@tecsinapse/react-web-kit 1.17.8 → 1.17.11

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/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.17.11](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.17.10...@tecsinapse/react-web-kit@1.17.11) (2022-07-14)
7
+
8
+ **Note:** Version bump only for package @tecsinapse/react-web-kit
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.17.10](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.17.9...@tecsinapse/react-web-kit@1.17.10) (2022-07-14)
15
+
16
+
17
+ ### Features
18
+
19
+ * fixing props tootip to react 18 ([76f9ec7](https://github.com/tecsinapse/design-system/commit/76f9ec7d974311ef7480a4b9ef2c207caab5bd9d))
20
+
21
+
22
+
23
+
24
+
25
+ ## [1.17.9](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.17.8...@tecsinapse/react-web-kit@1.17.9) (2022-07-11)
26
+
27
+ **Note:** Version bump only for package @tecsinapse/react-web-kit
28
+
29
+
30
+
31
+
32
+
6
33
  ## [1.17.8](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.17.7...@tecsinapse/react-web-kit@1.17.8) (2022-06-24)
7
34
 
8
35
  **Note:** Version bump only for package @tecsinapse/react-web-kit
@@ -7,6 +7,7 @@ export declare type Position = 'top' | 'bottom' | 'right' | 'left';
7
7
  export interface ITooltip {
8
8
  title: string;
9
9
  position?: Position;
10
+ children?: React.ReactNode;
10
11
  }
11
12
  declare const Tooltip: React.FC<ITooltip>;
12
13
  export default Tooltip;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Tooltip/Tooltip.tsx"],"names":["Tooltip","children","title","position","spanRef","React","useRef","computed","setComputed","useState","undefined","useLayoutEffect","width","current","clientWidth","height","clientHeight","ref"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAUA,MAAMA,OAA2B,GAAG,CAAC;AACnCC,EAAAA,QADmC;AAEnCC,EAAAA,KAFmC;AAGnCC,EAAAA,QAAQ,GAAG;AAHwB,CAAD,KAI9B;AACJ,QAAMC,OAAO,GAAGC,eAAMC,MAAN,EAAhB;;AACA,QAAM,CAACC,QAAD,EAAWC,WAAX,IAA0BH,eAAMI,QAAN,CAC9BC,SAD8B,CAAhC;;AAIAL,iBAAMM,eAAN,CAAsB,MAAM;AAAA;;AAC1BH,IAAAA,WAAW,CAAC;AACVI,MAAAA,KAAK,sBAAER,OAAO,CAACS,OAAV,qDAAE,iBAAiBC,WADd;AAEVC,MAAAA,MAAM,uBAAEX,OAAO,CAACS,OAAV,sDAAE,kBAAiBG;AAFf,KAAD,CAAX;AAID,GALD,EAKG,EALH;;AAOA,SACE,6BAAC,iBAAD;AAAW,IAAA,QAAQ,EAAEb;AAArB,KACGF,QADH,EAEE,6BAAC,mBAAD;AACE,IAAA,QAAQ,EAAEM,QADZ;AAEE,IAAA,QAAQ,EAAEJ,QAFZ;AAGE,IAAA,GAAG,EAAEc,GAAG,IAAKb,OAAO,CAACS,OAAR,GAAkBI;AAHjC,KAKE,6BAAC,eAAD;AACE,IAAA,UAAU,EAAC,MADb;AAEE,IAAA,UAAU,EAAC,MAFb;AAGE,IAAA,YAAY,EAAC,WAHf;AAIE,IAAA,SAAS,EAAC;AAJZ,KAMGf,KANH,CALF,CAFF,CADF;AAmBD,CApCD;;eAsCeF,O","sourcesContent":["import React from 'react';\nimport { Text } from '@tecsinapse/react-core';\nimport { Container, TooltipSpan } from './styled';\n\nexport type ComputedType = { width?: number; height?: number };\nexport type Position = 'top' | 'bottom' | 'right' | 'left';\n\nexport interface ITooltip {\n title: string;\n position?: Position;\n}\n\nconst Tooltip: React.FC<ITooltip> = ({\n children,\n title,\n position = 'bottom',\n}) => {\n const spanRef = React.useRef<HTMLSpanElement | null>();\n const [computed, setComputed] = React.useState<ComputedType | undefined>(\n undefined\n );\n\n React.useLayoutEffect(() => {\n setComputed({\n width: spanRef.current?.clientWidth,\n height: spanRef.current?.clientHeight,\n });\n }, []);\n\n return (\n <Container position={position}>\n {children}\n <TooltipSpan\n computed={computed}\n position={position}\n ref={ref => (spanRef.current = ref)}\n >\n <Text\n fontWeight=\"bold\"\n typography=\"base\"\n colorVariant=\"secondary\"\n colorTone=\"xlight\"\n >\n {title}\n </Text>\n </TooltipSpan>\n </Container>\n );\n};\n\nexport default Tooltip;\n"],"file":"Tooltip.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Tooltip/Tooltip.tsx"],"names":["Tooltip","children","title","position","spanRef","React","useRef","computed","setComputed","useState","undefined","useLayoutEffect","width","current","clientWidth","height","clientHeight","ref"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAWA,MAAMA,OAA2B,GAAG,CAAC;AACnCC,EAAAA,QADmC;AAEnCC,EAAAA,KAFmC;AAGnCC,EAAAA,QAAQ,GAAG;AAHwB,CAAD,KAI9B;AACJ,QAAMC,OAAO,GAAGC,eAAMC,MAAN,EAAhB;;AACA,QAAM,CAACC,QAAD,EAAWC,WAAX,IAA0BH,eAAMI,QAAN,CAC9BC,SAD8B,CAAhC;;AAIAL,iBAAMM,eAAN,CAAsB,MAAM;AAAA;;AAC1BH,IAAAA,WAAW,CAAC;AACVI,MAAAA,KAAK,sBAAER,OAAO,CAACS,OAAV,qDAAE,iBAAiBC,WADd;AAEVC,MAAAA,MAAM,uBAAEX,OAAO,CAACS,OAAV,sDAAE,kBAAiBG;AAFf,KAAD,CAAX;AAID,GALD,EAKG,EALH;;AAOA,SACE,6BAAC,iBAAD;AAAW,IAAA,QAAQ,EAAEb;AAArB,KACGF,QADH,EAEE,6BAAC,mBAAD;AACE,IAAA,QAAQ,EAAEM,QADZ;AAEE,IAAA,QAAQ,EAAEJ,QAFZ;AAGE,IAAA,GAAG,EAAEc,GAAG,IAAKb,OAAO,CAACS,OAAR,GAAkBI;AAHjC,KAKE,6BAAC,eAAD;AACE,IAAA,UAAU,EAAC,MADb;AAEE,IAAA,UAAU,EAAC,MAFb;AAGE,IAAA,YAAY,EAAC,WAHf;AAIE,IAAA,SAAS,EAAC;AAJZ,KAMGf,KANH,CALF,CAFF,CADF;AAmBD,CApCD;;eAsCeF,O","sourcesContent":["import React from 'react';\nimport { Text } from '@tecsinapse/react-core';\nimport { Container, TooltipSpan } from './styled';\n\nexport type ComputedType = { width?: number; height?: number };\nexport type Position = 'top' | 'bottom' | 'right' | 'left';\n\nexport interface ITooltip {\n title: string;\n position?: Position;\n children?: React.ReactNode;\n}\n\nconst Tooltip: React.FC<ITooltip> = ({\n children,\n title,\n position = 'bottom',\n}) => {\n const spanRef = React.useRef<HTMLSpanElement | null>();\n const [computed, setComputed] = React.useState<ComputedType | undefined>(\n undefined\n );\n\n React.useLayoutEffect(() => {\n setComputed({\n width: spanRef.current?.clientWidth,\n height: spanRef.current?.clientHeight,\n });\n }, []);\n\n return (\n <Container position={position}>\n {children}\n <TooltipSpan\n computed={computed}\n position={position}\n ref={ref => (spanRef.current = ref)}\n >\n <Text\n fontWeight=\"bold\"\n typography=\"base\"\n colorVariant=\"secondary\"\n colorTone=\"xlight\"\n >\n {title}\n </Text>\n </TooltipSpan>\n </Container>\n );\n};\n\nexport default Tooltip;\n"],"file":"Tooltip.js"}
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import { TextProps } from '@tecsinapse/react-core';
2
+ import React from 'react';
3
3
  export interface SelectProps<Data, Type extends 'single' | 'multi'> extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> {
4
4
  options: Data[];
5
5
  onSelect: (option: Type extends 'single' ? Data | undefined : Data[]) => never | void;
@@ -5,21 +5,21 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = exports.Select = void 0;
7
7
 
8
+ var _reactCore = require("@tecsinapse/react-core");
9
+
8
10
  var _react = _interopRequireDefault(require("react"));
9
11
 
10
- var _reactCore = require("@tecsinapse/react-core");
12
+ var _reactTransitionGroup = require("react-transition-group");
11
13
 
12
14
  var _hooks = require("../../../hooks");
13
15
 
14
- var _styled = require("./styled");
16
+ var _animations = require("./animations");
15
17
 
16
18
  var _Dropdown = require("./Dropdown");
17
19
 
18
20
  var _functions = require("./functions");
19
21
 
20
- var _reactTransitionGroup = require("react-transition-group");
21
-
22
- var _animations = require("./animations");
22
+ var _styled = require("./styled");
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
25
 
@@ -48,14 +48,21 @@ const Select = ({
48
48
  const refDropDown = _react.default.useRef(null);
49
49
 
50
50
  (0, _hooks.useClickAwayListener)(refDropDown, setDropDownVisible);
51
- const displayValue = (0, _functions.getDisplayValue)(type, value, options, placeholder, keyExtractor, labelExtractor);
51
+ const onlyLabel = label && !placeholder;
52
+ const hasValue = type === 'single' ? !!value : (value || []).length > 0;
53
+
54
+ const _placeholder = onlyLabel ? label : placeholder;
55
+
56
+ const _label = hasValue ? label : undefined;
57
+
58
+ const displayValue = (0, _functions.getDisplayValue)(type, value, options, _placeholder, keyExtractor, labelExtractor);
52
59
 
53
60
  const onPress = _react.default.useCallback(() => setDropDownVisible(prev => !prev), [setDropDownVisible]);
54
61
 
55
62
  return _react.default.createElement(_styled.StyledContainer, _extends({
56
63
  ref: refDropDown
57
64
  }, rest), _react.default.createElement(_styled.StyledInputContainer, null, _react.default.createElement(_reactCore.PressableInputContainer, {
58
- label: label,
65
+ label: _label,
59
66
  onPress: onPress,
60
67
  disabled: disabled,
61
68
  rightComponent: _styled.RightComponent
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/Select/Select.tsx"],"names":["Select","value","options","keyExtractor","onSelect","type","labelExtractor","placeholder","onSearch","searchBarPlaceholder","hideSearchBar","label","disabled","anchor","displayTextProps","selectAllLabel","rest","dropDownVisible","setDropDownVisible","React","useState","refDropDown","useRef","displayValue","onPress","useCallback","prev","RightComponent","state","defaultStyles","transition"],"mappings":";;;;;;;AAAA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;;;;;AAwBO,MAAMA,MAAM,GAAG,CAAwC;AAC5DC,EAAAA,KAD4D;AAE5DC,EAAAA,OAF4D;AAG5DC,EAAAA,YAH4D;AAI5DC,EAAAA,QAJ4D;AAK5DC,EAAAA,IAL4D;AAM5DC,EAAAA,cAN4D;AAO5DC,EAAAA,WAP4D;AAQ5DC,EAAAA,QAR4D;AAS5DC,EAAAA,oBAAoB,GAAG,yBATqC;AAU5DC,EAAAA,aAAa,GAAG,IAV4C;AAW5DC,EAAAA,KAX4D;AAY5DC,EAAAA,QAAQ,GAAG,KAZiD;AAa5DC,EAAAA,MAAM,GAAG,QAbmD;AAc5DC,EAAAA,gBAd4D;AAe5DC,EAAAA,cAAc,GAAG,kBAf2C;AAgB5D,KAAGC;AAhByD,CAAxC,KAiBsB;AAC1C,QAAM,CAACC,eAAD,EAAkBC,kBAAlB,IAAwCC,eAAMC,QAAN,CAAwB,KAAxB,CAA9C;;AACA,QAAMC,WAAW,GAAGF,eAAMG,MAAN,CAAa,IAAb,CAApB;;AACA,mCAAqBD,WAArB,EAAkCH,kBAAlC;AAEA,QAAMK,YAAY,GAAG,gCACnBlB,IADmB,EAEnBJ,KAFmB,EAGnBC,OAHmB,EAInBK,WAJmB,EAKnBJ,YALmB,EAMnBG,cANmB,CAArB;;AASA,QAAMkB,OAAO,GAAGL,eAAMM,WAAN,CAAkB,MAAMP,kBAAkB,CAACQ,IAAI,IAAI,CAACA,IAAV,CAA1C,EAA2D,CACzER,kBADyE,CAA3D,CAAhB;;AAIA,SACE,6BAAC,uBAAD;AAAiB,IAAA,GAAG,EAAEG;AAAtB,KAAuCL,IAAvC,GACE,6BAAC,4BAAD,QACE,6BAAC,kCAAD;AACE,IAAA,KAAK,EAAEL,KADT;AAEE,IAAA,OAAO,EAAEa,OAFX;AAGE,IAAA,QAAQ,EAAEZ,QAHZ;AAIE,IAAA,cAAc,EAAEe;AAJlB,KAME,6BAAC,eAAD,eAAUb,gBAAV;AAA4B,IAAA,aAAa,EAAC,MAA1C;AAAiD,IAAA,aAAa,EAAE;AAAhE,MACGS,YADH,CANF,CADF,CADF,EAaE,6BAAC,gCAAD;AAAY,IAAA,EAAE,EAAEN,eAAhB;AAAiC,IAAA,OAAO,EAAE;AAA1C,KACGW,KAAK,IACJ,6BAAC,kBAAD;AACE,IAAA,OAAO,EAAE1B,OADX;AAEE,IAAA,QAAQ,EAAEE,QAFZ;AAGE,IAAA,KAAK,EAAEH,KAHT;AAIE,IAAA,IAAI,EAAEI,IAJR;AAKE,IAAA,YAAY,EAAEF,YALhB;AAME,IAAA,cAAc,EAAEG,cANlB;AAOE,IAAA,aAAa,EAAEI,aAPjB;AAQE,IAAA,oBAAoB,EAAED,oBARxB;AASE,IAAA,QAAQ,EAAED,QATZ;AAUE,IAAA,KAAK,EAAE,EAAE,GAAGqB,yBAAL;AAAoB,SAAGC,uBAAWjB,MAAX,EAAmBe,KAAnB;AAAvB,KAVT;AAWE,IAAA,kBAAkB,EAAEV,kBAXtB;AAYE,IAAA,MAAM,EAAEL,MAZV;AAaE,IAAA,cAAc,EAAEE;AAblB,IAFJ,CAbF,CADF;AAmCD,CAtEM;;;eAwEQf,M","sourcesContent":["import React from 'react';\nimport {\n PressableInputContainer,\n Text,\n TextProps,\n} from '@tecsinapse/react-core';\nimport { useClickAwayListener } from '../../../hooks';\nimport {\n RightComponent,\n StyledContainer,\n StyledInputContainer,\n} from './styled';\nimport { Dropdown } from './Dropdown';\nimport { getDisplayValue } from './functions';\nimport { Transition } from 'react-transition-group';\nimport { defaultStyles, transition } from './animations';\n\nexport interface SelectProps<Data, Type extends 'single' | 'multi'>\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> {\n options: Data[];\n onSelect: (\n option: Type extends 'single' ? Data | undefined : Data[]\n ) => never | void;\n value: Type extends 'single' ? Data | undefined : Data[];\n type: Type;\n keyExtractor: (t: Data, index?: number) => string;\n labelExtractor: (t: Data) => string;\n placeholder?: string;\n onSearch?: (searchArg: string) => void | never;\n searchBarPlaceholder?: string;\n hideSearchBar?: boolean;\n selectAllLabel?: string;\n disabled?: boolean;\n label?: string;\n anchor?: 'top' | 'bottom';\n displayTextProps?: TextProps;\n}\n\n/** NOTE: For better performance, you should memoize options and handlers */\nexport const Select = <Data, Type extends 'single' | 'multi'>({\n value,\n options,\n keyExtractor,\n onSelect,\n type,\n labelExtractor,\n placeholder,\n onSearch,\n searchBarPlaceholder = 'Busque a opção desejada',\n hideSearchBar = true,\n label,\n disabled = false,\n anchor = 'bottom',\n displayTextProps,\n selectAllLabel = 'Selecionar todos',\n ...rest\n}: SelectProps<Data, Type>): JSX.Element => {\n const [dropDownVisible, setDropDownVisible] = React.useState<boolean>(false);\n const refDropDown = React.useRef(null);\n useClickAwayListener(refDropDown, setDropDownVisible);\n\n const displayValue = getDisplayValue<Data>(\n type,\n value,\n options,\n placeholder,\n keyExtractor,\n labelExtractor\n );\n\n const onPress = React.useCallback(() => setDropDownVisible(prev => !prev), [\n setDropDownVisible,\n ]);\n\n return (\n <StyledContainer ref={refDropDown} {...rest}>\n <StyledInputContainer>\n <PressableInputContainer\n label={label}\n onPress={onPress}\n disabled={disabled}\n rightComponent={RightComponent}\n >\n <Text {...displayTextProps} ellipsizeMode=\"tail\" numberOfLines={1}>\n {displayValue}\n </Text>\n </PressableInputContainer>\n </StyledInputContainer>\n <Transition in={dropDownVisible} timeout={300}>\n {state => (\n <Dropdown\n options={options}\n onSelect={onSelect}\n value={value}\n type={type}\n keyExtractor={keyExtractor}\n labelExtractor={labelExtractor}\n hideSearchBar={hideSearchBar}\n searchBarPlaceholder={searchBarPlaceholder}\n onSearch={onSearch}\n style={{ ...defaultStyles, ...transition[anchor][state] }}\n setDropDownVisible={setDropDownVisible}\n anchor={anchor}\n selectAllLabel={selectAllLabel}\n />\n )}\n </Transition>\n </StyledContainer>\n );\n};\n\nexport default Select;\n"],"file":"Select.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/Select/Select.tsx"],"names":["Select","value","options","keyExtractor","onSelect","type","labelExtractor","placeholder","onSearch","searchBarPlaceholder","hideSearchBar","label","disabled","anchor","displayTextProps","selectAllLabel","rest","dropDownVisible","setDropDownVisible","React","useState","refDropDown","useRef","onlyLabel","hasValue","length","_placeholder","_label","undefined","displayValue","onPress","useCallback","prev","RightComponent","state","defaultStyles","transition"],"mappings":";;;;;;;AAAA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AA4BO,MAAMA,MAAM,GAAG,CAAwC;AAC5DC,EAAAA,KAD4D;AAE5DC,EAAAA,OAF4D;AAG5DC,EAAAA,YAH4D;AAI5DC,EAAAA,QAJ4D;AAK5DC,EAAAA,IAL4D;AAM5DC,EAAAA,cAN4D;AAO5DC,EAAAA,WAP4D;AAQ5DC,EAAAA,QAR4D;AAS5DC,EAAAA,oBAAoB,GAAG,yBATqC;AAU5DC,EAAAA,aAAa,GAAG,IAV4C;AAW5DC,EAAAA,KAX4D;AAY5DC,EAAAA,QAAQ,GAAG,KAZiD;AAa5DC,EAAAA,MAAM,GAAG,QAbmD;AAc5DC,EAAAA,gBAd4D;AAe5DC,EAAAA,cAAc,GAAG,kBAf2C;AAgB5D,KAAGC;AAhByD,CAAxC,KAiBsB;AAC1C,QAAM,CAACC,eAAD,EAAkBC,kBAAlB,IAAwCC,eAAMC,QAAN,CAAwB,KAAxB,CAA9C;;AACA,QAAMC,WAAW,GAAGF,eAAMG,MAAN,CAAa,IAAb,CAApB;;AACA,mCAAqBD,WAArB,EAAkCH,kBAAlC;AAEA,QAAMK,SAAS,GAAGZ,KAAK,IAAI,CAACJ,WAA5B;AACA,QAAMiB,QAAQ,GAAGnB,IAAI,KAAK,QAAT,GAAoB,CAAC,CAACJ,KAAtB,GAA8B,CAAEA,KAAK,IAAI,EAAX,EAAsBwB,MAAtB,GAA+B,CAA9E;;AACA,QAAMC,YAAY,GAAGH,SAAS,GAAGZ,KAAH,GAAWJ,WAAzC;;AACA,QAAMoB,MAAM,GAAGH,QAAQ,GAAGb,KAAH,GAAWiB,SAAlC;;AAEA,QAAMC,YAAY,GAAG,gCACnBxB,IADmB,EAEnBJ,KAFmB,EAGnBC,OAHmB,EAInBwB,YAJmB,EAKnBvB,YALmB,EAMnBG,cANmB,CAArB;;AASA,QAAMwB,OAAO,GAAGX,eAAMY,WAAN,CAAkB,MAAMb,kBAAkB,CAACc,IAAI,IAAI,CAACA,IAAV,CAA1C,EAA2D,CACzEd,kBADyE,CAA3D,CAAhB;;AAIA,SACE,6BAAC,uBAAD;AAAiB,IAAA,GAAG,EAAEG;AAAtB,KAAuCL,IAAvC,GACE,6BAAC,4BAAD,QACE,6BAAC,kCAAD;AACE,IAAA,KAAK,EAAEW,MADT;AAEE,IAAA,OAAO,EAAEG,OAFX;AAGE,IAAA,QAAQ,EAAElB,QAHZ;AAIE,IAAA,cAAc,EAAEqB;AAJlB,KAME,6BAAC,eAAD,eAAUnB,gBAAV;AAA4B,IAAA,aAAa,EAAC,MAA1C;AAAiD,IAAA,aAAa,EAAE;AAAhE,MACGe,YADH,CANF,CADF,CADF,EAaE,6BAAC,gCAAD;AAAY,IAAA,EAAE,EAAEZ,eAAhB;AAAiC,IAAA,OAAO,EAAE;AAA1C,KACGiB,KAAK,IACJ,6BAAC,kBAAD;AACE,IAAA,OAAO,EAAEhC,OADX;AAEE,IAAA,QAAQ,EAAEE,QAFZ;AAGE,IAAA,KAAK,EAAEH,KAHT;AAIE,IAAA,IAAI,EAAEI,IAJR;AAKE,IAAA,YAAY,EAAEF,YALhB;AAME,IAAA,cAAc,EAAEG,cANlB;AAOE,IAAA,aAAa,EAAEI,aAPjB;AAQE,IAAA,oBAAoB,EAAED,oBARxB;AASE,IAAA,QAAQ,EAAED,QATZ;AAUE,IAAA,KAAK,EAAE,EAAE,GAAG2B,yBAAL;AAAoB,SAAGC,uBAAWvB,MAAX,EAAmBqB,KAAnB;AAAvB,KAVT;AAWE,IAAA,kBAAkB,EAAEhB,kBAXtB;AAYE,IAAA,MAAM,EAAEL,MAZV;AAaE,IAAA,cAAc,EAAEE;AAblB,IAFJ,CAbF,CADF;AAmCD,CA3EM;;;eA6EQf,M","sourcesContent":["import {\n PressableInputContainer,\n Text,\n TextProps\n} from '@tecsinapse/react-core';\nimport React from 'react';\nimport { Transition } from 'react-transition-group';\nimport { useClickAwayListener } from '../../../hooks';\nimport { defaultStyles, transition } from './animations';\nimport { Dropdown } from './Dropdown';\nimport { getDisplayValue } from './functions';\nimport {\n RightComponent,\n StyledContainer,\n StyledInputContainer\n} from './styled';\n\nexport interface SelectProps<Data, Type extends 'single' | 'multi'>\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> {\n options: Data[];\n onSelect: (\n option: Type extends 'single' ? Data | undefined : Data[]\n ) => never | void;\n value: Type extends 'single' ? Data | undefined : Data[];\n type: Type;\n keyExtractor: (t: Data, index?: number) => string;\n labelExtractor: (t: Data) => string;\n placeholder?: string;\n onSearch?: (searchArg: string) => void | never;\n searchBarPlaceholder?: string;\n hideSearchBar?: boolean;\n selectAllLabel?: string;\n disabled?: boolean;\n label?: string;\n anchor?: 'top' | 'bottom';\n displayTextProps?: TextProps;\n}\n\n/** NOTE: For better performance, you should memoize options and handlers */\nexport const Select = <Data, Type extends 'single' | 'multi'>({\n value,\n options,\n keyExtractor,\n onSelect,\n type,\n labelExtractor,\n placeholder,\n onSearch,\n searchBarPlaceholder = 'Busque a opção desejada',\n hideSearchBar = true,\n label,\n disabled = false,\n anchor = 'bottom',\n displayTextProps,\n selectAllLabel = 'Selecionar todos',\n ...rest\n}: SelectProps<Data, Type>): JSX.Element => {\n const [dropDownVisible, setDropDownVisible] = React.useState<boolean>(false);\n const refDropDown = React.useRef(null);\n useClickAwayListener(refDropDown, setDropDownVisible);\n\n const onlyLabel = label && !placeholder;\n const hasValue = type === 'single' ? !!value : ((value || []) as []).length > 0\n const _placeholder = onlyLabel ? label : placeholder\n const _label = hasValue ? label : undefined\n\n const displayValue = getDisplayValue<Data>(\n type,\n value,\n options,\n _placeholder,\n keyExtractor,\n labelExtractor\n );\n\n const onPress = React.useCallback(() => setDropDownVisible(prev => !prev), [\n setDropDownVisible,\n ]);\n\n return (\n <StyledContainer ref={refDropDown} {...rest}>\n <StyledInputContainer>\n <PressableInputContainer\n label={_label}\n onPress={onPress}\n disabled={disabled}\n rightComponent={RightComponent}\n >\n <Text {...displayTextProps} ellipsizeMode=\"tail\" numberOfLines={1}>\n {displayValue}\n </Text>\n </PressableInputContainer>\n </StyledInputContainer>\n <Transition in={dropDownVisible} timeout={300}>\n {state => (\n <Dropdown\n options={options}\n onSelect={onSelect}\n value={value}\n type={type}\n keyExtractor={keyExtractor}\n labelExtractor={labelExtractor}\n hideSearchBar={hideSearchBar}\n searchBarPlaceholder={searchBarPlaceholder}\n onSearch={onSearch}\n style={{ ...defaultStyles, ...transition[anchor][state] }}\n setDropDownVisible={setDropDownVisible}\n anchor={anchor}\n selectAllLabel={selectAllLabel}\n />\n )}\n </Transition>\n </StyledContainer>\n );\n};\n\nexport default Select;\n"],"file":"Select.js"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tecsinapse/react-web-kit",
3
3
  "description": "TecSinapse React components",
4
- "version": "1.17.8",
4
+ "version": "1.17.11",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -17,7 +17,7 @@
17
17
  "@emotion/native": "^11.0.0",
18
18
  "@emotion/react": "^11.4.1",
19
19
  "@emotion/styled": "^11.3.0",
20
- "@tecsinapse/react-core": "^1.16.4",
20
+ "@tecsinapse/react-core": "^1.16.6",
21
21
  "@types/react-native": "^0.64.4",
22
22
  "react-native-vector-icons": "^9.1.0",
23
23
  "react-transition-group": "^4.4.2"
@@ -36,5 +36,5 @@
36
36
  "react-dom": "^16.8.0 || ^17.0.0",
37
37
  "react-native-web": "^0.17.1"
38
38
  },
39
- "gitHead": "ab944cad9dc3a840ebf3ebc9ed525926ebe3a436"
39
+ "gitHead": "5b6adbc48490edb759d8f7d1a8519d5c7043360a"
40
40
  }
@@ -8,6 +8,7 @@ export type Position = 'top' | 'bottom' | 'right' | 'left';
8
8
  export interface ITooltip {
9
9
  title: string;
10
10
  position?: Position;
11
+ children?: React.ReactNode;
11
12
  }
12
13
 
13
14
  const Tooltip: React.FC<ITooltip> = ({
@@ -1,19 +1,19 @@
1
- import React from 'react';
2
1
  import {
3
2
  PressableInputContainer,
4
3
  Text,
5
- TextProps,
4
+ TextProps
6
5
  } from '@tecsinapse/react-core';
6
+ import React from 'react';
7
+ import { Transition } from 'react-transition-group';
7
8
  import { useClickAwayListener } from '../../../hooks';
9
+ import { defaultStyles, transition } from './animations';
10
+ import { Dropdown } from './Dropdown';
11
+ import { getDisplayValue } from './functions';
8
12
  import {
9
13
  RightComponent,
10
14
  StyledContainer,
11
- StyledInputContainer,
15
+ StyledInputContainer
12
16
  } from './styled';
13
- import { Dropdown } from './Dropdown';
14
- import { getDisplayValue } from './functions';
15
- import { Transition } from 'react-transition-group';
16
- import { defaultStyles, transition } from './animations';
17
17
 
18
18
  export interface SelectProps<Data, Type extends 'single' | 'multi'>
19
19
  extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> {
@@ -59,11 +59,16 @@ export const Select = <Data, Type extends 'single' | 'multi'>({
59
59
  const refDropDown = React.useRef(null);
60
60
  useClickAwayListener(refDropDown, setDropDownVisible);
61
61
 
62
+ const onlyLabel = label && !placeholder;
63
+ const hasValue = type === 'single' ? !!value : ((value || []) as []).length > 0
64
+ const _placeholder = onlyLabel ? label : placeholder
65
+ const _label = hasValue ? label : undefined
66
+
62
67
  const displayValue = getDisplayValue<Data>(
63
68
  type,
64
69
  value,
65
70
  options,
66
- placeholder,
71
+ _placeholder,
67
72
  keyExtractor,
68
73
  labelExtractor
69
74
  );
@@ -76,7 +81,7 @@ export const Select = <Data, Type extends 'single' | 'multi'>({
76
81
  <StyledContainer ref={refDropDown} {...rest}>
77
82
  <StyledInputContainer>
78
83
  <PressableInputContainer
79
- label={label}
84
+ label={_label}
80
85
  onPress={onPress}
81
86
  disabled={disabled}
82
87
  rightComponent={RightComponent}