@chayns-components/core 5.0.0-beta.535 → 5.0.0-beta.537
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/components/amount-control/AmountControl.d.ts +4 -0
- package/lib/components/amount-control/AmountControl.js +33 -3
- package/lib/components/amount-control/AmountControl.js.map +1 -1
- package/lib/components/amount-control/AmountControl.styles.d.ts +1 -0
- package/lib/components/amount-control/AmountControl.styles.js +13 -2
- package/lib/components/amount-control/AmountControl.styles.js.map +1 -1
- package/lib/components/checkbox/Checkbox.styles.js +24 -14
- package/lib/components/checkbox/Checkbox.styles.js.map +1 -1
- package/lib/components/content-card/ContentCard.styles.d.ts +3 -1
- package/lib/components/content-card/ContentCard.styles.js +9 -21
- package/lib/components/content-card/ContentCard.styles.js.map +1 -1
- package/lib/components/context-menu/ContextMenu.js +2 -1
- package/lib/components/context-menu/ContextMenu.js.map +1 -1
- package/lib/components/file-input/FileInput.d.ts +19 -7
- package/lib/components/file-input/FileInput.js +97 -24
- package/lib/components/file-input/FileInput.js.map +1 -1
- package/lib/components/file-input/FileInput.styles.d.ts +5 -1
- package/lib/components/file-input/FileInput.styles.js +27 -14
- package/lib/components/file-input/FileInput.styles.js.map +1 -1
- package/lib/components/file-input/file-list/FileListItem.d.ts +4 -3
- package/lib/components/file-input/file-list/FileListItem.js +6 -5
- package/lib/components/file-input/file-list/FileListItem.js.map +1 -1
- package/lib/components/filter-buttons/filter-button/FilterButton.styles.js +3 -2
- package/lib/components/filter-buttons/filter-button/FilterButton.styles.js.map +1 -1
- package/lib/components/mention-finder/MentionFinder.js +0 -31
- package/lib/components/mention-finder/MentionFinder.js.map +1 -1
- package/lib/components/mention-finder/MentionFinder.styles.js +1 -1
- package/lib/components/mention-finder/MentionFinder.styles.js.map +1 -1
- package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js +2 -3
- package/lib/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js.map +1 -1
- package/lib/components/popup/Popup.js +1 -1
- package/lib/components/popup/Popup.js.map +1 -1
- package/lib/components/popup/popup-content/PopupContent.styles.js +2 -0
- package/lib/components/popup/popup-content/PopupContent.styles.js.map +1 -1
- package/lib/components/progress-bar/ProgressBar.styles.js +2 -1
- package/lib/components/progress-bar/ProgressBar.styles.js.map +1 -1
- package/lib/components/select-button/SelectButton.js +19 -4
- package/lib/components/select-button/SelectButton.js.map +1 -1
- package/lib/components/slider/Slider.styles.d.ts +6 -2
- package/lib/components/slider/Slider.styles.js +34 -40
- package/lib/components/slider/Slider.styles.js.map +1 -1
- package/lib/components/slider-button/SliderButton.styles.js +1 -1
- package/lib/components/slider-button/SliderButton.styles.js.map +1 -1
- package/lib/components/small-wait-cursor/SmallWaitCursor.styles.js +16 -18
- package/lib/components/small-wait-cursor/SmallWaitCursor.styles.js.map +1 -1
- package/lib/components/tag-input/TagInput.js +35 -3
- package/lib/components/tag-input/TagInput.js.map +1 -1
- package/lib/types/fileInput.d.ts +7 -0
- package/lib/types/fileInput.js +2 -0
- package/lib/types/fileInput.js.map +1 -0
- package/lib/utils/file.d.ts +5 -0
- package/lib/utils/file.js +10 -2
- package/lib/utils/file.js.map +1 -1
- package/package.json +2 -2
|
@@ -21,6 +21,10 @@ export type AmountControlProps = {
|
|
|
21
21
|
* A Function that is executed when the amount is changed
|
|
22
22
|
*/
|
|
23
23
|
onChange?: (amount: number) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the icon should be displayed if no amount is selected
|
|
26
|
+
*/
|
|
27
|
+
shouldShowIcon?: boolean;
|
|
24
28
|
};
|
|
25
29
|
declare const AmountControl: FC<AmountControlProps>;
|
|
26
30
|
export default AmountControl;
|
|
@@ -7,6 +7,7 @@ const AmountControl = _ref => {
|
|
|
7
7
|
let {
|
|
8
8
|
amount,
|
|
9
9
|
icon,
|
|
10
|
+
shouldShowIcon = true,
|
|
10
11
|
label,
|
|
11
12
|
maxAmount,
|
|
12
13
|
onChange
|
|
@@ -130,14 +131,43 @@ const AmountControl = _ref => {
|
|
|
130
131
|
}
|
|
131
132
|
return item;
|
|
132
133
|
}, [displayState, icon]);
|
|
134
|
+
const shouldShowLeftIcon = useMemo(() => {
|
|
135
|
+
if (shouldShowIcon) {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
return !(displayState === 'default' && !shouldShowIcon);
|
|
139
|
+
}, [displayState, shouldShowIcon]);
|
|
133
140
|
return useMemo(() => /*#__PURE__*/React.createElement(StyledAmountControl, {
|
|
134
141
|
onClick: handleFirstAmount
|
|
135
|
-
}, /*#__PURE__*/React.createElement(
|
|
142
|
+
}, /*#__PURE__*/React.createElement(AnimatePresence, {
|
|
143
|
+
initial: false
|
|
144
|
+
}, shouldShowLeftIcon && /*#__PURE__*/React.createElement(StyledMotionAmountControlButton, {
|
|
145
|
+
key: "right_button",
|
|
146
|
+
initial: {
|
|
147
|
+
width: 0,
|
|
148
|
+
opacity: 0,
|
|
149
|
+
padding: 0
|
|
150
|
+
},
|
|
151
|
+
animate: {
|
|
152
|
+
width: 40,
|
|
153
|
+
opacity: 1,
|
|
154
|
+
padding: 0
|
|
155
|
+
},
|
|
156
|
+
exit: {
|
|
157
|
+
width: 0,
|
|
158
|
+
opacity: 0,
|
|
159
|
+
padding: 0
|
|
160
|
+
},
|
|
161
|
+
transition: {
|
|
162
|
+
duration: 0.2,
|
|
163
|
+
type: 'tween'
|
|
164
|
+
},
|
|
136
165
|
onClick: handleAmountRemove,
|
|
137
166
|
disabled: amountValue !== 0 && amountValue <= minAmount,
|
|
138
167
|
$isDisabled: amountValue !== 0 && amountValue <= minAmount
|
|
139
|
-
}, leftIcon), /*#__PURE__*/React.createElement(StyledAmountControlInput, {
|
|
168
|
+
}, leftIcon)), /*#__PURE__*/React.createElement(StyledAmountControlInput, {
|
|
140
169
|
$displayState: displayState,
|
|
170
|
+
$shouldShowIcon: shouldShowIcon,
|
|
141
171
|
onBlur: handleInputBlur,
|
|
142
172
|
onChange: handleInputChange,
|
|
143
173
|
value: displayState === 'default' && label ? label : inputValue,
|
|
@@ -172,7 +202,7 @@ const AmountControl = _ref => {
|
|
|
172
202
|
icons: ['fa fa-plus'],
|
|
173
203
|
size: 15,
|
|
174
204
|
color: "green"
|
|
175
|
-
})))), [amountValue, displayState, handleFirstAmount, handleInputBlur, handleInputChange, inputValue, label, leftIcon, maxAmount,
|
|
205
|
+
})))), [amountValue, displayState, handleFirstAmount, handleInputBlur, handleInputChange, inputValue, label, leftIcon, maxAmount, shouldShowIcon, shouldShowLeftIcon]);
|
|
176
206
|
};
|
|
177
207
|
AmountControl.displayName = 'AmountControl';
|
|
178
208
|
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","label","maxAmount","onChange","amountValue","setAmountValue","inputValue","setInputValue","displayState","setDisplayState","minAmount","toString","handleAmountAdd","prevState","Number","handleAmountRemove","handleFirstAmount","handleInputBlur","handleInputChange","event","valueBeforeCheck","target","value","checkedValue","leftIcon","item","createElement","icons","size","color","onClick","disabled","$isDisabled","$displayState","onBlur","type","initial","key","width","opacity","padding","animate","exit","transition","duration","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 * 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\nconst AmountControl: FC<AmountControlProps> = ({ amount, icon, label, maxAmount, onChange }) => {\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 /**\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 valueBeforeCheck = Number(event.target.value);\n\n const checkedValue = checkForValidAmount({\n minAmount,\n maxAmount,\n amount: Number(event.target.value),\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} />;\n break;\n case 'delete':\n item = <Icon icons={['fa ts-trash']} size={25} />;\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]);\n\n return useMemo(\n () => (\n <StyledAmountControl onClick={handleFirstAmount}>\n <StyledMotionAmountControlButton\n onClick={handleAmountRemove}\n disabled={amountValue !== 0 && amountValue <= minAmount}\n $isDisabled={amountValue !== 0 && amountValue <= minAmount}\n >\n {leftIcon}\n </StyledMotionAmountControlButton>\n <StyledAmountControlInput\n $displayState={displayState}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n value={displayState === 'default' && label ? label : inputValue}\n type={amountValue === 0 ? 'text' : 'number'}\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: 40, 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 inputValue,\n label,\n leftIcon,\n maxAmount,\n minAmount,\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;AA2B/B,MAAMC,aAAqC,GAAGC,IAAA,IAAkD;EAAA,IAAjD;IAAEC,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC,SAAS;IAAEC;EAAS,CAAC,GAAAL,IAAA;EACvF,MAAM,CAACM,WAAW,EAAEC,cAAc,CAAC,GAAGd,QAAQ,CAAC,CAAC,CAAC;EACjD,MAAM,CAACe,UAAU,EAAEC,aAAa,CAAC,GAAGhB,QAAQ,CAAC,GAAG,CAAC;EACjD,MAAM,CAACiB,YAAY,EAAEC,eAAe,CAAC,GAAGlB,QAAQ,CAAe,SAAS,CAAC;EAEzE,MAAMmB,SAAS,GAAG,CAAC;;EAEnB;AACJ;AACA;EACIrB,SAAS,CAAC,MAAM;IACZ,QAAQ,IAAI;MACR,KAAKa,SAAS,KAAK,CAAC,IAAIE,WAAW,KAAK,CAAC;QACrCK,eAAe,CAAC,QAAQ,CAAC;QACzB;MACJ,KAAKP,SAAS,IAAIE,WAAW,IAAIF,SAAS;QACtCO,eAAe,CAAC,WAAW,CAAC;QAC5B;MACJ,KAAKL,WAAW,GAAG,CAAC;QAChBK,eAAe,CAAC,QAAQ,CAAC;QACzB;MACJ;QACIA,eAAe,CAAC,SAAS,CAAC;IAClC;EACJ,CAAC,EAAE,CAACL,WAAW,EAAEF,SAAS,CAAC,CAAC;;EAE5B;AACJ;AACA;EACIb,SAAS,CAAC,MAAM;IACZ,IAAI,CAAC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AAO,EAAE;MAAEH,KAAK,EAAE,EAAE;MAAEC,OAAO,EAAE,CAAC;MAAEC,OAAO,EAAE;IAAE,CAAE;IAC/CE,IAAI,EAAE;MAAEJ,KAAK,EAAE,CAAC;MAAEC,OAAO,EAAE,CAAC;MAAEC,OAAO,EAAE;IAAE,CAAE;IAC3CG,UAAU,EAAE;MAAEC,QAAQ,EAAE,GAAG;MAAET,IAAI,EAAE;IAAQ,CAAE;IAC7CL,OAAO,EAAElB,eAAgB;IACzBmB,QAAQ,EAAE7B,SAAS,GAAGE,WAAW,IAAIF,SAAS,GAAG,KAAM;IACvD8B,WAAW,EAAE9B,SAAS,GAAGE,WAAW,IAAIF,SAAS,GAAG;EAAM,gBAE1Df,KAAA,CAAAuC,aAAA,CAACjC,IAAI;IAACkC,KAAK,EAAE,CAAC,YAAY,CAAE;IAACC,IAAI,EAAE,EAAG;IAACC,KAAK,EAAC;EAAO,CAAE,CACzB,CAExB,CACA,CACxB,EACD,CACIzB,WAAW,EACXI,YAAY,EACZQ,iBAAiB,EACjBC,eAAe,EACfC,iBAAiB,EACjBZ,UAAU,EACVL,KAAK,EACLuB,QAAQ,EACRtB,SAAS,EACTQ,SAAS,CAEjB,CAAC;AACL,CAAC;AAEDb,aAAa,CAACgD,WAAW,GAAG,eAAe;AAE3C,eAAehD,aAAa"}
|
|
1
|
+
{"version":3,"file":"AmountControl.js","names":["AnimatePresence","React","useCallback","useEffect","useMemo","useState","checkForValidAmount","Icon","StyledAmountControl","StyledAmountControlInput","StyledMotionAmountControlButton","AmountControl","_ref","amount","icon","shouldShowIcon","label","maxAmount","onChange","amountValue","setAmountValue","inputValue","setInputValue","displayState","setDisplayState","minAmount","toString","handleAmountAdd","prevState","Number","handleAmountRemove","handleFirstAmount","handleInputBlur","handleInputChange","event","valueBeforeCheck","target","value","checkedValue","leftIcon","item","createElement","icons","size","color","shouldShowLeftIcon","onClick","initial","key","width","opacity","padding","animate","exit","transition","duration","type","disabled","$isDisabled","$displayState","$shouldShowIcon","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 * 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 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 /**\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 valueBeforeCheck = Number(event.target.value);\n\n const checkedValue = checkForValidAmount({\n minAmount,\n maxAmount,\n amount: Number(event.target.value),\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} />;\n break;\n case 'delete':\n item = <Icon icons={['fa ts-trash']} size={25} />;\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]);\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: 40, opacity: 1, padding: 0 }}\n exit={{ width: 0, opacity: 0, padding: 0 }}\n transition={{ duration: 0.2, type: 'tween' }}\n onClick={handleAmountRemove}\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 onBlur={handleInputBlur}\n onChange={handleInputChange}\n value={displayState === 'default' && label ? label : inputValue}\n type={amountValue === 0 ? 'text' : 'number'}\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: 40, 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 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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;AAE3C,eAAenD,aAAa"}
|
|
@@ -7,6 +7,7 @@ export declare const StyledAmountControl: import("styled-components").IStyledCom
|
|
|
7
7
|
}>>;
|
|
8
8
|
type StyledAmountControlInputProps = WithTheme<{
|
|
9
9
|
$displayState: DisplayState;
|
|
10
|
+
$shouldShowIcon: boolean;
|
|
10
11
|
}>;
|
|
11
12
|
export declare const StyledAmountControlInput: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, StyledAmountControlInputProps>>;
|
|
12
13
|
type StyledAmountControlButtonProps = WithTheme<{
|
|
@@ -31,6 +31,17 @@ export const StyledAmountControlInput = styled.input`
|
|
|
31
31
|
border-top-right-radius: 3px;
|
|
32
32
|
`;
|
|
33
33
|
}}
|
|
34
|
+
|
|
35
|
+
${_ref4 => {
|
|
36
|
+
let {
|
|
37
|
+
$displayState,
|
|
38
|
+
$shouldShowIcon
|
|
39
|
+
} = _ref4;
|
|
40
|
+
return $displayState === 'default' && !$shouldShowIcon && css`
|
|
41
|
+
border-bottom-left-radius: 3px;
|
|
42
|
+
border-top-left-radius: 3px;
|
|
43
|
+
`;
|
|
44
|
+
}}
|
|
34
45
|
`;
|
|
35
46
|
export const StyledMotionAmountControlButton = styled(motion.button)`
|
|
36
47
|
overflow: hidden;
|
|
@@ -38,10 +49,10 @@ export const StyledMotionAmountControlButton = styled(motion.button)`
|
|
|
38
49
|
height: 28px;
|
|
39
50
|
width: 40px;
|
|
40
51
|
|
|
41
|
-
${
|
|
52
|
+
${_ref5 => {
|
|
42
53
|
let {
|
|
43
54
|
$isDisabled
|
|
44
|
-
} =
|
|
55
|
+
} = _ref5;
|
|
45
56
|
return $isDisabled && css`
|
|
46
57
|
opacity: 0.5;
|
|
47
58
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmountControl.styles.js","names":["motion","styled","css","StyledAmountControl","div","_ref","theme","StyledAmountControlInput","input","_ref2","_ref3","$displayState","StyledMotionAmountControlButton","button","
|
|
1
|
+
{"version":3,"file":"AmountControl.styles.js","names":["motion","styled","css","StyledAmountControl","div","_ref","theme","StyledAmountControlInput","input","_ref2","_ref3","$displayState","_ref4","$shouldShowIcon","StyledMotionAmountControlButton","button","_ref5","$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`;\n\ntype StyledAmountControlInputProps = WithTheme<{\n $displayState: DisplayState;\n $shouldShowIcon: boolean;\n}>;\n\nexport const StyledAmountControlInput = styled.input<StyledAmountControlInputProps>`\n background-color: ${({ theme }: StyledAmountControlInputProps) => theme['202']};\n border: none;\n height: 28px;\n width: 95px;\n text-align: center;\n ${({ $displayState }) =>\n $displayState !== 'normal' &&\n css`\n border-bottom-right-radius: 3px;\n border-top-right-radius: 3px;\n `}\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}>;\n\nexport const StyledMotionAmountControlButton = styled(\n motion.button,\n)<StyledAmountControlButtonProps>`\n overflow: hidden;\n background-color: rgba(255, 255, 255, 0.2);\n height: 28px;\n width: 40px;\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,OAAO,MAAMC,mBAAmB,GAAGF,MAAM,CAACG,GAA8B;AACxE,wBAAwBC,IAAA;EAAA,IAAC;IAAEC;EAAgC,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAC9E;AACA;AACA;AACA,CAAC;AAOD,OAAO,MAAMC,wBAAwB,GAAGN,MAAM,CAACO,KAAqC;AACpF,wBAAwBC,KAAA;EAAA,IAAC;IAAEH;EAAqC,CAAC,GAAAG,KAAA;EAAA,OAAKH,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AACnF;AACA;AACA;AACA;AACA,MAAMI,KAAA;EAAA,IAAC;IAAEC;EAAc,CAAC,GAAAD,KAAA;EAAA,OAChBC,aAAa,KAAK,QAAQ,IAC1BT,GAAI;AACZ;AACA;AACA,SAAS;AAAA,CAAC;AACV;AACA,MAAMU,KAAA;EAAA,IAAC;IAAED,aAAa;IAAEE;EAAgB,CAAC,GAAAD,KAAA;EAAA,OACjCD,aAAa,KAAK,SAAS,IAC3B,CAACE,eAAe,IAChBX,GAAI;AACZ;AACA;AACA,SAAS;AAAA,CAAC;AACV,CAAC;AAMD,OAAO,MAAMY,+BAA+B,GAAGb,MAAM,CACjDD,MAAM,CAACe,MACX,CAAkC;AAClC;AACA;AACA;AACA;AACA;AACA,MAAMC,KAAA;EAAA,IAAC;IAAEC;EAAY,CAAC,GAAAD,KAAA;EAAA,OACdC,WAAW,IACXf,GAAI;AACZ;AACA,SAAS;AAAA,CAAC;AACV,CAAC"}
|
|
@@ -81,43 +81,53 @@ export const StyledCheckboxLabel = styled.label`
|
|
|
81
81
|
}
|
|
82
82
|
return $isChecked ? theme['408'] : theme['403'];
|
|
83
83
|
}};
|
|
84
|
-
|
|
84
|
+
|
|
85
|
+
${_ref7 => {
|
|
85
86
|
let {
|
|
86
|
-
|
|
87
|
+
$shouldShowAsSwitch
|
|
87
88
|
} = _ref7;
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
return !$shouldShowAsSwitch && css`
|
|
90
|
+
border: 1px solid
|
|
91
|
+
rgba(${_ref8 => {
|
|
92
|
+
let {
|
|
93
|
+
theme
|
|
94
|
+
} = _ref8;
|
|
95
|
+
return theme['409-rgb'];
|
|
96
|
+
}}, 0.5);
|
|
97
|
+
`;
|
|
98
|
+
}}
|
|
99
|
+
|
|
100
|
+
border-radius: ${_ref9 => {
|
|
91
101
|
let {
|
|
92
102
|
$shouldShowAsSwitch
|
|
93
|
-
} =
|
|
103
|
+
} = _ref9;
|
|
94
104
|
return $shouldShowAsSwitch ? '100px' : 0;
|
|
95
105
|
}};
|
|
96
106
|
content: ' ';
|
|
97
|
-
height: ${
|
|
107
|
+
height: ${_ref10 => {
|
|
98
108
|
let {
|
|
99
109
|
$shouldShowAsSwitch
|
|
100
|
-
} =
|
|
110
|
+
} = _ref10;
|
|
101
111
|
return $shouldShowAsSwitch ? '13px' : '15px';
|
|
102
112
|
}};
|
|
103
|
-
left: ${
|
|
113
|
+
left: ${_ref11 => {
|
|
104
114
|
let {
|
|
105
115
|
$shouldShowAsSwitch
|
|
106
|
-
} =
|
|
116
|
+
} = _ref11;
|
|
107
117
|
return $shouldShowAsSwitch ? '10px' : 0;
|
|
108
118
|
}};
|
|
109
119
|
position: absolute;
|
|
110
120
|
transition: background-color 0.2s ease;
|
|
111
|
-
width: ${
|
|
121
|
+
width: ${_ref12 => {
|
|
112
122
|
let {
|
|
113
123
|
$shouldShowAsSwitch
|
|
114
|
-
} =
|
|
124
|
+
} = _ref12;
|
|
115
125
|
return $shouldShowAsSwitch ? '28px' : '15px';
|
|
116
126
|
}};
|
|
117
|
-
${
|
|
127
|
+
${_ref13 => {
|
|
118
128
|
let {
|
|
119
129
|
$lineHeight
|
|
120
|
-
} =
|
|
130
|
+
} = _ref13;
|
|
121
131
|
return $lineHeight ? css`
|
|
122
132
|
top: ${$lineHeight / 1.5}px;
|
|
123
133
|
transform: translateY(-50%);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.styles.js","names":["styled","css","StyledCheckbox","div","StyledCheckboxInput","input","StyledCheckboxLabel","label","_ref","theme","text","_ref2","$isDisabled","_ref3","_ref4","$shouldShowAsSwitch","_ref5","$isChecked","$lineHeight","_ref6","green","red","_ref7","_ref8","_ref9","_ref10","_ref11","_ref12"],"sources":["../../../src/components/checkbox/Checkbox.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { CheckboxProps } from './Checkbox';\n\nexport const StyledCheckbox = styled.div`\n align-items: center;\n display: flex;\n position: relative;\n`;\n\nexport const StyledCheckboxInput = styled.input`\n display: none;\n`;\n\ntype StyledCheckboxLabelProps = WithTheme<{\n $shouldShowAsSwitch?: CheckboxProps['shouldShowAsSwitch'];\n $isDisabled?: CheckboxProps['isDisabled'];\n $isChecked?: CheckboxProps['isChecked'];\n $lineHeight?: number;\n}>;\n\nexport const StyledCheckboxLabel = styled.label<StyledCheckboxLabelProps>`\n color: ${({ theme }: StyledCheckboxLabelProps) => theme.text};\n cursor: ${({ $isDisabled }) => ($isDisabled ? 'default' : 'pointer')};\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n padding-left: ${({ $shouldShowAsSwitch }) => ($shouldShowAsSwitch ? '48px' : '20px')};\n transition: opacity 0.2s ease;\n user-select: none;\n\n &:after {\n ${({ $isChecked, $shouldShowAsSwitch, $lineHeight }) =>\n $shouldShowAsSwitch\n ? css`\n background-color: white;\n border-radius: 50%;\n box-shadow: 0 1px 4px rgb(0 0 0 / 35%);\n height: 16px;\n left: 7px;\n top: ${$lineHeight ? `${$lineHeight / 1.5}px` : '50%'};\n transform: translateX(${$isChecked ? '18px' : 0}) translateY(-50%);\n transition: transform 0.2s ease;\n width: 16px;\n `\n : css`\n border-right: 2px solid #fff;\n border-bottom: 2px solid #fff;\n height: 10px;\n left: 2px;\n opacity: ${$isChecked ? 1 : 0};\n top: ${$lineHeight\n ? `calc(${$lineHeight / 1.5}px - 2px)`\n : 'calc(50% - 2px)'};\n transform: rotateZ(37deg) translateY(-50%);\n transition: opacity 0.2s ease;\n width: 5.5px;\n `}\n\n content: ' ';\n position: absolute;\n }\n\n &:before {\n background-color: ${({\n $isChecked,\n $shouldShowAsSwitch,\n theme,\n }: StyledCheckboxLabelProps) => {\n if ($shouldShowAsSwitch) {\n return $isChecked ? theme.green : theme.red;\n }\n\n return $isChecked ? theme['408'] : theme['403'];\n }};\n border: 1px solid
|
|
1
|
+
{"version":3,"file":"Checkbox.styles.js","names":["styled","css","StyledCheckbox","div","StyledCheckboxInput","input","StyledCheckboxLabel","label","_ref","theme","text","_ref2","$isDisabled","_ref3","_ref4","$shouldShowAsSwitch","_ref5","$isChecked","$lineHeight","_ref6","green","red","_ref7","_ref8","_ref9","_ref10","_ref11","_ref12","_ref13"],"sources":["../../../src/components/checkbox/Checkbox.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { CheckboxProps } from './Checkbox';\n\nexport const StyledCheckbox = styled.div`\n align-items: center;\n display: flex;\n position: relative;\n`;\n\nexport const StyledCheckboxInput = styled.input`\n display: none;\n`;\n\ntype StyledCheckboxLabelProps = WithTheme<{\n $shouldShowAsSwitch?: CheckboxProps['shouldShowAsSwitch'];\n $isDisabled?: CheckboxProps['isDisabled'];\n $isChecked?: CheckboxProps['isChecked'];\n $lineHeight?: number;\n}>;\n\nexport const StyledCheckboxLabel = styled.label<StyledCheckboxLabelProps>`\n color: ${({ theme }: StyledCheckboxLabelProps) => theme.text};\n cursor: ${({ $isDisabled }) => ($isDisabled ? 'default' : 'pointer')};\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n padding-left: ${({ $shouldShowAsSwitch }) => ($shouldShowAsSwitch ? '48px' : '20px')};\n transition: opacity 0.2s ease;\n user-select: none;\n\n &:after {\n ${({ $isChecked, $shouldShowAsSwitch, $lineHeight }) =>\n $shouldShowAsSwitch\n ? css`\n background-color: white;\n border-radius: 50%;\n box-shadow: 0 1px 4px rgb(0 0 0 / 35%);\n height: 16px;\n left: 7px;\n top: ${$lineHeight ? `${$lineHeight / 1.5}px` : '50%'};\n transform: translateX(${$isChecked ? '18px' : 0}) translateY(-50%);\n transition: transform 0.2s ease;\n width: 16px;\n `\n : css`\n border-right: 2px solid #fff;\n border-bottom: 2px solid #fff;\n height: 10px;\n left: 2px;\n opacity: ${$isChecked ? 1 : 0};\n top: ${$lineHeight\n ? `calc(${$lineHeight / 1.5}px - 2px)`\n : 'calc(50% - 2px)'};\n transform: rotateZ(37deg) translateY(-50%);\n transition: opacity 0.2s ease;\n width: 5.5px;\n `}\n\n content: ' ';\n position: absolute;\n }\n\n &:before {\n background-color: ${({\n $isChecked,\n $shouldShowAsSwitch,\n theme,\n }: StyledCheckboxLabelProps) => {\n if ($shouldShowAsSwitch) {\n return $isChecked ? theme.green : theme.red;\n }\n\n return $isChecked ? theme['408'] : theme['403'];\n }};\n \n ${({ $shouldShowAsSwitch }) =>\n !$shouldShowAsSwitch &&\n css`\n border: 1px solid\n rgba(${({ theme }: StyledCheckboxLabelProps) => theme['409-rgb']}, 0.5);\n `}\n \n border-radius: ${({ $shouldShowAsSwitch }) => ($shouldShowAsSwitch ? '100px' : 0)};\n content: ' ';\n height: ${({ $shouldShowAsSwitch }) => ($shouldShowAsSwitch ? '13px' : '15px')};\n left: ${({ $shouldShowAsSwitch }) => ($shouldShowAsSwitch ? '10px' : 0)};\n position: absolute;\n transition: background-color 0.2s ease;\n width: ${({ $shouldShowAsSwitch }) => ($shouldShowAsSwitch ? '28px' : '15px')};\n ${({ $lineHeight }) =>\n $lineHeight\n ? css`\n top: ${$lineHeight / 1.5}px;\n transform: translateY(-50%);\n `\n : css`\n top: 50%;\n transform: translateY(-50%);\n `}\n }\n }\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,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;AACA;AACA,mBAAmB;AAAA,CAAC;AACpB;AACA;AACA,CAAC"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const StyledContentCard: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").
|
|
2
|
+
export declare const StyledContentCard: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
3
|
+
theme: import("../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
4
|
+
}>>;
|
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
2
|
export const StyledContentCard = styled.div`
|
|
3
|
-
|
|
3
|
+
${_ref => {
|
|
4
4
|
let {
|
|
5
5
|
theme
|
|
6
6
|
} = _ref;
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
border-radius: ${_ref3 => {
|
|
15
|
-
let {
|
|
16
|
-
theme
|
|
17
|
-
} = _ref3;
|
|
18
|
-
return theme.cardBorderRadius;
|
|
19
|
-
}}px;
|
|
20
|
-
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, ${_ref4 => {
|
|
21
|
-
let {
|
|
22
|
-
theme
|
|
23
|
-
} = _ref4;
|
|
24
|
-
return theme.cardShadow;
|
|
25
|
-
}});
|
|
7
|
+
return css`
|
|
8
|
+
background-color: rgba(${theme['100-rgb']}, ${theme.cardBackgroundOpacity});
|
|
9
|
+
border-radius: ${theme.cardBorderRadius}px;
|
|
10
|
+
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, ${theme.cardShadow});
|
|
11
|
+
`;
|
|
12
|
+
}}
|
|
13
|
+
|
|
26
14
|
padding: 8px 12px;
|
|
27
15
|
|
|
28
16
|
&:not(:last-child) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentCard.styles.js","names":["styled","StyledContentCard","div","_ref","theme","
|
|
1
|
+
{"version":3,"file":"ContentCard.styles.js","names":["styled","css","StyledContentCard","div","_ref","theme","cardBackgroundOpacity","cardBorderRadius","cardShadow"],"sources":["../../../src/components/content-card/ContentCard.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledContentCardProps = WithTheme<unknown>;\n\nexport const StyledContentCard = styled.div<StyledContentCardProps>`\n ${({ theme }: StyledContentCardProps) => css`\n background-color: rgba(${theme['100-rgb']}, ${theme.cardBackgroundOpacity});\n border-radius: ${theme.cardBorderRadius}px;\n box-shadow: 0 2px 6px 0 rgba(0, 0, 0, ${theme.cardShadow});\n `}\n\n padding: 8px 12px;\n\n &:not(:last-child) {\n margin-bottom: 8px;\n }\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAK/C,OAAO,MAAMC,iBAAiB,GAAGF,MAAM,CAACG,GAA4B;AACpE,MAAMC,IAAA;EAAA,IAAC;IAAEC;EAA8B,CAAC,GAAAD,IAAA;EAAA,OAAKH,GAAI;AACjD,iCAAiCI,KAAK,CAAC,SAAS,CAAE,KAAIA,KAAK,CAACC,qBAAsB;AAClF,yBAAyBD,KAAK,CAACE,gBAAiB;AAChD,gDAAgDF,KAAK,CAACG,UAAW;AACjE,KAAK;AAAA,CAAC;AACN;AACA;AACA;AACA;AACA;AACA;AACA,CAAC"}
|
|
@@ -10,7 +10,8 @@ const ContextMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
10
10
|
let {
|
|
11
11
|
alignment,
|
|
12
12
|
children = /*#__PURE__*/React.createElement(Icon, {
|
|
13
|
-
icons: ['ts-ellipsis_v']
|
|
13
|
+
icons: ['ts-ellipsis_v'],
|
|
14
|
+
size: 20
|
|
14
15
|
}),
|
|
15
16
|
container = document.body,
|
|
16
17
|
coordinates,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","names":["AnimatePresence","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","createPortal","useUuid","ContextMenuAlignment","Icon","ContextMenuContent","StyledContextMenu","ContextMenu","_ref","ref","alignment","children","createElement","icons","container","document","body","coordinates","items","onHide","onShow","shouldCloseOnPopupClick","internalCoordinates","setInternalCoordinates","x","y","internalAlignment","setInternalAlignment","TopLeft","isContentShown","setIsContentShown","portal","setPortal","uuid","contextMenuContentRef","contextMenuRef","handleHide","handleShow","isMobile","isTablet","chayns","env","buttonType","selection","dialog","select","buttons","list","map","_ref2","index","text","name","value","icon","type","onClick","current","rootElement","querySelector","height","childrenHeight","width","childrenWidth","getBoundingClientRect","BottomRight","TopRight","BottomLeft","handleClick","event","preventDefault","stopPropagation","handleDocumentClick","contains","target","hide","show","addEventListener","window","removeEventListener","initial","key","Fragment","className","displayName"],"sources":["../../../src/components/context-menu/ContextMenu.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n forwardRef,\n MouseEvent,\n MouseEventHandler,\n ReactNode,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { ContextMenuAlignment } from '../../types/contextMenu';\nimport Icon from '../icon/Icon';\nimport ContextMenuContent from './context-menu-content/ContextMenuContent';\nimport { StyledContextMenu } from './ContextMenu.styles';\n\nexport type ContextMenuCoordinates = {\n x: number;\n y: number;\n};\n\nexport type ContextMenuItem = {\n icons: string[];\n key: string;\n onClick: (event?: MouseEvent<HTMLDivElement>) => Promise<void> | void;\n text: string;\n};\n\nexport type ContextMenuRef = {\n hide: VoidFunction;\n show: VoidFunction;\n};\n\ntype ContextMenuProps = {\n /**\n * Optional custom alignment used instead of calculating it using the\n * alignment within the page. The available alignment can be taken from the\n * ContextMenuAlignment enum.\n */\n alignment?: ContextMenuAlignment;\n /**\n * The element over which the content of the `ContextMenu` should be displayed.\n */\n children?: ReactNode;\n /**\n * The element where the content of the `ContextMenu` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * Optional own coordinates to be used instead of calculating the alignment\n * based on the alignment of the children.\n */\n coordinates?: ContextMenuCoordinates;\n /**\n * The items that will be displayed in the content of the `ContextMenu`.\n */\n items: ContextMenuItem[];\n /**\n * Function to be executed when the content of the Context menu has been hidden.\n */\n onHide?: VoidFunction;\n /**\n * Function to be executed when the content of the Context menu has been shown.\n */\n onShow?: VoidFunction;\n /**\n * Whether the popup should be closed if its clicked.\n */\n shouldCloseOnPopupClick?: boolean;\n};\n\nconst ContextMenu = forwardRef<ContextMenuRef, ContextMenuProps>(\n (\n {\n alignment,\n children = <Icon icons={['ts-ellipsis_v']} />,\n container = document.body,\n coordinates,\n items,\n onHide,\n onShow,\n shouldCloseOnPopupClick = true,\n },\n ref,\n ) => {\n const [internalCoordinates, setInternalCoordinates] = useState<ContextMenuCoordinates>({\n x: 0,\n y: 0,\n });\n const [internalAlignment, setInternalAlignment] = useState<ContextMenuAlignment>(\n ContextMenuAlignment.TopLeft,\n );\n const [isContentShown, setIsContentShown] = useState(false);\n const [portal, setPortal] = useState<ReactPortal>();\n\n const uuid = useUuid();\n\n // ToDo: Replace with hook if new chayns api is ready\n const contextMenuContentRef = useRef<HTMLDivElement>(null);\n const contextMenuRef = useRef<HTMLSpanElement>(null);\n\n const handleHide = useCallback(() => {\n setIsContentShown(false);\n }, []);\n\n const handleShow = useCallback(async () => {\n const { isMobile, isTablet } = chayns.env;\n\n if (isMobile || isTablet) {\n // ToDo: Replace with new api function if new api is ready\n const { buttonType, selection } = await chayns.dialog.select({\n buttons: [],\n list: items.map(({ icons, text }, index) => ({\n name: text,\n value: index,\n icon: icons[0],\n })),\n type: 2,\n });\n\n if (buttonType === 1 && typeof selection[0]?.value === 'number') {\n void items[selection[0].value]?.onClick();\n }\n } else if (contextMenuRef.current) {\n const rootElement = document.querySelector('.tapp') || document.body;\n\n const {\n x,\n y,\n height: childrenHeight,\n width: childrenWidth,\n } = contextMenuRef.current.getBoundingClientRect();\n\n setInternalCoordinates({ x: x + childrenWidth / 2, y: y + childrenHeight / 2 });\n\n const { height, width } = rootElement.getBoundingClientRect();\n\n if (x < width / 2) {\n if (y < height / 2) {\n setInternalAlignment(ContextMenuAlignment.BottomRight);\n } else {\n setInternalAlignment(ContextMenuAlignment.TopRight);\n }\n } else if (y < height / 2) {\n setInternalAlignment(ContextMenuAlignment.BottomLeft);\n } else {\n setInternalAlignment(ContextMenuAlignment.TopLeft);\n }\n\n setIsContentShown(true);\n }\n }, [items]);\n\n const handleClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n void handleShow();\n },\n [handleShow],\n );\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (\n !shouldCloseOnPopupClick &&\n contextMenuContentRef.current?.contains(event.target as Node)\n ) {\n return;\n }\n\n handleHide();\n },\n [handleHide, shouldCloseOnPopupClick],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow],\n );\n\n useEffect(() => {\n if (isContentShown) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n\n if (typeof onShow === 'function') {\n onShow();\n }\n } else if (typeof onHide === 'function') {\n onHide();\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, isContentShown, onHide, onShow]);\n\n useEffect(() => {\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isContentShown && (\n <ContextMenuContent\n coordinates={coordinates ?? internalCoordinates}\n items={items}\n key={`contextMenu_${uuid}`}\n alignment={alignment ?? internalAlignment}\n ref={contextMenuContentRef}\n />\n )}\n </AnimatePresence>,\n container,\n ),\n );\n }, [\n alignment,\n container,\n coordinates,\n internalAlignment,\n internalCoordinates,\n isContentShown,\n items,\n uuid,\n ]);\n\n return (\n <>\n <StyledContextMenu\n className=\"beta-chayns-context-menu\"\n onClick={handleClick}\n ref={contextMenuRef}\n >\n {children}\n </StyledContextMenu>\n {portal}\n </>\n );\n },\n);\n\nContextMenu.displayName = 'ContextMenu';\n\nexport default ContextMenu;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IACRC,UAAU,EAKVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,kBAAkB,MAAM,2CAA2C;AAC1E,SAASC,iBAAiB,QAAQ,sBAAsB;AAyDxD,MAAMC,WAAW,gBAAGZ,UAAU,CAC1B,CAAAa,IAAA,EAWIC,GAAG,KACF;EAAA,IAXD;IACIC,SAAS;IACTC,QAAQ,gBAAGjB,KAAA,CAAAkB,aAAA,CAACR,IAAI;MAACS,KAAK,EAAE,CAAC,eAAe;IAAE,CAAE,CAAC;IAC7CC,SAAS,GAAGC,QAAQ,CAACC,IAAI;IACzBC,WAAW;IACXC,KAAK;IACLC,MAAM;IACNC,MAAM;IACNC,uBAAuB,GAAG;EAC9B,CAAC,GAAAb,IAAA;EAGD,MAAM,CAACc,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGvB,QAAQ,CAAyB;IACnFwB,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE;EACP,CAAC,CAAC;EACF,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAG3B,QAAQ,CACtDG,oBAAoB,CAACyB,OACzB,CAAC;EACD,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAG9B,QAAQ,CAAC,K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AAG,eAAchD,IAAK,EAAE;MAC3BvB,SAAS,EAAEA,SAAS,IAAIgB,iBAAkB;MAC1CjB,GAAG,EAAEyB;IAAsB,CAC9B,CAEQ,CAAC,EAClBpB,SACJ,CACJ,CAAC;EACL,CAAC,EAAE,CACCJ,SAAS,EACTI,SAAS,EACTG,WAAW,EACXS,iBAAiB,EACjBJ,mBAAmB,EACnBO,cAAc,EACdX,KAAK,EACLe,IAAI,CACP,CAAC;EAEF,oBACIvC,KAAA,CAAAkB,aAAA,CAAAlB,KAAA,CAAAwF,QAAA,qBACIxF,KAAA,CAAAkB,aAAA,CAACN,iBAAiB;IACd6E,SAAS,EAAC,0BAA0B;IACpC3B,OAAO,EAAEY,WAAY;IACrB3D,GAAG,EAAE0B;EAAe,GAEnBxB,QACc,CAAC,EACnBoB,MACH,CAAC;AAEX,CACJ,CAAC;AAEDxB,WAAW,CAAC6E,WAAW,GAAG,aAAa;AAEvC,eAAe7E,WAAW"}
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","names":["AnimatePresence","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","createPortal","useUuid","ContextMenuAlignment","Icon","ContextMenuContent","StyledContextMenu","ContextMenu","_ref","ref","alignment","children","createElement","icons","size","container","document","body","coordinates","items","onHide","onShow","shouldCloseOnPopupClick","internalCoordinates","setInternalCoordinates","x","y","internalAlignment","setInternalAlignment","TopLeft","isContentShown","setIsContentShown","portal","setPortal","uuid","contextMenuContentRef","contextMenuRef","handleHide","handleShow","isMobile","isTablet","chayns","env","buttonType","selection","dialog","select","buttons","list","map","_ref2","index","text","name","value","icon","type","onClick","current","rootElement","querySelector","height","childrenHeight","width","childrenWidth","getBoundingClientRect","BottomRight","TopRight","BottomLeft","handleClick","event","preventDefault","stopPropagation","handleDocumentClick","contains","target","hide","show","addEventListener","window","removeEventListener","initial","key","Fragment","className","displayName"],"sources":["../../../src/components/context-menu/ContextMenu.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n forwardRef,\n MouseEvent,\n MouseEventHandler,\n ReactNode,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { ContextMenuAlignment } from '../../types/contextMenu';\nimport Icon from '../icon/Icon';\nimport ContextMenuContent from './context-menu-content/ContextMenuContent';\nimport { StyledContextMenu } from './ContextMenu.styles';\n\nexport type ContextMenuCoordinates = {\n x: number;\n y: number;\n};\n\nexport type ContextMenuItem = {\n icons: string[];\n key: string;\n onClick: (event?: MouseEvent<HTMLDivElement>) => Promise<void> | void;\n text: string;\n};\n\nexport type ContextMenuRef = {\n hide: VoidFunction;\n show: VoidFunction;\n};\n\ntype ContextMenuProps = {\n /**\n * Optional custom alignment used instead of calculating it using the\n * alignment within the page. The available alignment can be taken from the\n * ContextMenuAlignment enum.\n */\n alignment?: ContextMenuAlignment;\n /**\n * The element over which the content of the `ContextMenu` should be displayed.\n */\n children?: ReactNode;\n /**\n * The element where the content of the `ContextMenu` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * Optional own coordinates to be used instead of calculating the alignment\n * based on the alignment of the children.\n */\n coordinates?: ContextMenuCoordinates;\n /**\n * The items that will be displayed in the content of the `ContextMenu`.\n */\n items: ContextMenuItem[];\n /**\n * Function to be executed when the content of the Context menu has been hidden.\n */\n onHide?: VoidFunction;\n /**\n * Function to be executed when the content of the Context menu has been shown.\n */\n onShow?: VoidFunction;\n /**\n * Whether the popup should be closed if its clicked.\n */\n shouldCloseOnPopupClick?: boolean;\n};\n\nconst ContextMenu = forwardRef<ContextMenuRef, ContextMenuProps>(\n (\n {\n alignment,\n children = <Icon icons={['ts-ellipsis_v']} size={20} />,\n container = document.body,\n coordinates,\n items,\n onHide,\n onShow,\n shouldCloseOnPopupClick = true,\n },\n ref,\n ) => {\n const [internalCoordinates, setInternalCoordinates] = useState<ContextMenuCoordinates>({\n x: 0,\n y: 0,\n });\n const [internalAlignment, setInternalAlignment] = useState<ContextMenuAlignment>(\n ContextMenuAlignment.TopLeft,\n );\n const [isContentShown, setIsContentShown] = useState(false);\n const [portal, setPortal] = useState<ReactPortal>();\n\n const uuid = useUuid();\n\n // ToDo: Replace with hook if new chayns api is ready\n const contextMenuContentRef = useRef<HTMLDivElement>(null);\n const contextMenuRef = useRef<HTMLSpanElement>(null);\n\n const handleHide = useCallback(() => {\n setIsContentShown(false);\n }, []);\n\n const handleShow = useCallback(async () => {\n const { isMobile, isTablet } = chayns.env;\n\n if (isMobile || isTablet) {\n // ToDo: Replace with new api function if new api is ready\n const { buttonType, selection } = await chayns.dialog.select({\n buttons: [],\n list: items.map(({ icons, text }, index) => ({\n name: text,\n value: index,\n icon: icons[0],\n })),\n type: 2,\n });\n\n if (buttonType === 1 && typeof selection[0]?.value === 'number') {\n void items[selection[0].value]?.onClick();\n }\n } else if (contextMenuRef.current) {\n const rootElement = document.querySelector('.tapp') || document.body;\n\n const {\n x,\n y,\n height: childrenHeight,\n width: childrenWidth,\n } = contextMenuRef.current.getBoundingClientRect();\n\n setInternalCoordinates({ x: x + childrenWidth / 2, y: y + childrenHeight / 2 });\n\n const { height, width } = rootElement.getBoundingClientRect();\n\n if (x < width / 2) {\n if (y < height / 2) {\n setInternalAlignment(ContextMenuAlignment.BottomRight);\n } else {\n setInternalAlignment(ContextMenuAlignment.TopRight);\n }\n } else if (y < height / 2) {\n setInternalAlignment(ContextMenuAlignment.BottomLeft);\n } else {\n setInternalAlignment(ContextMenuAlignment.TopLeft);\n }\n\n setIsContentShown(true);\n }\n }, [items]);\n\n const handleClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n void handleShow();\n },\n [handleShow],\n );\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (\n !shouldCloseOnPopupClick &&\n contextMenuContentRef.current?.contains(event.target as Node)\n ) {\n return;\n }\n\n handleHide();\n },\n [handleHide, shouldCloseOnPopupClick],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow],\n );\n\n useEffect(() => {\n if (isContentShown) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n\n if (typeof onShow === 'function') {\n onShow();\n }\n } else if (typeof onHide === 'function') {\n onHide();\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, isContentShown, onHide, onShow]);\n\n useEffect(() => {\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isContentShown && (\n <ContextMenuContent\n coordinates={coordinates ?? internalCoordinates}\n items={items}\n key={`contextMenu_${uuid}`}\n alignment={alignment ?? internalAlignment}\n ref={contextMenuContentRef}\n />\n )}\n </AnimatePresence>,\n container,\n ),\n );\n }, [\n alignment,\n container,\n coordinates,\n internalAlignment,\n internalCoordinates,\n isContentShown,\n items,\n uuid,\n ]);\n\n return (\n <>\n <StyledContextMenu\n className=\"beta-chayns-context-menu\"\n onClick={handleClick}\n ref={contextMenuRef}\n >\n {children}\n </StyledContextMenu>\n {portal}\n </>\n );\n },\n);\n\nContextMenu.displayName = 'ContextMenu';\n\nexport default ContextMenu;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IACRC,UAAU,EAKVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,kBAAkB,MAAM,2CAA2C;AAC1E,SAASC,iBAAiB,QAAQ,sBAAsB;AAyDxD,MAAMC,WAAW,gBAAGZ,UAAU,CAC1B,CAAAa,IAAA,EAWIC,GAAG,KACF;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**
|
|
4
4
|
* An array of icons that should be displayed inside the FileInput
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
fileSelectionIcons?: string[];
|
|
7
|
+
/**
|
|
8
|
+
* The text that should be displayed inside the FileInput.
|
|
9
|
+
*/
|
|
10
|
+
fileSelectionPlaceholder?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The filetypes that could be selected. Example for multiple types: 'image/*, video/*'.
|
|
13
|
+
*/
|
|
14
|
+
fileTypes?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The icon of the image selection.
|
|
17
|
+
*/
|
|
18
|
+
imageSelectIcons?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* If set, pictures can be select via Pixabay.
|
|
21
|
+
*/
|
|
22
|
+
imageSelectPlaceholder?: string;
|
|
7
23
|
/**
|
|
8
24
|
* The maximum amount of Files that can be uploaded.
|
|
9
25
|
*/
|
|
@@ -11,7 +27,7 @@ export type FileInputProps = {
|
|
|
11
27
|
/**
|
|
12
28
|
* A function to be executed when files are added.
|
|
13
29
|
*/
|
|
14
|
-
onAdd?: (files: File[]) => void;
|
|
30
|
+
onAdd?: (files: File[] | string[]) => void;
|
|
15
31
|
/**
|
|
16
32
|
* Function to be executed when the maximum amount of Files are reached.
|
|
17
33
|
*/
|
|
@@ -19,11 +35,7 @@ export type FileInputProps = {
|
|
|
19
35
|
/**
|
|
20
36
|
* A function to be executed when a file is removed.
|
|
21
37
|
*/
|
|
22
|
-
onRemove?: (file: File) => void;
|
|
23
|
-
/**
|
|
24
|
-
* The text that should be displayed inside the FileInput
|
|
25
|
-
*/
|
|
26
|
-
placeholder?: string;
|
|
38
|
+
onRemove?: (file: File | string) => void;
|
|
27
39
|
};
|
|
28
40
|
declare const FileInput: FC<FileInputProps>;
|
|
29
41
|
export default FileInput;
|