guestbell-forms 2.0.270 → 2.0.274

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/components/money/Money.tsx"],"names":["PlusIcon","defaultMoneyTranslations","defaultBaseTranslations","cannotRemoveDefaultCurrency","removePrice","addPrice","addNewCurrency","MoneyRaw","props","index","currentCurrencies","e","newPrices","concat","prices","currency","filter","cc","value","toString","target","onPricesChange","num","Number","parts","split","length","isNaN","str","state","touched","touch","price","itemIndex","required","setInvalid","getTranslations","unusedCurrencies","setValid","setState","focused","currencies","Error","Object","assign","isValid","errors","handleValueChangeEnabled","forcedCurrencies","c","forceSelected","missingForced","find","p","map","undefined","subscribeSelf","translations","title","id","getValidationClass","className","containerRef","item","priceCurrency","priceIndex","retComponents","onFocus","onBlur","onCurrencyChanged","onTheFlightValidate","onPriceChanged","removePriceClick","Button","defaultProps","buttonProps","allowMultiple","addPriceClick","renderDefaultValidation","label","renderLabel","BaseInput","type","onChange","Money"],"mappings":";;;;;;;;;AAGA;;AAGA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAjBaA,Q,YAAAA,Q;;;;;;AAAAA,Q;;;;;GAEb;;AAsBO,IAAMC,wBAAwB,mCAChCC,mCADgC;AAEnCC,EAAAA,2BAA2B,EAAE,gCAFM;AAGnCC,EAAAA,WAAW,EAAE,cAHsB;AAInCC,EAAAA,QAAQ,EAAE,WAJyB;AAKnCC,EAAAA,cAAc,EAAE;AALmB,EAA9B;;;;IAoBMC,Q;;;;;AAYX,oBAAYC,KAAZ,EAA+B;AAAA;;AAAA;;AAC7B,8BAAMA,KAAN,EAAa,KAAb;;AAD6B,wEAwJH,UAC1BC,KAD0B,EAE1BC,iBAF0B;AAAA,aAGvB,UAAAC,CAAC,EAAI;AACR,YAAIC,SAA8B,GAAG,GAAGC,MAAH,CAAU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Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport { Select, SelectValue } from '../select/Select';\r\nimport { Text } from '../text/Text';\r\nimport InputGroup from '../inputGroup/InputGroup';\r\nimport {\r\n BaseInputProps,\r\n BaseInputState,\r\n BaseInput,\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 MoneyWithCurrency {\r\n value: number;\r\n currency: SelectValue;\r\n}\r\n\r\nexport const defaultMoneyTranslations = {\r\n ...defaultBaseTranslations,\r\n cannotRemoveDefaultCurrency: 'Cannot remove default currency',\r\n removePrice: 'Remove price',\r\n addPrice: 'Add price',\r\n addNewCurrency: 'Add new currency',\r\n};\r\n\r\nexport type MoneyTranslations = Partial<typeof defaultMoneyTranslations>;\r\n\r\nexport interface MoneyProps extends BaseInputProps<never, MoneyTranslations> {\r\n onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;\r\n onPricesChange: (prices: MoneyWithCurrency[]) => void;\r\n allowMultiple?: boolean;\r\n currencies: SelectValue[];\r\n prices: MoneyWithCurrency[];\r\n}\r\n\r\nexport interface MoneyState extends BaseInputState {}\r\n\r\nexport class MoneyRaw extends BaseInput<\r\n MoneyProps,\r\n MoneyState,\r\n never,\r\n MoneyTranslations\r\n> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n type: 'money',\r\n allowMultiple: false,\r\n onChange: undefined,\r\n });\r\n\r\n constructor(props: MoneyProps) {\r\n super(props, false);\r\n if (!props.currencies || !props.currencies.length) {\r\n throw Error('No currencies supplied to money input');\r\n }\r\n this.state = Object.assign(this.state, {\r\n isValid: props.required ? props.prices.length > 0 : true,\r\n errors:\r\n props.required && props.prices.length === 0\r\n ? [this.getTranslations(defaultMoneyTranslations).required]\r\n : [],\r\n handleValueChangeEnabled: false,\r\n });\r\n const forcedCurrencies = props.currencies.filter(c => c.forceSelected);\r\n const missingForced = forcedCurrencies.filter(\r\n c => !props.prices.find(p => p.currency.value === c.value)\r\n );\r\n if (missingForced.length > 0) {\r\n props.onPricesChange(\r\n props.prices.concat(\r\n missingForced.map(c => ({ currency: c, value: undefined }))\r\n )\r\n );\r\n }\r\n this.subscribeSelf(props);\r\n }\r\n\r\n public render() {\r\n let unusedCurrencies = this.props.currencies;\r\n const translations = this.getTranslations(defaultMoneyTranslations);\r\n return (\r\n <InputGroup title={this.props.title}>\r\n <div\r\n {...(this.props.id && { id: this.props.id })}\r\n className={\r\n 'input__base money-input ' +\r\n this.getValidationClass() +\r\n (this.props.className ? ' ' + this.props.className : '')\r\n }\r\n ref={this.containerRef}\r\n >\r\n {this.props.prices &&\r\n this.props.prices.map((item, index) => {\r\n let currentCurrencies = this.props.currencies.filter(\r\n c =>\r\n this.props.prices.filter(\r\n (priceCurrency, priceIndex) =>\r\n priceIndex !== index &&\r\n priceCurrency.currency.value === c.value\r\n ).length === 0\r\n );\r\n const currency = this.props.currencies.find(\r\n c => c.value === item.currency.value\r\n );\r\n let retComponents = currentCurrencies.length ? (\r\n <div key={index}>\r\n <Select\r\n {...(this.props.id && {\r\n id:\r\n this.props.id + '-currency-select-' + index.toString(),\r\n })}\r\n onFocus={this.onFocus}\r\n onBlur={this.onBlur}\r\n className={'money-input__select m-0'}\r\n values={currentCurrencies}\r\n onChange={this.onCurrencyChanged(index, currentCurrencies)}\r\n value={item.currency.value.toString()}\r\n />\r\n <Text\r\n {...(this.props.id && {\r\n id: this.props.id + '-amount-input-' + index.toString(),\r\n })}\r\n onFocus={this.onFocus}\r\n onBlur={this.onBlur}\r\n onTheFlightValidate={this.onTheFlightValidate}\r\n placeholder={'0.00'}\r\n className={'money-input__text m-0'}\r\n validators={['number']}\r\n value={item.value ? item.value.toString() : ''}\r\n onChange={this.onPriceChanged(index)}\r\n type=\"number\"\r\n />\r\n {this.props.prices.length > 0 && (\r\n <Button\r\n {...(this.props.id && {\r\n id:\r\n this.props.id + '-remove-button-' + index.toString(),\r\n })}\r\n blank={true}\r\n type=\"error\"\r\n onClick={this.removePriceClick(index)}\r\n className=\"transform-rotate--45 line-height--0\"\r\n buttonProps={{\r\n ...Button.defaultProps?.buttonProps,\r\n title:\r\n currency && currency.forceSelected\r\n ? translations.cannotRemoveDefaultCurrency\r\n : translations.removePrice,\r\n }}\r\n circular={true}\r\n disabled={currency && currency.forceSelected}\r\n >\r\n <PlusIcon />\r\n </Button>\r\n )}\r\n </div>\r\n ) : null;\r\n unusedCurrencies = unusedCurrencies.filter(\r\n c => c.value !== item.currency.value\r\n );\r\n return retComponents;\r\n })}\r\n {(this.props.allowMultiple ||\r\n (this.props.prices && !this.props.prices.length)) &&\r\n unusedCurrencies.length ? (\r\n <Button\r\n blank={true}\r\n {...(this.props.id && {\r\n id: this.props.id + '-add-button',\r\n })}\r\n type=\"primary\"\r\n className=\"line-height--0 align-self-start\"\r\n onClick={this.addPriceClick(unusedCurrencies)}\r\n circular={true}\r\n buttonProps={{\r\n ...Button.defaultProps?.buttonProps,\r\n title:\r\n this.props.prices && this.props.prices.length === 0\r\n ? translations.addPrice\r\n : translations.addNewCurrency,\r\n }}\r\n >\r\n <PlusIcon />\r\n </Button>\r\n ) : null}\r\n <span className=\"highlight\" />\r\n <span className={'bar ' + (this.state.focused ? 'focused' : '')} />\r\n {this.renderDefaultValidation()}\r\n {this.props.label && (\r\n <label\r\n className={\r\n this.props.prices && this.props.prices ? 'label--focused' : ''\r\n }\r\n >\r\n {this.renderLabel()}\r\n </label>\r\n )}\r\n </div>\r\n </InputGroup>\r\n );\r\n }\r\n\r\n private onCurrencyChanged = (\r\n index: number,\r\n currentCurrencies: SelectValue[]\r\n ) => e => {\r\n let newPrices: MoneyWithCurrency[] = [].concat(this.props.prices);\r\n newPrices[index].currency = currentCurrencies.filter(\r\n cc => cc.value.toString() === e.target.value\r\n )[0];\r\n this.props.onPricesChange(newPrices);\r\n };\r\n\r\n private onTheFlightValidate = value => {\r\n let num = Number(value);\r\n const parts = value.split('.');\r\n if (parts && parts.length > 1 && parts[parts.length - 1].length > 2) {\r\n return false;\r\n }\r\n if (!isNaN(num)) {\r\n return true;\r\n }\r\n if (num) {\r\n return false;\r\n }\r\n };\r\n\r\n private onPriceChanged = (index: number) => (\r\n e: React.ChangeEvent<HTMLInputElement>\r\n ) => {\r\n let newPrices: MoneyWithCurrency[] = [].concat(this.props.prices);\r\n let str = e.target.value;\r\n let num = Number(str);\r\n if (!isNaN(num)) {\r\n newPrices[index].value = num;\r\n }\r\n this.props.onPricesChange(newPrices);\r\n if (!this.state.touched) {\r\n this.touch();\r\n }\r\n };\r\n\r\n private removePriceClick = (index: number) => () => {\r\n const newPrices = this.props.prices.filter(\r\n (price, itemIndex) => itemIndex !== index\r\n );\r\n this.props.onPricesChange(newPrices);\r\n if (newPrices.length === 0 && this.props.required) {\r\n this.setInvalid([\r\n this.getTranslations(defaultMoneyTranslations).required,\r\n ]);\r\n }\r\n if (!this.state.touched) {\r\n this.touch();\r\n }\r\n };\r\n\r\n private addPriceClick = (unusedCurrencies: SelectValue[]) => () => {\r\n this.props.onPricesChange(\r\n this.props.prices.concat([{ value: 0, currency: unusedCurrencies[0] }])\r\n );\r\n this.setValid();\r\n if (!this.state.touched) {\r\n this.touch();\r\n }\r\n };\r\n\r\n private onFocus = () => this.setState({ focused: true });\r\n\r\n private onBlur = () => this.setState({ focused: false });\r\n}\r\n\r\nexport const Money = withThemeContext<\r\n MoneyProps,\r\n InstanceType<typeof MoneyRaw>\r\n>(withFormContext<MoneyProps>(MoneyRaw), 'money');\r\n\r\nexport default Money;\r\n"],"file":"Money.js"}
1
+ {"version":3,"sources":["../../../src/lib/components/money/Money.tsx"],"names":["PlusIcon","defaultMoneyTranslations","defaultBaseTranslations","cannotRemoveDefaultCurrency","removePrice","addPrice","addNewCurrency","MoneyRaw","props","index","currentCurrencies","e","newPrices","concat","prices","currency","filter","cc","value","toString","target","onPricesChange","num","Number","parts","split","length","isNaN","str","state","touched","touch","price","itemIndex","required","setInvalid","getTranslations","unusedCurrencies","setValid","setState","focused","currencies","Error","Object","assign","isValid","errors","handleValueChangeEnabled","forcedCurrencies","c","forceSelected","missingForced","find","p","map","undefined","subscribeSelf","translations","title","id","getValidationClass","className","containerRef","item","priceCurrency","priceIndex","retComponents","onFocus","onBlur","onCurrencyChanged","label","onTheFlightValidate","onPriceChanged","disableDelete","removePriceClick","Button","defaultProps","buttonProps","allowMultiple","addPriceClick","renderDefaultValidation","renderLabel","BaseInput","type","onChange","Money"],"mappings":";;;;;;;;;AAGA;;AAGA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAjBaA,Q,YAAAA,Q;;;;;;AAAAA,Q;;;;;GAEb;;AAsBO,IAAMC,wBAAwB,mCAChCC,mCADgC;AAEnCC,EAAAA,2BAA2B,EAAE,gCAFM;AAGnCC,EAAAA,WAAW,EAAE,cAHsB;AAInCC,EAAAA,QAAQ,EAAE,WAJyB;AAKnCC,EAAAA,cAAc,EAAE;AALmB,EAA9B;;;;IAqBMC,Q;;;;;AAYX,oBAAYC,KAAZ,EAA+B;AAAA;;AAAA;;AAC7B,8BAAMA,KAAN,EAAa,KAAb;;AAD6B,wEAiKH,UAC1BC,KAD0B,EAE1BC,iBAF0B;AAAA,aAGvB,UAAAC,CAAC,EAAI;AACR,YAAIC,SAA8B,GAAG,GAAGC,MAAH,CAAU,MAAKL,KAAL,CAAWM,MAArB,CAArC;AACAF,QAAAA,SAAS,CAACH,KAAD,CAAT,CAAiBM,QAAjB,GAA4BL,iBAAiB,CAACM,MAAlB,CAC1B,UAAAC,EAAE;AAAA,iBAAIA,EAAE,CAACC,KAAH,CAASC,QAAT,OAAwBR,CAAC,CAACS,MAAF,CAASF,KAArC;AAAA,SADwB,EAE1B,CAF0B,CAA5B;;AAGA,cAAKV,KAAL,CAAWa,cAAX,CAA0BT,SAA1B;AACD,OAT2B;AAAA,KAjKG;;AAAA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QAAA,QAAQ,EAAE,IARZ;AASE,QAAA,WAAW,2DACNsC,eAAOC,YADD,0DACN,sBAAqBC,WADf;AAETnB,UAAAA,KAAK,EACH,KAAKlD,KAAL,CAAWM,MAAX,IAAqB,KAAKN,KAAL,CAAWM,MAAX,CAAkBY,MAAlB,KAA6B,CAAlD,GACI+B,YAAY,CAACpD,QADjB,GAEIoD,YAAY,CAACnD;AALV;AATb,uBAiBE,oBAAC,QAAD,OAjBF,CAHD,GAsBG,IA/GN,eAgHE;AAAM,QAAA,SAAS,EAAC;AAAhB,QAhHF,eAiHE;AAAM,QAAA,SAAS,EAAE,UAAU,KAAKuB,KAAL,CAAWW,OAAX,GAAqB,SAArB,GAAiC,EAA3C;AAAjB,QAjHF,EAkHG,KAAKwC,uBAAL,EAlHH,EAmHG,KAAKxE,KAAL,CAAW8D,KAAX,iBACC;AACE,QAAA,SAAS,EACP,KAAK9D,KAAL,CAAWM,MAAX,IAAqB,KAAKN,KAAL,CAAWM,MAAhC,GAAyC,gBAAzC,GAA4D;AAFhE,SAKG,KAAKmE,WAAL,EALH,CApHJ,CADF,CADF;AAiID;;;;EA3K2BC,qB;;;;gBAAjB3E,Q,kBAMkBoC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBsC,sBAAUN,YAA5B,EAA0C;AACrEO,EAAAA,IAAI,EAAE,OAD+D;AAErEL,EAAAA,aAAa,EAAE,KAFsD;AAGrEM,EAAAA,QAAQ,EAAE7B;AAH2D,CAA1C,C;;AA6OxB,IAAM8B,KAAK,GAAG,wCAGnB,sCAA4B9E,QAA5B,CAHmB,EAGoB,OAHpB,CAAd;;eAKQ8E,K","sourcesContent":["import * as PlusIcon from 'material-design-icons/content/svg/production/ic_add_24px.svg';\r\n\r\n// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport { Select, SelectValue } from '../select/Select';\r\nimport { Text } from '../text/Text';\r\nimport InputGroup from '../inputGroup/InputGroup';\r\nimport {\r\n BaseInputProps,\r\n BaseInputState,\r\n BaseInput,\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 MoneyWithCurrency {\r\n value: number;\r\n currency: SelectValue;\r\n}\r\n\r\nexport const defaultMoneyTranslations = {\r\n ...defaultBaseTranslations,\r\n cannotRemoveDefaultCurrency: 'Cannot remove default currency',\r\n removePrice: 'Remove price',\r\n addPrice: 'Add price',\r\n addNewCurrency: 'Add new currency',\r\n};\r\n\r\nexport type MoneyTranslations = Partial<typeof defaultMoneyTranslations>;\r\n\r\nexport interface MoneyProps extends BaseInputProps<never, MoneyTranslations> {\r\n onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;\r\n onPricesChange: (prices: MoneyWithCurrency[]) => void;\r\n allowMultiple?: boolean;\r\n currencies: SelectValue[];\r\n prices: MoneyWithCurrency[];\r\n disableDelete?: boolean;\r\n}\r\n\r\nexport interface MoneyState extends BaseInputState {}\r\n\r\nexport class MoneyRaw extends BaseInput<\r\n MoneyProps,\r\n MoneyState,\r\n never,\r\n MoneyTranslations\r\n> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n type: 'money',\r\n allowMultiple: false,\r\n onChange: undefined,\r\n });\r\n\r\n constructor(props: MoneyProps) {\r\n super(props, false);\r\n if (!props.currencies || !props.currencies.length) {\r\n throw Error('No currencies supplied to money input');\r\n }\r\n this.state = Object.assign(this.state, {\r\n isValid: props.required ? props.prices.length > 0 : true,\r\n errors:\r\n props.required && props.prices.length === 0\r\n ? [this.getTranslations(defaultMoneyTranslations).required]\r\n : [],\r\n handleValueChangeEnabled: false,\r\n });\r\n const forcedCurrencies = props.currencies.filter(c => c.forceSelected);\r\n const missingForced = forcedCurrencies.filter(\r\n c => !props.prices.find(p => p.currency.value === c.value)\r\n );\r\n if (missingForced.length > 0) {\r\n props.onPricesChange(\r\n props.prices.concat(\r\n missingForced.map(c => ({ currency: c, value: undefined }))\r\n )\r\n );\r\n }\r\n this.subscribeSelf(props);\r\n }\r\n\r\n public render() {\r\n let unusedCurrencies = this.props.currencies;\r\n const translations = this.getTranslations(defaultMoneyTranslations);\r\n return (\r\n <InputGroup title={this.props.title}>\r\n <div\r\n {...(this.props.id && { id: this.props.id })}\r\n className={\r\n 'input__base money-input ' +\r\n this.getValidationClass() +\r\n (this.props.className ? ' ' + this.props.className : '')\r\n }\r\n ref={this.containerRef}\r\n >\r\n {this.props.prices &&\r\n this.props.prices.map((item, index) => {\r\n let currentCurrencies = this.props.currencies.filter(\r\n c =>\r\n this.props.prices.filter(\r\n (priceCurrency, priceIndex) =>\r\n priceIndex !== index &&\r\n priceCurrency.currency.value === c.value\r\n ).length === 0\r\n );\r\n const currency = this.props.currencies.find(\r\n c => c.value === item.currency.value\r\n );\r\n let retComponents = currentCurrencies.length ? (\r\n <div key={index}>\r\n {currentCurrencies.length > 1 ? (\r\n <Select\r\n {...(this.props.id && {\r\n id:\r\n this.props.id +\r\n '-currency-select-' +\r\n index.toString(),\r\n })}\r\n onFocus={this.onFocus}\r\n onBlur={this.onBlur}\r\n className={'money-input__select m-0'}\r\n values={currentCurrencies}\r\n onChange={this.onCurrencyChanged(\r\n index,\r\n currentCurrencies\r\n )}\r\n value={item.currency.value.toString()}\r\n />\r\n ) : (\r\n currentCurrencies?.[0]?.label\r\n )}\r\n <Text\r\n {...(this.props.id && {\r\n id: this.props.id + '-amount-input-' + index.toString(),\r\n })}\r\n onFocus={this.onFocus}\r\n onBlur={this.onBlur}\r\n onTheFlightValidate={this.onTheFlightValidate}\r\n placeholder={'0.00'}\r\n className={'money-input__text m-0'}\r\n validators={['number']}\r\n value={item.value ? item.value.toString() : ''}\r\n onChange={this.onPriceChanged(index)}\r\n type=\"number\"\r\n />\r\n {!this.props.disableDelete && this.props.prices.length > 0 && (\r\n <Button\r\n {...(this.props.id && {\r\n id:\r\n this.props.id + '-remove-button-' + index.toString(),\r\n })}\r\n blank={true}\r\n type=\"error\"\r\n onClick={this.removePriceClick(index)}\r\n className=\"transform-rotate--45 line-height--0\"\r\n buttonProps={{\r\n ...Button.defaultProps?.buttonProps,\r\n title:\r\n currency && currency.forceSelected\r\n ? translations.cannotRemoveDefaultCurrency\r\n : translations.removePrice,\r\n }}\r\n circular={true}\r\n disabled={currency && currency.forceSelected}\r\n >\r\n <PlusIcon />\r\n </Button>\r\n )}\r\n </div>\r\n ) : null;\r\n unusedCurrencies = unusedCurrencies.filter(\r\n c => c.value !== item.currency.value\r\n );\r\n return retComponents;\r\n })}\r\n {(this.props.allowMultiple ||\r\n (this.props.prices && !this.props.prices.length)) &&\r\n unusedCurrencies.length ? (\r\n <Button\r\n blank={true}\r\n {...(this.props.id && {\r\n id: this.props.id + '-add-button',\r\n })}\r\n type=\"primary\"\r\n className=\"line-height--0 align-self-start\"\r\n onClick={this.addPriceClick(unusedCurrencies)}\r\n circular={true}\r\n buttonProps={{\r\n ...Button.defaultProps?.buttonProps,\r\n title:\r\n this.props.prices && this.props.prices.length === 0\r\n ? translations.addPrice\r\n : translations.addNewCurrency,\r\n }}\r\n >\r\n <PlusIcon />\r\n </Button>\r\n ) : null}\r\n <span className=\"highlight\" />\r\n <span className={'bar ' + (this.state.focused ? 'focused' : '')} />\r\n {this.renderDefaultValidation()}\r\n {this.props.label && (\r\n <label\r\n className={\r\n this.props.prices && this.props.prices ? 'label--focused' : ''\r\n }\r\n >\r\n {this.renderLabel()}\r\n </label>\r\n )}\r\n </div>\r\n </InputGroup>\r\n );\r\n }\r\n\r\n private onCurrencyChanged = (\r\n index: number,\r\n currentCurrencies: SelectValue[]\r\n ) => e => {\r\n let newPrices: MoneyWithCurrency[] = [].concat(this.props.prices);\r\n newPrices[index].currency = currentCurrencies.filter(\r\n cc => cc.value.toString() === e.target.value\r\n )[0];\r\n this.props.onPricesChange(newPrices);\r\n };\r\n\r\n private onTheFlightValidate = value => {\r\n let num = Number(value);\r\n const parts = value.split('.');\r\n if (parts && parts.length > 1 && parts[parts.length - 1].length > 2) {\r\n return false;\r\n }\r\n if (!isNaN(num)) {\r\n return true;\r\n }\r\n if (num) {\r\n return false;\r\n }\r\n };\r\n\r\n private onPriceChanged = (index: number) => (\r\n e: React.ChangeEvent<HTMLInputElement>\r\n ) => {\r\n let newPrices: MoneyWithCurrency[] = [].concat(this.props.prices);\r\n let str = e.target.value;\r\n let num = Number(str);\r\n if (!isNaN(num)) {\r\n newPrices[index].value = num;\r\n }\r\n this.props.onPricesChange(newPrices);\r\n if (!this.state.touched) {\r\n this.touch();\r\n }\r\n };\r\n\r\n private removePriceClick = (index: number) => () => {\r\n const newPrices = this.props.prices.filter(\r\n (price, itemIndex) => itemIndex !== index\r\n );\r\n this.props.onPricesChange(newPrices);\r\n if (newPrices.length === 0 && this.props.required) {\r\n this.setInvalid([\r\n this.getTranslations(defaultMoneyTranslations).required,\r\n ]);\r\n }\r\n if (!this.state.touched) {\r\n this.touch();\r\n }\r\n };\r\n\r\n private addPriceClick = (unusedCurrencies: SelectValue[]) => () => {\r\n this.props.onPricesChange(\r\n this.props.prices.concat([{ value: 0, currency: unusedCurrencies[0] }])\r\n );\r\n this.setValid();\r\n if (!this.state.touched) {\r\n this.touch();\r\n }\r\n };\r\n\r\n private onFocus = () => this.setState({ focused: true });\r\n\r\n private onBlur = () => this.setState({ focused: false });\r\n}\r\n\r\nexport const Money = withThemeContext<\r\n MoneyProps,\r\n InstanceType<typeof MoneyRaw>\r\n>(withFormContext<MoneyProps>(MoneyRaw), 'money');\r\n\r\nexport default Money;\r\n"],"file":"Money.js"}
@@ -1010,17 +1010,18 @@
1010
1010
  background-color: #10bdc7;
1011
1011
  fill: white;
1012
1012
  color: white; }
1013
- .guestbell-btn.guestbell-btn-primary:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):hover {
1013
+ .guestbell-btn.guestbell-btn-primary:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):not(.guestbell-btn--outlined):hover {
1014
1014
  background-color: #0d9ea6; }
1015
1015
  .guestbell-btn.guestbell-btn-primary:not(.guestbell-btn--disabled).guestbell-btn--outlined {
1016
1016
  box-shadow: inset 0 0 0 1px #10bdc7 !important;
1017
1017
  color: #10bdc7;
1018
1018
  fill: #10bdc7;
1019
1019
  background-color: transparent; }
1020
- .guestbell-btn.guestbell-btn-primary:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1021
- color: white;
1022
- fill: white;
1023
- background-color: #10bdc7; }
1020
+ @media (hover: hover) and (pointer: fine) {
1021
+ .guestbell-btn.guestbell-btn-primary:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1022
+ color: white;
1023
+ fill: white;
1024
+ background-color: #10bdc7; } }
1024
1025
  .guestbell-btn.guestbell-btn-primary:not(.guestbell-btn--disabled).guestbell-btn--blank {
1025
1026
  color: #10bdc7;
1026
1027
  fill: #10bdc7;
@@ -1055,17 +1056,18 @@
1055
1056
  background-color: #5cb85c;
1056
1057
  fill: white;
1057
1058
  color: white; }
1058
- .guestbell-btn.guestbell-btn-success:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):hover {
1059
+ .guestbell-btn.guestbell-btn-success:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):not(.guestbell-btn--outlined):hover {
1059
1060
  background-color: #49a749; }
1060
1061
  .guestbell-btn.guestbell-btn-success:not(.guestbell-btn--disabled).guestbell-btn--outlined {
1061
1062
  box-shadow: inset 0 0 0 1px #5cb85c !important;
1062
1063
  color: #5cb85c;
1063
1064
  fill: #5cb85c;
1064
1065
  background-color: transparent; }
1065
- .guestbell-btn.guestbell-btn-success:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1066
- color: white;
1067
- fill: white;
1068
- background-color: #5cb85c; }
1066
+ @media (hover: hover) and (pointer: fine) {
1067
+ .guestbell-btn.guestbell-btn-success:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1068
+ color: white;
1069
+ fill: white;
1070
+ background-color: #5cb85c; } }
1069
1071
  .guestbell-btn.guestbell-btn-success:not(.guestbell-btn--disabled).guestbell-btn--blank {
1070
1072
  color: #5cb85c;
1071
1073
  fill: #5cb85c;
@@ -1100,17 +1102,18 @@
1100
1102
  background-color: white;
1101
1103
  fill: #555555;
1102
1104
  color: #555555; }
1103
- .guestbell-btn.guestbell-btn-white:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):hover {
1105
+ .guestbell-btn.guestbell-btn-white:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):not(.guestbell-btn--outlined):hover {
1104
1106
  background-color: #ededed; }
1105
1107
  .guestbell-btn.guestbell-btn-white:not(.guestbell-btn--disabled).guestbell-btn--outlined {
1106
1108
  box-shadow: inset 0 0 0 1px white !important;
1107
1109
  color: white;
1108
1110
  fill: white;
1109
1111
  background-color: transparent; }
1110
- .guestbell-btn.guestbell-btn-white:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1111
- color: #555555;
1112
- fill: #555555;
1113
- background-color: white; }
1112
+ @media (hover: hover) and (pointer: fine) {
1113
+ .guestbell-btn.guestbell-btn-white:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1114
+ color: #555555;
1115
+ fill: #555555;
1116
+ background-color: white; } }
1114
1117
  .guestbell-btn.guestbell-btn-white:not(.guestbell-btn--disabled).guestbell-btn--blank {
1115
1118
  color: white;
1116
1119
  fill: white;
@@ -1145,17 +1148,18 @@
1145
1148
  background-color: #a8dadc;
1146
1149
  fill: white;
1147
1150
  color: white; }
1148
- .guestbell-btn.guestbell-btn-info:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):hover {
1151
+ .guestbell-btn.guestbell-btn-info:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):not(.guestbell-btn--outlined):hover {
1149
1152
  background-color: #8fcfd2; }
1150
1153
  .guestbell-btn.guestbell-btn-info:not(.guestbell-btn--disabled).guestbell-btn--outlined {
1151
1154
  box-shadow: inset 0 0 0 1px #a8dadc !important;
1152
1155
  color: #a8dadc;
1153
1156
  fill: #a8dadc;
1154
1157
  background-color: transparent; }
1155
- .guestbell-btn.guestbell-btn-info:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1156
- color: white;
1157
- fill: white;
1158
- background-color: #a8dadc; }
1158
+ @media (hover: hover) and (pointer: fine) {
1159
+ .guestbell-btn.guestbell-btn-info:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1160
+ color: white;
1161
+ fill: white;
1162
+ background-color: #a8dadc; } }
1159
1163
  .guestbell-btn.guestbell-btn-info:not(.guestbell-btn--disabled).guestbell-btn--blank {
1160
1164
  color: #a8dadc;
1161
1165
  fill: #a8dadc;
@@ -1190,17 +1194,18 @@
1190
1194
  background-color: #d9534f;
1191
1195
  fill: white;
1192
1196
  color: white; }
1193
- .guestbell-btn.guestbell-btn-error:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):hover {
1197
+ .guestbell-btn.guestbell-btn-error:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):not(.guestbell-btn--outlined):hover {
1194
1198
  background-color: #d33632; }
1195
1199
  .guestbell-btn.guestbell-btn-error:not(.guestbell-btn--disabled).guestbell-btn--outlined {
1196
1200
  box-shadow: inset 0 0 0 1px #d9534f !important;
1197
1201
  color: #d9534f;
1198
1202
  fill: #d9534f;
1199
1203
  background-color: transparent; }
1200
- .guestbell-btn.guestbell-btn-error:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1201
- color: white;
1202
- fill: white;
1203
- background-color: #d9534f; }
1204
+ @media (hover: hover) and (pointer: fine) {
1205
+ .guestbell-btn.guestbell-btn-error:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1206
+ color: white;
1207
+ fill: white;
1208
+ background-color: #d9534f; } }
1204
1209
  .guestbell-btn.guestbell-btn-error:not(.guestbell-btn--disabled).guestbell-btn--blank {
1205
1210
  color: #d9534f;
1206
1211
  fill: #d9534f;
@@ -1235,17 +1240,18 @@
1235
1240
  background-color: #f0ad4e;
1236
1241
  fill: white;
1237
1242
  color: white; }
1238
- .guestbell-btn.guestbell-btn-warning:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):hover {
1243
+ .guestbell-btn.guestbell-btn-warning:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):not(.guestbell-btn--outlined):hover {
1239
1244
  background-color: #ed9e2d; }
1240
1245
  .guestbell-btn.guestbell-btn-warning:not(.guestbell-btn--disabled).guestbell-btn--outlined {
1241
1246
  box-shadow: inset 0 0 0 1px #f0ad4e !important;
1242
1247
  color: #f0ad4e;
1243
1248
  fill: #f0ad4e;
1244
1249
  background-color: transparent; }
1245
- .guestbell-btn.guestbell-btn-warning:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1246
- color: white;
1247
- fill: white;
1248
- background-color: #f0ad4e; }
1250
+ @media (hover: hover) and (pointer: fine) {
1251
+ .guestbell-btn.guestbell-btn-warning:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1252
+ color: white;
1253
+ fill: white;
1254
+ background-color: #f0ad4e; } }
1249
1255
  .guestbell-btn.guestbell-btn-warning:not(.guestbell-btn--disabled).guestbell-btn--blank {
1250
1256
  color: #f0ad4e;
1251
1257
  fill: #f0ad4e;
@@ -1280,17 +1286,18 @@
1280
1286
  background-color: #555555;
1281
1287
  fill: white;
1282
1288
  color: white; }
1283
- .guestbell-btn.guestbell-btn-gray:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):hover {
1289
+ .guestbell-btn.guestbell-btn-gray:not(.guestbell-btn--disabled):not(.guestbell-btn--blank):not(.guestbell-btn--outlined):hover {
1284
1290
  background-color: #434343; }
1285
1291
  .guestbell-btn.guestbell-btn-gray:not(.guestbell-btn--disabled).guestbell-btn--outlined {
1286
1292
  box-shadow: inset 0 0 0 1px #555555 !important;
1287
1293
  color: #555555;
1288
1294
  fill: #555555;
1289
1295
  background-color: transparent; }
1290
- .guestbell-btn.guestbell-btn-gray:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1291
- color: white;
1292
- fill: white;
1293
- background-color: #555555; }
1296
+ @media (hover: hover) and (pointer: fine) {
1297
+ .guestbell-btn.guestbell-btn-gray:not(.guestbell-btn--disabled).guestbell-btn--outlined:hover {
1298
+ color: white;
1299
+ fill: white;
1300
+ background-color: #555555; } }
1294
1301
  .guestbell-btn.guestbell-btn-gray:not(.guestbell-btn--disabled).guestbell-btn--blank {
1295
1302
  color: #555555;
1296
1303
  fill: #555555;