@ntbjs/react-components 2.0.3-rc.1 → 2.0.6
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/build/hooks/useTooltipAutoShow.js +14 -3
- package/build/hooks/useTooltipAutoShow.js.map +1 -1
- package/build/inputs/ActionButton/ActionButton.js +9 -5
- package/build/inputs/ActionButton/ActionButton.js.map +1 -1
- package/build/inputs/ActionButton/ActionButton.styled.js +16 -13
- package/build/inputs/ActionButton/ActionButton.styled.js.map +1 -1
- package/build/inputs/CompactTextInput/CompactTextInput.js +8 -6
- package/build/inputs/CompactTextInput/CompactTextInput.js.map +1 -1
- package/build/inputs/TextArea/TextArea.js +8 -6
- package/build/inputs/TextArea/TextArea.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryBase.js +4 -4
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryBase.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.js +8 -8
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.styled.js +5 -3
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.styled.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryGridCard/AssetGalleryGridCard.js +6 -6
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryGridCard/AssetGalleryGridCard.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryGridCard/AssetGalleryGridCard.styled.js +5 -5
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryGridCard/AssetGalleryGridCard.styled.js.map +1 -1
- package/build/widgets/Instructions/Instructions.js +0 -9
- package/build/widgets/Instructions/Instructions.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { useRef, useState } from 'react';
|
|
1
|
+
import { useRef, useState, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
function useTooltipAutoShow(content) {
|
|
4
|
+
const displayContent = useRef(content);
|
|
4
5
|
const prevContentRef = useRef(content);
|
|
5
6
|
const [forceVisible, setForceVisible] = useState(false);
|
|
7
|
+
const toolTipDisabled = !content;
|
|
8
|
+
const toolTipVisible = forceVisible ? true : undefined;
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (content) {
|
|
11
|
+
displayContent.current = content;
|
|
12
|
+
}
|
|
13
|
+
return () => {};
|
|
14
|
+
}, [content]);
|
|
6
15
|
if (prevContentRef.current !== content) {
|
|
7
16
|
const appeared = content && !prevContentRef.current;
|
|
8
17
|
const disappeared = !content;
|
|
@@ -10,8 +19,10 @@ function useTooltipAutoShow(content) {
|
|
|
10
19
|
prevContentRef.current = content;
|
|
11
20
|
}
|
|
12
21
|
return {
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
toolTipOnMouseLeave: () => setForceVisible(false),
|
|
23
|
+
toolTipContent: displayContent.current,
|
|
24
|
+
toolTipDisabled,
|
|
25
|
+
toolTipVisible
|
|
15
26
|
};
|
|
16
27
|
}
|
|
17
28
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTooltipAutoShow.js","sources":["../../src/hooks/useTooltipAutoShow.js"],"sourcesContent":["import { useRef, useState } from 'react';\n\n/**\n * Tracks a tooltip's content and automatically forces it to be visible when the\n * content transitions from empty → non-empty, then defaults to trigger prop.\n */\nfunction useTooltipAutoShow(content) {\n const prevContentRef = useRef(content);\n const [forceVisible, setForceVisible] = useState(false);\n\n if (prevContentRef.current !== content) {\n const appeared = content && !prevContentRef.current;\n const disappeared = !content;\n\n if (appeared) setForceVisible(true);\n else if (disappeared) setForceVisible(false);\n\n prevContentRef.current = content;\n }\n\n return {\n
|
|
1
|
+
{"version":3,"file":"useTooltipAutoShow.js","sources":["../../src/hooks/useTooltipAutoShow.js"],"sourcesContent":["import { useRef, useState, useEffect } from 'react';\n\n/**\n * Tracks a tooltip's content and automatically forces it to be visible when the\n * content transitions from empty → non-empty, then defaults to trigger prop.\n */\nfunction useTooltipAutoShow(content) {\n const displayContent = useRef(content);\n const prevContentRef = useRef(content);\n const [forceVisible, setForceVisible] = useState(false);\n\n const toolTipDisabled = !content;\n const toolTipVisible = forceVisible ? true : undefined;\n\n useEffect(() => {\n if (content) {\n displayContent.current = content;\n }\n\n return () => {};\n }, [content]);\n\n if (prevContentRef.current !== content) {\n const appeared = content && !prevContentRef.current;\n const disappeared = !content;\n\n if (appeared) setForceVisible(true);\n else if (disappeared) setForceVisible(false);\n\n prevContentRef.current = content;\n }\n\n return {\n toolTipOnMouseLeave: () => setForceVisible(false),\n toolTipContent: displayContent.current,\n toolTipDisabled,\n toolTipVisible\n };\n}\n\nexport default useTooltipAutoShow;\n"],"names":["useTooltipAutoShow","content","displayContent","useRef","prevContentRef","forceVisible","setForceVisible","useState","toolTipDisabled","toolTipVisible","undefined","useEffect","current","appeared","disappeared","toolTipOnMouseLeave","toolTipContent"],"mappings":";;AAMA,SAASA,kBAAkBA,CAACC,OAAO,EAAE;AACnC,EAAA,MAAMC,cAAc,GAAGC,MAAM,CAACF,OAAO,CAAC,CAAA;AACtC,EAAA,MAAMG,cAAc,GAAGD,MAAM,CAACF,OAAO,CAAC,CAAA;EACtC,MAAM,CAACI,YAAY,EAAEC,eAAe,CAAC,GAAGC,QAAQ,CAAC,KAAK,CAAC,CAAA;EAEvD,MAAMC,eAAe,GAAG,CAACP,OAAO,CAAA;AAChC,EAAA,MAAMQ,cAAc,GAAGJ,YAAY,GAAG,IAAI,GAAGK,SAAS,CAAA;AAEtDC,EAAAA,SAAS,CAAC,MAAM;AACd,IAAA,IAAIV,OAAO,EAAE;MACXC,cAAc,CAACU,OAAO,GAAGX,OAAO,CAAA;AAClC,KAAA;IAEA,OAAO,MAAM,EAAE,CAAA;AACjB,GAAC,EAAE,CAACA,OAAO,CAAC,CAAC,CAAA;AAEb,EAAA,IAAIG,cAAc,CAACQ,OAAO,KAAKX,OAAO,EAAE;AACtC,IAAA,MAAMY,QAAQ,GAAGZ,OAAO,IAAI,CAACG,cAAc,CAACQ,OAAO,CAAA;IACnD,MAAME,WAAW,GAAG,CAACb,OAAO,CAAA;AAE5B,IAAA,IAAIY,QAAQ,EAAEP,eAAe,CAAC,IAAI,CAAC,CAAC,KAC/B,IAAIQ,WAAW,EAAER,eAAe,CAAC,KAAK,CAAC,CAAA;IAE5CF,cAAc,CAACQ,OAAO,GAAGX,OAAO,CAAA;AAClC,GAAA;EAEA,OAAO;AACLc,IAAAA,mBAAmB,EAAEA,MAAMT,eAAe,CAAC,KAAK,CAAC;IACjDU,cAAc,EAAEd,cAAc,CAACU,OAAO;IACtCJ,eAAe;AACfC,IAAAA,cAAAA;GACD,CAAA;AACH;;;;"}
|
|
@@ -9,16 +9,18 @@ const ActionButton = React__default.forwardRef(function ActionButton({
|
|
|
9
9
|
active,
|
|
10
10
|
onClick,
|
|
11
11
|
actionWidthHeight,
|
|
12
|
+
useShadow,
|
|
12
13
|
backgroundColors,
|
|
13
14
|
...props
|
|
14
15
|
}, forwardedRef) {
|
|
15
16
|
return React__default.createElement(ActionButton$1, _extends({
|
|
16
17
|
ref: forwardedRef,
|
|
17
18
|
disabled: disabled,
|
|
18
|
-
active: active,
|
|
19
|
+
$active: active,
|
|
19
20
|
onClick: onClick,
|
|
20
|
-
actionWidthHeight: actionWidthHeight,
|
|
21
|
-
backgroundColors: backgroundColors
|
|
21
|
+
$actionWidthHeight: actionWidthHeight,
|
|
22
|
+
$backgroundColors: backgroundColors,
|
|
23
|
+
$useShadow: useShadow
|
|
22
24
|
}, props), icon);
|
|
23
25
|
});
|
|
24
26
|
ActionButton.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
@@ -27,11 +29,13 @@ ActionButton.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
27
29
|
active: PropTypes.bool,
|
|
28
30
|
onClick: PropTypes.func,
|
|
29
31
|
backgroundColors: PropTypes.arrayOf(PropTypes.string),
|
|
30
|
-
actionWidthHeight: PropTypes.array
|
|
32
|
+
actionWidthHeight: PropTypes.array,
|
|
33
|
+
useShadow: PropTypes.bool
|
|
31
34
|
} : {};
|
|
32
35
|
ActionButton.defaultProps = {
|
|
33
36
|
onClick: () => {},
|
|
34
|
-
actionWidthHeight: [40, 40]
|
|
37
|
+
actionWidthHeight: [40, 40],
|
|
38
|
+
useShadow: false
|
|
35
39
|
};
|
|
36
40
|
|
|
37
41
|
export { ActionButton as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionButton.js","sources":["../../../src/components/inputs/ActionButton/ActionButton.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport * as S from './ActionButton.styled';\n\n/**\n * An action button.\n *\n * ### Import\n *\n * ``` js\n * import { ActionButton } from '@ntbjs/react-components/inputs'\n * // or\n * import ActionButton from '@ntbjs/react-components/inputs/ActionButton'\n * ```\n *\n * ### Props\n * ```\n * Pass `icon={<svg></svg>}` to display an icon.\n * Pass `disabled={true}` to disable the button.\n * Pass `active={true}` to lock the hover state of the button.\n * Pass `onClick={() => {}}` to add an on-click effect.\n * Pass `backgroundColors={[#ffffff, #000000]}` to set the background color of the button\n * ```\n */\nconst ActionButton = React.forwardRef(function ActionButton(\n { icon, disabled, active, onClick, actionWidthHeight, backgroundColors, ...props },\n forwardedRef\n) {\n return (\n <S.ActionButton\n ref={forwardedRef}\n disabled={disabled}\n active={active}\n onClick={onClick}\n actionWidthHeight={actionWidthHeight}\n backgroundColors={backgroundColors}\n {...props}\n >\n {icon}\n </S.ActionButton>\n );\n});\n\nActionButton.propTypes = {\n /**\n * Icon element – e.g: `icon={<SvgAddCircle />}`\n */\n icon: PropTypes.element.isRequired,\n /**\n * Disable the action button\n */\n disabled: PropTypes.bool,\n /**\n * Locks the hover state of the `ActionButton` – this prop only affects the visual appearance of the\n * `ActionButton`\n */\n active: PropTypes.bool,\n /**\n * On-click effect for the action button\n */\n onClick: PropTypes.func,\n /**\n * Color of the button background as an array of [darkThemeColor, lightThemeColor]\n */\n backgroundColors: PropTypes.arrayOf(PropTypes.string),\n /**\n * Width and Height of the Action Button [50, 50]\n */\n actionWidthHeight: PropTypes.array\n};\n\nActionButton.defaultProps = {\n onClick: () => {},\n actionWidthHeight: [40, 40]\n};\n\nexport default ActionButton;\n"],"names":["ActionButton","React","forwardRef","icon","disabled","active","onClick","actionWidthHeight","backgroundColors","props","forwardedRef","createElement","S","_extends","ref","propTypes","process","env","NODE_ENV","PropTypes","element","isRequired","bool","func","arrayOf","string","array","defaultProps"],"mappings":";;;;;AAwBMA,MAAAA,YAAY,GAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,YAAYA,CACzD;EAAEG,IAAI;EAAEC,QAAQ;EAAEC,MAAM;EAAEC,OAAO;EAAEC,iBAAiB;EAAEC,gBAAgB;EAAE,GAAGC,KAAAA;AAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"ActionButton.js","sources":["../../../src/components/inputs/ActionButton/ActionButton.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport * as S from './ActionButton.styled';\n\n/**\n * An action button.\n *\n * ### Import\n *\n * ``` js\n * import { ActionButton } from '@ntbjs/react-components/inputs'\n * // or\n * import ActionButton from '@ntbjs/react-components/inputs/ActionButton'\n * ```\n *\n * ### Props\n * ```\n * Pass `icon={<svg></svg>}` to display an icon.\n * Pass `disabled={true}` to disable the button.\n * Pass `active={true}` to lock the hover state of the button.\n * Pass `onClick={() => {}}` to add an on-click effect.\n * Pass `backgroundColors={[#ffffff, #000000]}` to set the background color of the button\n * ```\n */\nconst ActionButton = React.forwardRef(function ActionButton(\n { icon, disabled, active, onClick, actionWidthHeight, useShadow, backgroundColors, ...props },\n forwardedRef\n) {\n return (\n <S.ActionButton\n ref={forwardedRef}\n disabled={disabled}\n $active={active}\n onClick={onClick}\n $actionWidthHeight={actionWidthHeight}\n $backgroundColors={backgroundColors}\n $useShadow={useShadow}\n {...props}\n >\n {icon}\n </S.ActionButton>\n );\n});\n\nActionButton.propTypes = {\n /**\n * Icon element – e.g: `icon={<SvgAddCircle />}`\n */\n icon: PropTypes.element.isRequired,\n /**\n * Disable the action button\n */\n disabled: PropTypes.bool,\n /**\n * Locks the hover state of the `ActionButton` – this prop only affects the visual appearance of the\n * `ActionButton`\n */\n active: PropTypes.bool,\n /**\n * On-click effect for the action button\n */\n onClick: PropTypes.func,\n /**\n * Color of the button background as an array of [darkThemeColor, lightThemeColor]\n */\n backgroundColors: PropTypes.arrayOf(PropTypes.string),\n /**\n * Width and Height of the Action Button [50, 50]\n */\n actionWidthHeight: PropTypes.array,\n /**\n *Use shadow for the action button\n */\n useShadow: PropTypes.bool\n};\n\nActionButton.defaultProps = {\n onClick: () => {},\n actionWidthHeight: [40, 40],\n useShadow: false\n};\n\nexport default ActionButton;\n"],"names":["ActionButton","React","forwardRef","icon","disabled","active","onClick","actionWidthHeight","useShadow","backgroundColors","props","forwardedRef","createElement","S","_extends","ref","$active","$actionWidthHeight","$backgroundColors","$useShadow","propTypes","process","env","NODE_ENV","PropTypes","element","isRequired","bool","func","arrayOf","string","array","defaultProps"],"mappings":";;;;;AAwBMA,MAAAA,YAAY,GAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,YAAYA,CACzD;EAAEG,IAAI;EAAEC,QAAQ;EAAEC,MAAM;EAAEC,OAAO;EAAEC,iBAAiB;EAAEC,SAAS;EAAEC,gBAAgB;EAAE,GAAGC,KAAAA;AAAM,CAAC,EAC7FC,YAAY,EACZ;EACA,OACEV,cAAA,CAAAW,aAAA,CAACC,cAAc,EAAAC,QAAA,CAAA;AACbC,IAAAA,GAAG,EAAEJ,YAAa;AAClBP,IAAAA,QAAQ,EAAEA,QAAS;AACnBY,IAAAA,OAAO,EAAEX,MAAO;AAChBC,IAAAA,OAAO,EAAEA,OAAQ;AACjBW,IAAAA,kBAAkB,EAAEV,iBAAkB;AACtCW,IAAAA,iBAAiB,EAAET,gBAAiB;AACpCU,IAAAA,UAAU,EAAEX,SAAAA;GACRE,EAAAA,KAAK,CAERP,EAAAA,IACa,CAAC,CAAA;AAErB,CAAC,EAAC;AAEFH,YAAY,CAACoB,SAAS,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,KAAG,YAAA,GAAA;AAIvBpB,EAAAA,IAAI,EAAEqB,SAAS,CAACC,OAAO,CAACC,UAAU;EAIlCtB,QAAQ,EAAEoB,SAAS,CAACG,IAAI;EAKxBtB,MAAM,EAAEmB,SAAS,CAACG,IAAI;EAItBrB,OAAO,EAAEkB,SAAS,CAACI,IAAI;EAIvBnB,gBAAgB,EAAEe,SAAS,CAACK,OAAO,CAACL,SAAS,CAACM,MAAM,CAAC;EAIrDvB,iBAAiB,EAAEiB,SAAS,CAACO,KAAK;EAIlCvB,SAAS,EAAEgB,SAAS,CAACG,IAAAA;AACvB,CAAC,GAAA,EAAA,CAAA;AAED3B,YAAY,CAACgC,YAAY,GAAG;AAC1B1B,EAAAA,OAAO,EAAEA,MAAM,EAAE;AACjBC,EAAAA,iBAAiB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;AAC3BC,EAAAA,SAAS,EAAE,KAAA;AACb,CAAC;;;;"}
|
|
@@ -2,13 +2,16 @@ import styled, { css } from 'styled-components';
|
|
|
2
2
|
import { rgba } from 'polished';
|
|
3
3
|
import { applyDefaultTheme } from '../../utils/defaultTheme.js';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const shouldForwardProp = prop => prop !== 'theme' && !prop.startsWith('$');
|
|
6
|
+
const ActionButton = styled.button.withConfig({
|
|
7
|
+
shouldForwardProp
|
|
8
|
+
}).attrs(applyDefaultTheme)`
|
|
6
9
|
display: inline-flex;
|
|
7
10
|
justify-content: center;
|
|
8
11
|
align-items: center;
|
|
9
12
|
border-radius: 50%;
|
|
10
|
-
width: ${props => `${props
|
|
11
|
-
height: ${props => `${props
|
|
13
|
+
width: ${props => `${props.$actionWidthHeight[0]}px`};
|
|
14
|
+
height: ${props => `${props.$actionWidthHeight[1]}px`};
|
|
12
15
|
border: 0;
|
|
13
16
|
color: inherit;
|
|
14
17
|
background-color: transparent;
|
|
@@ -20,30 +23,30 @@ const ActionButton = styled.button.attrs(applyDefaultTheme)`
|
|
|
20
23
|
cursor: pointer;
|
|
21
24
|
|
|
22
25
|
${props => {
|
|
23
|
-
const darkThemeBgColor = props
|
|
24
|
-
const lightThemeBgColor = props
|
|
26
|
+
const darkThemeBgColor = props?.$backgroundColors?.[0] ?? props.theme.getColor('gray-600');
|
|
27
|
+
const lightThemeBgColor = props?.$backgroundColors?.[1] ?? props.theme.getColor('gray-200');
|
|
25
28
|
return props.theme.themeProp('background-image', `radial-gradient(circle at center, ${darkThemeBgColor} 50%, transparent 51%)`, `radial-gradient(circle at center, ${lightThemeBgColor} 50%, transparent 51%)`);
|
|
26
29
|
}}
|
|
27
30
|
|
|
28
31
|
&:hover:not(:disabled) {
|
|
29
|
-
background-size: ${props => Math.max(props
|
|
30
|
-
${props => Math.max(props
|
|
32
|
+
background-size: ${props => Math.max(props.$actionWidthHeight[0], props.$actionWidthHeight[1]) * 2}px
|
|
33
|
+
${props => Math.max(props.$actionWidthHeight[0], props.$actionWidthHeight[1]) * 2}px;
|
|
31
34
|
|
|
32
35
|
svg {
|
|
33
36
|
${props => props.theme.themeProp('color', props.theme.getColor('gray-100'), props.theme.getColor('gray-700'))};
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
${props => props
|
|
38
|
-
background-size: ${Math.max(props
|
|
39
|
-
${Math.max(props
|
|
40
|
+
${props => props.$active && css`
|
|
41
|
+
background-size: ${Math.max(props.$actionWidthHeight[0], props.$actionWidthHeight[1]) * 2}px
|
|
42
|
+
${Math.max(props.$actionWidthHeight[0], props.$actionWidthHeight[1]) * 2}px;
|
|
40
43
|
|
|
41
44
|
svg {
|
|
42
45
|
${props.theme.themeProp('color', props.theme.getColor('gray-100'), props.theme.getColor('gray-700'))};
|
|
43
46
|
}
|
|
44
47
|
`}
|
|
45
48
|
|
|
46
|
-
${props => props
|
|
49
|
+
${props => props.$useShadow ? props.theme.themeProp('box-shadow', `0px 3px 6px ${rgba(props.theme.getColor('black'), 0.7)}`, `0px 3px 6px ${props.theme.getColor('black')}`) : null}
|
|
47
50
|
|
|
48
51
|
&:disabled {
|
|
49
52
|
opacity: 0.5;
|
|
@@ -53,8 +56,8 @@ const ActionButton = styled.button.attrs(applyDefaultTheme)`
|
|
|
53
56
|
|
|
54
57
|
svg {
|
|
55
58
|
width: 100%;
|
|
56
|
-
max-width: ${props => `${props
|
|
57
|
-
max-height: ${props => `${props
|
|
59
|
+
max-width: ${props => `${props.$actionWidthHeight[0] - 15}px`};
|
|
60
|
+
max-height: ${props => `${props.$actionWidthHeight[1] - 15}px`};
|
|
58
61
|
pointer-events: none;
|
|
59
62
|
transition: color 250ms;
|
|
60
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionButton.styled.js","sources":["../../../src/components/inputs/ActionButton/ActionButton.styled.js"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { rgba } from 'polished';\nimport { applyDefaultTheme } from '../../../utils/defaultTheme';\n\nexport const ActionButton = styled.button.attrs(applyDefaultTheme)`\n display: inline-flex;\n justify-content: center;\n align-items: center;\n border-radius: 50%;\n width: ${props => `${props
|
|
1
|
+
{"version":3,"file":"ActionButton.styled.js","sources":["../../../src/components/inputs/ActionButton/ActionButton.styled.js"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { rgba } from 'polished';\nimport { applyDefaultTheme } from '../../../utils/defaultTheme';\n\nconst shouldForwardProp = prop => prop !== 'theme' && !prop.startsWith('$');\n\nexport const ActionButton = styled.button\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n display: inline-flex;\n justify-content: center;\n align-items: center;\n border-radius: 50%;\n width: ${props => `${props.$actionWidthHeight[0]}px`};\n height: ${props => `${props.$actionWidthHeight[1]}px`};\n border: 0;\n color: inherit;\n background-color: transparent;\n\n background-position: center;\n background-repeat: no-repeat;\n background-size: 0 0;\n transition: background-size 250ms ease;\n cursor: pointer;\n\n ${props => {\n const darkThemeBgColor = props?.$backgroundColors?.[0] ?? props.theme.getColor('gray-600');\n const lightThemeBgColor = props?.$backgroundColors?.[1] ?? props.theme.getColor('gray-200');\n return props.theme.themeProp(\n 'background-image',\n `radial-gradient(circle at center, ${darkThemeBgColor} 50%, transparent 51%)`,\n `radial-gradient(circle at center, ${lightThemeBgColor} 50%, transparent 51%)`\n );\n }}\n\n &:hover:not(:disabled) {\n background-size: ${props =>\n Math.max(props.$actionWidthHeight[0], props.$actionWidthHeight[1]) * 2}px\n ${props => Math.max(props.$actionWidthHeight[0], props.$actionWidthHeight[1]) * 2}px;\n\n svg {\n ${props =>\n props.theme.themeProp(\n 'color',\n props.theme.getColor('gray-100'),\n props.theme.getColor('gray-700')\n )};\n }\n }\n\n ${props =>\n props.$active &&\n css`\n background-size: ${Math.max(props.$actionWidthHeight[0], props.$actionWidthHeight[1]) * 2}px\n ${Math.max(props.$actionWidthHeight[0], props.$actionWidthHeight[1]) * 2}px;\n\n svg {\n ${props.theme.themeProp(\n 'color',\n props.theme.getColor('gray-100'),\n props.theme.getColor('gray-700')\n )};\n }\n `}\n\n ${props =>\n props.$useShadow\n ? props.theme.themeProp(\n 'box-shadow',\n `0px 3px 6px ${rgba(props.theme.getColor('black'), 0.7)}`,\n `0px 3px 6px ${props.theme.getColor('black')}`\n )\n : null}\n\n &:disabled {\n opacity: 0.5;\n color: inherit;\n cursor: not-allowed;\n }\n\n svg {\n width: 100%;\n max-width: ${props => `${props.$actionWidthHeight[0] - 15}px`};\n max-height: ${props => `${props.$actionWidthHeight[1] - 15}px`};\n pointer-events: none;\n transition: color 250ms;\n }\n`;\n"],"names":["shouldForwardProp","prop","startsWith","ActionButton","styled","button","withConfig","attrs","applyDefaultTheme","props","$actionWidthHeight","darkThemeBgColor","$backgroundColors","theme","getColor","lightThemeBgColor","themeProp","Math","max","$active","css","$useShadow","rgba"],"mappings":";;;;AAIA,MAAMA,iBAAiB,GAAGC,IAAI,IAAIA,IAAI,KAAK,OAAO,IAAI,CAACA,IAAI,CAACC,UAAU,CAAC,GAAG,CAAC,CAAA;AAEpE,MAAMC,YAAY,GAAGC,MAAM,CAACC,MAAM,CACtCC,UAAU,CAAC;AACVN,EAAAA,iBAAAA;AACF,CAAC,CAAC,CACDO,KAAK,CAACC,iBAAiB,CAAC,CAAA;AAC3B;AACA;AACA;AACA;AACA,SAAWC,EAAAA,KAAK,IAAI,CAAGA,EAAAA,KAAK,CAACC,kBAAkB,CAAC,CAAC,CAAC,CAAI,EAAA,CAAA,CAAA;AACtD,UAAYD,EAAAA,KAAK,IAAI,CAAGA,EAAAA,KAAK,CAACC,kBAAkB,CAAC,CAAC,CAAC,CAAI,EAAA,CAAA,CAAA;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA,EAAID,KAAK,IAAI;AACT,EAAA,MAAME,gBAAgB,GAAGF,KAAK,EAAEG,iBAAiB,GAAG,CAAC,CAAC,IAAIH,KAAK,CAACI,KAAK,CAACC,QAAQ,CAAC,UAAU,CAAC,CAAA;AAC1F,EAAA,MAAMC,iBAAiB,GAAGN,KAAK,EAAEG,iBAAiB,GAAG,CAAC,CAAC,IAAIH,KAAK,CAACI,KAAK,CAACC,QAAQ,CAAC,UAAU,CAAC,CAAA;AAC3F,EAAA,OAAOL,KAAK,CAACI,KAAK,CAACG,SAAS,CAC1B,kBAAkB,EAClB,CAAA,kCAAA,EAAqCL,gBAAgB,CAAwB,sBAAA,CAAA,EAC7E,CAAqCI,kCAAAA,EAAAA,iBAAiB,wBACxD,CAAC,CAAA;AACH,CAAC,CAAA;AACH;AACA;AACA,qBAAuBN,EAAAA,KAAK,IACtBQ,IAAI,CAAC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IAAI,CAACb,KAAK,CAACI,KAAK,CAACC,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAA,CAAE,EACzD,CAAeL,YAAAA,EAAAA,KAAK,CAACI,KAAK,CAACC,QAAQ,CAAC,OAAO,CAAC,CAC9C,CAAA,CAAC,GACD,IAAI,CAAA;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAiBL,EAAAA,KAAK,IAAI,CAAA,EAAGA,KAAK,CAACC,kBAAkB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAI,EAAA,CAAA,CAAA;AACjE,gBAAkBD,EAAAA,KAAK,IAAI,CAAA,EAAGA,KAAK,CAACC,kBAAkB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAI,EAAA,CAAA,CAAA;AAClE;AACA;AACA;AACA;;;;"}
|
|
@@ -44,8 +44,10 @@ const CompactTextInput = React__default.forwardRef(function CompactTextInput({
|
|
|
44
44
|
const [currentValue, setCurrentValue] = useState();
|
|
45
45
|
const [autoFocus, setAutoFocus] = useState(false);
|
|
46
46
|
const {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
toolTipDisabled,
|
|
48
|
+
toolTipVisible,
|
|
49
|
+
toolTipOnMouseLeave,
|
|
50
|
+
toolTipContent
|
|
49
51
|
} = useTooltipAutoShow(descriptionToolTip);
|
|
50
52
|
useEffect(() => {
|
|
51
53
|
setCurrentValue(value || defaultValue);
|
|
@@ -102,15 +104,15 @@ const CompactTextInput = React__default.forwardRef(function CompactTextInput({
|
|
|
102
104
|
}, label, React__default.createElement(SuccessContainer, null, type === 'loading' && loadingIcon, type === 'success' && successIcon)), React__default.createElement(InputContainer, {
|
|
103
105
|
$hasLabel: !isEmpty(label)
|
|
104
106
|
}, !link && React__default.createElement("div", {
|
|
105
|
-
onMouseLeave:
|
|
107
|
+
onMouseLeave: toolTipOnMouseLeave
|
|
106
108
|
}, React__default.createElement(Tooltip, {
|
|
107
|
-
content:
|
|
109
|
+
content: toolTipContent,
|
|
108
110
|
key: "tooltip1",
|
|
109
111
|
placement: "bottom-end",
|
|
110
112
|
trigger: 'mouseenter',
|
|
111
|
-
disabled:
|
|
113
|
+
disabled: toolTipDisabled,
|
|
112
114
|
zIndex: 999999,
|
|
113
|
-
visible:
|
|
115
|
+
visible: toolTipVisible
|
|
114
116
|
}, input())), link && !readOnly && React__default.createElement("div", null, React__default.createElement(Popover, {
|
|
115
117
|
arrow: false,
|
|
116
118
|
content: React__default.createElement(LinkPopoverContainer, null, activeLinkHandler ? React__default.createElement(StyledLink, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompactTextInput.js","sources":["../../../src/components/inputs/CompactTextInput/CompactTextInput.js"],"sourcesContent":["import { isEmpty, isFunction } from 'lodash';\nimport { nanoid } from 'nanoid';\nimport PropTypes from 'prop-types';\nimport React, { useCallback, useState, useEffect } from 'react';\nimport useTooltipAutoShow from '../../../hooks/useTooltipAutoShow';\nimport { ReactComponent as EditNoteIcon } from '../../../icons/edit-note.svg';\nimport { ReactComponent as LinkIcon } from '../../../icons/link.svg';\nimport { Tooltip, Popover } from '../../data';\nimport * as S from './CompactTextInput.styled';\n\n// const ConditionalWrapper = ({ condition, wrapper, children }) =>\n// condition ? wrapper(children) : children;\n\n/**\n * Compact text inputs let users enter and edit text in the UI in a compact way. They typically appear in forms or displays of metadata.\n *\n * ### Import\n *\n * ``` js\n * import { CompactTextInput } from '@ntbjs/react-components/inputs'\n * // or\n * import CompactTextInput from '@ntbjs/react-components/inputs/CompactTextInput'\n * ```\n */\nconst CompactTextInput = React.forwardRef(function CompactTextInput(\n {\n label,\n inputType,\n name,\n defaultValue,\n value,\n placeholder,\n link,\n linkTarget,\n linkHandler,\n activeLinkHandler,\n autoSelect,\n readOnly,\n disabled,\n edit,\n type,\n descriptionToolTip,\n bold,\n hidden,\n onChange: onChangeProp,\n onFocus: onFocusProp,\n onBlur: onBlurProp,\n loadingIcon,\n successIcon,\n ...props\n },\n forwardedRef\n) {\n const [uniqueId] = useState(nanoid());\n const [currentValue, setCurrentValue] = useState();\n const [autoFocus, setAutoFocus] = useState(false);\n\n const { forceVisible, onMouseLeave: onTooltipMouseLeave } = useTooltipAutoShow(descriptionToolTip);\n\n useEffect(() => {\n setCurrentValue(value || defaultValue);\n setAutoFocus(false);\n }, [value, defaultValue]);\n\n const onChange = useCallback(\n event => {\n setCurrentValue(event.target.value);\n\n if (!autoFocus) {\n setAutoFocus(true);\n }\n if (isFunction(onChangeProp)) {\n onChangeProp(event);\n }\n },\n [onChangeProp]\n );\n\n const onFocus = useCallback(\n event => {\n if (autoSelect) {\n event.target.select();\n }\n\n if (isFunction(onFocusProp)) {\n onFocusProp(event);\n }\n },\n [autoSelect, readOnly, onFocusProp]\n );\n\n const onBlur = useCallback(\n event => {\n if (isFunction(onBlurProp)) {\n onBlurProp(event);\n }\n },\n [onBlurProp]\n );\n\n const input = () => {\n return (\n <S.Input\n ref={forwardedRef}\n id={uniqueId}\n key={uniqueId}\n autoFocus={autoFocus}\n inputtype={inputType}\n name={name}\n readOnly={readOnly}\n disabled={disabled}\n $edit={edit}\n placeholder={placeholder}\n defaultValue={defaultValue}\n value={value}\n $type={type}\n $bold={bold}\n $haslink={!isEmpty(link)}\n onFocus={onFocus}\n onChange={onChange}\n onBlur={onBlur}\n />\n );\n };\n\n if (hidden) return null;\n\n return (\n <S.CompactTextInput {...props}>\n {label && (\n <S.Label htmlFor={uniqueId} disabled={disabled}>\n {label}\n <S.SuccessContainer>\n {type === 'loading' && loadingIcon}\n {type === 'success' && successIcon}\n </S.SuccessContainer>\n </S.Label>\n )}\n <S.InputContainer $hasLabel={!isEmpty(label)}>\n {!link && (\n <div onMouseLeave={onTooltipMouseLeave}>\n <Tooltip\n content={descriptionToolTip}\n key=\"tooltip1\"\n placement=\"bottom-end\"\n trigger={'mouseenter'}\n disabled={!descriptionToolTip}\n zIndex={999999}\n visible={forceVisible ? true : undefined}\n >\n {input()}\n </Tooltip>\n </div>\n )}\n {link && !readOnly && (\n <div>\n <Popover\n arrow={false}\n content={\n <S.LinkPopoverContainer>\n {activeLinkHandler ? (\n <S.StyledLink\n href={link}\n target={linkTarget}\n onClick={e => {\n if (activeLinkHandler) {\n e.preventDefault();\n linkHandler();\n } else null;\n }}\n rel=\"noreferrer\"\n >\n <LinkIcon />\n {currentValue}\n </S.StyledLink>\n ) : (\n <S.StyledLink href={link} target={linkTarget} rel=\"noreferrer\">\n <LinkIcon />\n {currentValue}\n </S.StyledLink>\n )}\n </S.LinkPopoverContainer>\n }\n key=\"tooltip2\"\n placement=\"bottom-start\"\n trigger=\"focusin\"\n zIndex={999999}\n interactive={true}\n >\n {input()}\n </Popover>\n </div>\n )}\n {link && readOnly && (\n <S.ReadOnlyLinkContainer>\n <S.StyledLink\n href={link}\n rel=\"noreferrer\"\n style={{ display: 'inline-block' }}\n target={linkTarget}\n >\n {currentValue}\n </S.StyledLink>\n </S.ReadOnlyLinkContainer>\n )}\n {!readOnly && !disabled && (\n <>\n <S.InputIconContainer $type={type}>\n <EditNoteIcon />\n </S.InputIconContainer>\n {isEmpty(label) && (\n <S.InputSuccessContainer>\n {type === 'loading' && loadingIcon}\n {type === 'success' && successIcon}\n </S.InputSuccessContainer>\n )}\n </>\n )}\n </S.InputContainer>\n </S.CompactTextInput>\n );\n});\n\nCompactTextInput.propTypes = {\n /**\n * The label of the input field - leave `undefined` to hide the label\n */\n label: PropTypes.string,\n /**\n * Displays a light green background to show that an action was successful.\n */\n success: PropTypes.bool,\n /**\n * The input type - eg. `text`, `number`\n */\n inputType: PropTypes.string,\n /**\n * The input name\n */\n name: PropTypes.string,\n /**\n * The default value of the input - creates an uncontrolled input\n */\n defaultValue: PropTypes.string,\n /**\n * The value of the input - creates a controlled input\n */\n value: PropTypes.string,\n /**\n * The placeholder of the input\n */\n placeholder: PropTypes.string,\n /**\n * A URL associated with the input value. Creates a clickable link that accepts full or relative URL\n */\n link: PropTypes.string,\n /**\n * The target for the link. Only applies when the field is in read-only mode\n */\n linkTarget: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),\n /**\n * Whether the link has a onClick event.\n */\n linkHandler: PropTypes.func,\n /**\n * Whether the handler should preceed the link behavior.\n */\n activeLinkHandler: PropTypes.bool,\n /**\n * Whether to auto select the entire value when the input is focused – does also work when the field is in read-only mode\n */\n autoSelect: PropTypes.bool,\n /**\n * Whether the value is read only\n */\n readOnly: PropTypes.bool,\n /**\n * Whether the value is disabled\n */\n disabled: PropTypes.bool,\n /**\n * Displays a grey background to show that value is editable\n */\n edit: PropTypes.bool,\n /**\n * There is an error present - 'error be prioritized over warnings if both are set to 'true'.\n */\n // error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),\n /**\n * There is a warning present.\n */\n warning: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),\n /**\n * Whether to bold the input content - Slightly increases the font size and font weight of the input value\n */\n bold: PropTypes.bool,\n /**\n * Whether the component is hidden or visible.\n */\n hidden: PropTypes.bool,\n /**\n * Callback for `onChange`\n */\n onChange: PropTypes.func,\n /**\n * Callback for `onFocus`\n */\n onFocus: PropTypes.func,\n /**\n * Callback for `onBlur`\n */\n onBlur: PropTypes.func,\n /**\n * Define the type based on error, warning, loading and success.\n */\n type: PropTypes.oneOf(['', 'error', 'warning', 'loading', 'success']),\n /**\n * Description ToolTip text.\n */\n descriptionToolTip: PropTypes.string,\n /**\n * Icon element – E.g: `icon={<Spinner />}`\n */\n loadingIcon: PropTypes.element,\n /**\n * Icon element – E.g: `icon={<Check />}`\n */\n successIcon: PropTypes.element\n};\n\nCompactTextInput.defaultProps = {\n inputType: 'text',\n autoSelect: true,\n linkTarget: '_self',\n bold: false,\n readOnly: false,\n descriptionToolTip: '',\n edit: false,\n hidden: false,\n type: '',\n linkHandler: () => {},\n activeLinkHandler: false,\n onChange: () => {}\n};\n\nexport default CompactTextInput;\n"],"names":["CompactTextInput","React","forwardRef","label","inputType","name","defaultValue","value","placeholder","link","linkTarget","linkHandler","activeLinkHandler","autoSelect","readOnly","disabled","edit","type","descriptionToolTip","bold","hidden","onChange","onChangeProp","onFocus","onFocusProp","onBlur","onBlurProp","loadingIcon","successIcon","props","forwardedRef","uniqueId","useState","nanoid","currentValue","setCurrentValue","autoFocus","setAutoFocus","forceVisible","onMouseLeave","onTooltipMouseLeave","useTooltipAutoShow","useEffect","useCallback","event","target","isFunction","select","input","createElement","S","ref","id","key","inputtype","$edit","$type","$bold","$haslink","isEmpty","htmlFor","$hasLabel","Tooltip","content","placement","trigger","zIndex","visible","undefined","Popover","arrow","href","onClick","e","preventDefault","rel","LinkIcon","interactive","style","display","Fragment","EditNoteIcon","propTypes","process","env","NODE_ENV","PropTypes","string","success","bool","oneOf","func","warning","oneOfType","element","defaultProps"],"mappings":";;;;;;;;;;;;;;;;AAwBMA,MAAAA,gBAAgB,GAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,gBAAgBA,CACjE;EACEG,KAAK;EACLC,SAAS;EACTC,IAAI;EACJC,YAAY;EACZC,KAAK;EACLC,WAAW;EACXC,IAAI;EACJC,UAAU;EACVC,WAAW;EACXC,iBAAiB;EACjBC,UAAU;EACVC,QAAQ;EACRC,QAAQ;EACRC,IAAI;EACJC,IAAI;EACJC,kBAAkB;EAClBC,IAAI;EACJC,MAAM;AACNC,EAAAA,QAAQ,EAAEC,YAAY;AACtBC,EAAAA,OAAO,EAAEC,WAAW;AACpBC,EAAAA,MAAM,EAAEC,UAAU;EAClBC,WAAW;EACXC,WAAW;EACX,GAAGC,KAAAA;AACL,CAAC,EACDC,YAAY,EACZ;EACA,MAAM,CAACC,QAAQ,CAAC,GAAGC,QAAQ,CAACC,MAAM,EAAE,CAAC,CAAA;EACrC,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGH,QAAQ,EAAE,CAAA;EAClD,MAAM,CAACI,SAAS,EAAEC,YAAY,CAAC,GAAGL,QAAQ,CAAC,KAAK,CAAC,CAAA;EAEjD,MAAM;IAAEM,YAAY;AAAEC,IAAAA,YAAY,EA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D,SAAS,CAACQ,OAAAA;AACzB,CAAC,GAAA,EAAA,CAAA;AAED9F,gBAAgB,CAAC+F,YAAY,GAAG;AAC9B3F,EAAAA,SAAS,EAAE,MAAM;AACjBS,EAAAA,UAAU,EAAE,IAAI;AAChBH,EAAAA,UAAU,EAAE,OAAO;AACnBS,EAAAA,IAAI,EAAE,KAAK;AACXL,EAAAA,QAAQ,EAAE,KAAK;AACfI,EAAAA,kBAAkB,EAAE,EAAE;AACtBF,EAAAA,IAAI,EAAE,KAAK;AACXI,EAAAA,MAAM,EAAE,KAAK;AACbH,EAAAA,IAAI,EAAE,EAAE;AACRN,EAAAA,WAAW,EAAEA,MAAM,EAAE;AACrBC,EAAAA,iBAAiB,EAAE,KAAK;EACxBS,QAAQ,EAAEA,MAAM,EAAC;AACnB,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"CompactTextInput.js","sources":["../../../src/components/inputs/CompactTextInput/CompactTextInput.js"],"sourcesContent":["import { isEmpty, isFunction } from 'lodash';\nimport { nanoid } from 'nanoid';\nimport PropTypes from 'prop-types';\nimport React, { useCallback, useState, useEffect } from 'react';\nimport useTooltipAutoShow from '../../../hooks/useTooltipAutoShow';\nimport { ReactComponent as EditNoteIcon } from '../../../icons/edit-note.svg';\nimport { ReactComponent as LinkIcon } from '../../../icons/link.svg';\nimport { Tooltip, Popover } from '../../data';\nimport * as S from './CompactTextInput.styled';\n\n// const ConditionalWrapper = ({ condition, wrapper, children }) =>\n// condition ? wrapper(children) : children;\n\n/**\n * Compact text inputs let users enter and edit text in the UI in a compact way. They typically appear in forms or displays of metadata.\n *\n * ### Import\n *\n * ``` js\n * import { CompactTextInput } from '@ntbjs/react-components/inputs'\n * // or\n * import CompactTextInput from '@ntbjs/react-components/inputs/CompactTextInput'\n * ```\n */\nconst CompactTextInput = React.forwardRef(function CompactTextInput(\n {\n label,\n inputType,\n name,\n defaultValue,\n value,\n placeholder,\n link,\n linkTarget,\n linkHandler,\n activeLinkHandler,\n autoSelect,\n readOnly,\n disabled,\n edit,\n type,\n descriptionToolTip,\n bold,\n hidden,\n onChange: onChangeProp,\n onFocus: onFocusProp,\n onBlur: onBlurProp,\n loadingIcon,\n successIcon,\n ...props\n },\n forwardedRef\n) {\n const [uniqueId] = useState(nanoid());\n const [currentValue, setCurrentValue] = useState();\n const [autoFocus, setAutoFocus] = useState(false);\n\n const { toolTipDisabled, toolTipVisible, toolTipOnMouseLeave, toolTipContent } =\n useTooltipAutoShow(descriptionToolTip);\n\n useEffect(() => {\n setCurrentValue(value || defaultValue);\n setAutoFocus(false);\n }, [value, defaultValue]);\n\n const onChange = useCallback(\n event => {\n setCurrentValue(event.target.value);\n\n if (!autoFocus) {\n setAutoFocus(true);\n }\n if (isFunction(onChangeProp)) {\n onChangeProp(event);\n }\n },\n [onChangeProp]\n );\n\n const onFocus = useCallback(\n event => {\n if (autoSelect) {\n event.target.select();\n }\n\n if (isFunction(onFocusProp)) {\n onFocusProp(event);\n }\n },\n [autoSelect, readOnly, onFocusProp]\n );\n\n const onBlur = useCallback(\n event => {\n if (isFunction(onBlurProp)) {\n onBlurProp(event);\n }\n },\n [onBlurProp]\n );\n\n const input = () => {\n return (\n <S.Input\n ref={forwardedRef}\n id={uniqueId}\n key={uniqueId}\n autoFocus={autoFocus}\n inputtype={inputType}\n name={name}\n readOnly={readOnly}\n disabled={disabled}\n $edit={edit}\n placeholder={placeholder}\n defaultValue={defaultValue}\n value={value}\n $type={type}\n $bold={bold}\n $haslink={!isEmpty(link)}\n onFocus={onFocus}\n onChange={onChange}\n onBlur={onBlur}\n />\n );\n };\n\n if (hidden) return null;\n\n return (\n <S.CompactTextInput {...props}>\n {label && (\n <S.Label htmlFor={uniqueId} disabled={disabled}>\n {label}\n <S.SuccessContainer>\n {type === 'loading' && loadingIcon}\n {type === 'success' && successIcon}\n </S.SuccessContainer>\n </S.Label>\n )}\n <S.InputContainer $hasLabel={!isEmpty(label)}>\n {!link && (\n <div onMouseLeave={toolTipOnMouseLeave}>\n <Tooltip\n content={toolTipContent}\n key=\"tooltip1\"\n placement=\"bottom-end\"\n trigger={'mouseenter'}\n disabled={toolTipDisabled}\n zIndex={999999}\n visible={toolTipVisible}\n >\n {input()}\n </Tooltip>\n </div>\n )}\n {link && !readOnly && (\n <div>\n <Popover\n arrow={false}\n content={\n <S.LinkPopoverContainer>\n {activeLinkHandler ? (\n <S.StyledLink\n href={link}\n target={linkTarget}\n onClick={e => {\n if (activeLinkHandler) {\n e.preventDefault();\n linkHandler();\n } else null;\n }}\n rel=\"noreferrer\"\n >\n <LinkIcon />\n {currentValue}\n </S.StyledLink>\n ) : (\n <S.StyledLink href={link} target={linkTarget} rel=\"noreferrer\">\n <LinkIcon />\n {currentValue}\n </S.StyledLink>\n )}\n </S.LinkPopoverContainer>\n }\n key=\"tooltip2\"\n placement=\"bottom-start\"\n trigger=\"focusin\"\n zIndex={999999}\n interactive={true}\n >\n {input()}\n </Popover>\n </div>\n )}\n {link && readOnly && (\n <S.ReadOnlyLinkContainer>\n <S.StyledLink\n href={link}\n rel=\"noreferrer\"\n style={{ display: 'inline-block' }}\n target={linkTarget}\n >\n {currentValue}\n </S.StyledLink>\n </S.ReadOnlyLinkContainer>\n )}\n {!readOnly && !disabled && (\n <>\n <S.InputIconContainer $type={type}>\n <EditNoteIcon />\n </S.InputIconContainer>\n {isEmpty(label) && (\n <S.InputSuccessContainer>\n {type === 'loading' && loadingIcon}\n {type === 'success' && successIcon}\n </S.InputSuccessContainer>\n )}\n </>\n )}\n </S.InputContainer>\n </S.CompactTextInput>\n );\n});\n\nCompactTextInput.propTypes = {\n /**\n * The label of the input field - leave `undefined` to hide the label\n */\n label: PropTypes.string,\n /**\n * Displays a light green background to show that an action was successful.\n */\n success: PropTypes.bool,\n /**\n * The input type - eg. `text`, `number`\n */\n inputType: PropTypes.string,\n /**\n * The input name\n */\n name: PropTypes.string,\n /**\n * The default value of the input - creates an uncontrolled input\n */\n defaultValue: PropTypes.string,\n /**\n * The value of the input - creates a controlled input\n */\n value: PropTypes.string,\n /**\n * The placeholder of the input\n */\n placeholder: PropTypes.string,\n /**\n * A URL associated with the input value. Creates a clickable link that accepts full or relative URL\n */\n link: PropTypes.string,\n /**\n * The target for the link. Only applies when the field is in read-only mode\n */\n linkTarget: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),\n /**\n * Whether the link has a onClick event.\n */\n linkHandler: PropTypes.func,\n /**\n * Whether the handler should preceed the link behavior.\n */\n activeLinkHandler: PropTypes.bool,\n /**\n * Whether to auto select the entire value when the input is focused – does also work when the field is in read-only mode\n */\n autoSelect: PropTypes.bool,\n /**\n * Whether the value is read only\n */\n readOnly: PropTypes.bool,\n /**\n * Whether the value is disabled\n */\n disabled: PropTypes.bool,\n /**\n * Displays a grey background to show that value is editable\n */\n edit: PropTypes.bool,\n /**\n * There is an error present - 'error be prioritized over warnings if both are set to 'true'.\n */\n // error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),\n /**\n * There is a warning present.\n */\n warning: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),\n /**\n * Whether to bold the input content - Slightly increases the font size and font weight of the input value\n */\n bold: PropTypes.bool,\n /**\n * Whether the component is hidden or visible.\n */\n hidden: PropTypes.bool,\n /**\n * Callback for `onChange`\n */\n onChange: PropTypes.func,\n /**\n * Callback for `onFocus`\n */\n onFocus: PropTypes.func,\n /**\n * Callback for `onBlur`\n */\n onBlur: PropTypes.func,\n /**\n * Define the type based on error, warning, loading and success.\n */\n type: PropTypes.oneOf(['', 'error', 'warning', 'loading', 'success']),\n /**\n * Description ToolTip text.\n */\n descriptionToolTip: PropTypes.string,\n /**\n * Icon element – E.g: `icon={<Spinner />}`\n */\n loadingIcon: PropTypes.element,\n /**\n * Icon element – E.g: `icon={<Check />}`\n */\n successIcon: PropTypes.element\n};\n\nCompactTextInput.defaultProps = {\n inputType: 'text',\n autoSelect: true,\n linkTarget: '_self',\n bold: false,\n readOnly: false,\n descriptionToolTip: '',\n edit: false,\n hidden: false,\n type: '',\n linkHandler: () => {},\n activeLinkHandler: false,\n onChange: () => {}\n};\n\nexport default CompactTextInput;\n"],"names":["CompactTextInput","React","forwardRef","label","inputType","name","defaultValue","value","placeholder","link","linkTarget","linkHandler","activeLinkHandler","autoSelect","readOnly","disabled","edit","type","descriptionToolTip","bold","hidden","onChange","onChangeProp","onFocus","onFocusProp","onBlur","onBlurProp","loadingIcon","successIcon","props","forwardedRef","uniqueId","useState","nanoid","currentValue","setCurrentValue","autoFocus","setAutoFocus","toolTipDisabled","toolTipVisible","toolTipOnMouseLeave","toolTipContent","useTooltipAutoShow","useEffect","useCallback","event","target","isFunction","select","input","createElement","S","ref","id","key","inputtype","$edit","$type","$bold","$haslink","isEmpty","htmlFor","$hasLabel","onMouseLeave","Tooltip","content","placement","trigger","zIndex","visible","Popover","arrow","href","onClick","e","preventDefault","rel","LinkIcon","interactive","style","display","Fragment","EditNoteIcon","propTypes","process","env","NODE_ENV","PropTypes","string","success","bool","oneOf","func","warning","oneOfType","element","defaultProps"],"mappings":";;;;;;;;;;;;;;;;AAwBMA,MAAAA,gBAAgB,GAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,gBAAgBA,CACjE;EACEG,KAAK;EACLC,SAAS;EACTC,IAAI;EACJC,YAAY;EACZC,KAAK;EACLC,WAAW;EACXC,IAAI;EACJC,UAAU;EACVC,WAAW;EACXC,iBAAiB;EACjBC,UAAU;EACVC,QAAQ;EACRC,QAAQ;EACRC,IAAI;EACJC,IAAI;EACJC,kBAAkB;EAClBC,IAAI;EACJC,MAAM;AACNC,EAAAA,QAAQ,EAAEC,YAAY;AACtBC,EAAAA,OAAO,EAAEC,WAAW;AACpBC,EAAAA,MAAM,EAAEC,UAAU;EAClBC,WAAW;EACXC,WAAW;EACX,GAAGC,KAAAA;AACL,CAAC,EACDC,YAAY,EACZ;EACA,MAAM,CAACC,QAAQ,CAAC,GAAGC,QAAQ,CAACC,MAAM,EAAE,CAAC,CAAA;EACrC,MAAM,CAACC,YAAY,EAAEC,eAAe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S,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;EAIrEzE,kBAAkB,EAAEqE,SAAS,CAACC,MAAM;EAIpC7D,WAAW,EAAE4D,SAAS,CAACQ,OAAO;EAI9BnE,WAAW,EAAE2D,SAAS,CAACQ,OAAAA;AACzB,CAAC,GAAA,EAAA,CAAA;AAED/F,gBAAgB,CAACgG,YAAY,GAAG;AAC9B5F,EAAAA,SAAS,EAAE,MAAM;AACjBS,EAAAA,UAAU,EAAE,IAAI;AAChBH,EAAAA,UAAU,EAAE,OAAO;AACnBS,EAAAA,IAAI,EAAE,KAAK;AACXL,EAAAA,QAAQ,EAAE,KAAK;AACfI,EAAAA,kBAAkB,EAAE,EAAE;AACtBF,EAAAA,IAAI,EAAE,KAAK;AACXI,EAAAA,MAAM,EAAE,KAAK;AACbH,EAAAA,IAAI,EAAE,EAAE;AACRN,EAAAA,WAAW,EAAEA,MAAM,EAAE;AACrBC,EAAAA,iBAAiB,EAAE,KAAK;EACxBS,QAAQ,EAAEA,MAAM,EAAC;AACnB,CAAC;;;;"}
|
|
@@ -50,8 +50,10 @@ const TextArea = React__default.forwardRef(function TextArea({
|
|
|
50
50
|
const [autoFocus, setAutoFocus] = useState(false);
|
|
51
51
|
const [uniqueId] = useState(nanoid());
|
|
52
52
|
const {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
toolTipDisabled,
|
|
54
|
+
toolTipVisible,
|
|
55
|
+
toolTipOnMouseLeave,
|
|
56
|
+
toolTipContent
|
|
55
57
|
} = useTooltipAutoShow(descriptionToolTip);
|
|
56
58
|
useEffect(() => {
|
|
57
59
|
setAutoFocus(false);
|
|
@@ -125,15 +127,15 @@ const TextArea = React__default.forwardRef(function TextArea({
|
|
|
125
127
|
};
|
|
126
128
|
if (hidden) return null;
|
|
127
129
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
128
|
-
onMouseLeave:
|
|
130
|
+
onMouseLeave: toolTipOnMouseLeave
|
|
129
131
|
}, React__default.createElement(Tooltip, {
|
|
130
|
-
content:
|
|
132
|
+
content: toolTipContent,
|
|
131
133
|
key: "tooltipTextArea1",
|
|
132
134
|
placement: "bottom-end",
|
|
133
135
|
trigger: 'mouseenter',
|
|
134
|
-
disabled:
|
|
136
|
+
disabled: toolTipDisabled,
|
|
135
137
|
zIndex: 999999,
|
|
136
|
-
visible:
|
|
138
|
+
visible: toolTipVisible
|
|
137
139
|
}, input())));
|
|
138
140
|
});
|
|
139
141
|
TextArea.defaultProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.js","sources":["../../../src/components/inputs/TextArea/TextArea.js"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport useTooltipAutoShow from '../../../hooks/useTooltipAutoShow';\n\nimport { isEmpty } from 'lodash';\nimport useMergedRefs from '@restart/hooks/useMergedRefs';\nimport { nanoid } from 'nanoid';\nimport PropTypes from 'prop-types';\nimport { Tooltip } from '../../data';\n\nimport { ReactComponent as EditNoteIcon } from '../../../icons/edit-note.svg';\nimport * as S from './TextArea.styled';\n\n/**\n * Text areas let users enter and edit text in the UI. They typically appear in forms and dialogs.\n *\n * ### Import\n *\n * ``` js\n * import { TextArea } from '@ntbjs/react-components/inputs'\n * // or\n * import TextArea from '@ntbjs/react-components/inputs/TextArea'\n * ```\n */\nconst TextArea = React.forwardRef(function TextArea(\n {\n value,\n defaultValue,\n name,\n label,\n placeholder,\n required,\n disabled,\n hidden,\n readOnly,\n edit,\n autoComplete,\n description,\n type,\n icon,\n rows,\n className,\n style,\n onChange,\n onBlur,\n noBorder,\n loadingIcon,\n successIcon,\n padding,\n descriptionToolTip,\n borderRadius,\n fieldLabel,\n ...rest\n },\n forwardedRef\n) {\n const textInputDomNode = useRef(null);\n const textInputRef = useMergedRefs(forwardedRef, textInputDomNode);\n\n const [inputIsEmpty, setInputIsEmpty] = useState(!(value || defaultValue));\n const [autoFocus, setAutoFocus] = useState(false);\n\n const [uniqueId] = useState(nanoid());\n\n const { forceVisible: forceShowTooltip, onMouseLeave: onTooltipMouseLeave } =\n useTooltipAutoShow(descriptionToolTip);\n\n useEffect(() => {\n setAutoFocus(false);\n }, [value, defaultValue]);\n\n const onKeyDown = useCallback(event => {\n if (event.key === 'Enter') {\n event.stopPropagation();\n }\n }, []);\n\n const input = () => {\n return (\n <S.TextAreaContainter>\n {fieldLabel && (\n <S.Label htmlFor={uniqueId} disabled={disabled}>\n {fieldLabel}\n <S.SuccessContainerLabel>\n {type === 'loading' && loadingIcon}\n {type === 'success' && successIcon}\n </S.SuccessContainerLabel>\n </S.Label>\n )}\n <S.TextInput\n $fieldLabel={!isEmpty(fieldLabel)}\n disabled={disabled}\n readOnly={readOnly}\n $type={type}\n className={className}\n style={style}\n >\n <S.TextInputFieldIconAlert $type={type}>{icon}</S.TextInputFieldIconAlert>\n <S.TextInputField\n autoFocus={autoFocus}\n $borderRadius={borderRadius}\n ref={textInputRef}\n rows={rows}\n value={value}\n defaultValue={defaultValue}\n name={name}\n placeholder={placeholder || ' '}\n required={required}\n readOnly={readOnly}\n disabled={disabled}\n $edit={edit}\n $type={type}\n autoComplete={autoComplete}\n $hasIcon={Boolean(icon)}\n id={`text-input-${uniqueId}`}\n key={uniqueId}\n $padding={padding}\n onChange={e => {\n if (e.target.value) {\n setInputIsEmpty(false);\n if (!autoFocus) {\n setAutoFocus(true);\n }\n } else {\n setInputIsEmpty(true);\n if (!autoFocus) {\n setAutoFocus(true);\n }\n }\n onChange(e);\n }}\n onKeyDown={onKeyDown}\n onBlur={onBlur}\n $noBorder={noBorder}\n {...rest}\n />\n {!fieldLabel && (type === 'loading' || type === 'success') && (\n <S.SuccessContainer>\n {type === 'loading' && loadingIcon}\n {type === 'success' && successIcon}\n </S.SuccessContainer>\n )}\n {!readOnly && (edit || noBorder) && (\n <S.InputIconContainer disabled={disabled}>\n <EditNoteIcon className={padding === 'small' ? 'smallPadingIcon' : undefined} />\n </S.InputIconContainer>\n )}\n {label && (\n <S.TextInputLabel\n htmlFor={`text-input-${uniqueId}`}\n $hasPlaceholder={Boolean(placeholder)}\n $hasIcon={Boolean(icon)}\n $inputIsEmpty={inputIsEmpty}\n >\n {label}\n {required && ' *'}\n </S.TextInputLabel>\n )}\n {typeof description === 'string' && description.length > 0 && (\n <S.Description $type={type}>{description}</S.Description>\n )}\n </S.TextInput>\n </S.TextAreaContainter>\n );\n };\n\n if (hidden) return null;\n\n return (\n <>\n <div onMouseLeave={onTooltipMouseLeave}>\n <Tooltip\n content={descriptionToolTip}\n key=\"tooltipTextArea1\"\n placement=\"bottom-end\"\n trigger={'mouseenter'}\n disabled={!descriptionToolTip}\n zIndex={999999}\n visible={forceShowTooltip ? true : undefined}\n >\n {input()}\n </Tooltip>\n </div>\n </>\n );\n});\n\nTextArea.defaultProps = {\n rows: 4,\n noBorder: false,\n readOnly: false,\n edit: false,\n hidden: false,\n type: '',\n padding: 'medium',\n descriptionToolTip: '',\n onChange: () => {},\n borderRadius: 0\n};\n\nTextArea.propTypes = {\n /**\n * Value to be sent. Typically the content of the text area.\n */\n value: PropTypes.string,\n\n /**\n * Default value/text to be displayed in the text area by default.\n */\n defaultValue: PropTypes.string,\n\n /**\n * Name of the text area (used when sending form data)\n */\n name: PropTypes.string,\n\n /**\n * Label text for the text area. If the text area is empty (no input and no placeholder)\n * and isn't in focus, the label text will be displayed grayed out in the text area itself.\n * Otherwise, the label text will be displayed in the top left corner.\n */\n label: PropTypes.string,\n\n /**\n * Field Label text for the text area field. I\n */\n fieldLabel: PropTypes.string,\n\n /**\n * Placeholder text to be displayed if the text area is empty (no input)\n */\n placeholder: PropTypes.string,\n\n /**\n * Whether the user is required to fill in the text area\n */\n required: PropTypes.bool,\n\n /**\n * Whether the text area is disabled\n */\n disabled: PropTypes.bool,\n /**\n * Whether the component is hidden or visible.\n */\n hidden: PropTypes.bool,\n /**\n * Whether the text area is read-only\n */\n readOnly: PropTypes.bool,\n /**\n * Displays a grey background to show that value is editable\n */\n edit: PropTypes.bool,\n /**\n * ?\n */\n autoComplete: PropTypes.string,\n /**\n * Descriptive text displayed below the text area\n */\n description: PropTypes.string,\n\n /**\n * Optional icon to be displayed left of the text inside the text area\n */\n icon: PropTypes.element,\n /**\n * How many rows/lines of text to be displayed by default\n */\n rows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n /**\n * Add custom class names to the HTML element\n */\n className: PropTypes.string,\n /**\n * Add custom CSS styling\n */\n style: PropTypes.object,\n /**\n * Add padding (small-medium-large)\n */\n padding: PropTypes.oneOf(['small', 'medium', 'large']),\n /**\n * Optional callback function for the `onChange` event\n */\n onChange: PropTypes.func,\n /**\n * Optional callback function for the `onBlur` event\n */\n onBlur: PropTypes.func,\n noBorder: PropTypes.bool,\n // warningAlert: PropTypes.bool,\n // errorAlert: PropTypes.bool,\n /**\n * Define the type based on error,error-border , warning, loading and success.\n */\n type: PropTypes.oneOf([\n '',\n 'error',\n 'error-border',\n 'warning-border',\n 'warning',\n 'loading',\n 'success'\n ]),\n /**\n * Icon element â€\" E.g: `icon={<Spinner />}`\n */\n loadingIcon: PropTypes.element,\n /**\n * Icon element â€\" E.g: `icon={<Check />}`\n */\n successIcon: PropTypes.element,\n /**\n * Description ToolTip text.\n */\n descriptionToolTip: PropTypes.string,\n /**\n * Border Radius for rounded borders.\n */\n borderRadius: PropTypes.number\n};\n\nexport default TextArea;\n"],"names":["TextArea","React","forwardRef","value","defaultValue","name","label","placeholder","required","disabled","hidden","readOnly","edit","autoComplete","description","type","icon","rows","className","style","onChange","onBlur","noBorder","loadingIcon","successIcon","padding","descriptionToolTip","borderRadius","fieldLabel","rest","forwardedRef","textInputDomNode","useRef","textInputRef","useMergedRefs","inputIsEmpty","setInputIsEmpty","useState","autoFocus","setAutoFocus","uniqueId","nanoid","forceVisible","forceShowTooltip","onMouseLeave","onTooltipMouseLeave","useTooltipAutoShow","useEffect","onKeyDown","useCallback","event","key","stopPropagation","input","createElement","S","htmlFor","$fieldLabel","isEmpty","$type","_extends","$borderRadius","ref","$edit","$hasIcon","Boolean","id","$padding","e","target","$noBorder","EditNoteIcon","undefined","$hasPlaceholder","$inputIsEmpty","length","Fragment","Tooltip","content","placement","trigger","zIndex","visible","defaultProps","propTypes","process","env","NODE_ENV","PropTypes","string","bool","element","oneOfType","number","object","oneOf","func"],"mappings":";;;;;;;;;;;;;;;;;AAuBMA,MAAAA,QAAQ,GAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,QAAQA,CACjD;EACEG,KAAK;EACLC,YAAY;EACZC,IAAI;EACJC,KAAK;EACLC,WAAW;EACXC,QAAQ;EACRC,QAAQ;EACRC,MAAM;EACNC,QAAQ;EACRC,IAAI;EACJC,YAAY;EACZC,WAAW;EACXC,IAAI;EACJC,IAAI;EACJC,IAAI;EACJC,SAAS;EACTC,KAAK;EACLC,QAAQ;EACRC,MAAM;EACNC,QAAQ;EACRC,WAAW;EACXC,WAAW;EACXC,OAAO;EACPC,kBAAkB;EAClBC,YAAY;EACZC,UAAU;EACV,GAAGC,IAAAA;AACL,CAAC,EACDC,YAAY,EACZ;AACA,EAAA,MAAMC,gBAAgB,GAAGC,MAAM,CAAC,IAAI,CAAC,CAAA;AACrC,EAAA,MAAMC,YAAY,GAAGC,aAAa,CAACJ,YAAY,EAAEC,gBAAgB,CAAC,CAAA;AAElE,EAAA,MAAM,CAACI,YAAY,EAAEC,eAAe,CAAC,GAAGC,QAAQ,CAAC,EAAElC,KAAK,IAAIC,YAAY,CAAC,CAAC,CAAA;EAC1E,MAAM,CAACkC,SAAS,EAAEC,YAAY,CAAC,GAAGF,QAAQ,CAAC,KAAK,CAAC,CAAA;EAEjD,MAAM,CAACG,QAAQ,CAAC,GAAGH,QAAQ,CAACI,MAAM,EAAE,CAAC,CAAA;EAErC,MAAM;AAAEC,IAAAA,YAAY,EAAEC,gBAAgB;AAAEC,IAAAA,YAAY,EAAEC,mBAAAA;AAAoB,GAAC,GACzEC,kBAAkB,CAACpB,kBAAkB,CAAC,CAAA;AAExCqB,EAAAA,SAAS,CAAC,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AAS,CAACE,IAAI;EAIpB7E,YAAY,EAAE2E,SAAS,CAACC,MAAM;EAI9B3E,WAAW,EAAE0E,SAAS,CAACC,MAAM;EAK7BzE,IAAI,EAAEwE,SAAS,CAACG,OAAO;AAIvB1E,EAAAA,IAAI,EAAEuE,SAAS,CAACI,SAAS,CAAC,CAACJ,SAAS,CAACK,MAAM,EAAEL,SAAS,CAACC,MAAM,CAAC,CAAC;EAI/DvE,SAAS,EAAEsE,SAAS,CAACC,MAAM;EAI3BtE,KAAK,EAAEqE,SAAS,CAACM,MAAM;AAIvBrE,EAAAA,OAAO,EAAE+D,SAAS,CAACO,KAAK,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;EAItD3E,QAAQ,EAAEoE,SAAS,CAACQ,IAAI;EAIxB3E,MAAM,EAAEmE,SAAS,CAACQ,IAAI;EACtB1E,QAAQ,EAAEkE,SAAS,CAACE,IAAI;EAMxB3E,IAAI,EAAEyE,SAAS,CAACO,KAAK,CAAC,CACpB,EAAE,EACF,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,SAAS,CACV,CAAC;EAIFxE,WAAW,EAAEiE,SAAS,CAACG,OAAO;EAI9BnE,WAAW,EAAEgE,SAAS,CAACG,OAAO;EAI9BjE,kBAAkB,EAAE8D,SAAS,CAACC,MAAM;EAIpC9D,YAAY,EAAE6D,SAAS,CAACK,MAAAA;AAC1B,CAAC,GAAA,EAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"TextArea.js","sources":["../../../src/components/inputs/TextArea/TextArea.js"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport useTooltipAutoShow from '../../../hooks/useTooltipAutoShow';\n\nimport { isEmpty } from 'lodash';\nimport useMergedRefs from '@restart/hooks/useMergedRefs';\nimport { nanoid } from 'nanoid';\nimport PropTypes from 'prop-types';\nimport { Tooltip } from '../../data';\n\nimport { ReactComponent as EditNoteIcon } from '../../../icons/edit-note.svg';\nimport * as S from './TextArea.styled';\n\n/**\n * Text areas let users enter and edit text in the UI. They typically appear in forms and dialogs.\n *\n * ### Import\n *\n * ``` js\n * import { TextArea } from '@ntbjs/react-components/inputs'\n * // or\n * import TextArea from '@ntbjs/react-components/inputs/TextArea'\n * ```\n */\nconst TextArea = React.forwardRef(function TextArea(\n {\n value,\n defaultValue,\n name,\n label,\n placeholder,\n required,\n disabled,\n hidden,\n readOnly,\n edit,\n autoComplete,\n description,\n type,\n icon,\n rows,\n className,\n style,\n onChange,\n onBlur,\n noBorder,\n loadingIcon,\n successIcon,\n padding,\n descriptionToolTip,\n borderRadius,\n fieldLabel,\n ...rest\n },\n forwardedRef\n) {\n const textInputDomNode = useRef(null);\n const textInputRef = useMergedRefs(forwardedRef, textInputDomNode);\n\n const [inputIsEmpty, setInputIsEmpty] = useState(!(value || defaultValue));\n const [autoFocus, setAutoFocus] = useState(false);\n\n const [uniqueId] = useState(nanoid());\n\n const { toolTipDisabled, toolTipVisible, toolTipOnMouseLeave, toolTipContent } =\n useTooltipAutoShow(descriptionToolTip);\n\n useEffect(() => {\n setAutoFocus(false);\n }, [value, defaultValue]);\n\n const onKeyDown = useCallback(event => {\n if (event.key === 'Enter') {\n event.stopPropagation();\n }\n }, []);\n\n const input = () => {\n return (\n <S.TextAreaContainter>\n {fieldLabel && (\n <S.Label htmlFor={uniqueId} disabled={disabled}>\n {fieldLabel}\n <S.SuccessContainerLabel>\n {type === 'loading' && loadingIcon}\n {type === 'success' && successIcon}\n </S.SuccessContainerLabel>\n </S.Label>\n )}\n <S.TextInput\n $fieldLabel={!isEmpty(fieldLabel)}\n disabled={disabled}\n readOnly={readOnly}\n $type={type}\n className={className}\n style={style}\n >\n <S.TextInputFieldIconAlert $type={type}>{icon}</S.TextInputFieldIconAlert>\n <S.TextInputField\n autoFocus={autoFocus}\n $borderRadius={borderRadius}\n ref={textInputRef}\n rows={rows}\n value={value}\n defaultValue={defaultValue}\n name={name}\n placeholder={placeholder || ' '}\n required={required}\n readOnly={readOnly}\n disabled={disabled}\n $edit={edit}\n $type={type}\n autoComplete={autoComplete}\n $hasIcon={Boolean(icon)}\n id={`text-input-${uniqueId}`}\n key={uniqueId}\n $padding={padding}\n onChange={e => {\n if (e.target.value) {\n setInputIsEmpty(false);\n if (!autoFocus) {\n setAutoFocus(true);\n }\n } else {\n setInputIsEmpty(true);\n if (!autoFocus) {\n setAutoFocus(true);\n }\n }\n onChange(e);\n }}\n onKeyDown={onKeyDown}\n onBlur={onBlur}\n $noBorder={noBorder}\n {...rest}\n />\n {!fieldLabel && (type === 'loading' || type === 'success') && (\n <S.SuccessContainer>\n {type === 'loading' && loadingIcon}\n {type === 'success' && successIcon}\n </S.SuccessContainer>\n )}\n {!readOnly && (edit || noBorder) && (\n <S.InputIconContainer disabled={disabled}>\n <EditNoteIcon className={padding === 'small' ? 'smallPadingIcon' : undefined} />\n </S.InputIconContainer>\n )}\n {label && (\n <S.TextInputLabel\n htmlFor={`text-input-${uniqueId}`}\n $hasPlaceholder={Boolean(placeholder)}\n $hasIcon={Boolean(icon)}\n $inputIsEmpty={inputIsEmpty}\n >\n {label}\n {required && ' *'}\n </S.TextInputLabel>\n )}\n {typeof description === 'string' && description.length > 0 && (\n <S.Description $type={type}>{description}</S.Description>\n )}\n </S.TextInput>\n </S.TextAreaContainter>\n );\n };\n\n if (hidden) return null;\n\n return (\n <>\n <div onMouseLeave={toolTipOnMouseLeave}>\n <Tooltip\n content={toolTipContent}\n key=\"tooltipTextArea1\"\n placement=\"bottom-end\"\n trigger={'mouseenter'}\n disabled={toolTipDisabled}\n zIndex={999999}\n visible={toolTipVisible}\n >\n {input()}\n </Tooltip>\n </div>\n </>\n );\n});\n\nTextArea.defaultProps = {\n rows: 4,\n noBorder: false,\n readOnly: false,\n edit: false,\n hidden: false,\n type: '',\n padding: 'medium',\n descriptionToolTip: '',\n onChange: () => {},\n borderRadius: 0\n};\n\nTextArea.propTypes = {\n /**\n * Value to be sent. Typically the content of the text area.\n */\n value: PropTypes.string,\n\n /**\n * Default value/text to be displayed in the text area by default.\n */\n defaultValue: PropTypes.string,\n\n /**\n * Name of the text area (used when sending form data)\n */\n name: PropTypes.string,\n\n /**\n * Label text for the text area. If the text area is empty (no input and no placeholder)\n * and isn't in focus, the label text will be displayed grayed out in the text area itself.\n * Otherwise, the label text will be displayed in the top left corner.\n */\n label: PropTypes.string,\n\n /**\n * Field Label text for the text area field. I\n */\n fieldLabel: PropTypes.string,\n\n /**\n * Placeholder text to be displayed if the text area is empty (no input)\n */\n placeholder: PropTypes.string,\n\n /**\n * Whether the user is required to fill in the text area\n */\n required: PropTypes.bool,\n\n /**\n * Whether the text area is disabled\n */\n disabled: PropTypes.bool,\n /**\n * Whether the component is hidden or visible.\n */\n hidden: PropTypes.bool,\n /**\n * Whether the text area is read-only\n */\n readOnly: PropTypes.bool,\n /**\n * Displays a grey background to show that value is editable\n */\n edit: PropTypes.bool,\n /**\n * ?\n */\n autoComplete: PropTypes.string,\n /**\n * Descriptive text displayed below the text area\n */\n description: PropTypes.string,\n\n /**\n * Optional icon to be displayed left of the text inside the text area\n */\n icon: PropTypes.element,\n /**\n * How many rows/lines of text to be displayed by default\n */\n rows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n /**\n * Add custom class names to the HTML element\n */\n className: PropTypes.string,\n /**\n * Add custom CSS styling\n */\n style: PropTypes.object,\n /**\n * Add padding (small-medium-large)\n */\n padding: PropTypes.oneOf(['small', 'medium', 'large']),\n /**\n * Optional callback function for the `onChange` event\n */\n onChange: PropTypes.func,\n /**\n * Optional callback function for the `onBlur` event\n */\n onBlur: PropTypes.func,\n noBorder: PropTypes.bool,\n // warningAlert: PropTypes.bool,\n // errorAlert: PropTypes.bool,\n /**\n * Define the type based on error,error-border , warning, loading and success.\n */\n type: PropTypes.oneOf([\n '',\n 'error',\n 'error-border',\n 'warning-border',\n 'warning',\n 'loading',\n 'success'\n ]),\n /**\n * Icon element â€\" E.g: `icon={<Spinner />}`\n */\n loadingIcon: PropTypes.element,\n /**\n * Icon element â€\" E.g: `icon={<Check />}`\n */\n successIcon: PropTypes.element,\n /**\n * Description ToolTip text.\n */\n descriptionToolTip: PropTypes.string,\n /**\n * Border Radius for rounded borders.\n */\n borderRadius: PropTypes.number\n};\n\nexport default TextArea;\n"],"names":["TextArea","React","forwardRef","value","defaultValue","name","label","placeholder","required","disabled","hidden","readOnly","edit","autoComplete","description","type","icon","rows","className","style","onChange","onBlur","noBorder","loadingIcon","successIcon","padding","descriptionToolTip","borderRadius","fieldLabel","rest","forwardedRef","textInputDomNode","useRef","textInputRef","useMergedRefs","inputIsEmpty","setInputIsEmpty","useState","autoFocus","setAutoFocus","uniqueId","nanoid","toolTipDisabled","toolTipVisible","toolTipOnMouseLeave","toolTipContent","useTooltipAutoShow","useEffect","onKeyDown","useCallback","event","key","stopPropagation","input","createElement","S","htmlFor","$fieldLabel","isEmpty","$type","_extends","$borderRadius","ref","$edit","$hasIcon","Boolean","id","$padding","e","target","$noBorder","EditNoteIcon","undefined","$hasPlaceholder","$inputIsEmpty","length","Fragment","onMouseLeave","Tooltip","content","placement","trigger","zIndex","visible","defaultProps","propTypes","process","env","NODE_ENV","PropTypes","string","bool","element","oneOfType","number","object","oneOf","func"],"mappings":";;;;;;;;;;;;;;;;;AAuBMA,MAAAA,QAAQ,GAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,QAAQA,CACjD;EACEG,KAAK;EACLC,YAAY;EACZC,IAAI;EACJC,KAAK;EACLC,WAAW;EACXC,QAAQ;EACRC,QAAQ;EACRC,MAAM;EACNC,QAAQ;EACRC,IAAI;EACJC,YAAY;EACZC,WAAW;EACXC,IAAI;EACJC,IAAI;EACJC,IAAI;EACJC,SAAS;EACTC,KAAK;EACLC,QAAQ;EACRC,MAAM;EACNC,QAAQ;EACRC,WAAW;EACXC,WAAW;EACXC,OAAO;EACPC,kBAAkB;EAClBC,YAAY;EACZC,UAAU;EACV,GAAGC,IAAAA;AACL,CAAC,EACDC,YAAY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SAAS,EACT,SAAS,EACT,SAAS,CACV,CAAC;EAIFzE,WAAW,EAAEkE,SAAS,CAACG,OAAO;EAI9BpE,WAAW,EAAEiE,SAAS,CAACG,OAAO;EAI9BlE,kBAAkB,EAAE+D,SAAS,CAACC,MAAM;EAIpC/D,YAAY,EAAE8D,SAAS,CAACK,MAAAA;AAC1B,CAAC,GAAA,EAAA;;;;"}
|
|
@@ -344,21 +344,21 @@ const AssetGalleryBase = React__default.forwardRef(function AssetGalleryBase({
|
|
|
344
344
|
extendedSelectMode: Boolean(selectedAssetKeys.length),
|
|
345
345
|
onAssetSelected: onAssetSelected,
|
|
346
346
|
onAssetUnselected: onAssetUnselected,
|
|
347
|
-
|
|
347
|
+
softSelected: softSelectedAssetKey === asset.key,
|
|
348
348
|
component: component
|
|
349
349
|
}) : React__default.createElement(AssetGalleryCompactCard, {
|
|
350
350
|
asset: asset,
|
|
351
351
|
activeSummaryCard: activeSummaryCard,
|
|
352
352
|
displayIcon: displayIcon,
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
hasHeightAndWidth: asset.layout.hasHeightAndWidth,
|
|
354
|
+
collapseExtraInfo: asset.layout.width < 90,
|
|
355
355
|
selectable: 'selectable' in asset ? asset.selectable : selectable,
|
|
356
356
|
selected: selectedAssetKeys.includes(asset.key),
|
|
357
357
|
customSelectedBorder: customSelectedBorder,
|
|
358
358
|
extendedSelectMode: Boolean(selectedAssetKeys.length),
|
|
359
359
|
onAssetSelected: onAssetSelected,
|
|
360
360
|
onAssetUnselected: onAssetUnselected,
|
|
361
|
-
|
|
361
|
+
softSelected: softSelectedAssetKey === asset.key,
|
|
362
362
|
component: component
|
|
363
363
|
}))))));
|
|
364
364
|
});
|