@chayns-components/core 5.0.0-beta.626 → 5.0.0-beta.627
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/lib/cjs/components/amount-control/AmountControl.js +8 -4
- package/lib/cjs/components/amount-control/AmountControl.js.map +1 -1
- package/lib/cjs/components/amount-control/AmountControl.styles.js +6 -2
- package/lib/cjs/components/amount-control/AmountControl.styles.js.map +1 -1
- package/lib/esm/components/amount-control/AmountControl.js +8 -4
- package/lib/esm/components/amount-control/AmountControl.js.map +1 -1
- package/lib/esm/components/amount-control/AmountControl.styles.js +22 -12
- package/lib/esm/components/amount-control/AmountControl.styles.js.map +1 -1
- package/lib/types/components/amount-control/AmountControl.d.ts +4 -0
- package/lib/types/components/amount-control/AmountControl.styles.d.ts +2 -0
- package/package.json +2 -2
|
@@ -19,7 +19,8 @@ const AmountControl = ({
|
|
|
19
19
|
label,
|
|
20
20
|
iconColor,
|
|
21
21
|
maxAmount,
|
|
22
|
-
onChange
|
|
22
|
+
onChange,
|
|
23
|
+
shouldShowWideInput = false
|
|
23
24
|
}) => {
|
|
24
25
|
const [amountValue, setAmountValue] = (0, _react.useState)(0);
|
|
25
26
|
const [inputValue, setInputValue] = (0, _react.useState)('0');
|
|
@@ -164,7 +165,7 @@ const AmountControl = ({
|
|
|
164
165
|
padding: 0
|
|
165
166
|
},
|
|
166
167
|
animate: {
|
|
167
|
-
width: 28,
|
|
168
|
+
width: displayState === 'normal' || displayState === 'maxAmount' ? 40 : 28,
|
|
168
169
|
opacity: 1,
|
|
169
170
|
padding: 0
|
|
170
171
|
},
|
|
@@ -173,6 +174,7 @@ const AmountControl = ({
|
|
|
173
174
|
opacity: 0,
|
|
174
175
|
padding: 0
|
|
175
176
|
},
|
|
177
|
+
$isWide: displayState === 'normal' || displayState === 'maxAmount',
|
|
176
178
|
transition: {
|
|
177
179
|
duration: 0.2,
|
|
178
180
|
type: 'tween'
|
|
@@ -184,6 +186,7 @@ const AmountControl = ({
|
|
|
184
186
|
}, leftIcon)), /*#__PURE__*/_react.default.createElement(_AmountControl.StyledAmountControlInput, {
|
|
185
187
|
$displayState: displayState,
|
|
186
188
|
$shouldShowIcon: shouldShowIcon,
|
|
189
|
+
$shouldShowWideInput: shouldShowWideInput,
|
|
187
190
|
$hasFocus: hasFocus,
|
|
188
191
|
onBlur: handleInputBlur,
|
|
189
192
|
onChange: handleInputChange,
|
|
@@ -198,7 +201,7 @@ const AmountControl = ({
|
|
|
198
201
|
padding: 0
|
|
199
202
|
},
|
|
200
203
|
animate: {
|
|
201
|
-
width:
|
|
204
|
+
width: 40,
|
|
202
205
|
opacity: 1,
|
|
203
206
|
padding: 0
|
|
204
207
|
},
|
|
@@ -212,13 +215,14 @@ const AmountControl = ({
|
|
|
212
215
|
type: 'tween'
|
|
213
216
|
},
|
|
214
217
|
onClick: handleAmountAdd,
|
|
218
|
+
$isWide: displayState === 'normal' || displayState === 'maxAmount',
|
|
215
219
|
disabled: maxAmount ? amountValue >= maxAmount : false,
|
|
216
220
|
$isDisabled: maxAmount ? amountValue >= maxAmount : false
|
|
217
221
|
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
218
222
|
icons: ['fa fa-plus'],
|
|
219
223
|
size: 15,
|
|
220
224
|
color: "green"
|
|
221
|
-
})))), [amountValue, displayState, handleFirstAmount, handleInputBlur, handleInputChange, hasFocus, inputValue, label, leftIcon, maxAmount, shouldShowIcon, shouldShowLeftIcon]);
|
|
225
|
+
})))), [amountValue, displayState, handleFirstAmount, handleInputBlur, handleInputChange, hasFocus, inputValue, label, leftIcon, maxAmount, shouldShowIcon, shouldShowLeftIcon, shouldShowWideInput]);
|
|
222
226
|
};
|
|
223
227
|
AmountControl.displayName = 'AmountControl';
|
|
224
228
|
var _default = exports.default = AmountControl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmountControl.js","names":["_framerMotion","require","_react","_interopRequireWildcard","_amountControl","_Icon","_interopRequireDefault","_AmountControl","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AmountControl","amount","icon","shouldShowIcon","label","iconColor","maxAmount","onChange","amountValue","setAmountValue","useState","inputValue","setInputValue","displayState","setDisplayState","minAmount","useEffect","hasFocus","useMemo","checkForValidAmount","toString","handleAmountAdd","prevState","Number","handleAmountRemove","handleFirstAmount","useCallback","handleInputBlur","handleInputChange","event","value","target","valueBeforeCheck","replace","checkedValue","leftIcon","item","createElement","icons","size","color","shouldShowLeftIcon","StyledAmountControl","onClick","AnimatePresence","initial","StyledMotionAmountControlButton","key","width","opacity","padding","animate","exit","transition","duration","type","$color","undefined","disabled","$isDisabled","StyledAmountControlInput","$displayState","$shouldShowIcon","$hasFocus","onBlur","displayName","_default","exports"],"sources":["../../../../src/components/amount-control/AmountControl.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n ChangeEvent,\n FC,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { checkForValidAmount } from '../../utils/amountControl';\nimport Icon from '../icon/Icon';\nimport {\n StyledAmountControl,\n StyledAmountControlInput,\n StyledMotionAmountControlButton,\n} from './AmountControl.styles';\n\nexport type DisplayState = 'default' | 'delete' | 'normal' | 'maxAmount';\n\nexport type AmountControlProps = {\n /**\n * The amount that should be displayed.\n */\n amount?: number;\n /**\n * The icon that should be displayed if no amount is selected.\n */\n icon?: string;\n /**\n * The color of the icon.\n */\n iconColor?: string;\n /**\n * A Text that should be displayed, if no amount is selected;\n */\n label?: string;\n /**\n * The maximum allowed amount. If the maxAmount is set to one, a delete button is displayed on the left side.\n */\n maxAmount?: number;\n /**\n * A Function that is executed when the amount is changed\n */\n onChange?: (amount: number) => void;\n /**\n * Whether the icon should be displayed if no amount is selected\n */\n shouldShowIcon?: boolean;\n};\n\nconst AmountControl: FC<AmountControlProps> = ({\n amount,\n icon,\n shouldShowIcon = true,\n label,\n iconColor,\n maxAmount,\n onChange,\n}) => {\n const [amountValue, setAmountValue] = useState(0);\n const [inputValue, setInputValue] = useState('0');\n const [displayState, setDisplayState] = useState<DisplayState>('default');\n\n const minAmount = 0;\n\n /**\n * This function controls the displayState\n */\n useEffect(() => {\n switch (true) {\n case maxAmount === 1 && amountValue === 1:\n setDisplayState('delete');\n return;\n case maxAmount && amountValue >= maxAmount:\n setDisplayState('maxAmount');\n return;\n case amountValue > 0:\n setDisplayState('normal');\n return;\n default:\n setDisplayState('default');\n }\n }, [amountValue, maxAmount]);\n\n const hasFocus = useMemo(() => displayState !== 'default', [displayState]);\n\n /**\n * Function that sets the amountValue to the amount\n */\n useEffect(() => {\n if (!amount) {\n return;\n }\n\n setAmountValue(checkForValidAmount({ amount, maxAmount, minAmount }));\n setInputValue(checkForValidAmount({ amount, maxAmount, minAmount }).toString());\n }, [amount, maxAmount, minAmount]);\n\n /**\n * Function that updates the onChange event\n */\n useEffect(() => {\n if (onChange) {\n onChange(amountValue);\n }\n }, [amountValue, onChange]);\n\n const handleAmountAdd = () => {\n setAmountValue((prevState) => prevState + 1);\n setInputValue((prevState) => (Number(prevState) + 1).toString());\n };\n\n const handleAmountRemove = () => {\n setAmountValue((prevState) => prevState - 1);\n setInputValue((prevState) => (Number(prevState) - 1).toString());\n };\n\n const handleFirstAmount = useCallback(() => {\n if (amountValue !== 0) {\n return;\n }\n\n setAmountValue(1);\n setInputValue('1');\n }, [amountValue]);\n\n const handleInputBlur = useCallback(() => {\n setAmountValue(inputValue === '' ? 0 : Number(inputValue));\n\n if (inputValue === '') {\n setInputValue('0');\n }\n }, [inputValue]);\n\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const { value } = event.target;\n\n const valueBeforeCheck = Number(value.replace(/\\D/g, ''));\n\n const checkedValue = checkForValidAmount({\n minAmount,\n maxAmount,\n amount: valueBeforeCheck,\n });\n\n if (valueBeforeCheck < minAmount && minAmount === 0) {\n setInputValue('0');\n\n return;\n }\n\n setInputValue(checkedValue === 0 ? '' : checkedValue.toString());\n },\n [maxAmount, minAmount],\n );\n\n const leftIcon = useMemo(() => {\n let item: ReactElement | null = null;\n\n switch (displayState) {\n case 'default':\n item = <Icon icons={[icon ?? 'fa fa-cart-shopping']} size={15} color={iconColor} />;\n break;\n case 'delete':\n item = <Icon icons={['fa ts-check']} size={20} color=\"white\" />;\n break;\n case 'normal':\n item = <Icon icons={['fa fa-minus']} size={15} color=\"red\" />;\n break;\n case 'maxAmount':\n item = <Icon icons={['fa fa-minus']} size={15} color=\"red\" />;\n break;\n default:\n break;\n }\n\n return item;\n }, [displayState, icon, iconColor]);\n\n const shouldShowLeftIcon = useMemo(() => {\n if (shouldShowIcon) {\n return true;\n }\n\n return !(displayState === 'default' && !shouldShowIcon);\n }, [displayState, shouldShowIcon]);\n\n return useMemo(\n () => (\n <StyledAmountControl onClick={handleFirstAmount}>\n <AnimatePresence initial={false}>\n {shouldShowLeftIcon && (\n <StyledMotionAmountControlButton\n key=\"right_button\"\n initial={{ width: 0, opacity: 0, padding: 0 }}\n animate={{ width: 28, opacity: 1, padding: 0 }}\n exit={{ width: 0, opacity: 0, padding: 0 }}\n transition={{ duration: 0.2, type: 'tween' }}\n onClick={handleAmountRemove}\n $color={displayState === 'delete' ? 'rgb(32, 198, 90)' : undefined}\n disabled={amountValue !== 0 && amountValue <= minAmount}\n $isDisabled={amountValue !== 0 && amountValue <= minAmount}\n >\n {leftIcon}\n </StyledMotionAmountControlButton>\n )}\n </AnimatePresence>\n <StyledAmountControlInput\n $displayState={displayState}\n $shouldShowIcon={shouldShowIcon}\n $hasFocus={hasFocus}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n value={displayState === 'default' && label ? label : inputValue}\n />\n <AnimatePresence initial={false}>\n {displayState === 'normal' && (\n <StyledMotionAmountControlButton\n key=\"right_button\"\n initial={{ width: 0, opacity: 0, padding: 0 }}\n animate={{ width: 28, opacity: 1, padding: 0 }}\n exit={{ width: 0, opacity: 0, padding: 0 }}\n transition={{ duration: 0.2, type: 'tween' }}\n onClick={handleAmountAdd}\n disabled={maxAmount ? amountValue >= maxAmount : false}\n $isDisabled={maxAmount ? amountValue >= maxAmount : false}\n >\n <Icon icons={['fa fa-plus']} size={15} color=\"green\" />\n </StyledMotionAmountControlButton>\n )}\n </AnimatePresence>\n </StyledAmountControl>\n ),\n [\n amountValue,\n displayState,\n handleFirstAmount,\n handleInputBlur,\n handleInputChange,\n hasFocus,\n inputValue,\n label,\n leftIcon,\n maxAmount,\n shouldShowIcon,\n shouldShowLeftIcon,\n ],\n );\n};\n\nAmountControl.displayName = 'AmountControl';\n\nexport default AmountControl;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AAIgC,SAAAK,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAJ,CAAA,UAAAG,CAAA,CAAAE,GAAA,CAAAL,CA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,GAAAC,OAAA,CAAAtF,OAAA,GAE7BmB,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"AmountControl.js","names":["_framerMotion","require","_react","_interopRequireWildcard","_amountControl","_Icon","_interopRequireDefault","_AmountControl","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AmountControl","amount","icon","shouldShowIcon","label","iconColor","maxAmount","onChange","shouldShowWideInput","amountValue","setAmountValue","useState","inputValue","setInputValue","displayState","setDisplayState","minAmount","useEffect","hasFocus","useMemo","checkForValidAmount","toString","handleAmountAdd","prevState","Number","handleAmountRemove","handleFirstAmount","useCallback","handleInputBlur","handleInputChange","event","value","target","valueBeforeCheck","replace","checkedValue","leftIcon","item","createElement","icons","size","color","shouldShowLeftIcon","StyledAmountControl","onClick","AnimatePresence","initial","StyledMotionAmountControlButton","key","width","opacity","padding","animate","exit","$isWide","transition","duration","type","$color","undefined","disabled","$isDisabled","StyledAmountControlInput","$displayState","$shouldShowIcon","$shouldShowWideInput","$hasFocus","onBlur","displayName","_default","exports"],"sources":["../../../../src/components/amount-control/AmountControl.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n ChangeEvent,\n FC,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { checkForValidAmount } from '../../utils/amountControl';\nimport Icon from '../icon/Icon';\nimport {\n StyledAmountControl,\n StyledAmountControlInput,\n StyledMotionAmountControlButton,\n} from './AmountControl.styles';\n\nexport type DisplayState = 'default' | 'delete' | 'normal' | 'maxAmount';\n\nexport type AmountControlProps = {\n /**\n * The amount that should be displayed.\n */\n amount?: number;\n /**\n * The icon that should be displayed if no amount is selected.\n */\n icon?: string;\n /**\n * The color of the icon.\n */\n iconColor?: string;\n /**\n * A Text that should be displayed, if no amount is selected;\n */\n label?: string;\n /**\n * The maximum allowed amount. If the maxAmount is set to one, a delete button is displayed on the left side.\n */\n maxAmount?: number;\n /**\n * A Function that is executed when the amount is changed\n */\n onChange?: (amount: number) => void;\n /**\n * Whether the icon should be displayed if no amount is selected\n */\n shouldShowIcon?: boolean;\n /**\n * Whether the input should be wider\n */\n shouldShowWideInput?: boolean;\n};\n\nconst AmountControl: FC<AmountControlProps> = ({\n amount,\n icon,\n shouldShowIcon = true,\n label,\n iconColor,\n maxAmount,\n onChange,\n shouldShowWideInput = false,\n}) => {\n const [amountValue, setAmountValue] = useState(0);\n const [inputValue, setInputValue] = useState('0');\n const [displayState, setDisplayState] = useState<DisplayState>('default');\n\n const minAmount = 0;\n\n /**\n * This function controls the displayState\n */\n useEffect(() => {\n switch (true) {\n case maxAmount === 1 && amountValue === 1:\n setDisplayState('delete');\n return;\n case maxAmount && amountValue >= maxAmount:\n setDisplayState('maxAmount');\n return;\n case amountValue > 0:\n setDisplayState('normal');\n return;\n default:\n setDisplayState('default');\n }\n }, [amountValue, maxAmount]);\n\n const hasFocus = useMemo(() => displayState !== 'default', [displayState]);\n\n /**\n * Function that sets the amountValue to the amount\n */\n useEffect(() => {\n if (!amount) {\n return;\n }\n\n setAmountValue(checkForValidAmount({ amount, maxAmount, minAmount }));\n setInputValue(checkForValidAmount({ amount, maxAmount, minAmount }).toString());\n }, [amount, maxAmount, minAmount]);\n\n /**\n * Function that updates the onChange event\n */\n useEffect(() => {\n if (onChange) {\n onChange(amountValue);\n }\n }, [amountValue, onChange]);\n\n const handleAmountAdd = () => {\n setAmountValue((prevState) => prevState + 1);\n setInputValue((prevState) => (Number(prevState) + 1).toString());\n };\n\n const handleAmountRemove = () => {\n setAmountValue((prevState) => prevState - 1);\n setInputValue((prevState) => (Number(prevState) - 1).toString());\n };\n\n const handleFirstAmount = useCallback(() => {\n if (amountValue !== 0) {\n return;\n }\n\n setAmountValue(1);\n setInputValue('1');\n }, [amountValue]);\n\n const handleInputBlur = useCallback(() => {\n setAmountValue(inputValue === '' ? 0 : Number(inputValue));\n\n if (inputValue === '') {\n setInputValue('0');\n }\n }, [inputValue]);\n\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const { value } = event.target;\n\n const valueBeforeCheck = Number(value.replace(/\\D/g, ''));\n\n const checkedValue = checkForValidAmount({\n minAmount,\n maxAmount,\n amount: valueBeforeCheck,\n });\n\n if (valueBeforeCheck < minAmount && minAmount === 0) {\n setInputValue('0');\n\n return;\n }\n\n setInputValue(checkedValue === 0 ? '' : checkedValue.toString());\n },\n [maxAmount, minAmount],\n );\n\n const leftIcon = useMemo(() => {\n let item: ReactElement | null = null;\n\n switch (displayState) {\n case 'default':\n item = <Icon icons={[icon ?? 'fa fa-cart-shopping']} size={15} color={iconColor} />;\n break;\n case 'delete':\n item = <Icon icons={['fa ts-check']} size={20} color=\"white\" />;\n break;\n case 'normal':\n item = <Icon icons={['fa fa-minus']} size={15} color=\"red\" />;\n break;\n case 'maxAmount':\n item = <Icon icons={['fa fa-minus']} size={15} color=\"red\" />;\n break;\n default:\n break;\n }\n\n return item;\n }, [displayState, icon, iconColor]);\n\n const shouldShowLeftIcon = useMemo(() => {\n if (shouldShowIcon) {\n return true;\n }\n\n return !(displayState === 'default' && !shouldShowIcon);\n }, [displayState, shouldShowIcon]);\n\n return useMemo(\n () => (\n <StyledAmountControl onClick={handleFirstAmount}>\n <AnimatePresence initial={false}>\n {shouldShowLeftIcon && (\n <StyledMotionAmountControlButton\n key=\"right_button\"\n initial={{ width: 0, opacity: 0, padding: 0 }}\n animate={{\n width:\n displayState === 'normal' || displayState === 'maxAmount'\n ? 40\n : 28,\n opacity: 1,\n padding: 0,\n }}\n exit={{ width: 0, opacity: 0, padding: 0 }}\n $isWide={displayState === 'normal' || displayState === 'maxAmount'}\n transition={{ duration: 0.2, type: 'tween' }}\n onClick={handleAmountRemove}\n $color={displayState === 'delete' ? 'rgb(32, 198, 90)' : undefined}\n disabled={amountValue !== 0 && amountValue <= minAmount}\n $isDisabled={amountValue !== 0 && amountValue <= minAmount}\n >\n {leftIcon}\n </StyledMotionAmountControlButton>\n )}\n </AnimatePresence>\n <StyledAmountControlInput\n $displayState={displayState}\n $shouldShowIcon={shouldShowIcon}\n $shouldShowWideInput={shouldShowWideInput}\n $hasFocus={hasFocus}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n value={displayState === 'default' && label ? label : inputValue}\n />\n <AnimatePresence initial={false}>\n {displayState === 'normal' && (\n <StyledMotionAmountControlButton\n key=\"right_button\"\n initial={{ width: 0, opacity: 0, padding: 0 }}\n animate={{\n width: 40,\n opacity: 1,\n padding: 0,\n }}\n exit={{ width: 0, opacity: 0, padding: 0 }}\n transition={{ duration: 0.2, type: 'tween' }}\n onClick={handleAmountAdd}\n $isWide={displayState === 'normal' || displayState === 'maxAmount'}\n disabled={maxAmount ? amountValue >= maxAmount : false}\n $isDisabled={maxAmount ? amountValue >= maxAmount : false}\n >\n <Icon icons={['fa fa-plus']} size={15} color=\"green\" />\n </StyledMotionAmountControlButton>\n )}\n </AnimatePresence>\n </StyledAmountControl>\n ),\n [\n amountValue,\n displayState,\n handleFirstAmount,\n handleInputBlur,\n handleInputChange,\n hasFocus,\n inputValue,\n label,\n leftIcon,\n maxAmount,\n shouldShowIcon,\n shouldShowLeftIcon,\n shouldShowWideInput,\n ],\n );\n};\n\nAmountControl.displayName = 'AmountControl';\n\nexport default AmountControl;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AAIgC,SAAAK,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,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CAAE;IAC7Cb,OAAO,EAAEtB,eAAgB;IACzBgC,OAAO,EAAExC,YAAY,KAAK,QAAQ,IAAIA,YAAY,KAAK,WAAY;IACnE8C,QAAQ,EAAEtD,SAAS,GAAGG,WAAW,IAAIH,SAAS,GAAG,KAAM;IACvDuD,WAAW,EAAEvD,SAAS,GAAGG,WAAW,IAAIH,SAAS,GAAG;EAAM,gBAE1DjC,MAAA,CAAAQ,OAAA,CAAAyD,aAAA,CAAC9D,KAAA,CAAAK,OAAI;IAAC0D,KAAK,EAAE,CAAC,YAAY,CAAE;IAACC,IAAI,EAAE,EAAG;IAACC,KAAK,EAAC;EAAO,CAAE,CACzB,CAExB,CACA,CACxB,EACD,CACIhC,WAAW,EACXK,YAAY,EACZY,iBAAiB,EACjBE,eAAe,EACfC,iBAAiB,EACjBX,QAAQ,EACRN,UAAU,EACVR,KAAK,EACLgC,QAAQ,EACR9B,SAAS,EACTH,cAAc,EACduC,kBAAkB,EAClBlC,mBAAmB,CAE3B,CAAC;AACL,CAAC;AAEDR,aAAa,CAACoE,WAAW,GAAG,eAAe;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzF,OAAA,GAE7BmB,aAAa","ignoreList":[]}
|
|
@@ -26,7 +26,9 @@ const StyledAmountControlInput = exports.StyledAmountControlInput = _styledCompo
|
|
|
26
26
|
}) => theme.text};
|
|
27
27
|
border: none;
|
|
28
28
|
height: 28px;
|
|
29
|
-
width:
|
|
29
|
+
width: ${({
|
|
30
|
+
$shouldShowWideInput
|
|
31
|
+
}) => $shouldShowWideInput ? 90 : 55}px;
|
|
30
32
|
text-align: center;
|
|
31
33
|
cursor: ${({
|
|
32
34
|
$hasFocus
|
|
@@ -53,7 +55,9 @@ const StyledMotionAmountControlButton = exports.StyledMotionAmountControlButton
|
|
|
53
55
|
}) => $color ?? 'rgba(255, 255, 255, 0.2)'};
|
|
54
56
|
transition: background-color 0.2s ease-in-out;
|
|
55
57
|
height: 28px;
|
|
56
|
-
width:
|
|
58
|
+
width: ${({
|
|
59
|
+
$isWide
|
|
60
|
+
}) => $isWide ? 40 : 28}px;
|
|
57
61
|
|
|
58
62
|
${({
|
|
59
63
|
$isDisabled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmountControl.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","StyledAmountControl","exports","styled","div","theme","StyledAmountControlInput","input","text","$hasFocus","$displayState","css","$shouldShowIcon","StyledMotionAmountControlButton","motion","button","$color","$isDisabled"],"sources":["../../../../src/components/amount-control/AmountControl.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { DisplayState } from './AmountControl';\n\ntype StyledAmountControlProps = WithTheme<unknown>;\n\nexport const StyledAmountControl = styled.div<StyledAmountControlProps>`\n background-color: ${({ theme }: StyledAmountControlProps) => theme['202']};\n display: flex;\n width: fit-content;\n border-radius: 3px;\n overflow: hidden;\n`;\n\ntype StyledAmountControlInputProps = WithTheme<{\n $displayState: DisplayState;\n $shouldShowIcon: boolean;\n $hasFocus: boolean;\n}>;\n\nexport const StyledAmountControlInput = styled.input<StyledAmountControlInputProps>`\n background-color: ${({ theme }: StyledAmountControlInputProps) => theme['202']};\n color: ${({ theme }: StyledAmountControlInputProps) => theme.text};\n border: none;\n height: 28px;\n width:
|
|
1
|
+
{"version":3,"file":"AmountControl.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","StyledAmountControl","exports","styled","div","theme","StyledAmountControlInput","input","text","$shouldShowWideInput","$hasFocus","$displayState","css","$shouldShowIcon","StyledMotionAmountControlButton","motion","button","$color","$isWide","$isDisabled"],"sources":["../../../../src/components/amount-control/AmountControl.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { DisplayState } from './AmountControl';\n\ntype StyledAmountControlProps = WithTheme<unknown>;\n\nexport const StyledAmountControl = styled.div<StyledAmountControlProps>`\n background-color: ${({ theme }: StyledAmountControlProps) => theme['202']};\n display: flex;\n width: fit-content;\n border-radius: 3px;\n overflow: hidden;\n`;\n\ntype StyledAmountControlInputProps = WithTheme<{\n $displayState: DisplayState;\n $shouldShowIcon: boolean;\n $hasFocus: boolean;\n $shouldShowWideInput: boolean;\n}>;\n\nexport const StyledAmountControlInput = styled.input<StyledAmountControlInputProps>`\n background-color: ${({ theme }: StyledAmountControlInputProps) => theme['202']};\n color: ${({ theme }: StyledAmountControlInputProps) => theme.text};\n border: none;\n height: 28px;\n width: ${({ $shouldShowWideInput }) => ($shouldShowWideInput ? 90 : 55)}px;\n text-align: center;\n cursor: ${({ $hasFocus }) => ($hasFocus ? 'text' : 'pointer')};\n\n ${({ $displayState }) =>\n $displayState !== 'normal' &&\n css`\n border-bottom-right-radius: 3px;\n border-top-right-radius: 3px;\n `}\n ${({ $displayState, $shouldShowIcon }) =>\n $displayState === 'default' &&\n !$shouldShowIcon &&\n css`\n border-bottom-left-radius: 3px;\n border-top-left-radius: 3px;\n `};\n`;\n\ntype StyledAmountControlButtonProps = WithTheme<{\n $isDisabled: boolean;\n $color?: string;\n $isWide?: boolean;\n}>;\n\nexport const StyledMotionAmountControlButton = styled(\n motion.button,\n)<StyledAmountControlButtonProps>`\n overflow: hidden;\n background-color: ${({ $color }) => $color ?? 'rgba(255, 255, 255, 0.2)'};\n transition: background-color 0.2s ease-in-out;\n height: 28px;\n width: ${({ $isWide }) => ($isWide ? 40 : 28)}px;\n\n ${({ $isDisabled }) =>\n $isDisabled &&\n css`\n opacity: 0.5;\n `}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conColor,
|
|
13
13
|
maxAmount,
|
|
14
|
-
onChange
|
|
14
|
+
onChange,
|
|
15
|
+
shouldShowWideInput = false
|
|
15
16
|
} = _ref;
|
|
16
17
|
const [amountValue, setAmountValue] = useState(0);
|
|
17
18
|
const [inputValue, setInputValue] = useState('0');
|
|
@@ -156,7 +157,7 @@ const AmountControl = _ref => {
|
|
|
156
157
|
padding: 0
|
|
157
158
|
},
|
|
158
159
|
animate: {
|
|
159
|
-
width: 28,
|
|
160
|
+
width: displayState === 'normal' || displayState === 'maxAmount' ? 40 : 28,
|
|
160
161
|
opacity: 1,
|
|
161
162
|
padding: 0
|
|
162
163
|
},
|
|
@@ -165,6 +166,7 @@ const AmountControl = _ref => {
|
|
|
165
166
|
opacity: 0,
|
|
166
167
|
padding: 0
|
|
167
168
|
},
|
|
169
|
+
$isWide: displayState === 'normal' || displayState === 'maxAmount',
|
|
168
170
|
transition: {
|
|
169
171
|
duration: 0.2,
|
|
170
172
|
type: 'tween'
|
|
@@ -176,6 +178,7 @@ const AmountControl = _ref => {
|
|
|
176
178
|
}, leftIcon)), /*#__PURE__*/React.createElement(StyledAmountControlInput, {
|
|
177
179
|
$displayState: displayState,
|
|
178
180
|
$shouldShowIcon: shouldShowIcon,
|
|
181
|
+
$shouldShowWideInput: shouldShowWideInput,
|
|
179
182
|
$hasFocus: hasFocus,
|
|
180
183
|
onBlur: handleInputBlur,
|
|
181
184
|
onChange: handleInputChange,
|
|
@@ -190,7 +193,7 @@ const AmountControl = _ref => {
|
|
|
190
193
|
padding: 0
|
|
191
194
|
},
|
|
192
195
|
animate: {
|
|
193
|
-
width:
|
|
196
|
+
width: 40,
|
|
194
197
|
opacity: 1,
|
|
195
198
|
padding: 0
|
|
196
199
|
},
|
|
@@ -204,13 +207,14 @@ const AmountControl = _ref => {
|
|
|
204
207
|
type: 'tween'
|
|
205
208
|
},
|
|
206
209
|
onClick: handleAmountAdd,
|
|
210
|
+
$isWide: displayState === 'normal' || displayState === 'maxAmount',
|
|
207
211
|
disabled: maxAmount ? amountValue >= maxAmount : false,
|
|
208
212
|
$isDisabled: maxAmount ? amountValue >= maxAmount : false
|
|
209
213
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
210
214
|
icons: ['fa fa-plus'],
|
|
211
215
|
size: 15,
|
|
212
216
|
color: "green"
|
|
213
|
-
})))), [amountValue, displayState, handleFirstAmount, handleInputBlur, handleInputChange, hasFocus, inputValue, label, leftIcon, maxAmount, shouldShowIcon, shouldShowLeftIcon]);
|
|
217
|
+
})))), [amountValue, displayState, handleFirstAmount, handleInputBlur, handleInputChange, hasFocus, inputValue, label, leftIcon, maxAmount, shouldShowIcon, shouldShowLeftIcon, shouldShowWideInput]);
|
|
214
218
|
};
|
|
215
219
|
AmountControl.displayName = 'AmountControl';
|
|
216
220
|
export default AmountControl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmountControl.js","names":["AnimatePresence","React","useCallback","useEffect","useMemo","useState","checkForValidAmount","Icon","StyledAmountControl","StyledAmountControlInput","StyledMotionAmountControlButton","AmountControl","_ref","amount","icon","shouldShowIcon","label","iconColor","maxAmount","onChange","amountValue","setAmountValue","inputValue","setInputValue","displayState","setDisplayState","minAmount","hasFocus","toString","handleAmountAdd","prevState","Number","handleAmountRemove","handleFirstAmount","handleInputBlur","handleInputChange","event","value","target","valueBeforeCheck","replace","checkedValue","leftIcon","item","createElement","icons","size","color","shouldShowLeftIcon","onClick","initial","key","width","opacity","padding","animate","exit","transition","duration","type","$color","undefined","disabled","$isDisabled","$displayState","$shouldShowIcon","$hasFocus","onBlur","displayName"],"sources":["../../../../src/components/amount-control/AmountControl.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n ChangeEvent,\n FC,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { checkForValidAmount } from '../../utils/amountControl';\nimport Icon from '../icon/Icon';\nimport {\n StyledAmountControl,\n StyledAmountControlInput,\n StyledMotionAmountControlButton,\n} from './AmountControl.styles';\n\nexport type DisplayState = 'default' | 'delete' | 'normal' | 'maxAmount';\n\nexport type AmountControlProps = {\n /**\n * The amount that should be displayed.\n */\n amount?: number;\n /**\n * The icon that should be displayed if no amount is selected.\n */\n icon?: string;\n /**\n * The color of the icon.\n */\n iconColor?: string;\n /**\n * A Text that should be displayed, if no amount is selected;\n */\n label?: string;\n /**\n * The maximum allowed amount. If the maxAmount is set to one, a delete button is displayed on the left side.\n */\n maxAmount?: number;\n /**\n * A Function that is executed when the amount is changed\n */\n onChange?: (amount: number) => void;\n /**\n * Whether the icon should be displayed if no amount is selected\n */\n shouldShowIcon?: boolean;\n};\n\nconst AmountControl: FC<AmountControlProps> = ({\n amount,\n icon,\n shouldShowIcon = true,\n label,\n iconColor,\n maxAmount,\n onChange,\n}) => {\n const [amountValue, setAmountValue] = useState(0);\n const [inputValue, setInputValue] = useState('0');\n const [displayState, setDisplayState] = useState<DisplayState>('default');\n\n const minAmount = 0;\n\n /**\n * This function controls the displayState\n */\n useEffect(() => {\n switch (true) {\n case maxAmount === 1 && amountValue === 1:\n setDisplayState('delete');\n return;\n case maxAmount && amountValue >= maxAmount:\n setDisplayState('maxAmount');\n return;\n case amountValue > 0:\n setDisplayState('normal');\n return;\n default:\n setDisplayState('default');\n }\n }, [amountValue, maxAmount]);\n\n const hasFocus = useMemo(() => displayState !== 'default', [displayState]);\n\n /**\n * Function that sets the amountValue to the amount\n */\n useEffect(() => {\n if (!amount) {\n return;\n }\n\n setAmountValue(checkForValidAmount({ amount, maxAmount, minAmount }));\n setInputValue(checkForValidAmount({ amount, maxAmount, minAmount }).toString());\n }, [amount, maxAmount, minAmount]);\n\n /**\n * Function that updates the onChange event\n */\n useEffect(() => {\n if (onChange) {\n onChange(amountValue);\n }\n }, [amountValue, onChange]);\n\n const handleAmountAdd = () => {\n setAmountValue((prevState) => prevState + 1);\n setInputValue((prevState) => (Number(prevState) + 1).toString());\n };\n\n const handleAmountRemove = () => {\n setAmountValue((prevState) => prevState - 1);\n setInputValue((prevState) => (Number(prevState) - 1).toString());\n };\n\n const handleFirstAmount = useCallback(() => {\n if (amountValue !== 0) {\n return;\n }\n\n setAmountValue(1);\n setInputValue('1');\n }, [amountValue]);\n\n const handleInputBlur = useCallback(() => {\n setAmountValue(inputValue === '' ? 0 : Number(inputValue));\n\n if (inputValue === '') {\n setInputValue('0');\n }\n }, [inputValue]);\n\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const { value } = event.target;\n\n const valueBeforeCheck = Number(value.replace(/\\D/g, ''));\n\n const checkedValue = checkForValidAmount({\n minAmount,\n maxAmount,\n amount: valueBeforeCheck,\n });\n\n if (valueBeforeCheck < minAmount && minAmount === 0) {\n setInputValue('0');\n\n return;\n }\n\n setInputValue(checkedValue === 0 ? '' : checkedValue.toString());\n },\n [maxAmount, minAmount],\n );\n\n const leftIcon = useMemo(() => {\n let item: ReactElement | null = null;\n\n switch (displayState) {\n case 'default':\n item = <Icon icons={[icon ?? 'fa fa-cart-shopping']} size={15} color={iconColor} />;\n break;\n case 'delete':\n item = <Icon icons={['fa ts-check']} size={20} color=\"white\" />;\n break;\n case 'normal':\n item = <Icon icons={['fa fa-minus']} size={15} color=\"red\" />;\n break;\n case 'maxAmount':\n item = <Icon icons={['fa fa-minus']} size={15} color=\"red\" />;\n break;\n default:\n break;\n }\n\n return item;\n }, [displayState, icon, iconColor]);\n\n const shouldShowLeftIcon = useMemo(() => {\n if (shouldShowIcon) {\n return true;\n }\n\n return !(displayState === 'default' && !shouldShowIcon);\n }, [displayState, shouldShowIcon]);\n\n return useMemo(\n () => (\n <StyledAmountControl onClick={handleFirstAmount}>\n <AnimatePresence initial={false}>\n {shouldShowLeftIcon && (\n <StyledMotionAmountControlButton\n key=\"right_button\"\n initial={{ width: 0, opacity: 0, padding: 0 }}\n animate={{ width: 28, opacity: 1, padding: 0 }}\n exit={{ width: 0, opacity: 0, padding: 0 }}\n transition={{ duration: 0.2, type: 'tween' }}\n onClick={handleAmountRemove}\n $color={displayState === 'delete' ? 'rgb(32, 198, 90)' : undefined}\n disabled={amountValue !== 0 && amountValue <= minAmount}\n $isDisabled={amountValue !== 0 && amountValue <= minAmount}\n >\n {leftIcon}\n </StyledMotionAmountControlButton>\n )}\n </AnimatePresence>\n <StyledAmountControlInput\n $displayState={displayState}\n $shouldShowIcon={shouldShowIcon}\n $hasFocus={hasFocus}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n value={displayState === 'default' && label ? label : inputValue}\n />\n <AnimatePresence initial={false}>\n {displayState === 'normal' && (\n <StyledMotionAmountControlButton\n key=\"right_button\"\n initial={{ width: 0, opacity: 0, padding: 0 }}\n animate={{ width: 28, opacity: 1, padding: 0 }}\n exit={{ width: 0, opacity: 0, padding: 0 }}\n transition={{ duration: 0.2, type: 'tween' }}\n onClick={handleAmountAdd}\n disabled={maxAmount ? amountValue >= maxAmount : false}\n $isDisabled={maxAmount ? amountValue >= maxAmount : false}\n >\n <Icon icons={['fa fa-plus']} size={15} color=\"green\" />\n </StyledMotionAmountControlButton>\n )}\n </AnimatePresence>\n </StyledAmountControl>\n ),\n [\n amountValue,\n displayState,\n handleFirstAmount,\n handleInputBlur,\n handleInputChange,\n hasFocus,\n inputValue,\n label,\n leftIcon,\n maxAmount,\n shouldShowIcon,\n shouldShowLeftIcon,\n ],\n );\n};\n\nAmountControl.displayName = 'AmountControl';\n\nexport default AmountControl;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IAIRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACL,OAAO;AACd,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,OAAOC,IAAI,MAAM,cAAc;AAC/B,SACIC,mBAAmB,EACnBC,wBAAwB,EACxBC,+BAA+B,QAC5B,wBAAwB;AAmC/B,MAAMC,aAAqC,GAAGC,IAAA,IAQxC;EAAA,IARyC;IAC3CC,MAAM;IACNC,IAAI;IACJ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fC,iBAAiB,EACjBR,QAAQ,EACRL,UAAU,EACVN,KAAK,EACL0B,QAAQ,EACRxB,SAAS,EACTH,cAAc,EACdiC,kBAAkB,CAE1B,CAAC;AACL,CAAC;AAEDrC,aAAa,CAACyD,WAAW,GAAG,eAAe;AAE3C,eAAezD,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"AmountControl.js","names":["AnimatePresence","React","useCallback","useEffect","useMemo","useState","checkForValidAmount","Icon","StyledAmountControl","StyledAmountControlInput","StyledMotionAmountControlButton","AmountControl","_ref","amount","icon","shouldShowIcon","label","iconColor","maxAmount","onChange","shouldShowWideInput","amountValue","setAmountValue","inputValue","setInputValue","displayState","setDisplayState","minAmount","hasFocus","toString","handleAmountAdd","prevState","Number","handleAmountRemove","handleFirstAmount","handleInputBlur","handleInputChange","event","value","target","valueBeforeCheck","replace","checkedValue","leftIcon","item","createElement","icons","size","color","shouldShowLeftIcon","onClick","initial","key","width","opacity","padding","animate","exit","$isWide","transition","duration","type","$color","undefined","disabled","$isDisabled","$displayState","$shouldShowIcon","$shouldShowWideInput","$hasFocus","onBlur","displayName"],"sources":["../../../../src/components/amount-control/AmountControl.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n ChangeEvent,\n FC,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { checkForValidAmount } from '../../utils/amountControl';\nimport Icon from '../icon/Icon';\nimport {\n StyledAmountControl,\n StyledAmountControlInput,\n StyledMotionAmountControlButton,\n} from './AmountControl.styles';\n\nexport type DisplayState = 'default' | 'delete' | 'normal' | 'maxAmount';\n\nexport type AmountControlProps = {\n /**\n * The amount that should be displayed.\n */\n amount?: number;\n /**\n * The icon that should be displayed if no amount is selected.\n */\n icon?: string;\n /**\n * The color of the icon.\n */\n iconColor?: string;\n /**\n * A Text that should be displayed, if no amount is selected;\n */\n label?: string;\n /**\n * The maximum allowed amount. If the maxAmount is set to one, a delete button is displayed on the left side.\n */\n maxAmount?: number;\n /**\n * A Function that is executed when the amount is changed\n */\n onChange?: (amount: number) => void;\n /**\n * Whether the icon should be displayed if no amount is selected\n */\n shouldShowIcon?: boolean;\n /**\n * Whether the input should be wider\n */\n shouldShowWideInput?: boolean;\n};\n\nconst AmountControl: FC<AmountControlProps> = ({\n amount,\n icon,\n shouldShowIcon = true,\n label,\n iconColor,\n maxAmount,\n onChange,\n shouldShowWideInput = false,\n}) => {\n const [amountValue, setAmountValue] = useState(0);\n const [inputValue, setInputValue] = useState('0');\n const [displayState, setDisplayState] = useState<DisplayState>('default');\n\n const minAmount = 0;\n\n /**\n * This function controls the displayState\n */\n useEffect(() => {\n switch (true) {\n case maxAmount === 1 && amountValue === 1:\n setDisplayState('delete');\n return;\n case maxAmount && amountValue >= maxAmount:\n setDisplayState('maxAmount');\n return;\n case amountValue > 0:\n setDisplayState('normal');\n return;\n default:\n setDisplayState('default');\n }\n }, [amountValue, maxAmount]);\n\n const hasFocus = useMemo(() => displayState !== 'default', [displayState]);\n\n /**\n * Function that sets the amountValue to the amount\n */\n useEffect(() => {\n if (!amount) {\n return;\n }\n\n setAmountValue(checkForValidAmount({ amount, maxAmount, minAmount }));\n setInputValue(checkForValidAmount({ amount, maxAmount, minAmount }).toString());\n }, [amount, maxAmount, minAmount]);\n\n /**\n * Function that updates the onChange event\n */\n useEffect(() => {\n if (onChange) {\n onChange(amountValue);\n }\n }, [amountValue, onChange]);\n\n const handleAmountAdd = () => {\n setAmountValue((prevState) => prevState + 1);\n setInputValue((prevState) => (Number(prevState) + 1).toString());\n };\n\n const handleAmountRemove = () => {\n setAmountValue((prevState) => prevState - 1);\n setInputValue((prevState) => (Number(prevState) - 1).toString());\n };\n\n const handleFirstAmount = useCallback(() => {\n if (amountValue !== 0) {\n return;\n }\n\n setAmountValue(1);\n setInputValue('1');\n }, [amountValue]);\n\n const handleInputBlur = useCallback(() => {\n setAmountValue(inputValue === '' ? 0 : Number(inputValue));\n\n if (inputValue === '') {\n setInputValue('0');\n }\n }, [inputValue]);\n\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const { value } = event.target;\n\n const valueBeforeCheck = Number(value.replace(/\\D/g, ''));\n\n const checkedValue = checkForValidAmount({\n minAmount,\n maxAmount,\n amount: valueBeforeCheck,\n });\n\n if (valueBeforeCheck < minAmount && minAmount === 0) {\n setInputValue('0');\n\n return;\n }\n\n setInputValue(checkedValue === 0 ? '' : checkedValue.toString());\n },\n [maxAmount, minAmount],\n );\n\n const leftIcon = useMemo(() => {\n let item: ReactElement | null = null;\n\n switch (displayState) {\n case 'default':\n item = <Icon icons={[icon ?? 'fa fa-cart-shopping']} size={15} color={iconColor} />;\n break;\n case 'delete':\n item = <Icon icons={['fa ts-check']} size={20} color=\"white\" />;\n break;\n case 'normal':\n item = <Icon icons={['fa fa-minus']} size={15} color=\"red\" />;\n break;\n case 'maxAmount':\n item = <Icon icons={['fa fa-minus']} size={15} color=\"red\" />;\n break;\n default:\n break;\n }\n\n return item;\n }, [displayState, icon, iconColor]);\n\n const shouldShowLeftIcon = useMemo(() => {\n if (shouldShowIcon) {\n return true;\n }\n\n return !(displayState === 'default' && !shouldShowIcon);\n }, [displayState, shouldShowIcon]);\n\n return useMemo(\n () => (\n <StyledAmountControl onClick={handleFirstAmount}>\n <AnimatePresence initial={false}>\n {shouldShowLeftIcon && (\n <StyledMotionAmountControlButton\n key=\"right_button\"\n initial={{ width: 0, opacity: 0, padding: 0 }}\n animate={{\n width:\n displayState === 'normal' || displayState === 'maxAmount'\n ? 40\n : 28,\n opacity: 1,\n padding: 0,\n }}\n exit={{ width: 0, opacity: 0, padding: 0 }}\n $isWide={displayState === 'normal' || displayState === 'maxAmount'}\n transition={{ duration: 0.2, type: 'tween' }}\n onClick={handleAmountRemove}\n $color={displayState === 'delete' ? 'rgb(32, 198, 90)' : undefined}\n disabled={amountValue !== 0 && amountValue <= minAmount}\n $isDisabled={amountValue !== 0 && amountValue <= minAmount}\n >\n {leftIcon}\n </StyledMotionAmountControlButton>\n )}\n </AnimatePresence>\n <StyledAmountControlInput\n $displayState={displayState}\n $shouldShowIcon={shouldShowIcon}\n $shouldShowWideInput={shouldShowWideInput}\n $hasFocus={hasFocus}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n value={displayState === 'default' && label ? label : inputValue}\n />\n <AnimatePresence initial={false}>\n {displayState === 'normal' && (\n <StyledMotionAmountControlButton\n key=\"right_button\"\n initial={{ width: 0, opacity: 0, padding: 0 }}\n animate={{\n width: 40,\n opacity: 1,\n padding: 0,\n }}\n exit={{ width: 0, opacity: 0, padding: 0 }}\n transition={{ duration: 0.2, type: 'tween' }}\n onClick={handleAmountAdd}\n $isWide={displayState === 'normal' || displayState === 'maxAmount'}\n disabled={maxAmount ? amountValue >= maxAmount : false}\n $isDisabled={maxAmount ? amountValue >= maxAmount : false}\n >\n <Icon icons={['fa fa-plus']} size={15} color=\"green\" />\n </StyledMotionAmountControlButton>\n )}\n </AnimatePresence>\n </StyledAmountControl>\n ),\n [\n amountValue,\n displayState,\n handleFirstAmount,\n handleInputBlur,\n handleInputChange,\n hasFocus,\n inputValue,\n label,\n leftIcon,\n maxAmount,\n shouldShowIcon,\n shouldShowLeftIcon,\n shouldShowWideInput,\n ],\n );\n};\n\nAmountControl.displayName = 'AmountControl';\n\nexport default AmountControl;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IAIRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACL,OAAO;AACd,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,OAAOC,IAAI,MAAM,cAAc;AAC/B,SACIC,mBAAmB,EACnBC,wBAAwB,EACxBC,+BAA+B,QAC5B,wBAAwB;AAuC/B,MAAMC,aAAqC,GAAGC,IAAA,IASxC;EAAA,IATyC;IAC3CC,MAAM;IACNC,IAAI;IACJC,cAAc,GAAG,IAAI;IACrBC,KAAK;IACLC,SAAS;IACTC,SAAS;IACTC,QA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I;IAACuC,KAAK,EAAE,CAAC,YAAY,CAAE;IAACC,IAAI,EAAE,EAAG;IAACC,KAAK,EAAC;EAAO,CAAE,CACzB,CAExB,CACA,CACxB,EACD,CACI3B,WAAW,EACXI,YAAY,EACZS,iBAAiB,EACjBC,eAAe,EACfC,iBAAiB,EACjBR,QAAQ,EACRL,UAAU,EACVP,KAAK,EACL2B,QAAQ,EACRzB,SAAS,EACTH,cAAc,EACdkC,kBAAkB,EAClB7B,mBAAmB,CAE3B,CAAC;AACL,CAAC;AAEDT,aAAa,CAAC4D,WAAW,GAAG,eAAe;AAE3C,eAAe5D,aAAa","ignoreList":[]}
|
|
@@ -27,29 +27,34 @@ export const StyledAmountControlInput = styled.input`
|
|
|
27
27
|
}};
|
|
28
28
|
border: none;
|
|
29
29
|
height: 28px;
|
|
30
|
-
width:
|
|
30
|
+
width: ${_ref4 => {
|
|
31
|
+
let {
|
|
32
|
+
$shouldShowWideInput
|
|
33
|
+
} = _ref4;
|
|
34
|
+
return $shouldShowWideInput ? 90 : 55;
|
|
35
|
+
}}px;
|
|
31
36
|
text-align: center;
|
|
32
|
-
cursor: ${
|
|
37
|
+
cursor: ${_ref5 => {
|
|
33
38
|
let {
|
|
34
39
|
$hasFocus
|
|
35
|
-
} =
|
|
40
|
+
} = _ref5;
|
|
36
41
|
return $hasFocus ? 'text' : 'pointer';
|
|
37
42
|
}};
|
|
38
43
|
|
|
39
|
-
${
|
|
44
|
+
${_ref6 => {
|
|
40
45
|
let {
|
|
41
46
|
$displayState
|
|
42
|
-
} =
|
|
47
|
+
} = _ref6;
|
|
43
48
|
return $displayState !== 'normal' && css`
|
|
44
49
|
border-bottom-right-radius: 3px;
|
|
45
50
|
border-top-right-radius: 3px;
|
|
46
51
|
`;
|
|
47
52
|
}}
|
|
48
|
-
${
|
|
53
|
+
${_ref7 => {
|
|
49
54
|
let {
|
|
50
55
|
$displayState,
|
|
51
56
|
$shouldShowIcon
|
|
52
|
-
} =
|
|
57
|
+
} = _ref7;
|
|
53
58
|
return $displayState === 'default' && !$shouldShowIcon && css`
|
|
54
59
|
border-bottom-left-radius: 3px;
|
|
55
60
|
border-top-left-radius: 3px;
|
|
@@ -58,20 +63,25 @@ export const StyledAmountControlInput = styled.input`
|
|
|
58
63
|
`;
|
|
59
64
|
export const StyledMotionAmountControlButton = styled(motion.button)`
|
|
60
65
|
overflow: hidden;
|
|
61
|
-
background-color: ${
|
|
66
|
+
background-color: ${_ref8 => {
|
|
62
67
|
let {
|
|
63
68
|
$color
|
|
64
|
-
} =
|
|
69
|
+
} = _ref8;
|
|
65
70
|
return $color ?? 'rgba(255, 255, 255, 0.2)';
|
|
66
71
|
}};
|
|
67
72
|
transition: background-color 0.2s ease-in-out;
|
|
68
73
|
height: 28px;
|
|
69
|
-
width:
|
|
74
|
+
width: ${_ref9 => {
|
|
75
|
+
let {
|
|
76
|
+
$isWide
|
|
77
|
+
} = _ref9;
|
|
78
|
+
return $isWide ? 40 : 28;
|
|
79
|
+
}}px;
|
|
70
80
|
|
|
71
|
-
${
|
|
81
|
+
${_ref10 => {
|
|
72
82
|
let {
|
|
73
83
|
$isDisabled
|
|
74
|
-
} =
|
|
84
|
+
} = _ref10;
|
|
75
85
|
return $isDisabled && css`
|
|
76
86
|
opacity: 0.5;
|
|
77
87
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmountControl.styles.js","names":["motion","styled","css","StyledAmountControl","div","_ref","theme","StyledAmountControlInput","input","_ref2","_ref3","text","_ref4","$
|
|
1
|
+
{"version":3,"file":"AmountControl.styles.js","names":["motion","styled","css","StyledAmountControl","div","_ref","theme","StyledAmountControlInput","input","_ref2","_ref3","text","_ref4","$shouldShowWideInput","_ref5","$hasFocus","_ref6","$displayState","_ref7","$shouldShowIcon","StyledMotionAmountControlButton","button","_ref8","$color","_ref9","$isWide","_ref10","$isDisabled"],"sources":["../../../../src/components/amount-control/AmountControl.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { DisplayState } from './AmountControl';\n\ntype StyledAmountControlProps = WithTheme<unknown>;\n\nexport const StyledAmountControl = styled.div<StyledAmountControlProps>`\n background-color: ${({ theme }: StyledAmountControlProps) => theme['202']};\n display: flex;\n width: fit-content;\n border-radius: 3px;\n overflow: hidden;\n`;\n\ntype StyledAmountControlInputProps = WithTheme<{\n $displayState: DisplayState;\n $shouldShowIcon: boolean;\n $hasFocus: boolean;\n $shouldShowWideInput: boolean;\n}>;\n\nexport const StyledAmountControlInput = styled.input<StyledAmountControlInputProps>`\n background-color: ${({ theme }: StyledAmountControlInputProps) => theme['202']};\n color: ${({ theme }: StyledAmountControlInputProps) => theme.text};\n border: none;\n height: 28px;\n width: ${({ $shouldShowWideInput }) => ($shouldShowWideInput ? 90 : 55)}px;\n text-align: center;\n cursor: ${({ $hasFocus }) => ($hasFocus ? 'text' : 'pointer')};\n\n ${({ $displayState }) =>\n $displayState !== 'normal' &&\n css`\n border-bottom-right-radius: 3px;\n border-top-right-radius: 3px;\n `}\n ${({ $displayState, $shouldShowIcon }) =>\n $displayState === 'default' &&\n !$shouldShowIcon &&\n css`\n border-bottom-left-radius: 3px;\n border-top-left-radius: 3px;\n `};\n`;\n\ntype StyledAmountControlButtonProps = WithTheme<{\n $isDisabled: boolean;\n $color?: string;\n $isWide?: boolean;\n}>;\n\nexport const StyledMotionAmountControlButton = styled(\n motion.button,\n)<StyledAmountControlButtonProps>`\n overflow: hidden;\n background-color: ${({ $color }) => $color ?? 'rgba(255, 255, 255, 0.2)'};\n transition: background-color 0.2s ease-in-out;\n height: 28px;\n width: ${({ $isWide }) => ($isWide ? 40 : 28)}px;\n\n ${({ $isDisabled }) =>\n $isDisabled &&\n css`\n opacity: 0.5;\n `}\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAM/C,OAA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M,IAAI,0BAA0B;AAAA,CAAC;AAC7E;AACA;AACA,aAAaC,KAAA;EAAA,IAAC;IAAEC;EAAQ,CAAC,GAAAD,KAAA;EAAA,OAAMC,OAAO,GAAG,EAAE,GAAG,EAAE;AAAA,CAAE;AAClD;AACA,MAAMC,MAAA;EAAA,IAAC;IAAEC;EAAY,CAAC,GAAAD,MAAA;EAAA,OACdC,WAAW,IACXzB,GAAI;AACZ;AACA,SAAS;AAAA,CAAC;AACV,CAAC","ignoreList":[]}
|
|
@@ -29,6 +29,10 @@ export type AmountControlProps = {
|
|
|
29
29
|
* Whether the icon should be displayed if no amount is selected
|
|
30
30
|
*/
|
|
31
31
|
shouldShowIcon?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the input should be wider
|
|
34
|
+
*/
|
|
35
|
+
shouldShowWideInput?: boolean;
|
|
32
36
|
};
|
|
33
37
|
declare const AmountControl: FC<AmountControlProps>;
|
|
34
38
|
export default AmountControl;
|
|
@@ -9,11 +9,13 @@ type StyledAmountControlInputProps = WithTheme<{
|
|
|
9
9
|
$displayState: DisplayState;
|
|
10
10
|
$shouldShowIcon: boolean;
|
|
11
11
|
$hasFocus: boolean;
|
|
12
|
+
$shouldShowWideInput: boolean;
|
|
12
13
|
}>;
|
|
13
14
|
export declare const StyledAmountControlInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, StyledAmountControlInputProps>> & string;
|
|
14
15
|
type StyledAmountControlButtonProps = WithTheme<{
|
|
15
16
|
$isDisabled: boolean;
|
|
16
17
|
$color?: string;
|
|
18
|
+
$isWide?: boolean;
|
|
17
19
|
}>;
|
|
18
20
|
export declare const StyledMotionAmountControlButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<{
|
|
19
21
|
form?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.627",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "7f528d0e2af9da630168adc8203d16145bc3578a"
|
|
89
89
|
}
|