@xaypay/tui 0.0.60 → 0.0.62

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/dist/index.js CHANGED
@@ -9,7 +9,26 @@ var styled = require('styled-components');
9
9
 
10
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
11
 
12
+ function _interopNamespace(e) {
13
+ if (e && e.__esModule) return e;
14
+ var n = Object.create(null);
15
+ if (e) {
16
+ Object.keys(e).forEach(function (k) {
17
+ if (k !== 'default') {
18
+ var d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: function () { return e[k]; }
22
+ });
23
+ }
24
+ });
25
+ }
26
+ n["default"] = e;
27
+ return Object.freeze(n);
28
+ }
29
+
12
30
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
31
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
13
32
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
14
33
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
15
34
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
@@ -969,11 +988,43 @@ SelectCheckbox.propTypes = {
969
988
  checked: PropTypes__default["default"].bool
970
989
  };
971
990
 
972
- var ReactArrowIcon = "<svg width=\"15\" height=\"9\" viewBox=\"0 0 15 9\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M7.9878 8.00003C7.75456 8.00049 7.52851 7.91911 7.34892 7.77003L1.3594 2.77003C1.15554 2.60029 1.02734 2.35638 1.003 2.09196C0.978666 1.82753 1.06019 1.56425 1.22963 1.36003C1.39907 1.15581 1.64255 1.02739 1.90652 1.00301C2.17048 0.978631 2.4333 1.06029 2.63716 1.23003L7.9878 5.71003L13.3384 1.39003C13.4405 1.30697 13.558 1.24493 13.6842 1.2075C13.8103 1.17007 13.9425 1.15798 14.0733 1.17192C14.2041 1.18586 14.3309 1.22555 14.4463 1.28873C14.5618 1.3519 14.6636 1.4373 14.746 1.54003C14.8374 1.64285 14.9066 1.76348 14.9493 1.89435C14.9921 2.02523 15.0073 2.16353 14.9942 2.30059C14.9811 2.43765 14.9399 2.57053 14.8731 2.69088C14.8063 2.81124 14.7155 2.91649 14.6062 3.00003L8.6167 7.83003C8.43194 7.95555 8.21051 8.0154 7.9878 8.00003Z\" fill=\"#3C393E\"/>\n</svg>";
991
+ const SvgArrow = ({
992
+ title,
993
+ titleId,
994
+ ...props
995
+ }) => /*#__PURE__*/React__namespace.createElement("svg", _extends({
996
+ width: "1em",
997
+ height: "1em",
998
+ viewBox: "0 0 15 9",
999
+ fill: "none",
1000
+ xmlns: "http://www.w3.org/2000/svg",
1001
+ "aria-labelledby": titleId
1002
+ }, props), title ? /*#__PURE__*/React__namespace.createElement("title", {
1003
+ id: titleId
1004
+ }, title) : null, /*#__PURE__*/React__namespace.createElement("path", {
1005
+ d: "M7.988 8a.997.997 0 0 1-.64-.23l-5.989-5a1.002 1.002 0 0 1 .548-1.767.998.998 0 0 1 .73.227l5.35 4.48 5.351-4.32a.997.997 0 0 1 1.408.15 1 1 0 0 1-.14 1.46l-5.99 4.83a.997.997 0 0 1-.628.17Z",
1006
+ fill: "#3C393E"
1007
+ }));
973
1008
 
