guestbell-forms 3.0.18 → 3.0.19
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/.babelrc.js +1 -1
- package/build/components/base/input/BaseInput.js +8 -96
- package/build/components/base/input/BaseInput.js.map +1 -1
- package/build/components/base/input/index.js +0 -2
- package/build/components/base/input/index.js.map +1 -1
- package/build/components/bookingCalendar/BookingCalendar.js +7 -30
- package/build/components/bookingCalendar/BookingCalendar.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.js +2 -22
- package/build/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarControls/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarControls/index.js +0 -4
- package/build/components/bookingCalendar/bookingCalendarControls/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.js +6 -19
- package/build/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarDatePicker/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarDatePicker/index.js +0 -4
- package/build/components/bookingCalendar/bookingCalendarDatePicker/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarGrid/BookingCalendarGrid.d.ts +2 -1
- package/build/components/bookingCalendar/bookingCalendarGrid/BookingCalendarGrid.js +11 -10
- package/build/components/bookingCalendar/bookingCalendarGrid/BookingCalendarGrid.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarGrid/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.js +0 -9
- package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarItem/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarItem/index.js +0 -4
- package/build/components/bookingCalendar/bookingCalendarItem/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLane/BookingCalendarLane.js +0 -10
- package/build/components/bookingCalendar/bookingCalendarLane/BookingCalendarLane.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLane/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLane/index.js +0 -4
- package/build/components/bookingCalendar/bookingCalendarLane/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/BookingCalendarLaneHeader.js +0 -7
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/BookingCalendarLaneHeader.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/index.js +0 -2
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.js +0 -12
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeaderRenderItem.js +0 -9
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeaderRenderItem.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/index.js +0 -4
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarRenderItem/BookingCalendarRenderItem.js +0 -9
- package/build/components/bookingCalendar/bookingCalendarRenderItem/BookingCalendarRenderItem.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarRenderItem/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarRenderItem/index.js +0 -2
- package/build/components/bookingCalendar/bookingCalendarRenderItem/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js +0 -30
- package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/BookingCalendarTimeAxis.js +0 -7
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/BookingCalendarTimeAxis.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/classes.js.map +1 -1
- package/build/components/bookingCalendar/classes.js.map +1 -1
- package/build/components/bookingCalendar/common.js +0 -9
- package/build/components/bookingCalendar/common.js.map +1 -1
- package/build/components/bookingCalendar/index.js +0 -6
- package/build/components/bookingCalendar/index.js.map +1 -1
- package/build/components/bookingCalendar/utils.js +5 -50
- package/build/components/bookingCalendar/utils.js.map +1 -1
- package/build/components/button/Button.js +9 -37
- package/build/components/button/Button.js.map +1 -1
- package/build/components/button/index.js +0 -4
- package/build/components/button/index.js.map +1 -1
- package/build/components/checkbox/Checkbox.js +5 -35
- package/build/components/checkbox/Checkbox.js.map +1 -1
- package/build/components/checkbox/index.js +0 -4
- package/build/components/checkbox/index.js.map +1 -1
- package/build/components/dropdown/Dropdown.js +1 -15
- package/build/components/dropdown/Dropdown.js.map +1 -1
- package/build/components/dropdown/index.js +0 -4
- package/build/components/dropdown/index.js.map +1 -1
- package/build/components/dynamicSubmit/DynamicSubmit.js +7 -39
- package/build/components/dynamicSubmit/DynamicSubmit.js.map +1 -1
- package/build/components/dynamicSubmit/index.js +0 -4
- package/build/components/dynamicSubmit/index.js.map +1 -1
- package/build/components/externalValidationComponent/ExternalValidationComponent.js +6 -17
- package/build/components/externalValidationComponent/ExternalValidationComponent.js.map +1 -1
- package/build/components/externalValidationComponent/index.js +0 -4
- package/build/components/externalValidationComponent/index.js.map +1 -1
- package/build/components/form/Form.js +8 -46
- package/build/components/form/Form.js.map +1 -1
- package/build/components/form/FormContext.js +0 -4
- package/build/components/form/FormContext.js.map +1 -1
- package/build/components/form/FormValidationSummary.js +3 -25
- package/build/components/form/FormValidationSummary.js.map +1 -1
- package/build/components/form/index.js +0 -10
- package/build/components/form/index.js.map +1 -1
- package/build/components/form/withFormContext.js +0 -6
- package/build/components/form/withFormContext.js.map +1 -1
- package/build/components/inputGroup/InputGroup.js +5 -15
- package/build/components/inputGroup/InputGroup.js.map +1 -1
- package/build/components/inputGroup/index.js +0 -4
- package/build/components/inputGroup/index.js.map +1 -1
- package/build/components/inputHeader/InputHeader.js +16 -75
- package/build/components/inputHeader/InputHeader.js.map +1 -1
- package/build/components/inputHeader/InputHeaderContext.js +0 -4
- package/build/components/inputHeader/InputHeaderContext.js.map +1 -1
- package/build/components/inputHeader/index.js +0 -4
- package/build/components/inputHeader/index.js.map +1 -1
- package/build/components/inputHeader/withInputHeaderContext.js +0 -6
- package/build/components/inputHeader/withInputHeaderContext.js.map +1 -1
- package/build/components/money/Money.js +20 -64
- package/build/components/money/Money.js.map +1 -1
- package/build/components/money/index.js +0 -4
- package/build/components/money/index.js.map +1 -1
- package/build/components/numberInput/NumberInput.js +13 -44
- package/build/components/numberInput/NumberInput.js.map +1 -1
- package/build/components/numberInput/index.js +0 -4
- package/build/components/numberInput/index.js.map +1 -1
- package/build/components/openingHours/openingHoursDay/OpeningHoursDay.js +13 -62
- package/build/components/openingHours/openingHoursDay/OpeningHoursDay.js.map +1 -1
- package/build/components/openingHours/openingHoursDay/index.js +0 -4
- package/build/components/openingHours/openingHoursDay/index.js.map +1 -1
- package/build/components/openingHours/openingHoursSpecial/OpeningHoursSpecial.js +18 -49
- package/build/components/openingHours/openingHoursSpecial/OpeningHoursSpecial.js.map +1 -1
- package/build/components/openingHours/openingHoursSpecial/index.js +0 -4
- package/build/components/openingHours/openingHoursSpecial/index.js.map +1 -1
- package/build/components/openingHours/openingHoursWeek/OpeningHoursWeek.js +16 -53
- package/build/components/openingHours/openingHoursWeek/OpeningHoursWeek.js.map +1 -1
- package/build/components/openingHours/openingHoursWeek/index.js +0 -4
- package/build/components/openingHours/openingHoursWeek/index.js.map +1 -1
- package/build/components/openingHours/utils/OpeningHoursUtil.js +3 -21
- package/build/components/openingHours/utils/OpeningHoursUtil.js.map +1 -1
- package/build/components/radio/Radio.js +4 -19
- package/build/components/radio/Radio.js.map +1 -1
- package/build/components/radio/index.js +0 -4
- package/build/components/radio/index.js.map +1 -1
- package/build/components/radioContainer/RadioContainer.js +2 -13
- package/build/components/radioContainer/RadioContainer.js.map +1 -1
- package/build/components/radioContainer/index.js +0 -4
- package/build/components/radioContainer/index.js.map +1 -1
- package/build/components/select/Select.js +6 -53
- package/build/components/select/Select.js.map +1 -1
- package/build/components/select/index.js +0 -4
- package/build/components/select/index.js.map +1 -1
- package/build/components/submit/Submit.js +5 -28
- package/build/components/submit/Submit.js.map +1 -1
- package/build/components/submit/index.js +0 -4
- package/build/components/submit/index.js.map +1 -1
- package/build/components/submit/subComponents/SubmitValidationSummary.js +0 -9
- package/build/components/submit/subComponents/SubmitValidationSummary.js.map +1 -1
- package/build/components/tags/Tags.js +34 -119
- package/build/components/tags/Tags.js.map +1 -1
- package/build/components/tags/index.js +0 -4
- package/build/components/tags/index.js.map +1 -1
- package/build/components/tags/subComponents/TagsSuggestions.js +0 -14
- package/build/components/tags/subComponents/TagsSuggestions.js.map +1 -1
- package/build/components/text/Text.js +10 -42
- package/build/components/text/Text.js.map +1 -1
- package/build/components/text/index.js +0 -4
- package/build/components/text/index.js.map +1 -1
- package/build/components/textArea/TextArea.js +8 -31
- package/build/components/textArea/TextArea.js.map +1 -1
- package/build/components/textArea/index.js +0 -4
- package/build/components/textArea/index.js.map +1 -1
- package/build/components/themeProvider/ThemeContext.js +0 -4
- package/build/components/themeProvider/ThemeContext.js.map +1 -1
- package/build/components/themeProvider/ThemeProvider.js +2 -6
- package/build/components/themeProvider/ThemeProvider.js.map +1 -1
- package/build/components/themeProvider/index.js +0 -8
- package/build/components/themeProvider/index.js.map +1 -1
- package/build/components/themeProvider/withThemeContext.js +0 -8
- package/build/components/themeProvider/withThemeContext.js.map +1 -1
- package/build/components/time/Time.js +17 -73
- package/build/components/time/Time.js.map +1 -1
- package/build/components/time/index.js +0 -4
- package/build/components/time/index.js.map +1 -1
- package/build/components/timeSpan/TimeSpan.js +17 -99
- package/build/components/timeSpan/TimeSpan.js.map +1 -1
- package/build/components/timeSpan/index.js +0 -4
- package/build/components/timeSpan/index.js.map +1 -1
- package/build/components/utils/Guid.js +0 -3
- package/build/components/utils/Guid.js.map +1 -1
- package/build/components/utils/ShallowEqual.js +5 -10
- package/build/components/utils/ShallowEqual.js.map +1 -1
- package/build/components/utils/TimeUtil.js +1 -3
- package/build/components/utils/TimeUtil.js.map +1 -1
- package/build/dist/guestbell-forms.css.map +1 -1
- package/build/dist/guestbell-forms.js +21 -84
- package/build/dist/guestbell-forms.js.map +1 -1
- package/build/dist/guestbell-forms.min.js +1 -1
- package/build/dist/guestbell-forms.min.js.map +1 -1
- package/build/dist/report.html +13 -41
- package/build/index.js +0 -48
- package/build/index.js.map +1 -1
- package/build/validators/EmailValidator.js +0 -4
- package/build/validators/EmailValidator.js.map +1 -1
- package/build/validators/LatitudeValidator.js +0 -8
- package/build/validators/LatitudeValidator.js.map +1 -1
- package/build/validators/LongitudeValidator.js +0 -8
- package/build/validators/LongitudeValidator.js.map +1 -1
- package/build/validators/NumberValidator.js +0 -15
- package/build/validators/NumberValidator.js.map +1 -1
- package/build/validators/UrlValidator.js +2 -5
- package/build/validators/UrlValidator.js.map +1 -1
- package/build/validators/index.js +0 -7
- package/build/validators/index.js.map +1 -1
- package/package.json +19 -19
@@ -4,109 +4,75 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.defaultTagsTranslations = exports.default = exports.TagsRaw = exports.Tags = void 0;
|
7
|
-
|
8
7
|
var React = _interopRequireWildcard(require("react"));
|
9
|
-
|
10
8
|
var _InputGroup = require("../inputGroup/InputGroup");
|
11
|
-
|
12
9
|
var _Text = require("../text/Text");
|
13
|
-
|
14
10
|
var _BaseInput = require("../base/input/BaseInput");
|
15
|
-
|
16
11
|
var _Button = require("../button/Button");
|
17
|
-
|
18
12
|
var _TagsSuggestions = _interopRequireDefault(require("./subComponents/TagsSuggestions"));
|
19
|
-
|
20
13
|
var _withFormContext = require("../form/withFormContext");
|
21
|
-
|
22
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
23
|
-
|
24
15
|
var _withThemeContext = require("../themeProvider/withThemeContext");
|
25
|
-
|
26
16
|
var _LinearProgress = _interopRequireDefault(require("@mui/material/LinearProgress"));
|
27
|
-
|
28
17
|
var _Portal = _interopRequireDefault(require("@mui/material/Portal"));
|
29
|
-
|
30
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
31
|
-
|
32
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
33
|
-
|
34
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
35
|
-
|
36
21
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
37
|
-
|
38
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
39
|
-
|
40
23
|
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; }
|
41
|
-
|
42
|
-
function
|
43
|
-
|
24
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
26
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Libs
|
44
27
|
var PlusIcon = function PlusIcon(props) {
|
45
28
|
return /*#__PURE__*/React.createElement("svg", props, /*#__PURE__*/React.createElement("path", {
|
46
29
|
d: "M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"
|
47
30
|
}));
|
48
31
|
};
|
49
|
-
|
50
32
|
PlusIcon.defaultProps = {
|
51
33
|
xmlns: "http://www.w3.org/2000/svg",
|
52
34
|
width: "24",
|
53
35
|
height: "24",
|
54
36
|
viewBox: "0 0 24 24"
|
55
37
|
};
|
56
|
-
|
57
38
|
var LeftArrowIcon = function LeftArrowIcon(props) {
|
58
39
|
return /*#__PURE__*/React.createElement("svg", props, /*#__PURE__*/React.createElement("path", {
|
59
40
|
d: "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"
|
60
41
|
}));
|
61
42
|
};
|
62
|
-
|
63
43
|
LeftArrowIcon.defaultProps = {
|
64
44
|
xmlns: "http://www.w3.org/2000/svg",
|
65
45
|
width: "24",
|
66
46
|
height: "24",
|
67
47
|
viewBox: "0 0 24 24"
|
68
48
|
};
|
49
|
+
// Misc
|
69
50
|
|
70
51
|
const defaultTagsTranslations = _objectSpread(_objectSpread({}, _BaseInput.defaultBaseTranslations), {}, {
|
71
52
|
addNew: 'Add new'
|
72
53
|
});
|
73
|
-
|
74
54
|
exports.defaultTagsTranslations = defaultTagsTranslations;
|
75
|
-
|
76
55
|
const TagButtonComponent = p => /*#__PURE__*/React.createElement("a", {
|
77
56
|
className: p.className,
|
78
57
|
id: p.id,
|
79
58
|
onClick: p.onClick
|
80
59
|
}, p.children);
|
81
|
-
|
82
60
|
class TagsRaw extends _BaseInput.BaseInput {
|
83
61
|
constructor(props) {
|
84
62
|
var _this;
|
85
|
-
|
86
63
|
super(props);
|
87
64
|
_this = this;
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
_defineProperty(this, "suggestionsRef", void 0);
|
92
|
-
|
93
|
-
_defineProperty(this, "isMobile", false);
|
94
|
-
|
95
|
-
_defineProperty(this, "onTextErrorsChanged", textErrors => this.setState(() => ({
|
65
|
+
this.isMobile = false;
|
66
|
+
this.onTextErrorsChanged = textErrors => this.setState(() => ({
|
96
67
|
textErrors
|
97
|
-
}), () => this.handleErrors())
|
98
|
-
|
99
|
-
_defineProperty(this, "onFocus", () => {
|
68
|
+
}), () => this.handleErrors());
|
69
|
+
this.onFocus = () => {
|
100
70
|
var _this$props$onFocus, _this$props;
|
101
|
-
|
102
71
|
(_this$props$onFocus = (_this$props = this.props).onFocus) === null || _this$props$onFocus === void 0 ? void 0 : _this$props$onFocus.call(_this$props);
|
103
|
-
|
104
72
|
if (!this.state.suggestionsVisible) {
|
105
73
|
var _this$props$onSuggest, _this$props2;
|
106
|
-
|
107
74
|
(_this$props$onSuggest = (_this$props2 = this.props).onSuggestionsOpened) === null || _this$props$onSuggest === void 0 ? void 0 : _this$props$onSuggest.call(_this$props2);
|
108
75
|
}
|
109
|
-
|
110
76
|
this.fetchExistingTags(this.state.value);
|
111
77
|
this.setState(() => ({
|
112
78
|
textIsFocused: true,
|
@@ -114,29 +80,24 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
114
80
|
touched: true
|
115
81
|
}), () => this.handleErrors());
|
116
82
|
const showMobileVersion = this.props.mobileVersionEnabled && this.isMobile && (this.state.textIsFocused || this.state.suggestionsVisible);
|
117
|
-
|
118
83
|
if (!showMobileVersion && this.props.mobileVersionEnabled && this.isMobile) {
|
119
84
|
setTimeout(() => {
|
120
85
|
var _this$textRef$current;
|
121
|
-
|
122
86
|
return (_this$textRef$current = this.textRef.current) === null || _this$textRef$current === void 0 ? void 0 : _this$textRef$current.focus();
|
123
87
|
}, 100);
|
124
88
|
}
|
125
|
-
}
|
126
|
-
|
127
|
-
_defineProperty(this, "onKeyDown", suggestions => async e => {
|
89
|
+
};
|
90
|
+
this.onKeyDown = suggestions => async e => {
|
128
91
|
if (e.key === 'Tab') {
|
129
92
|
this.setState({
|
130
93
|
suggestionsVisible: false,
|
131
94
|
preselectedSuggestion: undefined
|
132
95
|
});
|
133
96
|
}
|
134
|
-
|
135
97
|
if (e.key === 'Enter' && (this.state.value !== '' || this.state.preselectedSuggestion !== undefined) && this.state.textErrors.length === 0) {
|
136
98
|
e.preventDefault();
|
137
99
|
e.stopPropagation();
|
138
100
|
const existingTag = this.props.existingTags && this.props.existingTags.find(et => et.name === this.state.value);
|
139
|
-
|
140
101
|
if (this.state.preselectedSuggestion !== undefined) {
|
141
102
|
this.props.onTagsChanged(this.props.tags.concat(suggestions[this.state.preselectedSuggestion]));
|
142
103
|
this.setState({
|
@@ -159,7 +120,6 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
159
120
|
this.handleErrors();
|
160
121
|
}
|
161
122
|
}
|
162
|
-
|
163
123
|
if (suggestions.length > 0 && this.state.suggestionsVisible) {
|
164
124
|
if (e.key === 'ArrowUp') {
|
165
125
|
const preselectedSuggestion = this.state.preselectedSuggestion === undefined ? suggestions.length - 1 : this.state.preselectedSuggestion === 0 ? suggestions.length - 1 : this.state.preselectedSuggestion - 1;
|
@@ -177,18 +137,15 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
177
137
|
});
|
178
138
|
}
|
179
139
|
}
|
180
|
-
}
|
181
|
-
|
182
|
-
_defineProperty(this, "addNewTag", async () => {
|
140
|
+
};
|
141
|
+
this.addNewTag = async () => {
|
183
142
|
const newTag = await this.props.onNewTagAdded(this.state.value);
|
184
143
|
this.setState({
|
185
144
|
suggestionsVisible: this.props.closeSuggestionsAfterCreate ? false : this.state.suggestionsVisible
|
186
145
|
});
|
187
|
-
|
188
146
|
if (newTag) {
|
189
147
|
this.props.onTagsChanged(this.props.tags ? this.props.tags.concat(newTag) : [newTag]);
|
190
148
|
}
|
191
|
-
|
192
149
|
this.setState({
|
193
150
|
value: '',
|
194
151
|
textErrors: []
|
@@ -196,9 +153,8 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
196
153
|
this.fetchExistingTags();
|
197
154
|
this.handleErrors();
|
198
155
|
});
|
199
|
-
}
|
200
|
-
|
201
|
-
_defineProperty(this, "onSuggestionSelected", (tag, lastSelected) => {
|
156
|
+
};
|
157
|
+
this.onSuggestionSelected = (tag, lastSelected) => {
|
202
158
|
const newTags = this.props.tags.concat(tag);
|
203
159
|
this.props.onTagsChanged(newTags);
|
204
160
|
const isMax = newTags.length === this.props.maxTags;
|
@@ -212,22 +168,18 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
212
168
|
if (!this.props.maxTags || this.props.tags.length + 1 < this.props.maxTags) {
|
213
169
|
this.fetchExistingTags(finalValue);
|
214
170
|
}
|
215
|
-
|
216
171
|
this.handleErrors();
|
217
172
|
});
|
218
|
-
}
|
219
|
-
|
220
|
-
_defineProperty(this, "onBlur", () => {
|
173
|
+
};
|
174
|
+
this.onBlur = () => {
|
221
175
|
var _this$props$onBlur, _this$props3;
|
222
|
-
|
223
176
|
(_this$props$onBlur = (_this$props3 = this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props3);
|
224
177
|
this.setState({
|
225
178
|
textIsFocused: false,
|
226
179
|
preselectedSuggestion: undefined
|
227
180
|
}, () => this.handleErrors());
|
228
|
-
}
|
229
|
-
|
230
|
-
_defineProperty(this, "onTextChanged", (e, isValid) => {
|
181
|
+
};
|
182
|
+
this.onTextChanged = (e, isValid) => {
|
231
183
|
const value = e.target.value;
|
232
184
|
this.setState(() => ({
|
233
185
|
value,
|
@@ -236,25 +188,20 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
236
188
|
suggestionsVisible: true
|
237
189
|
}), () => this.handleErrors());
|
238
190
|
this.fetchExistingTags(e.target.value);
|
239
|
-
}
|
240
|
-
|
241
|
-
_defineProperty(this, "handleErrors", function () {
|
191
|
+
};
|
192
|
+
this.handleErrors = function () {
|
242
193
|
let tags = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props.tags;
|
243
|
-
|
244
194
|
let errors = _this.getErrors(tags);
|
245
|
-
|
246
195
|
if (errors.length > 0) {
|
247
196
|
_this.setInvalid(errors);
|
248
197
|
} else {
|
249
198
|
_this.setValid();
|
250
199
|
}
|
251
|
-
}
|
252
|
-
|
253
|
-
_defineProperty(this, "tagClick", tag => () => {
|
200
|
+
};
|
201
|
+
this.tagClick = tag => () => {
|
254
202
|
this.props.onTagClick && this.props.onTagClick(tag);
|
255
|
-
}
|
256
|
-
|
257
|
-
_defineProperty(this, "tagRemoveClick", tag => e => {
|
203
|
+
};
|
204
|
+
this.tagRemoveClick = tag => e => {
|
258
205
|
e.stopPropagation();
|
259
206
|
const newTags = this.props.tags.filter(sv => sv.id !== tag.id);
|
260
207
|
/*if (newTags.length === 0) {
|
@@ -263,11 +210,10 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
263
210
|
this.setState({
|
264
211
|
suggestionsVisible: false,
|
265
212
|
});*/
|
266
|
-
|
267
213
|
this.props.onTagsChanged && this.props.onTagsChanged(newTags);
|
268
|
-
this.handleErrors(newTags);
|
269
|
-
|
270
|
-
|
214
|
+
this.handleErrors(newTags);
|
215
|
+
// this.fetchExistingTags();
|
216
|
+
};
|
271
217
|
this.state = _objectSpread(_objectSpread({}, this.state), {}, {
|
272
218
|
textErrors: [],
|
273
219
|
textIsFocused: false,
|
@@ -280,26 +226,21 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
280
226
|
this.suggestionsRef = /*#__PURE__*/React.createRef();
|
281
227
|
this.handleClickOutside = this.handleClickOutside.bind(this);
|
282
228
|
this.handleLeaveMobileClick = this.handleLeaveMobileClick.bind(this);
|
283
|
-
|
284
229
|
if (props.mobileVersionEnabled) {
|
285
230
|
var _require;
|
286
|
-
|
287
231
|
this.isMobile = (_require = require('react-device-detect')) === null || _require === void 0 ? void 0 : _require.isMobile;
|
288
232
|
}
|
289
233
|
}
|
290
|
-
|
291
234
|
focus() {
|
292
235
|
if (this.textRef.current) {
|
293
236
|
this.textRef.current.focus();
|
294
237
|
}
|
295
238
|
}
|
296
|
-
|
297
239
|
componentDidUpdate(oldProps) {
|
298
240
|
if (oldProps.tags !== this.props.tags || oldProps.validators !== this.props.validators || oldProps.customValidators !== this.props.customValidators || oldProps.required !== this.props.required) {
|
299
241
|
this.handleErrors(this.props.tags);
|
300
242
|
}
|
301
243
|
}
|
302
|
-
|
303
244
|
handleLeaveMobileClick() {
|
304
245
|
this.setState({
|
305
246
|
textIsFocused: false,
|
@@ -307,39 +248,30 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
307
248
|
preselectedSuggestion: undefined
|
308
249
|
});
|
309
250
|
}
|
310
|
-
|
311
251
|
handleClickOutside(e) {
|
312
252
|
var _this$containerRef$cu, _this$containerRef$cu2;
|
313
|
-
|
314
253
|
if (!this.containerRef.current || (_this$containerRef$cu = this.containerRef.current.querySelector('.tags-input__tag__wrapper')) !== null && _this$containerRef$cu !== void 0 && _this$containerRef$cu.contains(e.target) || (_this$containerRef$cu2 = this.containerRef.current.querySelector('.tags-input__text-input')) !== null && _this$containerRef$cu2 !== void 0 && _this$containerRef$cu2.contains(e.target) || !this.suggestionsRef.current || this.suggestionsRef.current.contains(e.target)) {
|
315
254
|
return;
|
316
255
|
}
|
317
|
-
|
318
256
|
if (this.state.suggestionsVisible) {
|
319
257
|
var _this$props$onSuggest2, _this$props4;
|
320
|
-
|
321
258
|
(_this$props$onSuggest2 = (_this$props4 = this.props).onSuggestionsClosed) === null || _this$props$onSuggest2 === void 0 ? void 0 : _this$props$onSuggest2.call(_this$props4);
|
322
259
|
}
|
323
|
-
|
324
260
|
this.setState({
|
325
261
|
suggestionsVisible: false,
|
326
262
|
preselectedSuggestion: undefined
|
327
263
|
});
|
328
|
-
|
329
264
|
if (this.props.addNewOnBlur && this.state.value) {
|
330
265
|
const suggestions = this.getSuggestions();
|
331
266
|
const existing = suggestions.find(s => s.name === this.state.value);
|
332
|
-
|
333
267
|
if (existing) {
|
334
268
|
this.onSuggestionSelected(existing, suggestions.length === 1);
|
335
269
|
} else if (this.props.allowNew) {
|
336
270
|
this.addNewTag();
|
337
271
|
}
|
338
|
-
}
|
339
|
-
|
340
|
-
|
341
|
-
}*/
|
342
|
-
|
272
|
+
} /* else if (this.state.value) {
|
273
|
+
this.setState({ value: '' });
|
274
|
+
}*/
|
343
275
|
}
|
344
276
|
|
345
277
|
componentDidMount() {
|
@@ -347,13 +279,11 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
347
279
|
document.addEventListener('touchstart', this.handleClickOutside);
|
348
280
|
this.handleErrors(this.props.tags);
|
349
281
|
}
|
350
|
-
|
351
282
|
componentWillUnmount() {
|
352
283
|
document.removeEventListener('mousedown', this.handleClickOutside);
|
353
284
|
document.removeEventListener('touchstart', this.handleClickOutside);
|
354
285
|
super.componentWillUnmount();
|
355
286
|
}
|
356
|
-
|
357
287
|
render() {
|
358
288
|
const translations = this.getTranslations(defaultTagsTranslations);
|
359
289
|
const textProps = this.props.textProps ? this.props.textProps : {};
|
@@ -443,32 +373,24 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
443
373
|
className: this.state.value !== '' || this.state.textIsFocused || this.props.readOnly || this.props.tags.length >= this.props.maxTags || showMobileVersion ? 'label--focused' : ''
|
444
374
|
}, this.renderLabel()))));
|
445
375
|
}
|
446
|
-
|
447
376
|
getErrors(tags) {
|
448
377
|
let errors = [];
|
449
|
-
|
450
378
|
if (tags.length < this.props.maxTags) {
|
451
379
|
errors = errors.concat(this.state.textErrors);
|
452
380
|
}
|
453
|
-
|
454
381
|
if (this.state.value !== '' && tags.length === 0 && this.props.required) {
|
455
382
|
errors = errors.concat(this.getTranslations(this.props.translations).required);
|
456
383
|
}
|
457
|
-
|
458
384
|
if (this.state.value && this.props.allowNew && !this.state.textIsFocused) {
|
459
385
|
errors = errors.concat(this.props.valueNotAddedError);
|
460
386
|
}
|
461
|
-
|
462
387
|
if (this.props.maxTags < (this.props.tags && this.props.tags.length)) {
|
463
388
|
errors = errors.concat(this.props.maxTagsSurpassedError);
|
464
389
|
}
|
465
|
-
|
466
390
|
return errors.filter(i => i);
|
467
391
|
}
|
468
|
-
|
469
392
|
fetchExistingTags() {
|
470
393
|
let startsWith = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
471
|
-
|
472
394
|
if (this.props.fetchExistingTags && startsWith.length >= this.props.minLettersToFetch) {
|
473
395
|
const timer = setTimeout(() => this.setState(() => ({
|
474
396
|
fetchingExistingTags: true
|
@@ -482,14 +404,12 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
482
404
|
});
|
483
405
|
}
|
484
406
|
}
|
485
|
-
|
486
407
|
getSuggestions() {
|
487
408
|
const existingTags = [].concat(this.props.existingTags ? this.props.existingTags : []).concat(this.state.fetchedExistingTags ? this.state.fetchedExistingTags : []);
|
488
409
|
const filteredTags = this.props.filterExistingTags(this.state.value ? this.state.value.toLowerCase() : '', existingTags);
|
489
410
|
let suggestions = filteredTags.filter(tag => this.props.allowSameTagMultipleTimes || !this.props.tags.some(t => t.id === tag.id)).slice(0, this.props.maxSuggestions);
|
490
411
|
return suggestions;
|
491
412
|
}
|
492
|
-
|
493
413
|
renderTag(tag, index) {
|
494
414
|
const body = /*#__PURE__*/React.createElement(React.Fragment, null, tag.name, !this.props.readOnly && /*#__PURE__*/React.createElement(_Button.Button, _extends({}, this.props.id && {
|
495
415
|
id: this.props.id + '-tag-' + index.toString()
|
@@ -504,7 +424,6 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
504
424
|
const className = (0, _classnames.default)('tags-input__tag', {
|
505
425
|
'tags-input__tag-chip': this.props.showChips
|
506
426
|
});
|
507
|
-
|
508
427
|
if (this.props.onTagClick) {
|
509
428
|
return /*#__PURE__*/React.createElement(_Button.Button, {
|
510
429
|
onClick: this.tagClick(tag),
|
@@ -513,19 +432,15 @@ class TagsRaw extends _BaseInput.BaseInput {
|
|
513
432
|
key: index
|
514
433
|
}, body);
|
515
434
|
}
|
516
|
-
|
517
435
|
return /*#__PURE__*/React.createElement("div", {
|
518
436
|
onClick: this.tagClick(tag),
|
519
437
|
className: className,
|
520
438
|
key: index
|
521
439
|
}, body);
|
522
440
|
}
|
523
|
-
|
524
441
|
}
|
525
|
-
|
526
442
|
exports.TagsRaw = TagsRaw;
|
527
|
-
|
528
|
-
_defineProperty(TagsRaw, "defaultProps", _objectSpread(_objectSpread({}, _BaseInput.BaseInput.defaultProps), {}, {
|
443
|
+
TagsRaw.defaultProps = _objectSpread(_objectSpread({}, _BaseInput.BaseInput.defaultProps), {}, {
|
529
444
|
disabled: false,
|
530
445
|
className: '',
|
531
446
|
tags: [],
|
@@ -552,9 +467,9 @@ _defineProperty(TagsRaw, "defaultProps", _objectSpread(_objectSpread({}, _BaseIn
|
|
552
467
|
minLettersToFetch: 0,
|
553
468
|
mobileVersionEnabled: true,
|
554
469
|
closeSuggestionsAfterCreate: false
|
555
|
-
})
|
556
|
-
|
557
|
-
|
470
|
+
});
|
471
|
+
const Tags = (0, _withThemeContext.withThemeContext)(
|
472
|
+
// tslint:disable-next-line: no-any
|
558
473
|
(0, _withFormContext.withFormContext)(TagsRaw), 'tags');
|
559
474
|
exports.Tags = Tags;
|
560
475
|
var _default = Tags;
|