@smart-react-components/ui 2.0.0-alpha-48 → 2.0.0-alpha-50

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.
@@ -30,11 +30,12 @@ const SelectBox = react_1.default.forwardRef((props, forwardRef) => {
30
30
  const formEl = react_1.default.useRef(null);
31
31
  const { itemList } = (0, useSelectBoxItemList_1.default)({ children: props.children });
32
32
  const handleBadgeClick = value => props.setActive(props.active.filter(i => i !== value));
33
- const getContent = () => {
33
+ const content = react_1.default.useMemo(() => {
34
34
  var _a;
35
35
  if (typeof props.active === 'undefined'
36
36
  || props.active === null
37
- || props.active.length === 0) {
37
+ || (Array.isArray(props.active) && props.active.length === 0)
38
+ || (props.active === '' && !itemList[''])) {
38
39
  return react_1.default.createElement(InputPlaceholder_1.default, null, props.placeholder);
39
40
  }
40
41
  if (!Array.isArray(props.active)) {
@@ -46,12 +47,8 @@ const SelectBox = react_1.default.forwardRef((props, forwardRef) => {
46
47
  react_1.default.createElement(BadgeIcon_1.default, { onClick: () => handleBadgeClick(item) },
47
48
  react_1.default.createElement(Close_1.default, null)),
48
49
  itemList[String(item)].children)))));
49
- };
50
- const [content, setContent] = react_1.default.useState(() => getContent());
51
- const [dropdownStatus, setDropdownStatus] = react_1.default.useState(false);
52
- (0, useChangeEffect_1.default)(() => {
53
- setContent(getContent());
54
50
  }, [props.active, props.placeholder, itemList]);
51
+ const [dropdownStatus, setDropdownStatus] = react_1.default.useState(false);
55
52
  (0, useChangeEffect_1.default)(() => {
56
53
  const event = new Event('src.fixedBox.setPosition');
57
54
  formEl.current.dispatchEvent(event);
@@ -38,7 +38,6 @@ exports.default = (0, styled_components_1.default)(Table_1.default).attrs({
38
38
  border: solid 0;
39
39
  box-sizing: border-box;
40
40
  fill: currentcolor;
41
- transition: background 150ms 0s ease-in-out;
42
41
 
43
42
  ${hasBorderX
44
43
  ? `
@@ -1,9 +1,5 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const useChangeEffect_1 = __importDefault(require("@smart-react-components/core/hooks/useChangeEffect"));
7
3
  const react_1 = require("react");
8
4
  const useSelectBoxItemList = ({ children }) => {
9
5
  const collectItems = (arr, children) => {
@@ -18,7 +14,7 @@ const useSelectBoxItemList = ({ children }) => {
18
14
  }
19
15
  });
20
16
  };
21
- const getItemList = () => {
17
+ const itemList = (0, react_1.useMemo)(() => {
22
18
  const arr = [];
23
19
  collectItems(arr, children);
24
20
  const itemList = {};
@@ -29,10 +25,6 @@ const useSelectBoxItemList = ({ children }) => {
29
25
  };
30
26
  });
31
27
  return itemList;
32
- };
33
- const [itemList, setItemList] = (0, react_1.useState)(() => getItemList());
34
- (0, useChangeEffect_1.default)(() => {
35
- setItemList(getItemList());
36
28
  }, [children]);
37
29
  return {
38
30
  itemList,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart-react-components/ui",
3
- "version": "2.0.0-alpha-48",
3
+ "version": "2.0.0-alpha-50",
4
4
  "license": "MIT",
5
5
  "main": "index.js",
6
6
  "description": "SRC UI includes React and Styled components.",