974
- var ReactCloseIcon = "<svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M12.4253 0.241029L12.431 0.236144C12.6129 0.0804082 12.8468 -0.00097097 13.0861 0.00827014C13.3253 0.0175112 13.5523 0.116692 13.7216 0.285992C13.8909 0.455292 13.9901 0.682241 13.9993 0.921488C14.0085 1.16074 13.9272 1.39466 13.7714 1.57651L13.7665 1.58222L8.38622 6.96254L13.7665 12.3429L13.7714 12.3486C13.9272 12.5304 14.0085 12.7643 13.9993 13.0036C13.9901 13.2428 13.8909 13.4698 13.7216 13.6391C13.5523 13.8084 13.3253 13.9076 13.0861 13.9168C12.8468 13.926 12.6129 13.8447 12.431 13.6889L12.4253 13.684L7.04493 8.30363L1.66742 13.6738C1.58315 13.7705 1.48016 13.8492 1.36462 13.9051C1.24669 13.9622 1.11823 13.9942 0.987309 13.9993C0.85639 14.0043 0.72584 13.9823 0.603852 13.9345C0.481865 13.8867 0.371073 13.8142 0.27843 13.7216C0.185788 13.6289 0.113295 13.5181 0.0655034 13.3961C0.0177115 13.2742 -0.00434842 13.1436 0.000708381 13.0127C0.00576522 12.8818 0.0378304 12.7533 0.0948891 12.6354C0.150805 12.5198 0.229542 12.4168 0.326326 12.3325L5.70384 6.96235L0.323475 1.57461L0.318633 1.56895C0.162897 1.3871 0.0815178 1.15317 0.0907589 0.913926C0.1 0.674678 0.199181 0.447729 0.36848 0.27843C0.53778 0.10913 0.76473 0.00995005 1.00398 0.000708956C1.24322 -0.00853214 1.47715 0.0728459 1.659 0.228582L1.66476 0.233511L7.04512 5.62125L12.4253 0.241029Z\" fill=\"#3C393E\"/>\n</svg>";
1009
+ const SvgCloseIcon = ({
1010
+ title,
1011
+ titleId,
1012
+ ...props
1013
+ }) => /*#__PURE__*/React__namespace.createElement("svg", _extends({
1014
+ width: "1em",
1015
+ height: "1em",
1016
+ viewBox: "0 0 14 14",
1017
+ fill: "none",
1018
+ xmlns: "http://www.w3.org/2000/svg",
1019
+ "aria-labelledby": titleId
1020
+ }, props), title ? /*#__PURE__*/React__namespace.createElement("title", {
1021
+ id: titleId
1022
+ }, title) : null, /*#__PURE__*/React__namespace.createElement("path", {
1023
+ d: "m12.425.241.006-.005a.95.95 0 0 1 1.34 1.34l-.005.006-5.38 5.38 5.38 5.38.005.007a.95.95 0 0 1-1.34 1.34l-.006-.005-5.38-5.38-5.378 5.37a.951.951 0 1 1-1.34-1.341l5.377-5.37-5.38-5.388-.005-.006a.95.95 0 0 1 1.34-1.34l.006.005 5.38 5.387 5.38-5.38Z",
1024
+ fill: "#3C393E"
1025
+ }));
975
1026
 
