guestbell-forms 2.0.286 → 2.0.289

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.
@@ -5,6 +5,7 @@ export interface CheckboxProps extends BaseInputProps<HTMLInputElement> {
5
5
  onChange?: never;
6
6
  type?: string;
7
7
  checked?: boolean;
8
+ supportsIndeterminate?: boolean;
8
9
  }
9
10
  export interface CheckboxState extends BaseInputState {
10
11
  checked: boolean;
@@ -12,11 +13,11 @@ export interface CheckboxState extends BaseInputState {
12
13
  export declare class CheckboxRaw extends BaseInput<CheckboxProps, CheckboxState, HTMLInputElement> {
13
14
  static defaultProps: CheckboxProps;
14
15
  constructor(props: CheckboxProps);
16
+ componentDidMount(): void;
15
17
  componentDidUpdate(oldProps: CheckboxProps): void;
16
18
  render(): JSX.Element;
17
19
  private handleChecked;
18
20
  protected handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>): void;
19
- private renderInput;
20
21
  }
21
22
  export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<CheckboxRaw>>;
22
23
  export default Checkbox;
@@ -31,6 +31,10 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
31
31
 
32
32
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
33
33
 
34
+ function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
35
+
36
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
37
+
34
38
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
35
39
 
36
40
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
@@ -74,8 +78,23 @@ var CheckboxRaw = /*#__PURE__*/function (_BaseInput) {
74
78
  }
75
79
 
76
80
  _createClass(CheckboxRaw, [{
81
+ key: "componentDidMount",
82
+ value: function componentDidMount() {
83
+ var _this$inputRef$curren, _get2;
84
+
85
+ var finalIndeterminate = Boolean(this.props.supportsIndeterminate && typeof this.props.checked !== 'boolean');
86
+
87
+ if (typeof this.props.checked !== 'boolean' && this.inputRef.current && ((_this$inputRef$curren = this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.indeterminate) !== finalIndeterminate) {
88
+ this.inputRef.current.indeterminate = finalIndeterminate;
89
+ }
90
+
91
+ (_get2 = _get(_getPrototypeOf(CheckboxRaw.prototype), "componentDidMount", this)) === null || _get2 === void 0 ? void 0 : _get2.call(this);
92
+ }
93
+ }, {
77
94
  key: "componentDidUpdate",
78
95
  value: function componentDidUpdate(oldProps) {
96
+ var _this$inputRef$curren2;
97
+
79
98
  if (this.props.checked !== this.state.checked) {
80
99
  this.setState({
81
100
  checked: this.props.checked
@@ -97,20 +116,42 @@ var CheckboxRaw = /*#__PURE__*/function (_BaseInput) {
97
116
  this.setValid();
98
117
  }
99
118
  }
119
+
120
+ var finalIndeterminate = Boolean(this.props.supportsIndeterminate && typeof this.props.checked !== 'boolean');
121
+
122
+ if (this.props.supportsIndeterminate && ((_this$inputRef$curren2 = this.inputRef.current) === null || _this$inputRef$curren2 === void 0 ? void 0 : _this$inputRef$curren2.indeterminate) !== finalIndeterminate) {
123
+ this.inputRef.current.indeterminate = finalIndeterminate;
124
+ }
100
125
  }
101
126
  }, {
102
127
  key: "render",
103
128
  value: function render() {
129
+ var _this$state$checked;
130
+
104
131
  var containerClassName = classNames(['input__base checkbox-input', this.getValidationClass(), this.props.className, _defineProperty({}, 'checkbox-input--with-label', Boolean(this.props.label)), _defineProperty({}, 'checkbox-input--disabled', this.props.disabled)]);
132
+ var input = /*#__PURE__*/React.createElement("input", _extends({}, this.props.id && {
133
+ id: this.props.id
134
+ }, {
135
+ ref: this.inputRef,
136
+ value: this.props.value || '',
137
+ type: "checkbox",
138
+ required: this.props.required,
139
+ checked: (_this$state$checked = this.state.checked) !== null && _this$state$checked !== void 0 ? _this$state$checked : false,
140
+ onChange: this.handleChecked,
141
+ onBlur: this.handleBlur,
142
+ onFocus: this.handleFocus,
143
+ onKeyDown: this.handleKeyDown,
144
+ tabIndex: this.props.disabled ? -1 : 0
145
+ }));
105
146
  return /*#__PURE__*/React.createElement(_InputGroup.default, {
106
147
  title: this.props.title,
107
148
  tooltip: this.props.tooltip
108
149
  }, /*#__PURE__*/React.createElement("div", {
109
150
  className: containerClassName,
110
151
  ref: this.containerRef
111
- }, this.props.title && !this.props.label && this.renderInput(), !this.props.title && !this.props.label && this.renderTooltip(this.renderInput()), this.renderDefaultValidation(), this.props.label && /*#__PURE__*/React.createElement("label", {
152
+ }, this.props.title && !this.props.label && input, !this.props.title && !this.props.label && this.renderTooltip(input), this.renderDefaultValidation(), this.props.label && /*#__PURE__*/React.createElement("label", {
112
153
  className: "checkbox-input__label"
113
- }, this.renderInput(), this.renderLabel())));
154
+ }, input, this.renderLabel())));
114
155
  }
115
156
  }, {
116
157
  key: "handleChecked",
@@ -135,30 +176,12 @@ var CheckboxRaw = /*#__PURE__*/function (_BaseInput) {
135
176
  value: function handleKeyDown(e) {
136
177
  if (!this.props.disabled) {
137
178
  if (e.key === 'Enter') {
138
- var _this$inputRef$curren;
179
+ var _this$inputRef$curren3;
139
180
 
140
- (_this$inputRef$curren = this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.click();
181
+ (_this$inputRef$curren3 = this.inputRef.current) === null || _this$inputRef$curren3 === void 0 ? void 0 : _this$inputRef$curren3.click();
141
182
  }
142
183
  }
143
184
  }
144
- }, {
145
- key: "renderInput",
146
- value: function renderInput() {
147
- return /*#__PURE__*/React.createElement("input", _extends({}, this.props.id && {
148
- id: this.props.id
149
- }, {
150
- ref: this.inputRef,
151
- value: this.props.value || '',
152
- type: "checkbox",
153
- required: this.props.required,
154
- checked: this.state.checked,
155
- onChange: this.handleChecked,
156
- onBlur: this.handleBlur,
157
- onFocus: this.handleFocus,
158
- onKeyDown: this.handleKeyDown,
159
- tabIndex: this.props.disabled ? -1 : 0
160
- }));
161
- }
162
185
  }]);
163
186
 
164
187
  return CheckboxRaw;
@@ -166,8 +189,7 @@ var CheckboxRaw = /*#__PURE__*/function (_BaseInput) {
166
189
 
167
190
  exports.CheckboxRaw = CheckboxRaw;
168
191
 
169
- _defineProperty(CheckboxRaw, "defaultProps", Object.assign({}, _BaseInput2.BaseInput.defaultProps, {
170
- checked: false
192
+ _defineProperty(CheckboxRaw, "defaultProps", Object.assign({}, _BaseInput2.BaseInput.defaultProps, {// checked: false,
171
193
  }));
172
194
 
173
195
  var Checkbox = (0, _withThemeContext.withThemeContext)((0, _withFormContext.withFormContext)(CheckboxRaw), 'checkbox');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/components/checkbox/Checkbox.tsx"],"names":["classNames","require","CheckboxRaw","props","state","Object","assign","checked","isValid","required","errors","getTranslations","defaultBaseTranslations","handleChecked","bind","handleKeyDown","subscribeSelf","oldProps","setState","setValid","setInvalid","containerClassName","getValidationClass","className","Boolean","label","disabled","title","tooltip","containerRef","renderInput","renderTooltip","renderDefaultValidation","renderLabel","e","onChecked","key","inputRef","current","click","id","value","handleBlur","handleFocus","BaseInput","defaultProps","Checkbox"],"mappings":";;;;;;;;;AACA;;AAGA;;AACA;;AAOA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAFA,IAAIA,UAAU,GAAGC,OAAO,C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BsC,sBAAUC,YAA5B,EAA0C;AACrEtC,EAAAA,OAAO,EAAE;AAD4D,CAA1C,C;;AAiHxB,IAAMuC,QAAQ,GAAG,wCAGtB,sCAA+B5C,WAA/B,CAHsB,EAGuB,UAHvB,CAAjB;;eAKQ4C,Q","sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport InputGroup from '../inputGroup/InputGroup';\r\nimport {\r\n BaseInputProps,\r\n BaseInput,\r\n BaseInputState,\r\n defaultBaseTranslations,\r\n} from '../base/input/BaseInput';\r\nvar classNames = require('classnames');\r\nimport { withFormContext } from '../form/withFormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\n\r\nexport interface CheckboxProps extends BaseInputProps<HTMLInputElement> {\r\n onChecked?: (e: React.ChangeEvent<HTMLInputElement>) => void;\r\n onChange?: never;\r\n type?: string;\r\n checked?: boolean;\r\n}\r\n\r\nexport interface CheckboxState extends BaseInputState {\r\n checked: boolean;\r\n}\r\n\r\nexport class CheckboxRaw extends BaseInput<\r\n CheckboxProps,\r\n CheckboxState,\r\n HTMLInputElement\r\n> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n checked: false,\r\n }) as CheckboxProps;\r\n\r\n constructor(props: CheckboxProps) {\r\n super(props, false);\r\n this.state = Object.assign(this.state, {\r\n checked: props.checked,\r\n isValid: props.required ? props.checked : true,\r\n errors:\r\n props.required && !props.checked\r\n ? [this.getTranslations(defaultBaseTranslations).required]\r\n : [],\r\n });\r\n this.handleChecked = this.handleChecked.bind(this);\r\n this.handleKeyDown = this.handleKeyDown.bind(this);\r\n this.subscribeSelf(props);\r\n }\r\n\r\n public componentDidUpdate(oldProps: CheckboxProps) {\r\n if (this.props.checked !== this.state.checked) {\r\n this.setState({ checked: this.props.checked });\r\n if (this.props.checked) {\r\n this.setValid();\r\n } else {\r\n if (this.props.required) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n }\r\n }\r\n }\r\n if (oldProps.required !== this.props.required) {\r\n if (this.props.required && !this.props.checked) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n } else {\r\n this.setValid();\r\n }\r\n }\r\n }\r\n\r\n public render() {\r\n const containerClassName = classNames([\r\n 'input__base checkbox-input',\r\n this.getValidationClass(),\r\n this.props.className,\r\n { ['checkbox-input--with-label']: Boolean(this.props.label) },\r\n { ['checkbox-input--disabled']: this.props.disabled },\r\n ]);\r\n return (\r\n <InputGroup title={this.props.title} tooltip={this.props.tooltip}>\r\n <div className={containerClassName} ref={this.containerRef}>\r\n {this.props.title && !this.props.label && this.renderInput()}\r\n {!this.props.title &&\r\n !this.props.label &&\r\n this.renderTooltip(this.renderInput())}\r\n {this.renderDefaultValidation()}\r\n {this.props.label && (\r\n <label className=\"checkbox-input__label\">\r\n {this.renderInput()}\r\n {this.renderLabel()}\r\n </label>\r\n )}\r\n </div>\r\n </InputGroup>\r\n );\r\n }\r\n\r\n private handleChecked(e: React.ChangeEvent<HTMLInputElement>) {\r\n if (!this.props.disabled) {\r\n this.props.onChecked && this.props.onChecked(e);\r\n this.setState({ checked: !this.state.checked });\r\n if (!this.state.checked) {\r\n this.setValid();\r\n } else {\r\n if (this.props.required) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {\r\n if (!this.props.disabled) {\r\n if (e.key === 'Enter') {\r\n this.inputRef.current?.click();\r\n }\r\n }\r\n }\r\n\r\n private renderInput() {\r\n return (\r\n <input\r\n {...(this.props.id && { id: this.props.id })}\r\n ref={this.inputRef}\r\n value={this.props.value || ''}\r\n type=\"checkbox\"\r\n required={this.props.required}\r\n checked={this.state.checked}\r\n onChange={this.handleChecked}\r\n onBlur={this.handleBlur}\r\n onFocus={this.handleFocus}\r\n onKeyDown={this.handleKeyDown}\r\n tabIndex={this.props.disabled ? -1 : 0}\r\n />\r\n );\r\n }\r\n}\r\n\r\nexport const Checkbox = withThemeContext<\r\n CheckboxProps,\r\n InstanceType<typeof CheckboxRaw>\r\n>(withFormContext<CheckboxProps>(CheckboxRaw), 'checkbox');\r\n\r\nexport default Checkbox;\r\n"],"file":"Checkbox.js"}
1
+ {"version":3,"sources":["../../../src/lib/components/checkbox/Checkbox.tsx"],"names":["classNames","require","CheckboxRaw","props","state","Object","assign","checked","isValid","required","errors","getTranslations","defaultBaseTranslations","handleChecked","bind","handleKeyDown","subscribeSelf","finalIndeterminate","Boolean","supportsIndeterminate","inputRef","current","indeterminate","oldProps","setState","setValid","setInvalid","containerClassName","getValidationClass","className","label","disabled","input","id","value","handleBlur","handleFocus","title","tooltip","containerRef","renderTooltip","renderDefaultValidation","renderLabel","e","onChecked","key","click","BaseInput","defaultProps","Checkbox"],"mappings":";;;;;;;;;AACA;;AAGA;;AACA;;AAOA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAFA,IAAIA,UAAU,GAAGC,OAAO,CAAC,YAAD,CAAxB;;IAgBaC,W;;;;;AASX,uBAAYC,KAAZ,EAAkC;AAAA;;AAAA;;AAChC,8BAAMA,KAAN,EAAa,KAAb;AACA,UAAKC,KAAL,GAAaC,MAAM,CAACC,MAAP,CAAc,MAAKF,KAAnB,EAA0B;AACrCG,MAAAA,OAAO,EAAEJ,KAAK,CAACI,OADsB;AAErCC,MAAAA,OAAO,EAAEL,KAAK,CAACM,QAAN,GAAiBN,KAAK,CAACI,OAAvB,GAAiC,IAFL;AAGrCG,MAAAA,MAAM,EACJP,KAAK,CAACM,QAAN,IAAkB,CAACN,KAAK,CAACI,OAAzB,GACI,CAAC,MAAKI,eAAL,CAAqBC,mCAArB,EAA8CH,QAA/C,CADJ,GAEI;AAN+B,KAA1B,CAAb;AAQA,UAAKI,aAAL,GAAqB,MAAKA,aAAL,CAAmBC,IAAnB,+BAArB;AACA,UAAKC,aAAL,GAAqB,M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rB,yCAAKzB,QAAL,CAAcC,OAAd,kFAAuByB,KAAvB;AACD;AACF;AACF;;;;EAvI8BC,qB;;;;gBAApB7C,W,kBAKkBG,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkByC,sBAAUC,YAA5B,EAA0C,CACrE;AADqE,CAA1C,C;;AAqIxB,IAAMC,QAAQ,GAAG,wCAGtB,sCAA+B/C,WAA/B,CAHsB,EAGuB,UAHvB,CAAjB;;eAKQ+C,Q","sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport InputGroup from '../inputGroup/InputGroup';\r\nimport {\r\n BaseInputProps,\r\n BaseInput,\r\n BaseInputState,\r\n defaultBaseTranslations,\r\n} from '../base/input/BaseInput';\r\nvar classNames = require('classnames');\r\nimport { withFormContext } from '../form/withFormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\n\r\nexport interface CheckboxProps extends BaseInputProps<HTMLInputElement> {\r\n onChecked?: (e: React.ChangeEvent<HTMLInputElement>) => void;\r\n onChange?: never;\r\n type?: string;\r\n checked?: boolean;\r\n supportsIndeterminate?: boolean;\r\n}\r\n\r\nexport interface CheckboxState extends BaseInputState {\r\n checked: boolean;\r\n}\r\n\r\nexport class CheckboxRaw extends BaseInput<\r\n CheckboxProps,\r\n CheckboxState,\r\n HTMLInputElement\r\n> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n // checked: false,\r\n }) as CheckboxProps;\r\n\r\n constructor(props: CheckboxProps) {\r\n super(props, false);\r\n this.state = Object.assign(this.state, {\r\n checked: props.checked,\r\n isValid: props.required ? props.checked : true,\r\n errors:\r\n props.required && !props.checked\r\n ? [this.getTranslations(defaultBaseTranslations).required]\r\n : [],\r\n });\r\n this.handleChecked = this.handleChecked.bind(this);\r\n this.handleKeyDown = this.handleKeyDown.bind(this);\r\n this.subscribeSelf(props);\r\n }\r\n\r\n public componentDidMount() {\r\n const finalIndeterminate = Boolean(\r\n this.props.supportsIndeterminate &&\r\n typeof this.props.checked !== 'boolean'\r\n );\r\n if (\r\n typeof this.props.checked !== 'boolean' &&\r\n this.inputRef.current &&\r\n this.inputRef.current?.indeterminate !== finalIndeterminate\r\n ) {\r\n this.inputRef.current.indeterminate = finalIndeterminate;\r\n }\r\n super.componentDidMount?.();\r\n }\r\n\r\n public componentDidUpdate(oldProps: CheckboxProps) {\r\n if (this.props.checked !== this.state.checked) {\r\n this.setState({ checked: this.props.checked });\r\n if (this.props.checked) {\r\n this.setValid();\r\n } else {\r\n if (this.props.required) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n }\r\n }\r\n }\r\n if (oldProps.required !== this.props.required) {\r\n if (this.props.required && !this.props.checked) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n } else {\r\n this.setValid();\r\n }\r\n }\r\n const finalIndeterminate = Boolean(\r\n this.props.supportsIndeterminate &&\r\n typeof this.props.checked !== 'boolean'\r\n );\r\n if (\r\n this.props.supportsIndeterminate &&\r\n this.inputRef.current?.indeterminate !== finalIndeterminate\r\n ) {\r\n this.inputRef.current.indeterminate = finalIndeterminate;\r\n }\r\n }\r\n\r\n public render() {\r\n const containerClassName = classNames([\r\n 'input__base checkbox-input',\r\n this.getValidationClass(),\r\n this.props.className,\r\n { ['checkbox-input--with-label']: Boolean(this.props.label) },\r\n { ['checkbox-input--disabled']: this.props.disabled },\r\n ]);\r\n const input = (\r\n <input\r\n {...(this.props.id && { id: this.props.id })}\r\n ref={this.inputRef}\r\n value={this.props.value || ''}\r\n type=\"checkbox\"\r\n required={this.props.required}\r\n checked={this.state.checked ?? false}\r\n onChange={this.handleChecked}\r\n onBlur={this.handleBlur}\r\n onFocus={this.handleFocus}\r\n onKeyDown={this.handleKeyDown}\r\n tabIndex={this.props.disabled ? -1 : 0}\r\n />\r\n );\r\n return (\r\n <InputGroup title={this.props.title} tooltip={this.props.tooltip}>\r\n <div className={containerClassName} ref={this.containerRef}>\r\n {this.props.title && !this.props.label && input}\r\n {!this.props.title && !this.props.label && this.renderTooltip(input)}\r\n {this.renderDefaultValidation()}\r\n {this.props.label && (\r\n <label className=\"checkbox-input__label\">\r\n {input}\r\n {this.renderLabel()}\r\n </label>\r\n )}\r\n </div>\r\n </InputGroup>\r\n );\r\n }\r\n\r\n private handleChecked(e: React.ChangeEvent<HTMLInputElement>) {\r\n if (!this.props.disabled) {\r\n this.props.onChecked && this.props.onChecked(e);\r\n this.setState({ checked: !this.state.checked });\r\n if (!this.state.checked) {\r\n this.setValid();\r\n } else {\r\n if (this.props.required) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {\r\n if (!this.props.disabled) {\r\n if (e.key === 'Enter') {\r\n this.inputRef.current?.click();\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport const Checkbox = withThemeContext<\r\n CheckboxProps,\r\n InstanceType<typeof CheckboxRaw>\r\n>(withFormContext<CheckboxProps>(CheckboxRaw), 'checkbox');\r\n\r\nexport default Checkbox;\r\n"],"file":"Checkbox.js"}
@@ -503,6 +503,7 @@ var TagsRaw = /*#__PURE__*/function (_BaseInput) {
503
503
  value: function componentDidMount() {
504
504
  document.addEventListener('mousedown', this.handleClickOutside);
505
505
  document.addEventListener('touchstart', this.handleClickOutside);
506
+ this.handleErrors(this.props.tags);
506
507
  }
507
508
  }, {
508
509
  key: "componentWillUnmount",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/components/tags/Tags.tsx"],"names":["PlusIcon","LeftArrowIcon","defaultTagsTranslations","defaultBaseTranslations","addNew","TagButtonComponent","p","className","id","onClick","children","TagsRaw","props","textErrors","setState","handleErrors","e","onFocus","state","suggestionsVisible","onSuggestionsOpened","textIsFocused","touched","fetchExistingTags","value","showMobileVersion","mobileVersionEnabled","isMobile","setTimeout","textRef","current","focus","suggestions","key","preselectedSuggestion","undefined","length","preventDefault","stopPropagation","existingTag","existingTags","find","et","name","onTagsChanged","tags","concat","allowNew","addNewTag","onNewTagAdded","newTag","closeSuggestionsAfterCreate","tag","lastSelected","newTags","isMax","maxTags","finalValue","onBlur","isValid","target","textIsValid","errors","getErrors","setInvalid","setValid","onTagClick","filter","sv","fetchingExistingTags","fetchedExistingTags","React","createRef","suggestionsRef","handleClickOutside","bind","handleLeaveMobileClick","require","oldProps","validators","customValidators","required","containerRef","querySelector","contains","onSuggestionsClosed","addNewOnBlur","getSuggestions","existing","s","onSuggestionSelected","document","addEventListener","removeEventListener","translations","getTranslations","textProps","LeaveMobileButton","showInput","Boolean","readOnly","body","title","tooltip","getValidationClass","placeholder","map","item","index","renderTag","readonlyEmptyPlaceholder","onKeyDown","onTextErrorsChanged","onTextChanged","showSuggestions","tagsSuggestionsClassName","isLoading","suggestionsLoadingComponent","suggestionsEmptyComponent","waitingForMoreInputComponent","minLettersToFetch","SuggestionTag","popperProps","renderDefaultValidation","label","renderLabel","valueNotAddedError","maxTagsSurpassedError","i","startsWith","timer","loadingDelayMs","then","clearTimeout","filteredTags","filterExistingTags","toLowerCase","allowSameTagMultipleTimes","some","t","slice","maxSuggestions","toString","tagRemoveClick","showChips","tagClick","BaseInput","defaultProps","disabled","newTagName","Promise","resolve","Date","getTime","text","Tags"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AAGA;;AAOA;;AACA;;AAGA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAlBYA,Q,YAAAA,Q;;;;;;AAAAA,Q;;;;;;;IACAC,a,YAAAA,a;;;;;;AAAAA,a;;;;;;;AAyBL,IAAMC,uBAAuB,mCAC/BC,mCAD+B;AAElCC,EAAAA,MAAM,EAAE;AAF0B,EAA7B;;;;AAsDP,IAAMC,kBAAkD,GAAG,SAArDA,kBAAqD,CAAAC,CAAC;AAAA,sBAC1D;AAAG,IAAA,SAAS,EA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U;AAAA,WACvBC,OAAO,CAACC,OAAR,CAAgB;AAAE5G,MAAAA,IAAI,EAAE0G,UAAR;AAAoB7I,MAAAA,EAAE,EAAE,IAAIgJ,IAAJ,GAAWC,OAAX;AAAxB,KAAhB,CADuB;AAAA,G;AAEzB3B,EAAAA,kBAAkB,eAAE,0D;AACpBC,EAAAA,qBAAqB,eAAE,qE;AACvBR,EAAAA,4BAA4B,eAAE,8D;AAC9BL,EAAAA,eAAe,EAAE,I;AACjBG,EAAAA,2BAA2B,eACzB,oBAAC,uBAAD;AAAgB,IAAA,SAAS,EAAC;AAA1B,I;AAEFC,EAAAA,yBAAyB,EAAE,qB;AAC3Ba,EAAAA,cAAc,EAAE,G;AAChBI,EAAAA,kBAAkB,EAAE,4BAACmB,IAAD,EAAO7G,IAAP;AAAA,WAClBA,IAAI,CAACsB,MAAL,CAAY,UAAAf,GAAG;AAAA,aAAIA,GAAG,CAACT,IAAJ,IAAYS,GAAG,CAACT,IAAJ,CAAS6F,WAAT,GAAuBP,UAAvB,CAAkCyB,IAAlC,CAAhB;AAAA,KAAf,CADkB;AAAA,G;AAEpBb,EAAAA,cAAc,EAAE,C;AAChBvD,EAAAA,YAAY,EAAE,K;AACdQ,EAAAA,YAAY,EAAE5F,uB;AACdsH,EAAAA,iBAAiB,EAAE,C;AACnB9F,EAAAA,oBAAoB,EAAE,I;AACtByB,EAAAA,2BAA2B,EAAE;;;AA2jB1B,IAAMwG,IAAI,GAAI,yCACnB;AACA,sCAA2BhJ,OAA3B,CAFmB,EAGnB,MAHmB,CAAd;;eAMQgJ,I","sourcesContent":["// Libs\r\nimport * as React from 'react';\r\nimport { InputGroup } from '../inputGroup/InputGroup';\r\nimport { Text, TextProps, TextRaw } from '../text/Text';\r\nimport * as PlusIcon from 'material-design-icons/content/svg/production/ic_add_circle_outline_24px.svg';\r\nimport * as LeftArrowIcon from 'material-design-icons/navigation/svg/production/ic_arrow_back_24px.svg';\r\nimport {\r\n BaseInputProps,\r\n BaseInputState,\r\n BaseInput,\r\n ValidationError,\r\n defaultBaseTranslations,\r\n} from '../base/input/BaseInput';\r\nimport { Button, ButtonComponentProps } from '../button/Button';\r\nimport TagsSuggestions, {\r\n RenderSuggestionTagProps,\r\n} from './subComponents/TagsSuggestions';\r\nimport { withFormContext } from '../form/withFormContext';\r\nimport classNames from 'classnames';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\nimport { PopperProps } from '@material-ui/core/Popper/Popper';\r\nimport LinearProgress from '@material-ui/core/LinearProgress';\r\nimport Portal from '@material-ui/core/Portal';\r\n\r\n// Misc\r\nexport type Tag = {\r\n id: number | string;\r\n name: string;\r\n};\r\n\r\nexport const defaultTagsTranslations = {\r\n ...defaultBaseTranslations,\r\n addNew: 'Add new',\r\n};\r\n\r\nexport type TagsTranslations = Partial<typeof defaultTagsTranslations>;\r\n\r\nexport type TagsProps<T extends Tag = Tag> = {\r\n className?: string;\r\n tagsSuggestionsClassName?: string;\r\n disabled?: boolean;\r\n tags: T[];\r\n existingTags?: T[];\r\n fetchExistingTags?: (text: string) => Promise<T[]>;\r\n onTagsChanged: (newTags: T[]) => void;\r\n onNewTagAdded?: (newTagName: string) => Promise<T>;\r\n onTagClick?: (tag: T) => void;\r\n showChips?: boolean;\r\n allowNew?: boolean;\r\n addNewOnBlur?: boolean;\r\n textProps?: TextProps;\r\n readOnly?: boolean;\r\n readonlyEmptyPlaceholder?: string;\r\n maxTags?: number;\r\n valueNotAddedError?: string | JSX.Element;\r\n maxTagsSurpassedError?: string | JSX.Element;\r\n showSuggestions?: boolean;\r\n suggestionsLoadingComponent?: string | JSX.Element;\r\n suggestionsEmptyComponent?: string | JSX.Element;\r\n waitingForMoreInputComponent?: string | JSX.Element;\r\n loadingDelayMs?: number;\r\n filterExistingTags?: (text: string, existingTags: T[]) => T[];\r\n allowSameTagMultipleTimes?: boolean;\r\n maxSuggestions?: number;\r\n popperProps?: Partial<PopperProps>;\r\n minLettersToFetch?: number;\r\n mobileVersionEnabled?: boolean;\r\n isLoading?: boolean;\r\n closeSuggestionsAfterCreate?: boolean;\r\n SuggestionTag?: React.ComponentType<RenderSuggestionTagProps<T>>;\r\n} & BaseInputProps<HTMLInputElement, TagsTranslations>;\r\n\r\nexport interface TagsState<T extends Tag = Tag> extends BaseInputState {\r\n textIsFocused: boolean;\r\n textErrors: ValidationError[];\r\n textIsValid: boolean;\r\n suggestionsVisible: boolean;\r\n fetchedExistingTags: T[];\r\n fetchingExistingTags: boolean;\r\n preselectedSuggestion?: number;\r\n}\r\n\r\ntype InjectedProps = {};\r\n\r\nconst TagButtonComponent: React.FC<ButtonComponentProps> = p => (\r\n <a className={p.className} id={p.id} onClick={p.onClick}>\r\n {p.children}\r\n </a>\r\n);\r\n\r\nexport class TagsRaw<T extends Tag = Tag> extends BaseInput<\r\n TagsProps<T> & InjectedProps,\r\n TagsState<T>,\r\n HTMLInputElement,\r\n TagsTranslations\r\n> {\r\n public static defaultProps: TagsProps = {\r\n ...BaseInput.defaultProps,\r\n disabled: false,\r\n className: '',\r\n tags: [],\r\n existingTags: [],\r\n maxTags: 1000,\r\n onTagsChanged: () => undefined,\r\n onNewTagAdded: newTagName =>\r\n Promise.resolve({ name: newTagName, id: new Date().getTime() }),\r\n valueNotAddedError: <span>You forgot to add tag</span>,\r\n maxTagsSurpassedError: <span>Maximum number of tags surpassed</span>,\r\n waitingForMoreInputComponent: <span>Waiting for more input...</span>,\r\n showSuggestions: true,\r\n suggestionsLoadingComponent: (\r\n <LinearProgress className=\"tags-input__suggestions__defaultLoading\" />\r\n ),\r\n suggestionsEmptyComponent: 'No existing tags...',\r\n loadingDelayMs: 500,\r\n filterExistingTags: (text, tags) =>\r\n tags.filter(tag => tag.name && tag.name.toLowerCase().startsWith(text)),\r\n maxSuggestions: 5,\r\n addNewOnBlur: false,\r\n translations: defaultTagsTranslations,\r\n minLettersToFetch: 0,\r\n mobileVersionEnabled: true,\r\n closeSuggestionsAfterCreate: false,\r\n };\r\n\r\n private textRef: React.RefObject<TextRaw>;\r\n private suggestionsRef: React.RefObject<HTMLDivElement>;\r\n private isMobile: boolean = false;\r\n\r\n constructor(props: TagsProps<T> & InjectedProps) {\r\n super(props);\r\n this.state = {\r\n ...this.state,\r\n textErrors: [],\r\n textIsFocused: false,\r\n suggestionsVisible: false,\r\n fetchingExistingTags: false,\r\n textIsValid: false,\r\n fetchedExistingTags: [],\r\n };\r\n this.textRef = React.createRef();\r\n this.suggestionsRef = React.createRef();\r\n this.handleClickOutside = this.handleClickOutside.bind(this);\r\n this.handleLeaveMobileClick = this.handleLeaveMobileClick.bind(this);\r\n if (props.mobileVersionEnabled) {\r\n this.isMobile = require('react-device-detect')?.isMobile;\r\n }\r\n }\r\n\r\n public focus() {\r\n if (this.textRef.current) {\r\n this.textRef.current.focus();\r\n }\r\n }\r\n\r\n public componentDidUpdate(oldProps: TagsProps & InjectedProps) {\r\n if (\r\n oldProps.tags !== this.props.tags ||\r\n oldProps.validators !== this.props.validators ||\r\n oldProps.customValidators !== this.props.customValidators ||\r\n oldProps.required !== this.props.required\r\n ) {\r\n this.handleErrors(this.props.tags);\r\n }\r\n }\r\n\r\n public handleLeaveMobileClick() {\r\n this.setState({\r\n textIsFocused: false,\r\n suggestionsVisible: false,\r\n preselectedSuggestion: undefined,\r\n });\r\n }\r\n\r\n public handleClickOutside(e: MouseEvent) {\r\n if (\r\n !this.containerRef.current ||\r\n this.containerRef.current\r\n .querySelector('.tags-input__tag__wrapper')\r\n ?.contains(e.target as HTMLDivElement) ||\r\n this.containerRef.current\r\n .querySelector('.tags-input__text-input')\r\n ?.contains(e.target as HTMLDivElement) ||\r\n !this.suggestionsRef.current ||\r\n this.suggestionsRef.current.contains(e.target as HTMLDivElement)\r\n ) {\r\n return;\r\n }\r\n if (this.state.suggestionsVisible) {\r\n this.props.onSuggestionsClosed?.();\r\n }\r\n this.setState({\r\n suggestionsVisible: false,\r\n preselectedSuggestion: undefined,\r\n });\r\n if (this.props.addNewOnBlur && this.state.value) {\r\n const suggestions = this.getSuggestions();\r\n const existing = suggestions.find(s => s.name === this.state.value);\r\n if (existing) {\r\n this.onSuggestionSelected(existing, suggestions.length === 1);\r\n } else if (this.props.allowNew) {\r\n this.addNewTag();\r\n }\r\n } /* else if (this.state.value) {\r\n this.setState({ value: '' });\r\n }*/\r\n }\r\n\r\n public componentDidMount() {\r\n document.addEventListener('mousedown', this.handleClickOutside);\r\n document.addEventListener('touchstart', this.handleClickOutside);\r\n }\r\n\r\n public componentWillUnmount() {\r\n document.removeEventListener('mousedown', this.handleClickOutside);\r\n document.removeEventListener('touchstart', this.handleClickOutside);\r\n super.componentWillUnmount();\r\n }\r\n\r\n public render() {\r\n const translations = this.getTranslations(defaultTagsTranslations);\r\n const textProps = this.props.textProps ? this.props.textProps : {};\r\n const suggestions = this.getSuggestions();\r\n const showMobileVersion =\r\n this.props.mobileVersionEnabled &&\r\n this.isMobile &&\r\n (this.state.textIsFocused || this.state.suggestionsVisible);\r\n const LeaveMobileButton = showMobileVersion ? (\r\n <Button\r\n className=\"tags-input__leaveMobileTagsButton line-height--0\"\r\n onClick={this.handleLeaveMobileClick}\r\n noShadow={true}\r\n unobtrusive={true}\r\n >\r\n <LeftArrowIcon />\r\n </Button>\r\n ) : (\r\n undefined\r\n );\r\n const showInput = Boolean(\r\n (!this.props.maxTags ||\r\n this.props.maxTags > (this.props.tags && this.props.tags.length)) &&\r\n !this.props.readOnly\r\n );\r\n return (\r\n <Portal container={document.body} disablePortal={!showMobileVersion}>\r\n <InputGroup title={this.props.title} tooltip={this.props.tooltip}>\r\n <div\r\n {...(this.props.id && {\r\n id: this.props.id,\r\n })}\r\n className={classNames(\r\n 'input__base tags-input',\r\n this.getValidationClass(),\r\n this.props.className,\r\n {\r\n 'tags-input--readOnly': this.props.readOnly,\r\n 'tags-input--hasPlaceholder':\r\n this.props.textProps && this.props.textProps.placeholder,\r\n 'tags-input--mobile': showMobileVersion,\r\n }\r\n )}\r\n ref={this.containerRef}\r\n >\r\n {showMobileVersion && (\r\n <div className=\"tags-input__mobileBackdrop\" />\r\n )}\r\n <div className=\"tags-input__tags__wrapper\">\r\n {!showInput && showMobileVersion && LeaveMobileButton}\r\n {this.props.tags && this.props.tags.length > 0 ? (\r\n <div className=\"tags-input__tag__wrapper\">\r\n {this.props.tags.map((item, index) =>\r\n this.renderTag(item, index)\r\n )}\r\n </div>\r\n ) : (\r\n this.props.readOnly && (\r\n <div className=\"tags-input__tag__wrapper\">\r\n <div className=\"tags-input__tag\">\r\n {this.props.readonlyEmptyPlaceholder}\r\n </div>\r\n </div>\r\n )\r\n )}\r\n </div>\r\n {showInput && (\r\n <div\r\n className={\r\n 'tags-input__tags__wrapper ' +\r\n (this.props.readOnly ? 'filled ' : '')\r\n }\r\n >\r\n <Text\r\n showClearButton={true}\r\n {...textProps}\r\n {...(this.props.id && {\r\n id: this.props.id + '-text-input',\r\n })}\r\n ref={this.textRef}\r\n required={\r\n this.props.tags.length > 0 ? false : this.props.required\r\n }\r\n className={\r\n 'tags-input__text-input ' +\r\n (textProps.className ? textProps.className : '')\r\n }\r\n onKeyDown={this.onKeyDown(suggestions)}\r\n onErrorsChanged={this.onTextErrorsChanged}\r\n onChange={this.onTextChanged}\r\n onFocus={this.onFocus}\r\n onBlur={this.onBlur}\r\n value={this.state.value}\r\n readOnly={this.props.readOnly}\r\n showValidation={false}\r\n ignoreContext={true}\r\n validators={this.props.validators}\r\n customValidators={this.props.customValidators}\r\n before={LeaveMobileButton}\r\n />\r\n {this.state.suggestionsVisible && this.props.showSuggestions && (\r\n <TagsSuggestions<T>\r\n {...(this.props.id && {\r\n id: this.props.id + '-text-input',\r\n })}\r\n className={classNames(this.props.tagsSuggestionsClassName)}\r\n innerRef={this.suggestionsRef}\r\n anchorEl={this.containerRef.current}\r\n allowNew={this.props.allowNew}\r\n preselectedSuggestion={this.state.preselectedSuggestion}\r\n loading={\r\n this.state.fetchingExistingTags || this.props.isLoading\r\n }\r\n LoadingComponent={this.props.suggestionsLoadingComponent}\r\n isVisible={this.state.suggestionsVisible}\r\n EmptyComponent={this.props.suggestionsEmptyComponent}\r\n WaitingForMoreInputComponent={\r\n this.props.waitingForMoreInputComponent\r\n }\r\n isWaitingForMoreInput={\r\n this.state.value.length < this.props.minLettersToFetch\r\n }\r\n tags={suggestions}\r\n onSelected={this.onSuggestionSelected}\r\n value={this.state.value}\r\n AddNewTagComponent={\r\n this.props.allowNew &&\r\n this.state.value !== '' &&\r\n (!this.props.existingTags ||\r\n !this.props.existingTags.find(\r\n e => e.name === this.state.value\r\n )) &&\r\n (!this.state.fetchedExistingTags ||\r\n !this.state.fetchedExistingTags.find(\r\n e => e.name === this.state.value\r\n )) &&\r\n this.state.textIsValid && (\r\n <Button\r\n {...(this.props.id && {\r\n id: this.props.id + '-add-new-button',\r\n })}\r\n className=\"tags-input__suggestion tags-input__add-new\"\r\n dropdown={true}\r\n onClick={this.addNewTag}\r\n >\r\n {translations.addNew} \"{this.state.value}\"\r\n </Button>\r\n )\r\n }\r\n SuggestionTag={this.props.SuggestionTag}\r\n popperProps={this.props.popperProps}\r\n />\r\n )}\r\n </div>\r\n )}\r\n {this.renderDefaultValidation()}\r\n {this.props.label && (\r\n <label\r\n className={\r\n this.state.value !== '' ||\r\n this.state.textIsFocused ||\r\n this.props.readOnly ||\r\n this.props.tags.length >= this.props.maxTags ||\r\n showMobileVersion\r\n ? 'label--focused'\r\n : ''\r\n }\r\n >\r\n {this.renderLabel()}\r\n </label>\r\n )}\r\n </div>\r\n </InputGroup>\r\n </Portal>\r\n );\r\n }\r\n\r\n private onTextErrorsChanged = (textErrors: ValidationError[]) =>\r\n this.setState(\r\n () => ({ textErrors }),\r\n () => this.handleErrors()\r\n );\r\n\r\n private onFocus = (e: React.SyntheticEvent<{}>) => {\r\n this.props.onFocus?.(e);\r\n if (!this.state.suggestionsVisible) {\r\n this.props.onSuggestionsOpened?.();\r\n }\r\n this.setState(\r\n () => ({ textIsFocused: true, suggestionsVisible: true, touched: true }),\r\n () => this.handleErrors()\r\n );\r\n this.fetchExistingTags(this.state.value);\r\n const showMobileVersion =\r\n this.props.mobileVersionEnabled &&\r\n this.isMobile &&\r\n (this.state.textIsFocused || this.state.suggestionsVisible);\r\n if (\r\n !showMobileVersion &&\r\n this.props.mobileVersionEnabled &&\r\n this.isMobile\r\n ) {\r\n setTimeout(() => this.textRef.current?.focus(), 100);\r\n }\r\n };\r\n\r\n private onKeyDown = (suggestions: T[]) => async (e: React.KeyboardEvent) => {\r\n if (e.key === 'Tab') {\r\n this.setState({\r\n suggestionsVisible: false,\r\n preselectedSuggestion: undefined,\r\n });\r\n }\r\n if (\r\n e.key === 'Enter' &&\r\n (this.state.value !== '' ||\r\n this.state.preselectedSuggestion !== undefined) &&\r\n this.state.textErrors.length === 0\r\n ) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n const existingTag =\r\n this.props.existingTags &&\r\n this.props.existingTags.find(et => et.name === this.state.value);\r\n if (this.state.preselectedSuggestion !== undefined) {\r\n this.props.onTagsChanged(\r\n this.props.tags.concat(suggestions[this.state.preselectedSuggestion])\r\n );\r\n this.setState({ value: '', preselectedSuggestion: undefined }, () => {\r\n this.fetchExistingTags();\r\n this.handleErrors();\r\n });\r\n } else if (existingTag) {\r\n this.props.onTagsChanged(this.props.tags.concat(existingTag));\r\n this.setState({ value: '' }, () => {\r\n this.fetchExistingTags();\r\n this.handleErrors();\r\n });\r\n } else if (this.props.allowNew) {\r\n await this.addNewTag();\r\n this.handleErrors();\r\n }\r\n }\r\n if (suggestions.length > 0 && this.state.suggestionsVisible) {\r\n if (e.key === 'ArrowUp') {\r\n const preselectedSuggestion =\r\n this.state.preselectedSuggestion === undefined\r\n ? suggestions.length - 1\r\n : this.state.preselectedSuggestion === 0\r\n ? suggestions.length - 1\r\n : this.state.preselectedSuggestion - 1;\r\n this.setState({ preselectedSuggestion });\r\n } else if (e.key === 'ArrowDown') {\r\n const preselectedSuggestion =\r\n this.state.preselectedSuggestion === undefined\r\n ? 0\r\n : this.state.preselectedSuggestion === suggestions.length - 1\r\n ? 0\r\n : this.state.preselectedSuggestion + 1;\r\n this.setState({ preselectedSuggestion });\r\n } else {\r\n this.setState({ preselectedSuggestion: undefined });\r\n }\r\n }\r\n };\r\n\r\n private addNewTag = async () => {\r\n const newTag = await this.props.onNewTagAdded(this.state.value);\r\n this.setState({\r\n suggestionsVisible: this.props.closeSuggestionsAfterCreate\r\n ? false\r\n : this.state.suggestionsVisible,\r\n });\r\n if (newTag) {\r\n this.props.onTagsChanged(\r\n this.props.tags ? this.props.tags.concat(newTag) : [newTag]\r\n );\r\n }\r\n this.setState({ value: '', textErrors: [] }, () => {\r\n this.fetchExistingTags();\r\n this.handleErrors();\r\n });\r\n };\r\n\r\n private onSuggestionSelected = (tag: T, lastSelected: boolean) => {\r\n const newTags = this.props.tags.concat(tag);\r\n this.props.onTagsChanged(newTags);\r\n const isMax = newTags.length === this.props.maxTags;\r\n const finalValue =\r\n !this.props.allowNew && !isMax && !lastSelected ? this.state.value : '';\r\n this.setState(\r\n {\r\n value: finalValue,\r\n suggestionsVisible:\r\n isMax || this.props.closeSuggestionsAfterCreate\r\n ? false\r\n : this.state.suggestionsVisible,\r\n preselectedSuggestion: undefined,\r\n textErrors: [],\r\n },\r\n () => {\r\n if (\r\n !this.props.maxTags ||\r\n this.props.tags.length + 1 < this.props.maxTags\r\n ) {\r\n this.fetchExistingTags(finalValue);\r\n }\r\n this.handleErrors();\r\n }\r\n );\r\n };\r\n\r\n private onBlur = () => {\r\n this.props.onBlur?.();\r\n this.setState(\r\n {\r\n textIsFocused: false,\r\n preselectedSuggestion: undefined,\r\n },\r\n () => this.handleErrors()\r\n );\r\n };\r\n\r\n private onTextChanged = (\r\n e: React.ChangeEvent<HTMLInputElement>,\r\n isValid: boolean\r\n ) => {\r\n const value = e.target.value;\r\n this.setState(\r\n () => ({\r\n value,\r\n isValid: isValid,\r\n textIsValid: isValid,\r\n suggestionsVisible: true,\r\n }),\r\n () => this.handleErrors()\r\n );\r\n this.fetchExistingTags(e.target.value);\r\n };\r\n\r\n private handleErrors = (tags: T[] = this.props.tags) => {\r\n let errors = this.getErrors(tags);\r\n if (errors.length > 0) {\r\n this.setInvalid(errors);\r\n } else {\r\n this.setValid();\r\n }\r\n };\r\n\r\n private getErrors(tags: T[]) {\r\n let errors = [];\r\n if (tags.length < this.props.maxTags) {\r\n errors = errors.concat(this.state.textErrors);\r\n }\r\n if (this.state.value !== '' && tags.length === 0 && this.props.required) {\r\n errors = errors.concat(\r\n this.getTranslations(this.props.translations).required\r\n );\r\n }\r\n if (this.state.value && this.props.allowNew && !this.state.textIsFocused) {\r\n errors = errors.concat(this.props.valueNotAddedError);\r\n }\r\n if (this.props.maxTags < (this.props.tags && this.props.tags.length)) {\r\n errors = errors.concat(this.props.maxTagsSurpassedError);\r\n }\r\n return errors.filter(i => i);\r\n }\r\n\r\n private fetchExistingTags(startsWith: string = '') {\r\n if (\r\n this.props.fetchExistingTags &&\r\n startsWith.length >= this.props.minLettersToFetch\r\n ) {\r\n const timer = setTimeout(\r\n () => this.setState(() => ({ fetchingExistingTags: true })),\r\n this.props.loadingDelayMs\r\n );\r\n this.props.fetchExistingTags(startsWith).then(fetchedExistingTags => {\r\n clearTimeout(timer);\r\n this.setState(() => ({\r\n fetchedExistingTags,\r\n fetchingExistingTags: false,\r\n }));\r\n });\r\n }\r\n }\r\n\r\n private getSuggestions() {\r\n const existingTags: T[] = []\r\n .concat(this.props.existingTags ? this.props.existingTags : [])\r\n .concat(\r\n this.state.fetchedExistingTags ? this.state.fetchedExistingTags : []\r\n );\r\n const filteredTags = this.props.filterExistingTags(\r\n this.state.value ? this.state.value.toLowerCase() : '',\r\n existingTags\r\n );\r\n let suggestions = filteredTags\r\n .filter(\r\n tag =>\r\n this.props.allowSameTagMultipleTimes ||\r\n !this.props.tags.some(t => t.id === tag.id)\r\n )\r\n .slice(0, this.props.maxSuggestions);\r\n return suggestions;\r\n }\r\n\r\n private renderTag(tag: T, index: number) {\r\n const body = (\r\n <>\r\n {tag.name}\r\n {!this.props.readOnly && (\r\n <Button\r\n {...(this.props.id && {\r\n id: this.props.id + '-tag-' + index.toString(),\r\n })}\r\n circular={true}\r\n blank={true}\r\n onClick={this.tagRemoveClick(tag)}\r\n className=\"ml-1 transform-rotate--45 line-height--0 p-0\"\r\n Component={TagButtonComponent}\r\n preventsDefault={false}\r\n >\r\n <PlusIcon />\r\n </Button>\r\n )}\r\n </>\r\n );\r\n const className = classNames('tags-input__tag', {\r\n 'tags-input__tag-chip': this.props.showChips,\r\n });\r\n if (this.props.onTagClick) {\r\n return (\r\n <Button\r\n onClick={this.tagClick(tag)}\r\n small={true}\r\n className={className}\r\n key={index}\r\n >\r\n {body}\r\n </Button>\r\n );\r\n }\r\n return (\r\n <div onClick={this.tagClick(tag)} className={className} key={index}>\r\n {body}\r\n </div>\r\n );\r\n }\r\n\r\n private tagClick = (tag: T) => () => {\r\n this.props.onTagClick && this.props.onTagClick(tag);\r\n };\r\n\r\n private tagRemoveClick = (tag: T) => (e: React.MouseEvent<HTMLElement>) => {\r\n e.stopPropagation();\r\n const newTags = this.props.tags.filter(sv => sv.id !== tag.id);\r\n /*if (newTags.length === 0) {\r\n setTimeout(() => this.focus(), 50);\r\n }\r\n this.setState({\r\n suggestionsVisible: false,\r\n });*/\r\n this.props.onTagsChanged && this.props.onTagsChanged(newTags);\r\n this.handleErrors(newTags);\r\n // this.fetchExistingTags();\r\n };\r\n}\r\n\r\ninterface TagsFinal {\r\n <T extends Tag = Tag>(item: TagsProps<T>): React.ReactElement;\r\n defaultProps?: Partial<TagsProps>;\r\n}\r\n\r\nexport const Tags = (withThemeContext<TagsProps, InstanceType<typeof TagsRaw>>(\r\n // tslint:disable-next-line: no-any\r\n withFormContext<TagsProps>(TagsRaw),\r\n 'tags'\r\n) as unknown) as TagsFinal;\r\n\r\nexport default Tags;\r\n"],"file":"Tags.js"}
1
+ {"version":3,"sources":["../../../src/lib/components/tags/Tags.tsx"],"names":["PlusIcon","LeftArrowIcon","defaultTagsTranslations","defaultBaseTranslations","addNew","TagButtonComponent","p","className","id","onClick","children","TagsRaw","props","textErrors","setState","handleErrors","e","onFocus","state","suggestionsVisible","onSuggestionsOpened","textIsFocused","touched","fetchExistingTags","value","showMobileVersion","mobileVersionEnabled","isMobile","setTimeout","textRef","current","focus","suggestions","key","preselectedSuggestion","undefined","length","preventDefault","stopPropagation","existingTag","existingTags","find","et","name","onTagsChanged","tags","concat","allowNew","addNewTag","onNewTagAdded","newTag","closeSuggestionsAfterCreate","tag","lastSelected","newTags","isMax","maxTags","finalValue","onBlur","isValid","target","textIsValid","errors","getErrors","setInvalid","setValid","onTagClick","filter","sv","fetchingExistingTags","fetchedExistingTags","React","createRef","suggestionsRef","handleClickOutside","bind","handleLeaveMobileClick","require","oldProps","validators","customValidators","required","containerRef","querySelector","contains","onSuggestionsClosed","addNewOnBlur","getSuggestions","existing","s","onSuggestionSelected","document","addEventListener","removeEventListener","translations","getTranslations","textProps","LeaveMobileButton","showInput","Boolean","readOnly","body","title","tooltip","getValidationClass","placeholder","map","item","index","renderTag","readonlyEmptyPlaceholder","onKeyDown","onTextErrorsChanged","onTextChanged","showSuggestions","tagsSuggestionsClassName","isLoading","suggestionsLoadingComponent","suggestionsEmptyComponent","waitingForMoreInputComponent","minLettersToFetch","SuggestionTag","popperProps","renderDefaultValidation","label","renderLabel","valueNotAddedError","maxTagsSurpassedError","i","startsWith","timer","loadingDelayMs","then","clearTimeout","filteredTags","filterExistingTags","toLowerCase","allowSameTagMultipleTimes","some","t","slice","maxSuggestions","toString","tagRemoveClick","showChips","tagClick","BaseInput","defaultProps","disabled","newTagName","Promise","resolve","Date","getTime","text","Tags"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AAGA;;AAOA;;AACA;;AAGA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAlBYA,Q,YAAAA,Q;;;;;;AAAAA,Q;;;;;;;IACAC,a,YAAAA,a;;;;;;AAAAA,a;;;;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nimport * as React from 'react';\r\nimport { InputGroup } from '../inputGroup/InputGroup';\r\nimport { Text, TextProps, TextRaw } from '../text/Text';\r\nimport * as PlusIcon from 'material-design-icons/content/svg/production/ic_add_circle_outline_24px.svg';\r\nimport * as LeftArrowIcon from 'material-design-icons/navigation/svg/production/ic_arrow_back_24px.svg';\r\nimport {\r\n BaseInputProps,\r\n BaseInputState,\r\n BaseInput,\r\n ValidationError,\r\n defaultBaseTranslations,\r\n} from '../base/input/BaseInput';\r\nimport { Button, ButtonComponentProps } from '../button/Button';\r\nimport TagsSuggestions, {\r\n RenderSuggestionTagProps,\r\n} from './subComponents/TagsSuggestions';\r\nimport { withFormContext } from '../form/withFormContext';\r\nimport classNames from 'classnames';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\nimport { PopperProps } from '@material-ui/core/Popper/Popper';\r\nimport LinearProgress from '@material-ui/core/LinearProgress';\r\nimport Portal from '@material-ui/core/Portal';\r\n\r\n// Misc\r\nexport type Tag = {\r\n id: number | string;\r\n name: string;\r\n};\r\n\r\nexport const defaultTagsTranslations = {\r\n ...defaultBaseTranslations,\r\n addNew: 'Add new',\r\n};\r\n\r\nexport type TagsTranslations = Partial<typeof defaultTagsTranslations>;\r\n\r\nexport type TagsProps<T extends Tag = Tag> = {\r\n className?: string;\r\n tagsSuggestionsClassName?: string;\r\n disabled?: boolean;\r\n tags: T[];\r\n existingTags?: T[];\r\n fetchExistingTags?: (text: string) => Promise<T[]>;\r\n onTagsChanged: (newTags: T[]) => void;\r\n onNewTagAdded?: (newTagName: string) => Promise<T>;\r\n onTagClick?: (tag: T) => void;\r\n showChips?: boolean;\r\n allowNew?: boolean;\r\n addNewOnBlur?: boolean;\r\n textProps?: TextProps;\r\n readOnly?: boolean;\r\n readonlyEmptyPlaceholder?: string;\r\n maxTags?: number;\r\n valueNotAddedError?: string | JSX.Element;\r\n maxTagsSurpassedError?: string | JSX.Element;\r\n showSuggestions?: boolean;\r\n suggestionsLoadingComponent?: string | JSX.Element;\r\n suggestionsEmptyComponent?: string | JSX.Element;\r\n waitingForMoreInputComponent?: string | JSX.Element;\r\n loadingDelayMs?: number;\r\n filterExistingTags?: (text: string, existingTags: T[]) => T[];\r\n allowSameTagMultipleTimes?: boolean;\r\n maxSuggestions?: number;\r\n popperProps?: Partial<PopperProps>;\r\n minLettersToFetch?: number;\r\n mobileVersionEnabled?: boolean;\r\n isLoading?: boolean;\r\n closeSuggestionsAfterCreate?: boolean;\r\n SuggestionTag?: React.ComponentType<RenderSuggestionTagProps<T>>;\r\n} & BaseInputProps<HTMLInputElement, TagsTranslations>;\r\n\r\nexport interface TagsState<T extends Tag = Tag> extends BaseInputState {\r\n textIsFocused: boolean;\r\n textErrors: ValidationError[];\r\n textIsValid: boolean;\r\n suggestionsVisible: boolean;\r\n fetchedExistingTags: T[];\r\n fetchingExistingTags: boolean;\r\n preselectedSuggestion?: number;\r\n}\r\n\r\ntype InjectedProps = {};\r\n\r\nconst TagButtonComponent: React.FC<ButtonComponentProps> = p => (\r\n <a className={p.className} id={p.id} onClick={p.onClick}>\r\n {p.children}\r\n </a>\r\n);\r\n\r\nexport class TagsRaw<T extends Tag = Tag> extends BaseInput<\r\n TagsProps<T> & InjectedProps,\r\n TagsState<T>,\r\n HTMLInputElement,\r\n TagsTranslations\r\n> {\r\n public static defaultProps: TagsProps = {\r\n ...BaseInput.defaultProps,\r\n disabled: false,\r\n className: '',\r\n tags: [],\r\n existingTags: [],\r\n maxTags: 1000,\r\n onTagsChanged: () => undefined,\r\n onNewTagAdded: newTagName =>\r\n Promise.resolve({ name: newTagName, id: new Date().getTime() }),\r\n valueNotAddedError: <span>You forgot to add tag</span>,\r\n maxTagsSurpassedError: <span>Maximum number of tags surpassed</span>,\r\n waitingForMoreInputComponent: <span>Waiting for more input...</span>,\r\n showSuggestions: true,\r\n suggestionsLoadingComponent: (\r\n <LinearProgress className=\"tags-input__suggestions__defaultLoading\" />\r\n ),\r\n suggestionsEmptyComponent: 'No existing tags...',\r\n loadingDelayMs: 500,\r\n filterExistingTags: (text, tags) =>\r\n tags.filter(tag => tag.name && tag.name.toLowerCase().startsWith(text)),\r\n maxSuggestions: 5,\r\n addNewOnBlur: false,\r\n translations: defaultTagsTranslations,\r\n minLettersToFetch: 0,\r\n mobileVersionEnabled: true,\r\n closeSuggestionsAfterCreate: false,\r\n };\r\n\r\n private textRef: React.RefObject<TextRaw>;\r\n private suggestionsRef: React.RefObject<HTMLDivElement>;\r\n private isMobile: boolean = false;\r\n\r\n constructor(props: TagsProps<T> & InjectedProps) {\r\n super(props);\r\n this.state = {\r\n ...this.state,\r\n textErrors: [],\r\n textIsFocused: false,\r\n suggestionsVisible: false,\r\n fetchingExistingTags: false,\r\n textIsValid: false,\r\n fetchedExistingTags: [],\r\n };\r\n this.textRef = React.createRef();\r\n this.suggestionsRef = React.createRef();\r\n this.handleClickOutside = this.handleClickOutside.bind(this);\r\n this.handleLeaveMobileClick = this.handleLeaveMobileClick.bind(this);\r\n if (props.mobileVersionEnabled) {\r\n this.isMobile = require('react-device-detect')?.isMobile;\r\n }\r\n }\r\n\r\n public focus() {\r\n if (this.textRef.current) {\r\n this.textRef.current.focus();\r\n }\r\n }\r\n\r\n public componentDidUpdate(oldProps: TagsProps & InjectedProps) {\r\n if (\r\n oldProps.tags !== this.props.tags ||\r\n oldProps.validators !== this.props.validators ||\r\n oldProps.customValidators !== this.props.customValidators ||\r\n oldProps.required !== this.props.required\r\n ) {\r\n this.handleErrors(this.props.tags);\r\n }\r\n }\r\n\r\n public handleLeaveMobileClick() {\r\n this.setState({\r\n textIsFocused: false,\r\n suggestionsVisible: false,\r\n preselectedSuggestion: undefined,\r\n });\r\n }\r\n\r\n public handleClickOutside(e: MouseEvent) {\r\n if (\r\n !this.containerRef.current ||\r\n this.containerRef.current\r\n .querySelector('.tags-input__tag__wrapper')\r\n ?.contains(e.target as HTMLDivElement) ||\r\n this.containerRef.current\r\n .querySelector('.tags-input__text-input')\r\n ?.contains(e.target as HTMLDivElement) ||\r\n !this.suggestionsRef.current ||\r\n this.suggestionsRef.current.contains(e.target as HTMLDivElement)\r\n ) {\r\n return;\r\n }\r\n if (this.state.suggestionsVisible) {\r\n this.props.onSuggestionsClosed?.();\r\n }\r\n this.setState({\r\n suggestionsVisible: false,\r\n preselectedSuggestion: undefined,\r\n });\r\n if (this.props.addNewOnBlur && this.state.value) {\r\n const suggestions = this.getSuggestions();\r\n const existing = suggestions.find(s => s.name === this.state.value);\r\n if (existing) {\r\n this.onSuggestionSelected(existing, suggestions.length === 1);\r\n } else if (this.props.allowNew) {\r\n this.addNewTag();\r\n }\r\n } /* else if (this.state.value) {\r\n this.setState({ value: '' });\r\n }*/\r\n }\r\n\r\n public componentDidMount() {\r\n document.addEventListener('mousedown', this.handleClickOutside);\r\n document.addEventListener('touchstart', this.handleClickOutside);\r\n this.handleErrors(this.props.tags);\r\n }\r\n\r\n public componentWillUnmount() {\r\n document.removeEventListener('mousedown', this.handleClickOutside);\r\n document.removeEventListener('touchstart', this.handleClickOutside);\r\n super.componentWillUnmount();\r\n }\r\n\r\n public render() {\r\n const translations = this.getTranslations(defaultTagsTranslations);\r\n const textProps = this.props.textProps ? this.props.textProps : {};\r\n const suggestions = this.getSuggestions();\r\n const showMobileVersion =\r\n this.props.mobileVersionEnabled &&\r\n this.isMobile &&\r\n (this.state.textIsFocused || this.state.suggestionsVisible);\r\n const LeaveMobileButton = showMobileVersion ? (\r\n <Button\r\n className=\"tags-input__leaveMobileTagsButton line-height--0\"\r\n onClick={this.handleLeaveMobileClick}\r\n noShadow={true}\r\n unobtrusive={true}\r\n >\r\n <LeftArrowIcon />\r\n </Button>\r\n ) : (\r\n undefined\r\n );\r\n const showInput = Boolean(\r\n (!this.props.maxTags ||\r\n this.props.maxTags > (this.props.tags && this.props.tags.length)) &&\r\n !this.props.readOnly\r\n );\r\n return (\r\n <Portal container={document.body} disablePortal={!showMobileVersion}>\r\n <InputGroup title={this.props.title} tooltip={this.props.tooltip}>\r\n <div\r\n {...(this.props.id && {\r\n id: this.props.id,\r\n })}\r\n className={classNames(\r\n 'input__base tags-input',\r\n this.getValidationClass(),\r\n this.props.className,\r\n {\r\n 'tags-input--readOnly': this.props.readOnly,\r\n 'tags-input--hasPlaceholder':\r\n this.props.textProps && this.props.textProps.placeholder,\r\n 'tags-input--mobile': showMobileVersion,\r\n }\r\n )}\r\n ref={this.containerRef}\r\n >\r\n {showMobileVersion && (\r\n <div className=\"tags-input__mobileBackdrop\" />\r\n )}\r\n <div className=\"tags-input__tags__wrapper\">\r\n {!showInput && showMobileVersion && LeaveMobileButton}\r\n {this.props.tags && this.props.tags.length > 0 ? (\r\n <div className=\"tags-input__tag__wrapper\">\r\n {this.props.tags.map((item, index) =>\r\n this.renderTag(item, index)\r\n )}\r\n </div>\r\n ) : (\r\n this.props.readOnly && (\r\n <div className=\"tags-input__tag__wrapper\">\r\n <div className=\"tags-input__tag\">\r\n {this.props.readonlyEmptyPlaceholder}\r\n </div>\r\n </div>\r\n )\r\n )}\r\n </div>\r\n {showInput && (\r\n <div\r\n className={\r\n 'tags-input__tags__wrapper ' +\r\n (this.props.readOnly ? 'filled ' : '')\r\n }\r\n >\r\n <Text\r\n showClearButton={true}\r\n {...textProps}\r\n {...(this.props.id && {\r\n id: this.props.id + '-text-input',\r\n })}\r\n ref={this.textRef}\r\n required={\r\n this.props.tags.length > 0 ? false : this.props.required\r\n }\r\n className={\r\n 'tags-input__text-input ' +\r\n (textProps.className ? textProps.className : '')\r\n }\r\n onKeyDown={this.onKeyDown(suggestions)}\r\n onErrorsChanged={this.onTextErrorsChanged}\r\n onChange={this.onTextChanged}\r\n onFocus={this.onFocus}\r\n onBlur={this.onBlur}\r\n value={this.state.value}\r\n readOnly={this.props.readOnly}\r\n showValidation={false}\r\n ignoreContext={true}\r\n validators={this.props.validators}\r\n customValidators={this.props.customValidators}\r\n before={LeaveMobileButton}\r\n />\r\n {this.state.suggestionsVisible && this.props.showSuggestions && (\r\n <TagsSuggestions<T>\r\n {...(this.props.id && {\r\n id: this.props.id + '-text-input',\r\n })}\r\n className={classNames(this.props.tagsSuggestionsClassName)}\r\n innerRef={this.suggestionsRef}\r\n anchorEl={this.containerRef.current}\r\n allowNew={this.props.allowNew}\r\n preselectedSuggestion={this.state.preselectedSuggestion}\r\n loading={\r\n this.state.fetchingExistingTags || this.props.isLoading\r\n }\r\n LoadingComponent={this.props.suggestionsLoadingComponent}\r\n isVisible={this.state.suggestionsVisible}\r\n EmptyComponent={this.props.suggestionsEmptyComponent}\r\n WaitingForMoreInputComponent={\r\n this.props.waitingForMoreInputComponent\r\n }\r\n isWaitingForMoreInput={\r\n this.state.value.length < this.props.minLettersToFetch\r\n }\r\n tags={suggestions}\r\n onSelected={this.onSuggestionSelected}\r\n value={this.state.value}\r\n AddNewTagComponent={\r\n this.props.allowNew &&\r\n this.state.value !== '' &&\r\n (!this.props.existingTags ||\r\n !this.props.existingTags.find(\r\n e => e.name === this.state.value\r\n )) &&\r\n (!this.state.fetchedExistingTags ||\r\n !this.state.fetchedExistingTags.find(\r\n e => e.name === this.state.value\r\n )) &&\r\n this.state.textIsValid && (\r\n <Button\r\n {...(this.props.id && {\r\n id: this.props.id + '-add-new-button',\r\n })}\r\n className=\"tags-input__suggestion tags-input__add-new\"\r\n dropdown={true}\r\n onClick={this.addNewTag}\r\n >\r\n {translations.addNew} \"{this.state.value}\"\r\n </Button>\r\n )\r\n }\r\n SuggestionTag={this.props.SuggestionTag}\r\n popperProps={this.props.popperProps}\r\n />\r\n )}\r\n </div>\r\n )}\r\n {this.renderDefaultValidation()}\r\n {this.props.label && (\r\n <label\r\n className={\r\n this.state.value !== '' ||\r\n this.state.textIsFocused ||\r\n this.props.readOnly ||\r\n this.props.tags.length >= this.props.maxTags ||\r\n showMobileVersion\r\n ? 'label--focused'\r\n : ''\r\n }\r\n >\r\n {this.renderLabel()}\r\n </label>\r\n )}\r\n </div>\r\n </InputGroup>\r\n </Portal>\r\n );\r\n }\r\n\r\n private onTextErrorsChanged = (textErrors: ValidationError[]) =>\r\n this.setState(\r\n () => ({ textErrors }),\r\n () => this.handleErrors()\r\n );\r\n\r\n private onFocus = (e: React.SyntheticEvent<{}>) => {\r\n this.props.onFocus?.(e);\r\n if (!this.state.suggestionsVisible) {\r\n this.props.onSuggestionsOpened?.();\r\n }\r\n this.setState(\r\n () => ({ textIsFocused: true, suggestionsVisible: true, touched: true }),\r\n () => this.handleErrors()\r\n );\r\n this.fetchExistingTags(this.state.value);\r\n const showMobileVersion =\r\n this.props.mobileVersionEnabled &&\r\n this.isMobile &&\r\n (this.state.textIsFocused || this.state.suggestionsVisible);\r\n if (\r\n !showMobileVersion &&\r\n this.props.mobileVersionEnabled &&\r\n this.isMobile\r\n ) {\r\n setTimeout(() => this.textRef.current?.focus(), 100);\r\n }\r\n };\r\n\r\n private onKeyDown = (suggestions: T[]) => async (e: React.KeyboardEvent) => {\r\n if (e.key === 'Tab') {\r\n this.setState({\r\n suggestionsVisible: false,\r\n preselectedSuggestion: undefined,\r\n });\r\n }\r\n if (\r\n e.key === 'Enter' &&\r\n (this.state.value !== '' ||\r\n this.state.preselectedSuggestion !== undefined) &&\r\n this.state.textErrors.length === 0\r\n ) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n const existingTag =\r\n this.props.existingTags &&\r\n this.props.existingTags.find(et => et.name === this.state.value);\r\n if (this.state.preselectedSuggestion !== undefined) {\r\n this.props.onTagsChanged(\r\n this.props.tags.concat(suggestions[this.state.preselectedSuggestion])\r\n );\r\n this.setState({ value: '', preselectedSuggestion: undefined }, () => {\r\n this.fetchExistingTags();\r\n this.handleErrors();\r\n });\r\n } else if (existingTag) {\r\n this.props.onTagsChanged(this.props.tags.concat(existingTag));\r\n this.setState({ value: '' }, () => {\r\n this.fetchExistingTags();\r\n this.handleErrors();\r\n });\r\n } else if (this.props.allowNew) {\r\n await this.addNewTag();\r\n this.handleErrors();\r\n }\r\n }\r\n if (suggestions.length > 0 && this.state.suggestionsVisible) {\r\n if (e.key === 'ArrowUp') {\r\n const preselectedSuggestion =\r\n this.state.preselectedSuggestion === undefined\r\n ? suggestions.length - 1\r\n : this.state.preselectedSuggestion === 0\r\n ? suggestions.length - 1\r\n : this.state.preselectedSuggestion - 1;\r\n this.setState({ preselectedSuggestion });\r\n } else if (e.key === 'ArrowDown') {\r\n const preselectedSuggestion =\r\n this.state.preselectedSuggestion === undefined\r\n ? 0\r\n : this.state.preselectedSuggestion === suggestions.length - 1\r\n ? 0\r\n : this.state.preselectedSuggestion + 1;\r\n this.setState({ preselectedSuggestion });\r\n } else {\r\n this.setState({ preselectedSuggestion: undefined });\r\n }\r\n }\r\n };\r\n\r\n private addNewTag = async () => {\r\n const newTag = await this.props.onNewTagAdded(this.state.value);\r\n this.setState({\r\n suggestionsVisible: this.props.closeSuggestionsAfterCreate\r\n ? false\r\n : this.state.suggestionsVisible,\r\n });\r\n if (newTag) {\r\n this.props.onTagsChanged(\r\n this.props.tags ? this.props.tags.concat(newTag) : [newTag]\r\n );\r\n }\r\n this.setState({ value: '', textErrors: [] }, () => {\r\n this.fetchExistingTags();\r\n this.handleErrors();\r\n });\r\n };\r\n\r\n private onSuggestionSelected = (tag: T, lastSelected: boolean) => {\r\n const newTags = this.props.tags.concat(tag);\r\n this.props.onTagsChanged(newTags);\r\n const isMax = newTags.length === this.props.maxTags;\r\n const finalValue =\r\n !this.props.allowNew && !isMax && !lastSelected ? this.state.value : '';\r\n this.setState(\r\n {\r\n value: finalValue,\r\n suggestionsVisible:\r\n isMax || this.props.closeSuggestionsAfterCreate\r\n ? false\r\n : this.state.suggestionsVisible,\r\n preselectedSuggestion: undefined,\r\n textErrors: [],\r\n },\r\n () => {\r\n if (\r\n !this.props.maxTags ||\r\n this.props.tags.length + 1 < this.props.maxTags\r\n ) {\r\n this.fetchExistingTags(finalValue);\r\n }\r\n this.handleErrors();\r\n }\r\n );\r\n };\r\n\r\n private onBlur = () => {\r\n this.props.onBlur?.();\r\n this.setState(\r\n {\r\n textIsFocused: false,\r\n preselectedSuggestion: undefined,\r\n },\r\n () => this.handleErrors()\r\n );\r\n };\r\n\r\n private onTextChanged = (\r\n e: React.ChangeEvent<HTMLInputElement>,\r\n isValid: boolean\r\n ) => {\r\n const value = e.target.value;\r\n this.setState(\r\n () => ({\r\n value,\r\n isValid: isValid,\r\n textIsValid: isValid,\r\n suggestionsVisible: true,\r\n }),\r\n () => this.handleErrors()\r\n );\r\n this.fetchExistingTags(e.target.value);\r\n };\r\n\r\n private handleErrors = (tags: T[] = this.props.tags) => {\r\n let errors = this.getErrors(tags);\r\n if (errors.length > 0) {\r\n this.setInvalid(errors);\r\n } else {\r\n this.setValid();\r\n }\r\n };\r\n\r\n private getErrors(tags: T[]) {\r\n let errors = [];\r\n if (tags.length < this.props.maxTags) {\r\n errors = errors.concat(this.state.textErrors);\r\n }\r\n if (this.state.value !== '' && tags.length === 0 && this.props.required) {\r\n errors = errors.concat(\r\n this.getTranslations(this.props.translations).required\r\n );\r\n }\r\n if (this.state.value && this.props.allowNew && !this.state.textIsFocused) {\r\n errors = errors.concat(this.props.valueNotAddedError);\r\n }\r\n if (this.props.maxTags < (this.props.tags && this.props.tags.length)) {\r\n errors = errors.concat(this.props.maxTagsSurpassedError);\r\n }\r\n return errors.filter(i => i);\r\n }\r\n\r\n private fetchExistingTags(startsWith: string = '') {\r\n if (\r\n this.props.fetchExistingTags &&\r\n startsWith.length >= this.props.minLettersToFetch\r\n ) {\r\n const timer = setTimeout(\r\n () => this.setState(() => ({ fetchingExistingTags: true })),\r\n this.props.loadingDelayMs\r\n );\r\n this.props.fetchExistingTags(startsWith).then(fetchedExistingTags => {\r\n clearTimeout(timer);\r\n this.setState(() => ({\r\n fetchedExistingTags,\r\n fetchingExistingTags: false,\r\n }));\r\n });\r\n }\r\n }\r\n\r\n private getSuggestions() {\r\n const existingTags: T[] = []\r\n .concat(this.props.existingTags ? this.props.existingTags : [])\r\n .concat(\r\n this.state.fetchedExistingTags ? this.state.fetchedExistingTags : []\r\n );\r\n const filteredTags = this.props.filterExistingTags(\r\n this.state.value ? this.state.value.toLowerCase() : '',\r\n existingTags\r\n );\r\n let suggestions = filteredTags\r\n .filter(\r\n tag =>\r\n this.props.allowSameTagMultipleTimes ||\r\n !this.props.tags.some(t => t.id === tag.id)\r\n )\r\n .slice(0, this.props.maxSuggestions);\r\n return suggestions;\r\n }\r\n\r\n private renderTag(tag: T, index: number) {\r\n const body = (\r\n <>\r\n {tag.name}\r\n {!this.props.readOnly && (\r\n <Button\r\n {...(this.props.id && {\r\n id: this.props.id + '-tag-' + index.toString(),\r\n })}\r\n circular={true}\r\n blank={true}\r\n onClick={this.tagRemoveClick(tag)}\r\n className=\"ml-1 transform-rotate--45 line-height--0 p-0\"\r\n Component={TagButtonComponent}\r\n preventsDefault={false}\r\n >\r\n <PlusIcon />\r\n </Button>\r\n )}\r\n </>\r\n );\r\n const className = classNames('tags-input__tag', {\r\n 'tags-input__tag-chip': this.props.showChips,\r\n });\r\n if (this.props.onTagClick) {\r\n return (\r\n <Button\r\n onClick={this.tagClick(tag)}\r\n small={true}\r\n className={className}\r\n key={index}\r\n >\r\n {body}\r\n </Button>\r\n );\r\n }\r\n return (\r\n <div onClick={this.tagClick(tag)} className={className} key={index}>\r\n {body}\r\n </div>\r\n );\r\n }\r\n\r\n private tagClick = (tag: T) => () => {\r\n this.props.onTagClick && this.props.onTagClick(tag);\r\n };\r\n\r\n private tagRemoveClick = (tag: T) => (e: React.MouseEvent<HTMLElement>) => {\r\n e.stopPropagation();\r\n const newTags = this.props.tags.filter(sv => sv.id !== tag.id);\r\n /*if (newTags.length === 0) {\r\n setTimeout(() => this.focus(), 50);\r\n }\r\n this.setState({\r\n suggestionsVisible: false,\r\n });*/\r\n this.props.onTagsChanged && this.props.onTagsChanged(newTags);\r\n this.handleErrors(newTags);\r\n // this.fetchExistingTags();\r\n };\r\n}\r\n\r\ninterface TagsFinal {\r\n <T extends Tag = Tag>(item: TagsProps<T>): React.ReactElement;\r\n defaultProps?: Partial<TagsProps>;\r\n}\r\n\r\nexport const Tags = (withThemeContext<TagsProps, InstanceType<typeof TagsRaw>>(\r\n // tslint:disable-next-line: no-any\r\n withFormContext<TagsProps>(TagsRaw),\r\n 'tags'\r\n) as unknown) as TagsFinal;\r\n\r\nexport default Tags;\r\n"],"file":"Tags.js"}
@@ -136,7 +136,7 @@ var TextRaw = /*#__PURE__*/function (_BaseInput) {
136
136
  _createClass(TextRaw, [{
137
137
  key: "componentDidUpdate",
138
138
  value: function componentDidUpdate(prevProps, prevState) {
139
- if (this.props.onNumberChange && (this.state.isValid !== prevState.isValid || this.state.value !== prevState.value) && this.props.number !== Number(this.state.value)) {
139
+ if (this.props.onNumberChange && (this.state.isValid !== prevState.isValid || this.state.value !== prevState.value || this.props.number !== Number(this.state.value))) {
140
140
  var num = Number(this.state.value);
141
141
 
142
142
  if (!isNaN(num)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/components/text/Text.tsx"],"names":["PlusIcon","classNames","require","TextRaw","props","inputRef","current","nativeTextAreaValueSetter","Object","getOwnPropertyDescriptor","window","HTMLInputElement","prototype","set","call","event","Event","bubbles","dispatchEvent","e","stopClickPropagation","stopPropagation","onKeyDown","number","undefined","value","toString","res","handleValueChange","state","isValid","errors","ignoreContext","formContext","updateCallback","componentId","validation","prevProps","prevState","onNumberChange","Number","num","isNaN","clearButtonHidden","length","disabled","title","tooltip","getValidationClass","readOnly","className","containerClick","containerRef","before","id","placeholder","getDisabled","required","handleChange","handleBlur","handleFocus","type","onClick","maxLength","sizeFromValue","after","showClearButton","clearClick","renderDefaultValidation","label","renderLabel","BaseInput","assign","defaultProps","Text"],"mappings":";;;;;;;;;AACA;;AAGA;;AACA;;AAKA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACYA,Q,YAAAA,Q;;;;;;AAAAA,Q;;;;;;;AACZ,IAAIC,UAAU,GAAGC,OAAO,CAAC,YAAD,CAAxB;;IAqBaC,O;;;;;AAOX,mBAAYC,KAAZ,EAA8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AAyC;AAA3D,SACG,KAAKqB,WAAL,EADH,CAlDJ,CARF,CADF,CADF;AAoED;;;;EA5H0BC,qB;;;;gBAAhBpE,O,kBACkBK,MAAM,CAACgE,MAAP,CAAc,EAAd,EAAkBD,sBAAUE,YAA5B,EAA0C;AACrEZ,EAAAA,IAAI,EAAE,MAD+D;AAErEzC,EAAAA,oBAAoB,EAAE,IAF+C;AAGrE6B,EAAAA,QAAQ,EAAE;AAH2D,CAA1C,C;;AAmJxB,IAAMyB,IAAI,GAAG,wCAClB,sCAA2BvE,OAA3B,CADkB,EAElB,MAFkB,CAAb;;eAKQuE,I","sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport InputGroup from '../inputGroup/InputGroup';\r\nimport {\r\n BaseInputProps,\r\n BaseInputState,\r\n BaseInput,\r\n} from '../base/input/BaseInput';\r\nimport { withFormContext } from '../form/withFormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\nimport Button from '../button';\r\nimport * as PlusIcon from 'material-design-icons/content/svg/production/ic_add_24px.svg';\r\nvar classNames = require('classnames');\r\n\r\nexport interface TextProps extends BaseInputProps<HTMLInputElement> {\r\n mask?: string;\r\n reverse?: boolean;\r\n placeholder?: string;\r\n stopClickPropagation?: boolean;\r\n inputRef?: React.Ref<HTMLInputElement>;\r\n readOnly?: boolean;\r\n type?: 'number' | 'text';\r\n maxLength?: number;\r\n showClearButton?: boolean;\r\n after?: React.ReactNode;\r\n before?: React.ReactNode;\r\n sizeFromValue?: boolean;\r\n onNumberChange?: (number: number, isValid: boolean) => void;\r\n number?: number;\r\n}\r\n\r\nexport interface TextState extends BaseInputState {}\r\n\r\nexport class TextRaw extends BaseInput<TextProps, TextState, HTMLInputElement> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n type: 'text',\r\n stopClickPropagation: true,\r\n readOnly: false,\r\n }) as TextProps;\r\n\r\n constructor(props: TextProps) {\r\n super(props);\r\n if (props.number !== undefined) {\r\n const value = props.number?.toString() ?? '';\r\n const res = this.handleValueChange(value, true, [], props, true);\r\n this.state = {\r\n ...this.state,\r\n isValid: res.isValid,\r\n errors: res.errors,\r\n value,\r\n };\r\n if (!this.props.ignoreContext) {\r\n this.props.formContext &&\r\n this.props.formContext.updateCallback(this.componentId, {\r\n validation: {\r\n isValid: res.isValid,\r\n errors: res.errors,\r\n },\r\n });\r\n }\r\n }\r\n }\r\n\r\n public componentDidUpdate(prevProps: TextProps, prevState: TextState) {\r\n if (\r\n this.props.onNumberChange &&\r\n (this.state.isValid !== prevState.isValid ||\r\n this.state.value !== prevState.value) &&\r\n this.props.number !== Number(this.state.value)\r\n ) {\r\n const num = Number(this.state.value);\r\n if (!isNaN(num)) {\r\n this.props.onNumberChange(num, this.state.isValid);\r\n }\r\n if (this.state.value === '') {\r\n this.props.onNumberChange(undefined, this.state.isValid);\r\n }\r\n }\r\n if (\r\n (prevProps.number !== undefined || this.props.number !== undefined) &&\r\n this.props.number !== prevProps.number\r\n ) {\r\n this.handleValueChange(this.props.number?.toString() ?? '');\r\n }\r\n super.componentDidUpdate(prevProps, prevState);\r\n }\r\n\r\n public render() {\r\n const clearButtonHidden = !this.state.value?.length || this.props.disabled;\r\n return (\r\n <InputGroup title={this.props.title} tooltip={this.props.tooltip}>\r\n <div\r\n className={`input__base text-input ${this.getValidationClass()} \r\n ${this.props.readOnly ? 'text-input--readOnly' : ''} ${\r\n this.props.className ? this.props.className : ''\r\n }`}\r\n onClick={this.containerClick}\r\n ref={this.containerRef}\r\n >\r\n <div className=\"text-input__textWrapper\">\r\n {this.props.before}\r\n <input\r\n {...(this.props.id && {\r\n id: this.props.id,\r\n })}\r\n ref={this.inputRef}\r\n placeholder={this.props.placeholder}\r\n disabled={this.getDisabled()}\r\n required={this.props.required}\r\n className={this.state.value ? 'filled' : ''}\r\n onChange={this.handleChange}\r\n value={this.state.value}\r\n onBlur={this.handleBlur}\r\n onFocus={this.handleFocus}\r\n readOnly={this.props.readOnly}\r\n onKeyDown={this.onKeyDown}\r\n type={this.props.type}\r\n onClick={this.props.onClick}\r\n maxLength={this.props.maxLength}\r\n size={\r\n this.props.sizeFromValue\r\n ? this.props.value?.length || 1\r\n : undefined\r\n }\r\n />\r\n {this.props.after}\r\n {!this.props.readOnly && this.props.showClearButton && (\r\n <Button\r\n {...(this.props.id && {\r\n id: this.props.id + '-clear-button',\r\n })}\r\n disabled={clearButtonHidden}\r\n unobtrusive={true}\r\n noShadow={true}\r\n onClick={this.clearClick}\r\n className={classNames(\r\n 'text-input__clearButton line-height--0',\r\n {\r\n 'text-input__clearButton--hidden': clearButtonHidden,\r\n }\r\n )}\r\n >\r\n <PlusIcon className=\"transform-rotate--45 line-height--0\" />\r\n </Button>\r\n )}\r\n <span className=\"highlight\" />\r\n <span className=\"bar\" />\r\n {this.renderDefaultValidation()}\r\n {this.props.label && (\r\n <label className={this.props.readOnly ? 'label--focused' : ''}>\r\n {this.renderLabel()}\r\n </label>\r\n )}\r\n </div>\r\n </div>\r\n </InputGroup>\r\n );\r\n }\r\n\r\n private clearClick = () => {\r\n if (this.inputRef.current) {\r\n var nativeTextAreaValueSetter = Object.getOwnPropertyDescriptor(\r\n window.HTMLInputElement.prototype,\r\n 'value'\r\n ).set;\r\n if (nativeTextAreaValueSetter) {\r\n nativeTextAreaValueSetter.call(this.inputRef.current, '');\r\n\r\n const event = new Event('input', { bubbles: true });\r\n this.inputRef.current.dispatchEvent(event);\r\n }\r\n }\r\n };\r\n\r\n private containerClick = (e: React.MouseEvent<HTMLDivElement>) =>\r\n this.props.stopClickPropagation && e.stopPropagation();\r\n\r\n private onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) =>\r\n this.props.onKeyDown && this.props.onKeyDown(e);\r\n}\r\n\r\nexport const Text = withThemeContext<TextProps, InstanceType<typeof TextRaw>>(\r\n withFormContext<TextProps>(TextRaw),\r\n 'text'\r\n);\r\n\r\nexport default Text;\r\n"],"file":"Text.js"}
1
+ {"version":3,"sources":["../../../src/lib/components/text/Text.tsx"],"names":["PlusIcon","classNames","require","TextRaw","props","inputRef","current","nativeTextAreaValueSetter","Object","getOwnPropertyDescriptor","window","HTMLInputElement","prototype","set","call","event","Event","bubbles","dispatchEvent","e","stopClickPropagation","stopPropagation","onKeyDown","number","undefined","value","toString","res","handleValueChange","state","isValid","errors","ignoreContext","formContext","updateCallback","componentId","validation","prevProps","prevState","onNumberChange","Number","num","isNaN","clearButtonHidden","length","disabled","title","tooltip","getValidationClass","readOnly","className","containerClick","containerRef","before","id","placeholder","getDisabled","required","handleChange","handleBlur","handleFocus","type","onClick","maxLength","sizeFromValue","after","showClearButton","clearClick","renderDefaultValidation","label","renderLabel","BaseInput","assign","defaultProps","Text"],"mappings":";;;;;;;;;AACA;;AAGA;;AACA;;AAKA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACYA,Q,YAAAA,Q;;;;;;AAAAA,Q;;;;;;;AACZ,IAAIC,UAAU,GAAGC,OAAO,CAAC,YAAD,CAAxB;;IAqBaC,O;;;;;AAOX,mBAAYC,KAAZ,EAA8B;AAAA;;AAAA;;AAC5B,8BAAMA,KAAN;;AAD4B,iEAuHT,YAAM;AACzB,UAAI,MAAKC,QAAL,CAAcC,OAAlB,EAA2B;AACzB,YAAIC,yBAAyB,GAAGC,MAAM,CAACC,wBAAP,CAC9BC,MAAM,CAACC,gBAAP,CAAwBC,SADM,EAE9B,OAF8B,EAG9BC,GAHF;;AAIA,YAAIN,yBAAJ,EAA+B;AAC7BA,UAAAA,yBAAyB,CAACO,IAA1B,CAA+B,MAAKT,QAAL,CAAcC,OAA7C,EAAsD,EAAtD;AAEA,cAAMS,KAAK,GAAG,IAAIC,KAAJ,CAAU,OAAV,EAAmB;AAAEC,YAAAA,OAAO,EAAE;AAAX,WAAnB,CAAd;;AACA,gBAAKZ,QAAL,CAAcC,OAAd,CAAsBY,aAAtB,CAAoCH,KAApC;AACD;AACF;AACF,KApI6B;;AAAA,qEAsIL,UAACI,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K7C,KAAL,CAAW8D,eAAnC,iBACC,oBAAC,eAAD,eACO,KAAK9D,KAAL,CAAWkD,EAAX,IAAiB;AACpBA,QAAAA,EAAE,EAAE,KAAKlD,KAAL,CAAWkD,EAAX,GAAgB;AADA,OADxB;AAIE,QAAA,QAAQ,EAAEX,iBAJZ;AAKE,QAAA,WAAW,EAAE,IALf;AAME,QAAA,QAAQ,EAAE,IANZ;AAOE,QAAA,OAAO,EAAE,KAAKwB,UAPhB;AAQE,QAAA,SAAS,EAAElE,UAAU,CACnB,wCADmB,EAEnB;AACE,6CAAmC0C;AADrC,SAFmB;AARvB,uBAeE,oBAAC,QAAD;AAAU,QAAA,SAAS,EAAC;AAApB,QAfF,CA5BJ,eA8CE;AAAM,QAAA,SAAS,EAAC;AAAhB,QA9CF,eA+CE;AAAM,QAAA,SAAS,EAAC;AAAhB,QA/CF,EAgDG,KAAKyB,uBAAL,EAhDH,EAiDG,KAAKhE,KAAL,CAAWiE,KAAX,iBACC;AAAO,QAAA,SAAS,EAAE,KAAKjE,KAAL,CAAW6C,QAAX,GAAsB,gBAAtB,GAAyC;AAA3D,SACG,KAAKqB,WAAL,EADH,CAlDJ,CARF,CADF,CADF;AAoED;;;;EA5H0BC,qB;;;;gBAAhBpE,O,kBACkBK,MAAM,CAACgE,MAAP,CAAc,EAAd,EAAkBD,sBAAUE,YAA5B,EAA0C;AACrEZ,EAAAA,IAAI,EAAE,MAD+D;AAErEzC,EAAAA,oBAAoB,EAAE,IAF+C;AAGrE6B,EAAAA,QAAQ,EAAE;AAH2D,CAA1C,C;;AAmJxB,IAAMyB,IAAI,GAAG,wCAClB,sCAA2BvE,OAA3B,CADkB,EAElB,MAFkB,CAAb;;eAKQuE,I","sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport InputGroup from '../inputGroup/InputGroup';\r\nimport {\r\n BaseInputProps,\r\n BaseInputState,\r\n BaseInput,\r\n} from '../base/input/BaseInput';\r\nimport { withFormContext } from '../form/withFormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\nimport Button from '../button';\r\nimport * as PlusIcon from 'material-design-icons/content/svg/production/ic_add_24px.svg';\r\nvar classNames = require('classnames');\r\n\r\nexport interface TextProps extends BaseInputProps<HTMLInputElement> {\r\n mask?: string;\r\n reverse?: boolean;\r\n placeholder?: string;\r\n stopClickPropagation?: boolean;\r\n inputRef?: React.Ref<HTMLInputElement>;\r\n readOnly?: boolean;\r\n type?: 'number' | 'text';\r\n maxLength?: number;\r\n showClearButton?: boolean;\r\n after?: React.ReactNode;\r\n before?: React.ReactNode;\r\n sizeFromValue?: boolean;\r\n onNumberChange?: (number: number, isValid: boolean) => void;\r\n number?: number;\r\n}\r\n\r\nexport interface TextState extends BaseInputState {}\r\n\r\nexport class TextRaw extends BaseInput<TextProps, TextState, HTMLInputElement> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n type: 'text',\r\n stopClickPropagation: true,\r\n readOnly: false,\r\n }) as TextProps;\r\n\r\n constructor(props: TextProps) {\r\n super(props);\r\n if (props.number !== undefined) {\r\n const value = props.number?.toString() ?? '';\r\n const res = this.handleValueChange(value, true, [], props, true);\r\n this.state = {\r\n ...this.state,\r\n isValid: res.isValid,\r\n errors: res.errors,\r\n value,\r\n };\r\n if (!this.props.ignoreContext) {\r\n this.props.formContext &&\r\n this.props.formContext.updateCallback(this.componentId, {\r\n validation: {\r\n isValid: res.isValid,\r\n errors: res.errors,\r\n },\r\n });\r\n }\r\n }\r\n }\r\n\r\n public componentDidUpdate(prevProps: TextProps, prevState: TextState) {\r\n if (\r\n this.props.onNumberChange &&\r\n (this.state.isValid !== prevState.isValid ||\r\n this.state.value !== prevState.value ||\r\n this.props.number !== Number(this.state.value))\r\n ) {\r\n const num = Number(this.state.value);\r\n if (!isNaN(num)) {\r\n this.props.onNumberChange(num, this.state.isValid);\r\n }\r\n if (this.state.value === '') {\r\n this.props.onNumberChange(undefined, this.state.isValid);\r\n }\r\n }\r\n if (\r\n (prevProps.number !== undefined || this.props.number !== undefined) &&\r\n this.props.number !== prevProps.number\r\n ) {\r\n this.handleValueChange(this.props.number?.toString() ?? '');\r\n }\r\n super.componentDidUpdate(prevProps, prevState);\r\n }\r\n\r\n public render() {\r\n const clearButtonHidden = !this.state.value?.length || this.props.disabled;\r\n return (\r\n <InputGroup title={this.props.title} tooltip={this.props.tooltip}>\r\n <div\r\n className={`input__base text-input ${this.getValidationClass()} \r\n ${this.props.readOnly ? 'text-input--readOnly' : ''} ${\r\n this.props.className ? this.props.className : ''\r\n }`}\r\n onClick={this.containerClick}\r\n ref={this.containerRef}\r\n >\r\n <div className=\"text-input__textWrapper\">\r\n {this.props.before}\r\n <input\r\n {...(this.props.id && {\r\n id: this.props.id,\r\n })}\r\n ref={this.inputRef}\r\n placeholder={this.props.placeholder}\r\n disabled={this.getDisabled()}\r\n required={this.props.required}\r\n className={this.state.value ? 'filled' : ''}\r\n onChange={this.handleChange}\r\n value={this.state.value}\r\n onBlur={this.handleBlur}\r\n onFocus={this.handleFocus}\r\n readOnly={this.props.readOnly}\r\n onKeyDown={this.onKeyDown}\r\n type={this.props.type}\r\n onClick={this.props.onClick}\r\n maxLength={this.props.maxLength}\r\n size={\r\n this.props.sizeFromValue\r\n ? this.props.value?.length || 1\r\n : undefined\r\n }\r\n />\r\n {this.props.after}\r\n {!this.props.readOnly && this.props.showClearButton && (\r\n <Button\r\n {...(this.props.id && {\r\n id: this.props.id + '-clear-button',\r\n })}\r\n disabled={clearButtonHidden}\r\n unobtrusive={true}\r\n noShadow={true}\r\n onClick={this.clearClick}\r\n className={classNames(\r\n 'text-input__clearButton line-height--0',\r\n {\r\n 'text-input__clearButton--hidden': clearButtonHidden,\r\n }\r\n )}\r\n >\r\n <PlusIcon className=\"transform-rotate--45 line-height--0\" />\r\n </Button>\r\n )}\r\n <span className=\"highlight\" />\r\n <span className=\"bar\" />\r\n {this.renderDefaultValidation()}\r\n {this.props.label && (\r\n <label className={this.props.readOnly ? 'label--focused' : ''}>\r\n {this.renderLabel()}\r\n </label>\r\n )}\r\n </div>\r\n </div>\r\n </InputGroup>\r\n );\r\n }\r\n\r\n private clearClick = () => {\r\n if (this.inputRef.current) {\r\n var nativeTextAreaValueSetter = Object.getOwnPropertyDescriptor(\r\n window.HTMLInputElement.prototype,\r\n 'value'\r\n ).set;\r\n if (nativeTextAreaValueSetter) {\r\n nativeTextAreaValueSetter.call(this.inputRef.current, '');\r\n\r\n const event = new Event('input', { bubbles: true });\r\n this.inputRef.current.dispatchEvent(event);\r\n }\r\n }\r\n };\r\n\r\n private containerClick = (e: React.MouseEvent<HTMLDivElement>) =>\r\n this.props.stopClickPropagation && e.stopPropagation();\r\n\r\n private onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) =>\r\n this.props.onKeyDown && this.props.onKeyDown(e);\r\n}\r\n\r\nexport const Text = withThemeContext<TextProps, InstanceType<typeof TextRaw>>(\r\n withFormContext<TextProps>(TextRaw),\r\n 'text'\r\n);\r\n\r\nexport default Text;\r\n"],"file":"Text.js"}
@@ -1376,6 +1376,9 @@
1376
1376
  pointer-events: none; }
1377
1377
  .input__base.checkbox-input input:checked:before {
1378
1378
  transform: rotate(-45deg) scale(1, 1); }
1379
+ .input__base.checkbox-input input:indeterminate:before {
1380
+ border-left-style: none;
1381
+ transform: rotate(0deg) scale(0.8, 1.2) translateX(0); }
1379
1382
  .input__base.checkbox-input input:after {
1380
1383
  content: '';
1381
1384
  position: absolute;