guestbell-forms 3.0.103 → 3.0.104

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.
@@ -0,0 +1,44 @@
1
+ /// <reference types="react" />
2
+ import { AllowedHtmlElements, BaseTranslations, ValidationError } from './BaseInput';
3
+ import * as Validators from '../../../validators';
4
+ import { FormContextState } from '../../form/FormContext';
5
+ interface UseBaseInputProps<TranslationsT extends BaseTranslations> {
6
+ value?: string;
7
+ required?: boolean;
8
+ validators?: string[];
9
+ customValidators?: Validators.IBaseValidator[];
10
+ onTheFlightValidate?: (value: string) => boolean;
11
+ onChange?: (event: React.ChangeEvent<AllowedHtmlElements>, isValid: boolean) => void;
12
+ onBlur?: () => void;
13
+ onFocus?: () => void;
14
+ errors?: ValidationError[];
15
+ infoText?: string;
16
+ touchOn?: 'focus' | 'blur';
17
+ showValidation?: boolean;
18
+ disabled?: boolean;
19
+ ignoreContext?: boolean;
20
+ formContext?: FormContextState;
21
+ translations?: TranslationsT;
22
+ validationName?: string;
23
+ label?: string | JSX.Element;
24
+ }
25
+ export declare function useBaseInput<TranslationsT extends BaseTranslations = BaseTranslations>(props: UseBaseInputProps<TranslationsT>): {
26
+ value: string;
27
+ setValue: (newValue: string) => void;
28
+ isValid: boolean;
29
+ errors: ValidationError[];
30
+ touched: boolean;
31
+ focused: boolean;
32
+ inputRef: import("react").MutableRefObject<AllowedHtmlElements>;
33
+ containerRef: import("react").MutableRefObject<HTMLDivElement>;
34
+ handleFocus: () => void;
35
+ handleBlur: () => void;
36
+ scrollTo: () => void;
37
+ setValid: () => void;
38
+ setInvalid: (validationErrors?: ValidationError[]) => void;
39
+ disableComponent: () => void;
40
+ enableComponent: () => void;
41
+ setTouched: import("react").Dispatch<import("react").SetStateAction<boolean>>;
42
+ componentDisabled: boolean;
43
+ };
44
+ export {};
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useBaseInput = useBaseInput;
7
+ var _react = require("react");
8
+ var Validators = _interopRequireWildcard(require("../../../validators"));
9
+ var _Guid = _interopRequireDefault(require("../../utils/Guid"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ 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); }
12
+ 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; }
13
+ // experimental and unfinished and unused for now
14
+
15
+ function useBaseInput(props) {
16
+ const {
17
+ value: initialValue = '',
18
+ required = false,
19
+ validators = [],
20
+ customValidators = [],
21
+ onTheFlightValidate,
22
+ onChange,
23
+ onBlur,
24
+ onFocus,
25
+ //errors: propErrors = [],
26
+ //infoText,
27
+ touchOn = 'focus',
28
+ //showValidation = true,
29
+ disabled = false,
30
+ ignoreContext = false,
31
+ formContext,
32
+ translations,
33
+ validationName,
34
+ label
35
+ } = props;
36
+ const [value, setValue] = (0, _react.useState)(initialValue);
37
+ const [touched, setTouched] = (0, _react.useState)(false);
38
+ const [isValid, setIsValid] = (0, _react.useState)(true);
39
+ const [errors, setErrors] = (0, _react.useState)([]);
40
+ const [focused, setFocused] = (0, _react.useState)(false);
41
+ const [componentDisabled, setComponentDisabled] = (0, _react.useState)(disabled);
42
+ const inputRef = (0, _react.useRef)(null);
43
+ const containerRef = (0, _react.useRef)(null);
44
+ const componentId = (0, _react.useRef)((0, _Guid.default)());
45
+ const handleValidation = (0, _react.useCallback)(function (currentValue) {
46
+ let initializing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
47
+ let validationErrors = [];
48
+ let validationStatus = true;
49
+ if (required && !currentValue) {
50
+ validationErrors.push((translations === null || translations === void 0 ? void 0 : translations.required) || 'This field is required');
51
+ validationStatus = false;
52
+ } else if (validators) {
53
+ validators.forEach(validator => {
54
+ let isValidForValidator = false;
55
+ switch (validator) {
56
+ case 'email':
57
+ isValidForValidator = new Validators.EmailValidator().Validate(currentValue, required, error => validationErrors.push(error));
58
+ break;
59
+ // Add other validators as needed
60
+ default:
61
+ throw new Error(`Validator ${validator} not implemented`);
62
+ }
63
+ if (!isValidForValidator) validationStatus = false;
64
+ });
65
+ }
66
+ customValidators.forEach(customValidator => {
67
+ const isValidForCustomValidator = customValidator.Validate(currentValue, required, error => validationErrors.push(error));
68
+ if (!isValidForCustomValidator) validationStatus = false;
69
+ });
70
+ setErrors(validationErrors);
71
+ setIsValid(validationStatus);
72
+ if (!initializing && !ignoreContext) {
73
+ formContext === null || formContext === void 0 ? void 0 : formContext.updateCallback(componentId.current, {
74
+ isValid: validationStatus,
75
+ errors: validationErrors
76
+ });
77
+ }
78
+ return {
79
+ isValid: validationStatus,
80
+ errors: validationErrors
81
+ };
82
+ }, [required, validators, customValidators, formContext, translations, ignoreContext]);
83
+ const handleValueChange = (0, _react.useCallback)(newValue => {
84
+ if (!onTheFlightValidate || onTheFlightValidate(newValue)) {
85
+ const result = handleValidation(newValue);
86
+ setValue(newValue);
87
+ onChange === null || onChange === void 0 ? void 0 : onChange({
88
+ target: {
89
+ value: newValue
90
+ }
91
+ }, result.isValid);
92
+ }
93
+ }, [handleValidation, onTheFlightValidate, onChange]);
94
+ const handleFocus = (0, _react.useCallback)(() => {
95
+ if (!disabled) {
96
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus();
97
+ setFocused(true);
98
+ if (touchOn === 'focus') setTouched(true);
99
+ }
100
+ }, [disabled, onFocus, touchOn]);
101
+ const handleBlur = (0, _react.useCallback)(() => {
102
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur();
103
+ setFocused(false);
104
+ if (touchOn === 'blur') setTouched(true);
105
+ }, [onBlur, touchOn]);
106
+ const scrollTo = (0, _react.useCallback)(() => {
107
+ var _containerRef$current;
108
+ (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.scrollIntoView({
109
+ behavior: 'smooth'
110
+ });
111
+ }, []);
112
+ const setValid = (0, _react.useCallback)(() => {
113
+ setIsValid(true);
114
+ setErrors([]);
115
+ formContext === null || formContext === void 0 ? void 0 : formContext.updateCallback(componentId.current, {
116
+ isValid: true,
117
+ errors: []
118
+ });
119
+ }, [formContext]);
120
+ const setInvalid = (0, _react.useCallback)(function () {
121
+ let validationErrors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
122
+ setIsValid(false);
123
+ setErrors(validationErrors);
124
+ formContext === null || formContext === void 0 ? void 0 : formContext.updateCallback(componentId.current, {
125
+ isValid: false,
126
+ errors: validationErrors
127
+ });
128
+ }, [formContext]);
129
+ const disableComponent = (0, _react.useCallback)(() => {
130
+ setComponentDisabled(true);
131
+ }, []);
132
+ const enableComponent = (0, _react.useCallback)(() => {
133
+ setComponentDisabled(false);
134
+ }, []);
135
+ (0, _react.useEffect)(() => {
136
+ handleValidation(value, true);
137
+ if (!ignoreContext && formContext) {
138
+ formContext.subscribe(componentId.current, {
139
+ componentApi: {
140
+ disableComponent,
141
+ enableComponent,
142
+ focus: () => {
143
+ var _inputRef$current;
144
+ return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
145
+ },
146
+ scrollTo,
147
+ touch: () => setTouched(true),
148
+ unTouch: () => setTouched(false)
149
+ },
150
+ validation: {
151
+ isValid,
152
+ errors,
153
+ name: validationName || label
154
+ }
155
+ });
156
+ }
157
+ return () => {
158
+ if (!ignoreContext) formContext === null || formContext === void 0 ? void 0 : formContext.unSubscribe(componentId.current);
159
+ };
160
+ }, [formContext, ignoreContext, handleValidation, value]);
161
+ return {
162
+ value,
163
+ setValue: handleValueChange,
164
+ isValid,
165
+ errors,
166
+ touched,
167
+ focused,
168
+ inputRef,
169
+ containerRef,
170
+ handleFocus,
171
+ handleBlur,
172
+ scrollTo,
173
+ setValid,
174
+ setInvalid,
175
+ disableComponent,
176
+ enableComponent,
177
+ setTouched,
178
+ componentDisabled
179
+ };
180
+ }
181
+ //# sourceMappingURL=useBaseInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBaseInput.js","names":["_react","require","Validators","_interopRequireWildcard","_Guid","_interopRequireDefault","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","useBaseInput","props","value","initialValue","required","validators","customValidators","onTheFlightValidate","onChange","onBlur","onFocus","touchOn","disabled","ignoreContext","formContext","translations","validationName","label","setValue","useState","touched","setTouched","isValid","setIsValid","errors","setErrors","focused","setFocused","componentDisabled","setComponentDisabled","inputRef","useRef","containerRef","componentId","guid","handleValidation","useCallback","currentValue","initializing","arguments","length","undefined","validationErrors","validationStatus","push","forEach","validator","isValidForValidator","EmailValidator","Validate","error","Error","customValidator","isValidForCustomValidator","updateCallback","current","handleValueChange","newValue","result","target","handleFocus","handleBlur","scrollTo","_containerRef$current","scrollIntoView","behavior","setValid","setInvalid","disableComponent","enableComponent","useEffect","subscribe","componentApi","focus","_inputRef$current","touch","unTouch","validation","name","unSubscribe"],"sources":["../../../../src/lib/components/base/input/useBaseInput.tsx"],"sourcesContent":["// experimental and unfinished and unused for now\nimport { useState, useRef, useCallback, useEffect } from 'react';\nimport {\n AllowedHtmlElements,\n BaseTranslations,\n ValidationError,\n} from './BaseInput';\nimport * as Validators from '../../../validators';\nimport { FormContextState } from '../../form/FormContext';\nimport guid from '../../utils/Guid';\n\ninterface UseBaseInputProps<TranslationsT extends BaseTranslations> {\n value?: string;\n required?: boolean;\n validators?: string[];\n customValidators?: Validators.IBaseValidator[];\n onTheFlightValidate?: (value: string) => boolean;\n onChange?: (\n event: React.ChangeEvent<AllowedHtmlElements>,\n isValid: boolean\n ) => void;\n onBlur?: () => void;\n onFocus?: () => void;\n errors?: ValidationError[];\n infoText?: string;\n touchOn?: 'focus' | 'blur';\n showValidation?: boolean;\n disabled?: boolean;\n ignoreContext?: boolean;\n formContext?: FormContextState;\n translations?: TranslationsT;\n validationName?: string;\n label?: string | JSX.Element;\n}\n\nexport function useBaseInput<\n TranslationsT extends BaseTranslations = BaseTranslations\n>(props: UseBaseInputProps<TranslationsT>) {\n const {\n value: initialValue = '',\n required = false,\n validators = [],\n customValidators = [],\n onTheFlightValidate,\n onChange,\n onBlur,\n onFocus,\n //errors: propErrors = [],\n //infoText,\n touchOn = 'focus',\n //showValidation = true,\n disabled = false,\n ignoreContext = false,\n formContext,\n translations,\n validationName,\n label,\n } = props;\n\n const [value, setValue] = useState<string>(initialValue);\n const [touched, setTouched] = useState<boolean>(false);\n const [isValid, setIsValid] = useState<boolean>(true);\n const [errors, setErrors] = useState<ValidationError[]>([]);\n const [focused, setFocused] = useState<boolean>(false);\n const [componentDisabled, setComponentDisabled] = useState<boolean>(disabled);\n\n const inputRef = useRef<AllowedHtmlElements>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const componentId = useRef(guid());\n\n const handleValidation = useCallback(\n (currentValue: string, initializing = false) => {\n let validationErrors: ValidationError[] = [];\n let validationStatus = true;\n\n if (required && !currentValue) {\n validationErrors.push(\n translations?.required || 'This field is required'\n );\n validationStatus = false;\n } else if (validators) {\n validators.forEach((validator) => {\n let isValidForValidator = false;\n switch (validator) {\n case 'email':\n isValidForValidator = new Validators.EmailValidator().Validate(\n currentValue,\n required,\n (error) => validationErrors.push(error)\n );\n break;\n // Add other validators as needed\n default:\n throw new Error(`Validator ${validator} not implemented`);\n }\n if (!isValidForValidator) validationStatus = false;\n });\n }\n\n customValidators.forEach((customValidator) => {\n const isValidForCustomValidator = customValidator.Validate(\n currentValue,\n required,\n (error) => validationErrors.push(error)\n );\n if (!isValidForCustomValidator) validationStatus = false;\n });\n\n setErrors(validationErrors);\n setIsValid(validationStatus);\n\n if (!initializing && !ignoreContext) {\n formContext?.updateCallback(componentId.current, {\n isValid: validationStatus,\n errors: validationErrors,\n });\n }\n\n return { isValid: validationStatus, errors: validationErrors };\n },\n [\n required,\n validators,\n customValidators,\n formContext,\n translations,\n ignoreContext,\n ]\n );\n\n const handleValueChange = useCallback(\n (newValue: string) => {\n if (!onTheFlightValidate || onTheFlightValidate(newValue)) {\n const result = handleValidation(newValue);\n setValue(newValue);\n onChange?.(\n {\n target: { value: newValue },\n } as React.ChangeEvent<AllowedHtmlElements>,\n result.isValid\n );\n }\n },\n [handleValidation, onTheFlightValidate, onChange]\n );\n\n const handleFocus = useCallback(() => {\n if (!disabled) {\n onFocus?.();\n setFocused(true);\n if (touchOn === 'focus') setTouched(true);\n }\n }, [disabled, onFocus, touchOn]);\n\n const handleBlur = useCallback(() => {\n onBlur?.();\n setFocused(false);\n if (touchOn === 'blur') setTouched(true);\n }, [onBlur, touchOn]);\n\n const scrollTo = useCallback(() => {\n containerRef.current?.scrollIntoView({ behavior: 'smooth' });\n }, []);\n\n const setValid = useCallback(() => {\n setIsValid(true);\n setErrors([]);\n formContext?.updateCallback(componentId.current, {\n isValid: true,\n errors: [],\n });\n }, [formContext]);\n\n const setInvalid = useCallback(\n (validationErrors: ValidationError[] = []) => {\n setIsValid(false);\n setErrors(validationErrors);\n formContext?.updateCallback(componentId.current, {\n isValid: false,\n errors: validationErrors,\n });\n },\n [formContext]\n );\n\n const disableComponent = useCallback(() => {\n setComponentDisabled(true);\n }, []);\n\n const enableComponent = useCallback(() => {\n setComponentDisabled(false);\n }, []);\n\n useEffect(() => {\n handleValidation(value, true);\n\n if (!ignoreContext && formContext) {\n formContext.subscribe(componentId.current, {\n componentApi: {\n disableComponent,\n enableComponent,\n focus: () => inputRef.current?.focus(),\n scrollTo,\n touch: () => setTouched(true),\n unTouch: () => setTouched(false),\n },\n validation: {\n isValid,\n errors,\n name: validationName || label,\n },\n });\n }\n\n return () => {\n if (!ignoreContext) formContext?.unSubscribe(componentId.current);\n };\n }, [formContext, ignoreContext, handleValidation, value]);\n\n return {\n value,\n setValue: handleValueChange,\n isValid,\n errors,\n touched,\n focused,\n inputRef,\n containerRef,\n handleFocus,\n handleBlur,\n scrollTo,\n setValid,\n setInvalid,\n disableComponent,\n enableComponent,\n setTouched,\n componentDisabled,\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,UAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAoC,SAAAI,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAP,wBAAAG,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,WAAA,OAAAI,KAAA,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AAK;QACjC,CAAC;QACDwD,UAAU,EAAE;UACVvD,OAAO;UACPE,MAAM;UACNsD,IAAI,EAAE9D,cAAc,IAAIC;QAC1B;MACF,CAAC,CAAC;IACJ;IAEA,OAAO,MAAM;MACX,IAAI,CAACJ,aAAa,EAAEC,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEiE,WAAW,CAAC9C,WAAW,CAACsB,OAAO,CAAC;IACnE,CAAC;EACH,CAAC,EAAE,CAACzC,WAAW,EAAED,aAAa,EAAEsB,gBAAgB,EAAEjC,KAAK,CAAC,CAAC;EAEzD,OAAO;IACLA,KAAK;IACLgB,QAAQ,EAAEsC,iBAAiB;IAC3BlC,OAAO;IACPE,MAAM;IACNJ,OAAO;IACPM,OAAO;IACPI,QAAQ;IACRE,YAAY;IACZ4B,WAAW;IACXC,UAAU;IACVC,QAAQ;IACRI,QAAQ;IACRC,UAAU;IACVC,gBAAgB;IAChBC,eAAe;IACfhD,UAAU;IACVO;EACF,CAAC;AACH"}
@@ -79,7 +79,7 @@ export declare class TagsRaw<IdT extends number | string = number, T extends Res
79
79
  private isMobile;
80
80
  constructor(props: TagsProps<IdT, T> & InjectedProps);
81
81
  focus(): void;
82
- componentDidUpdate(oldProps: TagsProps<IdT, T> & InjectedProps): void;
82
+ componentDidUpdate(oldProps: TagsProps<IdT, T> & InjectedProps, oldState: TagsState<IdT, T>): void;
83
83
  handleLeaveMobileClick(): void;
84
84
  handleClickOutside(e: MouseEvent): void;
85
85
  componentDidMount(): void;
@@ -80,7 +80,6 @@ class TagsRaw extends _BaseInput.BaseInput {
80
80
  var _this$props$onSuggest, _this$props2;
81
81
  (_this$props$onSuggest = (_this$props2 = this.props).onSuggestionsOpened) === null || _this$props$onSuggest === void 0 ? void 0 : _this$props$onSuggest.call(_this$props2);
82
82
  }
83
- this.fetchExistingTags(this.state.value);
84
83
  this.setState(() => ({
85
84
  textIsFocused: true,
86
85
  suggestionsVisible: true,
@@ -111,7 +110,6 @@ class TagsRaw extends _BaseInput.BaseInput {
111
110
  value: '',
112
111
  preselectedSuggestion: undefined
113
112
  }, () => {
114
- this.fetchExistingTags();
115
113
  this.handleErrors();
116
114
  });
117
115
  } else if (existingTag) {
@@ -119,7 +117,6 @@ class TagsRaw extends _BaseInput.BaseInput {
119
117
  this.setState({
120
118
  value: ''
121
119
  }, () => {
122
- this.fetchExistingTags();
123
120
  this.handleErrors();
124
121
  });
125
122
  } else if (this.props.allowNew) {
@@ -150,14 +147,14 @@ class TagsRaw extends _BaseInput.BaseInput {
150
147
  this.setState({
151
148
  suggestionsVisible: this.props.closeSuggestionsAfterCreate ? false : this.state.suggestionsVisible
152
149
  });
150
+ const newTags = newTag ? this.props.tags ? this.props.tags.concat(newTag) : [newTag] : this.props.tags;
153
151
  if (newTag) {
154
- this.props.onTagsChanged(this.props.tags ? this.props.tags.concat(newTag) : [newTag]);
152
+ this.props.onTagsChanged(newTags);
155
153
  }
156
154
  this.setState({
157
155
  value: '',
158
156
  textErrors: []
159
157
  }, () => {
160
- this.fetchExistingTags();
161
158
  this.handleErrors();
162
159
  });
163
160
  };
@@ -199,7 +196,6 @@ class TagsRaw extends _BaseInput.BaseInput {
199
196
  textIsValid: isValid,
200
197
  suggestionsVisible: true
201
198
  }), () => this.handleErrors());
202
- this.fetchExistingTags(e.target.value);
203
199
  };
204
200
  this.handleErrors = function () {
205
201
  let tags = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props.tags;
@@ -253,12 +249,12 @@ class TagsRaw extends _BaseInput.BaseInput {
253
249
  this.textRef.current.focus();
254
250
  }
255
251
  }
256
- componentDidUpdate(oldProps) {
252
+ componentDidUpdate(oldProps, oldState) {
257
253
  if (oldProps.tags !== this.props.tags || oldProps.validators !== this.props.validators || oldProps.customValidators !== this.props.customValidators || oldProps.required !== this.props.required) {
258
254
  this.handleErrors(this.props.tags);
259
255
  }
260
- if (oldProps.tags !== this.props.tags && this.state.suggestionsVisible) {
261
- this.fetchExistingTags();
256
+ if (this.state.suggestionsVisible && (oldProps.tags !== this.props.tags || oldProps.existingTags !== this.props.existingTags || this.state.value !== oldState.value || this.state.suggestionsVisible !== oldState.suggestionsVisible)) {
257
+ this.fetchExistingTags(this.state.value);
262
258
  }
263
259
  }
264
260
  handleLeaveMobileClick() {
@@ -423,9 +419,16 @@ class TagsRaw extends _BaseInput.BaseInput {
423
419
  fetchingExistingTags: true
424
420
  })), this.props.loadingDelayMs);
425
421
  this.props.fetchExistingTags(startsWith, this.props.tags).then(fetchedExistingTags => {
422
+ if (fetchedExistingTags) {
423
+ clearTimeout(timer);
424
+ this.setState(() => ({
425
+ fetchedExistingTags,
426
+ fetchingExistingTags: false
427
+ }));
428
+ }
429
+ }).catch(() => {
426
430
  clearTimeout(timer);
427
431
  this.setState(() => ({
428
- fetchedExistingTags,
429
432
  fetchingExistingTags: false
430
433
  }));
431
434
  });
@@ -447,10 +450,12 @@ class TagsRaw extends _BaseInput.BaseInput {
447
450
  circular: true,
448
451
  blank: true,
449
452
  onClick: this.tagRemoveClick(tag),
450
- className: "ml-1 transform-rotate--45 line-height--0 p-0",
453
+ className: "tags-input__tag__removeButton p-0",
451
454
  Component: TagButtonComponent,
452
455
  preventsDefault: false
453
- }), /*#__PURE__*/React.createElement(PlusIcon, null)));
456
+ }), /*#__PURE__*/React.createElement(PlusIcon, {
457
+ className: "transform-rotate--45"
458
+ })));
454
459
  const className = (0, _classnames.default)('tags-input__tag', {
455
460
  'tags-input__tag-chip': this.props.showChips
456
461
  });
@@ -462,7 +467,7 @@ class TagsRaw extends _BaseInput.BaseInput {
462
467
  key: index
463
468
  }, body);
464
469
  }
465
- return /*#__PURE__*/React.createElement("div", {
470
+ return /*#__PURE__*/React.createElement("span", {
466
471
  onClick: this.tagClick(tag),
467
472
  className: className,
468
473
  key: index