guestbell-forms 2.0.294 → 2.0.297
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/form/Form.d.ts +3 -0
- package/build/components/form/Form.js +3 -2
- package/build/components/form/Form.js.map +1 -1
- package/build/components/select/Select.js +4 -2
- package/build/components/select/Select.js.map +1 -1
- package/build/dist/report.html +1 -1
- package/package.json +1 -1
@@ -7,6 +7,7 @@ export declare type FormProps = React.PropsWithChildren<ThemeContextProps & {
|
|
7
7
|
noValidate?: boolean;
|
8
8
|
onSubmit?: () => void;
|
9
9
|
extraComponents?: ComponentsDict;
|
10
|
+
component?: keyof JSX.IntrinsicElements;
|
10
11
|
}>;
|
11
12
|
export interface FormState {
|
12
13
|
contextState: FormContextState;
|
@@ -15,6 +16,7 @@ export declare class Form extends React.PureComponent<FormProps, FormState> {
|
|
15
16
|
static defaultProps: {
|
16
17
|
noValidate: boolean;
|
17
18
|
showExpandAll: boolean;
|
19
|
+
component: keyof JSX.IntrinsicElements;
|
18
20
|
};
|
19
21
|
constructor(props: FormProps);
|
20
22
|
disableComponents(): void;
|
@@ -35,6 +37,7 @@ declare const _default: React.ForwardRefExoticComponent<ThemeContextProps & {
|
|
35
37
|
noValidate?: boolean;
|
36
38
|
onSubmit?: () => void;
|
37
39
|
extraComponents?: ComponentsDict;
|
40
|
+
component?: keyof JSX.IntrinsicElements;
|
38
41
|
} & {
|
39
42
|
children?: React.ReactNode;
|
40
43
|
} & React.RefAttributes<Form>>;
|
@@ -124,7 +124,7 @@ var Form = /*#__PURE__*/function (_React$PureComponent) {
|
|
124
124
|
}, {
|
125
125
|
key: "render",
|
126
126
|
value: function render() {
|
127
|
-
return /*#__PURE__*/React.createElement(
|
127
|
+
return /*#__PURE__*/React.createElement(this.props.component, _extends({}, this.props.id && {
|
128
128
|
id: this.props.id
|
129
129
|
}, {
|
130
130
|
noValidate: true,
|
@@ -242,7 +242,8 @@ exports.Form = Form;
|
|
242
242
|
|
243
243
|
_defineProperty(Form, "defaultProps", {
|
244
244
|
noValidate: false,
|
245
|
-
showExpandAll: true
|
245
|
+
showExpandAll: true,
|
246
|
+
component: 'form'
|
246
247
|
});
|
247
248
|
|
248
249
|
var _default = (0, _withThemeContext.withThemeContext)(Form, 'form');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/components/form/Form.tsx"],"names":["Form","props","e","preventDefault","onSubmit","subscribe","bind","unSubscribe","updateCallback","disableComponents","enableComponents","state","contextState","isFormValid","components","extraComponents","Object","keys","forEach","key","component","componentApi","disableComponent","enableComponent","touch","unTouch","id","className","mergeContext","children","getIsFormValid","componentId","componentState","setState","previousState","assign","initialValid","validation","isValid","previousComponent","React","PureComponent","noValidate","showExpandAll"],"mappings":";;;;;;;;;AACA;;AAGA;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiBaA,I;;;;;AAMX,gBAAYC,KAAZ,EAA8B;AAAA;;AAAA;;AAC5B,8BAAMA,KAAN;;AAD4B,+DA+GX,UAACC,CAAD,EAAwB;AACzCA,MAAAA,CAAC,CAACC,cAAF;AACA,YAAKF,KAAL,CAAWG,QAAX,IAAuB,MAAKH,KAAL,CAAWG,QAAX,EAAvB;AACD,KAlH6B;;AAE5B,UAAKC,SAAL,GAAiB,MAAKA,SAAL,CAAeC,IAAf,+BAAjB;AACA,UAAKC,WAAL,GAAmB,MAAKA,WAAL,CAAiBD,IAAjB,+BAAnB;AACA,UAAKE,cAAL,GAAsB,MAAKA,cAAL,CAAoBF,IAApB,+BAAtB;AACA,UAAKG,iBAAL,GAAyB,MAAKA,iBAAL,CAAuBH,IAAvB,+BAAzB;AACA,UAAKI,gBAAL,GAAwB,MAAKA,gBAAL,CAAsBJ,IAAtB,+BAAxB;AACA,UAAKK,KAAL,GAAa;AACXC,MAAAA,YAAY,EAAE;AACZP,QAAAA,SAAS,EAAE,MAAKA,SADJ;AAEZE,QAAAA,WAAW,EAAE,MAAKA,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EA/MuB2B,KAAK,CAACC,a;;;;gBAAnBzC,I,kBACkB;AAC3B0C,EAAAA,UAAU,EAAE,KADe;AAE3BC,EAAAA,aAAa,EAAE;AAFY,C;;eAiNhB,wCACb3C,IADa,EAEb,MAFa,C","sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport {\r\n FormContextState,\r\n FormComponentContextState,\r\n FormContextProvider,\r\n ComponentsDict,\r\n} from './FormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\nimport { ThemeContextProps } from '../themeProvider/ThemeContext';\r\n\r\nexport type FormProps = React.PropsWithChildren<\r\n ThemeContextProps & {\r\n id?: string;\r\n className?: string;\r\n noValidate?: boolean;\r\n onSubmit?: () => void;\r\n extraComponents?: ComponentsDict;\r\n }\r\n>;\r\n\r\nexport interface FormState {\r\n contextState: FormContextState;\r\n}\r\n\r\nexport class Form extends React.PureComponent<FormProps, FormState> {\r\n public static defaultProps = {\r\n noValidate: false,\r\n showExpandAll: true,\r\n };\r\n\r\n constructor(props: FormProps) {\r\n super(props);\r\n this.subscribe = this.subscribe.bind(this);\r\n this.unSubscribe = this.unSubscribe.bind(this);\r\n this.updateCallback = this.updateCallback.bind(this);\r\n this.disableComponents = this.disableComponents.bind(this);\r\n this.enableComponents = this.enableComponents.bind(this);\r\n this.state = {\r\n contextState: {\r\n subscribe: this.subscribe,\r\n unSubscribe: this.unSubscribe,\r\n isFormValid: true,\r\n updateCallback: this.updateCallback,\r\n disableComponents: this.disableComponents,\r\n enableComponents: this.enableComponents,\r\n components: {},\r\n },\r\n };\r\n }\r\n\r\n public disableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.disableComponent &&\r\n component.componentApi.disableComponent();\r\n });\r\n }\r\n\r\n public enableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.enableComponent &&\r\n component.componentApi.enableComponent();\r\n });\r\n }\r\n\r\n public touchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.touch &&\r\n component.componentApi.touch();\r\n });\r\n }\r\n\r\n public unTouchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.unTouch &&\r\n component.componentApi.unTouch();\r\n });\r\n }\r\n\r\n public render() {\r\n return (\r\n <form\r\n {...(this.props.id && { id: this.props.id })}\r\n noValidate={true}\r\n role=\"form\"\r\n className={`input__form validation-form ${\r\n this.props.className ? this.props.className : ''\r\n }`}\r\n onSubmit={this.onSubmit}\r\n >\r\n <FormContextProvider value={this.mergeContext()}>\r\n {this.props.children}\r\n </FormContextProvider>\r\n </form>\r\n );\r\n }\r\n\r\n private mergeContext(): FormContextState {\r\n if (!this.props.extraComponents) {\r\n return this.state.contextState;\r\n }\r\n const isFormValid =\r\n this.state.contextState.isFormValid &&\r\n this.getIsFormValid(this.props.extraComponents);\r\n return {\r\n ...this.state.contextState,\r\n components: {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n },\r\n isFormValid,\r\n };\r\n }\r\n\r\n private onSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n this.props.onSubmit && this.props.onSubmit();\r\n };\r\n\r\n private subscribe(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n if (componentState) {\r\n components[componentId] = componentState;\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private unSubscribe(componentId: string) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n delete components[componentId];\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private getIsFormValid(\r\n components: ComponentsDict = this.state.contextState.components,\r\n initialValid: boolean = true\r\n ): boolean {\r\n let isFormValid = initialValid;\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n if (component && component.validation && !component.validation.isValid) {\r\n isFormValid = false;\r\n }\r\n });\r\n return isFormValid;\r\n }\r\n\r\n private updateCallback(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n this.setState(previousState => {\r\n let components = Object.assign({}, previousState.contextState.components);\r\n const previousComponent = components[componentId];\r\n if (componentState && previousComponent) {\r\n components[componentId] = {\r\n ...previousComponent,\r\n ...componentState,\r\n validation: {\r\n ...previousComponent.validation,\r\n ...componentState.validation,\r\n },\r\n };\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...this.state.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n}\r\n\r\nexport default withThemeContext<FormProps, InstanceType<typeof Form>>(\r\n Form,\r\n 'form'\r\n);\r\n"],"file":"Form.js"}
|
1
|
+
{"version":3,"sources":["../../../src/lib/components/form/Form.tsx"],"names":["Form","props","e","preventDefault","onSubmit","subscribe","bind","unSubscribe","updateCallback","disableComponents","enableComponents","state","contextState","isFormValid","components","extraComponents","Object","keys","forEach","key","component","componentApi","disableComponent","enableComponent","touch","unTouch","id","className","mergeContext","children","getIsFormValid","componentId","componentState","setState","previousState","assign","initialValid","validation","isValid","previousCom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,SAAS,CAACiB,UAAV,CAAqBC,OAA/D,EAAwE;AACtEzB,UAAAA,WAAW,GAAG,KAAd;AACD;AACF,OALD;AAMA,aAAOA,WAAP;AACD;;;WAED,wBACEkB,WADF,EAEEC,cAFF,EAGE;AAAA;;AACA,WAAKC,QAAL,CAAc,UAAAC,aAAa,EAAI;AAC7B,YAAIpB,UAAU,GAAGE,MAAM,CAACmB,MAAP,CAAc,EAAd,EAAkBD,aAAa,CAACtB,YAAd,CAA2BE,UAA7C,CAAjB;AACA,YAAMyB,iBAAiB,GAAGzB,UAAU,CAACiB,WAAD,CAApC;;AACA,YAAIC,cAAc,IAAIO,iBAAtB,EAAyC;AACvCzB,UAAAA,UAAU,CAACiB,WAAD,CAAV,iDACKQ,iBADL,GAEKP,cAFL;AAGEK,YAAAA,UAAU,kCACLE,iBAAiB,CAACF,UADb,GAELL,cAAc,CAACK,UAFV;AAHZ;AAQD;;AACD,YAAIxB,WAAW,GAAG,MAAI,CAACiB,cAAL,CAAoBhB,UAApB,CAAlB;;AACA,eAAO;AACLF,UAAAA,YAAY,kCACP,MAAI,CAACD,KAAL,CAAWC,YADJ;AAEVE,YAAAA,UAAU,EAAVA,UAFU;AAGVD,YAAAA,WAAW,EAAXA;AAHU;AADP,SAAP;AAOD,OArBD;AAsBD;;;;EAhNuB2B,KAAK,CAACC,a;;;;gBAAnBzC,I,kBACkB;AAC3B0C,EAAAA,UAAU,EAAE,KADe;AAE3BC,EAAAA,aAAa,EAAE,IAFY;AAG3BvB,EAAAA,SAAS,EAAE;AAHgB,C;;eAkNhB,wCACbpB,IADa,EAEb,MAFa,C","sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport {\r\n FormContextState,\r\n FormComponentContextState,\r\n FormContextProvider,\r\n ComponentsDict,\r\n} from './FormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\nimport { ThemeContextProps } from '../themeProvider/ThemeContext';\r\n\r\nexport type FormProps = React.PropsWithChildren<\r\n ThemeContextProps & {\r\n id?: string;\r\n className?: string;\r\n noValidate?: boolean;\r\n onSubmit?: () => void;\r\n extraComponents?: ComponentsDict;\r\n component?: keyof JSX.IntrinsicElements;\r\n }\r\n>;\r\n\r\nexport interface FormState {\r\n contextState: FormContextState;\r\n}\r\n\r\nexport class Form extends React.PureComponent<FormProps, FormState> {\r\n public static defaultProps = {\r\n noValidate: false,\r\n showExpandAll: true,\r\n component: 'form' as keyof JSX.IntrinsicElements,\r\n };\r\n\r\n constructor(props: FormProps) {\r\n super(props);\r\n this.subscribe = this.subscribe.bind(this);\r\n this.unSubscribe = this.unSubscribe.bind(this);\r\n this.updateCallback = this.updateCallback.bind(this);\r\n this.disableComponents = this.disableComponents.bind(this);\r\n this.enableComponents = this.enableComponents.bind(this);\r\n this.state = {\r\n contextState: {\r\n subscribe: this.subscribe,\r\n unSubscribe: this.unSubscribe,\r\n isFormValid: true,\r\n updateCallback: this.updateCallback,\r\n disableComponents: this.disableComponents,\r\n enableComponents: this.enableComponents,\r\n components: {},\r\n },\r\n };\r\n }\r\n\r\n public disableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.disableComponent &&\r\n component.componentApi.disableComponent();\r\n });\r\n }\r\n\r\n public enableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.enableComponent &&\r\n component.componentApi.enableComponent();\r\n });\r\n }\r\n\r\n public touchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.touch &&\r\n component.componentApi.touch();\r\n });\r\n }\r\n\r\n public unTouchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.unTouch &&\r\n component.componentApi.unTouch();\r\n });\r\n }\r\n\r\n public render() {\r\n return (\r\n <this.props.component\r\n {...(this.props.id && { id: this.props.id })}\r\n noValidate={true}\r\n role=\"form\"\r\n className={`input__form validation-form ${\r\n this.props.className ? this.props.className : ''\r\n }`}\r\n onSubmit={this.onSubmit}\r\n >\r\n <FormContextProvider value={this.mergeContext()}>\r\n {this.props.children}\r\n </FormContextProvider>\r\n </this.props.component>\r\n );\r\n }\r\n\r\n private mergeContext(): FormContextState {\r\n if (!this.props.extraComponents) {\r\n return this.state.contextState;\r\n }\r\n const isFormValid =\r\n this.state.contextState.isFormValid &&\r\n this.getIsFormValid(this.props.extraComponents);\r\n return {\r\n ...this.state.contextState,\r\n components: {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n },\r\n isFormValid,\r\n };\r\n }\r\n\r\n private onSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n this.props.onSubmit && this.props.onSubmit();\r\n };\r\n\r\n private subscribe(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n if (componentState) {\r\n components[componentId] = componentState;\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private unSubscribe(componentId: string) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n delete components[componentId];\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private getIsFormValid(\r\n components: ComponentsDict = this.state.contextState.components,\r\n initialValid: boolean = true\r\n ): boolean {\r\n let isFormValid = initialValid;\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n if (component && component.validation && !component.validation.isValid) {\r\n isFormValid = false;\r\n }\r\n });\r\n return isFormValid;\r\n }\r\n\r\n private updateCallback(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n this.setState(previousState => {\r\n let components = Object.assign({}, previousState.contextState.components);\r\n const previousComponent = components[componentId];\r\n if (componentState && previousComponent) {\r\n components[componentId] = {\r\n ...previousComponent,\r\n ...componentState,\r\n validation: {\r\n ...previousComponent.validation,\r\n ...componentState.validation,\r\n },\r\n };\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...this.state.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n}\r\n\r\nexport default withThemeContext<FormProps, InstanceType<typeof Form>>(\r\n Form,\r\n 'form'\r\n);\r\n"],"file":"Form.js"}
|
@@ -174,7 +174,7 @@ var SelectRaw = /*#__PURE__*/function (_BaseInput) {
|
|
174
174
|
|
175
175
|
if (!this.props.multiple) {
|
176
176
|
return _get(_getPrototypeOf(SelectRaw.prototype), "handleValueChange", this).call(this, value, isValid, errors, props, initializing);
|
177
|
-
} else {
|
177
|
+
} else if (!initializing) {
|
178
178
|
this.handleValid(this.props.selectedValues);
|
179
179
|
}
|
180
180
|
|
@@ -275,8 +275,10 @@ var SelectRaw = /*#__PURE__*/function (_BaseInput) {
|
|
275
275
|
|
276
276
|
if (this.props.customValidators) {
|
277
277
|
this.props.customValidators.forEach(function (customValidator) {
|
278
|
+
var _this3$state;
|
279
|
+
|
278
280
|
var validInner = false;
|
279
|
-
validInner = customValidator.Validate(_this3.state.value, _this3.props.required, function (error) {
|
281
|
+
validInner = customValidator.Validate((_this3$state = _this3.state) === null || _this3$state === void 0 ? void 0 : _this3$state.value, _this3.props.required, function (error) {
|
280
282
|
return errors.push(error);
|
281
283
|
});
|
282
284
|
|
@@ -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","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;;AAEA;;AAOA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAVYA,Q,YAAAA,Q;;;;;;AAAAA,Q;;;;;;;IA+BCC,S;;;;;AAYX,qBAAYC,KAAZ,EAAgC;AAAA;;AAAA;;AAC9B,8BAAMA,KAAN;;AAD8B,sEA2QN,UAACC,IAAD;AAAA,aAAuB,YAAM;AACrD,YAAMC,SAAS,GAAG,MAAKF,KAAL,CAAWG,cAAX,CAA0BC,MAA1B,CAChB,UAAAC,EAAE;AAAA,iBAAIA,EAAE,CAACC,KAAH,KAAaL,IAAI,CAACK,KAAtB;AAAA,SADc,CAAlB;;AAGA,cAAKC,WAAL,CAAiBL,SAAjB;;AACA,cAAKF,KAAL,CAAWQ,sBAAX,IACE,MAAKR,KAAL,CAAWQ,sBAAX,CAAkCN,SAAlC,CADF;AAED,OAPyB;AAAA,KA3QM;;AAE9B,QAAMO,GAAG,GAAG,CAACT,KAAK,CAACM,KAAP,GACRN,KAAK,CAACU,YAAN,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9B,CADH,CADF,GAoBE,KAAKD,KAAL,CAAW+B,QAAX,iBACE;AAAK,QAAA,SAAS,EAAC;AAAf,sBACE;AAAK,QAAA,SAAS,EAAC;AAAf,SACG,KAAK/B,KAAL,CAAW4E,wBADd,CADF,CAtBC,GA6BH,IA7BJ;AA8BD;;;;EArR4BC,qB;;;;gBAAlB9E,S,kBAKkBe,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkB8D,sBAAUC,YAA5B,EAA0C;AACrEpE,EAAAA,YAAY,EAAE,IADuD;AAErEQ,EAAAA,QAAQ,EAAE,KAF2D;AAGrEa,EAAAA,QAAQ,EAAE,KAH2D;AAIrE6C,EAAAA,wBAAwB,EAAE;AAJ2C,CAA1C,C;;AA4RxB,IAAMG,MAAM,GAAG,wCAGpB,sCAA6BhF,SAA7B,CAHoB,EAGqB,QAHrB,CAAf;;eAKQgF,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 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"}
|
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;;AAEA;;AAOA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAVYA,Q,YAAAA,Q;;;;;;AAAAA,Q;;;;;;;IA+BCC,S;;;;;AAYX,qBAAYC,KAAZ,EAAgC;AAAA;;AAAA;;AAC9B,8BAAMA,KAAN;;AAD8B,sEA2QN,UAACC,IAAD;AAAA,aAAuB,YAAM;AACrD,YAAMC,SAAS,GAAG,MAAKF,KAAL,CAAWG,cAAX,CAA0BC,MAA1B,CAChB,UAAAC,EAAE;AAAA,iBAAIA,EAAE,CAACC,KAAH,KAAaL,IAAI,CAACK,KAAtB;AAAA,SADc,CAAlB;;AAGA,cAAKC,WAAL,CAAiBL,SAAjB;;AACA,cAAKF,KAAL,CAAWQ,sBAAX,IACE,MAAKR,KAAL,CAAWQ,sBAAX,CAAkCN,SAAlC,CADF;AAED,OAPyB;AAAA,KA3QM;;AAE9B,QAAMO,GAAG,GAAG,CAACT,KAAK,CAACM,KAAP,GACRN,KAAK,CAACU,YAAN,GACE,EADF,GAEEV,KAAK,CAACW,MAAN,IAAgBX,KAAK,CAACW,MAAN,CAAaC,MAAb,GAAsB,CAAtC,GACAZ,KAAK,CAACW,MAAN,CAAa,CAAb,CADA,GAEA,EALM,GAMRX,KAAK,CAACM,KANV;AAOA,UAAKO,KAAL,GAAaC,MAAM,CAACC,MAAP,CAAc,MAAKF,KAAnB,EAA0B;AAAEP,MAAAA,KAAK,EAAEG;AAAT,KAA1B,CAAb;AACA,UAAKO,kBAAL,GAA0B,MAAKA,kBAAL,CAAwBC,IAAxB,+BAA1B;AAV8B;AAW/B;;;;WAED,6BAA2B;AACzB,WAAKjB,KAAL,CAAW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rEa,EAAAA,QAAQ,EAAE,KAH2D;AAIrE6C,EAAAA,wBAAwB,EAAE;AAJ2C,CAA1C,C;;AA4RxB,IAAMG,MAAM,GAAG,wCAGpB,sCAA6BhF,SAA7B,CAHoB,EAGqB,QAHrB,CAAf;;eAKQgF,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 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 if (!initializing) {\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"}
|
package/build/dist/report.html
CHANGED
@@ -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
|
+
<title>guestbell-forms [12 Sep 2022 at 15:42]</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/DA2u631Ouy0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