@happeouikit/form-elements 2.0.0 → 2.2.1

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 ADDED
@@ -0,0 +1,128 @@
1
+ # Changelog
2
+
3
+ ## 2.2.1
4
+
5
+ - [Fixed] build dist
6
+
7
+ ## 2.2.0
8
+
9
+ - [Fixed] DatePicker. inability to control component by value prop
10
+ - [Fixed] DatePicker. focus loss on edit
11
+ - [Fixed] DatePicker. selected date highlight in the UI
12
+ - [Fixed] DatePicker. PropTypes
13
+ - [Fixed] DatePicker. disabled `react/jsx-props-no-spreading eslint rule`
14
+
15
+ ## 2.1.0
16
+
17
+ - [Added] CheckboxGroup component
18
+
19
+ ## 2.0.1
20
+
21
+ - [Fixed] InputNumber will only accept numerical value
22
+
23
+ ## 2.0.0
24
+
25
+ - [Fixed] updated versions for react, styled-components and other dependencies
26
+
27
+ ## 1.1.2
28
+
29
+ - [Fixed] build dist for DatePicker
30
+
31
+ ## 1.1.1
32
+
33
+ - [Fixed] inability to select year in DatePicker component
34
+ - [Fixed] checkbox label padding
35
+
36
+ ## 1.1.0
37
+
38
+ - [Added] `ref` forwarding to `Link` and `LinkExternal`
39
+
40
+ ## 1.0.28
41
+
42
+ - [Fixed] Input icon default sizes
43
+
44
+ ## 1.0.27
45
+
46
+ - [Fixed] build dist
47
+
48
+ ## 1.0.26
49
+
50
+ -[Fixed] the default locale was taken into account on init -[Fixed] use forward ref to remove error from console
51
+
52
+ ## 1.0.25
53
+
54
+ -[Added] Switch is now tabbable and can be toggled with keyboard.
55
+
56
+ ## 1.0.22
57
+
58
+ - [Fixed] build dist
59
+
60
+ ## 1.0.21
61
+
62
+ - [Added] increased size of checkbox
63
+
64
+ ## 1.0.20
65
+
66
+ - [Fixed] decreased react-intl package version
67
+
68
+ ## 1.0.19
69
+
70
+ - [Fixed] react-intl package
71
+
72
+ ## 1.0.18
73
+
74
+ - [Added] react-intl package
75
+
76
+ ## 1.0.17
77
+
78
+ - [Fixed] use our own buttons
79
+
80
+ ## 1.0.16
81
+
82
+ - [Fixed] some bugfixes in DatePicker
83
+
84
+ ## 1.0.15
85
+
86
+ - [Fixed] stop publishing the docs
87
+
88
+ ## 1.0.13
89
+
90
+ - [Added] Improved DatePicker component with year & month select.
91
+ - [Fixed] bugfixes in DatePicker
92
+ - [Added] More examples and clarifications to doc
93
+
94
+ ## 1.0.12
95
+
96
+ - [Added] css styles for disabled checkboxes
97
+
98
+ ## 1.0.11
99
+
100
+ - Publish
101
+
102
+ ## 1.0.10
103
+
104
+ - [Fixed] default state when using null
105
+
106
+ ## 1.0.9
107
+
108
+ - [Fixed] Enforce Checkbox content box
109
+
110
+ ## 1.0.8
111
+
112
+ - [Fixed] disabled state
113
+
114
+ ## 1.0.4
115
+
116
+ - [Fixed] show error border consistently
117
+
118
+ ## 1.0.3
119
+
120
+ - [Fixed] exported dropdownStyles correctly
121
+
122
+ ## 1.0.2
123
+
124
+ - [Fixed] exported dropdownStyles
125
+
126
+ ## 1.0.0
127
+
128
+ - Initial copy from the private kit
package/dist/Checkbox.js CHANGED
@@ -34,7 +34,14 @@ var Checkbox = function Checkbox(_ref) {
34
34
  };
35
35
 
