guestbell-forms 2.0.293 → 2.0.294

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.
@@ -61,6 +61,10 @@ export declare class SelectRaw extends BaseInput<SelectProps, SelectState, HTMLS
61
61
  componentDidMount(): void;
62
62
  componentDidUpdate(oldProps: SelectProps): void;
63
63
  render(): JSX.Element;
64
+ protected handleValueChange(value: string, isValid?: boolean, errors?: ValidationError[], props?: SelectProps, initializing?: boolean): {
65
+ isValid: boolean;
66
+ errors: ValidationError[];
67
+ };
64
68
  protected handleBlur(e: React.FocusEvent<HTMLSelectElement>): void;
65
69
  protected handleFocus(e: React.FocusEvent<HTMLSelectElement>): void;
66
70
  private handleChangeCustom;
@@ -33,6 +33,10 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
33
33
 
34
34
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
35
35
 
36
+ 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); }
37
+
38
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
39
+
36
40
  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); }
37
41
 
38
42
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
@@ -160,6 +164,25 @@ var SelectRaw = /*#__PURE__*/function (_BaseInput) {
160
164
  className: "bar"
161
165
  }), this.renderDefaultValidation(), this.props.label && finalValues.length > 0 && /*#__PURE__*/React.createElement("label", null, this.renderLabel()))));
162
166
  }