976
- var css_248z$5 = ".select-module_select-content__GCMDX{display:flex;flex-direction:column;position:relative}.select-module_select-content-top__Aw-fB{align-items:center;display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between}.select-module_select-content-bottom__ueZCR{animation:select-module_select-show__391hQ .64s linear forwards;-webkit-animation:select-module_select-show__391hQ .64s linear forwards;left:0;max-height:0;overflow:hidden;position:absolute;width:100%;z-index:1}.select-module_select-content-bottom-inner__NWy2X{display:flex;flex-direction:column;max-height:234px;overflow-x:hidden;overflow-y:auto}.select-module_select-content-top-icon__MBrGK{align-items:center;box-sizing:border-box;display:flex;flex:0 0 auto;padding:0 5px 0 20px}.select-module_select-content-top-icon__MBrGK>div{align-items:center;display:flex;height:14px;justify-content:center;width:14px}.select-module_close-icon__SFNaJ{border-right:1px solid #eee;padding-right:9px}.select-module_arrow-icon__rjHt-{margin-left:9px;transform-origin:center;transition:all .64s ease;-webkit-transition:all .64s ease;-moz-transition:all .64s ease;-ms-transition:all .64s ease;-o-transition:all .64s ease}.select-module_select-content-bottom-row__eKq5L{align-items:center;display:flex;transition:background-color .24s,color .24s;-webkit-transition:background-color .24s,color .24s;-moz-transition:background-color .24s,color .24s;-ms-transition:background-color .24s,color .24s;-o-transition:background-color .24s,color .24s}.select-module_select-content-bottom-row__eKq5L:last-child{margin-bottom:0}@keyframes select-module_select-show__391hQ{to{max-height:234px}}";
1027
+ var css_248z$5 = ".select-module_select-content__GCMDX{display:flex;flex-direction:column;position:relative}.select-module_select-content-top__Aw-fB{align-items:center;display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between}.select-module_select-content-bottom__ueZCR{animation:select-module_select-show__391hQ .64s linear forwards;-webkit-animation:select-module_select-show__391hQ .64s linear forwards;left:0;max-height:0;overflow:hidden;position:absolute;width:100%;z-index:1}.select-module_select-content-bottom-inner__NWy2X{display:flex;flex-direction:column;max-height:234px;overflow-x:hidden;overflow-y:auto}.select-module_select-content-top-icon__MBrGK{align-items:center;box-sizing:border-box;display:flex;flex:0 0 auto;padding:0 5px 0 20px}.select-module_select-content-top-icon__MBrGK>div{align-items:center;display:flex;height:14px;justify-content:center;width:14px}.select-module_close-icon__SFNaJ{border-right:1px solid #eee;box-sizing:content-box;padding-right:9px}.select-module_arrow-icon__rjHt-{margin-left:9px;transform-origin:center;transition:all .64s ease;-webkit-transition:all .64s ease;-moz-transition:all .64s ease;-ms-transition:all .64s ease;-o-transition:all .64s ease}.select-module_select-content-bottom-row__eKq5L{align-items:center;display:flex;transition:background-color .24s,color .24s;-webkit-transition:background-color .24s,color .24s;-moz-transition:background-color .24s,color .24s;-ms-transition:background-color .24s,color .24s;-o-transition:background-color .24s,color .24s}.select-module_select-content-bottom-row__eKq5L:last-child{margin-bottom:0}@keyframes select-module_select-show__391hQ{to{max-height:234px}}";
977
1028
  var styles$5 = {"select-content":"select-module_select-content__GCMDX","select-content-top":"select-module_select-content-top__Aw-fB","select-content-bottom":"select-module_select-content-bottom__ueZCR","select-show":"select-module_select-show__391hQ","select-content-bottom-inner":"select-module_select-content-bottom-inner__NWy2X","select-content-top-icon":"select-module_select-content-top-icon__MBrGK","close-icon":"select-module_close-icon__SFNaJ","arrow-icon":"select-module_arrow-icon__rjHt-","select-content-bottom-row":"select-module_select-content-bottom-row__eKq5L"};
978
1029
  styleInject(css_248z$5);
979
1030
 
@@ -1055,22 +1106,24 @@ const Select = ({
1055
1106
  ...option
1056
1107
  };
1057
1108
  delete checkedOption.checked;
1058
- onChange(checkedOption);
1059
1109
  if (!multiple) {
1060
1110
  setOpened(!opened);
1061
1111
  setNewSelected([option]);
1112
+ onChange(checkedOption);
1062
1113
  } else {
1063
1114
  const indexOfObject = newSelected.findIndex(obj => {
1064
- return obj.value === option.value;
1115
+ return obj[keyNames.name] === option[keyNames.name];
1065
1116
  });
1066
1117
  if (indexOfObject === -1) {
1067
1118
  option.checked = true;
1068
1119
  setNewSelected(prev => {
1069
1120
  return [...prev, option];
1070
1121
  });
1122
+ onChange([...newSelected, option]);
1071
1123
  } else {
1072
1124
  option.checked = false;
1073
1125
  setNewSelected([...newSelected.slice(0, indexOfObject), ...newSelected.slice(indexOfObject + 1)]);
1126
+ onChange([...newSelected.slice(0, indexOfObject), ...newSelected.slice(indexOfObject + 1)]);
1074
1127
  }
1075
1128
  }
1076
1129
  };
