@xaypay/tui 0.0.30 → 0.0.32
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.es.js +29 -16
- package/dist/index.js +28 -15
- package/package.json +1 -1
- package/src/components/file/file.module.css +1 -0
- package/src/components/modal/index.js +1 -1
- package/src/components/modal/modal.module.css +2 -1
- package/src/components/modal/modal.stories.js +4 -1
- package/src/components/select/index.js +56 -38
- package/src/components/select/select.stories.js +1 -1
- package/src/components/table/table.stories.js +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, useMemo } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import styled from 'styled-components';
|
|
@@ -842,12 +842,26 @@ const Select = ({
|
|
|
842
842
|
selected
|
|
843
843
|
}) => {
|
|
844
844
|
const options = jsonData.length ? JSON.parse(jsonData) : [];
|
|
845
|
+
const ref = useRef();
|
|
845
846
|
let [opened, setOpened] = useState(false);
|
|
846
847
|
let [newSelected, setNewSelected] = useState({});
|
|
847
848
|
useEffect(() => {
|
|
848
849
|
const parseSelectedData = selected.length !== 0 ? JSON.parse(selected) : {};
|
|
849
850
|
setNewSelected(parseSelectedData);
|
|
850
851
|
}, [selected]);
|
|
852
|
+
useEffect(() => {
|
|
853
|
+
if (opened) {
|
|
854
|
+
const checkIfClickedOutside = e => {
|
|
855
|
+
if (opened && ref.current && !ref.current.contains(e.target)) {
|
|
856
|
+
setOpened(false);
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
document.addEventListener("mousedown", checkIfClickedOutside);
|
|
860
|
+
return () => {
|
|
861
|
+
document.removeEventListener("mousedown", checkIfClickedOutside);
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
}, [opened]);
|
|
851
865
|
classnames(styles$3[theme], styles$3[size], {
|
|
852
866
|
[styles$3.disabled]: disabled,
|
|
853
867
|
[styles$3.required]: required
|
|
@@ -855,7 +869,8 @@ const Select = ({
|
|
|
855
869
|
return /*#__PURE__*/React.createElement("div", null, label ? /*#__PURE__*/React.createElement("label", {
|
|
856
870
|
className: styles$3['select-title']
|
|
857
871
|
}, label) : "", /*#__PURE__*/React.createElement("div", {
|
|
858
|
-
className: styles$3['select-wrap']
|
|
872
|
+
className: styles$3['select-wrap'],
|
|
873
|
+
ref: ref
|
|
859
874
|
}, /*#__PURE__*/React.createElement("div", {
|
|
860
875
|
className: styles$3['select-content'],
|
|
861
876
|
id: styles$3.selector
|
|
@@ -868,22 +883,19 @@ const Select = ({
|
|
|
868
883
|
className: styles$3['select-content-top-text']
|
|
869
884
|
}, newSelected && newSelected[keyNames.name] ? newSelected[keyNames.name] : defaultOption), /*#__PURE__*/React.createElement("div", {
|
|
870
885
|
className: styles$3['select-content-top-icon']
|
|
871
|
-
}, /*#__PURE__*/React.createElement(
|
|
886
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
887
|
+
onClick: e => {
|
|
888
|
+
setNewSelected({});
|
|
889
|
+
onChange({});
|
|
890
|
+
e.stopPropagation();
|
|
891
|
+
}
|
|
892
|
+
}, "X"), /*#__PURE__*/React.createElement("i", {
|
|
872
893
|
className: opened ? 'icon-arrow-up' : 'icon-arrow-down'
|
|
873
894
|
}))), opened && !disabled ? /*#__PURE__*/React.createElement("div", {
|
|
874
895
|
className: styles$3['select-content-bottom']
|
|
875
896
|
}, /*#__PURE__*/React.createElement("div", {
|
|
876
897
|
className: styles$3['select-content-bottom-inner']
|
|
877
|
-
},
|
|
878
|
-
className: styles$3['select-content-bottom-row'],
|
|
879
|
-
onClick: () => {
|
|
880
|
-
if (!required && !selected) {
|
|
881
|
-
setNewSelected(defaultOption);
|
|
882
|
-
onChange(defaultOption);
|
|
883
|
-
setOpened(!opened);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
}, defaultOption), options.map((option, i) => {
|
|
898
|
+
}, options.map((option, i) => {
|
|
887
899
|
return /*#__PURE__*/React.createElement("div", {
|
|
888
900
|
key: i,
|
|
889
901
|
className: styles$3['select-content-bottom-row'],
|
|
@@ -917,7 +929,7 @@ Select.defaultProps = {
|
|
|
917
929
|
size: 'medium'
|
|
918
930
|
};
|
|
919
931
|
|
|
920
|
-
var css_248z$2 = ".file-module_file-form__l13d5{align-items:center;background:#fbfbfb;border:2px dashed;border-radius:6px;cursor:pointer;display:flex;flex-direction:column;height:100%;justify-content:space-between;padding:4px 0;position:relative;width:100%}.file-module_file-form__l13d5:hover .file-module_delete-upload-file__DirSm{opacity:1}.file-module_file-form-inner-upload__tq3Dn{align-items:center;display:flex;flex-direction:column;justify-content:space-between;padding-bottom:16px;padding-top:48px}.file-module_file-form-inner-upload__tq3Dn>img{display:block;margin-bottom:14px}.file-module_upload-info__a8GFs{margin-bottom:40px;max-width:150px;text-align:center}.file-module_upload-info-txt__l11uN{color:#0da574}.file-module_file-form__l13d5.file-module_default__t7KU0{border-color:#d1d1d1}.file-module_file-form__l13d5.file-module_error__H-M4Z{border-color:#e00}.file-module_file-form__l13d5.file-module_accept__WTW6V{border-color:#00236a}.file-module_delete-upload-file__DirSm{background:rgba(60,57,62,.4);height:100%;left:0;opacity:0;position:absolute;top:0;transition:opacity .24s;width:100%;z-index:1}.file-module_delete-upload-icon__PWN66{align-items:center;background:#fff;border-radius:6px;display:flex;height:26px;justify-content:center;position:absolute;right:10px;top:10px;width:26px;z-index:2}.file-module_delete-upload-icon__PWN66>i{color:#00236a;font-size:16px}.file-module_upload-file-content__QHMjn>img{display:block}.file-module_file-form-title__zWTSB{margin-bottom:10px;max-width:390px;word-break:break-all}";
|
|
932
|
+
var css_248z$2 = ".file-module_file-form__l13d5{align-items:center;background:#fbfbfb;border:2px dashed;border-radius:6px;cursor:pointer;display:flex;flex-direction:column;height:100%;justify-content:space-between;padding:4px 0;position:relative;width:100%}.file-module_file-form__l13d5:hover .file-module_delete-upload-file__DirSm{opacity:1}.file-module_file-form-inner-upload__tq3Dn{align-items:center;display:flex;flex-direction:column;justify-content:space-between;padding-bottom:16px;padding-top:48px}.file-module_file-form-inner-upload__tq3Dn>img{display:block;margin-bottom:14px}.file-module_upload-info__a8GFs{margin-bottom:40px;max-width:150px;text-align:center}.file-module_upload-info-txt__l11uN{color:#0da574}.file-module_file-form__l13d5.file-module_default__t7KU0{border-color:#d1d1d1}.file-module_file-form__l13d5.file-module_error__H-M4Z{border-color:#e00}.file-module_file-form__l13d5.file-module_accept__WTW6V{border-color:#00236a}.file-module_delete-upload-file__DirSm{background:rgba(60,57,62,.4);height:100%;left:0;opacity:0;position:absolute;top:0;transition:opacity .24s;width:100%;z-index:1}.file-module_delete-upload-icon__PWN66{align-items:center;background:#fff;border-radius:6px;display:flex;height:26px;justify-content:center;position:absolute;right:10px;top:10px;width:26px;z-index:2}.file-module_delete-upload-icon__PWN66>i{color:#00236a;font-size:16px}.file-module_upload-file-content__QHMjn>img{display:block;max-width:400px}.file-module_file-form-title__zWTSB{margin-bottom:10px;max-width:390px;word-break:break-all}";
|
|
921
933
|
var styles$2 = {"file-form":"file-module_file-form__l13d5","delete-upload-file":"file-module_delete-upload-file__DirSm","file-form-inner-upload":"file-module_file-form-inner-upload__tq3Dn","upload-info":"file-module_upload-info__a8GFs","upload-info-txt":"file-module_upload-info-txt__l11uN","default":"file-module_default__t7KU0","error":"file-module_error__H-M4Z","accept":"file-module_accept__WTW6V","delete-upload-icon":"file-module_delete-upload-icon__PWN66","upload-file-content":"file-module_upload-file-content__QHMjn","file-form-title":"file-module_file-form-title__zWTSB"};
|
|
922
934
|
styleInject(css_248z$2);
|
|
923
935
|
|
|
@@ -1032,7 +1044,7 @@ File.propTypes = {
|
|
|
1032
1044
|
defaultData: PropTypes.object
|
|
1033
1045
|
};
|
|
1034
1046
|
|
|
1035
|
-
var css_248z$1 = ".modal-module_modal-wrap__IsXXf{background:rgba(0,0,0,.4);height:100%;left:0;position:fixed;top:0;width:100%;z-index:9}.modal-module_modal-top__ntDBi{box-shadow:0 1px 0 0 rgba(0,0,0,.08);box-sizing:border-box;display:flex;flex-direction:row;height:30px;padding-left:24px;width:100%}.modal-module_modal-title__r-WKl{align-items:center;color:#3c393e;display:flex;flex:1 1;font-size:20px;font-weight:500;justify-content:center;line-height:24px}.modal-module_close-btn__Qf2UD{cursor:pointer;flex:0 0 auto;width:24px}.modal-module_close-btn__Qf2UD,.modal-module_modal-section__Bp8jN{align-items:center;display:flex;height:100%;justify-content:center}.modal-module_modal-section__Bp8jN{flex:1 1;width:100%}.modal-module_modal-content__1F-uE{align-items:center;animation:modal-module_show-popup__WrH7a .24s;background:#fff;border-radius:8px;display:flex;flex-direction:column;height:auto;left:0;margin:auto;min-height:130px;padding:
|
|
1047
|
+
var css_248z$1 = ".modal-module_modal-wrap__IsXXf{background:rgba(0,0,0,.4);height:100%;left:0;position:fixed;top:0;width:100%;z-index:9}.modal-module_modal-top__ntDBi{box-shadow:0 1px 0 0 rgba(0,0,0,.08);box-sizing:border-box;display:flex;flex-direction:row;height:30px;padding-left:24px;width:100%}.modal-module_modal-title__r-WKl{align-items:center;color:#3c393e;display:flex;flex:1 1;font-size:20px;font-weight:500;justify-content:center;line-height:24px}.modal-module_close-btn__Qf2UD{cursor:pointer;flex:0 0 auto;width:24px}.modal-module_close-btn__Qf2UD,.modal-module_modal-section__Bp8jN{align-items:center;display:flex;height:100%;justify-content:center}.modal-module_modal-section__Bp8jN{flex:1 1;padding:10px 0;width:100%}.modal-module_modal-content__1F-uE{align-items:center;animation:modal-module_show-popup__WrH7a .24s;background:#fff;border-radius:8px;display:flex;flex-direction:column;height:auto;left:0;margin:auto;min-height:130px;padding:10px;position:absolute;right:0;top:110px;width:fit-content}@keyframes modal-module_show-popup__WrH7a{0%{transform:translate3d(0,-30%,0)}to{opacity:1;transform:translateZ(0)}}";
|
|
1036
1048
|
var styles$1 = {"modal-wrap":"modal-module_modal-wrap__IsXXf","modal-top":"modal-module_modal-top__ntDBi","modal-title":"modal-module_modal-title__r-WKl","close-btn":"modal-module_close-btn__Qf2UD","modal-section":"modal-module_modal-section__Bp8jN","modal-content":"modal-module_modal-content__1F-uE","show-popup":"modal-module_show-popup__WrH7a"};
|
|
1037
1049
|
styleInject(css_248z$1);
|
|
1038
1050
|
|
|
@@ -1056,7 +1068,8 @@ const Modal = ({
|
|
|
1056
1068
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1057
1069
|
className: styles$1["modal-title"]
|
|
1058
1070
|
}, /*#__PURE__*/React.createElement(Typography, {
|
|
1059
|
-
variant: TypographyType.
|
|
1071
|
+
variant: TypographyType.p,
|
|
1072
|
+
color: "#00236A"
|
|
1060
1073
|
}, headerText)), /*#__PURE__*/React.createElement("div", {
|
|
1061
1074
|
className: styles$1["close-btn"],
|
|
1062
1075
|
onClick: () => setShow(false)
|
package/dist/index.js
CHANGED
|
@@ -853,12 +853,26 @@ const Select = ({
|
|
|
853
853
|
selected
|
|
854
854
|
}) => {
|
|
855
855
|
const options = jsonData.length ? JSON.parse(jsonData) : [];
|
|
856
|
+
const ref = React.useRef();
|
|
856
857
|
let [opened, setOpened] = React.useState(false);
|
|
857
858
|
let [newSelected, setNewSelected] = React.useState({});
|
|
858
859
|
React.useEffect(() => {
|
|
859
860
|
const parseSelectedData = selected.length !== 0 ? JSON.parse(selected) : {};
|
|
860
861
|
setNewSelected(parseSelectedData);
|
|
861
862
|
}, [selected]);
|
|
863
|
+
React.useEffect(() => {
|
|
864
|
+
if (opened) {
|
|
865
|
+
const checkIfClickedOutside = e => {
|
|
866
|
+
if (opened && ref.current && !ref.current.contains(e.target)) {
|
|
867
|
+
setOpened(false);
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
document.addEventListener("mousedown", checkIfClickedOutside);
|
|
871
|
+
return () => {
|
|
872
|
+
document.removeEventListener("mousedown", checkIfClickedOutside);
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
}, [opened]);
|
|
862
876
|
classnames__default["default"](styles$3[theme], styles$3[size], {
|
|
863
877
|
[styles$3.disabled]: disabled,
|
|
864
878
|
[styles$3.required]: required
|
|
@@ -866,7 +880,8 @@ const Select = ({
|
|
|
866
880
|
return /*#__PURE__*/React__default["default"].createElement("div", null, label ? /*#__PURE__*/React__default["default"].createElement("label", {
|
|
867
881
|
className: styles$3['select-title']
|
|
868
882
|
}, label) : "", /*#__PURE__*/React__default["default"].createElement("div", {
|
|
869
|
-
className: styles$3['select-wrap']
|
|
883
|
+
className: styles$3['select-wrap'],
|
|
884
|
+
ref: ref
|
|
870
885
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
871
886
|
className: styles$3['select-content'],
|
|
872
887
|
id: styles$3.selector
|
|
@@ -879,22 +894,19 @@ const Select = ({
|
|
|
879
894
|
className: styles$3['select-content-top-text']
|
|
880
895
|
}, newSelected && newSelected[keyNames.name] ? newSelected[keyNames.name] : defaultOption), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
881
896
|
className: styles$3['select-content-top-icon']
|
|
882
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
897
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
898
|
+
onClick: e => {
|
|
899
|
+
setNewSelected({});
|
|
900
|
+
onChange({});
|
|
901
|
+
e.stopPropagation();
|
|
902
|
+
}
|
|
903
|
+
}, "X"), /*#__PURE__*/React__default["default"].createElement("i", {
|
|
883
904
|
className: opened ? 'icon-arrow-up' : 'icon-arrow-down'
|
|
884
905
|
}))), opened && !disabled ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
885
906
|
className: styles$3['select-content-bottom']
|
|
886
907
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
887
908
|
className: styles$3['select-content-bottom-inner']
|
|
888
|
-
},
|
|
889
|
-
className: styles$3['select-content-bottom-row'],
|
|
890
|
-
onClick: () => {
|
|
891
|
-
if (!required && !selected) {
|
|
892
|
-
setNewSelected(defaultOption);
|
|
893
|
-
onChange(defaultOption);
|
|
894
|
-
setOpened(!opened);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
}, defaultOption), options.map((option, i) => {
|
|
909
|
+
}, options.map((option, i) => {
|
|
898
910
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
899
911
|
key: i,
|
|
900
912
|
className: styles$3['select-content-bottom-row'],
|
|
@@ -928,7 +940,7 @@ Select.defaultProps = {
|
|
|
928
940
|
size: 'medium'
|
|
929
941
|
};
|
|
930
942
|
|
|
931
|
-
var css_248z$2 = ".file-module_file-form__l13d5{align-items:center;background:#fbfbfb;border:2px dashed;border-radius:6px;cursor:pointer;display:flex;flex-direction:column;height:100%;justify-content:space-between;padding:4px 0;position:relative;width:100%}.file-module_file-form__l13d5:hover .file-module_delete-upload-file__DirSm{opacity:1}.file-module_file-form-inner-upload__tq3Dn{align-items:center;display:flex;flex-direction:column;justify-content:space-between;padding-bottom:16px;padding-top:48px}.file-module_file-form-inner-upload__tq3Dn>img{display:block;margin-bottom:14px}.file-module_upload-info__a8GFs{margin-bottom:40px;max-width:150px;text-align:center}.file-module_upload-info-txt__l11uN{color:#0da574}.file-module_file-form__l13d5.file-module_default__t7KU0{border-color:#d1d1d1}.file-module_file-form__l13d5.file-module_error__H-M4Z{border-color:#e00}.file-module_file-form__l13d5.file-module_accept__WTW6V{border-color:#00236a}.file-module_delete-upload-file__DirSm{background:rgba(60,57,62,.4);height:100%;left:0;opacity:0;position:absolute;top:0;transition:opacity .24s;width:100%;z-index:1}.file-module_delete-upload-icon__PWN66{align-items:center;background:#fff;border-radius:6px;display:flex;height:26px;justify-content:center;position:absolute;right:10px;top:10px;width:26px;z-index:2}.file-module_delete-upload-icon__PWN66>i{color:#00236a;font-size:16px}.file-module_upload-file-content__QHMjn>img{display:block}.file-module_file-form-title__zWTSB{margin-bottom:10px;max-width:390px;word-break:break-all}";
|
|
943
|
+
var css_248z$2 = ".file-module_file-form__l13d5{align-items:center;background:#fbfbfb;border:2px dashed;border-radius:6px;cursor:pointer;display:flex;flex-direction:column;height:100%;justify-content:space-between;padding:4px 0;position:relative;width:100%}.file-module_file-form__l13d5:hover .file-module_delete-upload-file__DirSm{opacity:1}.file-module_file-form-inner-upload__tq3Dn{align-items:center;display:flex;flex-direction:column;justify-content:space-between;padding-bottom:16px;padding-top:48px}.file-module_file-form-inner-upload__tq3Dn>img{display:block;margin-bottom:14px}.file-module_upload-info__a8GFs{margin-bottom:40px;max-width:150px;text-align:center}.file-module_upload-info-txt__l11uN{color:#0da574}.file-module_file-form__l13d5.file-module_default__t7KU0{border-color:#d1d1d1}.file-module_file-form__l13d5.file-module_error__H-M4Z{border-color:#e00}.file-module_file-form__l13d5.file-module_accept__WTW6V{border-color:#00236a}.file-module_delete-upload-file__DirSm{background:rgba(60,57,62,.4);height:100%;left:0;opacity:0;position:absolute;top:0;transition:opacity .24s;width:100%;z-index:1}.file-module_delete-upload-icon__PWN66{align-items:center;background:#fff;border-radius:6px;display:flex;height:26px;justify-content:center;position:absolute;right:10px;top:10px;width:26px;z-index:2}.file-module_delete-upload-icon__PWN66>i{color:#00236a;font-size:16px}.file-module_upload-file-content__QHMjn>img{display:block;max-width:400px}.file-module_file-form-title__zWTSB{margin-bottom:10px;max-width:390px;word-break:break-all}";
|
|
932
944
|
var styles$2 = {"file-form":"file-module_file-form__l13d5","delete-upload-file":"file-module_delete-upload-file__DirSm","file-form-inner-upload":"file-module_file-form-inner-upload__tq3Dn","upload-info":"file-module_upload-info__a8GFs","upload-info-txt":"file-module_upload-info-txt__l11uN","default":"file-module_default__t7KU0","error":"file-module_error__H-M4Z","accept":"file-module_accept__WTW6V","delete-upload-icon":"file-module_delete-upload-icon__PWN66","upload-file-content":"file-module_upload-file-content__QHMjn","file-form-title":"file-module_file-form-title__zWTSB"};
|
|
933
945
|
styleInject(css_248z$2);
|
|
934
946
|
|
|
@@ -1043,7 +1055,7 @@ File.propTypes = {
|
|
|
1043
1055
|
defaultData: PropTypes__default["default"].object
|
|
1044
1056
|
};
|
|
1045
1057
|
|
|
1046
|
-
var css_248z$1 = ".modal-module_modal-wrap__IsXXf{background:rgba(0,0,0,.4);height:100%;left:0;position:fixed;top:0;width:100%;z-index:9}.modal-module_modal-top__ntDBi{box-shadow:0 1px 0 0 rgba(0,0,0,.08);box-sizing:border-box;display:flex;flex-direction:row;height:30px;padding-left:24px;width:100%}.modal-module_modal-title__r-WKl{align-items:center;color:#3c393e;display:flex;flex:1 1;font-size:20px;font-weight:500;justify-content:center;line-height:24px}.modal-module_close-btn__Qf2UD{cursor:pointer;flex:0 0 auto;width:24px}.modal-module_close-btn__Qf2UD,.modal-module_modal-section__Bp8jN{align-items:center;display:flex;height:100%;justify-content:center}.modal-module_modal-section__Bp8jN{flex:1 1;width:100%}.modal-module_modal-content__1F-uE{align-items:center;animation:modal-module_show-popup__WrH7a .24s;background:#fff;border-radius:8px;display:flex;flex-direction:column;height:auto;left:0;margin:auto;min-height:130px;padding:
|
|
1058
|
+
var css_248z$1 = ".modal-module_modal-wrap__IsXXf{background:rgba(0,0,0,.4);height:100%;left:0;position:fixed;top:0;width:100%;z-index:9}.modal-module_modal-top__ntDBi{box-shadow:0 1px 0 0 rgba(0,0,0,.08);box-sizing:border-box;display:flex;flex-direction:row;height:30px;padding-left:24px;width:100%}.modal-module_modal-title__r-WKl{align-items:center;color:#3c393e;display:flex;flex:1 1;font-size:20px;font-weight:500;justify-content:center;line-height:24px}.modal-module_close-btn__Qf2UD{cursor:pointer;flex:0 0 auto;width:24px}.modal-module_close-btn__Qf2UD,.modal-module_modal-section__Bp8jN{align-items:center;display:flex;height:100%;justify-content:center}.modal-module_modal-section__Bp8jN{flex:1 1;padding:10px 0;width:100%}.modal-module_modal-content__1F-uE{align-items:center;animation:modal-module_show-popup__WrH7a .24s;background:#fff;border-radius:8px;display:flex;flex-direction:column;height:auto;left:0;margin:auto;min-height:130px;padding:10px;position:absolute;right:0;top:110px;width:fit-content}@keyframes modal-module_show-popup__WrH7a{0%{transform:translate3d(0,-30%,0)}to{opacity:1;transform:translateZ(0)}}";
|
|
1047
1059
|
var styles$1 = {"modal-wrap":"modal-module_modal-wrap__IsXXf","modal-top":"modal-module_modal-top__ntDBi","modal-title":"modal-module_modal-title__r-WKl","close-btn":"modal-module_close-btn__Qf2UD","modal-section":"modal-module_modal-section__Bp8jN","modal-content":"modal-module_modal-content__1F-uE","show-popup":"modal-module_show-popup__WrH7a"};
|
|
1048
1060
|
styleInject(css_248z$1);
|
|
1049
1061
|
|
|
@@ -1067,7 +1079,8 @@ const Modal = ({
|
|
|
1067
1079
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1068
1080
|
className: styles$1["modal-title"]
|
|
1069
1081
|
}, /*#__PURE__*/React__default["default"].createElement(Typography, {
|
|
1070
|
-
variant: TypographyType.
|
|
1082
|
+
variant: TypographyType.p,
|
|
1083
|
+
color: "#00236A"
|
|
1071
1084
|
}, headerText)), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1072
1085
|
className: styles$1["close-btn"],
|
|
1073
1086
|
onClick: () => setShow(false)
|
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@ export const Modal = ({
|
|
|
22
22
|
<div className={styles["modal-content"]}>
|
|
23
23
|
<div className={styles["modal-top"]}>
|
|
24
24
|
<div className={styles["modal-title"]}>
|
|
25
|
-
<Typography variant={TypographyType.
|
|
25
|
+
<Typography variant={TypographyType.p} color="#00236A">{headerText}</Typography>
|
|
26
26
|
</div>
|
|
27
27
|
<div
|
|
28
28
|
className={styles["close-btn"]}
|
|
@@ -42,11 +42,12 @@
|
|
|
42
42
|
display: flex;
|
|
43
43
|
align-items: center;
|
|
44
44
|
justify-content: center;
|
|
45
|
+
padding: 10px 0;
|
|
45
46
|
}
|
|
46
47
|
.modal-content {
|
|
47
48
|
position: absolute;
|
|
48
49
|
width: fit-content;
|
|
49
|
-
padding:
|
|
50
|
+
padding: 10px;
|
|
50
51
|
min-height: 130px;
|
|
51
52
|
top: 110px;
|
|
52
53
|
left: 0;
|
|
@@ -37,7 +37,10 @@ const Template = ({ headerText, className }) => {
|
|
|
37
37
|
<>
|
|
38
38
|
<button onClick={handleClick}>Click</button>
|
|
39
39
|
{show && (
|
|
40
|
-
<Modal type='images' selected={4} data={data} setShow={setShow} headerText={headerText} className={className} />
|
|
40
|
+
// <Modal type='images' selected={4} data={data} setShow={setShow} headerText={headerText} className={className} />
|
|
41
|
+
<Modal type='content' headerText="test">
|
|
42
|
+
<div>TEst</div>
|
|
43
|
+
</Modal>
|
|
41
44
|
)}
|
|
42
45
|
</>
|
|
43
46
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {useEffect, useState} from 'react';
|
|
1
|
+
import React, {useEffect, useState, useRef} from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import styles from './select.module.css';
|
|
@@ -35,10 +35,10 @@ export const Select = ({
|
|
|
35
35
|
keyNames,
|
|
36
36
|
selected
|
|
37
37
|
}) => {
|
|
38
|
-
const options = jsonData.length ? JSON.parse(jsonData) : [];
|
|
39
38
|
|
|
39
|
+
const options = jsonData.length ? JSON.parse(jsonData) : [];
|
|
40
|
+
const ref = useRef();
|
|
40
41
|
|
|
41
|
-
|
|
42
42
|
let [opened, setOpened] = useState(false)
|
|
43
43
|
let [newSelected, setNewSelected] = useState({})
|
|
44
44
|
|
|
@@ -48,6 +48,20 @@ export const Select = ({
|
|
|
48
48
|
setNewSelected(parseSelectedData);
|
|
49
49
|
},[selected])
|
|
50
50
|
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if(opened){
|
|
53
|
+
const checkIfClickedOutside = e => {
|
|
54
|
+
if (opened && ref.current && !ref.current.contains(e.target)) {
|
|
55
|
+
setOpened(false)
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
document.addEventListener("mousedown", checkIfClickedOutside)
|
|
59
|
+
return () => {
|
|
60
|
+
document.removeEventListener("mousedown", checkIfClickedOutside)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}, [opened]);
|
|
64
|
+
|
|
51
65
|
const classProps = classnames(
|
|
52
66
|
styles[theme],
|
|
53
67
|
styles[size],
|
|
@@ -61,7 +75,7 @@ export const Select = ({
|
|
|
61
75
|
return (
|
|
62
76
|
<div>
|
|
63
77
|
{label ? <label className={styles['select-title']}>{label}</label> : ""}
|
|
64
|
-
<div className={styles['select-wrap']}>
|
|
78
|
+
<div className={styles['select-wrap']} ref={ref}>
|
|
65
79
|
<div className={styles['select-content']} id={styles.selector}>
|
|
66
80
|
<div
|
|
67
81
|
className={styles['select-content-top']}
|
|
@@ -71,51 +85,55 @@ export const Select = ({
|
|
|
71
85
|
>
|
|
72
86
|
<div className={styles['select-content-top-text']}>{newSelected && newSelected[keyNames.name] ? newSelected[keyNames.name] : defaultOption}</div>
|
|
73
87
|
<div className={styles['select-content-top-icon']}>
|
|
74
|
-
<
|
|
88
|
+
<span onClick={
|
|
89
|
+
(e) => {
|
|
90
|
+
setNewSelected({})
|
|
91
|
+
onChange({});
|
|
92
|
+
e.stopPropagation()
|
|
93
|
+
}
|
|
94
|
+
}>X</span>
|
|
95
|
+
<i className={opened ? 'icon-arrow-up' : 'icon-arrow-down'}/>
|
|
75
96
|
</div>
|
|
76
97
|
</div>
|
|
77
98
|
{
|
|
78
99
|
opened && !disabled ?
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<div
|
|
83
|
-
className={styles['select-content-bottom-row']}
|
|
84
|
-
onClick={() => {
|
|
85
|
-
if (!required && !selected) {
|
|
86
|
-
setNewSelected(defaultOption)
|
|
87
|
-
onChange(defaultOption)
|
|
88
|
-
setOpened(!opened)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
>
|
|
93
|
-
{defaultOption}
|
|
94
|
-
</div>
|
|
95
|
-
{
|
|
96
|
-
options.map((option, i) => {
|
|
97
|
-
return <div
|
|
98
|
-
key={i}
|
|
100
|
+
<div className={styles['select-content-bottom']}>
|
|
101
|
+
<div className={styles['select-content-bottom-inner']}>
|
|
102
|
+
{/* <div
|
|
99
103
|
className={styles['select-content-bottom-row']}
|
|
100
|
-
disabled={true}
|
|
101
104
|
onClick={() => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
if (!required && !selected) {
|
|
106
|
+
setNewSelected(defaultOption)
|
|
107
|
+
onChange(defaultOption)
|
|
108
|
+
setOpened(!opened)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
105
111
|
}
|
|
112
|
+
>
|
|
113
|
+
{defaultOption}
|
|
114
|
+
</div> */}
|
|
115
|
+
{
|
|
116
|
+
options.map((option, i) => {
|
|
117
|
+
return <div
|
|
118
|
+
key={i}
|
|
119
|
+
className={styles['select-content-bottom-row']}
|
|
120
|
+
disabled={true}
|
|
121
|
+
onClick={() => {
|
|
122
|
+
setNewSelected(option);
|
|
123
|
+
onChange(option);
|
|
124
|
+
setOpened(!opened);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
defaultValue={option[keyNames.id]}
|
|
128
|
+
>
|
|
129
|
+
{option[keyNames.name]}
|
|
130
|
+
</div>
|
|
131
|
+
})
|
|
106
132
|
}
|
|
107
|
-
|
|
108
|
-
>
|
|
109
|
-
{option[keyNames.name]}
|
|
110
|
-
</div>
|
|
111
|
-
})
|
|
112
|
-
}
|
|
133
|
+
</div>
|
|
113
134
|
</div>
|
|
114
|
-
|
|
115
|
-
</div>
|
|
116
135
|
: null
|
|
117
136
|
}
|
|
118
|
-
|
|
119
137
|
</div>
|
|
120
138
|
</div>
|
|
121
139
|
{eMessage ? <span className={styles.eMessage}>{eMessage}</span> : null}
|
|
@@ -14,7 +14,7 @@ Default.args = {
|
|
|
14
14
|
jsonData: '[{"bbb":"0", "value":"Արաբկիր"}, {"bbb":"1", "value":"Կենտրոն"}, {"bbb":"2", "value":"Մալաթիա"}]',
|
|
15
15
|
onChange: (newValue)=> {
|
|
16
16
|
},
|
|
17
|
-
defaultOption: '
|
|
17
|
+
defaultOption: '',
|
|
18
18
|
selected: '{"bbb":"2", "value":"Մալաթիա"}',
|
|
19
19
|
keyNames: {name: 'value', id : 'bbb'}
|
|
20
20
|
};
|
|
@@ -32,5 +32,5 @@ Default.args = {
|
|
|
32
32
|
jsonData: JSON.stringify([{id:1,name:'Item 1',name2:'Item 1'},{id:2, name:'Item 2',name2:'Item 2'}]),
|
|
33
33
|
actions: [{icon: 'icon-1',show: show, click: action},{icon: 'icon-2'},{icon: 'icon-3'},{icon: 'icon-4'}],
|
|
34
34
|
keyNames: ['name',{name: 'name2', icon: 'icon-temp'}],
|
|
35
|
-
hearderData: ['first Name', 'Last Name']
|
|
35
|
+
hearderData: ['first Name', 'Last Name','asdas',]
|
|
36
36
|
};
|