@chayns-components/core 5.0.0-beta.920 → 5.0.0-beta.922
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/input/Input.js +6 -3
- package/lib/cjs/components/input/Input.js.map +1 -1
- package/lib/cjs/utils/file.js +20 -378
- package/lib/cjs/utils/file.js.map +1 -1
- package/lib/esm/components/input/Input.js +6 -3
- package/lib/esm/components/input/Input.js.map +1 -1
- package/lib/esm/utils/file.js +18 -376
- package/lib/esm/utils/file.js.map +1 -1
- package/lib/types/components/input/Input.d.ts +4 -0
- package/lib/types/utils/file.d.ts +4 -357
- package/package.json +2 -2
|
@@ -37,6 +37,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
37
37
|
value,
|
|
38
38
|
shouldUseAutoFocus = false,
|
|
39
39
|
isInvalid = false,
|
|
40
|
+
shouldPreventPlaceholderAnimation = false,
|
|
40
41
|
id
|
|
41
42
|
}, ref) => {
|
|
42
43
|
var _rightElement$props;
|
|
@@ -85,7 +86,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
85
86
|
}
|
|
86
87
|
}, [value]);
|
|
87
88
|
const labelPosition = (0, _react.useMemo)(() => {
|
|
88
|
-
if (hasValue && !shouldRemainPlaceholder) {
|
|
89
|
+
if (hasValue && !shouldRemainPlaceholder && !shouldPreventPlaceholderAnimation) {
|
|
89
90
|
return shouldShowOnlyBottomBorder ? {
|
|
90
91
|
right: 3,
|
|
91
92
|
top: -1.5
|
|
@@ -125,7 +126,9 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
125
126
|
$isInvalid: isInvalid,
|
|
126
127
|
$shouldShowCenteredContent: shouldShowCenteredContent
|
|
127
128
|
}), /*#__PURE__*/_react.default.createElement(_Input.StyledMotionInputLabelWrapper, {
|
|
128
|
-
animate: {
|
|
129
|
+
animate: shouldPreventPlaceholderAnimation ? {
|
|
130
|
+
opacity: hasValue ? 0 : 1
|
|
131
|
+
} : {
|
|
129
132
|
fontSize: hasValue && !shouldShowOnlyBottomBorder && !shouldRemainPlaceholder ? '9px' : '16px'
|
|
130
133
|
},
|
|
131
134
|
initial: false,
|
|
@@ -136,7 +139,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
136
139
|
},
|
|
137
140
|
transition: {
|
|
138
141
|
type: 'tween',
|
|
139
|
-
duration: 0.1
|
|
142
|
+
duration: shouldPreventPlaceholderAnimation ? 0 : 0.1
|
|
140
143
|
}
|
|
141
144
|
}, /*#__PURE__*/_react.default.createElement(_Input.StyledInputLabel, {
|
|
142
145
|
$isInvalid: isInvalid
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_useElementSize","_AreaContextProvider","_Icon","_interopRequireDefault","_Input","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","InputSize","exports","Input","forwardRef","leftElement","inputMode","isDisabled","onBlur","onChange","onFocus","onKeyDown","placeholder","rightElement","shouldShowOnlyBottomBorder","shouldRemainPlaceholder","shouldShowClearIcon","shouldShowCenteredContent","size","Medium","type","value","shouldUseAutoFocus","isInvalid","id","ref","_rightElement$props","hasValue","setHasValue","useState","placeholderWidth","setPlaceholderWidth","areaProvider","useContext","AreaContext","theme","useTheme","inputRef","useRef","placeholderRef","placeholderSize","useElementSize","useEffect","width","shouldChangeColor","useMemo","handleClearIconClick","useCallback","current","target","shouldShowBorder","props","style","backgroundColor","undefined","handleInputFieldChange","event","useImperativeHandle","focus","_inputRef$current","labelPosition","right","top","bottom","Small","left","createElement","StyledInput","className","$isDisabled","StyledInputContentWrapper","$shouldChangeColor","$isInvalid","$shouldRoundRightCorners","$shouldShowOnlyBottomBorder","$size","StyledInputIconWrapper","StyledInputContent","StyledInputField","$placeholderWidth","disabled","autoFocus","$shouldShowCenteredContent","StyledMotionInputLabelWrapper","animate","fontSize","initial","layout","transition","duration","StyledInputLabel","StyledMotionInputClearIcon","opacity","onClick","icons","color","wrong","StyledInputRightElement","displayName","_default"],"sources":["../../../../src/components/input/Input.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n HTMLInputTypeAttribute,\n KeyboardEventHandler,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type ReactElement,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { useElementSize } from '../../hooks/useElementSize';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledInput,\n StyledInputContent,\n StyledInputContentWrapper,\n StyledInputField,\n StyledInputIconWrapper,\n StyledInputLabel,\n StyledInputRightElement,\n StyledMotionInputClearIcon,\n StyledMotionInputLabelWrapper,\n} from './Input.styles';\n\nexport type InputRef = {\n focus: VoidFunction;\n};\n\ntype InputMode =\n | 'email'\n | 'search'\n | 'tel'\n | 'text'\n | 'url'\n | 'none'\n | 'numeric'\n | 'decimal'\n | undefined;\n\nexport enum InputSize {\n Small = 'small',\n Medium = 'medium',\n}\n\nexport type InputProps = {\n /**\n * An element to be displayed on the left side of the input field\n */\n leftElement?: ReactNode;\n /**\n * The id of the input\n */\n id?: string;\n /**\n * Defines the input mode of the input\n */\n inputMode?: InputMode;\n /**\n * Disables the input so that it cannot be changed anymore\n */\n isDisabled?: boolean;\n /**\n * If true, the input field is marked as invalid\n */\n isInvalid?: boolean;\n /**\n * Function that is executed when the input field loses focus\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the text of the input changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the input field is focused\n */\n onFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when a letter is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * An element that should be displayed on the right side of the Input.\n */\n rightElement?: ReactElement;\n /**\n * Whether the placeholder should remain at its position if a value is typed.\n */\n shouldRemainPlaceholder?: boolean;\n /**\n * Whether the content should be displayed centered inside the input.\n */\n shouldShowCenteredContent?: boolean;\n /**\n * If true, a clear icon is displayed at the end of the input field\n */\n shouldShowClearIcon?: boolean;\n /**\n * Whether only the bottom border should be displayed\n */\n shouldShowOnlyBottomBorder?: boolean;\n /**\n * If true, the input field is focused when the component is mounted\n */\n shouldUseAutoFocus?: boolean;\n /**\n * The size of the input field\n */\n size?: InputSize;\n /**\n * Input type set for input element (e.g. 'text', 'number' or 'password')\n */\n type?: HTMLInputTypeAttribute;\n /**\n * Value if the input field should be controlled\n */\n value?: string;\n};\n\nconst Input = forwardRef<InputRef, InputProps>(\n (\n {\n leftElement,\n inputMode,\n isDisabled,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n placeholder,\n rightElement,\n shouldShowOnlyBottomBorder,\n shouldRemainPlaceholder = false,\n shouldShowClearIcon = false,\n shouldShowCenteredContent = false,\n size = InputSize.Medium,\n type = 'text',\n value,\n shouldUseAutoFocus = false,\n isInvalid = false,\n id,\n },\n ref,\n ) => {\n const [hasValue, setHasValue] = useState(typeof value === 'string' && value !== '');\n const [placeholderWidth, setPlaceholderWidth] = useState(0);\n\n const areaProvider = useContext(AreaContext);\n\n const theme = useTheme() as Theme;\n\n const inputRef = useRef<HTMLInputElement>(null);\n const placeholderRef = useRef<HTMLLabelElement>(null);\n\n const placeholderSize = useElementSize(placeholderRef);\n\n useEffect(() => {\n if (placeholderSize && shouldShowOnlyBottomBorder) {\n setPlaceholderWidth(placeholderSize.width + 5);\n }\n }, [placeholderSize, shouldShowOnlyBottomBorder]);\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n const handleClearIconClick = useCallback(() => {\n if (inputRef.current) {\n inputRef.current.value = '';\n\n setHasValue(false);\n\n if (typeof onChange === 'function') {\n onChange({ target: inputRef.current } as ChangeEvent<HTMLInputElement>);\n }\n }\n }, [onChange]);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const shouldShowBorder = rightElement?.props?.style?.backgroundColor === undefined;\n\n const handleInputFieldChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setHasValue(event.target.value !== '');\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n focus: () => inputRef.current?.focus(),\n }),\n [],\n );\n\n useEffect(() => {\n if (typeof value === 'string') {\n setHasValue(value !== '');\n }\n }, [value]);\n\n const labelPosition = useMemo(() => {\n if (hasValue && !shouldRemainPlaceholder) {\n return shouldShowOnlyBottomBorder\n ? { right: 3, top: -1.5 }\n : { bottom: size === InputSize.Small ? -4 : -10, right: -6 };\n }\n\n return { left: -1 };\n }, [hasValue, shouldRemainPlaceholder, shouldShowOnlyBottomBorder, size]);\n\n return (\n <StyledInput className=\"beta-chayns-input\" $isDisabled={isDisabled}>\n <StyledInputContentWrapper\n $shouldChangeColor={shouldChangeColor}\n $isInvalid={isInvalid}\n $shouldRoundRightCorners={shouldShowBorder}\n $shouldShowOnlyBottomBorder={shouldShowOnlyBottomBorder}\n $size={size}\n >\n {leftElement && <StyledInputIconWrapper>{leftElement}</StyledInputIconWrapper>}\n <StyledInputContent $shouldShowOnlyBottomBorder={shouldShowOnlyBottomBorder}>\n <StyledInputField\n $placeholderWidth={placeholderWidth}\n id={id}\n disabled={isDisabled}\n onBlur={onBlur}\n onChange={handleInputFieldChange}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n ref={inputRef}\n type={type}\n value={value}\n autoFocus={shouldUseAutoFocus}\n inputMode={inputMode}\n $isInvalid={isInvalid}\n $shouldShowCenteredContent={shouldShowCenteredContent}\n />\n <StyledMotionInputLabelWrapper\n animate={{\n fontSize:\n hasValue &&\n !shouldShowOnlyBottomBorder &&\n !shouldRemainPlaceholder\n ? '9px'\n : '16px',\n }}\n initial={false}\n layout\n ref={placeholderRef}\n style={{ ...labelPosition }}\n transition={{ type: 'tween', duration: 0.1 }}\n >\n <StyledInputLabel $isInvalid={isInvalid}>\n {placeholder}\n </StyledInputLabel>\n </StyledMotionInputLabelWrapper>\n </StyledInputContent>\n {shouldShowClearIcon && (\n <StyledMotionInputClearIcon\n $shouldShowOnlyBottomBorder={shouldShowOnlyBottomBorder}\n $size={size}\n animate={{ opacity: hasValue ? 1 : 0 }}\n initial={false}\n onClick={handleClearIconClick}\n transition={{ type: 'tween' }}\n >\n <Icon\n icons={['fa fa-times']}\n color={isInvalid ? theme.wrong : undefined}\n />\n </StyledMotionInputClearIcon>\n )}\n {rightElement && shouldShowBorder && rightElement}\n </StyledInputContentWrapper>\n {rightElement && !shouldShowBorder && (\n <StyledInputRightElement>{rightElement}</StyledInputRightElement>\n )}\n </StyledInput>\n );\n },\n);\n\nInput.displayName = 'Input';\n\nexport default Input;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAiBA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAUwB,SAAAK,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAA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,IAAIrC,YACd,CAAC,EAC3BA,YAAY,IAAI,CAACqC,gBAAgB,iBAC9B9E,MAAA,CAAAW,OAAA,CAAAmF,aAAA,CAACtF,MAAA,CAAAqH,uBAAuB,QAAEpF,YAAsC,CAE3D,CAAC;AAEtB,CACJ,CAAC;AAEDV,KAAK,CAAC+F,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAjG,OAAA,CAAAnB,OAAA,GAEboB,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Input.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_useElementSize","_AreaContextProvider","_Icon","_interopRequireDefault","_Input","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","InputSize","exports","Input","forwardRef","leftElement","inputMode","isDisabled","onBlur","onChange","onFocus","onKeyDown","placeholder","rightElement","shouldShowOnlyBottomBorder","shouldRemainPlaceholder","shouldShowClearIcon","shouldShowCenteredContent","size","Medium","type","value","shouldUseAutoFocus","isInvalid","shouldPreventPlaceholderAnimation","id","ref","_rightElement$props","hasValue","setHasValue","useState","placeholderWidth","setPlaceholderWidth","areaProvider","useContext","AreaContext","theme","useTheme","inputRef","useRef","placeholderRef","placeholderSize","useElementSize","useEffect","width","shouldChangeColor","useMemo","handleClearIconClick","useCallback","current","target","shouldShowBorder","props","style","backgroundColor","undefined","handleInputFieldChange","event","useImperativeHandle","focus","_inputRef$current","labelPosition","right","top","bottom","Small","left","createElement","StyledInput","className","$isDisabled","StyledInputContentWrapper","$shouldChangeColor","$isInvalid","$shouldRoundRightCorners","$shouldShowOnlyBottomBorder","$size","StyledInputIconWrapper","StyledInputContent","StyledInputField","$placeholderWidth","disabled","autoFocus","$shouldShowCenteredContent","StyledMotionInputLabelWrapper","animate","opacity","fontSize","initial","layout","transition","duration","StyledInputLabel","StyledMotionInputClearIcon","onClick","icons","color","wrong","StyledInputRightElement","displayName","_default"],"sources":["../../../../src/components/input/Input.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n HTMLInputTypeAttribute,\n KeyboardEventHandler,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type ReactElement,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { useElementSize } from '../../hooks/useElementSize';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledInput,\n StyledInputContent,\n StyledInputContentWrapper,\n StyledInputField,\n StyledInputIconWrapper,\n StyledInputLabel,\n StyledInputRightElement,\n StyledMotionInputClearIcon,\n StyledMotionInputLabelWrapper,\n} from './Input.styles';\n\nexport type InputRef = {\n focus: VoidFunction;\n};\n\ntype InputMode =\n | 'email'\n | 'search'\n | 'tel'\n | 'text'\n | 'url'\n | 'none'\n | 'numeric'\n | 'decimal'\n | undefined;\n\nexport enum InputSize {\n Small = 'small',\n Medium = 'medium',\n}\n\nexport type InputProps = {\n /**\n * An element to be displayed on the left side of the input field\n */\n leftElement?: ReactNode;\n /**\n * The id of the input\n */\n id?: string;\n /**\n * Defines the input mode of the input\n */\n inputMode?: InputMode;\n /**\n * Disables the input so that it cannot be changed anymore\n */\n isDisabled?: boolean;\n /**\n * If true, the input field is marked as invalid\n */\n isInvalid?: boolean;\n /**\n * Function that is executed when the input field loses focus\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the text of the input changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the input field is focused\n */\n onFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when a letter is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * An element that should be displayed on the right side of the Input.\n */\n rightElement?: ReactElement;\n /**\n * Whether the placeholder animation should be prevented.\n */\n shouldPreventPlaceholderAnimation?: boolean;\n /**\n * Whether the placeholder should remain at its position if a value is typed.\n */\n shouldRemainPlaceholder?: boolean;\n /**\n * Whether the content should be displayed centered inside the input.\n */\n shouldShowCenteredContent?: boolean;\n /**\n * If true, a clear icon is displayed at the end of the input field\n */\n shouldShowClearIcon?: boolean;\n /**\n * Whether only the bottom border should be displayed\n */\n shouldShowOnlyBottomBorder?: boolean;\n /**\n * If true, the input field is focused when the component is mounted\n */\n shouldUseAutoFocus?: boolean;\n /**\n * The size of the input field\n */\n size?: InputSize;\n /**\n * Input type set for input element (e.g. 'text', 'number' or 'password')\n */\n type?: HTMLInputTypeAttribute;\n /**\n * Value if the input field should be controlled\n */\n value?: string;\n};\n\nconst Input = forwardRef<InputRef, InputProps>(\n (\n {\n leftElement,\n inputMode,\n isDisabled,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n placeholder,\n rightElement,\n shouldShowOnlyBottomBorder,\n shouldRemainPlaceholder = false,\n shouldShowClearIcon = false,\n shouldShowCenteredContent = false,\n size = InputSize.Medium,\n type = 'text',\n value,\n shouldUseAutoFocus = false,\n isInvalid = false,\n shouldPreventPlaceholderAnimation = false,\n id,\n },\n ref,\n ) => {\n const [hasValue, setHasValue] = useState(typeof value === 'string' && value !== '');\n const [placeholderWidth, setPlaceholderWidth] = useState(0);\n\n const areaProvider = useContext(AreaContext);\n\n const theme = useTheme() as Theme;\n\n const inputRef = useRef<HTMLInputElement>(null);\n const placeholderRef = useRef<HTMLLabelElement>(null);\n\n const placeholderSize = useElementSize(placeholderRef);\n\n useEffect(() => {\n if (placeholderSize && shouldShowOnlyBottomBorder) {\n setPlaceholderWidth(placeholderSize.width + 5);\n }\n }, [placeholderSize, shouldShowOnlyBottomBorder]);\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n const handleClearIconClick = useCallback(() => {\n if (inputRef.current) {\n inputRef.current.value = '';\n\n setHasValue(false);\n\n if (typeof onChange === 'function') {\n onChange({ target: inputRef.current } as ChangeEvent<HTMLInputElement>);\n }\n }\n }, [onChange]);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const shouldShowBorder = rightElement?.props?.style?.backgroundColor === undefined;\n\n const handleInputFieldChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setHasValue(event.target.value !== '');\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n focus: () => inputRef.current?.focus(),\n }),\n [],\n );\n\n useEffect(() => {\n if (typeof value === 'string') {\n setHasValue(value !== '');\n }\n }, [value]);\n\n const labelPosition = useMemo(() => {\n if (hasValue && !shouldRemainPlaceholder && !shouldPreventPlaceholderAnimation) {\n return shouldShowOnlyBottomBorder\n ? { right: 3, top: -1.5 }\n : { bottom: size === InputSize.Small ? -4 : -10, right: -6 };\n }\n\n return { left: -1 };\n }, [hasValue, shouldRemainPlaceholder, shouldShowOnlyBottomBorder, size]);\n\n return (\n <StyledInput className=\"beta-chayns-input\" $isDisabled={isDisabled}>\n <StyledInputContentWrapper\n $shouldChangeColor={shouldChangeColor}\n $isInvalid={isInvalid}\n $shouldRoundRightCorners={shouldShowBorder}\n $shouldShowOnlyBottomBorder={shouldShowOnlyBottomBorder}\n $size={size}\n >\n {leftElement && <StyledInputIconWrapper>{leftElement}</StyledInputIconWrapper>}\n <StyledInputContent $shouldShowOnlyBottomBorder={shouldShowOnlyBottomBorder}>\n <StyledInputField\n $placeholderWidth={placeholderWidth}\n id={id}\n disabled={isDisabled}\n onBlur={onBlur}\n onChange={handleInputFieldChange}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n ref={inputRef}\n type={type}\n value={value}\n autoFocus={shouldUseAutoFocus}\n inputMode={inputMode}\n $isInvalid={isInvalid}\n $shouldShowCenteredContent={shouldShowCenteredContent}\n />\n <StyledMotionInputLabelWrapper\n animate={shouldPreventPlaceholderAnimation ? {\n opacity: hasValue ? 0 : 1,\n }:{\n fontSize:\n hasValue &&\n !shouldShowOnlyBottomBorder &&\n !shouldRemainPlaceholder\n ? '9px'\n : '16px',\n }}\n initial={false}\n layout\n ref={placeholderRef}\n style={{ ...labelPosition }}\n transition={{ type: 'tween', duration: shouldPreventPlaceholderAnimation ? 0 : 0.1 }}\n >\n <StyledInputLabel $isInvalid={isInvalid}>\n {placeholder}\n </StyledInputLabel>\n </StyledMotionInputLabelWrapper>\n </StyledInputContent>\n {shouldShowClearIcon && (\n <StyledMotionInputClearIcon\n $shouldShowOnlyBottomBorder={shouldShowOnlyBottomBorder}\n $size={size}\n animate={{ opacity: hasValue ? 1 : 0 }}\n initial={false}\n onClick={handleClearIconClick}\n transition={{ type: 'tween' }}\n >\n <Icon\n icons={['fa fa-times']}\n color={isInvalid ? theme.wrong : undefined}\n />\n </StyledMotionInputClearIcon>\n )}\n {rightElement && shouldShowBorder && rightElement}\n </StyledInputContentWrapper>\n {rightElement && !shouldShowBorder && (\n <StyledInputRightElement>{rightElement}</StyledInputRightElement>\n )}\n </StyledInput>\n );\n },\n);\n\nInput.displayName = 'Input';\n\nexport default Input;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAiBA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAUwB,SAAAK,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,W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AAAW,OAAA,CAAAoF,aAAA,CAACzF,KAAA,CAAAK,OAAI;IACDgH,KAAK,EAAE,CAAC,aAAa,CAAE;IACvBC,KAAK,EAAEzE,SAAS,GAAGa,KAAK,CAAC6D,KAAK,GAAG1C;EAAU,CAC9C,CACuB,CAC/B,EACA1C,YAAY,IAAIsC,gBAAgB,IAAItC,YACd,CAAC,EAC3BA,YAAY,IAAI,CAACsC,gBAAgB,iBAC9B/E,MAAA,CAAAW,OAAA,CAAAoF,aAAA,CAACvF,MAAA,CAAAsH,uBAAuB,QAAErF,YAAsC,CAE3D,CAAC;AAEtB,CACJ,CAAC;AAEDV,KAAK,CAACgG,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAlG,OAAA,CAAAnB,OAAA,GAEboB,KAAK","ignoreList":[]}
|
package/lib/cjs/utils/file.js
CHANGED
|
@@ -3,25 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isValidFileType = exports.getIconByMimeType = exports.getHumanSize = exports.filterDuplicateFileUrls = exports.filterDuplicateFile = exports.MIME_TYPE_MAPPING = void 0;
|
|
6
|
+
exports.isValidFileType = exports.hasDuplicate = exports.getIconByMimeType = exports.getHumanSize = exports.filterDuplicateFileUrls = exports.filterDuplicateFile = exports.MIME_TYPE_MAPPING = void 0;
|
|
7
|
+
const hasDuplicate = (items, newItem, comparator) => items.some(item => comparator(item, newItem));
|
|
8
|
+
exports.hasDuplicate = hasDuplicate;
|
|
7
9
|
const filterDuplicateFile = ({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}) =>
|
|
11
|
-
const duplicates = files.filter(fileItem => fileItem && fileItem.name === newFile.name && fileItem.size === newFile.size);
|
|
12
|
-
return duplicates.length > 0;
|
|
13
|
-
};
|
|
10
|
+
files,
|
|
11
|
+
newFile
|
|
12
|
+
}) => hasDuplicate(files, newFile, (a, b) => a.name === b.name && a.size === b.size);
|
|
14
13
|
exports.filterDuplicateFile = filterDuplicateFile;
|
|
15
14
|
const filterDuplicateFileUrls = ({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}) =>
|
|
19
|
-
const duplicates = files.filter(fileItem => fileItem === newFile);
|
|
20
|
-
return duplicates.length > 0;
|
|
21
|
-
};
|
|
15
|
+
files,
|
|
16
|
+
newFile
|
|
17
|
+
}) => hasDuplicate(files, newFile, (a, b) => a === b);
|
|
22
18
|
exports.filterDuplicateFileUrls = filterDuplicateFileUrls;
|
|
23
|
-
const FILE_SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
|
24
19
|
const getHumanSize = bytes => {
|
|
20
|
+
const FILE_SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
|
25
21
|
let size = bytes || 0;
|
|
26
22
|
let unitIndex = 0;
|
|
27
23
|
while (size >= 1024) {
|
|
@@ -48,374 +44,20 @@ const isValidFileType = ({
|
|
|
48
44
|
};
|
|
49
45
|
exports.isValidFileType = isValidFileType;
|
|
50
46
|
const MIME_TYPE_MAPPING = exports.MIME_TYPE_MAPPING = {
|
|
51
|
-
//
|
|
52
|
-
'application/vnd.ms-excel': 'fa fa-file-excel',
|
|
53
|
-
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'fa fa-file-excel',
|
|
54
|
-
'application/vnd.ms-excel.sheet.macroEnabled.12': 'fa fa-file-excel',
|
|
55
|
-
'application/vnd.openxmlformats-officedocument.spreadsheetml.template': 'fa fa-file-excel',
|
|
56
|
-
'application/vnd.ms-excel.template.macroEnabled.12': 'fa fa-file-excel',
|
|
57
|
-
'application/vnd.ms-excel.addin.macroEnabled.12': 'fa fa-file-excel',
|
|
58
|
-
'application/vnd.ms-excel.sheet.binary.macroEnabled.12': 'fa fa-file-excel',
|
|
59
|
-
'application/msexcel': 'fa fa-file-excel',
|
|
60
|
-
'application/x-msexcel': 'fa fa-file-excel',
|
|
61
|
-
'application/x-ms-excel': 'fa fa-file-excel',
|
|
62
|
-
'application/x-excel': 'fa fa-file-excel',
|
|
63
|
-
'application/x-dos_ms_excel': 'fa fa-file-excel',
|
|
64
|
-
'application/xls': 'fa fa-file-excel',
|
|
65
|
-
'application/x-xls': 'fa fa-file-excel',
|
|
66
|
-
'application/vnd.ms-excel.sheet': 'fa fa-file-excel',
|
|
67
|
-
'appliaction/msexcel': 'fa fa-file-excel',
|
|
68
|
-
'application/vnd.openxmlformats-officedocument.spreadsheetml': 'fa fa-file-excel',
|
|
69
|
-
'application/vnd.oasis.opendocument.spreadsheet': 'fa fa-file-excel',
|
|
70
|
-
// Word
|
|
71
|
-
'application/msword': 'fa fa-file-word',
|
|
72
|
-
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'fa fa-file-word',
|
|
73
|
-
'application/vnd.ms-word.document.macroEnabled.12': 'fa fa-file-word',
|
|
74
|
-
'application/vnd.openxmlformats-officedocument.wordprocessingml.template': 'fa fa-file-word',
|
|
75
|
-
'application/vnd.ms-word.template.macroEnabled.12': 'fa fa-file-word',
|
|
76
|
-
'application/doc': 'fa fa-file-word',
|
|
77
|
-
'application/vnd.ms-word': 'fa fa-file-word',
|
|
78
|
-
'application/vnd.ms-word.document.macroEnabled': 'fa fa-file-word',
|
|
79
|
-
'application/vnd.ms-word.template.macroEnabled': 'fa fa-file-word',
|
|
80
|
-
'application/word': 'fa fa-file-word',
|
|
81
|
-
'application/x-msword': 'fa fa-file-word',
|
|
82
|
-
'application/x-msword-template': 'fa fa-file-word',
|
|
83
|
-
'application/vnd.ms-word.document': 'fa fa-file-word',
|
|
84
|
-
'application/rtf': 'fa fa-file-word',
|
|
85
|
-
'application/vnd.oasis.opendocument.text': 'fa fa-file-word',
|
|
86
|
-
'application/vnd.openxmlformats-officedocument.wordprocessingml': 'fa fa-file-word',
|
|
87
|
-
// PDF
|
|
47
|
+
// Haupttypen
|
|
88
48
|
'application/pdf': 'fa fa-file-pdf',
|
|
89
|
-
'application/x-pdf': 'fa fa-file-pdf',
|
|
90
|
-
'application/vnd.pdf': 'fa fa-file-pdf',
|
|
91
|
-
'text/pdf': 'fa fa-file-pdf',
|
|
92
|
-
'application/x-bzpdf': 'fa fa-file-pdf',
|
|
93
|
-
'application/x-gzpdf': 'fa fa-file-pdf',
|
|
94
|
-
'application/x-xzpdf': 'fa fa-file-pdf',
|
|
95
|
-
'application/vnd.adobe.pdf': 'fa fa-file-pdf',
|
|
96
|
-
'application/vnd.adobe.x-mars': 'fa fa-file-pdf',
|
|
97
|
-
'application/vnd.fdf': 'fa fa-file-pdf',
|
|
98
|
-
'application/vnd.adobe.xfdf': 'fa fa-file-pdf',
|
|
99
|
-
'application/vnd.adobe.xdp+xml': 'fa fa-file-pdf',
|
|
100
|
-
'application/vnd.adobe.xfd+xml': 'fa fa-file-pdf',
|
|
101
|
-
'application/vnd.adobe.xslfo+xml': 'fa fa-file-pdf',
|
|
102
|
-
'application/vnd.adobe.pdx': 'fa fa-file-pdf',
|
|
103
|
-
'application/vnd.adobe.xsp+xml': 'fa fa-file-pdf',
|
|
104
|
-
'application/vnd.adobe.xp+xml': 'fa fa-file-pdf',
|
|
105
|
-
'application/vnd.adobe.xpp+xml': 'fa fa-file-pdf',
|
|
106
|
-
'application/vnd.adobe.xdp+zip': 'fa fa-file-pdf',
|
|
107
|
-
'application/vnd.adobe.xfd+zip': 'fa fa-file-pdf',
|
|
108
|
-
'application/vnd.adobe.xfdf+zip': 'fa fa-file-pdf',
|
|
109
|
-
'application/vnd.adobe.xslt+xml': 'fa fa-file-pdf',
|
|
110
|
-
'application/vnd.adobe.xfm+xml': 'fa fa-file-pdf',
|
|
111
|
-
'application/vnd.adobe.xsf+xml': 'fa fa-file-pdf',
|
|
112
|
-
'application/vnd.adobe.xdpxml': 'fa fa-file-pdf',
|
|
113
|
-
'application/vnd.adobe.xfa': 'fa fa-file-pdf',
|
|
114
|
-
'application/vnd.adobe.xpinstall': 'fa fa-file-pdf',
|
|
115
|
-
'application/vnd.adobe.xquery': 'fa fa-file-pdf',
|
|
116
|
-
'application/vnd.adobe.xrd+xml': 'fa fa-file-pdf',
|
|
117
|
-
'application/vnd.adobe.xspf+xml': 'fa fa-file-pdf',
|
|
118
|
-
'application/vnd.adobe.xliff+xml': 'fa fa-file-pdf',
|
|
119
|
-
'application/vnd.adobe.xfdf+xml': 'fa fa-file-pdf',
|
|
120
|
-
'application/vnd.adobe.xmp+xml': 'fa fa-file-pdf',
|
|
121
|
-
'application/vnd.adobe.xmp+zip': 'fa fa-file-pdf',
|
|
122
|
-
'application/vnd.adobe.xna+xml': 'fa fa-file-pdf',
|
|
123
|
-
'application/vnd.adobe.cif+xml': 'fa fa-file-pdf',
|
|
124
|
-
'application/vnd.adobe.edn+xml': 'fa fa-file-pdf',
|
|
125
|
-
'application/vnd.adobe.eps': 'fa fa-file-pdf',
|
|
126
|
-
'application/vnd.adobe.encase.package+xml': 'fa fa-file-pdf',
|
|
127
|
-
'application/vnd.adobe.flash.movie': 'fa fa-file-pdf',
|
|
128
|
-
'application/vnd.adobe.formscentral.fcdt': 'fa fa-file-pdf',
|
|
129
|
-
'application/vnd.adobe.illustrator': 'fa fa-file-pdf',
|
|
130
|
-
'application/vnd.adobe.flash-movie': 'fa fa-file-pdf',
|
|
131
|
-
'application/vnd.adobe.air-application-installer-package+zip': 'fa fa-file-pdf',
|
|
132
|
-
// Zip
|
|
133
49
|
'application/zip': 'fa fa-file-archive',
|
|
134
|
-
'application/
|
|
135
|
-
'application/
|
|
136
|
-
|
|
137
|
-
'application/
|
|
138
|
-
'application/x-
|
|
139
|
-
|
|
140
|
-
'
|
|
141
|
-
'application/java-archive': 'fa fa-file-archive',
|
|
142
|
-
'application/vnd.ms-cab-compressed': 'fa fa-file-archive',
|
|
143
|
-
'application/x-ace-compressed': 'fa fa-file-archive',
|
|
144
|
-
'application/x-apple-diskimage': 'fa fa-file-archive',
|
|
145
|
-
'application/x-stuffit': 'fa fa-file-archive',
|
|
146
|
-
'application/x-deb': 'fa fa-file-archive',
|
|
147
|
-
'application/x-lzip': 'fa fa-file-archive',
|
|
148
|
-
'application/x-lzma': 'fa fa-file-archive',
|
|
149
|
-
'application/x-lz4': 'fa fa-file-archive',
|
|
150
|
-
'application/x-arj': 'fa fa-file-archive',
|
|
151
|
-
'application/x-gtar': 'fa fa-file-archive',
|
|
152
|
-
'application/x-gtar-compressed': 'fa fa-file-archive',
|
|
153
|
-
'application/x-compress': 'fa fa-file-archive',
|
|
154
|
-
'application/x-bzip': 'fa fa-file-archive',
|
|
155
|
-
'application/x-bzip2-compressed-tar': 'fa fa-file-archive',
|
|
156
|
-
'application/x-iso9660-image': 'fa fa-file-archive',
|
|
157
|
-
'application/x-nrg': 'fa fa-file-archive',
|
|
158
|
-
'application/x-cpio': 'fa fa-file-archive',
|
|
159
|
-
'application/x-rpm': 'fa fa-file-archive',
|
|
160
|
-
'application/x-msdownload': 'fa fa-file-archive',
|
|
161
|
-
'application/x-ace': 'fa fa-file-archive',
|
|
162
|
-
'application/x-gca-compressed': 'fa fa-file-archive',
|
|
163
|
-
'application/x-java-pack200': 'fa fa-file-archive',
|
|
164
|
-
'application/x-tarz': 'fa fa-file-archive',
|
|
165
|
-
'application/x-vhd': 'fa fa-file-archive',
|
|
166
|
-
'application/x-virtualbox-hdd': 'fa fa-file-archive',
|
|
167
|
-
'application/x-lha': 'fa fa-file-archive',
|
|
168
|
-
'application/x-lzx': 'fa fa-file-archive',
|
|
169
|
-
'application/x-nsis': 'fa fa-file-archive',
|
|
170
|
-
'application/x-sit': 'fa fa-file-archive',
|
|
171
|
-
'application/x-squashfs': 'fa fa-file-archive',
|
|
172
|
-
'application/x-tzo': 'fa fa-file-archive',
|
|
173
|
-
'application/x-lzh-compressed': 'fa fa-file-archive',
|
|
174
|
-
'application/x-xar': 'fa fa-file-archive',
|
|
175
|
-
'application/x-war': 'fa fa-file-archive',
|
|
176
|
-
'application/x-cfs-compressed': 'fa fa-file-archive',
|
|
177
|
-
'application/x-zoo': 'fa fa-file-archive',
|
|
178
|
-
'application/x-ice': 'fa fa-file-archive',
|
|
179
|
-
'application/x-b1': 'fa fa-file-archive',
|
|
180
|
-
'application/x-arc': 'fa fa-file-archive',
|
|
181
|
-
'application/x-uc2': 'fa fa-file-archive',
|
|
182
|
-
'application/x-gzcompressed': 'fa fa-file-archive',
|
|
183
|
-
'application/x-cab-compressed': 'fa fa-file-archive',
|
|
184
|
-
'application/x-egg': 'fa fa-file-archive',
|
|
185
|
-
'application/x-ipynb+zip': 'fa fa-file-archive',
|
|
186
|
-
'application/x-iso9660-appimage': 'fa fa-file-archive',
|
|
187
|
-
'application/x-java-archive-diff': 'fa fa-file-archive',
|
|
188
|
-
'application/x-lhz': 'fa fa-file-archive',
|
|
189
|
-
'application/x-ms-wim': 'fa fa-file-archive',
|
|
190
|
-
'application/x-rar': 'fa fa-file-archive',
|
|
191
|
-
'application/x-sfx': 'fa fa-file-archive',
|
|
192
|
-
'application/x-shar': 'fa fa-file-archive',
|
|
193
|
-
'application/x-tar-gz': 'fa fa-file-archive',
|
|
194
|
-
'application/x-tar-bz2': 'fa fa-file-archive',
|
|
195
|
-
'application/x-tar-xz': 'fa fa-file-archive',
|
|
196
|
-
'application/x-tar-z': 'fa fa-file-archive',
|
|
197
|
-
'application/x-tar-zstd': 'fa fa-file-archive',
|
|
198
|
-
'application/x-tar.lz': 'fa fa-file-archive',
|
|
199
|
-
'application/x-tar.lzo': 'fa fa-file-archive',
|
|
200
|
-
'application/x-ustar': 'fa fa-file-archive',
|
|
201
|
-
'application/x-wim': 'fa fa-file-archive',
|
|
202
|
-
'application/x-xpinstall': 'fa fa-file-archive',
|
|
203
|
-
'application/x-xz-compressed-tar': 'fa fa-file-archive',
|
|
204
|
-
'application/xz-compressed-tar': 'fa fa-file-archive',
|
|
205
|
-
'application/x-zip': 'fa fa-file-archive',
|
|
206
|
-
'application/x-zip-sfx': 'fa fa-file-archive',
|
|
207
|
-
'application/x-zipx': 'fa fa-file-archive',
|
|
208
|
-
'application/xz': 'fa fa-file-archive',
|
|
209
|
-
'application/zlib': 'fa fa-file-archive',
|
|
210
|
-
'application/vnd.apple.installer+xml': 'fa fa-file-archive',
|
|
211
|
-
'application/vnd.debian.binary-package': 'fa fa-file-archive',
|
|
212
|
-
'application/vnd.ms-office.addin.macroEnabled.12': 'fa fa-file-archive',
|
|
213
|
-
'application/vnd.ms-office.activex+xml': 'fa fa-file-archive',
|
|
214
|
-
'application/vnd.ms-pki.seccat': 'fa fa-file-archive',
|
|
215
|
-
'application/vnd.ms-pki.stl': 'fa fa-file-archive',
|
|
216
|
-
'application/vnd.ms-powerpoint.addin.macroEnabled.12': 'fa fa-file-archive',
|
|
217
|
-
'application/vnd.ms-powerpoint.presentation.macroEnabled.12': 'fa fa-file-archive',
|
|
218
|
-
'application/vnd.ms-powerpoint.slide.macroEnabled.12': 'fa fa-file-archive',
|
|
219
|
-
'application/vnd.ms-powerpoint.slideshow.macroEnabled.12': 'fa fa-file-archive',
|
|
220
|
-
'application/vnd.ms-powerpoint.template.macroEnabled.12': 'fa fa-file-archive',
|
|
221
|
-
'application/vnd.ms-visio.drawing': 'fa fa-file-archive',
|
|
222
|
-
'application/vnd.ms-visio.drawing.macroEnabled.12': 'fa fa-file-archive',
|
|
223
|
-
'application/vnd.ms-visio.stencil': 'fa fa-file-archive',
|
|
224
|
-
'application/vnd.ms-visio.stencil.macroEnabled.12': 'fa fa-file-archive',
|
|
225
|
-
'application/vnd.ms-visio.template': 'fa fa-file-archive',
|
|
226
|
-
'application/vnd.ms-visio.template.macroEnabled.12': 'fa fa-file-archive',
|
|
227
|
-
'application/vnd.ms-xpsdocument': 'fa fa-file-archive',
|
|
228
|
-
'application/octet-stream': 'fa fa-file-archive',
|
|
229
|
-
'application/gzip': 'fa fa-file-archive',
|
|
230
|
-
// PowerPoint
|
|
231
|
-
'application/vnd.ms-powerpoint': 'fa fa-file-powerpoint',
|
|
232
|
-
'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'fa fa-file-powerpoint',
|
|
233
|
-
'application/vnd.openxmlformats-officedocument.presentationml.slideshow': 'fa fa-file-powerpoint',
|
|
234
|
-
'application/vnd.openxmlformats-officedocument.presentationml.template': 'fa fa-file-powerpoint',
|
|
235
|
-
'application/vnd.ms-powerpoint.slide+xml': 'fa fa-file-powerpoint',
|
|
236
|
-
'application/vnd.ms-powerpoint.slide.show+xml': 'fa fa-file-powerpoint',
|
|
237
|
-
'application/vnd.ms-powerpoint.slide.show.macroEnabled.12': 'fa fa-file-powerpoint',
|
|
238
|
-
'application/vnd.ms-powerpoint.slideLayout+xml': 'fa fa-file-powerpoint',
|
|
239
|
-
'application/vnd.ms-powerpoint.slideMaster+xml': 'fa fa-file-powerpoint',
|
|
240
|
-
'application/vnd.ms-powerpoint.slideshow+xml': 'fa fa-file-powerpoint',
|
|
241
|
-
'application/vnd.ms-powerpoint.template+xml': 'fa fa-file-powerpoint',
|
|
242
|
-
'application/vnd.ms-powerpoint.presentation+xml': 'fa fa-file-powerpoint',
|
|
243
|
-
'application/vnd.ms-powerpoint.addin+xml': 'fa fa-file-powerpoint',
|
|
244
|
-
'application/vnd.ms-powerpoint.presentation.macroEnabled+xml': 'fa fa-file-powerpoint',
|
|
245
|
-
'application/vnd.ms-powerpoint.presentation.main+xml': 'fa fa-file-powerpoint',
|
|
246
|
-
'application/vnd.ms-powerpoint.slide.show.macroEnabled+xml': 'fa fa-file-powerpoint',
|
|
247
|
-
'application/vnd.ms-powerpoint.template.macroEnabled+xml': 'fa fa-file-powerpoint',
|
|
248
|
-
'application/x-mspowerpoint': 'fa fa-file-powerpoint',
|
|
249
|
-
'application/x-ms-powerpoint': 'fa fa-file-powerpoint',
|
|
250
|
-
'application/mspowerpoint': 'fa fa-file-powerpoint',
|
|
251
|
-
'application/ppt': 'fa fa-file-powerpoint',
|
|
252
|
-
'application/vnd.ms-ppt': 'fa fa-file-powerpoint',
|
|
253
|
-
'application/powerpoint': 'fa fa-file-powerpoint',
|
|
254
|
-
'application/x-ppt': 'fa fa-file-powerpoint',
|
|
255
|
-
'application/pptx': 'fa fa-file-powerpoint',
|
|
256
|
-
'application/vnd.openxmlformats-officedocument.presentationml.slide': 'fa fa-file-powerpoint',
|
|
257
|
-
'application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml': 'fa fa-file-powerpoint',
|
|
258
|
-
'application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml': 'fa fa-file-powerpoint',
|
|
259
|
-
'application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml': 'fa fa-file-powerpoint',
|
|
260
|
-
'application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml': 'fa fa-file-powerpoint',
|
|
261
|
-
'application/vnd.openxmlformats-officedocument.presentationml': 'fa fa-file-powerpoint',
|
|
262
|
-
'application/vnd.oasis.opendocument.presentation': 'fa fa-file-powerpoint',
|
|
263
|
-
// Text
|
|
264
|
-
'text/plain': 'fa fa-file-alt',
|
|
265
|
-
// CSV
|
|
266
|
-
'text/csv': 'fa fa-file-csv',
|
|
267
|
-
'application/csv': 'fa fa-file-csv',
|
|
268
|
-
'application/x-csv': 'fa fa-file-csv',
|
|
269
|
-
'text/comma-separated-values': 'fa fa-file-csv',
|
|
270
|
-
'text/x-comma-separated-values': 'fa fa-file-csv',
|
|
271
|
-
'text/tab-separated-values': 'fa fa-file-csv',
|
|
272
|
-
'application/x-sqlite3': 'fa fa-file-csv',
|
|
273
|
-
'application/vnd.oasis.opendocument.graphics': 'fa fa-file-csv',
|
|
274
|
-
'application/vnd.oasis.opendocument.chart': 'fa fa-file-csv',
|
|
275
|
-
'application/vnd.oasis.opendocument.database': 'fa fa-file-csv',
|
|
276
|
-
'application/vnd.oasis.opendocument.formula': 'fa fa-file-csv',
|
|
277
|
-
'application/vnd.oasis.opendocument.image': 'fa fa-file-csv',
|
|
278
|
-
'application/vnd.oasis.opendocument.text-master': 'fa fa-file-csv',
|
|
279
|
-
'application/vnd.oasis.opendocument.presentation-master': 'fa fa-file-csv',
|
|
280
|
-
'application/vnd.oasis.opendocument.spreadsheet-template': 'fa fa-file-csv',
|
|
281
|
-
'application/vnd.oasis.opendocument.text-template': 'fa fa-file-csv',
|
|
282
|
-
'application/vnd.oasis.opendocument.presentation-template': 'fa fa-file-csv',
|
|
283
|
-
'application/vnd.oasis.opendocument.graphics-template': 'fa fa-file-csv',
|
|
284
|
-
'application/vnd.oasis.opendocument.chart-template': 'fa fa-file-csv',
|
|
285
|
-
'application/vnd.oasis.opendocument.database-template': 'fa fa-file-csv',
|
|
286
|
-
'application/vnd.oasis.opendocument.formula-template': 'fa fa-file-csv',
|
|
287
|
-
'application/vnd.oasis.opendocument.image-template': 'fa fa-file-csv',
|
|
288
|
-
'application/vnd.sun.xml.writer': 'fa fa-file-csv',
|
|
289
|
-
'application/vnd.sun.xml.writer.template': 'fa fa-file-csv',
|
|
290
|
-
'application/vnd.sun.xml.calc': 'fa fa-file-csv',
|
|
291
|
-
'application/vnd.sun.xml.calc.template': 'fa fa-file-csv',
|
|
292
|
-
'application/vnd.sun.xml.impress': 'fa fa-file-csv',
|
|
293
|
-
'application/vnd.sun.xml.impress.template': 'fa fa-file-csv',
|
|
294
|
-
'application/vnd.sun.xml.draw': 'fa fa-file-csv',
|
|
295
|
-
'application/vnd.sun.xml.draw.template': 'fa fa-file-csv',
|
|
296
|
-
'application/vnd.sun.xml.math': 'fa fa-file-csv',
|
|
297
|
-
// Code
|
|
298
|
-
'text/x-sass': 'fa fa-file-code',
|
|
299
|
-
'text/x-scheme': 'fa fa-file-code',
|
|
300
|
-
'text/x-scons': 'fa fa-file-code',
|
|
301
|
-
'text/x-stsrc': 'fa fa-file-code',
|
|
302
|
-
'text/x-tcl': 'fa fa-file-code',
|
|
303
|
-
'text/x-tex': 'fa fa-file-code',
|
|
304
|
-
'text/x-texinfo': 'fa fa-file-code',
|
|
305
|
-
'text/x-toml': 'fa fa-file-code',
|
|
306
|
-
'text/x-uuencode': 'fa fa-file-code',
|
|
307
|
-
'text/x-vala': 'fa fa-file-code',
|
|
308
|
-
'text/x-vbdotnet': 'fa fa-file-code',
|
|
309
|
-
'text/x-vbnet': 'fa fa-file-code',
|
|
310
|
-
'text/x-verilog': 'fa fa-file-code',
|
|
311
|
-
'text/x-vhdl': 'fa fa-file-code',
|
|
312
|
-
'text/x-yaml': 'fa fa-file-code',
|
|
313
|
-
'application/x-gnuplot': 'fa fa-file-code',
|
|
314
|
-
'application/x-haml': 'fa fa-file-code',
|
|
315
|
-
'application/x-ini': 'fa fa-file-code',
|
|
316
|
-
'application/x-mumps': 'fa fa-file-code',
|
|
317
|
-
'application/x-ocaml': 'fa fa-file-code',
|
|
318
|
-
'application/x-ooc': 'fa fa-file-code',
|
|
319
|
-
'application/x-patch': 'fa fa-file-code',
|
|
320
|
-
'application/x-prolog': 'fa fa-file-code',
|
|
321
|
-
'application/x-properties': 'fa fa-file-code',
|
|
322
|
-
'application/x-rsrc': 'fa fa-file-code',
|
|
323
|
-
'application/x-sass': 'fa fa-file-code',
|
|
324
|
-
'application/x-scheme': 'fa fa-file-code',
|
|
325
|
-
'application/x-scons': 'fa fa-file-code',
|
|
326
|
-
'application/x-stsrc': 'fa fa-file-code',
|
|
327
|
-
'application/x-tcl': 'fa fa-file-code',
|
|
328
|
-
'application/x-tex': 'fa fa-file-code',
|
|
329
|
-
'application/x-texinfo': 'fa fa-file-code',
|
|
330
|
-
'application/x-toml': 'fa fa-file-code',
|
|
331
|
-
'application/x-uuencode': 'fa fa-file-code',
|
|
332
|
-
'application/x-vala': 'fa fa-file-code',
|
|
333
|
-
'application/x-vbdotnet': 'fa fa-file-code',
|
|
334
|
-
'application/x-vbnet': 'fa fa-file-code',
|
|
335
|
-
'application/x-vhdl': 'fa fa-file-code',
|
|
336
|
-
'application/x-verilog': 'fa fa-file-code',
|
|
337
|
-
'application/x-yaml': 'fa fa-file-code',
|
|
338
|
-
'text/x-arduino': 'fa fa-file-code',
|
|
339
|
-
'text/x-bibtex': 'fa fa-file-code',
|
|
340
|
-
'text/x-coffeescript': 'fa fa-file-code',
|
|
341
|
-
'text/x-dtd': 'fa fa-file-code',
|
|
342
|
-
'text/x-erlang': 'fa fa-file-code',
|
|
343
|
-
'text/x-gnuplot': 'fa fa-file-code',
|
|
344
|
-
'text/x-go': 'fa fa-file-code',
|
|
345
|
-
'text/x-gwt-rpc': 'fa fa-file-code',
|
|
346
|
-
'text/x-handlebars': 'fa fa-file-code',
|
|
347
|
-
'text/x-haml': 'fa fa-file-code',
|
|
348
|
-
'text/x-ini': 'fa fa-file-code',
|
|
349
|
-
'text/x-json': 'fa fa-file-code',
|
|
350
|
-
'text/x-kotlin': 'fa fa-file-code',
|
|
351
|
-
'text/x-liquid': 'fa fa-file-code',
|
|
352
|
-
'text/x-literate-haskell': 'fa fa-file-code',
|
|
353
|
-
'text/x-lua': 'fa fa-file-code',
|
|
354
|
-
'text/x-makefile': 'fa fa-file-code',
|
|
355
|
-
'text/x-nfo': 'fa fa-file-code',
|
|
356
|
-
'text/x-ocaml': 'fa fa-file-code',
|
|
357
|
-
'text/x-ooc': 'fa fa-file-code',
|
|
358
|
-
'text/x-patch': 'fa fa-file-code',
|
|
359
|
-
'text/x-prolog': 'fa fa-file-code',
|
|
360
|
-
'text/x-properties': 'fa fa-file-code',
|
|
361
|
-
'text/x-rsrc': 'fa fa-file-code',
|
|
362
|
-
'text/x-rust': 'fa fa-file-code',
|
|
363
|
-
'text/html': 'fa fa-file-code',
|
|
364
|
-
'text/css': 'fa fa-file-code',
|
|
365
|
-
'text/javascript': 'fa fa-file-code',
|
|
366
|
-
'application/javascript': 'fa fa-file-code',
|
|
367
|
-
'application/json': 'fa fa-file-code',
|
|
368
|
-
'application/xml': 'fa fa-file-code',
|
|
369
|
-
'application/xhtml+xml': 'fa fa-file-code',
|
|
370
|
-
'application/atom+xml': 'fa fa-file-code',
|
|
371
|
-
'application/rss+xml': 'fa fa-file-code',
|
|
372
|
-
'application/x-latex': 'fa fa-file-code',
|
|
373
|
-
'application/x-sh': 'fa fa-file-code',
|
|
374
|
-
'application/x-python': 'fa fa-file-code',
|
|
375
|
-
'application/x-perl': 'fa fa-file-code',
|
|
376
|
-
'application/x-ruby': 'fa fa-file-code',
|
|
377
|
-
'application/x-php': 'fa fa-file-code',
|
|
378
|
-
'application/x-java': 'fa fa-file-code',
|
|
379
|
-
'application/x-c++': 'fa fa-file-code',
|
|
380
|
-
'application/x-c': 'fa fa-file-code',
|
|
381
|
-
'application/x-shellscript': 'fa fa-file-code',
|
|
382
|
-
'application/x-diff': 'fa fa-file-code',
|
|
383
|
-
'application/x-go': 'fa fa-file-code',
|
|
384
|
-
'application/x-swift': 'fa fa-file-code',
|
|
385
|
-
'application/x-objective-c': 'fa fa-file-code',
|
|
386
|
-
'application/x-scala': 'fa fa-file-code',
|
|
387
|
-
'application/x-rust': 'fa fa-file-code',
|
|
388
|
-
'application/x-haskell': 'fa fa-file-code',
|
|
389
|
-
'application/x-lua': 'fa fa-file-code',
|
|
390
|
-
'application/x-matlab': 'fa fa-file-code',
|
|
391
|
-
'application/x-fortran': 'fa fa-file-code',
|
|
392
|
-
'application/x-csharp': 'fa fa-file-code',
|
|
393
|
-
'application/x-vb': 'fa fa-file-code',
|
|
394
|
-
'application/x-pascal': 'fa fa-file-code',
|
|
395
|
-
'application/x-cobol': 'fa fa-file-code',
|
|
396
|
-
'application/x-groovy': 'fa fa-file-code',
|
|
397
|
-
'application/x-sql': 'fa fa-file-code',
|
|
398
|
-
'application/x-typescript': 'fa fa-file-code',
|
|
399
|
-
'application/x-kotlin': 'fa fa-file-code',
|
|
400
|
-
'application/x-erlang': 'fa fa-file-code',
|
|
401
|
-
'application/x-clojure': 'fa fa-file-code',
|
|
402
|
-
'application/x-less': 'fa fa-file-code',
|
|
403
|
-
'application/x-stylus': 'fa fa-file-code',
|
|
404
|
-
'application/x-markdown': 'fa fa-file-code',
|
|
405
|
-
'application/x-coffeescript': 'fa fa-file-code',
|
|
406
|
-
'application/x-dart': 'fa fa-file-code',
|
|
407
|
-
'application/x-lisp': 'fa fa-file-code',
|
|
408
|
-
'application/x-powershell': 'fa fa-file-code',
|
|
409
|
-
// Images
|
|
410
|
-
image: 'fa fa-file-image',
|
|
411
|
-
// Audio
|
|
412
|
-
audio: 'fa fa-file-audio',
|
|
413
|
-
// Video
|
|
414
|
-
video: 'fa fa-file-video'
|
|
50
|
+
'application/msword': 'fa fa-file-word',
|
|
51
|
+
'application/vnd.ms-excel': 'fa fa-file-excel',
|
|
52
|
+
// Typen mit Wildcards
|
|
53
|
+
'application/vnd.openxmlformats-officedocument.': 'fa fa-file-word',
|
|
54
|
+
'application/x-': 'fa fa-file-archive',
|
|
55
|
+
// Addiere nur spezifische Fälle
|
|
56
|
+
'text/pdf': 'fa fa-file-pdf'
|
|
415
57
|
};
|
|
416
58
|
const getIconByMimeType = mimeType => {
|
|
417
|
-
const
|
|
418
|
-
return
|
|
59
|
+
const matchedType = Object.keys(MIME_TYPE_MAPPING).find(type => mimeType === null || mimeType === void 0 ? void 0 : mimeType.startsWith(type));
|
|
60
|
+
return MIME_TYPE_MAPPING[matchedType] || 'fa fa-file';
|
|
419
61
|
};
|
|
420
62
|
exports.getIconByMimeType = getIconByMimeType;
|
|
421
63
|
//# sourceMappingURL=file.js.map
|