@@ -1088,6 +1141,14 @@ const Select = ({
1088
1141
  e.target.style.color = optionItemColor ? optionItemColor : configStyles.SELECT.optionItemColor;
1089
1142
  e.target.style.backgroundColor = optionItemBackgroudColor ? optionItemBackgroudColor : configStyles.SELECT.optionItemBackgroudColor;
1090
1143
  };
1144
+ const isObjectEmpty = obj => {
1145
+ for (var key in obj) {
1146
+ if (obj.hasOwnProperty(key)) {
1147
+ return false;
1148
+ }
1149
+ }
1150
+ return true;
1151
+ };
1091
1152
  React.useEffect(() => {
1092
1153
  if (opened) {
1093
1154
  const checkIfClickedOutside = e => {
@@ -1102,7 +1163,7 @@ const Select = ({
1102
1163
  }
1103
1164
  }, [opened]);
1104
1165
  React.useEffect(() => {
1105
- selected && selected.length > 0 && setNewSelected(selected);
1166
+ selected && selected.length > 0 && setNewSelected(isObjectEmpty(selected[0]) ? [] : selected);
1106
1167
  if (!multiple) {
1107
1168
  options && options.length > 0 && setExistOptions(options);
1108
1169
  } else {
@@ -1110,7 +1171,7 @@ const Select = ({
1110
1171
  item.checked = false;
1111
1172
  if (selected && selected.length > 0) {
1112
1173
  selected.map(innerItem => {
1113
- if (innerItem.value === item.value) {
1174
+ if (innerItem[keyNames.name] === item[keyNames.name]) {
1114
1175
  item.checked = true;
1115
1176
  }
1116
1177
  });
@@ -1179,18 +1240,12 @@ const Select = ({
1179
1240
  style: {
1180
1241
  marginLeft: multiple && newSelected.length > 1 ? '17px' : '0px'
1181
1242
  }
1182
- }, closeIcon ? closeIcon : /*#__PURE__*/React__default["default"].createElement("img", {
1183
- src: ReactCloseIcon,
1184
- alt: "icon"
1185
- })), /*#__PURE__*/React__default["default"].createElement("div", {
1243
+ }, closeIcon ? closeIcon : /*#__PURE__*/React__default["default"].createElement(SvgCloseIcon, null)), /*#__PURE__*/React__default["default"].createElement("div", {
1186
1244
  style: {
1187
1245
  transform: opened ? 'rotate(180deg)' : 'rotate(0deg)'
1188
1246
  },
1189
1247
  className: `${styles$5['arrow-icon']}`
1190
- }, arrowIcon ? arrowIcon : /*#__PURE__*/React__default["default"].createElement("img", {
1191
- src: ReactArrowIcon,
1192
- alt: "icon"
1193
- })))), opened && !disabled ? /*#__PURE__*/React__default["default"].createElement("div", {
1248
+ }, arrowIcon ? arrowIcon : /*#__PURE__*/React__default["default"].createElement(SvgArrow, null)))), opened && !disabled ? /*#__PURE__*/React__default["default"].createElement("div", {
1194
1249
  style: {
1195
1250
  boxShadow: optionsBoxShadow ? optionsBoxShadow : configStyles.SELECT.optionsBoxShadow,
1196
1251
  borderRadius: optionsBorderRadius ? optionsBorderRadius : configStyles.SELECT.optionsBorderRadius,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaypay/tui",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -9,7 +9,7 @@
9
9
  "storybook": "STORYBOOK_PATH=../../tui.config.js start-storybook -p 6006",
10
10
  "build-storybook": "STORYBOOK_PATH=../../tui.config.js build-storybook",
11
11
  "build-lib": "STORYBOOK_PATH=../tui.config.js rollup --config rollup.config.js",
12
- "svgr": "svgr --icon --title-prop --replace-attr-values '#1D1D1D=currentColor' -d src/components/icon -- src/assets"
12
+ "svgr": "svgr --icon --title-prop -d src/components/icon -- src/assets/icons"
13
13
  },
14
14
  "author": "",
15
15
  "license": "MIT",
@@ -28,6 +28,7 @@
28
28
  "@storybook/react": "^6.5.10",
29
29
  "@storybook/testing-library": "^0.0.13",
30
30
  "@svgr/cli": "^6.4.0",
31
+ "@svgr/webpack": "^6.5.1",
31
32
  "babel-loader": "^8.2.5",
32
33
  "classnames": "^2.3.1",
33
34
  "css-loader": "^6.7.1",
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ const SvgArrow = ({ title, titleId, ...props }) => (
3
+ <svg
4
+ width="1em"
5
+ height="1em"
6
+ viewBox="0 0 15 9"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ aria-labelledby={titleId}
10
+ {...props}
11
+ >
12
+ {title ? <title id={titleId}>{title}</title> : null}
13
+ <path
14
+ d="M7.988 8a.997.997 0 0 1-.64-.23l-5.989-5a1.002 1.002 0 0 1 .548-1.767.998.998 0 0 1 .73.227l5.35 4.48 5.351-4.32a.997.997 0 0 1 1.408.15 1 1 0 0 1-.14 1.46l-5.99 4.83a.997.997 0 0 1-.628.17Z"
15
+ fill="#3C393E"
16
+ />
17
+ </svg>
18
+ );
19
+ export default SvgArrow;
@@ -0,0 +1,21 @@
1
+ import * as React from "react";
2
+ const SvgCheckboxChecked = ({ title, titleId, ...props }) => (
3
+ <svg
4
+ width="1em"
5
+ height="1em"
6
+ viewBox="0 0 16 16"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ aria-labelledby={titleId}
10
+ {...props}
11
+ >
12
+ {title ? <title id={titleId}>{title}</title> : null}
13
+ <path
14
+ fillRule="evenodd"
15
+ clipRule="evenodd"
16
+ d="M12.8 0H3.2A3.2 3.2 0 0 0 0 3.2v9.6A3.2 3.2 0 0 0 3.2 16h9.6a3.2 3.2 0 0 0 3.2-3.2V3.2A3.2 3.2 0 0 0 12.8 0ZM6.85 10.966c.068.023.14.034.218.034.078 0 .151-.011.219-.034a.515.515 0 0 0 .19-.114l5.363-4.94A.496.496 0 0 0 13 5.53a.496.496 0 0 0-.16-.382.589.589 0 0 0-.415-.148.59.59 0 0 0-.416.148l-4.94 4.55-2.085-1.92a.579.579 0 0 0-.408-.147.579.579 0 0 0-.408.148A.52.52 0 0 0 4 8.16a.476.476 0 0 0 .154.383l2.506 2.308a.515.515 0 0 0 .19.114Z"
17
+ fill="#00236A"
18
+ />
19
+ </svg>
20
+ );
21
+ export default SvgCheckboxChecked;
@@ -0,0 +1,21 @@
1
+ import * as React from "react";
2
+ const SvgCheckboxUnchecked = ({ title, titleId, ...props }) => (
3
+ <svg
4
+ width="1em"
5
+ height="1em"
6
+ viewBox="0 0 16 16"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ aria-labelledby={titleId}
10
+ {...props}
11
+ >
12
+ {title ? <title id={titleId}>{title}</title> : null}
13
+ <path
14
+ fillRule="evenodd"
15
+ clipRule="evenodd"
16
+ d="M3.2 0h9.6A3.2 3.2 0 0 1 16 3.2v9.6a3.2 3.2 0 0 1-3.2 3.2H3.2A3.2 3.2 0 0 1 0 12.8V3.2A3.2 3.2 0 0 1 3.2 0Zm0 1.6a1.6 1.6 0 0 0-1.6 1.6v9.6a1.6 1.6 0 0 0 1.6 1.6h9.6a1.6 1.6 0 0 0 1.6-1.6V3.2a1.6 1.6 0 0 0-1.6-1.6H3.2Z"
17
+ fill="#D1D1D1"
18
+ />
19
+ </svg>
20
+ );
21
+ export default SvgCheckboxUnchecked;
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ const SvgCloseIcon = ({ title, titleId, ...props }) => (
3
+ <svg
4
+ width="1em"
5
+ height="1em"
6
+ viewBox="0 0 14 14"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ aria-labelledby={titleId}
10
+ {...props}
11
+ >
12
+ {title ? <title id={titleId}>{title}</title> : null}
13
+ <path
14
+ d="m12.425.241.006-.005a.95.95 0 0 1 1.34 1.34l-.005.006-5.38 5.38 5.38 5.38.005.007a.95.95 0 0 1-1.34 1.34l-.006-.005-5.38-5.38-5.378 5.37a.951.951 0 1 1-1.34-1.341l5.377-5.37-5.38-5.388-.005-.006a.95.95 0 0 1 1.34-1.34l.006.005 5.38 5.387 5.38-5.38Z"
15
+ fill="#3C393E"
16
+ />
17
+ </svg>
18
+ );
19
+ export default SvgCloseIcon;
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ const SvgTooltip = ({ title, titleId, ...props }) => (
3
+ <svg
4
+ width="1em"
5
+ height="1em"
6
+ viewBox="0 0 16 16"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ aria-labelledby={titleId}
10
+ {...props}
11
+ >
12
+ {title ? <title id={titleId}>{title}</title> : null}
13
+ <path
14
+ d="M8 0a8 8 0 1 0 .001 16.001A8 8 0 0 0 8 0Zm.571 11.857A.143.143 0 0 1 8.43 12H7.57a.143.143 0 0 1-.142-.143V7c0-.079.064-.143.142-.143h.858c.078 0 .142.064.142.143v4.857ZM8 5.714A.857.857 0 0 1 8 4a.857.857 0 0 1 0 1.714Z"
15
+ fill="#D1D1D1"
16
+ />
17
+ </svg>
18
+ );
19
+ export default SvgTooltip;
@@ -1,6 +1,5 @@
1
- export { default as HeartFilled } from "./HeartFilled";
2
- export { default as HeartOutline } from "./HeartOutline";
3
- export { default as LikeFilled } from "./LikeFilled";
4
- export { default as LikeOutline } from "./LikeOutline";
5
- export { default as StarFilled } from "./StarFilled";
6
- export { default as StarOutline } from "./StarOutline";
1
+ export { default as Arrow } from "./Arrow";
2
+ export { default as CheckboxChecked } from "./CheckboxChecked";
3
+ export { default as CheckboxUnchecked } from "./CheckboxUnchecked";
4
+ export { default as CloseIcon } from "./CloseIcon";
5
+ export { default as Tooltip } from "./Tooltip";
@@ -2,11 +2,10 @@ import React, {useEffect, useState, useRef} from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classnames from 'classnames';
4
4
  import { compereConfigs } from "./../../utils";
5
-
6
5
  import { SelectCheckbox } from './../selectCheckbox';
7
6
 
8
- import ReactArrowIcon from './../../assets/icons/arrow.svg';
9
- import ReactCloseIcon from './../../assets/icons/close-icon.svg';
7
+ import ReactArrowIcon from '../icon/Arrow';
8
+ import ReactCloseIcon from '../icon/CloseIcon';
10
9
 
11
10
  import styles from './select.module.css';
12
11
 
@@ -97,14 +96,14 @@ export const Select = ({
97
96
  const handleSelectItem = (option) => {
98
97
  const checkedOption = {...option};
99
98
  delete checkedOption.checked;
100
- onChange(checkedOption);
101
99
 
102
100
  if (!multiple) {
103
101
  setOpened(!opened);
104
102
  setNewSelected([option]);
103
+ onChange(checkedOption);
105
104
  } else {
106
105
  const indexOfObject = newSelected.findIndex(obj => {
107
- return obj.value === option.value;
106
+ return obj[keyNames.name] === option[keyNames.name];
108
107
  });
109
108
  if (indexOfObject === -1) {
110
109
  option.checked = true;
@@ -114,12 +113,17 @@ export const Select = ({
114
113
  option
115
114
  ]
116
115
  });
116
+ onChange([...newSelected, option])
117
117
  } else {
118
118
  option.checked = false;
119
119
  setNewSelected([
120
120
  ...newSelected.slice(0, indexOfObject),
121
121
  ...newSelected.slice(indexOfObject + 1),
122
122
  ]);
123
+ onChange([
124
+ ...newSelected.slice(0, indexOfObject),
125
+ ...newSelected.slice(indexOfObject + 1),
126
+ ])
123
127
  }
124
128
  }
125
129
  };
@@ -142,6 +146,15 @@ export const Select = ({
142
146
  e.target.style.backgroundColor = optionItemBackgroudColor ? optionItemBackgroudColor : configStyles.SELECT.optionItemBackgroudColor;
143
147
  };
144
148
 
149
+ const isObjectEmpty = (obj) => {
150
+ for (var key in obj) {
151
+ if (obj.hasOwnProperty(key)) {
152
+ return false;
153
+ }
154
+ }
155
+ return true;
156
+ }
157
+
145
158
  useEffect(() => {
146
159
  if(opened){
147
160
  const checkIfClickedOutside = e => {
@@ -157,7 +170,7 @@ export const Select = ({
157
170
  }, [opened]);
158
171
 
159
172
  useEffect(() => {
160
- selected && selected.length > 0 && setNewSelected(selected);
173
+ selected && selected.length > 0 && setNewSelected(isObjectEmpty(selected[0]) ? []: selected );
161
174
  if (!multiple) {
162
175
  options && options.length > 0 && setExistOptions(options);
163
176
  } else {
@@ -165,7 +178,7 @@ export const Select = ({
165
178
  item.checked = false;
166
179
  if (selected && selected.length > 0) {
167
180
  selected.map(innerItem => {
168
- if (innerItem.value === item.value) {
181
+ if (innerItem[keyNames.name] === item[keyNames.name]) {
169
182
  item.checked = true;
170
183
  }
171
184
  });
@@ -247,7 +260,7 @@ export const Select = ({
247
260
  onClick={disabled ? _ => _ : handleClearSelect}
248
261
  style={{marginLeft: multiple && newSelected.length > 1 ? '17px' : '0px'}}
249
262
  >
250
- { closeIcon ? closeIcon : <img src={ReactCloseIcon} alt="icon" /> }
263
+ { closeIcon ? closeIcon : <ReactCloseIcon /> }
251
264
  </div>
252
265
  }
253
266
 
@@ -256,7 +269,7 @@ export const Select = ({
256
269
  transform: opened ? 'rotate(180deg)' : 'rotate(0deg)',
257
270
  }}
258
271
  className={`${styles['arrow-icon']}`}>
259
- {arrowIcon ? arrowIcon : <img src={ReactArrowIcon} alt="icon"/>}
272
+ {arrowIcon ? arrowIcon : <ReactArrowIcon />}
260
273
  </div>
261
274
  </div>
262
275
  </div>
@@ -50,6 +50,7 @@
50
50
  .close-icon {
51
51
  padding-right: 9px;
52
52
  border-right: 1px solid #EEEEEE;
53
+ box-sizing: content-box;
53
54
  }
54
55
 
55
56
  .arrow-icon{
@@ -1,24 +0,0 @@
1
- import * as React from "react";
2
-
3
- const SvgLikeFilled = ({ title, titleId, ...props }) => (
4
- <svg
5
- width="1em"
6
- height="1em"
7
- viewBox="0 0 23 20"
8
- xmlns="http://www.w3.org/2000/svg"
9
- role="img"
10
- aria-labelledby={titleId}
11
- {...props}
12
- >
13
- {title ? <title id={titleId}>{title}</title> : null}
14
- <g fill="none" fillRule="evenodd">
15
- <path opacity={0.87} d="M-1-1h24v24H-1z" />
16
- <path
17
- d="M12.12 1.06 6.58 6.6c-.37.37-.58.88-.58 1.41V18c0 1.1.9 2 2 2h9c.8 0 1.52-.48 1.84-1.21l3.26-7.61C22.94 9.2 21.49 7 19.34 7h-5.65l.95-4.58c.1-.5-.05-1.01-.41-1.37-.59-.58-1.53-.58-2.11.01ZM2 20c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2s-2 .9-2 2v8c0 1.1.9 2 2 2Z"
18
- fill="currentColor"
19
- />
20
- </g>
21
- </svg>
22
- );
23
-
24
- export default SvgLikeFilled;
@@ -1,24 +0,0 @@
1
- import * as React from "react";
2
-
3
- const SvgLikeOutline = ({ title, titleId, ...props }) => (
4
- <svg
5
- width="1em"
6
- height="1em"
7
- viewBox="0 0 22 20"
8
- xmlns="http://www.w3.org/2000/svg"
9
- role="img"
10
- aria-labelledby={titleId}
11
- {...props}
12
- >
13
- {title ? <title id={titleId}>{title}</title> : null}
14
- <g fill="none" fillRule="evenodd">
15
- <path opacity={0.87} d="M-1-1h24v24H-1z" />
16
- <path
17
- d="M20 7h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L13.17 0 6.59 6.59C6.22 6.95 6 7.45 6 8v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73V9c0-1.1-.9-2-2-2Zm0 4-3 7H8V8l4.34-4.34L11.23 9H20v2ZM0 8h4v12H0V8Z"
18
- fill="currentColor"
19
- />
20
- </g>
21
- </svg>
22
- );
23
-
24
- export default SvgLikeOutline;
@@ -1,24 +0,0 @@
1
- import * as React from "react";
2
-
3
- const SvgStarFilled = ({ title, titleId, ...props }) => (
4
- <svg
5
- width="1em"
6
- height="1em"
7
- viewBox="0 0 18 17"
8
- xmlns="http://www.w3.org/2000/svg"
9
- role="img"
10
- aria-labelledby={titleId}
11
- {...props}
12
- >
13
- {title ? <title id={titleId}>{title}</title> : null}
14
- <g fill="none" fillRule="evenodd">
15
- <path d="M-3-3h24v24H-3z" />
16
- <path
17
- d="m9 14.27 4.15 2.51c.76.46 1.69-.22 1.49-1.08l-1.1-4.72 3.67-3.18c.67-.58.31-1.68-.57-1.75l-4.83-.41-1.89-4.46c-.34-.81-1.5-.81-1.84 0L6.19 5.63l-4.83.41C.48 6.11.12 7.21.79 7.79l3.67 3.18-1.1 4.72c-.2.86.73 1.54 1.49 1.08L9 14.27Z"
18
- fill="currentColor"
19
- />
20
- </g>
21
- </svg>
22
- );
23
-
24
- export default SvgStarFilled;
@@ -1,24 +0,0 @@
1
- import * as React from "react";
2
-
3
- const SvgStarOutline = ({ title, titleId, ...props }) => (
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- viewBox="0 0 24 24"
7
- fill="none"
8
- stroke="currentColor"
9
- strokeWidth={2}
10
- strokeLinecap="round"
11
- strokeLinejoin="round"
12
- className="star-outline_svg__feather star-outline_svg__feather-star"
13
- width="1em"
14
- height="1em"
15
- role="img"
16
- aria-labelledby={titleId}
17
- {...props}
18
- >
19
- {title ? <title id={titleId}>{title}</title> : null}
20
- <path d="m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" />
21
- </svg>
22
- );
23
-
24
- export default SvgStarOutline;