167
+ }, {
168
+ key: "handleValueChange",
169
+ value: function handleValueChange(value) {
170
+ var isValid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
171
+ var errors = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
172
+ var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.props;
173
+ var initializing = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
174
+
175
+ if (!this.props.multiple) {
176
+ return _get(_getPrototypeOf(SelectRaw.prototype), "handleValueChange", this).call(this, value, isValid, errors, props, initializing);
177
+ } else {
178
+ this.handleValid(this.props.selectedValues);
179
+ }
180
+
181
+ return {
182
+ isValid: true,
183
+ errors: []
184
+ };
185
+ }
163
186
  }, {
164
187
  key: "handleBlur",
165
188
  value: function handleBlur(e) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/components/select/Select.tsx"],"names":["PlusIcon","SelectRaw","props","item","newValues","selectedValues","filter","sv","value","handleValid","onSelectedValuesChange","val","defaultEmpty","values","length","state","Object","assign","handleChangeCustom","bind","multiple","oldProps","validators","customValidators","required","handleValueChange","finalValues","findIndex","t","title","tooltip","getValidationClass","className","readOnly","containerRef","renderSelectedValues","id","inputRef","getDisabled","handleBlur","handleFocus","display","map","index","label","renderReadonly","renderDefaultValidation","renderLabel","e","onBlur","focused","touched","touchOn","setState","onFocus","event","target","isNaN","Number","valNumber","concat","handleChange","isValid","errors","push","getTranslations","defaultBaseTranslations","forEach","customValidator","validInner","Validate","error","setValid","setInvalid","toString","forceSelected","removeItemClick","readonlyEmptyPlaceholder","BaseInput","defaultProps","Select"],"mappings":";;;;;;;;;AACA;;AAGA;;AAEA;;AAOA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA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CAJX;AAKE,UAAA,SAAS,EAAC;AALZ,wBAOE,oBAAC,QAAD,OAPF,CAHJ,CAD6B;AAAA,OAA9B,CADH,CADF,GAoBE,KAAKD,KAAL,CAAW+B,QAAX,iBACE;AAAK,QAAA,SAAS,EAAC;AAAf,sBACE;AAAK,QAAA,SAAS,EAAC;AAAf,SACG,KAAK/B,KAAL,CAAW2E,wBADd,CADF,CAtBC,GA6BH,IA7BJ;AA8BD;;;;EA7P4BC,qB;;;;gBAAlB7E,S,kBAKkBe,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkB6D,sBAAUC,YAA5B,EAA0C;AACrEnE,EAAAA,YAAY,EAAE,IADuD;AAErEQ,EAAAA,QAAQ,EAAE,KAF2D;AAGrEa,EAAAA,QAAQ,EAAE,KAH2D;AAIrE4C,EAAAA,wBAAwB,EAAE;AAJ2C,CAA1C,C;;AAoQxB,IAAMG,MAAM,GAAG,wCAGpB,sCAA6B/E,SAA7B,CAHoB,EAGqB,QAHrB,CAAf;;eAKQ+E,M","sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport InputGroup from '../inputGroup/InputGroup';\r\nimport * as PlusIcon from 'material-design-icons/content/svg/production/ic_add_circle_outline_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 } from '../button/Button';\r\nimport { withFormContext } from '../form/withFormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\n\r\nexport interface SelectValue {\r\n value: number | string;\r\n label?: string;\r\n forceSelected?: boolean;\r\n}\r\n\r\nexport interface SelectProps extends BaseInputProps<HTMLSelectElement> {\r\n values?: SelectValue[];\r\n defaultEmpty?: boolean;\r\n multiple?: boolean;\r\n selectedValues?: SelectValue[];\r\n onSelectedValuesChange?: (newValues: SelectValue[]) => void;\r\n inputRef?: (input: HTMLSelectElement) => void;\r\n readOnly?: boolean;\r\n readonlyEmptyPlaceholder?: string;\r\n}\r\n\r\nexport interface SelectState extends BaseInputState {}\r\n\r\nexport class SelectRaw extends BaseInput<\r\n SelectProps,\r\n SelectState,\r\n HTMLSelectElement\r\n> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n defaultEmpty: true,\r\n multiple: false,\r\n readOnly: false,\r\n readonlyEmptyPlaceholder: 'N/A',\r\n });\r\n\r\n constructor(props: SelectProps) {\r\n super(props);\r\n const val = !props.value\r\n ? props.defaultEmpty\r\n ? ''\r\n : props.values && props.values.length > 0\r\n ? props.values[0]\r\n : ''\r\n : props.value;\r\n this.state = Object.assign(this.state, { value: val });\r\n this.handleChangeCustom = this.handleChangeCustom.bind(this);\r\n }\r\n\r\n public componentDidMount() {\r\n this.props.multiple && this.handleValid(this.props.selectedValues);\r\n }\r\n\r\n public componentDidUpdate(oldProps: SelectProps) {\r\n if (\r\n oldProps.value !== this.props.value ||\r\n oldProps.validators !== this.props.validators ||\r\n oldProps.customValidators !== this.props.customValidators ||\r\n oldProps.required !== this.props.required ||\r\n oldProps.selectedValues !== this.props.selectedValues\r\n ) {\r\n if (this.props.multiple) {\r\n this.handleValid(this.props.selectedValues);\r\n } else {\r\n this.handleValueChange(this.props.value, true, [], this.props);\r\n }\r\n }\r\n }\r\n\r\n public render() {\r\n const finalValues = this.props.multiple\r\n ? this.props.values.filter(\r\n item =>\r\n this.props.selectedValues.findIndex(t => t.value === item.value) < 0\r\n )\r\n : this.props.values;\r\n return (\r\n <InputGroup title={this.props.title} tooltip={this.props.tooltip}>\r\n <div\r\n className={\r\n 'input__base select-input ' +\r\n this.getValidationClass() +\r\n ' ' +\r\n (this.props.className ? this.props.className : '') +\r\n ' ' +\r\n (this.props.readOnly ? 'readonly' : '') +\r\n ' ' +\r\n (this.props.multiple ? 'multiple' : '')\r\n }\r\n ref={this.containerRef}\r\n >\r\n {this.renderSelectedValues()}\r\n {finalValues.length > 0 &&\r\n ((this.props.multiple && !this.props.readOnly) ||\r\n !this.props.multiple) && (\r\n <div className=\"select-input__select__wrapper\">\r\n {(!this.props.multiple && !this.props.readOnly) ||\r\n this.props.multiple ? (\r\n <select\r\n {...(this.props.id && {\r\n id: this.props.id,\r\n })}\r\n ref={this.inputRef}\r\n disabled={this.getDisabled()}\r\n required={this.props.required}\r\n onChange={this.handleChangeCustom}\r\n value={this.state.value}\r\n className={\r\n 'select-input__select ' +\r\n (this.state.value !== '' ||\r\n (this.props.selectedValues &&\r\n this.props.selectedValues.length > 0)\r\n ? 'filled'\r\n : '')\r\n }\r\n onBlur={this.handleBlur}\r\n onFocus={this.handleFocus}\r\n tabIndex={0}\r\n >\r\n {this.props.defaultEmpty && (\r\n <option\r\n key={-1}\r\n disabled={true}\r\n value=\"\"\r\n style={{ display: 'none' }}\r\n />\r\n )}\r\n {finalValues.map((value, index) => (\r\n <option key={index} value={value.value}>\r\n {value.label ? value.label : value.value}\r\n </option>\r\n ))}\r\n </select>\r\n ) : (\r\n <span\r\n className={\r\n 'select-input__select ' +\r\n (this.state.value !== '' ||\r\n (this.props.selectedValues &&\r\n this.props.selectedValues.length > 0)\r\n ? 'filled'\r\n : '')\r\n }\r\n >\r\n {this.renderReadonly()}\r\n </span>\r\n )}\r\n <span className=\"highlight\" />\r\n <span className=\"bar\" />\r\n {this.renderDefaultValidation()}\r\n {this.props.label && finalValues.length > 0 && (\r\n <label>{this.renderLabel()}</label>\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n </InputGroup>\r\n );\r\n }\r\n\r\n protected handleBlur(e: React.FocusEvent<HTMLSelectElement>) {\r\n this.props.onBlur && this.props.onBlur();\r\n let state = { focused: false };\r\n if (!this.state.touched && this.props.touchOn === 'blur') {\r\n state = Object.assign(state, { touched: true });\r\n if (!this.props.multiple) {\r\n this.handleValueChange(this.state.value);\r\n } else {\r\n this.handleValid(this.props.selectedValues);\r\n }\r\n }\r\n this.setState(state);\r\n }\r\n\r\n protected handleFocus(e: React.FocusEvent<HTMLSelectElement>) {\r\n this.props.onFocus && this.props.onFocus(e);\r\n let state = { focused: true };\r\n if (!this.state.touched && this.props.touchOn === 'focus') {\r\n state = Object.assign(state, { touched: true });\r\n if (!this.props.multiple) {\r\n this.handleValueChange(this.state.value);\r\n } else {\r\n this.handleValid(this.props.selectedValues);\r\n }\r\n }\r\n this.setState(state);\r\n }\r\n\r\n private handleChangeCustom(event: React.ChangeEvent<HTMLSelectElement>) {\r\n if (this.props.multiple) {\r\n let value = event.target.value;\r\n let val = this.props.values.filter(item => item.value === value)[0];\r\n if (!val) {\r\n if (!isNaN(Number(value))) {\r\n let valNumber = Number(value);\r\n val = this.props.values.filter(item => item.value === valNumber)[0];\r\n }\r\n }\r\n let newValues = this.props.selectedValues.concat(val);\r\n if (val) {\r\n this.props.onSelectedValuesChange &&\r\n this.props.onSelectedValuesChange(newValues);\r\n this.handleValid(newValues);\r\n this.setState({ value: '' });\r\n }\r\n } else {\r\n this.handleChange(event);\r\n }\r\n }\r\n\r\n private handleValid(newValues: SelectValue[]) {\r\n let isValid = true;\r\n let errors: ValidationError[] = [];\r\n if (this.props.required) {\r\n if (newValues.length === 0) {\r\n isValid = false;\r\n errors.push(this.getTranslations(defaultBaseTranslations).required);\r\n }\r\n }\r\n if (this.props.customValidators) {\r\n this.props.customValidators.forEach(customValidator => {\r\n let validInner = false;\r\n validInner = customValidator.Validate(\r\n this.state.value,\r\n this.props.required,\r\n error => errors.push(error)\r\n );\r\n if (isValid && !validInner) {\r\n isValid = validInner;\r\n }\r\n });\r\n }\r\n if (isValid) {\r\n this.setValid();\r\n } else {\r\n this.setInvalid(errors);\r\n }\r\n }\r\n\r\n private renderReadonly() {\r\n const value = this.props.values.filter(\r\n item => item.value.toString() === this.state.value\r\n )[0];\r\n return value ? (value.label ? value.label : value.value) : '';\r\n }\r\n\r\n private renderSelectedValues() {\r\n return this.props.multiple ? (\r\n this.props.selectedValues.length > 0 ? (\r\n <div className=\"select-input__selectedValue__wrapper\">\r\n {this.props.selectedValues.map((item, index) => (\r\n <div className=\"select-input__selectedValue\" key={index}>\r\n {item.label ? item.label : item.value}\r\n {!this.props.readOnly && (\r\n <Button\r\n disabled={item.forceSelected}\r\n circular={true}\r\n blank={true}\r\n onClick={this.removeItemClick(item)}\r\n className=\"ml-1 transform-rotate--45 line-height--0 p-0\"\r\n >\r\n <PlusIcon />\r\n </Button>\r\n )}\r\n </div>\r\n ))}\r\n </div>\r\n ) : (\r\n this.props.readOnly && (\r\n <div className=\"select-input__selectedValue__wrapper\">\r\n <div className=\"select-input__selectedValue\">\r\n {this.props.readonlyEmptyPlaceholder}\r\n </div>\r\n </div>\r\n )\r\n )\r\n ) : null;\r\n }\r\n\r\n private removeItemClick = (item: SelectValue) => () => {\r\n const newValues = this.props.selectedValues.filter(\r\n sv => sv.value !== item.value\r\n );\r\n this.handleValid(newValues);\r\n this.props.onSelectedValuesChange &&\r\n this.props.onSelectedValuesChange(newValues);\r\n };\r\n}\r\n\r\nexport const Select = withThemeContext<\r\n SelectProps,\r\n InstanceType<typeof SelectRaw>\r\n>(withFormContext<SelectProps>(SelectRaw), 'select');\r\n\r\nexport default Select;\r\n"],"file":"Select.js"}
1
+ {"version":3,"sources":["../../../src/lib/components/select/Select.tsx"],"names":["PlusIcon","SelectRaw","props","item","newValues","selectedValues","filter","sv","value","handleValid","onSelectedValuesChange","val","defaultEmpty","values","length","state","Object","assign","handleChangeCustom","bind","multiple","oldProps","validators","customValidators","required","handleValueChange","finalValues","findIndex","t","title","tooltip","getValidationClass","className","readOnly","containerRef","renderSelectedValues","id","inputRef","getDisabled","handleBlur","handleFocus","display","map","index","label","renderReadonly","renderDefaultValidation","renderLabel","isValid","errors","initializing","e","onBlur","focused","touched","touchOn","setState","onFocus","event","target","isNaN","Number","valNumber","concat","handleChange","push","getTranslations","defaultBaseTranslations","forEach","customValidator","validInner","Validate","error","setValid","setInvalid","toString","forceSelected","removeItemClick","readonlyEmptyPlaceholder","BaseInput","defaultProps","Select"],"mappings":";;;;;;;;;AACA;;AAGA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putGroup from '../inputGroup/InputGroup';\r\nimport * as PlusIcon from 'material-design-icons/content/svg/production/ic_add_circle_outline_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 } from '../button/Button';\r\nimport { withFormContext } from '../form/withFormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\n\r\nexport interface SelectValue {\r\n value: number | string;\r\n label?: string;\r\n forceSelected?: boolean;\r\n}\r\n\r\nexport interface SelectProps extends BaseInputProps<HTMLSelectElement> {\r\n values?: SelectValue[];\r\n defaultEmpty?: boolean;\r\n multiple?: boolean;\r\n selectedValues?: SelectValue[];\r\n onSelectedValuesChange?: (newValues: SelectValue[]) => void;\r\n inputRef?: (input: HTMLSelectElement) => void;\r\n readOnly?: boolean;\r\n readonlyEmptyPlaceholder?: string;\r\n}\r\n\r\nexport interface SelectState extends BaseInputState {}\r\n\r\nexport class SelectRaw extends BaseInput<\r\n SelectProps,\r\n SelectState,\r\n HTMLSelectElement\r\n> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n defaultEmpty: true,\r\n multiple: false,\r\n readOnly: false,\r\n readonlyEmptyPlaceholder: 'N/A',\r\n });\r\n\r\n constructor(props: SelectProps) {\r\n super(props);\r\n const val = !props.value\r\n ? props.defaultEmpty\r\n ? ''\r\n : props.values && props.values.length > 0\r\n ? props.values[0]\r\n : ''\r\n : props.value;\r\n this.state = Object.assign(this.state, { value: val });\r\n this.handleChangeCustom = this.handleChangeCustom.bind(this);\r\n }\r\n\r\n public componentDidMount() {\r\n this.props.multiple && this.handleValid(this.props.selectedValues);\r\n }\r\n\r\n public componentDidUpdate(oldProps: SelectProps) {\r\n if (\r\n oldProps.value !== this.props.value ||\r\n oldProps.validators !== this.props.validators ||\r\n oldProps.customValidators !== this.props.customValidators ||\r\n oldProps.required !== this.props.required ||\r\n oldProps.selectedValues !== this.props.selectedValues\r\n ) {\r\n if (this.props.multiple) {\r\n this.handleValid(this.props.selectedValues);\r\n } else {\r\n this.handleValueChange(this.props.value, true, [], this.props);\r\n }\r\n }\r\n }\r\n\r\n public render() {\r\n const finalValues = this.props.multiple\r\n ? this.props.values.filter(\r\n item =>\r\n this.props.selectedValues.findIndex(t => t.value === item.value) < 0\r\n )\r\n : this.props.values;\r\n return (\r\n <InputGroup title={this.props.title} tooltip={this.props.tooltip}>\r\n <div\r\n className={\r\n 'input__base select-input ' +\r\n this.getValidationClass() +\r\n ' ' +\r\n (this.props.className ? this.props.className : '') +\r\n ' ' +\r\n (this.props.readOnly ? 'readonly' : '') +\r\n ' ' +\r\n (this.props.multiple ? 'multiple' : '')\r\n }\r\n ref={this.containerRef}\r\n >\r\n {this.renderSelectedValues()}\r\n {finalValues.length > 0 &&\r\n ((this.props.multiple && !this.props.readOnly) ||\r\n !this.props.multiple) && (\r\n <div className=\"select-input__select__wrapper\">\r\n {(!this.props.multiple && !this.props.readOnly) ||\r\n this.props.multiple ? (\r\n <select\r\n {...(this.props.id && {\r\n id: this.props.id,\r\n })}\r\n ref={this.inputRef}\r\n disabled={this.getDisabled()}\r\n required={this.props.required}\r\n onChange={this.handleChangeCustom}\r\n value={this.state.value}\r\n className={\r\n 'select-input__select ' +\r\n (this.state.value !== '' ||\r\n (this.props.selectedValues &&\r\n this.props.selectedValues.length > 0)\r\n ? 'filled'\r\n : '')\r\n }\r\n onBlur={this.handleBlur}\r\n onFocus={this.handleFocus}\r\n tabIndex={0}\r\n >\r\n {this.props.defaultEmpty && (\r\n <option\r\n key={-1}\r\n disabled={true}\r\n value=\"\"\r\n style={{ display: 'none' }}\r\n />\r\n )}\r\n {finalValues.map((value, index) => (\r\n <option key={index} value={value.value}>\r\n {value.label ? value.label : value.value}\r\n </option>\r\n ))}\r\n </select>\r\n ) : (\r\n <span\r\n className={\r\n 'select-input__select ' +\r\n (this.state.value !== '' ||\r\n (this.props.selectedValues &&\r\n this.props.selectedValues.length > 0)\r\n ? 'filled'\r\n : '')\r\n }\r\n >\r\n {this.renderReadonly()}\r\n </span>\r\n )}\r\n <span className=\"highlight\" />\r\n <span className=\"bar\" />\r\n {this.renderDefaultValidation()}\r\n {this.props.label && finalValues.length > 0 && (\r\n <label>{this.renderLabel()}</label>\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n </InputGroup>\r\n );\r\n }\r\n\r\n protected handleValueChange(\r\n value: string,\r\n isValid: boolean = true,\r\n errors: ValidationError[] = [],\r\n props: SelectProps = this.props,\r\n initializing: boolean = false\r\n ) {\r\n if (!this.props.multiple) {\r\n return super.handleValueChange(\r\n value,\r\n isValid,\r\n errors,\r\n props,\r\n initializing\r\n );\r\n } else {\r\n this.handleValid(this.props.selectedValues);\r\n }\r\n return {\r\n isValid: true,\r\n errors: [],\r\n };\r\n }\r\n\r\n protected handleBlur(e: React.FocusEvent<HTMLSelectElement>) {\r\n this.props.onBlur && this.props.onBlur();\r\n let state = { focused: false };\r\n if (!this.state.touched && this.props.touchOn === 'blur') {\r\n state = Object.assign(state, { touched: true });\r\n if (!this.props.multiple) {\r\n this.handleValueChange(this.state.value);\r\n } else {\r\n this.handleValid(this.props.selectedValues);\r\n }\r\n }\r\n this.setState(state);\r\n }\r\n\r\n protected handleFocus(e: React.FocusEvent<HTMLSelectElement>) {\r\n this.props.onFocus && this.props.onFocus(e);\r\n let state = { focused: true };\r\n if (!this.state.touched && this.props.touchOn === 'focus') {\r\n state = Object.assign(state, { touched: true });\r\n if (!this.props.multiple) {\r\n this.handleValueChange(this.state.value);\r\n } else {\r\n this.handleValid(this.props.selectedValues);\r\n }\r\n }\r\n this.setState(state);\r\n }\r\n\r\n private handleChangeCustom(event: React.ChangeEvent<HTMLSelectElement>) {\r\n if (this.props.multiple) {\r\n let value = event.target.value;\r\n let val = this.props.values.filter(item => item.value === value)[0];\r\n if (!val) {\r\n if (!isNaN(Number(value))) {\r\n let valNumber = Number(value);\r\n val = this.props.values.filter(item => item.value === valNumber)[0];\r\n }\r\n }\r\n let newValues = this.props.selectedValues.concat(val);\r\n if (val) {\r\n this.props.onSelectedValuesChange &&\r\n this.props.onSelectedValuesChange(newValues);\r\n this.handleValid(newValues);\r\n this.setState({ value: '' });\r\n }\r\n } else {\r\n this.handleChange(event);\r\n }\r\n }\r\n\r\n private handleValid(newValues: SelectValue[]) {\r\n let isValid = true;\r\n let errors: ValidationError[] = [];\r\n if (this.props.required) {\r\n if (newValues.length === 0) {\r\n isValid = false;\r\n errors.push(this.getTranslations(defaultBaseTranslations).required);\r\n }\r\n }\r\n if (this.props.customValidators) {\r\n this.props.customValidators.forEach(customValidator => {\r\n let validInner = false;\r\n validInner = customValidator.Validate(\r\n this.state.value,\r\n this.props.required,\r\n error => errors.push(error)\r\n );\r\n if (isValid && !validInner) {\r\n isValid = validInner;\r\n }\r\n });\r\n }\r\n if (isValid) {\r\n this.setValid();\r\n } else {\r\n this.setInvalid(errors);\r\n }\r\n }\r\n\r\n private renderReadonly() {\r\n const value = this.props.values.filter(\r\n item => item.value.toString() === this.state.value\r\n )[0];\r\n return value ? (value.label ? value.label : value.value) : '';\r\n }\r\n\r\n private renderSelectedValues() {\r\n return this.props.multiple ? (\r\n this.props.selectedValues.length > 0 ? (\r\n <div className=\"select-input__selectedValue__wrapper\">\r\n {this.props.selectedValues.map((item, index) => (\r\n <div className=\"select-input__selectedValue\" key={index}>\r\n {item.label ? item.label : item.value}\r\n {!this.props.readOnly && (\r\n <Button\r\n disabled={item.forceSelected}\r\n circular={true}\r\n blank={true}\r\n onClick={this.removeItemClick(item)}\r\n className=\"ml-1 transform-rotate--45 line-height--0 p-0\"\r\n >\r\n <PlusIcon />\r\n </Button>\r\n )}\r\n </div>\r\n ))}\r\n </div>\r\n ) : (\r\n this.props.readOnly && (\r\n <div className=\"select-input__selectedValue__wrapper\">\r\n <div className=\"select-input__selectedValue\">\r\n {this.props.readonlyEmptyPlaceholder}\r\n </div>\r\n </div>\r\n )\r\n )\r\n ) : null;\r\n }\r\n\r\n private removeItemClick = (item: SelectValue) => () => {\r\n const newValues = this.props.selectedValues.filter(\r\n sv => sv.value !== item.value\r\n );\r\n this.handleValid(newValues);\r\n this.props.onSelectedValuesChange &&\r\n this.props.onSelectedValuesChange(newValues);\r\n };\r\n}\r\n\r\nexport const Select = withThemeContext<\r\n SelectProps,\r\n InstanceType<typeof SelectRaw>\r\n>(withFormContext<SelectProps>(SelectRaw), 'select');\r\n\r\nexport default Select;\r\n"],"file":"Select.js"}
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>guestbell-forms [6 May 2022 at 23:55]</title>
6
+ <title>guestbell-forms [30 Jul 2022 at 12:4]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2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WPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
8
8
 
9
9
  <script>
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.293",
2
+ "version": "2.0.294",
3
3
  "description": "React forms with validation as used in GuestBell",
4
4
  "keywords": [
5
5
  "react",