36
36
  Checkbox.propTypes = {
37
- label: PropTypes.node
37
+ label: PropTypes.node,
38
+ value: PropTypes.string,
39
+ background: PropTypes.string
40
+ };
41
+ Checkbox.defaultProps = {
42
+ label: null,
43
+ value: undefined,
44
+ background: null
38
45
  };
39
46
  var StyledCheckbox = styled.span.withConfig({
40
47
  displayName: "Checkbox__StyledCheckbox",
@@ -0,0 +1,150 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import React, { useEffect, useMemo, useState } from "react";
4
+ import PropTypes from "prop-types";
5
+ import Checkbox from "./Checkbox";
6
+ import { devWarning, getValidChildrenArray, isString, useDevWarningOnce } from "./utils";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+
9
+ var getOptions = function getOptions(options) {
10
+ return options.map(function (option) {
11
+ return isString(option) ? {
12
+ label: option,
13
+ value: option
14
+ } : option;
15
+ });
16
+ };
17
+
18
+ var sortValuesByOrderInOptions = function sortValuesByOrderInOptions(options) {
19
+ return function (a, b) {
20
+ var indexA = options.findIndex(function (opt) {
21
+ return opt.value === a;
22
+ });
23
+ var indexB = options.findIndex(function (opt) {
24
+ return opt.value === b;
25
+ });
26
+ return indexA - indexB;
27
+ };
28
+ };
29
+
30
+ var getOptionsFromChildren = function getOptionsFromChildren(children) {
31
+ return getValidChildrenArray(children).map(function (_ref) {
32
+ var option = _ref.props;
33
+ return option;
34
+ });
35
+ };
36
+
37
+ var getChildrenDefaultValue = function getChildrenDefaultValue(options) {
38
+ return options.filter(function (_ref2) {
39
+ var defaultChecked = _ref2.defaultChecked;
40
+ return defaultChecked;
41
+ }).map(function (_ref3) {
42
+ var value = _ref3.value;
43
+ return value;
44
+ });
45
+ };
46
+
47
+ var optionsWarning = "[CheckboxGroup] Both the `children` and `options` props have been used.\n The `options` prop will be ignored. To get rid of this warning, remove one of these props.";
48
+ var defaultValueWarning = "[CheckboxGroup] Both the `defaultChecked` and `defaultValue` props have been used.\n The `defaultValue` prop will be ignored. To get rid of this warning, remove one of these props.";
49
+
50
+ var CheckboxGroup = function CheckboxGroup(_ref4) {
51
+ var value = _ref4.value,
52
+ disabled = _ref4.disabled,
53
+ name = _ref4.name,
54
+ children = _ref4.children,
55
+ className = _ref4.className,
56
+ rawOptions = _ref4.options,
57
+ onGroupChange = _ref4.onChange,
58
+ groupDefaultValue = _ref4.defaultValue;
59
+ useDevWarningOnce(children && rawOptions, optionsWarning);
60
+ var options = useMemo(function () {
61
+ return children ? getOptionsFromChildren(children) : getOptions(rawOptions);
62
+ }, [children, rawOptions]);
63
+ var defaultValue = useMemo(function () {
64
+ var childrenDefaultValue = getChildrenDefaultValue(options);
65
+ var hasChildrenDefaultValue = Boolean(childrenDefaultValue.length);
66
+
67
+ if (hasChildrenDefaultValue && groupDefaultValue) {
68
+ devWarning(defaultValueWarning);
69
+ }
70
+
71
+ return hasChildrenDefaultValue ? childrenDefaultValue : groupDefaultValue;
72
+ }, [options, groupDefaultValue]);
73
+
74
+ var _useState = useState(value || defaultValue || []),
75
+ _useState2 = _slicedToArray(_useState, 2),
76
+ groupValue = _useState2[0],
77
+ setGroupValue = _useState2[1];
78
+
79
+ useEffect(function () {
80
+ if (value) {
81
+ setGroupValue(value);
82
+ }
83
+ }, [value]);
84
+
85
+ var isChecked = function isChecked(optionValue) {
86
+ return groupValue.includes(optionValue);
87
+ };
88
+
89
+ var handleChange = function handleChange(option, event) {
90
+ if (option.onChange) {
91
+ option.onChange(event);
92
+ }
93
+
94
+ var newValue = event.target.checked ? [].concat(_toConsumableArray(groupValue), [option.value]) : groupValue.filter(function (val) {
95
+ return val !== option.value;
96
+ });
97
+ var newSortedValue = newValue.sort(sortValuesByOrderInOptions(options));
98
+ setGroupValue(newSortedValue);
99
+
100
+ if (onGroupChange) {
101
+ onGroupChange(newSortedValue);
102
+ }
103
+ };
104
+
105
+ return /*#__PURE__*/_jsx("div", {
106
+ className: className,
107
+ children: options.map(function (option) {
108
+ return /*#__PURE__*/_jsx(Checkbox, {
109
+ label: option.label,
110
+ name: name,
111
+ disabled: option.disabled || disabled,
112
+ checked: isChecked(option.value),
113
+ onChange: function onChange(event) {
114
+ return handleChange(option, event);
115
+ }
116
+ }, option.value);
117
+ })
118
+ });
119
+ };
120
+
121
+ var optionPropType = PropTypes.oneOfType([PropTypes.shape({
122
+ label: PropTypes.string,
123
+ value: PropTypes.string.isRequired,
124
+ onChange: PropTypes.func
125
+ }), PropTypes.string]);
126
+ CheckboxGroup.propTypes = {
127
+ className: PropTypes.string,
128
+ options: PropTypes.arrayOf(optionPropType),
129
+ onChange: PropTypes.func,
130
+ value: PropTypes.arrayOf(PropTypes.string),
131
+ defaultValue: PropTypes.arrayOf(PropTypes.string),
132
+ disabled: PropTypes.bool,
133
+ name: PropTypes.string,
134
+ children: PropTypes.oneOfType([PropTypes.shape({
135
+ type: PropTypes.oneOf([Checkbox])
136
+ }), PropTypes.arrayOf(PropTypes.shape({
137
+ type: PropTypes.oneOf([Checkbox])
138
+ }))])
139
+ };
140
+ CheckboxGroup.defaultProps = {
141
+ className: "",
142
+ options: null,
143
+ onChange: null,
144
+ value: null,
145
+ defaultValue: null,
146
+ disabled: false,
147
+ name: "",
148
+ children: null
149
+ };
150
+ export default CheckboxGroup;
@@ -1,6 +1,6 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  var _excluded = ["label", "locale", "width", "date", "type", "fromMonth", "disabledDays", "value", "pickerRef"],
5
5
  _excluded2 = ["children"];
6
6
 
@@ -23,15 +23,43 @@ import { margin200, padding300 } from "@happeouikit/layout";
23
23
  import { IconButton, ButtonSecondary } from "@happeouikit/buttons";
24
24
  import { IconChevronLeft, IconChevronRight, IconCalendar, IconCheck } from "@happeouikit/icons";
25
25
  import { radius500, shadow500 } from "@happeouikit/theme";
26
+ import { components } from "react-select";
26
27
  import Dropdown from "./Dropdown"; // CSS
27
28
 
28
29
  import "react-day-picker/lib/style.css";
29
30
  import messages from "./messages";
30
- import { components } from "react-select";
31
+ import { useDevWarningOnce } from "./utils";
31
32
  import { jsx as _jsx } from "react/jsx-runtime";
32
33
  import { jsxs as _jsxs } from "react/jsx-runtime";
33
34
  import { Fragment as _Fragment } from "react/jsx-runtime";
34
35
 
36
+ var formatValue = function formatValue(value, locale) {
37
+ if (!value) return null;
38
+ return moment(value).locale(locale).format("L");
39
+ };
40
+
41
+ var CustomInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
42
+ return /*#__PURE__*/_jsxs("div", {
43
+ style: {
44
+ display: "flex",
45
+ alignItems: "center"
46
+ },
47
+ children: [/*#__PURE__*/_jsx(IconCalendar, {
48
+ style: {
49
+ position: "absolute",
50
+ paddingLeft: "10px",
51
+ fill: gray03,
52
+ height: "20px",
53
+ width: "20px",
54
+ boxSizing: "content-box"
55
+ }
56
+ }), /*#__PURE__*/_jsx("input", _objectSpread({
57
+ "data-testid": "datepicker-input",
58
+ ref: ref
59
+ }, props))]
60
+ });
61
+ });
62
+
35
63
  var DatePicker = function DatePicker(_ref) {
36
64
  var label = _ref.label,
37
65
  locale = _ref.locale,
@@ -49,21 +77,21 @@ var DatePicker = function DatePicker(_ref) {
49
77
  month = _useState2[0],
50
78
  setMonth = _useState2[1];
51
79
 
80
+ var from = date.from,
81
+ to = date.to;
82
+ var formattedValue = formatValue(value || date[type], locale);
83
+ var isRangeMode = Boolean(from) && Boolean(to);
84
+ useDevWarningOnce(value && date[type], "[DatePicker] Both the `value` and `date` props have been used.\n The `date` prop will be ignored. To get rid of this warning, remove one of these props.");
85
+
52
86
  var onChangeMonthYear = function onChangeMonthYear(_ref2) {
53
87
  var month = _ref2.month,
54
88
  year = _ref2.year;
55
89
  setMonth(new Date(year, month));
56
90
  };
57
91
 
58
- if (!date.to || date.to === "") {
59
- date.to = value || "";
60
- }
61
-
62
- var to = date.to,
63
- from = date.from;
64
92
  return /*#__PURE__*/_jsxs(Wrapper, {
65
93
  width: width,
66
- hasRange: Boolean(from) && Boolean(to),
94
+ hasRange: isRangeMode,
67
95
  children: [label && /*#__PURE__*/_jsx("div", {
68
96
  style: {
69
97
  margin: "4px 0"
@@ -73,30 +101,26 @@ var DatePicker = function DatePicker(_ref) {
73
101
  children: label
74
102
  })
75
103
  }), /*#__PURE__*/_jsx(DayPickerInput, _objectSpread({
76
- component: /*#__PURE__*/React.forwardRef(function (props, ref) {
77
- return /*#__PURE__*/_jsx(CustomInput, _objectSpread({
78
- ref: ref
79
- }, props));
80
- }),
81
- value: date[type] && moment(date[type]).locale(locale).format("L"),
104
+ component: CustomInput,
105
+ value: formattedValue,
82
106
  formatDate: formatDate,
83
107
  parseDate: parseDate,
84
- placeholder: "".concat(formatDate(new Date(), "L", locale)),
108
+ placeholder: formatValue(new Date(), locale),
85
109
  dayPickerProps: {
86
110
  locale: locale,
87
111
  localeUtils: MomentLocaleUtils,
88
112
  className: "Range",
89
- disabledDays: type === "to" && from ? {
113
+ disabledDays: isRangeMode ? {
90
114
  before: from
91
115
  } : disabledDays,
92
116
  modifiers: {
93
117
  before: from,
94
118
  after: to
95
119
  },
96
- selectedDays: [date[type] && new Date(date[type]), {
120
+ selectedDays: isRangeMode ? {
97
121
  from: from,
98
122
  to: to
99
- }],
123
+ } : undefined,
100
124
  navbarElement: /*#__PURE__*/_jsx(CustomNavbar, {
101
125
  onChangeMonthYear: onChangeMonthYear,
102
126
  disabledDays: disabledDays
@@ -116,9 +140,15 @@ DatePicker.defaultProps = {
116
140
  from: "",
117
141
  to: ""
118
142
  },
119
- locale: "en-gb"
143
+ locale: "en-gb",
144
+ label: "",
145
+ width: undefined,
146
+ value: undefined,
147
+ pickerRef: undefined,
148
+ disabledDays: []
120
149
  };
121
150
  DatePicker.propTypes = {
151
+ fromMonth: PropTypes.instanceOf(Date),
122
152
  label: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
123
153
  locale: PropTypes.string,
124
154
  width: PropTypes.string,
@@ -138,13 +168,18 @@ DatePicker.propTypes = {
138
168
  if (typeof from === "undefined" || typeof to === "undefined") {
139
169
  return new Error("Date prop required. Format: { from: Date|number|string, to: Date|number|string }. ");
140
170
  }
171
+
172
+ return null;
141
173
  },
142
174
 
143
175
  /** Can be used to disable range of dates. Also restricts the year selector. Example: { after: new Date(2025, 0, 0), before: new Date(2020, 0, 0) } */
144
- disabledDays: PropTypes.object,
176
+ disabledDays: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.object)]),
145
177
 
146
178
  /** Can be used to tap a ref to the picker. See Range select code example how to utilise. */
147
- pickerRef: PropTypes.object
179
+ pickerRef: PropTypes.oneOfType([PropTypes.func, // eslint-disable-next-line react/forbid-prop-types
180
+ PropTypes.shape({
181
+ current: PropTypes.any
182
+ })])
148
183
  };
149
184
 
150
185
  var CustomNavbar = function CustomNavbar(_ref3) {
@@ -209,27 +244,6 @@ var CustomNavbar = function CustomNavbar(_ref3) {
209
244
  });
210
245
  };
211
246
 
212
- var CustomInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
213
- return /*#__PURE__*/_jsxs("div", {
214
- style: {
215
- display: "flex",
216
- alignItems: "center"
217
- },
218
- children: [/*#__PURE__*/_jsx(IconCalendar, {
219
- style: {
220
- position: "absolute",
221
- paddingLeft: "10px",
222
- fill: gray03,
223
- height: "20px",
224
- width: "20px",
225
- boxSizing: "content-box"
226
- }
227
- }), /*#__PURE__*/_jsx("input", _objectSpread({
228
- ref: ref
229
- }, props))]
230
- });
231
- });
232
-
233
247
  var MonthPicker = function MonthPicker(_ref4) {
234
248
  var date = _ref4.date,
235
249
  disabledDays = _ref4.disabledDays,
@@ -255,7 +269,7 @@ var MonthPicker = function MonthPicker(_ref4) {
255
269
 
256
270
  var fromYear = before ? new Date(before).getFullYear() + 1 : 1939;
257
271
  var toYear = after ? new Date(after).getFullYear() : new Date(currentYear + 10, 11).getFullYear();
258
- var years = [];
272
+ var years = []; // eslint-disable-next-line no-plusplus
259
273
 
260
274
  for (var i = toYear; i >= fromYear; i--) {
261
275
  years.push({
@@ -277,6 +291,9 @@ var MonthPicker = function MonthPicker(_ref4) {
277
291
  onMouseDown: function onMouseDown(e) {
278
292
  return e.stopPropagation();
279
293
  },
294
+ role: "option",
295
+ "aria-selected": true,
296
+ tabIndex: "0",
280
297
  children: /*#__PURE__*/_jsx(components.Option, _objectSpread(_objectSpread({}, props), {}, {
281
298
  children: children
282
299
  }))
@@ -366,16 +383,16 @@ var Wrapper = styled.div.withConfig({
366
383
  return width || "200px";
367
384
  }, shadow500, radius500, function (_ref9) {
368
385
  var hasRange = _ref9.hasRange;
369
- return hasRange && "\n background-color: ".concat(toBgLight(active), ";\n border-radius: 0;\n &:not(.DayPicker-Day--outside) {\n color: ").concat(gray01, ";\n }\n ");
386
+ return hasRange && css(["background-color:", ";border-radius:0;&:not(.DayPicker-Day--outside){color:", ";}"], toBgLight(active), gray01);
370
387
  }, active, white, function (_ref10) {
371
388
  var hasRange = _ref10.hasRange;
372
- return hasRange && "\n ::before {\n content: \"\";\n position: absolute;\n background-color: ".concat(toBgLight(active), ";\n width: 10px;\n height: 35px;\n top: 0;\n right: 0;\n z-index: -1;\n }\n ");
389
+ return hasRange && css(["::before{content:\"\";position:absolute;background-color:", ";width:10px;height:35px;top:0;right:0;z-index:-1;}"], toBgLight(active));
373
390
  }, function (_ref11) {
374
391
  var hasRange = _ref11.hasRange;
375
- return hasRange && "\n ::before {\n content: \"\";\n position: absolute;\n background-color: ".concat(toBgLight(active), ";\n width: 10px;\n height: 35px;\n top: 0;\n left: 0;\n z-index: -1;\n }\n ");
392
+ return hasRange && css(["::before{content:\"\";position:absolute;background-color:", ";width:10px;height:35px;top:0;left:0;z-index:-1;}"], toBgLight(active));
376
393
  }, active, white, sansFamily, gray06, black, gray06, active, active, sansFamily, gray01, function (_ref12) {
377
394
  var hasRange = _ref12.hasRange;
378
- return hasRange && "\n .DayPicker-Day--selected:not(.DayPicker-Day--before):not(.DayPicker-Day--after) {\n &:first-child {\n border-top-left-radius: ".concat(borderRadius, " !important;\n border-bottom-left-radius: ").concat(borderRadius, " !important;\n }\n &:last-child {\n border-top-right-radius: ").concat(borderRadius, " !important;\n border-bottom-right-radius: ").concat(borderRadius, " !important;\n }\n }\n ");
395
+ return hasRange && css([".DayPicker-Day--selected:not(.DayPicker-Day--before):not(.DayPicker-Day--after){&:first-child{border-top-left-radius:", " !important;border-bottom-left-radius:", " !important;}&:last-child{border-top-right-radius:", " !important;border-bottom-right-radius:", " !important;}}"], borderRadius, borderRadius, borderRadius, borderRadius);
379
396
  });
380
397
  var NavBarContainer = styled.div.withConfig({
381
398
  displayName: "DatePicker__NavBarContainer",
package/dist/Input.js CHANGED
@@ -88,8 +88,11 @@ var InputLabel = styled.div.withConfig({
88
88
  displayName: "Input__InputLabel",
89
89
  componentId: "sc-1izazxd-2"
90
90
  })(["margin:4px 0;"]);
91
- export var StyledInput = styled.input.attrs({
92
- type: "text"
91
+ export var StyledInput = styled.input.attrs(function (_ref2) {
92
+ var type = _ref2.type;
93
+ return {
94
+ type: type || "text"
95
+ };
93
96
  }).withConfig({
94
97
  displayName: "Input__StyledInput",
95
98
  componentId: "sc-1izazxd-3"
@@ -99,26 +102,26 @@ export var StyledInput = styled.input.attrs({
99
102
  "letter-spacing": "-0.3px",
100
103
  "font-size": "14px",
101
104
  "font-weight": "normal"
102
- }), sansFamily, gray06, function (_ref2) {
103
- var hasIcon = _ref2.hasIcon;
105
+ }), sansFamily, gray06, function (_ref3) {
106
+ var hasIcon = _ref3.hasIcon;
104
107
  return hasIcon ? "10px 12px 10px 38px" : "10px 12px";
105
- }, black, function (_ref3) {
106
- var _ref3$state = _ref3.state,
107
- state = _ref3$state === void 0 ? "default" : _ref3$state;
108
- return state === "default" ? gray04 : inputStates[state];
109
- }, function (_ref4) {
108
+ }, black, function (_ref4) {
110
109
  var _ref4$state = _ref4.state,
111
110
  state = _ref4$state === void 0 ? "default" : _ref4$state;
112
- return state === "default" ? active : inputStates[state];
111
+ return state === "default" ? gray04 : inputStates[state];
113
112
  }, function (_ref5) {
114
113
  var _ref5$state = _ref5.state,
115
114
  state = _ref5$state === void 0 ? "default" : _ref5$state;
116
115
  return state === "default" ? active : inputStates[state];
117
- }, gray08, gray05, placeholder({
118
- color: gray05
119
- }), function (_ref6) {
116
+ }, function (_ref6) {
120
117
  var _ref6$state = _ref6.state,
121
118
  state = _ref6$state === void 0 ? "default" : _ref6$state;
119
+ return state === "default" ? active : inputStates[state];
120
+ }, gray08, gray05, placeholder({
121
+ color: gray05
122
+ }), function (_ref7) {
123
+ var _ref7$state = _ref7.state,
124
+ state = _ref7$state === void 0 ? "default" : _ref7$state;
122
125
  return inputStates[state];
123
126
  });
124
127
  var InputIconWrapper = styled.span.withConfig({
@@ -129,22 +132,22 @@ var InputIconWrapper = styled.span.withConfig({
129
132
  * Number Input
130
133
  */
131
134
 
132
- export var InputNumber = function InputNumber(_ref7) {
133
- var label = _ref7.label,
134
- props = _objectWithoutProperties(_ref7, _excluded2);
135
+ export var InputNumber = function InputNumber(_ref8) {
136
+ var label = _ref8.label,
137
+ props = _objectWithoutProperties(_ref8, _excluded2);
135
138
 
136
139
  return /*#__PURE__*/_jsxs(InputNumberContainer, {
137
- children: [/*#__PURE__*/_jsx(StyledInputNumber, _objectSpread({}, props)), label && /*#__PURE__*/_jsx(InputNumberLabel, {
140
+ children: [/*#__PURE__*/_jsx(StyledInputNumber, _objectSpread(_objectSpread({}, props), {}, {
141
+ type: "number"
142
+ })), label && /*#__PURE__*/_jsx(InputNumberLabel, {
138
143
  children: label
139
144
  })]
140
145
  });
141
146
  };
142
- var StyledInputNumber = styled(Input).attrs({
143
- pattern: "[0-9.]+"
144
- }).withConfig({
147
+ var StyledInputNumber = styled(Input).withConfig({
145
148
  displayName: "Input__StyledInputNumber",
146
149
  componentId: "sc-1izazxd-5"
147
- })(["width:40px;text-align:center;font-size:14px;"]);
150
+ })(["width:60px;text-align:center;font-size:14px;"]);
148
151
  var InputNumberContainer = styled.div.withConfig({
149
152
  displayName: "Input__InputNumberContainer",
150
153
  componentId: "sc-1izazxd-6"
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ export { default as Dropdown, dropdownStyles } from "./Dropdown";
3
3
  export * from "./Link";
4
4
  export { default as Switch } from "./Switch";
5
5
  export { default as Checkbox } from "./Checkbox";
6
+ export { default as CheckboxGroup } from "./CheckboxGroup";
6
7
  export { default as RadioButton } from "./RadioButton";
7
8
  export { default as Textarea } from "./Textarea";
8
9
  export { default as Tag } from "./Tag";
package/dist/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import React, { useEffect } from "react";
1
2
  export var toCamelCase = function toCamelCase(str) {
2
3
  return str.replace(/(_|-|,|\.)(.)/g, function (match) {
3
4
  return match[1].toUpperCase();
@@ -24,4 +25,24 @@ export var sanitiseHashtag = function sanitiseHashtag(hashtag) {
24
25
  export var addHashSign = function addHashSign(input) {
25
26
  if (input.startsWith("#")) return input;
26
27
  return "#" + input;
28
+ };
29
+ export var isString = function isString(value) {
30
+ return typeof value === "string";
31
+ };
32
+ export var getValidChildrenArray = function getValidChildrenArray(children) {
33
+ return React.Children.toArray(children).filter(React.isValidElement);
34
+ };
35
+ export var devWarning = function devWarning(message) {
36
+ if (process.env.NODE_ENV !== "production") {
37
+ // eslint-disable-next-line no-console
38
+ console.warn("HappeoUiKit/form-elements: ".concat(message));
39
+ }
40
+ };
41
+ export var useDevWarningOnce = function useDevWarningOnce(shouldWarn, message) {
42
+ useEffect(function () {
43
+ if (shouldWarn) {
44
+ devWarning(message);
45
+ } // eslint-disable-next-line
46
+
47
+ }, []);
27
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happeouikit/form-elements",
3
- "version": "2.0.0",
3
+ "version": "2.2.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
@@ -34,6 +34,8 @@
34
34
  "@babel/plugin-proposal-unicode-property-regex": "^7.16.0"
35
35
  },
36
36
  "peerDependencies": {
37
+ "@testing-library/jest-dom": "^5.14.1",
38
+ "@testing-library/react": "^10.2.1",
37
39
  "prop-types": "^15.7.2",
38
40
  "react": "^17.0.2",
39
41
  "styled-components": "^5.3.3"