@chayns-components/core 5.0.0-beta.1015 → 5.0.0-beta.1017
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/search-input/SearchInput.js +71 -5
- package/lib/cjs/components/search-input/SearchInput.js.map +1 -1
- package/lib/cjs/components/search-input/SearchInput.styles.js +35 -12
- package/lib/cjs/components/search-input/SearchInput.styles.js.map +1 -1
- package/lib/cjs/components/tag-input/TagInput.js +6 -5
- package/lib/cjs/components/tag-input/TagInput.js.map +1 -1
- package/lib/esm/components/search-input/SearchInput.js +73 -7
- package/lib/esm/components/search-input/SearchInput.js.map +1 -1
- package/lib/esm/components/search-input/SearchInput.styles.js +36 -11
- package/lib/esm/components/search-input/SearchInput.styles.js.map +1 -1
- package/lib/esm/components/tag-input/TagInput.js +6 -5
- package/lib/esm/components/tag-input/TagInput.js.map +1 -1
- package/lib/types/components/search-input/SearchInput.d.ts +4 -0
- package/lib/types/components/search-input/SearchInput.styles.d.ts +7 -3
- package/lib/types/components/tag-input/TagInput.d.ts +5 -2
- package/package.json +2 -2
|
@@ -9,6 +9,8 @@ var _react2 = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _Icon = _interopRequireDefault(require("../icon/Icon"));
|
|
10
10
|
var _Input = _interopRequireWildcard(require("../input/Input"));
|
|
11
11
|
var _SearchInput = require("./SearchInput.styles");
|
|
12
|
+
var _styledComponents = require("styled-components");
|
|
13
|
+
var _useElementSize = require("../../hooks/useElementSize");
|
|
12
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -19,11 +21,15 @@ const SearchInput = ({
|
|
|
19
21
|
onChange,
|
|
20
22
|
onKeyDown,
|
|
21
23
|
placeholder,
|
|
24
|
+
shouldUseAbsolutePositioning = false,
|
|
22
25
|
size = _Input.InputSize.Medium,
|
|
23
26
|
value
|
|
24
27
|
}) => {
|
|
25
28
|
const [isSearchInputActive, setIsSearchInputActive] = (0, _react2.useState)(isActive ?? (typeof value === 'string' && value.trim() !== ''));
|
|
26
29
|
const inputRef = (0, _react2.useRef)(null);
|
|
30
|
+
const pseudoRef = (0, _react2.useRef)(null);
|
|
31
|
+
const parentWidth = (0, _useElementSize.useElementSize)(pseudoRef);
|
|
32
|
+
const theme = (0, _styledComponents.useTheme)();
|
|
27
33
|
const handleBackIconClick = (0, _react2.useCallback)(() => setIsSearchInputActive(false), []);
|
|
28
34
|
const handleSearchIconClick = (0, _react2.useCallback)(() => setIsSearchInputActive(true), []);
|
|
29
35
|
(0, _react2.useEffect)(() => {
|
|
@@ -40,15 +46,18 @@ const SearchInput = ({
|
|
|
40
46
|
setIsSearchInputActive(isActive);
|
|
41
47
|
}
|
|
42
48
|
}, [isActive]);
|
|
43
|
-
|
|
49
|
+
const width = (0, _react2.useMemo)(() => parentWidth === null || parentWidth === void 0 ? void 0 : parentWidth.width, [parentWidth === null || parentWidth === void 0 ? void 0 : parentWidth.width]);
|
|
50
|
+
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement(_SearchInput.StyledSearchInput, {
|
|
44
51
|
className: "beta-chayns-search-input",
|
|
45
|
-
$size: size
|
|
46
|
-
|
|
52
|
+
$size: size,
|
|
53
|
+
$shouldUseAbsolutePositioning: shouldUseAbsolutePositioning
|
|
54
|
+
}, shouldUseAbsolutePositioning ? /*#__PURE__*/_react2.default.createElement(_react.AnimatePresence, {
|
|
47
55
|
initial: false
|
|
48
56
|
}, isSearchInputActive && /*#__PURE__*/_react2.default.createElement(_SearchInput.StyledMotionSearchInputContentWrapper, {
|
|
57
|
+
$shouldUseAbsolutePositioning: shouldUseAbsolutePositioning,
|
|
49
58
|
animate: {
|
|
50
59
|
opacity: 1,
|
|
51
|
-
width
|
|
60
|
+
width
|
|
52
61
|
},
|
|
53
62
|
exit: {
|
|
54
63
|
opacity: 0,
|
|
@@ -91,7 +100,64 @@ const SearchInput = ({
|
|
|
91
100
|
icons: isSearchInputActive ? ['fa fa-xmark'] : ['fa fa-search'],
|
|
92
101
|
onClick: isSearchInputActive ? handleBackIconClick : handleSearchIconClick,
|
|
93
102
|
size: 18
|
|
94
|
-
})))
|
|
103
|
+
}))) : /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement(_SearchInput.StyledMotionSearchInputIconWrapper, null, /*#__PURE__*/_react2.default.createElement(_react.AnimatePresence, {
|
|
104
|
+
initial: false
|
|
105
|
+
}, /*#__PURE__*/_react2.default.createElement(_SearchInput.StyledMotionSearchInputIconWrapperContent, {
|
|
106
|
+
animate: {
|
|
107
|
+
opacity: 1
|
|
108
|
+
},
|
|
109
|
+
exit: {
|
|
110
|
+
opacity: 0,
|
|
111
|
+
position: 'absolute'
|
|
112
|
+
},
|
|
113
|
+
initial: {
|
|
114
|
+
opacity: 0
|
|
115
|
+
},
|
|
116
|
+
key: isSearchInputActive ? 'backIcon' : 'searchIcon',
|
|
117
|
+
transition: {
|
|
118
|
+
duration: 0.3
|
|
119
|
+
},
|
|
120
|
+
id: isSearchInputActive ? 'search-input-backIcon' : 'search-input-searchIcon'
|
|
121
|
+
}, /*#__PURE__*/_react2.default.createElement(_Icon.default, {
|
|
122
|
+
color: iconColor,
|
|
123
|
+
icons: isSearchInputActive ? ['fa fa-arrow-left'] : ['fa fa-search'],
|
|
124
|
+
onClick: isSearchInputActive ? handleBackIconClick : handleSearchIconClick,
|
|
125
|
+
size: 18
|
|
126
|
+
})))), /*#__PURE__*/_react2.default.createElement(_react.AnimatePresence, {
|
|
127
|
+
initial: false
|
|
128
|
+
}, isSearchInputActive && /*#__PURE__*/_react2.default.createElement(_SearchInput.StyledMotionSearchInputContentWrapper, {
|
|
129
|
+
$shouldUseAbsolutePositioning: shouldUseAbsolutePositioning,
|
|
130
|
+
animate: {
|
|
131
|
+
opacity: 1,
|
|
132
|
+
width: '100%'
|
|
133
|
+
},
|
|
134
|
+
exit: {
|
|
135
|
+
opacity: 0,
|
|
136
|
+
width: 0
|
|
137
|
+
},
|
|
138
|
+
initial: {
|
|
139
|
+
opacity: 0,
|
|
140
|
+
width: 0
|
|
141
|
+
},
|
|
142
|
+
key: "searchInputContentWrapper",
|
|
143
|
+
transition: {
|
|
144
|
+
duration: 0.3
|
|
145
|
+
}
|
|
146
|
+
}, /*#__PURE__*/_react2.default.createElement(_Input.default, {
|
|
147
|
+
leftElement: /*#__PURE__*/_react2.default.createElement(_Icon.default, {
|
|
148
|
+
color: theme.text,
|
|
149
|
+
icons: ['far fa-search']
|
|
150
|
+
}),
|
|
151
|
+
onChange: onChange,
|
|
152
|
+
onKeyDown: onKeyDown,
|
|
153
|
+
placeholder: placeholder,
|
|
154
|
+
ref: inputRef,
|
|
155
|
+
shouldShowClearIcon: true,
|
|
156
|
+
size: size,
|
|
157
|
+
value: value
|
|
158
|
+
}))))), /*#__PURE__*/_react2.default.createElement(_SearchInput.StyledSearchInputPseudoElement, {
|
|
159
|
+
ref: pseudoRef
|
|
160
|
+
}));
|
|
95
161
|
};
|
|
96
162
|
SearchInput.displayName = 'SearchInput';
|
|
97
163
|
var _default = exports.default = SearchInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.js","names":["_react","require","_react2","_interopRequireWildcard","_Icon","_interopRequireDefault","_Input","_SearchInput","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SearchInput","iconColor","isActive","onActiveChange","onChange","onKeyDown","placeholder","size","InputSize","Medium","value","isSearchInputActive","setIsSearchInputActive","useState","trim","inputRef","useRef","handleBackIconClick","useCallback","handleSearchIconClick","useEffect","_inputRef$current","current","focus","createElement","StyledSearchInput","className","$size","AnimatePresence","initial","StyledMotionSearchInputContentWrapper","animate","opacity","width","exit","key","transition","duration","ref","shouldShowClearIcon","StyledMotionSearchInputIconWrapperContent","position","id","color","icons","onClick","displayName","_default","exports"],"sources":["../../../../src/components/search-input/SearchInput.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n CSSProperties,\n FC,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport Icon from '../icon/Icon';\nimport Input, { InputRef, InputSize } from '../input/Input';\nimport {\n StyledMotionSearchInputContentWrapper,\n StyledMotionSearchInputIconWrapperContent,\n StyledSearchInput,\n} from './SearchInput.styles';\n\nexport type SearchInputProps = {\n /**\n * Color of the icon\n */\n iconColor?: CSSProperties['color'];\n /**\n * Force the active state of the input and override the internal state\n */\n isActive?: boolean;\n /**\n * Function that is executed when the active state of the input changes\n */\n onActiveChange?: (isActive: boolean) => void;\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 a key is pressed\n */\n onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * The size of the input field\n */\n size?: InputSize;\n /**\n * Value if the input field should be controlled\n */\n value?: string;\n};\n\nconst SearchInput: FC<SearchInputProps> = ({\n iconColor,\n isActive,\n onActiveChange,\n onChange,\n onKeyDown,\n placeholder,\n size = InputSize.Medium,\n value,\n}) => {\n const [isSearchInputActive, setIsSearchInputActive] = useState(\n isActive ?? (typeof value === 'string' && value.trim() !== ''),\n );\n\n const inputRef = useRef<InputRef>(null);\n\n const handleBackIconClick = useCallback(() => setIsSearchInputActive(false), []);\n\n const handleSearchIconClick = useCallback(() => setIsSearchInputActive(true), []);\n\n useEffect(() => {\n if (typeof onActiveChange === 'function') {\n onActiveChange(isSearchInputActive);\n }\n\n if (isSearchInputActive) {\n inputRef.current?.focus();\n }\n }, [isSearchInputActive, onActiveChange]);\n\n useEffect(() => {\n if (typeof isActive === 'boolean') {\n setIsSearchInputActive(isActive);\n }\n }, [isActive]);\n\n return (\n <StyledSearchInput className=\"beta-chayns-search-input\" $size={size}>\n <AnimatePresence initial={false}>\n {isSearchInputActive && (\n <StyledMotionSearchInputContentWrapper\n animate={{ opacity: 1, width: '100%' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"searchInputContentWrapper\"\n transition={{ duration: 0.3 }}\n >\n <Input\n onChange={onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={inputRef}\n shouldShowClearIcon\n size={size}\n value={value}\n />\n </StyledMotionSearchInputContentWrapper>\n )}\n <StyledMotionSearchInputIconWrapperContent\n animate={{ opacity: 1 }}\n exit={{ opacity: 0, position: 'absolute' }}\n initial={{ opacity: 0 }}\n key={isSearchInputActive ? 'backIcon' : 'searchIcon'}\n transition={{ duration: 0.3 }}\n id={isSearchInputActive ? 'search-input-backIcon' : 'search-input-searchIcon'}\n >\n <Icon\n color={iconColor}\n icons={isSearchInputActive ? ['fa fa-xmark'] : ['fa fa-search']}\n onClick={isSearchInputActive ? handleBackIconClick : handleSearchIconClick}\n size={18}\n />\n </StyledMotionSearchInputIconWrapperContent>\n </AnimatePresence>\n </StyledSearchInput>\n );\n};\n\nSearchInput.displayName = 'SearchInput';\n\nexport default SearchInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,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,EAAE;IAAI,CAAE;IAC9BK,EAAE,EAAE/B,mBAAmB,GAAG,uBAAuB,GAAG;EAA0B,gBAE9ErC,OAAA,CAAAQ,OAAA,CAAA0C,aAAA,CAAChD,KAAA,CAAAM,OAAI;IACD6D,KAAK,EAAE1C,SAAU;IACjB2C,KAAK,EAAEjC,mBAAmB,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,CAAE;IAChEkC,OAAO,EAAElC,mBAAmB,GAAGM,mBAAmB,GAAGE,qBAAsB;IAC3EZ,IAAI,EAAE;EAAG,CACZ,CACsC,CAC9B,CACF,CAAC;AAE5B,CAAC;AAEDP,WAAW,CAAC8C,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAlE,OAAA,GAEzBkB,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SearchInput.js","names":["_react","require","_react2","_interopRequireWildcard","_Icon","_interopRequireDefault","_Input","_SearchInput","_styledComponents","_useElementSize","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SearchInput","iconColor","isActive","onActiveChange","onChange","onKeyDown","placeholder","shouldUseAbsolutePositioning","size","InputSize","Medium","value","isSearchInputActive","setIsSearchInputActive","useState","trim","inputRef","useRef","pseudoRef","parentWidth","useElementSize","theme","useTheme","handleBackIconClick","useCallback","handleSearchIconClick","useEffect","_inputRef$current","current","focus","width","useMemo","createElement","Fragment","StyledSearchInput","className","$size","$shouldUseAbsolutePositioning","AnimatePresence","initial","StyledMotionSearchInputContentWrapper","animate","opacity","exit","key","transition","duration","ref","shouldShowClearIcon","StyledMotionSearchInputIconWrapperContent","position","id","color","icons","onClick","StyledMotionSearchInputIconWrapper","leftElement","text","StyledSearchInputPseudoElement","displayName","_default","exports"],"sources":["../../../../src/components/search-input/SearchInput.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n CSSProperties,\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport Icon from '../icon/Icon';\nimport Input, { InputRef, InputSize } from '../input/Input';\nimport {\n StyledMotionSearchInputContentWrapper,\n StyledMotionSearchInputIconWrapper,\n StyledMotionSearchInputIconWrapperContent,\n StyledSearchInput,\n StyledSearchInputPseudoElement,\n} from './SearchInput.styles';\nimport { useTheme } from 'styled-components';\nimport { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { useElementSize } from '../../hooks/useElementSize';\n\nexport type SearchInputProps = {\n /**\n * Color of the icon\n */\n iconColor?: CSSProperties['color'];\n /**\n * Force the active state of the input and override the internal state\n */\n isActive?: boolean;\n /**\n * Function that is executed when the active state of the input changes\n */\n onActiveChange?: (isActive: boolean) => void;\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 a key is pressed\n */\n onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Whether the SearchInput should be positioned absolute.\n */\n shouldUseAbsolutePositioning?: boolean;\n /**\n * The size of the input field\n */\n size?: InputSize;\n /**\n * Value if the input field should be controlled\n */\n value?: string;\n};\n\nconst SearchInput: FC<SearchInputProps> = ({\n iconColor,\n isActive,\n onActiveChange,\n onChange,\n onKeyDown,\n placeholder,\n shouldUseAbsolutePositioning = false,\n size = InputSize.Medium,\n value,\n}) => {\n const [isSearchInputActive, setIsSearchInputActive] = useState(\n isActive ?? (typeof value === 'string' && value.trim() !== ''),\n );\n\n const inputRef = useRef<InputRef>(null);\n const pseudoRef = useRef<HTMLDivElement>(null);\n\n const parentWidth = useElementSize(pseudoRef);\n\n const theme = useTheme() as Theme;\n\n const handleBackIconClick = useCallback(() => setIsSearchInputActive(false), []);\n\n const handleSearchIconClick = useCallback(() => setIsSearchInputActive(true), []);\n\n useEffect(() => {\n if (typeof onActiveChange === 'function') {\n onActiveChange(isSearchInputActive);\n }\n\n if (isSearchInputActive) {\n inputRef.current?.focus();\n }\n }, [isSearchInputActive, onActiveChange]);\n\n useEffect(() => {\n if (typeof isActive === 'boolean') {\n setIsSearchInputActive(isActive);\n }\n }, [isActive]);\n\n const width = useMemo(() => parentWidth?.width, [parentWidth?.width]);\n\n return (\n <>\n <StyledSearchInput\n className=\"beta-chayns-search-input\"\n $size={size}\n $shouldUseAbsolutePositioning={shouldUseAbsolutePositioning}\n >\n {shouldUseAbsolutePositioning ? (\n <AnimatePresence initial={false}>\n {isSearchInputActive && (\n <StyledMotionSearchInputContentWrapper\n $shouldUseAbsolutePositioning={shouldUseAbsolutePositioning}\n animate={{ opacity: 1, width }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"searchInputContentWrapper\"\n transition={{ duration: 0.3 }}\n >\n <Input\n onChange={onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={inputRef}\n shouldShowClearIcon\n size={size}\n value={value}\n />\n </StyledMotionSearchInputContentWrapper>\n )}\n <StyledMotionSearchInputIconWrapperContent\n animate={{ opacity: 1 }}\n exit={{ opacity: 0, position: 'absolute' }}\n initial={{ opacity: 0 }}\n key={isSearchInputActive ? 'backIcon' : 'searchIcon'}\n transition={{ duration: 0.3 }}\n id={\n isSearchInputActive\n ? 'search-input-backIcon'\n : 'search-input-searchIcon'\n }\n >\n <Icon\n color={iconColor}\n icons={isSearchInputActive ? ['fa fa-xmark'] : ['fa fa-search']}\n onClick={\n isSearchInputActive\n ? handleBackIconClick\n : handleSearchIconClick\n }\n size={18}\n />\n </StyledMotionSearchInputIconWrapperContent>\n </AnimatePresence>\n ) : (\n <>\n <StyledMotionSearchInputIconWrapper>\n <AnimatePresence initial={false}>\n <StyledMotionSearchInputIconWrapperContent\n animate={{ opacity: 1 }}\n exit={{ opacity: 0, position: 'absolute' }}\n initial={{ opacity: 0 }}\n key={isSearchInputActive ? 'backIcon' : 'searchIcon'}\n transition={{ duration: 0.3 }}\n id={\n isSearchInputActive\n ? 'search-input-backIcon'\n : 'search-input-searchIcon'\n }\n >\n <Icon\n color={iconColor}\n icons={\n isSearchInputActive\n ? ['fa fa-arrow-left']\n : ['fa fa-search']\n }\n onClick={\n isSearchInputActive\n ? handleBackIconClick\n : handleSearchIconClick\n }\n size={18}\n />\n </StyledMotionSearchInputIconWrapperContent>\n </AnimatePresence>\n </StyledMotionSearchInputIconWrapper>\n <AnimatePresence initial={false}>\n {isSearchInputActive && (\n <StyledMotionSearchInputContentWrapper\n $shouldUseAbsolutePositioning={shouldUseAbsolutePositioning}\n animate={{ opacity: 1, width: '100%' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"searchInputContentWrapper\"\n transition={{ duration: 0.3 }}\n >\n <Input\n leftElement={\n <Icon color={theme.text} icons={['far fa-search']} />\n }\n onChange={onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={inputRef}\n shouldShowClearIcon\n size={size}\n value={value}\n />\n </StyledMotionSearchInputContentWrapper>\n )}\n </AnimatePresence>\n </>\n )}\n </StyledSearchInput>\n <StyledSearchInputPseudoElement ref={pseudoRef} />\n </>\n );\n};\n\nSearchInput.displayName = 'SearchInput';\n\nexport default SearchInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AAUA,IAAAG,KAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAH,uBAAA,CAAAF,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAOA,IAAAO,iBAAA,GAAAP,OAAA;AAEA,IAAAQ,eAAA,GAAAR,OAAA;AAA4D,SAAAI,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA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EAAEA,IAAK;IACXG,KAAK,EAAEA;EAAM,CAChB,CACkC,CAE9B,CACnB,CAES,CAAC,eACpBvC,OAAA,CAAAU,OAAA,CAAAkD,aAAA,CAACvD,YAAA,CAAAiF,8BAA8B;IAACX,GAAG,EAAE7B;EAAU,CAAE,CACnD,CAAC;AAEX,CAAC;AAEDlB,WAAW,CAAC2D,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA/E,OAAA,GAEzBkB,WAAW","ignoreList":[]}
|
|
@@ -3,34 +3,57 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.StyledSearchInput = exports.StyledMotionSearchInputIconWrapperContent = exports.StyledMotionSearchInputContentWrapper = void 0;
|
|
6
|
+
exports.StyledSearchInputPseudoElement = exports.StyledSearchInput = exports.StyledMotionSearchInputIconWrapperContent = exports.StyledMotionSearchInputIconWrapper = exports.StyledMotionSearchInputContentWrapper = void 0;
|
|
7
7
|
var _react = require("motion/react");
|
|
8
|
-
var _styledComponents =
|
|
9
|
-
function
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
11
|
const StyledSearchInput = exports.StyledSearchInput = _styledComponents.default.div`
|
|
11
12
|
display: flex;
|
|
12
13
|
align-items: center;
|
|
13
|
-
justify-content: center;
|
|
14
|
-
aspect-ratio: 1;
|
|
15
|
-
border-radius: 3px;
|
|
16
14
|
|
|
17
15
|
height: ${({
|
|
18
16
|
$size
|
|
19
17
|
}) => $size === 'medium' ? '42px' : '32px'};
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
${({
|
|
20
|
+
$shouldUseAbsolutePositioning,
|
|
23
21
|
theme
|
|
24
|
-
}) =>
|
|
25
|
-
|
|
22
|
+
}) => $shouldUseAbsolutePositioning ? (0, _styledComponents.css)`
|
|
23
|
+
justify-content: center;
|
|
24
|
+
aspect-ratio: 1;
|
|
25
|
+
border-radius: 3px;
|
|
26
|
+
position: relative;
|
|
27
|
+
|
|
28
|
+
&:hover {
|
|
29
|
+
background-color: ${theme[103]};
|
|
30
|
+
}
|
|
31
|
+
` : (0, _styledComponents.css)`
|
|
32
|
+
gap: 8px;
|
|
33
|
+
justify-content: flex-end;
|
|
34
|
+
width: 100%;
|
|
35
|
+
`}
|
|
26
36
|
`;
|
|
27
|
-
const
|
|
37
|
+
const StyledSearchInputPseudoElement = exports.StyledSearchInputPseudoElement = _styledComponents.default.div`
|
|
28
38
|
position: absolute;
|
|
29
|
-
top: 0;
|
|
30
39
|
right: 0;
|
|
40
|
+
left: 0;
|
|
41
|
+
`;
|
|
42
|
+
const StyledMotionSearchInputContentWrapper = exports.StyledMotionSearchInputContentWrapper = (0, _styledComponents.default)(_react.motion.div)`
|
|
43
|
+
${({
|
|
44
|
+
$shouldUseAbsolutePositioning
|
|
45
|
+
}) => $shouldUseAbsolutePositioning && (0, _styledComponents.css)`
|
|
46
|
+
position: absolute;
|
|
47
|
+
top: 0;
|
|
48
|
+
right: 0;
|
|
49
|
+
`}
|
|
50
|
+
|
|
31
51
|
overflow: hidden;
|
|
32
52
|
`;
|
|
33
53
|
const StyledMotionSearchInputIconWrapperContent = exports.StyledMotionSearchInputIconWrapperContent = (0, _styledComponents.default)(_react.motion.div)`
|
|
34
54
|
display: flex;
|
|
35
55
|
`;
|
|
56
|
+
const StyledMotionSearchInputIconWrapper = exports.StyledMotionSearchInputIconWrapper = _styledComponents.default.div`
|
|
57
|
+
width: 18px;
|
|
58
|
+
`;
|
|
36
59
|
//# sourceMappingURL=SearchInput.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.styles.js","names":["_react","require","_styledComponents","
|
|
1
|
+
{"version":3,"file":"SearchInput.styles.js","names":["_react","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","StyledSearchInput","exports","styled","div","$size","$shouldUseAbsolutePositioning","theme","css","StyledSearchInputPseudoElement","StyledMotionSearchInputContentWrapper","motion","StyledMotionSearchInputIconWrapperContent","StyledMotionSearchInputIconWrapper"],"sources":["../../../../src/components/search-input/SearchInput.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport type { FramerMotionBugFix, WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { InputSize } from '../input/Input';\n\ntype StyledSearchInputProps = WithTheme<{\n $size: InputSize;\n $shouldUseAbsolutePositioning: boolean;\n}>;\n\nexport const StyledSearchInput = styled.div<StyledSearchInputProps>`\n display: flex;\n align-items: center;\n\n height: ${({ $size }: StyledSearchInputProps) => ($size === 'medium' ? '42px' : '32px')};\n\n ${({ $shouldUseAbsolutePositioning, theme }: StyledSearchInputProps) =>\n $shouldUseAbsolutePositioning\n ? css`\n justify-content: center;\n aspect-ratio: 1;\n border-radius: 3px;\n position: relative;\n\n &:hover {\n background-color: ${theme[103]};\n }\n `\n : css`\n gap: 8px;\n justify-content: flex-end;\n width: 100%;\n `}\n`;\n\nexport const StyledSearchInputPseudoElement = styled.div`\n position: absolute;\n right: 0;\n left: 0;\n`;\n\ntype StyledMotionSearchInputContentWrapperProps = {\n $shouldUseAbsolutePositioning: boolean;\n};\n\nexport const StyledMotionSearchInputContentWrapper = styled(\n motion.div,\n)<StyledMotionSearchInputContentWrapperProps>`\n ${({ $shouldUseAbsolutePositioning }) =>\n $shouldUseAbsolutePositioning &&\n css`\n position: absolute;\n top: 0;\n right: 0;\n `}\n\n overflow: hidden;\n`;\n\nexport const StyledMotionSearchInputIconWrapperContent = styled(motion.div)<FramerMotionBugFix>`\n display: flex;\n`;\n\nexport const StyledMotionSearchInputIconWrapper = styled.div`\n width: 18px;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAgD,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA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V,yBAAM,CAACC,GAAG;AAC5D;AACA,CAAC","ignoreList":[]}
|
|
@@ -13,14 +13,12 @@ var _TagInput = require("./TagInput.styles");
|
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const TagInput = ({
|
|
16
|
+
const TagInput = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
19
17
|
placeholder,
|
|
20
18
|
tags,
|
|
21
19
|
onRemove,
|
|
22
20
|
onAdd
|
|
23
|
-
}) => {
|
|
21
|
+
}, ref) => {
|
|
24
22
|
const [internalTags, setInternalTags] = (0, _react.useState)();
|
|
25
23
|
const [currentValue, setCurrentValue] = (0, _react.useState)('');
|
|
26
24
|
const [selectedId, setSelectedId] = (0, _react.useState)();
|
|
@@ -30,6 +28,9 @@ const TagInput = ({
|
|
|
30
28
|
setInternalTags(tags);
|
|
31
29
|
}
|
|
32
30
|
}, [tags]);
|
|
31
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
32
|
+
getUnsavedTagText: currentValue !== '' ? currentValue : undefined
|
|
33
|
+
}), [currentValue]);
|
|
33
34
|
const handleKeyDown = (0, _react.useCallback)(event => {
|
|
34
35
|
if (event.key === 'Enter') {
|
|
35
36
|
setCurrentValue(prevValue => {
|
|
@@ -117,6 +118,6 @@ const TagInput = ({
|
|
|
117
118
|
onChange: handleChange,
|
|
118
119
|
value: currentValue
|
|
119
120
|
})), [content, currentValue, handleKeyDown, placeholder, tags]);
|
|
120
|
-
};
|
|
121
|
+
});
|
|
121
122
|
var _default = exports.default = TagInput;
|
|
122
123
|
//# sourceMappingURL=TagInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagInput.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_uuid","_Badge","_interopRequireDefault","_Icon","_TagInput","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","TagInput","placeholder","tags","onRemove","onAdd","internalTags","setInternalTags","useState","currentValue","setCurrentValue","selectedId","setSelectedId","theme","useTheme","useEffect","handleKeyDown","useCallback","event","key","prevValue","prevTags","newTag","id","uuidv4","text","_internalTags","newSelectedId","length","prevState","_prevState","removedId","updatedTags","filter","tag","undefined","handleChange","target","value","handleIconClick","content","useMemo","items","forEach","push","createElement","backgroundColor","StyledTagInputTagWrapper","StyledTagInputTagWrapperText","icons","onClick","StyledTagInput","StyledTagInputTagInput","onKeyDown","onChange","_default","exports"],"sources":["../../../../src/components/tag-input/TagInput.tsx"],"sourcesContent":["import React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useState,\n type ChangeEvent,\n type KeyboardEvent,\n type ReactElement,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { v4 as uuidv4 } from 'uuid';\nimport type { Tag } from '../../types/tagInput';\nimport Badge from '../badge/Badge';\nimport Icon from '../icon/Icon';\nimport {\n StyledTagInput,\n StyledTagInputTagInput,\n StyledTagInputTagWrapper,\n StyledTagInputTagWrapperText,\n} from './TagInput.styles';\n\nexport type TagInputProps = {\n /**\n * Function to be executed when a tag is added.\n */\n onAdd?: (tag: Tag) => void;\n /**\n * Function to be executed when a tag is removed.\n */\n onRemove?: (id: string) => void;\n /**\n * The placeholder that should be displayed.\n */\n placeholder?: string;\n /**\n * The tags that should be displayed.\n */\n tags?: Tag[];\n};\n\n// ToDo: Add reference with \"save\" function to return unsaved tags\n\nconst TagInput: FC<TagInputProps> = ({ placeholder, tags, onRemove, onAdd }) => {\n const [internalTags, setInternalTags] = useState<Tag[]>();\n const [currentValue, setCurrentValue] = useState('');\n const [selectedId, setSelectedId] = useState<Tag['id']>();\n\n const theme = useTheme();\n\n useEffect(() => {\n if (tags) {\n setInternalTags(tags);\n }\n }, [tags]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n setCurrentValue((prevValue) => {\n if (!prevValue) {\n return '';\n }\n\n setInternalTags((prevTags) => {\n const newTag = { id: uuidv4(), text: prevValue };\n\n if (typeof onAdd === 'function') {\n onAdd(newTag);\n }\n\n return prevTags ? [...prevTags, newTag] : [newTag];\n });\n\n return '';\n });\n }\n\n if (event.key === 'Backspace' && currentValue === '') {\n if (!selectedId) {\n if (!internalTags) {\n return;\n }\n\n const newSelectedId = internalTags[internalTags.length - 1]?.id;\n\n setSelectedId(newSelectedId);\n\n return;\n }\n\n setInternalTags((prevState) => {\n if (!prevState) {\n return prevState;\n }\n\n const removedId = prevState[prevState.length - 1]?.id;\n\n if (!removedId) {\n return prevState;\n }\n\n const updatedTags = (prevState ?? []).filter((tag) => tag.id !== removedId);\n\n if (typeof onRemove === 'function') {\n onRemove(removedId);\n }\n\n setSelectedId(undefined);\n\n return updatedTags;\n });\n }\n },\n [currentValue, internalTags, onAdd, onRemove, selectedId],\n );\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n setCurrentValue(event.target.value);\n\n if (event.target.value !== '') {\n setSelectedId(undefined);\n }\n };\n\n const handleIconClick = useCallback(\n (id: string) => {\n setInternalTags((prevState) => {\n const updatedTags = (prevState ?? []).filter((tag) => tag.id !== id);\n\n if (typeof onRemove === 'function') {\n onRemove(id);\n }\n\n return updatedTags;\n });\n },\n [onRemove],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!internalTags) {\n return items;\n }\n\n internalTags.forEach(({ text, id }) => {\n items.push(\n <Badge\n key={`tag-input-${id}`}\n backgroundColor={\n id === selectedId ? ((theme['206'] as string) ?? undefined) : undefined\n }\n >\n <StyledTagInputTagWrapper>\n <StyledTagInputTagWrapperText>{text}</StyledTagInputTagWrapperText>\n <Icon icons={['ts-wrong']} onClick={() => handleIconClick(id)} />\n </StyledTagInputTagWrapper>\n </Badge>,\n );\n });\n\n return items;\n }, [handleIconClick, internalTags, selectedId, theme]);\n\n return useMemo(\n () => (\n <StyledTagInput>\n {content}\n <StyledTagInputTagInput\n placeholder={tags && tags.length > 0 ? undefined : placeholder}\n onKeyDown={handleKeyDown}\n onChange={handleChange}\n value={currentValue}\n />\n </StyledTagInput>\n ),\n [content, currentValue, handleKeyDown, placeholder, tags],\n );\n};\n\nexport default TagInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAUA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAK2B,SAAAI,uBAAAG,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;AAAA,SAAAR,wBAAAQ,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA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C5D,CAAC;AACL,CAAC;AAAC,IAAAoD,QAAA,GAAAC,OAAA,CAAAzE,OAAA,GAEakB,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"TagInput.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_uuid","_Badge","_interopRequireDefault","_Icon","_TagInput","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","TagInput","forwardRef","placeholder","tags","onRemove","onAdd","ref","internalTags","setInternalTags","useState","currentValue","setCurrentValue","selectedId","setSelectedId","theme","useTheme","useEffect","useImperativeHandle","getUnsavedTagText","undefined","handleKeyDown","useCallback","event","key","prevValue","prevTags","newTag","id","uuidv4","text","_internalTags","newSelectedId","length","prevState","_prevState","removedId","updatedTags","filter","tag","handleChange","target","value","handleIconClick","content","useMemo","items","forEach","push","createElement","backgroundColor","StyledTagInputTagWrapper","StyledTagInputTagWrapperText","icons","onClick","StyledTagInput","StyledTagInputTagInput","onKeyDown","onChange","_default","exports"],"sources":["../../../../src/components/tag-input/TagInput.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useState,\n type ChangeEvent,\n type KeyboardEvent,\n type ReactElement,\n useImperativeHandle,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { v4 as uuidv4 } from 'uuid';\nimport type { Tag } from '../../types/tagInput';\nimport Badge from '../badge/Badge';\nimport Icon from '../icon/Icon';\nimport {\n StyledTagInput,\n StyledTagInputTagInput,\n StyledTagInputTagWrapper,\n StyledTagInputTagWrapperText,\n} from './TagInput.styles';\n\nexport type TagInputProps = {\n /**\n * Function to be executed when a tag is added.\n */\n onAdd?: (tag: Tag) => void;\n /**\n * Function to be executed when a tag is removed.\n */\n onRemove?: (id: string) => void;\n /**\n * The placeholder that should be displayed.\n */\n placeholder?: string;\n /**\n * The tags that should be displayed.\n */\n tags?: Tag[];\n};\n\nexport type TagInputRef = {\n getUnsavedTagText: Tag['text'] | undefined;\n};\n\nconst TagInput = forwardRef<TagInputRef, TagInputProps>(\n ({ placeholder, tags, onRemove, onAdd }, ref) => {\n const [internalTags, setInternalTags] = useState<Tag[]>();\n const [currentValue, setCurrentValue] = useState('');\n const [selectedId, setSelectedId] = useState<Tag['id']>();\n\n const theme = useTheme();\n\n useEffect(() => {\n if (tags) {\n setInternalTags(tags);\n }\n }, [tags]);\n\n useImperativeHandle(\n ref,\n () => ({\n getUnsavedTagText: currentValue !== '' ? currentValue : undefined,\n }),\n [currentValue],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n setCurrentValue((prevValue) => {\n if (!prevValue) {\n return '';\n }\n\n setInternalTags((prevTags) => {\n const newTag = { id: uuidv4(), text: prevValue };\n\n if (typeof onAdd === 'function') {\n onAdd(newTag);\n }\n\n return prevTags ? [...prevTags, newTag] : [newTag];\n });\n\n return '';\n });\n }\n\n if (event.key === 'Backspace' && currentValue === '') {\n if (!selectedId) {\n if (!internalTags) {\n return;\n }\n\n const newSelectedId = internalTags[internalTags.length - 1]?.id;\n\n setSelectedId(newSelectedId);\n\n return;\n }\n\n setInternalTags((prevState) => {\n if (!prevState) {\n return prevState;\n }\n\n const removedId = prevState[prevState.length - 1]?.id;\n\n if (!removedId) {\n return prevState;\n }\n\n const updatedTags = (prevState ?? []).filter((tag) => tag.id !== removedId);\n\n if (typeof onRemove === 'function') {\n onRemove(removedId);\n }\n\n setSelectedId(undefined);\n\n return updatedTags;\n });\n }\n },\n [currentValue, internalTags, onAdd, onRemove, selectedId],\n );\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n setCurrentValue(event.target.value);\n\n if (event.target.value !== '') {\n setSelectedId(undefined);\n }\n };\n\n const handleIconClick = useCallback(\n (id: string) => {\n setInternalTags((prevState) => {\n const updatedTags = (prevState ?? []).filter((tag) => tag.id !== id);\n\n if (typeof onRemove === 'function') {\n onRemove(id);\n }\n\n return updatedTags;\n });\n },\n [onRemove],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!internalTags) {\n return items;\n }\n\n internalTags.forEach(({ text, id }) => {\n items.push(\n <Badge\n key={`tag-input-${id}`}\n backgroundColor={\n id === selectedId ? ((theme['206'] as string) ?? undefined) : undefined\n }\n >\n <StyledTagInputTagWrapper>\n <StyledTagInputTagWrapperText>{text}</StyledTagInputTagWrapperText>\n <Icon icons={['ts-wrong']} onClick={() => handleIconClick(id)} />\n </StyledTagInputTagWrapper>\n </Badge>,\n );\n });\n\n return items;\n }, [handleIconClick, internalTags, selectedId, theme]);\n\n return useMemo(\n () => (\n <StyledTagInput>\n {content}\n <StyledTagInputTagInput\n placeholder={tags && tags.length > 0 ? undefined : placeholder}\n onKeyDown={handleKeyDown}\n onChange={handleChange}\n value={currentValue}\n />\n </StyledTagInput>\n ),\n [content, currentValue, handleKeyDown, placeholder, tags],\n );\n },\n);\n\nexport default TagInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAWA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAK2B,SAAAI,uBAAAG,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;AAAA,SAAAR,wBAAAQ,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CA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AAY;IAC/DsD,SAAS,EAAEpC,aAAc;IACzBqC,QAAQ,EAAElB,YAAa;IACvBE,KAAK,EAAE/B;EAAa,CACvB,CACW,CACnB,EACD,CAACiC,OAAO,EAAEjC,YAAY,EAAEU,aAAa,EAAElB,WAAW,EAAEC,IAAI,CAC5D,CAAC;AACL,CACJ,CAAC;AAAC,IAAAuD,QAAA,GAAAC,OAAA,CAAA7E,OAAA,GAEakB,QAAQ","ignoreList":[]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AnimatePresence } from 'motion/react';
|
|
2
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import Icon from '../icon/Icon';
|
|
4
4
|
import Input, { InputSize } from '../input/Input';
|
|
5
|
-
import { StyledMotionSearchInputContentWrapper, StyledMotionSearchInputIconWrapperContent, StyledSearchInput } from './SearchInput.styles';
|
|
5
|
+
import { StyledMotionSearchInputContentWrapper, StyledMotionSearchInputIconWrapper, StyledMotionSearchInputIconWrapperContent, StyledSearchInput, StyledSearchInputPseudoElement } from './SearchInput.styles';
|
|
6
|
+
import { useTheme } from 'styled-components';
|
|
7
|
+
import { useElementSize } from '../../hooks/useElementSize';
|
|
6
8
|
const SearchInput = _ref => {
|
|
7
9
|
let {
|
|
8
10
|
iconColor,
|
|
@@ -11,11 +13,15 @@ const SearchInput = _ref => {
|
|
|
11
13
|
onChange,
|
|
12
14
|
onKeyDown,
|
|
13
15
|
placeholder,
|
|
16
|
+
shouldUseAbsolutePositioning = false,
|
|
14
17
|
size = InputSize.Medium,
|
|
15
18
|
value
|
|
16
19
|
} = _ref;
|
|
17
20
|
const [isSearchInputActive, setIsSearchInputActive] = useState(isActive ?? (typeof value === 'string' && value.trim() !== ''));
|
|
18
21
|
const inputRef = useRef(null);
|
|
22
|
+
const pseudoRef = useRef(null);
|
|
23
|
+
const parentWidth = useElementSize(pseudoRef);
|
|
24
|
+
const theme = useTheme();
|
|
19
25
|
const handleBackIconClick = useCallback(() => setIsSearchInputActive(false), []);
|
|
20
26
|
const handleSearchIconClick = useCallback(() => setIsSearchInputActive(true), []);
|
|
21
27
|
useEffect(() => {
|
|
@@ -31,15 +37,18 @@ const SearchInput = _ref => {
|
|
|
31
37
|
setIsSearchInputActive(isActive);
|
|
32
38
|
}
|
|
33
39
|
}, [isActive]);
|
|
34
|
-
|
|
40
|
+
const width = useMemo(() => parentWidth?.width, [parentWidth?.width]);
|
|
41
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledSearchInput, {
|
|
35
42
|
className: "beta-chayns-search-input",
|
|
36
|
-
$size: size
|
|
37
|
-
|
|
43
|
+
$size: size,
|
|
44
|
+
$shouldUseAbsolutePositioning: shouldUseAbsolutePositioning
|
|
45
|
+
}, shouldUseAbsolutePositioning ? /*#__PURE__*/React.createElement(AnimatePresence, {
|
|
38
46
|
initial: false
|
|
39
47
|
}, isSearchInputActive && /*#__PURE__*/React.createElement(StyledMotionSearchInputContentWrapper, {
|
|
48
|
+
$shouldUseAbsolutePositioning: shouldUseAbsolutePositioning,
|
|
40
49
|
animate: {
|
|
41
50
|
opacity: 1,
|
|
42
|
-
width
|
|
51
|
+
width
|
|
43
52
|
},
|
|
44
53
|
exit: {
|
|
45
54
|
opacity: 0,
|
|
@@ -82,7 +91,64 @@ const SearchInput = _ref => {
|
|
|
82
91
|
icons: isSearchInputActive ? ['fa fa-xmark'] : ['fa fa-search'],
|
|
83
92
|
onClick: isSearchInputActive ? handleBackIconClick : handleSearchIconClick,
|
|
84
93
|
size: 18
|
|
85
|
-
})))
|
|
94
|
+
}))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledMotionSearchInputIconWrapper, null, /*#__PURE__*/React.createElement(AnimatePresence, {
|
|
95
|
+
initial: false
|
|
96
|
+
}, /*#__PURE__*/React.createElement(StyledMotionSearchInputIconWrapperContent, {
|
|
97
|
+
animate: {
|
|
98
|
+
opacity: 1
|
|
99
|
+
},
|
|
100
|
+
exit: {
|
|
101
|
+
opacity: 0,
|
|
102
|
+
position: 'absolute'
|
|
103
|
+
},
|
|
104
|
+
initial: {
|
|
105
|
+
opacity: 0
|
|
106
|
+
},
|
|
107
|
+
key: isSearchInputActive ? 'backIcon' : 'searchIcon',
|
|
108
|
+
transition: {
|
|
109
|
+
duration: 0.3
|
|
110
|
+
},
|
|
111
|
+
id: isSearchInputActive ? 'search-input-backIcon' : 'search-input-searchIcon'
|
|
112
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
113
|
+
color: iconColor,
|
|
114
|
+
icons: isSearchInputActive ? ['fa fa-arrow-left'] : ['fa fa-search'],
|
|
115
|
+
onClick: isSearchInputActive ? handleBackIconClick : handleSearchIconClick,
|
|
116
|
+
size: 18
|
|
117
|
+
})))), /*#__PURE__*/React.createElement(AnimatePresence, {
|
|
118
|
+
initial: false
|
|
119
|
+
}, isSearchInputActive && /*#__PURE__*/React.createElement(StyledMotionSearchInputContentWrapper, {
|
|
120
|
+
$shouldUseAbsolutePositioning: shouldUseAbsolutePositioning,
|
|
121
|
+
animate: {
|
|
122
|
+
opacity: 1,
|
|
123
|
+
width: '100%'
|
|
124
|
+
},
|
|
125
|
+
exit: {
|
|
126
|
+
opacity: 0,
|
|
127
|
+
width: 0
|
|
128
|
+
},
|
|
129
|
+
initial: {
|
|
130
|
+
opacity: 0,
|
|
131
|
+
width: 0
|
|
132
|
+
},
|
|
133
|
+
key: "searchInputContentWrapper",
|
|
134
|
+
transition: {
|
|
135
|
+
duration: 0.3
|
|
136
|
+
}
|
|
137
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
138
|
+
leftElement: /*#__PURE__*/React.createElement(Icon, {
|
|
139
|
+
color: theme.text,
|
|
140
|
+
icons: ['far fa-search']
|
|
141
|
+
}),
|
|
142
|
+
onChange: onChange,
|
|
143
|
+
onKeyDown: onKeyDown,
|
|
144
|
+
placeholder: placeholder,
|
|
145
|
+
ref: inputRef,
|
|
146
|
+
shouldShowClearIcon: true,
|
|
147
|
+
size: size,
|
|
148
|
+
value: value
|
|
149
|
+
}))))), /*#__PURE__*/React.createElement(StyledSearchInputPseudoElement, {
|
|
150
|
+
ref: pseudoRef
|
|
151
|
+
}));
|
|
86
152
|
};
|
|
87
153
|
SearchInput.displayName = 'SearchInput';
|
|
88
154
|
export default SearchInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.js","names":["AnimatePresence","React","useCallback","useEffect","useRef","useState","Icon","Input","InputSize","StyledMotionSearchInputContentWrapper","StyledMotionSearchInputIconWrapperContent","StyledSearchInput","SearchInput","_ref","iconColor","isActive","onActiveChange","onChange","onKeyDown","placeholder","size","Medium","value","isSearchInputActive","setIsSearchInputActive","trim","inputRef","handleBackIconClick","handleSearchIconClick","current","focus","createElement","className","$size","initial","animate","opacity","width","exit","key","transition","duration","ref","shouldShowClearIcon","position","id","color","icons","onClick","displayName"],"sources":["../../../../src/components/search-input/SearchInput.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n CSSProperties,\n FC,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport Icon from '../icon/Icon';\nimport Input, { InputRef, InputSize } from '../input/Input';\nimport {\n StyledMotionSearchInputContentWrapper,\n StyledMotionSearchInputIconWrapperContent,\n StyledSearchInput,\n} from './SearchInput.styles';\n\nexport type SearchInputProps = {\n /**\n * Color of the icon\n */\n iconColor?: CSSProperties['color'];\n /**\n * Force the active state of the input and override the internal state\n */\n isActive?: boolean;\n /**\n * Function that is executed when the active state of the input changes\n */\n onActiveChange?: (isActive: boolean) => void;\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 a key is pressed\n */\n onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * The size of the input field\n */\n size?: InputSize;\n /**\n * Value if the input field should be controlled\n */\n value?: string;\n};\n\nconst SearchInput: FC<SearchInputProps> = ({\n iconColor,\n isActive,\n onActiveChange,\n onChange,\n onKeyDown,\n placeholder,\n size = InputSize.Medium,\n value,\n}) => {\n const [isSearchInputActive, setIsSearchInputActive] = useState(\n isActive ?? (typeof value === 'string' && value.trim() !== ''),\n );\n\n const inputRef = useRef<InputRef>(null);\n\n const handleBackIconClick = useCallback(() => setIsSearchInputActive(false), []);\n\n const handleSearchIconClick = useCallback(() => setIsSearchInputActive(true), []);\n\n useEffect(() => {\n if (typeof onActiveChange === 'function') {\n onActiveChange(isSearchInputActive);\n }\n\n if (isSearchInputActive) {\n inputRef.current?.focus();\n }\n }, [isSearchInputActive, onActiveChange]);\n\n useEffect(() => {\n if (typeof isActive === 'boolean') {\n setIsSearchInputActive(isActive);\n }\n }, [isActive]);\n\n return (\n <StyledSearchInput className=\"beta-chayns-search-input\" $size={size}>\n <AnimatePresence initial={false}>\n {isSearchInputActive && (\n <StyledMotionSearchInputContentWrapper\n animate={{ opacity: 1, width: '100%' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"searchInputContentWrapper\"\n transition={{ duration: 0.3 }}\n >\n <Input\n onChange={onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={inputRef}\n shouldShowClearIcon\n size={size}\n value={value}\n />\n </StyledMotionSearchInputContentWrapper>\n )}\n <StyledMotionSearchInputIconWrapperContent\n animate={{ opacity: 1 }}\n exit={{ opacity: 0, position: 'absolute' }}\n initial={{ opacity: 0 }}\n key={isSearchInputActive ? 'backIcon' : 'searchIcon'}\n transition={{ duration: 0.3 }}\n id={isSearchInputActive ? 'search-input-backIcon' : 'search-input-searchIcon'}\n >\n <Icon\n color={iconColor}\n icons={isSearchInputActive ? ['fa fa-xmark'] : ['fa fa-search']}\n onClick={isSearchInputActive ? handleBackIconClick : handleSearchIconClick}\n size={18}\n />\n </StyledMotionSearchInputIconWrapperContent>\n </AnimatePresence>\n </StyledSearchInput>\n );\n};\n\nSearchInput.displayName = 'SearchInput';\n\nexport default SearchInput;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,cAAc;AAC9C,OAAOC,KAAK,IAIRC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,KAAK,IAAcC,SAAS,QAAQ,gBAAgB;AAC3D,SACIC,qCAAqC,EACrCC,yCAAyC,EACzCC,iBAAiB,QACd,sBAAsB;AAqC7B,MAAMC,WAAiC,GAAGC,IAAA,IASpC;EAAA,IATqC;IACvCC,SAAS;IACTC,QAAQ;IACRC,cAAc;IACdC,QAAQ;IACRC,SAAS;IACTC,WAAW;IACXC,IAAI,GAAGZ,SAAS,CAACa,MAAM;IACvBC;EACJ,CAAC,GAAAT,IAAA;EACG,MAAM,CAACU,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGnB,QAAQ,CAC1DU,QAAQ,KAAK,OAAOO,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACG,IAAI,CAAC,CAAC,KAAK,EAAE,CACjE,CAAC;EAED,MAAMC,QAAQ,GAAGtB,MAAM,CAAW,IAAI,CAAC;EAEvC,MAAMuB,mBAAmB,GAAGzB,WAAW,CAAC,MAAMsB,sBAAsB,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;EAEhF,MAAMI,qBAAqB,GAAG1B,WAAW,CAAC,MAAMsB,sBAAsB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;EAEjFrB,SAAS,CAAC,MAAM;IACZ,IAAI,OAAOa,cAAc,KAAK,UAAU,EAAE;MACtCA,cAAc,CAACO,mBAAmB,CAAC;IACvC;IAEA,IAAIA,mBAAmB,EAAE;MACrBG,QAAQ,CAACG,OAAO,EAAEC,KAAK,CAAC,CAAC;IAC7B;EACJ,CAAC,EAAE,CAACP,mBAAm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AU,GAAG,YAAa;IACrDiB,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAI,CAAE;IAC9BI,EAAE,EAAEtB,mBAAmB,GAAG,uBAAuB,GAAG;EAA0B,gBAE9EtB,KAAA,CAAA8B,aAAA,CAACzB,IAAI;IACDwC,KAAK,EAAEhC,SAAU;IACjBiC,KAAK,EAAExB,mBAAmB,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,CAAE;IAChEyB,OAAO,EAAEzB,mBAAmB,GAAGI,mBAAmB,GAAGC,qBAAsB;IAC3ER,IAAI,EAAE;EAAG,CACZ,CACsC,CAC9B,CACF,CAAC;AAE5B,CAAC;AAEDR,WAAW,CAACqC,WAAW,GAAG,aAAa;AAEvC,eAAerC,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SearchInput.js","names":["AnimatePresence","React","useCallback","useEffect","useMemo","useRef","useState","Icon","Input","InputSize","StyledMotionSearchInputContentWrapper","StyledMotionSearchInputIconWrapper","StyledMotionSearchInputIconWrapperContent","StyledSearchInput","StyledSearchInputPseudoElement","useTheme","useElementSize","SearchInput","_ref","iconColor","isActive","onActiveChange","onChange","onKeyDown","placeholder","shouldUseAbsolutePositioning","size","Medium","value","isSearchInputActive","setIsSearchInputActive","trim","inputRef","pseudoRef","parentWidth","theme","handleBackIconClick","handleSearchIconClick","current","focus","width","createElement","Fragment","className","$size","$shouldUseAbsolutePositioning","initial","animate","opacity","exit","key","transition","duration","ref","shouldShowClearIcon","position","id","color","icons","onClick","leftElement","text","displayName"],"sources":["../../../../src/components/search-input/SearchInput.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n ChangeEventHandler,\n CSSProperties,\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport Icon from '../icon/Icon';\nimport Input, { InputRef, InputSize } from '../input/Input';\nimport {\n StyledMotionSearchInputContentWrapper,\n StyledMotionSearchInputIconWrapper,\n StyledMotionSearchInputIconWrapperContent,\n StyledSearchInput,\n StyledSearchInputPseudoElement,\n} from './SearchInput.styles';\nimport { useTheme } from 'styled-components';\nimport { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { useElementSize } from '../../hooks/useElementSize';\n\nexport type SearchInputProps = {\n /**\n * Color of the icon\n */\n iconColor?: CSSProperties['color'];\n /**\n * Force the active state of the input and override the internal state\n */\n isActive?: boolean;\n /**\n * Function that is executed when the active state of the input changes\n */\n onActiveChange?: (isActive: boolean) => void;\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 a key is pressed\n */\n onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Whether the SearchInput should be positioned absolute.\n */\n shouldUseAbsolutePositioning?: boolean;\n /**\n * The size of the input field\n */\n size?: InputSize;\n /**\n * Value if the input field should be controlled\n */\n value?: string;\n};\n\nconst SearchInput: FC<SearchInputProps> = ({\n iconColor,\n isActive,\n onActiveChange,\n onChange,\n onKeyDown,\n placeholder,\n shouldUseAbsolutePositioning = false,\n size = InputSize.Medium,\n value,\n}) => {\n const [isSearchInputActive, setIsSearchInputActive] = useState(\n isActive ?? (typeof value === 'string' && value.trim() !== ''),\n );\n\n const inputRef = useRef<InputRef>(null);\n const pseudoRef = useRef<HTMLDivElement>(null);\n\n const parentWidth = useElementSize(pseudoRef);\n\n const theme = useTheme() as Theme;\n\n const handleBackIconClick = useCallback(() => setIsSearchInputActive(false), []);\n\n const handleSearchIconClick = useCallback(() => setIsSearchInputActive(true), []);\n\n useEffect(() => {\n if (typeof onActiveChange === 'function') {\n onActiveChange(isSearchInputActive);\n }\n\n if (isSearchInputActive) {\n inputRef.current?.focus();\n }\n }, [isSearchInputActive, onActiveChange]);\n\n useEffect(() => {\n if (typeof isActive === 'boolean') {\n setIsSearchInputActive(isActive);\n }\n }, [isActive]);\n\n const width = useMemo(() => parentWidth?.width, [parentWidth?.width]);\n\n return (\n <>\n <StyledSearchInput\n className=\"beta-chayns-search-input\"\n $size={size}\n $shouldUseAbsolutePositioning={shouldUseAbsolutePositioning}\n >\n {shouldUseAbsolutePositioning ? (\n <AnimatePresence initial={false}>\n {isSearchInputActive && (\n <StyledMotionSearchInputContentWrapper\n $shouldUseAbsolutePositioning={shouldUseAbsolutePositioning}\n animate={{ opacity: 1, width }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"searchInputContentWrapper\"\n transition={{ duration: 0.3 }}\n >\n <Input\n onChange={onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={inputRef}\n shouldShowClearIcon\n size={size}\n value={value}\n />\n </StyledMotionSearchInputContentWrapper>\n )}\n <StyledMotionSearchInputIconWrapperContent\n animate={{ opacity: 1 }}\n exit={{ opacity: 0, position: 'absolute' }}\n initial={{ opacity: 0 }}\n key={isSearchInputActive ? 'backIcon' : 'searchIcon'}\n transition={{ duration: 0.3 }}\n id={\n isSearchInputActive\n ? 'search-input-backIcon'\n : 'search-input-searchIcon'\n }\n >\n <Icon\n color={iconColor}\n icons={isSearchInputActive ? ['fa fa-xmark'] : ['fa fa-search']}\n onClick={\n isSearchInputActive\n ? handleBackIconClick\n : handleSearchIconClick\n }\n size={18}\n />\n </StyledMotionSearchInputIconWrapperContent>\n </AnimatePresence>\n ) : (\n <>\n <StyledMotionSearchInputIconWrapper>\n <AnimatePresence initial={false}>\n <StyledMotionSearchInputIconWrapperContent\n animate={{ opacity: 1 }}\n exit={{ opacity: 0, position: 'absolute' }}\n initial={{ opacity: 0 }}\n key={isSearchInputActive ? 'backIcon' : 'searchIcon'}\n transition={{ duration: 0.3 }}\n id={\n isSearchInputActive\n ? 'search-input-backIcon'\n : 'search-input-searchIcon'\n }\n >\n <Icon\n color={iconColor}\n icons={\n isSearchInputActive\n ? ['fa fa-arrow-left']\n : ['fa fa-search']\n }\n onClick={\n isSearchInputActive\n ? handleBackIconClick\n : handleSearchIconClick\n }\n size={18}\n />\n </StyledMotionSearchInputIconWrapperContent>\n </AnimatePresence>\n </StyledMotionSearchInputIconWrapper>\n <AnimatePresence initial={false}>\n {isSearchInputActive && (\n <StyledMotionSearchInputContentWrapper\n $shouldUseAbsolutePositioning={shouldUseAbsolutePositioning}\n animate={{ opacity: 1, width: '100%' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"searchInputContentWrapper\"\n transition={{ duration: 0.3 }}\n >\n <Input\n leftElement={\n <Icon color={theme.text} icons={['far fa-search']} />\n }\n onChange={onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={inputRef}\n shouldShowClearIcon\n size={size}\n value={value}\n />\n </StyledMotionSearchInputContentWrapper>\n )}\n </AnimatePresence>\n </>\n )}\n </StyledSearchInput>\n <StyledSearchInputPseudoElement ref={pseudoRef} />\n </>\n );\n};\n\nSearchInput.displayName = 'SearchInput';\n\nexport default SearchInput;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,cAAc;AAC9C,OAAOC,KAAK,IAIRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,KAAK,IAAcC,SAAS,QAAQ,gBAAgB;AAC3D,SACIC,qCAAqC,EACrCC,kCAAkC,EAClCC,yCAAyC,EACzCC,iBAAiB,EACjBC,8BAA8B,QAC3B,sBAAsB;AAC7B,SAASC,QAAQ,QAAQ,mBAAmB;AAE5C,SAASC,cAAc,QAAQ,4BAA4B;AAyC3D,MAAMC,WAAiC,GAAGC,IAAA,IAUpC;EAAA,IAVqC;IACvCC,SAAS;IACTC,QAAQ;IACRC,cAAc;IACdC,QAAQ;IACRC,SAAS;IACTC,WAAW;IACXC,4BAA4B,GAAG,KAAK;IACpCC,IAAI,GAAGjB,SAAS,CAACkB,MAAM;IACvBC;EACJ,CAAC,GAAAV,IAAA;E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ER,KAAK,EAAE;IAAO,CAAE;IACvCS,IAAI,EAAE;MAAED,OAAO,EAAE,CAAC;MAAER,KAAK,EAAE;IAAE,CAAE;IAC/BM,OAAO,EAAE;MAAEE,OAAO,EAAE,CAAC;MAAER,KAAK,EAAE;IAAE,CAAE;IAClCU,GAAG,EAAC,2BAA2B;IAC/BC,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAI;EAAE,gBAE9BnD,KAAA,CAAAwC,aAAA,CAACjC,KAAK;IACFoD,WAAW,eACP3D,KAAA,CAAAwC,aAAA,CAAClC,IAAI;MAACkD,KAAK,EAAEtB,KAAK,CAAC0B,IAAK;MAACH,KAAK,EAAE,CAAC,eAAe;IAAE,CAAE,CACvD;IACDpC,QAAQ,EAAEA,QAAS;IACnBC,SAAS,EAAEA,SAAU;IACrBC,WAAW,EAAEA,WAAY;IACzB6B,GAAG,EAAErB,QAAS;IACdsB,mBAAmB;IACnB5B,IAAI,EAAEA,IAAK;IACXE,KAAK,EAAEA;EAAM,CAChB,CACkC,CAE9B,CACnB,CAES,CAAC,eACpB3B,KAAA,CAAAwC,aAAA,CAAC3B,8BAA8B;IAACuC,GAAG,EAAEpB;EAAU,CAAE,CACnD,CAAC;AAEX,CAAC;AAEDhB,WAAW,CAAC6C,WAAW,GAAG,aAAa;AAEvC,eAAe7C,WAAW","ignoreList":[]}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { motion } from 'motion/react';
|
|
2
|
-
import styled from 'styled-components';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
3
|
export const StyledSearchInput = styled.div`
|
|
4
4
|
display: flex;
|
|
5
5
|
align-items: center;
|
|
6
|
-
justify-content: center;
|
|
7
|
-
aspect-ratio: 1;
|
|
8
|
-
border-radius: 3px;
|
|
9
6
|
|
|
10
7
|
height: ${_ref => {
|
|
11
8
|
let {
|
|
@@ -14,22 +11,50 @@ export const StyledSearchInput = styled.div`
|
|
|
14
11
|
return $size === 'medium' ? '42px' : '32px';
|
|
15
12
|
}};
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
background-color: ${_ref2 => {
|
|
14
|
+
${_ref2 => {
|
|
19
15
|
let {
|
|
16
|
+
$shouldUseAbsolutePositioning,
|
|
20
17
|
theme
|
|
21
18
|
} = _ref2;
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
return $shouldUseAbsolutePositioning ? css`
|
|
20
|
+
justify-content: center;
|
|
21
|
+
aspect-ratio: 1;
|
|
22
|
+
border-radius: 3px;
|
|
23
|
+
position: relative;
|
|
24
|
+
|
|
25
|
+
&:hover {
|
|
26
|
+
background-color: ${theme[103]};
|
|
27
|
+
}
|
|
28
|
+
` : css`
|
|
29
|
+
gap: 8px;
|
|
30
|
+
justify-content: flex-end;
|
|
31
|
+
width: 100%;
|
|
32
|
+
`;
|
|
33
|
+
}}
|
|
25
34
|
`;
|
|
26
|
-
export const
|
|
35
|
+
export const StyledSearchInputPseudoElement = styled.div`
|
|
27
36
|
position: absolute;
|
|
28
|
-
top: 0;
|
|
29
37
|
right: 0;
|
|
38
|
+
left: 0;
|
|
39
|
+
`;
|
|
40
|
+
export const StyledMotionSearchInputContentWrapper = styled(motion.div)`
|
|
41
|
+
${_ref3 => {
|
|
42
|
+
let {
|
|
43
|
+
$shouldUseAbsolutePositioning
|
|
44
|
+
} = _ref3;
|
|
45
|
+
return $shouldUseAbsolutePositioning && css`
|
|
46
|
+
position: absolute;
|
|
47
|
+
top: 0;
|
|
48
|
+
right: 0;
|
|
49
|
+
`;
|
|
50
|
+
}}
|
|
51
|
+
|
|
30
52
|
overflow: hidden;
|
|
31
53
|
`;
|
|
32
54
|
export const StyledMotionSearchInputIconWrapperContent = styled(motion.div)`
|
|
33
55
|
display: flex;
|
|
34
56
|
`;
|
|
57
|
+
export const StyledMotionSearchInputIconWrapper = styled.div`
|
|
58
|
+
width: 18px;
|
|
59
|
+
`;
|
|
35
60
|
//# sourceMappingURL=SearchInput.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.styles.js","names":["motion","styled","StyledSearchInput","div","_ref","$size","_ref2","theme","StyledMotionSearchInputContentWrapper","StyledMotionSearchInputIconWrapperContent"],"sources":["../../../../src/components/search-input/SearchInput.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled from 'styled-components';\nimport type { FramerMotionBugFix, WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { InputSize } from '../input/Input';\n\ntype StyledSearchInputProps = WithTheme<{\n $size: InputSize;\n}>;\n\nexport const StyledSearchInput = styled.div<StyledSearchInputProps>`\n display: flex;\n align-items: center;\n
|
|
1
|
+
{"version":3,"file":"SearchInput.styles.js","names":["motion","styled","css","StyledSearchInput","div","_ref","$size","_ref2","$shouldUseAbsolutePositioning","theme","StyledSearchInputPseudoElement","StyledMotionSearchInputContentWrapper","_ref3","StyledMotionSearchInputIconWrapperContent","StyledMotionSearchInputIconWrapper"],"sources":["../../../../src/components/search-input/SearchInput.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport type { FramerMotionBugFix, WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { InputSize } from '../input/Input';\n\ntype StyledSearchInputProps = WithTheme<{\n $size: InputSize;\n $shouldUseAbsolutePositioning: boolean;\n}>;\n\nexport const StyledSearchInput = styled.div<StyledSearchInputProps>`\n display: flex;\n align-items: center;\n\n height: ${({ $size }: StyledSearchInputProps) => ($size === 'medium' ? '42px' : '32px')};\n\n ${({ $shouldUseAbsolutePositioning, theme }: StyledSearchInputProps) =>\n $shouldUseAbsolutePositioning\n ? css`\n justify-content: center;\n aspect-ratio: 1;\n border-radius: 3px;\n position: relative;\n\n &:hover {\n background-color: ${theme[103]};\n }\n `\n : css`\n gap: 8px;\n justify-content: flex-end;\n width: 100%;\n `}\n`;\n\nexport const StyledSearchInputPseudoElement = styled.div`\n position: absolute;\n right: 0;\n left: 0;\n`;\n\ntype StyledMotionSearchInputContentWrapperProps = {\n $shouldUseAbsolutePositioning: boolean;\n};\n\nexport const StyledMotionSearchInputContentWrapper = styled(\n motion.div,\n)<StyledMotionSearchInputContentWrapperProps>`\n ${({ $shouldUseAbsolutePositioning }) =>\n $shouldUseAbsolutePositioning &&\n css`\n position: absolute;\n top: 0;\n right: 0;\n `}\n\n overflow: hidden;\n`;\n\nexport const StyledMotionSearchInputIconWrapperContent = styled(motion.div)<FramerMotionBugFix>`\n display: flex;\n`;\n\nexport const StyledMotionSearchInputIconWrapper = styled.div`\n width: 18px;\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,cAAc;AACrC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAS/C,OAAO,MAAMC,iBAAiB,GAAGF,MAAM,CAACG,GAA2B;AACnE;AACA;AACA;AACA,cAAcC,IAAA;EAAA,IAAC;IAAEC;EAA8B,CAAC,GAAAD,IAAA;EAAA,OAAMC,KAAK,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM;AAAA,CAAC;AAC3F;AACA,MAAMC,KAAA;EAAA,IAAC;IAAEC,6BAA6B;IAAEC;EAA8B,CAAC,GAAAF,KAAA;EAAA,OAC/DC,6BAA6B,GACvBN,GAAG;AACjB;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0CO,KAAK,CAAC,GAAG,CAAC;AACpD;AACA,eAAe,GACDP,GAAG;AACjB;AACA;AACA;AACA,eAAe;AAAA;AACf,CAAC;AAED,OAAO,MAAMQ,8BAA8B,GAAGT,MAAM,CAACG,GAAG;AACxD;AACA;AACA;AACA,CAAC;AAMD,OAAO,MAAMO,qCAAqC,GAAGV,MAAM,CACvDD,MAAM,CAACI,GACX,CAA6C;AAC7C,MAAMQ,KAAA;EAAA,IAAC;IAAEJ;EAA8B,CAAC,GAAAI,KAAA;EAAA,OAChCJ,6BAA6B,IAC7BN,GAAG;AACX;AACA;AACA;AACA,SAAS;AAAA;AACT;AACA;AACA,CAAC;AAED,OAAO,MAAMW,yCAAyC,GAAGZ,MAAM,CAACD,MAAM,CAACI,GAAG,CAAqB;AAC/F;AACA,CAAC;AAED,OAAO,MAAMU,kCAAkC,GAAGb,MAAM,CAACG,GAAG;AAC5D;AACA,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import React, { forwardRef, useCallback, useEffect, useMemo, useState, useImperativeHandle } from 'react';
|
|
2
2
|
import { useTheme } from 'styled-components';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
import Badge from '../badge/Badge';
|
|
5
5
|
import Icon from '../icon/Icon';
|
|
6
6
|
import { StyledTagInput, StyledTagInputTagInput, StyledTagInputTagWrapper, StyledTagInputTagWrapperText } from './TagInput.styles';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const TagInput = _ref => {
|
|
7
|
+
const TagInput = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
10
8
|
let {
|
|
11
9
|
placeholder,
|
|
12
10
|
tags,
|
|
@@ -22,6 +20,9 @@ const TagInput = _ref => {
|
|
|
22
20
|
setInternalTags(tags);
|
|
23
21
|
}
|
|
24
22
|
}, [tags]);
|
|
23
|
+
useImperativeHandle(ref, () => ({
|
|
24
|
+
getUnsavedTagText: currentValue !== '' ? currentValue : undefined
|
|
25
|
+
}), [currentValue]);
|
|
25
26
|
const handleKeyDown = useCallback(event => {
|
|
26
27
|
if (event.key === 'Enter') {
|
|
27
28
|
setCurrentValue(prevValue => {
|
|
@@ -108,6 +109,6 @@ const TagInput = _ref => {
|
|
|
108
109
|
onChange: handleChange,
|
|
109
110
|
value: currentValue
|
|
110
111
|
})), [content, currentValue, handleKeyDown, placeholder, tags]);
|
|
111
|
-
};
|
|
112
|
+
});
|
|
112
113
|
export default TagInput;
|
|
113
114
|
//# sourceMappingURL=TagInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagInput.js","names":["React","useCallback","useEffect","useMemo","useState","useTheme","v4","uuidv4","Badge","Icon","StyledTagInput","StyledTagInputTagInput","StyledTagInputTagWrapper","StyledTagInputTagWrapperText","TagInput","_ref","placeholder","tags","onRemove","onAdd","internalTags","setInternalTags","currentValue","setCurrentValue","selectedId","setSelectedId","theme","handleKeyDown","event","key","prevValue","prevTags","newTag","id","text","newSelectedId","length","prevState","removedId","updatedTags","filter","tag","undefined","handleChange","target","value","handleIconClick","content","items","forEach","_ref2","push","createElement","backgroundColor","icons","onClick","onKeyDown","onChange"],"sources":["../../../../src/components/tag-input/TagInput.tsx"],"sourcesContent":["import React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useState,\n type ChangeEvent,\n type KeyboardEvent,\n type ReactElement,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { v4 as uuidv4 } from 'uuid';\nimport type { Tag } from '../../types/tagInput';\nimport Badge from '../badge/Badge';\nimport Icon from '../icon/Icon';\nimport {\n StyledTagInput,\n StyledTagInputTagInput,\n StyledTagInputTagWrapper,\n StyledTagInputTagWrapperText,\n} from './TagInput.styles';\n\nexport type TagInputProps = {\n /**\n * Function to be executed when a tag is added.\n */\n onAdd?: (tag: Tag) => void;\n /**\n * Function to be executed when a tag is removed.\n */\n onRemove?: (id: string) => void;\n /**\n * The placeholder that should be displayed.\n */\n placeholder?: string;\n /**\n * The tags that should be displayed.\n */\n tags?: Tag[];\n};\n\n// ToDo: Add reference with \"save\" function to return unsaved tags\n\nconst TagInput: FC<TagInputProps> = ({ placeholder, tags, onRemove, onAdd }) => {\n const [internalTags, setInternalTags] = useState<Tag[]>();\n const [currentValue, setCurrentValue] = useState('');\n const [selectedId, setSelectedId] = useState<Tag['id']>();\n\n const theme = useTheme();\n\n useEffect(() => {\n if (tags) {\n setInternalTags(tags);\n }\n }, [tags]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n setCurrentValue((prevValue) => {\n if (!prevValue) {\n return '';\n }\n\n setInternalTags((prevTags) => {\n const newTag = { id: uuidv4(), text: prevValue };\n\n if (typeof onAdd === 'function') {\n onAdd(newTag);\n }\n\n return prevTags ? [...prevTags, newTag] : [newTag];\n });\n\n return '';\n });\n }\n\n if (event.key === 'Backspace' && currentValue === '') {\n if (!selectedId) {\n if (!internalTags) {\n return;\n }\n\n const newSelectedId = internalTags[internalTags.length - 1]?.id;\n\n setSelectedId(newSelectedId);\n\n return;\n }\n\n setInternalTags((prevState) => {\n if (!prevState) {\n return prevState;\n }\n\n const removedId = prevState[prevState.length - 1]?.id;\n\n if (!removedId) {\n return prevState;\n }\n\n const updatedTags = (prevState ?? []).filter((tag) => tag.id !== removedId);\n\n if (typeof onRemove === 'function') {\n onRemove(removedId);\n }\n\n setSelectedId(undefined);\n\n return updatedTags;\n });\n }\n },\n [currentValue, internalTags, onAdd, onRemove, selectedId],\n );\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n setCurrentValue(event.target.value);\n\n if (event.target.value !== '') {\n setSelectedId(undefined);\n }\n };\n\n const handleIconClick = useCallback(\n (id: string) => {\n setInternalTags((prevState) => {\n const updatedTags = (prevState ?? []).filter((tag) => tag.id !== id);\n\n if (typeof onRemove === 'function') {\n onRemove(id);\n }\n\n return updatedTags;\n });\n },\n [onRemove],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!internalTags) {\n return items;\n }\n\n internalTags.forEach(({ text, id }) => {\n items.push(\n <Badge\n key={`tag-input-${id}`}\n backgroundColor={\n id === selectedId ? ((theme['206'] as string) ?? undefined) : undefined\n }\n >\n <StyledTagInputTagWrapper>\n <StyledTagInputTagWrapperText>{text}</StyledTagInputTagWrapperText>\n <Icon icons={['ts-wrong']} onClick={() => handleIconClick(id)} />\n </StyledTagInputTagWrapper>\n </Badge>,\n );\n });\n\n return items;\n }, [handleIconClick, internalTags, selectedId, theme]);\n\n return useMemo(\n () => (\n <StyledTagInput>\n {content}\n <StyledTagInputTagInput\n placeholder={tags && tags.length > 0 ? undefined : placeholder}\n onKeyDown={handleKeyDown}\n onChange={handleChange}\n value={currentValue}\n />\n </StyledTagInput>\n ),\n [content, currentValue, handleKeyDown, placeholder, tags],\n );\n};\n\nexport default TagInput;\n"],"mappings":"AAAA,OAAOA,KAAK,IAERC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,QAAQ,QAIL,OAAO;AACd,SAASC,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AAEnC,OAAOC,KAAK,MAAM,gBAAgB;AAClC,OAAOC,IAAI,MAAM,cAAc;AAC/B,SACIC,cAAc,EACdC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,QACzB,mBAAmB;AAqB1B;;AAEA,MAAMC,QAA2B,GAAGC,IAAA,IAA4C;EAAA,IAA3C;IAAEC,WAAW;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAM,CAAC,GAAAJ,IAAA;EACvE,MAAM,CAACK,YAAY,EAAEC,eAAe,CAAC,GAAGjB,QAAQ,CAAQ,CAAC;EACzD,MAAM,CAACkB,YAAY,EAAEC,eAAe,CAAC,GAAGnB,QAAQ,CAAC,EAAE,CAAC;EACpD,MAAM,CAACoB,UAAU,EAAEC,aAAa,CAAC,GAAGrB,QAAQ,CAAY,CAAC;EAEzD,MAAMsB,KAAK,GAAGrB,QAAQ,CAAC,CAAC;EAExBH,SAAS,CAAC,MAAM;IACZ,IAAIe,IAAI,EAAE;MACNI,eAAe,CAACJ,IAAI,CAAC;IACzB;EACJ,CAAC,EAAE,CAACA,IAAI,CAAC,CAAC;EAEV,MAAMU,aAAa,GAAG1B,WAAW,CAC5B2B,KAAoB,IAAK;IACtB,IAAIA,KAAK,CAACC,GAAG,KAAK,OAAO,EAAE;MACvBN,eAAe,CAAEO,SAAS,IAAK;QAC3B,IAAI,CAACA,SAAS,EAAE;UACZ,OAAO,EAAE;QACb;QAEAT,eAAe,CAAEU,QAAQ,IAAK;UA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,EAAEA,CAAA,KAAMT,eAAe,CAACb,EAAE;MAAE,CAAE,CAC1C,CACvB,CACX,CAAC;IACL,CAAC,CAAC;IAEF,OAAOe,KAAK;EAChB,CAAC,EAAE,CAACF,eAAe,EAAE1B,YAAY,EAAEI,UAAU,EAAEE,KAAK,CAAC,CAAC;EAEtD,OAAOvB,OAAO,CACV,mBACIH,KAAA,CAAAoD,aAAA,CAAC1C,cAAc,QACVqC,OAAO,eACR/C,KAAA,CAAAoD,aAAA,CAACzC,sBAAsB;IACnBK,WAAW,EAAEC,IAAI,IAAIA,IAAI,CAACmB,MAAM,GAAG,CAAC,GAAGM,SAAS,GAAG1B,WAAY;IAC/DwC,SAAS,EAAE7B,aAAc;IACzB8B,QAAQ,EAAEd,YAAa;IACvBE,KAAK,EAAEvB;EAAa,CACvB,CACW,CACnB,EACD,CAACyB,OAAO,EAAEzB,YAAY,EAAEK,aAAa,EAAEX,WAAW,EAAEC,IAAI,CAC5D,CAAC;AACL,CAAC;AAED,eAAeH,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"TagInput.js","names":["React","forwardRef","useCallback","useEffect","useMemo","useState","useImperativeHandle","useTheme","v4","uuidv4","Badge","Icon","StyledTagInput","StyledTagInputTagInput","StyledTagInputTagWrapper","StyledTagInputTagWrapperText","TagInput","_ref","ref","placeholder","tags","onRemove","onAdd","internalTags","setInternalTags","currentValue","setCurrentValue","selectedId","setSelectedId","theme","getUnsavedTagText","undefined","handleKeyDown","event","key","prevValue","prevTags","newTag","id","text","newSelectedId","length","prevState","removedId","updatedTags","filter","tag","handleChange","target","value","handleIconClick","content","items","forEach","_ref2","push","createElement","backgroundColor","icons","onClick","onKeyDown","onChange"],"sources":["../../../../src/components/tag-input/TagInput.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useState,\n type ChangeEvent,\n type KeyboardEvent,\n type ReactElement,\n useImperativeHandle,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { v4 as uuidv4 } from 'uuid';\nimport type { Tag } from '../../types/tagInput';\nimport Badge from '../badge/Badge';\nimport Icon from '../icon/Icon';\nimport {\n StyledTagInput,\n StyledTagInputTagInput,\n StyledTagInputTagWrapper,\n StyledTagInputTagWrapperText,\n} from './TagInput.styles';\n\nexport type TagInputProps = {\n /**\n * Function to be executed when a tag is added.\n */\n onAdd?: (tag: Tag) => void;\n /**\n * Function to be executed when a tag is removed.\n */\n onRemove?: (id: string) => void;\n /**\n * The placeholder that should be displayed.\n */\n placeholder?: string;\n /**\n * The tags that should be displayed.\n */\n tags?: Tag[];\n};\n\nexport type TagInputRef = {\n getUnsavedTagText: Tag['text'] | undefined;\n};\n\nconst TagInput = forwardRef<TagInputRef, TagInputProps>(\n ({ placeholder, tags, onRemove, onAdd }, ref) => {\n const [internalTags, setInternalTags] = useState<Tag[]>();\n const [currentValue, setCurrentValue] = useState('');\n const [selectedId, setSelectedId] = useState<Tag['id']>();\n\n const theme = useTheme();\n\n useEffect(() => {\n if (tags) {\n setInternalTags(tags);\n }\n }, [tags]);\n\n useImperativeHandle(\n ref,\n () => ({\n getUnsavedTagText: currentValue !== '' ? currentValue : undefined,\n }),\n [currentValue],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n setCurrentValue((prevValue) => {\n if (!prevValue) {\n return '';\n }\n\n setInternalTags((prevTags) => {\n const newTag = { id: uuidv4(), text: prevValue };\n\n if (typeof onAdd === 'function') {\n onAdd(newTag);\n }\n\n return prevTags ? [...prevTags, newTag] : [newTag];\n });\n\n return '';\n });\n }\n\n if (event.key === 'Backspace' && currentValue === '') {\n if (!selectedId) {\n if (!internalTags) {\n return;\n }\n\n const newSelectedId = internalTags[internalTags.length - 1]?.id;\n\n setSelectedId(newSelectedId);\n\n return;\n }\n\n setInternalTags((prevState) => {\n if (!prevState) {\n return prevState;\n }\n\n const removedId = prevState[prevState.length - 1]?.id;\n\n if (!removedId) {\n return prevState;\n }\n\n const updatedTags = (prevState ?? []).filter((tag) => tag.id !== removedId);\n\n if (typeof onRemove === 'function') {\n onRemove(removedId);\n }\n\n setSelectedId(undefined);\n\n return updatedTags;\n });\n }\n },\n [currentValue, internalTags, onAdd, onRemove, selectedId],\n );\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n setCurrentValue(event.target.value);\n\n if (event.target.value !== '') {\n setSelectedId(undefined);\n }\n };\n\n const handleIconClick = useCallback(\n (id: string) => {\n setInternalTags((prevState) => {\n const updatedTags = (prevState ?? []).filter((tag) => tag.id !== id);\n\n if (typeof onRemove === 'function') {\n onRemove(id);\n }\n\n return updatedTags;\n });\n },\n [onRemove],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!internalTags) {\n return items;\n }\n\n internalTags.forEach(({ text, id }) => {\n items.push(\n <Badge\n key={`tag-input-${id}`}\n backgroundColor={\n id === selectedId ? ((theme['206'] as string) ?? undefined) : undefined\n }\n >\n <StyledTagInputTagWrapper>\n <StyledTagInputTagWrapperText>{text}</StyledTagInputTagWrapperText>\n <Icon icons={['ts-wrong']} onClick={() => handleIconClick(id)} />\n </StyledTagInputTagWrapper>\n </Badge>,\n );\n });\n\n return items;\n }, [handleIconClick, internalTags, selectedId, theme]);\n\n return useMemo(\n () => (\n <StyledTagInput>\n {content}\n <StyledTagInputTagInput\n placeholder={tags && tags.length > 0 ? undefined : placeholder}\n onKeyDown={handleKeyDown}\n onChange={handleChange}\n value={currentValue}\n />\n </StyledTagInput>\n ),\n [content, currentValue, handleKeyDown, placeholder, tags],\n );\n },\n);\n\nexport default TagInput;\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,QAAQ,EAIRC,mBAAmB,QAChB,OAAO;AACd,SAASC,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AAEnC,OAAOC,KAAK,MAAM,gBAAgB;AAClC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CAAC,CAAC;EAEtD,OAAOzB,OAAO,CACV,mBACIJ,KAAA,CAAAwD,aAAA,CAAC5C,cAAc,QACVuC,OAAO,eACRnD,KAAA,CAAAwD,aAAA,CAAC3C,sBAAsB;IACnBM,WAAW,EAAEC,IAAI,IAAIA,IAAI,CAACqB,MAAM,GAAG,CAAC,GAAGV,SAAS,GAAGZ,WAAY;IAC/DyC,SAAS,EAAE5B,aAAc;IACzB6B,QAAQ,EAAEd,YAAa;IACvBE,KAAK,EAAExB;EAAa,CACvB,CACW,CACnB,EACD,CAAC0B,OAAO,EAAE1B,YAAY,EAAEO,aAAa,EAAEb,WAAW,EAAEC,IAAI,CAC5D,CAAC;AACL,CACJ,CAAC;AAED,eAAeJ,QAAQ","ignoreList":[]}
|
|
@@ -25,6 +25,10 @@ export type SearchInputProps = {
|
|
|
25
25
|
* Placeholder for the input field
|
|
26
26
|
*/
|
|
27
27
|
placeholder?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the SearchInput should be positioned absolute.
|
|
30
|
+
*/
|
|
31
|
+
shouldUseAbsolutePositioning?: boolean;
|
|
28
32
|
/**
|
|
29
33
|
* The size of the input field
|
|
30
34
|
*/
|
|
@@ -2,16 +2,20 @@ import type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';
|
|
|
2
2
|
import type { InputSize } from '../input/Input';
|
|
3
3
|
type StyledSearchInputProps = WithTheme<{
|
|
4
4
|
$size: InputSize;
|
|
5
|
+
$shouldUseAbsolutePositioning: boolean;
|
|
5
6
|
}>;
|
|
6
7
|
export declare const StyledSearchInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledSearchInputProps>> & string;
|
|
8
|
+
export declare const StyledSearchInputPseudoElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
9
|
+
type StyledMotionSearchInputContentWrapperProps = {
|
|
10
|
+
$shouldUseAbsolutePositioning: boolean;
|
|
11
|
+
};
|
|
7
12
|
export declare const StyledMotionSearchInputContentWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<Omit<import("motion/react").HTMLMotionProps<"div">, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
8
13
|
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
9
|
-
}, {
|
|
10
|
-
theme: import("../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
11
|
-
}>> & string & Omit<import("motion/react").ForwardRefComponent<HTMLDivElement, import("motion/react").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
|
|
14
|
+
}, StyledMotionSearchInputContentWrapperProps>> & string & Omit<import("motion/react").ForwardRefComponent<HTMLDivElement, import("motion/react").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
|
|
12
15
|
export declare const StyledMotionSearchInputIconWrapperContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<Omit<import("motion/react").HTMLMotionProps<"div">, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
13
16
|
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
14
17
|
}, {
|
|
15
18
|
theme: import("../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
16
19
|
}>> & string & Omit<import("motion/react").ForwardRefComponent<HTMLDivElement, import("motion/react").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
|
|
20
|
+
export declare const StyledMotionSearchInputIconWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
17
21
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import type { Tag } from '../../types/tagInput';
|
|
3
3
|
export type TagInputProps = {
|
|
4
4
|
/**
|
|
@@ -18,5 +18,8 @@ export type TagInputProps = {
|
|
|
18
18
|
*/
|
|
19
19
|
tags?: Tag[];
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
export type TagInputRef = {
|
|
22
|
+
getUnsavedTagText: Tag['text'] | undefined;
|
|
23
|
+
};
|
|
24
|
+
declare const TagInput: React.ForwardRefExoticComponent<TagInputProps & React.RefAttributes<TagInputRef>>;
|
|
22
25
|
export default TagInput;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.1017",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "79d53ff3b44bc05550d2298d008b66125c93d292"
|
|
92
92
|
}
|