@happeouikit/form-elements 2.2.1 → 2.3.0
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 +4 -0
- package/dist/Badge.js +1 -1
- package/dist/Checkbox.js +29 -12
- package/dist/DatePicker.js +11 -13
- package/dist/DateTimePicker.js +82 -57
- package/dist/Dropdown.js +5 -6
- package/dist/Input.js +5 -7
- package/dist/Link.js +6 -6
- package/dist/RadioButton.js +2 -3
- package/dist/Switch.js +4 -5
- package/dist/Tag.js +3 -4
- package/dist/Textarea.js +2 -3
- package/dist/Typeahead/Typeahead.js +234 -0
- package/dist/Typeahead/TypeaheadDropdown.js +27 -0
- package/dist/Typeahead/TypeaheadError.js +16 -0
- package/dist/Typeahead/TypeaheadList.js +37 -0
- package/dist/Typeahead/TypeaheadLoading.js +26 -0
- package/dist/Typeahead/TypeaheadMessage.js +41 -0
- package/dist/Typeahead/TypeaheadNoResults.js +19 -0
- package/dist/Typeahead/messages.js +29 -0
- package/dist/index.js +2 -1
- package/dist/utils.js +1 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
package/dist/Badge.js
CHANGED
|
@@ -25,7 +25,7 @@ var Badge = function Badge(_ref) {
|
|
|
25
25
|
|
|
26
26
|
var Wrapper = styled.span.withConfig({
|
|
27
27
|
displayName: "Badge__Wrapper",
|
|
28
|
-
componentId: "
|
|
28
|
+
componentId: "xyqvne-0"
|
|
29
29
|
})(["display:inline-block;background:", ";padding:4px 8px;border-radius:100px;"], function (_ref2) {
|
|
30
30
|
var color = _ref2.color,
|
|
31
31
|
isFilled = _ref2.isFilled;
|
package/dist/Checkbox.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["label", "background"];
|
|
4
3
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
6
5
|
|
|
7
6
|
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
7
|
|
|
9
|
-
import React from "react";
|
|
8
|
+
import React, { useRef } from "react";
|
|
10
9
|
import styled from "styled-components";
|
|
11
10
|
import PropTypes from "prop-types";
|
|
12
11
|
import { white, active, gray01, gray06, gray08 } from "@happeouikit/colors";
|
|
@@ -18,14 +17,32 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
18
17
|
var Checkbox = function Checkbox(_ref) {
|
|
19
18
|
var label = _ref.label,
|
|
20
19
|
background = _ref.background,
|
|
21
|
-
props = _objectWithoutProperties(_ref,
|
|
20
|
+
props = _objectWithoutProperties(_ref, ["label", "background"]);
|
|
21
|
+
|
|
22
|
+
var checkboxRef = useRef();
|
|
23
|
+
|
|
24
|
+
var onKeyDown = function onKeyDown(event) {
|
|
25
|
+
if (event.key.match(/enter|spacebar|\W{1}/i)) {
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
checkboxRef.current.checked = !checkboxRef.current.checked;
|
|
28
|
+
|
|
29
|
+
if (typeof props.onChange === "function") {
|
|
30
|
+
props.onChange(event);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
22
34
|
|
|
23
35
|
return /*#__PURE__*/_jsxs(CheckboxWrapper, {
|
|
24
36
|
background: background,
|
|
25
37
|
disabled: props.disabled,
|
|
26
38
|
children: [/*#__PURE__*/_jsx("input", _objectSpread({
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
ref: checkboxRef,
|
|
40
|
+
type: "checkbox",
|
|
41
|
+
tabIndex: "-1"
|
|
42
|
+
}, props)), /*#__PURE__*/_jsx(StyledCheckbox, _objectSpread({
|
|
43
|
+
onKeyDown: onKeyDown,
|
|
44
|
+
tabIndex: 0
|
|
45
|
+
}, props, {
|
|
29
46
|
children: /*#__PURE__*/_jsx(Checkmark, {})
|
|
30
47
|
})), label && /*#__PURE__*/_jsx(Label, {
|
|
31
48
|
children: label
|
|
@@ -45,16 +62,16 @@ Checkbox.defaultProps = {
|
|
|
45
62
|
};
|
|
46
63
|
var StyledCheckbox = styled.span.withConfig({
|
|
47
64
|
displayName: "Checkbox__StyledCheckbox",
|
|
48
|
-
componentId: "
|
|
49
|
-
})(["cursor:pointer;position:absolute;height:18px;width:18px;border-radius:3px;background-color:", ";border:2px solid ", ";box-sizing:content-box !important;"], white, gray06);
|
|
65
|
+
componentId: "tc08iy-0"
|
|
66
|
+
})(["cursor:pointer;position:absolute;height:18px;width:18px;border-radius:3px;background-color:", ";border:2px solid ", ";box-sizing:content-box !important;&:focus-visible{outline:0;box-shadow:0 0 0 1px ", ";}"], white, gray06, active);
|
|
50
67
|
var Checkmark = styled(IconCheck).withConfig({
|
|
51
68
|
displayName: "Checkbox__Checkmark",
|
|
52
|
-
componentId: "
|
|
69
|
+
componentId: "tc08iy-1"
|
|
53
70
|
})(["position:absolute;display:none;fill:", ";width:18px;height:16px;top:50%;transform:translateY(-50%);"], white);
|
|
54
71
|
var CheckboxWrapper = styled.label.withConfig({
|
|
55
72
|
displayName: "Checkbox__CheckboxWrapper",
|
|
56
|
-
componentId: "
|
|
57
|
-
})(["display:flex;align-items:center;position:relative;cursor:", ";user-select:none;padding:4px 0;input{
|
|
73
|
+
componentId: "tc08iy-2"
|
|
74
|
+
})(["display:flex;align-items:center;position:relative;cursor:", ";user-select:none;padding:4px 0;input{opacity:0;width:0;height:0;}input:checked + ", "{background:", ";border:", ";}input:checked + ", " > svg{display:block;}input:disabled + ", "{cursor:not-allowed;background:", ";border:2px solid ", ";}input:disabled ~ p{color:", ";}"], function (_ref2) {
|
|
58
75
|
var disabled = _ref2.disabled;
|
|
59
76
|
return disabled ? "not-allowed" : " pointer";
|
|
60
77
|
}, StyledCheckbox, function (_ref3) {
|
|
@@ -66,6 +83,6 @@ var CheckboxWrapper = styled.label.withConfig({
|
|
|
66
83
|
}, StyledCheckbox, StyledCheckbox, gray08, gray08, gray06);
|
|
67
84
|
var Label = styled(TextZeta).withConfig({
|
|
68
85
|
displayName: "Checkbox__Label",
|
|
69
|
-
componentId: "
|
|
86
|
+
componentId: "tc08iy-3"
|
|
70
87
|
})(["display:inline-block;position:relative;margin-left:30px;color:", ";"], gray01);
|
|
71
88
|
export default Checkbox;
|
package/dist/DatePicker.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
var _excluded = ["label", "locale", "width", "date", "type", "fromMonth", "disabledDays", "value", "pickerRef"],
|
|
5
|
-
_excluded2 = ["children"];
|
|
6
4
|
|
|
7
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
8
6
|
|
|
9
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; }
|
|
10
8
|
|
|
@@ -70,7 +68,7 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
70
68
|
disabledDays = _ref.disabledDays,
|
|
71
69
|
value = _ref.value,
|
|
72
70
|
pickerRef = _ref.pickerRef,
|
|
73
|
-
props = _objectWithoutProperties(_ref,
|
|
71
|
+
props = _objectWithoutProperties(_ref, ["label", "locale", "width", "date", "type", "fromMonth", "disabledDays", "value", "pickerRef"]);
|
|
74
72
|
|
|
75
73
|
var _useState = useState(fromMonth),
|
|
76
74
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -285,7 +283,7 @@ var MonthPicker = function MonthPicker(_ref4) {
|
|
|
285
283
|
|
|
286
284
|
var DropdownYearOption = function DropdownYearOption(_ref6) {
|
|
287
285
|
var children = _ref6.children,
|
|
288
|
-
props = _objectWithoutProperties(_ref6,
|
|
286
|
+
props = _objectWithoutProperties(_ref6, ["children"]);
|
|
289
287
|
|
|
290
288
|
return components.Option && /*#__PURE__*/_jsx("div", {
|
|
291
289
|
onMouseDown: function onMouseDown(e) {
|
|
@@ -294,7 +292,7 @@ var MonthPicker = function MonthPicker(_ref4) {
|
|
|
294
292
|
role: "option",
|
|
295
293
|
"aria-selected": true,
|
|
296
294
|
tabIndex: "0",
|
|
297
|
-
children: /*#__PURE__*/_jsx(components.Option, _objectSpread(
|
|
295
|
+
children: /*#__PURE__*/_jsx(components.Option, _objectSpread({}, props, {
|
|
298
296
|
children: children
|
|
299
297
|
}))
|
|
300
298
|
});
|
|
@@ -353,23 +351,23 @@ var MonthPicker = function MonthPicker(_ref4) {
|
|
|
353
351
|
|
|
354
352
|
var YearMonthSelectContainer = styled.div.withConfig({
|
|
355
353
|
displayName: "DatePicker__YearMonthSelectContainer",
|
|
356
|
-
componentId: "
|
|
354
|
+
componentId: "ce3xgi-0"
|
|
357
355
|
})(["position:absolute;z-index:1;top:0;bottom:0;left:0;right:0;background-color:", ";padding:", ";"], white, padding300);
|
|
358
356
|
var ActionList = styled.div.withConfig({
|
|
359
357
|
displayName: "DatePicker__ActionList",
|
|
360
|
-
componentId: "
|
|
358
|
+
componentId: "ce3xgi-1"
|
|
361
359
|
})(["display:flex;align-items:center;justify-content:flex-end;margin-top:", ";"], padding300);
|
|
362
360
|
var YearSelectContainer = styled.div.withConfig({
|
|
363
361
|
displayName: "DatePicker__YearSelectContainer",
|
|
364
|
-
componentId: "
|
|
362
|
+
componentId: "ce3xgi-2"
|
|
365
363
|
})(["align-items:center;justify-content:center;margin-bottom:", ";> div{width:100%;}"], margin200);
|
|
366
364
|
var MonthUl = styled.ul.withConfig({
|
|
367
365
|
displayName: "DatePicker__MonthUl",
|
|
368
|
-
componentId: "
|
|
366
|
+
componentId: "ce3xgi-3"
|
|
369
367
|
})(["display:grid;grid-template-columns:1fr 1fr 1fr 1fr;grid-gap:8px;width:100%;margin:", " 0 0 0;padding:0;list-style:none;li{width:100%;}"], padding300);
|
|
370
368
|
var MonthSelectButton2 = styled(ButtonSecondary).withConfig({
|
|
371
369
|
displayName: "DatePicker__MonthSelectButton2",
|
|
372
|
-
componentId: "
|
|
370
|
+
componentId: "ce3xgi-4"
|
|
373
371
|
})(["padding:8px;", ""], function (_ref7) {
|
|
374
372
|
var $isActive = _ref7.$isActive;
|
|
375
373
|
return $isActive && css(["background-color:", ";p{color:", ";font-weight:bold;}"], lighten(active, 0.9), active);
|
|
@@ -377,7 +375,7 @@ var MonthSelectButton2 = styled(ButtonSecondary).withConfig({
|
|
|
377
375
|
var borderRadius = "100px";
|
|
378
376
|
var Wrapper = styled.div.withConfig({
|
|
379
377
|
displayName: "DatePicker__Wrapper",
|
|
380
|
-
componentId: "
|
|
378
|
+
componentId: "ce3xgi-5"
|
|
381
379
|
})(["display:flex;flex-direction:column;width:", ";.DayPickerInput-Overlay{margin-top:8px;box-shadow:", ";border-radius:", ";}.DayPickerInput{.Range{.DayPicker-Day{min-width:21px;:focus{outline:none;}&.DayPicker-Day--selected:not(.DayPicker-Day--before):not(.DayPicker-Day--after){", "}&.DayPicker-Day--selected{background-color:", ";color:", ";}&.DayPicker-Day--before{position:relative;", "}&.DayPicker-Day--after{position:relative;", "}&.DayPicker-Day--today:not(.DayPicker-Day--selected){color:", ";}&.DayPicker-Day--outside{&.DayPicker-Day--before,&.DayPicker-Day--after{color:", ";}}}}input{font-family:", ";width:100%;border-radius:4px;border:solid 1px ", ";box-sizing:border-box;box-shadow:none;font-size:14px;padding:9px 12px 9px 38px;font-weight:normal;font-style:normal;font-stretch:normal;line-height:1.43;letter-spacing:0.3px;color:", ";:hover{border-color:", ";}:active{outline:none;box-shadow:none;border-color:", ";}:focus{outline:none;border-color:", ";}}.DayPicker-wrapper{font-family:", ";color:", ";letter-spacing:-0.3px;font-size:14px;font-weight:normal;}.DayPicker-Week{", " .DayPicker-Day--selected{&:first-child{&.DayPicker-Day--after{::before{content:none;}}}&:last-child{&.DayPicker-Day--before{::before{content:none;}}}}}.DayPicker-Caption{display:none;}}"], function (_ref8) {
|
|
382
380
|
var width = _ref8.width;
|
|
383
381
|
return width || "200px";
|
|
@@ -396,6 +394,6 @@ var Wrapper = styled.div.withConfig({
|
|
|
396
394
|
});
|
|
397
395
|
var NavBarContainer = styled.div.withConfig({
|
|
398
396
|
displayName: "DatePicker__NavBarContainer",
|
|
399
|
-
componentId: "
|
|
397
|
+
componentId: "ce3xgi-6"
|
|
400
398
|
})(["display:flex;align-items:center;justify-content:space-between;padding:16px 14px 0px 14px;"]);
|
|
401
399
|
export default DatePicker;
|
package/dist/DateTimePicker.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/* eslint-disable radix */
|
|
4
|
+
import React, { useState, useCallback } from "react";
|
|
3
5
|
import styled from "styled-components";
|
|
4
6
|
import moment from "moment";
|
|
5
7
|
import debounce from "lodash.debounce";
|
|
@@ -33,8 +35,8 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
33
35
|
|
|
34
36
|
var _useState5 = useState(inputMode),
|
|
35
37
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
selectedMode = _useState6[0],
|
|
39
|
+
setSelectedMode = _useState6[1];
|
|
38
40
|
|
|
39
41
|
var _useState7 = useState(DEFAULT_INPUT_STATE),
|
|
40
42
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
@@ -51,25 +53,11 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
51
53
|
timeValue = _useState12[0],
|
|
52
54
|
setTimeValue = _useState12[1];
|
|
53
55
|
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
var handleTimeSelected = function handleTimeSelected(time) {
|
|
60
|
-
if (time.length !== 2) {
|
|
61
|
-
setTimeInputState("error");
|
|
62
|
-
setTimeInputErrorMessage(intl.formatMessage(messages.wrongFormat));
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
setSelectedTime(time);
|
|
67
|
-
setDateTime();
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
var validateTime = function validateTime(time) {
|
|
56
|
+
var validateTime = useCallback(function (_ref2) {
|
|
57
|
+
var time = _ref2.time,
|
|
58
|
+
mode = _ref2.mode;
|
|
71
59
|
var hour = parseInt(time[0]);
|
|
72
|
-
var minute = parseInt(time[1]);
|
|
60
|
+
var minute = parseInt(time[1]); // eslint-disable-next-line no-restricted-globals
|
|
73
61
|
|
|
74
62
|
if (isNaN(hour) || isNaN(minute)) {
|
|
75
63
|
setTimeInputState("error");
|
|
@@ -77,7 +65,10 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
77
65
|
return false;
|
|
78
66
|
}
|
|
79
67
|
|
|
80
|
-
|
|
68
|
+
var regex = new RegExp(mode === "24h" ? "([0-1][0-9]{1}|[2][0-3]{1}):([0-5]{1}[0-9]{1})" : "([0][1-9]|[1][0-2]{1}):([0-5]{1}[0-9]{1})");
|
|
69
|
+
var timeValue = hour < 10 ? "0".concat(hour, ":").concat(time[1]) : "".concat(hour, ":").concat(time[1]);
|
|
70
|
+
|
|
71
|
+
if (!regex.test(timeValue)) {
|
|
81
72
|
setTimeInputState("error");
|
|
82
73
|
setTimeInputErrorMessage(intl.formatMessage(messages.invalidTime));
|
|
83
74
|
return false;
|
|
@@ -85,36 +76,20 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
85
76
|
|
|
86
77
|
setTimeInputState(DEFAULT_INPUT_STATE);
|
|
87
78
|
return true;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
var
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (timeString.match(TIME_REGEX)) {
|
|
104
|
-
newTime = "".concat(timeString.slice(0, 2), ":").concat(timeString.slice(2));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
setTimeValue(newTime);
|
|
108
|
-
handleTimeSelectedDebounced(newTime.split(":"));
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
var setDateTime = function setDateTime() {
|
|
112
|
-
if (!selectedTime || !mode) return;
|
|
113
|
-
if (!validateTime(selectedTime)) return;
|
|
114
|
-
if (!selectedDate) return;
|
|
115
|
-
var hour = parseInt(selectedTime[0]);
|
|
116
|
-
var minute = parseInt(selectedTime[1]);
|
|
117
|
-
var selectedDateTime = moment(selectedDate);
|
|
79
|
+
}, [intl]);
|
|
80
|
+
var setDateTime = useCallback(function (_ref3) {
|
|
81
|
+
var date = _ref3.date,
|
|
82
|
+
time = _ref3.time,
|
|
83
|
+
mode = _ref3.mode;
|
|
84
|
+
if (!time || !mode) return;
|
|
85
|
+
if (!validateTime({
|
|
86
|
+
time: time,
|
|
87
|
+
mode: mode
|
|
88
|
+
})) return;
|
|
89
|
+
if (!date) return;
|
|
90
|
+
var hour = parseInt(time[0]);
|
|
91
|
+
var minute = parseInt(time[1]);
|
|
92
|
+
var selectedDateTime = moment(date);
|
|
118
93
|
|
|
119
94
|
if (mode === "am" && hour === 12) {
|
|
120
95
|
selectedDateTime.hour(0);
|
|
@@ -128,8 +103,56 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
128
103
|
|
|
129
104
|
selectedDateTime.minute(minute);
|
|
130
105
|
if (onChange) onChange(selectedDateTime.toDate());
|
|
131
|
-
};
|
|
106
|
+
}, [onChange, validateTime]);
|
|
107
|
+
var handleDateSelected = useCallback(function (date) {
|
|
108
|
+
setSelectedDate(date);
|
|
109
|
+
setDateTime({
|
|
110
|
+
date: date,
|
|
111
|
+
time: selectedTime,
|
|
112
|
+
mode: selectedMode
|
|
113
|
+
});
|
|
114
|
+
}, [selectedMode, selectedTime, setDateTime]);
|
|
115
|
+
var handleOnKeyPress = useCallback(function (event) {
|
|
116
|
+
if (event.charCode < 48 || event.charCode > 58) {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
}
|
|
119
|
+
}, []);
|
|
120
|
+
var handleTimeSelected = useCallback(function (time) {
|
|
121
|
+
if (time.length !== 2) {
|
|
122
|
+
setTimeInputState("error");
|
|
123
|
+
setTimeInputErrorMessage(intl.formatMessage(messages.wrongFormat));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
132
126
|
|
|
127
|
+
setSelectedTime(time);
|
|
128
|
+
setDateTime({
|
|
129
|
+
date: selectedDate,
|
|
130
|
+
time: time,
|
|
131
|
+
mode: selectedMode
|
|
132
|
+
});
|
|
133
|
+
}, [intl, selectedDate, selectedMode, setDateTime]);
|
|
134
|
+
var onChangeMode = useCallback(function (_ref4) {
|
|
135
|
+
var value = _ref4.value;
|
|
136
|
+
setSelectedMode(value);
|
|
137
|
+
setDateTime({
|
|
138
|
+
date: selectedDate,
|
|
139
|
+
time: selectedTime,
|
|
140
|
+
mode: value
|
|
141
|
+
});
|
|
142
|
+
}, [selectedDate, selectedTime, setDateTime]);
|
|
143
|
+
var handleTimeSelectedDebounced = debounce(handleTimeSelected, 500);
|
|
144
|
+
var onChangeTime = useCallback(function (event) {
|
|
145
|
+
var timeString = event.target.value;
|
|
146
|
+
var newTime = timeString;
|
|
147
|
+
setTimeInputState(DEFAULT_INPUT_STATE);
|
|
148
|
+
|
|
149
|
+
if (timeString.match(TIME_REGEX)) {
|
|
150
|
+
newTime = "".concat(timeString.slice(0, 2), ":").concat(timeString.slice(2));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
setTimeValue(newTime);
|
|
154
|
+
handleTimeSelectedDebounced(newTime.split(":"));
|
|
155
|
+
}, [handleTimeSelectedDebounced]);
|
|
133
156
|
return /*#__PURE__*/_jsxs(Wrapper, {
|
|
134
157
|
children: [/*#__PURE__*/_jsx(DatePicker, {
|
|
135
158
|
width: "100%",
|
|
@@ -142,7 +165,8 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
142
165
|
onChange: onChangeTime,
|
|
143
166
|
state: timeInputState,
|
|
144
167
|
errorMessage: timeInputErrorMessage,
|
|
145
|
-
value: timeValue
|
|
168
|
+
value: timeValue,
|
|
169
|
+
onKeyPress: handleOnKeyPress
|
|
146
170
|
}), /*#__PURE__*/_jsx("div", {
|
|
147
171
|
style: {
|
|
148
172
|
paddingTop: "28px"
|
|
@@ -170,14 +194,15 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
170
194
|
|
|
171
195
|
var Wrapper = styled.div.withConfig({
|
|
172
196
|
displayName: "DateTimePicker__Wrapper",
|
|
173
|
-
componentId: "
|
|
197
|
+
componentId: "sdui13-0"
|
|
174
198
|
})(["display:grid;grid-template-columns:180px 90px 90px;column-gap:8px;"]);
|
|
175
199
|
DateTimePicker.propTypes = {
|
|
176
200
|
onChange: PropTypes.func.isRequired,
|
|
177
201
|
label: PropTypes.string,
|
|
178
|
-
|
|
202
|
+
inputMode: PropTypes.oneOf(["am", "pm", "24h"])
|
|
179
203
|
};
|
|
180
204
|
DateTimePicker.defaultProps = {
|
|
181
|
-
inputMode: "am"
|
|
205
|
+
inputMode: "am",
|
|
206
|
+
label: undefined
|
|
182
207
|
};
|
|
183
208
|
export default DateTimePicker;
|
package/dist/Dropdown.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["label"];
|
|
4
3
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
6
5
|
|
|
7
6
|
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
7
|
|
|
@@ -18,7 +17,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
18
17
|
|
|
19
18
|
var Dropdown = function Dropdown(_ref, ref) {
|
|
20
19
|
var label = _ref.label,
|
|
21
|
-
props = _objectWithoutProperties(_ref,
|
|
20
|
+
props = _objectWithoutProperties(_ref, ["label"]);
|
|
22
21
|
|
|
23
22
|
var dropdownRef = useRef();
|
|
24
23
|
useImperativeHandle(ref, function () {
|
|
@@ -47,7 +46,7 @@ var Dropdown = function Dropdown(_ref, ref) {
|
|
|
47
46
|
};
|
|
48
47
|
|
|
49
48
|
var DropdownIndicator = function DropdownIndicator(props) {
|
|
50
|
-
return components.DropdownIndicator && /*#__PURE__*/_jsx(components.DropdownIndicator, _objectSpread(
|
|
49
|
+
return components.DropdownIndicator && /*#__PURE__*/_jsx(components.DropdownIndicator, _objectSpread({}, props, {
|
|
51
50
|
children: /*#__PURE__*/_jsx(IconArrowDropDown, {
|
|
52
51
|
width: "24px",
|
|
53
52
|
height: "24px",
|
|
@@ -62,10 +61,10 @@ export var dropdownStyles = css(["min-width:200px;width:auto;font-family:", ";le
|
|
|
62
61
|
});
|
|
63
62
|
var StyledDropdown = styled(Select).withConfig({
|
|
64
63
|
displayName: "Dropdown__StyledDropdown",
|
|
65
|
-
componentId: "
|
|
64
|
+
componentId: "pcee56-0"
|
|
66
65
|
})(["", ""], dropdownStyles);
|
|
67
66
|
var Label = styled.div.withConfig({
|
|
68
67
|
displayName: "Dropdown__Label",
|
|
69
|
-
componentId: "
|
|
68
|
+
componentId: "pcee56-1"
|
|
70
69
|
})(["margin:4px 0;"]);
|
|
71
70
|
export default /*#__PURE__*/forwardRef(Dropdown);
|
package/dist/Input.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["label", "icon", "iconProps", "state", "errorMessage"],
|
|
4
|
-
_excluded2 = ["label"];
|
|
5
3
|
|
|
6
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
7
5
|
|
|
8
6
|
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; }
|
|
9
7
|
|
|
@@ -30,7 +28,7 @@ export var Input = function Input(_ref) {
|
|
|
30
28
|
iconProps = _ref.iconProps,
|
|
31
29
|
state = _ref.state,
|
|
32
30
|
errorMessage = _ref.errorMessage,
|
|
33
|
-
rest = _objectWithoutProperties(_ref,
|
|
31
|
+
rest = _objectWithoutProperties(_ref, ["label", "icon", "iconProps", "state", "errorMessage"]);
|
|
34
32
|
|
|
35
33
|
return /*#__PURE__*/_jsxs(Container, {
|
|
36
34
|
children: [!!label && /*#__PURE__*/_jsx(InputLabel, {
|
|
@@ -69,7 +67,7 @@ function iconWrapper(IconComponent, iconProps) {
|
|
|
69
67
|
var props = Object.assign({}, iconDefaults, iconProps);
|
|
70
68
|
return function () {
|
|
71
69
|
return /*#__PURE__*/_jsx(InputIconWrapper, {
|
|
72
|
-
children: /*#__PURE__*/_jsx(IconComponent, _objectSpread(
|
|
70
|
+
children: /*#__PURE__*/_jsx(IconComponent, _objectSpread({}, props, {
|
|
73
71
|
style: style
|
|
74
72
|
}))
|
|
75
73
|
});
|
|
@@ -134,10 +132,10 @@ var InputIconWrapper = styled.span.withConfig({
|
|
|
134
132
|
|
|
135
133
|
export var InputNumber = function InputNumber(_ref8) {
|
|
136
134
|
var label = _ref8.label,
|
|
137
|
-
props = _objectWithoutProperties(_ref8,
|
|
135
|
+
props = _objectWithoutProperties(_ref8, ["label"]);
|
|
138
136
|
|
|
139
137
|
return /*#__PURE__*/_jsxs(InputNumberContainer, {
|
|
140
|
-
children: [/*#__PURE__*/_jsx(StyledInputNumber, _objectSpread(
|
|
138
|
+
children: [/*#__PURE__*/_jsx(StyledInputNumber, _objectSpread({}, props, {
|
|
141
139
|
type: "number"
|
|
142
140
|
})), label && /*#__PURE__*/_jsx(InputNumberLabel, {
|
|
143
141
|
children: label
|
package/dist/Link.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
5
|
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; }
|
|
6
6
|
|
|
@@ -11,26 +11,26 @@ import { BodyUI } from "@happeouikit/typography";
|
|
|
11
11
|
import { active } from "@happeouikit/colors";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
export var Link = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
14
|
-
return /*#__PURE__*/_jsx(StyledLink, _objectSpread(
|
|
14
|
+
return /*#__PURE__*/_jsx(StyledLink, _objectSpread({
|
|
15
15
|
ref: ref,
|
|
16
16
|
as: "a"
|
|
17
|
-
}, props
|
|
17
|
+
}, props, {
|
|
18
18
|
children: props.children
|
|
19
19
|
}));
|
|
20
20
|
});
|
|
21
21
|
export var LinkExternal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
22
|
-
return /*#__PURE__*/_jsx(StyledLink, _objectSpread(
|
|
22
|
+
return /*#__PURE__*/_jsx(StyledLink, _objectSpread({
|
|
23
23
|
ref: ref,
|
|
24
24
|
as: "a",
|
|
25
25
|
target: "_blank",
|
|
26
26
|
rel: "nofollow noopener"
|
|
27
|
-
}, props
|
|
27
|
+
}, props, {
|
|
28
28
|
children: props.children
|
|
29
29
|
}));
|
|
30
30
|
});
|
|
31
31
|
var StyledLink = styled(BodyUI).withConfig({
|
|
32
32
|
displayName: "Link__StyledLink",
|
|
33
|
-
componentId: "
|
|
33
|
+
componentId: "jezurh-0"
|
|
34
34
|
})(["text-decoration:", ";color:", ";:hover{color:", ";text-decoration:underline;}"], function (_ref) {
|
|
35
35
|
var underline = _ref.underline;
|
|
36
36
|
return underline ? "underline" : "none";
|
package/dist/RadioButton.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["label"];
|
|
4
3
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
6
5
|
|
|
7
6
|
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
7
|
|
|
@@ -16,7 +15,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
16
15
|
|
|
17
16
|
var RadioButton = function RadioButton(_ref) {
|
|
18
17
|
var label = _ref.label,
|
|
19
|
-
props = _objectWithoutProperties(_ref,
|
|
18
|
+
props = _objectWithoutProperties(_ref, ["label"]);
|
|
20
19
|
|
|
21
20
|
return /*#__PURE__*/_jsxs(RadioButtonWrapper, {
|
|
22
21
|
children: [/*#__PURE__*/_jsx("input", _objectSpread({
|
package/dist/Switch.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["label", "tabIndex"];
|
|
4
3
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
6
5
|
|
|
7
6
|
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
7
|
|
|
@@ -17,7 +16,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
17
16
|
var Switch = function Switch(_ref) {
|
|
18
17
|
var label = _ref.label,
|
|
19
18
|
tabIndex = _ref.tabIndex,
|
|
20
|
-
props = _objectWithoutProperties(_ref,
|
|
19
|
+
props = _objectWithoutProperties(_ref, ["label", "tabIndex"]);
|
|
21
20
|
|
|
22
21
|
var checkboxRef = useRef();
|
|
23
22
|
|
|
@@ -30,10 +29,10 @@ var Switch = function Switch(_ref) {
|
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
return /*#__PURE__*/_jsxs(ToggleSwitchWrapper, {
|
|
33
|
-
children: [/*#__PURE__*/_jsx("input", _objectSpread(
|
|
32
|
+
children: [/*#__PURE__*/_jsx("input", _objectSpread({
|
|
34
33
|
ref: checkboxRef,
|
|
35
34
|
type: "checkbox"
|
|
36
|
-
}, props
|
|
35
|
+
}, props, {
|
|
37
36
|
tabIndex: -1
|
|
38
37
|
})), /*#__PURE__*/_jsx(StyledSwitch, _objectSpread({
|
|
39
38
|
onKeyDown: onKeyDown,
|
package/dist/Tag.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["text", "closeCallback", "isUppercase"];
|
|
5
4
|
|
|
6
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
7
6
|
|
|
8
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; }
|
|
9
8
|
|
|
@@ -20,7 +19,7 @@ var Tag = function Tag(_ref) {
|
|
|
20
19
|
var text = _ref.text,
|
|
21
20
|
closeCallback = _ref.closeCallback,
|
|
22
21
|
isUppercase = _ref.isUppercase,
|
|
23
|
-
props = _objectWithoutProperties(_ref,
|
|
22
|
+
props = _objectWithoutProperties(_ref, ["text", "closeCallback", "isUppercase"]);
|
|
24
23
|
|
|
25
24
|
var _useState = useState(true),
|
|
26
25
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -32,7 +31,7 @@ var Tag = function Tag(_ref) {
|
|
|
32
31
|
closeCallback && closeCallback();
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
return show && /*#__PURE__*/_jsxs(TagWrapper, _objectSpread(
|
|
34
|
+
return show && /*#__PURE__*/_jsxs(TagWrapper, _objectSpread({}, props, {
|
|
36
35
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
37
36
|
bold: true,
|
|
38
37
|
uppercase: isUppercase,
|
package/dist/Textarea.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["cols", "rows", "label"];
|
|
4
3
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
6
5
|
|
|
7
6
|
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
7
|
|
|
@@ -18,7 +17,7 @@ var Textarea = function Textarea(_ref) {
|
|
|
18
17
|
var cols = _ref.cols,
|
|
19
18
|
rows = _ref.rows,
|
|
20
19
|
label = _ref.label,
|
|
21
|
-
props = _objectWithoutProperties(_ref,
|
|
20
|
+
props = _objectWithoutProperties(_ref, ["cols", "rows", "label"]);
|
|
22
21
|
|
|
23
22
|
return /*#__PURE__*/_jsxs(Fragment, {
|
|
24
23
|
children: [!!label && /*#__PURE__*/_jsx(Label, {
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useState, useEffect, useRef } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { IconSearch } from "@happeouikit/icons";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
import { hooks } from "@happeo/react-core";
|
|
7
|
+
import { Input } from "../Input";
|
|
8
|
+
import TypeaheadList from "./TypeaheadList";
|
|
9
|
+
import TypeaheadDropdown from "./TypeaheadDropdown";
|
|
10
|
+
import TypeaheadError from "./TypeaheadError";
|
|
11
|
+
import TypeaheadNoResults from "./TypeaheadNoResults";
|
|
12
|
+
import TypeaheadLoading from "./TypeaheadLoading";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
|
|
16
|
+
var Typeahead = function Typeahead(_ref) {
|
|
17
|
+
var onQuery = _ref.onQuery,
|
|
18
|
+
loading = _ref.loading,
|
|
19
|
+
results = _ref.results,
|
|
20
|
+
afterSelect = _ref.afterSelect,
|
|
21
|
+
keepResult = _ref.keepResult,
|
|
22
|
+
placeholder = _ref.placeholder,
|
|
23
|
+
errorMessage = _ref.errorMessage,
|
|
24
|
+
queryError = _ref.queryError,
|
|
25
|
+
dropdownMaxHeight = _ref.dropdownMaxHeight;
|
|
26
|
+
|
|
27
|
+
// Need to store query as object to support change detection when debouncing from query to the same query
|
|
28
|
+
var _useState = useState({
|
|
29
|
+
q: ""
|
|
30
|
+
}),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
query = _useState2[0],
|
|
33
|
+
setQuery = _useState2[1];
|
|
34
|
+
|
|
35
|
+
var debouncedQuery = hooks.useDebounce(query, 300);
|
|
36
|
+
|
|
37
|
+
var _useState3 = useState(null),
|
|
38
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
39
|
+
focusedResultIndex = _useState4[0],
|
|
40
|
+
setFocusedResultIndex = _useState4[1];
|
|
41
|
+
|
|
42
|
+
var _useState5 = useState(true),
|
|
43
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
44
|
+
allowDropdown = _useState6[0],
|
|
45
|
+
setAllowDropdown = _useState6[1];
|
|
46
|
+
|
|
47
|
+
var _useState7 = useState(null),
|
|
48
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
49
|
+
selectedResult = _useState8[0],
|
|
50
|
+
setSelectedResult = _useState8[1];
|
|
51
|
+
|
|
52
|
+
var selfRef = useRef(null);
|
|
53
|
+
var selectedRef = useRef(null);
|
|
54
|
+
var userIsTyping = query !== debouncedQuery;
|
|
55
|
+
var showDropDown = query.q.length > 1 && !selectedResult && allowDropdown; // The parent may want to keep the result visible until some further user interaction
|
|
56
|
+
// Then keepResult may be toggled OFF to clear the input for next query and set back ON at onQuery
|
|
57
|
+
|
|
58
|
+
useEffect(function () {
|
|
59
|
+
if (!keepResult) setQuery({
|
|
60
|
+
q: ""
|
|
61
|
+
});
|
|
62
|
+
}, [keepResult]);
|
|
63
|
+
useEffect(function () {
|
|
64
|
+
// Debouncing timer might still be running after result is selected, so ignore false triggers
|
|
65
|
+
if (selectedResult) return;
|
|
66
|
+
var q = debouncedQuery.q;
|
|
67
|
+
if (q.length < 2) return;
|
|
68
|
+
onQuery(q);
|
|
69
|
+
}, [onQuery, debouncedQuery, selectedResult]);
|
|
70
|
+
useEffect(function () {
|
|
71
|
+
if (results.length === 0) {
|
|
72
|
+
setFocusedResultIndex(null);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (results.length > 0) {
|
|
76
|
+
setFocusedResultIndex(0);
|
|
77
|
+
}
|
|
78
|
+
}, [results]);
|
|
79
|
+
|
|
80
|
+
var focusNextResult = function focusNextResult() {
|
|
81
|
+
return focusedResultIndex < results.length - 1 ? focusedResultIndex + 1 : focusedResultIndex;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
var focusPrevResult = function focusPrevResult() {
|
|
85
|
+
return focusedResultIndex > 0 ? focusedResultIndex - 1 : focusedResultIndex;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
var selectResult = function selectResult(result) {
|
|
89
|
+
if (keepResult && result.text) {
|
|
90
|
+
setQuery({
|
|
91
|
+
q: result.text
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
setQuery({
|
|
95
|
+
q: ""
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setSelectedResult(result);
|
|
100
|
+
afterSelect(result);
|
|
101
|
+
setFocusedResultIndex(null);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
var valueChangeHandler = function valueChangeHandler(event) {
|
|
105
|
+
var value = event.target.value;
|
|
106
|
+
setQuery({
|
|
107
|
+
q: value
|
|
108
|
+
});
|
|
109
|
+
setAllowDropdown(true);
|
|
110
|
+
setSelectedResult(null);
|
|
111
|
+
setFocusedResultIndex(null); // notify parent that selection was erased
|
|
112
|
+
|
|
113
|
+
if (selectedResult) {
|
|
114
|
+
afterSelect(null);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
useEffect(function () {
|
|
119
|
+
if (!selectedRef.current) return;
|
|
120
|
+
selectedRef.current.scrollIntoView({
|
|
121
|
+
block: "nearest"
|
|
122
|
+
});
|
|
123
|
+
}, [focusedResultIndex]);
|
|
124
|
+
|
|
125
|
+
var keyDownHandler = function keyDownHandler(event) {
|
|
126
|
+
if (!showDropDown) return;
|
|
127
|
+
if (queryError || userIsTyping || loading) return;
|
|
128
|
+
|
|
129
|
+
if (event.key === "ArrowUp") {
|
|
130
|
+
setFocusedResultIndex(focusPrevResult());
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
} else if (event.key === "ArrowDown") {
|
|
133
|
+
setFocusedResultIndex(focusNextResult());
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
} else if (event.key === "Enter") {
|
|
136
|
+
if (focusedResultIndex != null) {
|
|
137
|
+
selectResult(results[focusedResultIndex]);
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
var resultClickHandler = function resultClickHandler(result) {
|
|
144
|
+
selectResult(result);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
useEffect(function () {
|
|
148
|
+
var handleWindowClick = function handleWindowClick(event) {
|
|
149
|
+
if (selfRef.current && !selfRef.current.contains(event.target)) {
|
|
150
|
+
setAllowDropdown(false);
|
|
151
|
+
} else {
|
|
152
|
+
setAllowDropdown(true);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
document.addEventListener("pointerdown", handleWindowClick);
|
|
157
|
+
return function cleanup() {
|
|
158
|
+
document.removeEventListener("pointerdown", handleWindowClick);
|
|
159
|
+
};
|
|
160
|
+
}, [selfRef]);
|
|
161
|
+
|
|
162
|
+
var renderDropdownContent = function renderDropdownContent() {
|
|
163
|
+
if (queryError) {
|
|
164
|
+
return /*#__PURE__*/_jsx(TypeaheadError, {});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (userIsTyping || loading) {
|
|
168
|
+
return /*#__PURE__*/_jsx(TypeaheadLoading, {
|
|
169
|
+
query: query.q
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (results.length > 0) {
|
|
174
|
+
return /*#__PURE__*/_jsx(TypeaheadList, {
|
|
175
|
+
results: results,
|
|
176
|
+
focusedResultIndex: focusedResultIndex,
|
|
177
|
+
onResultClick: resultClickHandler,
|
|
178
|
+
ref: selectedRef
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return /*#__PURE__*/_jsx(TypeaheadNoResults, {
|
|
183
|
+
query: query.q
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
return /*#__PURE__*/_jsxs(Wrapper, {
|
|
188
|
+
ref: selfRef,
|
|
189
|
+
children: [/*#__PURE__*/_jsx(Input, {
|
|
190
|
+
placeholder: placeholder,
|
|
191
|
+
icon: IconSearch,
|
|
192
|
+
value: query.q,
|
|
193
|
+
name: "inputValue",
|
|
194
|
+
onChange: valueChangeHandler,
|
|
195
|
+
onKeyDown: keyDownHandler,
|
|
196
|
+
state: errorMessage ? "error" : "default",
|
|
197
|
+
errorMessage: errorMessage,
|
|
198
|
+
autoComplete: "off"
|
|
199
|
+
}), showDropDown && /*#__PURE__*/_jsx(TypeaheadDropdown, {
|
|
200
|
+
maxHeight: dropdownMaxHeight,
|
|
201
|
+
children: renderDropdownContent()
|
|
202
|
+
})]
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
var Wrapper = styled.div.withConfig({
|
|
207
|
+
displayName: "Typeahead__Wrapper",
|
|
208
|
+
componentId: "sc-16j2d25-0"
|
|
209
|
+
})(["width:100%;"]);
|
|
210
|
+
Typeahead.propTypes = {
|
|
211
|
+
onQuery: PropTypes.func.isRequired,
|
|
212
|
+
loading: PropTypes.bool.isRequired,
|
|
213
|
+
results: PropTypes.arrayOf(PropTypes.shape({
|
|
214
|
+
text: PropTypes.string,
|
|
215
|
+
// This is used in association with keepResult
|
|
216
|
+
component: PropTypes.element.isRequired,
|
|
217
|
+
data: PropTypes.shape // You may add any data related to the result, so you can use it on afterSelect
|
|
218
|
+
|
|
219
|
+
})).isRequired,
|
|
220
|
+
afterSelect: PropTypes.func.isRequired,
|
|
221
|
+
keepResult: PropTypes.bool,
|
|
222
|
+
placeholder: PropTypes.string,
|
|
223
|
+
errorMessage: PropTypes.string,
|
|
224
|
+
queryError: PropTypes.bool,
|
|
225
|
+
dropdownMaxHeight: PropTypes.string
|
|
226
|
+
};
|
|
227
|
+
Typeahead.defaultProps = {
|
|
228
|
+
keepResult: false,
|
|
229
|
+
placeholder: "",
|
|
230
|
+
errorMessage: null,
|
|
231
|
+
queryError: false,
|
|
232
|
+
dropdownMaxHeight: "350px"
|
|
233
|
+
};
|
|
234
|
+
export default Typeahead;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { shadow400 } from "@happeouikit/theme";
|
|
3
|
+
import { white } from "@happeouikit/colors";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
var TypeaheadDropdown = function TypeaheadDropdown(_ref) {
|
|
7
|
+
var maxHeight = _ref.maxHeight,
|
|
8
|
+
children = _ref.children;
|
|
9
|
+
return /*#__PURE__*/_jsx(Dropdown, {
|
|
10
|
+
children: /*#__PURE__*/_jsx(DropdownContent, {
|
|
11
|
+
maxHeight: maxHeight,
|
|
12
|
+
children: children
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var Dropdown = styled.div.withConfig({
|
|
18
|
+
displayName: "TypeaheadDropdown__Dropdown",
|
|
19
|
+
componentId: "c2clla-0"
|
|
20
|
+
})(["position:relative;display:block;width:100%;z-index:1000;"]);
|
|
21
|
+
var DropdownContent = styled.div.withConfig({
|
|
22
|
+
displayName: "TypeaheadDropdown__DropdownContent",
|
|
23
|
+
componentId: "c2clla-1"
|
|
24
|
+
})(["position:absolute;display:block;width:100%;background:", ";margin-top:8px;padding-top:8px;padding-bottom:8px;box-shadow:", ";border-radius:4px;max-height:", ";overflow-y:auto;"], white, shadow400, function (props) {
|
|
25
|
+
return props.maxHeight;
|
|
26
|
+
});
|
|
27
|
+
export default TypeaheadDropdown;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IconError } from "@happeouikit/icons";
|
|
2
|
+
import { useIntl } from "react-intl";
|
|
3
|
+
import messages from "./messages";
|
|
4
|
+
import TypeaheadMessage from "./TypeaheadMessage";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
var TypeaheadError = function TypeaheadError() {
|
|
8
|
+
var intl = useIntl();
|
|
9
|
+
return /*#__PURE__*/_jsx(TypeaheadMessage, {
|
|
10
|
+
icon: IconError,
|
|
11
|
+
title: intl.formatMessage(messages.typeaheadServerError),
|
|
12
|
+
details: intl.formatMessage(messages.typeaheadServerErrorDetails)
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default TypeaheadError;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { active, toBgLight, lighten40 } from "@happeouikit/colors";
|
|
4
|
+
import { radius400 } from "@happeouikit/theme";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
var FocusStyle = {
|
|
7
|
+
border: "solid 1px ".concat(lighten40(active)),
|
|
8
|
+
borderRadius: radius400
|
|
9
|
+
};
|
|
10
|
+
var TypeaheadList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
11
|
+
var results = _ref.results,
|
|
12
|
+
focusedResultIndex = _ref.focusedResultIndex,
|
|
13
|
+
onResultClick = _ref.onResultClick;
|
|
14
|
+
return /*#__PURE__*/_jsx(Container, {
|
|
15
|
+
children: results.map(function (result, index) {
|
|
16
|
+
return /*#__PURE__*/_jsx(Fragment, {
|
|
17
|
+
children: /*#__PURE__*/_jsx(Row, {
|
|
18
|
+
onClick: function onClick() {
|
|
19
|
+
return onResultClick(result);
|
|
20
|
+
},
|
|
21
|
+
style: index === focusedResultIndex ? FocusStyle : {},
|
|
22
|
+
ref: index === focusedResultIndex ? ref : null,
|
|
23
|
+
children: result.component
|
|
24
|
+
})
|
|
25
|
+
}, result.text || index);
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
var Container = styled.ul.withConfig({
|
|
30
|
+
displayName: "TypeaheadList__Container",
|
|
31
|
+
componentId: "ce1llk-0"
|
|
32
|
+
})(["padding:0px;margin:0px;"]);
|
|
33
|
+
var Row = styled.li.withConfig({
|
|
34
|
+
displayName: "TypeaheadList__Row",
|
|
35
|
+
componentId: "ce1llk-1"
|
|
36
|
+
})(["padding:9px 15px 9px 15px;border:solid 1px transparent;list-style-type:none;&:hover{background:", ";}"], toBgLight(active));
|
|
37
|
+
export default TypeaheadList;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Loader } from "@happeouikit/loaders";
|
|
2
|
+
import { useIntl } from "react-intl";
|
|
3
|
+
import messages from "./messages";
|
|
4
|
+
import TypeaheadMessage, { ICON_SIZE } from "./TypeaheadMessage";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
var FixedSizeLoader = function FixedSizeLoader() {
|
|
8
|
+
return /*#__PURE__*/_jsx(Loader, {
|
|
9
|
+
containerWidth: ICON_SIZE,
|
|
10
|
+
containerHeight: ICON_SIZE
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
var TypeaheadLoading = function TypeaheadLoading(_ref) {
|
|
15
|
+
var query = _ref.query;
|
|
16
|
+
var intl = useIntl();
|
|
17
|
+
return /*#__PURE__*/_jsx(TypeaheadMessage, {
|
|
18
|
+
icon: FixedSizeLoader,
|
|
19
|
+
title: intl.formatMessage(messages.typeaheadSearching),
|
|
20
|
+
details: intl.formatMessage(messages.typeaheadSearchingDetails, {
|
|
21
|
+
query: query
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default TypeaheadLoading;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { TextEpsilon, BodyUI } from "@happeouikit/typography";
|
|
3
|
+
import { gray07, gray04 } from "@happeouikit/colors";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
export var ICON_SIZE = "48px";
|
|
7
|
+
var IconStyle = {
|
|
8
|
+
width: ICON_SIZE,
|
|
9
|
+
height: ICON_SIZE,
|
|
10
|
+
fill: gray07
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
var TypeaheadMessage = function TypeaheadMessage(_ref) {
|
|
14
|
+
var icon = _ref.icon,
|
|
15
|
+
title = _ref.title,
|
|
16
|
+
details = _ref.details;
|
|
17
|
+
var Icon = icon;
|
|
18
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
19
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
20
|
+
style: IconStyle
|
|
21
|
+
}), /*#__PURE__*/_jsx(Title, {
|
|
22
|
+
children: title
|
|
23
|
+
}), /*#__PURE__*/_jsx(Details, {
|
|
24
|
+
children: details
|
|
25
|
+
})]
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var Title = styled(TextEpsilon).withConfig({
|
|
30
|
+
displayName: "TypeaheadMessage__Title",
|
|
31
|
+
componentId: "sc-1yxn5eq-0"
|
|
32
|
+
})(["text-align:center;margin-bottom:8px;"]);
|
|
33
|
+
var Details = styled(BodyUI).withConfig({
|
|
34
|
+
displayName: "TypeaheadMessage__Details",
|
|
35
|
+
componentId: "sc-1yxn5eq-1"
|
|
36
|
+
})(["text-align:center;color:", ";"], gray04);
|
|
37
|
+
var Flexbox = styled.div.withConfig({
|
|
38
|
+
displayName: "TypeaheadMessage__Flexbox",
|
|
39
|
+
componentId: "sc-1yxn5eq-2"
|
|
40
|
+
})(["display:flex;flex-direction:column;align-items:center;padding:24px;"]);
|
|
41
|
+
export default TypeaheadMessage;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useIntl } from "react-intl";
|
|
2
|
+
import { IconSearch } from "@happeouikit/icons";
|
|
3
|
+
import messages from "./messages";
|
|
4
|
+
import TypeaheadMessage from "./TypeaheadMessage";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
var TypeaheadNoResults = function TypeaheadNoResults(_ref) {
|
|
8
|
+
var query = _ref.query;
|
|
9
|
+
var intl = useIntl();
|
|
10
|
+
return /*#__PURE__*/_jsx(TypeaheadMessage, {
|
|
11
|
+
icon: IconSearch,
|
|
12
|
+
title: intl.formatMessage(messages.typeaheadNoResults),
|
|
13
|
+
details: intl.formatMessage(messages.typeaheadNoResultsDetails, {
|
|
14
|
+
query: query
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default TypeaheadNoResults;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineMessages } from "react-intl";
|
|
2
|
+
export default defineMessages({
|
|
3
|
+
typeaheadNoResults: {
|
|
4
|
+
id: "typeahead.noResults",
|
|
5
|
+
defaultMessage: "No results found"
|
|
6
|
+
},
|
|
7
|
+
typeaheadNoResultsDetails: {
|
|
8
|
+
id: "typeahead.noResultsDetails",
|
|
9
|
+
// eslint-disable-next-line quotes
|
|
10
|
+
defaultMessage: 'We found no results for "{query}"'
|
|
11
|
+
},
|
|
12
|
+
typeaheadServerError: {
|
|
13
|
+
id: "typeahead.serverError",
|
|
14
|
+
defaultMessage: "Server Error"
|
|
15
|
+
},
|
|
16
|
+
typeaheadServerErrorDetails: {
|
|
17
|
+
id: "typeahead.serverErrorDetails",
|
|
18
|
+
defaultMessage: "Oh no, there seems to be an issue with our servers. Please try again later"
|
|
19
|
+
},
|
|
20
|
+
typeaheadSearching: {
|
|
21
|
+
id: "typeahead.searching",
|
|
22
|
+
defaultMessage: "Searching..."
|
|
23
|
+
},
|
|
24
|
+
typeaheadSearchingDetails: {
|
|
25
|
+
id: "typeahead.searchingDetails",
|
|
26
|
+
// eslint-disable-next-line quotes
|
|
27
|
+
defaultMessage: 'Please wait as we try to find "{query}"'
|
|
28
|
+
}
|
|
29
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -10,4 +10,5 @@ export { default as Tag } from "./Tag";
|
|
|
10
10
|
export { default as Badge } from "./Badge";
|
|
11
11
|
export { default as DatePicker } from "./DatePicker";
|
|
12
12
|
export * from "./utils";
|
|
13
|
-
export { default as DateTimePicker } from "./DateTimePicker";
|
|
13
|
+
export { default as DateTimePicker } from "./DateTimePicker";
|
|
14
|
+
export { default as Typeahead } from "./Typeahead/Typeahead";
|
package/dist/utils.js
CHANGED
|
@@ -7,7 +7,7 @@ export var toCamelCase = function toCamelCase(str) {
|
|
|
7
7
|
var HASHTAG_MAX_LENGTH = 64;
|
|
8
8
|
export var sanitiseHashtag = function sanitiseHashtag(hashtag) {
|
|
9
9
|
if (hashtag && typeof hashtag === "string") {
|
|
10
|
-
var regex = new RegExp(/(?:
|
|
10
|
+
var regex = new RegExp(/(?:[\0-"\$-\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08BE-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0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7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1ABF-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u200B\u200E-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31BB-\u31EF\u3200-\u33FF\u4DB6-\u4DFF\u9FF0-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7C7-\uA7F6\uA828-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB68-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65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EA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/);
|
|
11
11
|
var withoutConsecutiveUnderscores = hashtag.replace(/_+/g, "_");
|
|
12
12
|
var match = withoutConsecutiveUnderscores.match(regex);
|
|
13
13
|
var firstDisallowedCharIndex = match && match.index || withoutConsecutiveUnderscores.length;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happeouikit/form-elements",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -15,10 +15,12 @@
|
|
|
15
15
|
"author": "Happeo Oy",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@happeo/react-core": "^0.9.0",
|
|
18
19
|
"@happeouikit/buttons": "^1.0.15",
|
|
19
20
|
"@happeouikit/colors": "^1.0.4",
|
|
20
|
-
"@happeouikit/icons": "^2.0.
|
|
21
|
+
"@happeouikit/icons": "^2.0.5",
|
|
21
22
|
"@happeouikit/layout": "^1.1.11",
|
|
23
|
+
"@happeouikit/loaders": "^1.0.4",
|
|
22
24
|
"@happeouikit/theme": "^1.0.4",
|
|
23
25
|
"@happeouikit/tooltip": "^1.0.11",
|
|
24
26
|
"@happeouikit/typography": "^1.0.10",
|