josenanodev-react-components-library 0.0.15 → 0.0.17

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.
Files changed (33) hide show
  1. package/dist/cjs/components/ParallelSelectionList/ParallelSelectionList.css +229 -0
  2. package/dist/cjs/components/ParallelSelectionList/ParallelSelectionList.d.ts +5 -0
  3. package/dist/cjs/components/ParallelSelectionList/ParallelSelectionList.js +135 -0
  4. package/dist/cjs/components/ParallelSelectionList/types.d.ts +19 -0
  5. package/dist/cjs/components/PopUp/PopUp.css +1 -1
  6. package/dist/cjs/components/PopUp/PopUp.d.ts +2 -2
  7. package/dist/cjs/components/PopUp/PopUp.js +6 -6
  8. package/dist/cjs/components/PopUp/types.d.ts +3 -2
  9. package/dist/cjs/components/ProgressBar/ProgressBar.css +39 -0
  10. package/dist/cjs/components/ProgressBar/ProgressBar.d.ts +5 -0
  11. package/dist/cjs/components/ProgressBar/ProgressBar.js +56 -0
  12. package/dist/cjs/components/ProgressBar/types.d.ts +7 -0
  13. package/dist/cjs/hooks/useOutsideClick.d.ts +1 -1
  14. package/dist/cjs/hooks/useOutsideClick.js +5 -3
  15. package/dist/cjs/index.d.ts +3 -1
  16. package/dist/cjs/index.js +5 -1
  17. package/dist/esm/components/ParallelSelectionList/ParallelSelectionList.css +229 -0
  18. package/dist/esm/components/ParallelSelectionList/ParallelSelectionList.d.ts +5 -0
  19. package/dist/esm/components/ParallelSelectionList/ParallelSelectionList.js +130 -0
  20. package/dist/esm/components/ParallelSelectionList/types.d.ts +19 -0
  21. package/dist/esm/components/PopUp/PopUp.css +1 -1
  22. package/dist/esm/components/PopUp/PopUp.d.ts +2 -2
  23. package/dist/esm/components/PopUp/PopUp.js +6 -6
  24. package/dist/esm/components/PopUp/types.d.ts +3 -2
  25. package/dist/esm/components/ProgressBar/ProgressBar.css +39 -0
  26. package/dist/esm/components/ProgressBar/ProgressBar.d.ts +5 -0
  27. package/dist/esm/components/ProgressBar/ProgressBar.js +31 -0
  28. package/dist/esm/components/ProgressBar/types.d.ts +7 -0
  29. package/dist/esm/hooks/useOutsideClick.d.ts +1 -1
  30. package/dist/esm/hooks/useOutsideClick.js +5 -3
  31. package/dist/esm/index.d.ts +3 -1
  32. package/dist/esm/index.js +3 -1
  33. package/package.json +1 -1
@@ -0,0 +1,229 @@
1
+ .parallel-selection-list {
2
+ display: grid;
3
+ grid-template-areas:
4
+ "lef rig"
5
+ "but but";
6
+ height: 100%;
7
+ grid-template-rows: calc(100% - 80px) 80px;
8
+ grid-template-columns: 50% 50%;
9
+ }
10
+
11
+ .parallel-selection-list .div-left-list {
12
+ grid-area: lef;
13
+ display: flex;
14
+ flex-flow: column;
15
+ align-items: center;
16
+ box-sizing: border-box;
17
+ padding: 10px;
18
+ height: 100%;
19
+ }
20
+
21
+ .parallel-selection-list .div-right-list {
22
+ grid-area: rig;
23
+ display: flex;
24
+ flex-flow: column;
25
+ align-items: center;
26
+ box-sizing: border-box;
27
+ padding: 10px;
28
+ height: 100%;
29
+ }
30
+
31
+ .parallel-selection-list .div-action-buttons {
32
+ grid-area: but;
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: space-between;
36
+ box-sizing: border-box;
37
+ padding: 10px 20px;
38
+ }
39
+
40
+ .parallel-selection-list .list-title {
41
+ font-size: 20px;
42
+ font-weight: 600;
43
+ color: dimgray;
44
+ height: 30px;
45
+ display: flex;
46
+ align-items: center;
47
+ justify-content: center;
48
+ }
49
+
50
+ .parallel-selection-list .div-search-bar {
51
+ width: 100%;
52
+ border: 1px solid rgb(185, 185, 185);
53
+ border-top-left-radius: 6px;
54
+ border-top-right-radius: 6px;
55
+ padding: 6px;
56
+ height: 30px;
57
+ box-sizing: border-box;
58
+ color: dimgray;
59
+ display: flex;
60
+ align-items: center;
61
+ justify-content: center;
62
+ }
63
+
64
+ .parallel-selection-list .div-search-bar input {
65
+ border: none;
66
+ padding-left: 10px;
67
+ width: 100%;
68
+ }
69
+
70
+ .parallel-selection-list .div-search-bar input:focus {
71
+ outline: none;
72
+ }
73
+
74
+ .parallel-selection-list .list-container {
75
+ width: 100%;
76
+ display: flex;
77
+ flex-flow: column;
78
+ box-sizing: border-box;
79
+ border: 1px solid rgb(169, 169, 169);
80
+ border-bottom-left-radius: 6px;
81
+ border-bottom-right-radius: 6px;
82
+ border-top: none;
83
+ height: calc(100% - 60px);
84
+ }
85
+
86
+ .parallel-selection-list .list-container .apply-all-button {
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: center;
90
+ width: 100%;
91
+ height: 30px;
92
+ border: none;
93
+ background-color: transparent;
94
+ color: dimgray;
95
+ font-weight: 700;
96
+ border-bottom: 1px solid rgb(169, 169, 169);
97
+ box-sizing: border-box;
98
+ padding: 5px 0;
99
+ transition: all 0.3s;
100
+ cursor: pointer;
101
+ }
102
+
103
+ .parallel-selection-list .list-container .apply-all-button svg {
104
+ width: 20px;
105
+ height: 20px;
106
+ }
107
+
108
+ .parallel-selection-list .list-container .apply-all-button:hover {
109
+ background-color: rgb(238, 238, 238);
110
+ }
111
+
112
+ .parallel-selection-list .list-container .scrollable-section {
113
+ overflow-y: auto;
114
+ height: calc(100% - 30px);
115
+ }
116
+
117
+ .parallel-selection-list .list-container .scrollable-section .resizable-div-for-scroll {
118
+ width: 100%;
119
+ box-sizing: border-box;
120
+ }
121
+
122
+ .parallel-selection-list
123
+ .list-container
124
+ .scrollable-section
125
+ .resizable-div-for-scroll
126
+ .div-datum-wrapper {
127
+ width: 100%;
128
+ display: flex;
129
+ justify-content: space-between;
130
+ align-items: center;
131
+ border-bottom: 1px solid rgb(169, 169, 169);
132
+ }
133
+
134
+ .parallel-selection-list
135
+ .list-container
136
+ .scrollable-section
137
+ .resizable-div-for-scroll
138
+ .div-datum-wrapper
139
+ .div-custom-component-wrapper {
140
+ position: relative;
141
+ height: 100%;
142
+ width: calc(100% - 50px);
143
+ display: flex;
144
+ align-items: center;
145
+ justify-content: center;
146
+ overflow: hidden;
147
+ }
148
+
149
+ .parallel-selection-list
150
+ .list-container
151
+ .scrollable-section
152
+ .resizable-div-for-scroll
153
+ .div-datum-wrapper
154
+ .visible-default-name {
155
+ box-sizing: border-box;
156
+ padding: 17px 10px;
157
+ font-size: 16px;
158
+ font-weight: 600;
159
+ color: dimgray;
160
+ height: 50px;
161
+ white-space: nowrap;
162
+ text-overflow: ellipsis;
163
+ overflow: hidden;
164
+ width: calc(100% - 50px);
165
+ text-align: start;
166
+ }
167
+
168
+ .parallel-selection-list
169
+ .list-container
170
+ .scrollable-section
171
+ .resizable-div-for-scroll
172
+ .div-datum-wrapper
173
+ .apply-to-one-button {
174
+ height: 30px;
175
+ width: 30px;
176
+ display: flex;
177
+ align-items: center;
178
+ justify-content: center;
179
+ margin: 10px;
180
+ background-color: transparent;
181
+ border: none;
182
+ border-radius: 15px;
183
+ transition: all 0.3s;
184
+ cursor: pointer;
185
+ }
186
+
187
+ .parallel-selection-list
188
+ .list-container
189
+ .scrollable-section
190
+ .resizable-div-for-scroll
191
+ .div-datum-wrapper
192
+ .apply-to-one-button:hover {
193
+ background-color: rgb(238, 238, 238);
194
+ }
195
+
196
+ .parallel-selection-list .div-action-buttons button {
197
+ box-sizing: border-box;
198
+ padding: 10px 15px;
199
+ display: flex;
200
+ align-items: center;
201
+ justify-content: center;
202
+ background-color: transparent;
203
+ border: solid 2px;
204
+ border-radius: 6px;
205
+ font-size: 16px;
206
+ font-weight: 600;
207
+ transition: all 0.3s;
208
+ cursor: pointer;
209
+ }
210
+
211
+ .parallel-selection-list .div-action-buttons .cancel-button {
212
+ border-color: dimgray;
213
+ color: dimgray;
214
+ }
215
+
216
+ .parallel-selection-list .div-action-buttons .cancel-button:hover {
217
+ background-color: dimgray;
218
+ color: white;
219
+ }
220
+
221
+ .parallel-selection-list .div-action-buttons .apply-button {
222
+ border-color: var(--primary-color);
223
+ color: var(--primary-color);
224
+ }
225
+
226
+ .parallel-selection-list .div-action-buttons .apply-button:hover {
227
+ background-color: var(--primary-color);
228
+ color: white;
229
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./ParallelSelectionList.css";
3
+ import { ParallelSelectionListPropsTypes } from "./types";
4
+ declare const ParallelSelectionList: ({ dataList, applyAction, cancelAction, leftListTitle, rightListTitle, searchBarsVisible, applyButonText, cancelButtonText, preSelectedDatumsIds, listElementsHeight, }: ParallelSelectionListPropsTypes) => JSX.Element;
5
+ export default ParallelSelectionList;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const react_2 = require("react");
8
+ require("./ParallelSelectionList.css");
9
+ //Icons
10
+ const bs_1 = require("react-icons/bs");
11
+ //Hooks
12
+ const useResizeObserver_1 = __importDefault(require("../../hooks/useResizeObserver"));
13
+ const ParallelSelectionList = ({ dataList, applyAction, cancelAction, leftListTitle, rightListTitle, searchBarsVisible, applyButonText, cancelButtonText, preSelectedDatumsIds = [], listElementsHeight = 50, }) => {
14
+ //Refs
15
+ const leftListRef = (0, react_2.useRef)(null);
16
+ const rightListRef = (0, react_2.useRef)(null);
17
+ //useState
18
+ const [selectedDatumsIds, setSelectedDatumsIds] = (0, react_2.useState)(preSelectedDatumsIds);
19
+ const [filteredLeftList, setFilteredLeftList] = (0, react_2.useState)([]);
20
+ const [filteredRightList, setFilteredRightList] = (0, react_2.useState)([]);
21
+ const [leftListFirstVisibleElementIndex, setLeftListFirstVisibleElementIndex] = (0, react_2.useState)(0);
22
+ const [leftListLastVisibleElementIndex, setLeftListLastVisibleElementIndex] = (0, react_2.useState)(0);
23
+ const [rightListFirstVisibleElementIndex, setRightListFirstVisibleElementIndex] = (0, react_2.useState)(0);
24
+ const [rightListLastVisibleElementIndex, setRightListLastVisibleElementIndex] = (0, react_2.useState)(0);
25
+ const [leftListSearchValue, setLeftListSearchValue] = (0, react_2.useState)("");
26
+ const [rightListSearchValue, setRightListSearchValue] = (0, react_2.useState)("");
27
+ //hooks
28
+ const [leftListWidth, leftListHeight] = (0, useResizeObserver_1.default)(leftListRef);
29
+ const [rightListWidth, rightListHeight] = (0, useResizeObserver_1.default)(rightListRef);
30
+ //Functions
31
+ const addToSelectedDatumsIds = (datumIdsArray) => {
32
+ const selectedDatumsIdsClone = [...selectedDatumsIds];
33
+ datumIdsArray.forEach((datumId) => {
34
+ if (!selectedDatumsIds.includes(datumId)) {
35
+ selectedDatumsIdsClone.push(datumId);
36
+ }
37
+ });
38
+ setSelectedDatumsIds(selectedDatumsIdsClone);
39
+ };
40
+ const removeFromSelectedDatumsIds = (datumIdsArray) => {
41
+ const selectedDatumsIdsClone = [...selectedDatumsIds];
42
+ datumIdsArray.forEach((datumId) => {
43
+ if (selectedDatumsIds.includes(datumId)) {
44
+ selectedDatumsIdsClone.splice(selectedDatumsIdsClone.indexOf(datumId), 1);
45
+ }
46
+ });
47
+ setSelectedDatumsIds(selectedDatumsIdsClone);
48
+ };
49
+ //useEffects
50
+ (0, react_2.useEffect)(() => {
51
+ let dataListClone = [...dataList];
52
+ dataListClone = dataListClone.filter((datum) => !selectedDatumsIds.includes(datum._id));
53
+ dataListClone = dataListClone.filter((datum) => datum.searchValue.toLowerCase().includes(leftListSearchValue.toLowerCase()));
54
+ setFilteredLeftList(dataListClone);
55
+ }, [leftListSearchValue, dataList, selectedDatumsIds]);
56
+ (0, react_2.useEffect)(() => {
57
+ let dataListClone = [...dataList];
58
+ dataListClone = dataListClone.filter((datum) => selectedDatumsIds.includes(datum._id));
59
+ dataListClone = dataListClone.filter((datum) => datum.searchValue.toLowerCase().includes(rightListSearchValue.toLowerCase()));
60
+ setFilteredRightList(dataListClone);
61
+ }, [rightListSearchValue, dataList, selectedDatumsIds]);
62
+ (0, react_2.useEffect)(() => {
63
+ if (leftListRef.current && leftListRef.current.clientHeight !== 0) {
64
+ setLeftListLastVisibleElementIndex(leftListFirstVisibleElementIndex +
65
+ Math.floor(leftListRef.current.clientHeight / listElementsHeight) +
66
+ 2);
67
+ }
68
+ else {
69
+ setLeftListLastVisibleElementIndex(filteredLeftList.length);
70
+ }
71
+ }, [
72
+ leftListHeight,
73
+ leftListWidth,
74
+ leftListFirstVisibleElementIndex,
75
+ listElementsHeight,
76
+ filteredLeftList.length
77
+ ]);
78
+ (0, react_2.useEffect)(() => {
79
+ if (rightListRef.current && rightListRef.current.clientHeight !== 0) {
80
+ setRightListLastVisibleElementIndex(rightListFirstVisibleElementIndex +
81
+ Math.floor(rightListRef.current.clientHeight / listElementsHeight) +
82
+ 2);
83
+ }
84
+ else {
85
+ setRightListLastVisibleElementIndex(filteredRightList.length);
86
+ }
87
+ }, [
88
+ rightListHeight,
89
+ rightListWidth,
90
+ rightListFirstVisibleElementIndex,
91
+ listElementsHeight,
92
+ filteredRightList.length
93
+ ]);
94
+ return (react_1.default.createElement("div", { className: "parallel-selection-list" },
95
+ react_1.default.createElement("div", { className: "div-left-list" },
96
+ react_1.default.createElement("p", { className: "list-title" }, leftListTitle),
97
+ searchBarsVisible && (react_1.default.createElement("div", { className: "div-search-bar" },
98
+ react_1.default.createElement(bs_1.BsSearch, null),
99
+ react_1.default.createElement("input", { type: "text", value: leftListSearchValue, onChange: (event) => setLeftListSearchValue(event.target.value) }))),
100
+ react_1.default.createElement("div", { className: "list-container" },
101
+ react_1.default.createElement("button", { className: "apply-all-button", onClick: () => addToSelectedDatumsIds(filteredLeftList.map((datum) => datum._id)) },
102
+ react_1.default.createElement(bs_1.BsChevronDoubleRight, null)),
103
+ react_1.default.createElement("div", { ref: leftListRef, className: "scrollable-section", onScroll: (event) => setLeftListFirstVisibleElementIndex(Math.floor(event.target.scrollTop / listElementsHeight)) },
104
+ react_1.default.createElement("div", { className: "resizable-div-for-scroll", style: {
105
+ paddingTop: leftListFirstVisibleElementIndex * listElementsHeight,
106
+ height: filteredLeftList.length * listElementsHeight,
107
+ } }, filteredLeftList
108
+ .slice(leftListFirstVisibleElementIndex, leftListLastVisibleElementIndex)
109
+ .map((datum) => (react_1.default.createElement("div", { key: datum._id, className: "div-datum-wrapper", style: { height: listElementsHeight } },
110
+ datum.customComponent ? (react_1.default.createElement("div", { className: "div-custom-component-wrapper" }, datum.customComponent)) : (react_1.default.createElement("p", { className: "visible-default-name", title: datum.visibleDefaultName }, datum.visibleDefaultName)),
111
+ react_1.default.createElement("button", { className: "apply-to-one-button", onClick: () => addToSelectedDatumsIds([datum._id]) },
112
+ react_1.default.createElement(bs_1.BsChevronRight, null))))))))),
113
+ react_1.default.createElement("div", { className: "div-right-list" },
114
+ react_1.default.createElement("p", { className: "list-title" }, rightListTitle),
115
+ searchBarsVisible && (react_1.default.createElement("div", { className: "div-search-bar" },
116
+ react_1.default.createElement(bs_1.BsSearch, null),
117
+ react_1.default.createElement("input", { type: "text", value: rightListSearchValue, onChange: (event) => setRightListSearchValue(event.target.value) }))),
118
+ react_1.default.createElement("div", { className: "list-container" },
119
+ react_1.default.createElement("button", { className: "apply-all-button", onClick: () => removeFromSelectedDatumsIds(filteredRightList.map((datum) => datum._id)) },
120
+ react_1.default.createElement(bs_1.BsChevronDoubleLeft, null)),
121
+ react_1.default.createElement("div", { ref: rightListRef, className: "scrollable-section", onScroll: (event) => setRightListFirstVisibleElementIndex(Math.floor(event.target.scrollTop / listElementsHeight)) },
122
+ react_1.default.createElement("div", { className: "resizable-div-for-scroll", style: {
123
+ paddingTop: rightListFirstVisibleElementIndex * listElementsHeight,
124
+ height: filteredRightList.length * listElementsHeight,
125
+ } }, filteredRightList
126
+ .slice(rightListFirstVisibleElementIndex, rightListLastVisibleElementIndex)
127
+ .map((datum) => (react_1.default.createElement("div", { key: datum._id, className: "div-datum-wrapper", style: { height: listElementsHeight } },
128
+ react_1.default.createElement("button", { className: "apply-to-one-button", onClick: () => removeFromSelectedDatumsIds([datum._id]) },
129
+ react_1.default.createElement(bs_1.BsChevronLeft, null)),
130
+ datum.customComponent ? (react_1.default.createElement("div", { className: "div-custom-component-wrapper" }, datum.customComponent)) : (react_1.default.createElement("p", { className: "visible-default-name", title: datum.visibleDefaultName }, datum.visibleDefaultName))))))))),
131
+ react_1.default.createElement("div", { className: "div-action-buttons" },
132
+ react_1.default.createElement("button", { className: "cancel-button", onClick: () => cancelAction() }, cancelButtonText ? cancelButtonText : "Cancel"),
133
+ react_1.default.createElement("button", { className: "apply-button", onClick: () => applyAction(selectedDatumsIds) }, applyButonText ? applyButonText : "Apply"))));
134
+ };
135
+ exports.default = ParallelSelectionList;
@@ -0,0 +1,19 @@
1
+ export interface ParallelSelectionListPropsTypes {
2
+ dataList: ListDatumType[];
3
+ applyAction: (dataListId: ListDatumType["_id"][]) => Fuction;
4
+ cancelAction: Function;
5
+ leftListTitle?: string;
6
+ rightListTitle?: string;
7
+ searchBarsVisible?: boolean;
8
+ applyButonText?: string;
9
+ cancelButtonText?: string;
10
+ preSelectedDatumsIds?: ListDatumType["_id"][];
11
+ listElementsHeight?: number;
12
+ }
13
+
14
+ export type ListDatumType = {
15
+ _id: string;
16
+ searchValue: string;
17
+ visibleDefaultName: string;
18
+ customComponent?: JSX.Element;
19
+ };
@@ -5,7 +5,7 @@
5
5
  border-width: 0px 1px 1px;
6
6
  box-shadow: rgb(0 0 0 / 15%) 0px 14px 36px 2px;
7
7
  padding: 0px;
8
- position: relative;
8
+ position: absolute;
9
9
  overflow: auto;
10
10
  box-sizing: border-box;
11
11
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import "./PopUp.css";
3
- import { PopUpProps } from "./types";
4
- declare const PopUp: ({ open, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle, aditionalClass, }: PopUpProps) => JSX.Element;
3
+ import { PopUpPropsType } from "./types";
4
+ declare const PopUp: ({ open, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle, aditionalClass, activationButtonRef, }: PopUpPropsType) => JSX.Element;
5
5
  export default PopUp;
@@ -27,9 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const react_1 = __importStar(require("react"));
30
- const useOutsideClick_1 = __importDefault(require("../../hooks/useOutsideClick"));
31
30
  require("./PopUp.css");
32
- const PopUp = ({ open = false, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle = {}, aditionalClass, }) => {
31
+ //hooks
32
+ const useOutsideClick_1 = __importDefault(require("../../hooks/useOutsideClick"));
33
+ const PopUp = ({ open = false, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle = {}, aditionalClass, activationButtonRef, }) => {
33
34
  //Refs
34
35
  const popUpRef = (0, react_1.useRef)(null);
35
36
  //Hooks
@@ -39,12 +40,11 @@ const PopUp = ({ open = false, children, closeAction, outBoundClickClosesPopUp,
39
40
  if (closeAction)
40
41
  closeAction();
41
42
  }
42
- });
43
- //Estados
44
- const [openState, setOpenState] = (0, react_1.useState)(open);
43
+ }, activationButtonRef ? [activationButtonRef] : []);
45
44
  //useState
45
+ const [openState, setOpenState] = (0, react_1.useState)(open);
46
46
  return (react_1.default.createElement("div", { ref: popUpRef, className: "pop-up" +
47
47
  ((closeAction && open) || (!closeAction && openState) ? "" : " pop-up-hidden") +
48
- (aditionalClass ? " " + aditionalClass : ""), style: aditionalInlineStyle }, children));
48
+ (aditionalClass ? " " + aditionalClass : ""), style: open ? aditionalInlineStyle : {} }, children));
49
49
  };
50
50
  exports.default = PopUp;
@@ -1,8 +1,9 @@
1
- export interface PopUpProps {
1
+ export interface PopUpPropsType {
2
2
  children: JSX.Element | JSX.Element[];
3
3
  open: boolean;
4
4
  closeAction?: Function;
5
5
  outBoundClickClosesPopUp?: boolean;
6
6
  aditionalInlineStyle?: React.CSSProperties;
7
- aditionalClass: string;
7
+ aditionalClass?: string;
8
+ activationButtonRef?: React.MutableRefObject<HTMLElement | null>;
8
9
  }
@@ -0,0 +1,39 @@
1
+ .progress-bar {
2
+ height: 40px;
3
+ width: 100%;
4
+ position: relative;
5
+ opacity: 0.9;
6
+ backdrop-filter: blur(10px);
7
+ }
8
+
9
+ .progress-bar .fillable-body {
10
+ position: relative;
11
+ height: 100%;
12
+ width: 100%;
13
+ background-color: dimgray;
14
+ border-radius: 100px;
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: flex-start;
18
+ overflow: hidden;
19
+ }
20
+
21
+ .progress-bar .fillable-body .filler {
22
+ height: 100%;
23
+ box-sizing: border-box;
24
+ transition: all 0.2s;
25
+ border-radius: 100px;
26
+ }
27
+
28
+ .progress-bar .fillable-body p {
29
+ position: absolute;
30
+ width: 100%;
31
+ height: 100%;
32
+ text-align: center;
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ font-size: 16px;
37
+ font-weight: 600;
38
+ color: white;
39
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./ProgressBar.css";
3
+ import { ProgressBarPropsType } from "./types";
4
+ declare const ProgressBar: ({ totalSize, currentValue, color, }: ProgressBarPropsType) => JSX.Element;
5
+ export default ProgressBar;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const react_1 = __importStar(require("react"));
27
+ require("./ProgressBar.css");
28
+ const ProgressBar = ({ totalSize, currentValue, color = "var(--secondary-color)", }) => {
29
+ var _a;
30
+ //useRef
31
+ const fillableBodyRef = (0, react_1.useRef)(null);
32
+ //useStates
33
+ const [currentPercentage, setCurrentPercentage] = (0, react_1.useState)(totalSize !== 0 ? currentValue / totalSize : 0);
34
+ const [barWidth, setBarWidth] = (0, react_1.useState)(0);
35
+ //useEffects
36
+ (0, react_1.useEffect)(() => {
37
+ if (totalSize !== 0) {
38
+ setCurrentPercentage(currentValue / totalSize);
39
+ }
40
+ else {
41
+ setCurrentPercentage(0);
42
+ }
43
+ }, [totalSize, currentValue]);
44
+ (0, react_1.useEffect)(() => {
45
+ if (fillableBodyRef.current !== null) {
46
+ setBarWidth(fillableBodyRef.current.clientWidth);
47
+ }
48
+ }, [(_a = fillableBodyRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight]);
49
+ return (react_1.default.createElement("div", { className: "progress-bar" },
50
+ react_1.default.createElement("div", { ref: fillableBodyRef, className: "fillable-body" },
51
+ react_1.default.createElement("div", { className: "filler", style: { width: barWidth * currentPercentage, backgroundColor: color } }),
52
+ react_1.default.createElement("p", null,
53
+ (currentPercentage * 100).toFixed(0),
54
+ "%"))));
55
+ };
56
+ exports.default = ProgressBar;
@@ -0,0 +1,7 @@
1
+ import { languageType } from "../../../assets/languages/types";
2
+
3
+ export interface ProgressBarPropsType {
4
+ totalSize: number;
5
+ currentValue: number;
6
+ color?: string,
7
+ }
@@ -2,5 +2,5 @@
2
2
  /**
3
3
  * Hook that alerts clicks outside of the passed ref
4
4
  */
5
- declare function useOutsideClick(elementRef: React.MutableRefObject<HTMLElement | null>, onOutsideClickAction: Function): void;
5
+ declare function useOutsideClick(elementRef: React.MutableRefObject<HTMLElement | null>, onOutsideClickAction: Function, elementsRefsExceptions?: React.MutableRefObject<HTMLElement | null>[]): void;
6
6
  export default useOutsideClick;
@@ -4,13 +4,15 @@ const react_1 = require("react");
4
4
  /**
5
5
  * Hook that alerts clicks outside of the passed ref
6
6
  */
7
- function useOutsideClick(elementRef, onOutsideClickAction) {
7
+ function useOutsideClick(elementRef, onOutsideClickAction, elementsRefsExceptions = []) {
8
8
  (0, react_1.useEffect)(() => {
9
9
  /**
10
10
  * Alert if clicked on outside of element
11
11
  */
12
12
  function handleClickOutside(event) {
13
- if (elementRef.current && !elementRef.current.contains(event.target)) {
13
+ if (elementRef.current &&
14
+ !elementRef.current.contains(event.target) &&
15
+ elementsRefsExceptions.every((elementRefException) => elementRefException.current !== event.target)) {
14
16
  onOutsideClickAction();
15
17
  }
16
18
  }
@@ -20,6 +22,6 @@ function useOutsideClick(elementRef, onOutsideClickAction) {
20
22
  // Unbind the event listener on clean up
21
23
  document.removeEventListener("mousedown", handleClickOutside);
22
24
  };
23
- }, [elementRef, onOutsideClickAction]);
25
+ }, [elementRef, onOutsideClickAction, elementsRefsExceptions]);
24
26
  }
25
27
  exports.default = useOutsideClick;
@@ -3,5 +3,7 @@ import SideBar from "./components/SideBar/SideBar";
3
3
  import SearchBar from "./components/SearchBar/SearchBar";
4
4
  import Modal from "./components/Modal/Modal";
5
5
  import PopUp from "./components/PopUp/PopUp";
6
+ import ProgressBar from "./components/ProgressBar/ProgressBar";
7
+ import ParallelSelectionList from "./components/ParallelSelectionList/ParallelSelectionList";
6
8
  import { setMulticalendarYScrollPosition } from "./Services/MulticalendarStatesAndSettings";
7
- export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, };
9
+ export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, ProgressBar, ParallelSelectionList };
package/dist/cjs/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PopUp = exports.Modal = exports.SearchBar = exports.SideBar = exports.setMulticalendarYScrollPosition = exports.Multicalendar = void 0;
6
+ exports.ParallelSelectionList = exports.ProgressBar = exports.PopUp = exports.Modal = exports.SearchBar = exports.SideBar = exports.setMulticalendarYScrollPosition = exports.Multicalendar = void 0;
7
7
  const Multicalendar_1 = __importDefault(require("./components/Multicalendar/Multicalendar"));
8
8
  exports.Multicalendar = Multicalendar_1.default;
9
9
  const SideBar_1 = __importDefault(require("./components/SideBar/SideBar"));
@@ -14,5 +14,9 @@ const Modal_1 = __importDefault(require("./components/Modal/Modal"));
14
14
  exports.Modal = Modal_1.default;
15
15
  const PopUp_1 = __importDefault(require("./components/PopUp/PopUp"));
16
16
  exports.PopUp = PopUp_1.default;
17
+ const ProgressBar_1 = __importDefault(require("./components/ProgressBar/ProgressBar"));
18
+ exports.ProgressBar = ProgressBar_1.default;
19
+ const ParallelSelectionList_1 = __importDefault(require("./components/ParallelSelectionList/ParallelSelectionList"));
20
+ exports.ParallelSelectionList = ParallelSelectionList_1.default;
17
21
  const MulticalendarStatesAndSettings_1 = require("./Services/MulticalendarStatesAndSettings");
18
22
  Object.defineProperty(exports, "setMulticalendarYScrollPosition", { enumerable: true, get: function () { return MulticalendarStatesAndSettings_1.setMulticalendarYScrollPosition; } });
@@ -0,0 +1,229 @@
1
+ .parallel-selection-list {
2
+ display: grid;
3
+ grid-template-areas:
4
+ "lef rig"
5
+ "but but";
6
+ height: 100%;
7
+ grid-template-rows: calc(100% - 80px) 80px;
8
+ grid-template-columns: 50% 50%;
9
+ }
10
+
11
+ .parallel-selection-list .div-left-list {
12
+ grid-area: lef;
13
+ display: flex;
14
+ flex-flow: column;
15
+ align-items: center;
16
+ box-sizing: border-box;
17
+ padding: 10px;
18
+ height: 100%;
19
+ }
20
+
21
+ .parallel-selection-list .div-right-list {
22
+ grid-area: rig;
23
+ display: flex;
24
+ flex-flow: column;
25
+ align-items: center;
26
+ box-sizing: border-box;
27
+ padding: 10px;
28
+ height: 100%;
29
+ }
30
+
31
+ .parallel-selection-list .div-action-buttons {
32
+ grid-area: but;
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: space-between;
36
+ box-sizing: border-box;
37
+ padding: 10px 20px;
38
+ }
39
+
40
+ .parallel-selection-list .list-title {
41
+ font-size: 20px;
42
+ font-weight: 600;
43
+ color: dimgray;
44
+ height: 30px;
45
+ display: flex;
46
+ align-items: center;
47
+ justify-content: center;
48
+ }
49
+
50
+ .parallel-selection-list .div-search-bar {
51
+ width: 100%;
52
+ border: 1px solid rgb(185, 185, 185);
53
+ border-top-left-radius: 6px;
54
+ border-top-right-radius: 6px;
55
+ padding: 6px;
56
+ height: 30px;
57
+ box-sizing: border-box;
58
+ color: dimgray;
59
+ display: flex;
60
+ align-items: center;
61
+ justify-content: center;
62
+ }
63
+
64
+ .parallel-selection-list .div-search-bar input {
65
+ border: none;
66
+ padding-left: 10px;
67
+ width: 100%;
68
+ }
69
+
70
+ .parallel-selection-list .div-search-bar input:focus {
71
+ outline: none;
72
+ }
73
+
74
+ .parallel-selection-list .list-container {
75
+ width: 100%;
76
+ display: flex;
77
+ flex-flow: column;
78
+ box-sizing: border-box;
79
+ border: 1px solid rgb(169, 169, 169);
80
+ border-bottom-left-radius: 6px;
81
+ border-bottom-right-radius: 6px;
82
+ border-top: none;
83
+ height: calc(100% - 60px);
84
+ }
85
+
86
+ .parallel-selection-list .list-container .apply-all-button {
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: center;
90
+ width: 100%;
91
+ height: 30px;
92
+ border: none;
93
+ background-color: transparent;
94
+ color: dimgray;
95
+ font-weight: 700;
96
+ border-bottom: 1px solid rgb(169, 169, 169);
97
+ box-sizing: border-box;
98
+ padding: 5px 0;
99
+ transition: all 0.3s;
100
+ cursor: pointer;
101
+ }
102
+
103
+ .parallel-selection-list .list-container .apply-all-button svg {
104
+ width: 20px;
105
+ height: 20px;
106
+ }
107
+
108
+ .parallel-selection-list .list-container .apply-all-button:hover {
109
+ background-color: rgb(238, 238, 238);
110
+ }
111
+
112
+ .parallel-selection-list .list-container .scrollable-section {
113
+ overflow-y: auto;
114
+ height: calc(100% - 30px);
115
+ }
116
+
117
+ .parallel-selection-list .list-container .scrollable-section .resizable-div-for-scroll {
118
+ width: 100%;
119
+ box-sizing: border-box;
120
+ }
121
+
122
+ .parallel-selection-list
123
+ .list-container
124
+ .scrollable-section
125
+ .resizable-div-for-scroll
126
+ .div-datum-wrapper {
127
+ width: 100%;
128
+ display: flex;
129
+ justify-content: space-between;
130
+ align-items: center;
131
+ border-bottom: 1px solid rgb(169, 169, 169);
132
+ }
133
+
134
+ .parallel-selection-list
135
+ .list-container
136
+ .scrollable-section
137
+ .resizable-div-for-scroll
138
+ .div-datum-wrapper
139
+ .div-custom-component-wrapper {
140
+ position: relative;
141
+ height: 100%;
142
+ width: calc(100% - 50px);
143
+ display: flex;
144
+ align-items: center;
145
+ justify-content: center;
146
+ overflow: hidden;
147
+ }
148
+
149
+ .parallel-selection-list
150
+ .list-container
151
+ .scrollable-section
152
+ .resizable-div-for-scroll
153
+ .div-datum-wrapper
154
+ .visible-default-name {
155
+ box-sizing: border-box;
156
+ padding: 17px 10px;
157
+ font-size: 16px;
158
+ font-weight: 600;
159
+ color: dimgray;
160
+ height: 50px;
161
+ white-space: nowrap;
162
+ text-overflow: ellipsis;
163
+ overflow: hidden;
164
+ width: calc(100% - 50px);
165
+ text-align: start;
166
+ }
167
+
168
+ .parallel-selection-list
169
+ .list-container
170
+ .scrollable-section
171
+ .resizable-div-for-scroll
172
+ .div-datum-wrapper
173
+ .apply-to-one-button {
174
+ height: 30px;
175
+ width: 30px;
176
+ display: flex;
177
+ align-items: center;
178
+ justify-content: center;
179
+ margin: 10px;
180
+ background-color: transparent;
181
+ border: none;
182
+ border-radius: 15px;
183
+ transition: all 0.3s;
184
+ cursor: pointer;
185
+ }
186
+
187
+ .parallel-selection-list
188
+ .list-container
189
+ .scrollable-section
190
+ .resizable-div-for-scroll
191
+ .div-datum-wrapper
192
+ .apply-to-one-button:hover {
193
+ background-color: rgb(238, 238, 238);
194
+ }
195
+
196
+ .parallel-selection-list .div-action-buttons button {
197
+ box-sizing: border-box;
198
+ padding: 10px 15px;
199
+ display: flex;
200
+ align-items: center;
201
+ justify-content: center;
202
+ background-color: transparent;
203
+ border: solid 2px;
204
+ border-radius: 6px;
205
+ font-size: 16px;
206
+ font-weight: 600;
207
+ transition: all 0.3s;
208
+ cursor: pointer;
209
+ }
210
+
211
+ .parallel-selection-list .div-action-buttons .cancel-button {
212
+ border-color: dimgray;
213
+ color: dimgray;
214
+ }
215
+
216
+ .parallel-selection-list .div-action-buttons .cancel-button:hover {
217
+ background-color: dimgray;
218
+ color: white;
219
+ }
220
+
221
+ .parallel-selection-list .div-action-buttons .apply-button {
222
+ border-color: var(--primary-color);
223
+ color: var(--primary-color);
224
+ }
225
+
226
+ .parallel-selection-list .div-action-buttons .apply-button:hover {
227
+ background-color: var(--primary-color);
228
+ color: white;
229
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./ParallelSelectionList.css";
3
+ import { ParallelSelectionListPropsTypes } from "./types";
4
+ declare const ParallelSelectionList: ({ dataList, applyAction, cancelAction, leftListTitle, rightListTitle, searchBarsVisible, applyButonText, cancelButtonText, preSelectedDatumsIds, listElementsHeight, }: ParallelSelectionListPropsTypes) => JSX.Element;
5
+ export default ParallelSelectionList;
@@ -0,0 +1,130 @@
1
+ import React from "react";
2
+ import { useState, useEffect, useRef } from "react";
3
+ import "./ParallelSelectionList.css";
4
+ //Icons
5
+ import { BsChevronDoubleLeft, BsChevronDoubleRight, BsChevronLeft, BsChevronRight, BsSearch, } from "react-icons/bs";
6
+ //Hooks
7
+ import useResizeObserver from "../../hooks/useResizeObserver";
8
+ const ParallelSelectionList = ({ dataList, applyAction, cancelAction, leftListTitle, rightListTitle, searchBarsVisible, applyButonText, cancelButtonText, preSelectedDatumsIds = [], listElementsHeight = 50, }) => {
9
+ //Refs
10
+ const leftListRef = useRef(null);
11
+ const rightListRef = useRef(null);
12
+ //useState
13
+ const [selectedDatumsIds, setSelectedDatumsIds] = useState(preSelectedDatumsIds);
14
+ const [filteredLeftList, setFilteredLeftList] = useState([]);
15
+ const [filteredRightList, setFilteredRightList] = useState([]);
16
+ const [leftListFirstVisibleElementIndex, setLeftListFirstVisibleElementIndex] = useState(0);
17
+ const [leftListLastVisibleElementIndex, setLeftListLastVisibleElementIndex] = useState(0);
18
+ const [rightListFirstVisibleElementIndex, setRightListFirstVisibleElementIndex] = useState(0);
19
+ const [rightListLastVisibleElementIndex, setRightListLastVisibleElementIndex] = useState(0);
20
+ const [leftListSearchValue, setLeftListSearchValue] = useState("");
21
+ const [rightListSearchValue, setRightListSearchValue] = useState("");
22
+ //hooks
23
+ const [leftListWidth, leftListHeight] = useResizeObserver(leftListRef);
24
+ const [rightListWidth, rightListHeight] = useResizeObserver(rightListRef);
25
+ //Functions
26
+ const addToSelectedDatumsIds = (datumIdsArray) => {
27
+ const selectedDatumsIdsClone = [...selectedDatumsIds];
28
+ datumIdsArray.forEach((datumId) => {
29
+ if (!selectedDatumsIds.includes(datumId)) {
30
+ selectedDatumsIdsClone.push(datumId);
31
+ }
32
+ });
33
+ setSelectedDatumsIds(selectedDatumsIdsClone);
34
+ };
35
+ const removeFromSelectedDatumsIds = (datumIdsArray) => {
36
+ const selectedDatumsIdsClone = [...selectedDatumsIds];
37
+ datumIdsArray.forEach((datumId) => {
38
+ if (selectedDatumsIds.includes(datumId)) {
39
+ selectedDatumsIdsClone.splice(selectedDatumsIdsClone.indexOf(datumId), 1);
40
+ }
41
+ });
42
+ setSelectedDatumsIds(selectedDatumsIdsClone);
43
+ };
44
+ //useEffects
45
+ useEffect(() => {
46
+ let dataListClone = [...dataList];
47
+ dataListClone = dataListClone.filter((datum) => !selectedDatumsIds.includes(datum._id));
48
+ dataListClone = dataListClone.filter((datum) => datum.searchValue.toLowerCase().includes(leftListSearchValue.toLowerCase()));
49
+ setFilteredLeftList(dataListClone);
50
+ }, [leftListSearchValue, dataList, selectedDatumsIds]);
51
+ useEffect(() => {
52
+ let dataListClone = [...dataList];
53
+ dataListClone = dataListClone.filter((datum) => selectedDatumsIds.includes(datum._id));
54
+ dataListClone = dataListClone.filter((datum) => datum.searchValue.toLowerCase().includes(rightListSearchValue.toLowerCase()));
55
+ setFilteredRightList(dataListClone);
56
+ }, [rightListSearchValue, dataList, selectedDatumsIds]);
57
+ useEffect(() => {
58
+ if (leftListRef.current && leftListRef.current.clientHeight !== 0) {
59
+ setLeftListLastVisibleElementIndex(leftListFirstVisibleElementIndex +
60
+ Math.floor(leftListRef.current.clientHeight / listElementsHeight) +
61
+ 2);
62
+ }
63
+ else {
64
+ setLeftListLastVisibleElementIndex(filteredLeftList.length);
65
+ }
66
+ }, [
67
+ leftListHeight,
68
+ leftListWidth,
69
+ leftListFirstVisibleElementIndex,
70
+ listElementsHeight,
71
+ filteredLeftList.length
72
+ ]);
73
+ useEffect(() => {
74
+ if (rightListRef.current && rightListRef.current.clientHeight !== 0) {
75
+ setRightListLastVisibleElementIndex(rightListFirstVisibleElementIndex +
76
+ Math.floor(rightListRef.current.clientHeight / listElementsHeight) +
77
+ 2);
78
+ }
79
+ else {
80
+ setRightListLastVisibleElementIndex(filteredRightList.length);
81
+ }
82
+ }, [
83
+ rightListHeight,
84
+ rightListWidth,
85
+ rightListFirstVisibleElementIndex,
86
+ listElementsHeight,
87
+ filteredRightList.length
88
+ ]);
89
+ return (React.createElement("div", { className: "parallel-selection-list" },
90
+ React.createElement("div", { className: "div-left-list" },
91
+ React.createElement("p", { className: "list-title" }, leftListTitle),
92
+ searchBarsVisible && (React.createElement("div", { className: "div-search-bar" },
93
+ React.createElement(BsSearch, null),
94
+ React.createElement("input", { type: "text", value: leftListSearchValue, onChange: (event) => setLeftListSearchValue(event.target.value) }))),
95
+ React.createElement("div", { className: "list-container" },
96
+ React.createElement("button", { className: "apply-all-button", onClick: () => addToSelectedDatumsIds(filteredLeftList.map((datum) => datum._id)) },
97
+ React.createElement(BsChevronDoubleRight, null)),
98
+ React.createElement("div", { ref: leftListRef, className: "scrollable-section", onScroll: (event) => setLeftListFirstVisibleElementIndex(Math.floor(event.target.scrollTop / listElementsHeight)) },
99
+ React.createElement("div", { className: "resizable-div-for-scroll", style: {
100
+ paddingTop: leftListFirstVisibleElementIndex * listElementsHeight,
101
+ height: filteredLeftList.length * listElementsHeight,
102
+ } }, filteredLeftList
103
+ .slice(leftListFirstVisibleElementIndex, leftListLastVisibleElementIndex)
104
+ .map((datum) => (React.createElement("div", { key: datum._id, className: "div-datum-wrapper", style: { height: listElementsHeight } },
105
+ datum.customComponent ? (React.createElement("div", { className: "div-custom-component-wrapper" }, datum.customComponent)) : (React.createElement("p", { className: "visible-default-name", title: datum.visibleDefaultName }, datum.visibleDefaultName)),
106
+ React.createElement("button", { className: "apply-to-one-button", onClick: () => addToSelectedDatumsIds([datum._id]) },
107
+ React.createElement(BsChevronRight, null))))))))),
108
+ React.createElement("div", { className: "div-right-list" },
109
+ React.createElement("p", { className: "list-title" }, rightListTitle),
110
+ searchBarsVisible && (React.createElement("div", { className: "div-search-bar" },
111
+ React.createElement(BsSearch, null),
112
+ React.createElement("input", { type: "text", value: rightListSearchValue, onChange: (event) => setRightListSearchValue(event.target.value) }))),
113
+ React.createElement("div", { className: "list-container" },
114
+ React.createElement("button", { className: "apply-all-button", onClick: () => removeFromSelectedDatumsIds(filteredRightList.map((datum) => datum._id)) },
115
+ React.createElement(BsChevronDoubleLeft, null)),
116
+ React.createElement("div", { ref: rightListRef, className: "scrollable-section", onScroll: (event) => setRightListFirstVisibleElementIndex(Math.floor(event.target.scrollTop / listElementsHeight)) },
117
+ React.createElement("div", { className: "resizable-div-for-scroll", style: {
118
+ paddingTop: rightListFirstVisibleElementIndex * listElementsHeight,
119
+ height: filteredRightList.length * listElementsHeight,
120
+ } }, filteredRightList
121
+ .slice(rightListFirstVisibleElementIndex, rightListLastVisibleElementIndex)
122
+ .map((datum) => (React.createElement("div", { key: datum._id, className: "div-datum-wrapper", style: { height: listElementsHeight } },
123
+ React.createElement("button", { className: "apply-to-one-button", onClick: () => removeFromSelectedDatumsIds([datum._id]) },
124
+ React.createElement(BsChevronLeft, null)),
125
+ datum.customComponent ? (React.createElement("div", { className: "div-custom-component-wrapper" }, datum.customComponent)) : (React.createElement("p", { className: "visible-default-name", title: datum.visibleDefaultName }, datum.visibleDefaultName))))))))),
126
+ React.createElement("div", { className: "div-action-buttons" },
127
+ React.createElement("button", { className: "cancel-button", onClick: () => cancelAction() }, cancelButtonText ? cancelButtonText : "Cancel"),
128
+ React.createElement("button", { className: "apply-button", onClick: () => applyAction(selectedDatumsIds) }, applyButonText ? applyButonText : "Apply"))));
129
+ };
130
+ export default ParallelSelectionList;
@@ -0,0 +1,19 @@
1
+ export interface ParallelSelectionListPropsTypes {
2
+ dataList: ListDatumType[];
3
+ applyAction: (dataListId: ListDatumType["_id"][]) => Fuction;
4
+ cancelAction: Function;
5
+ leftListTitle?: string;
6
+ rightListTitle?: string;
7
+ searchBarsVisible?: boolean;
8
+ applyButonText?: string;
9
+ cancelButtonText?: string;
10
+ preSelectedDatumsIds?: ListDatumType["_id"][];
11
+ listElementsHeight?: number;
12
+ }
13
+
14
+ export type ListDatumType = {
15
+ _id: string;
16
+ searchValue: string;
17
+ visibleDefaultName: string;
18
+ customComponent?: JSX.Element;
19
+ };
@@ -5,7 +5,7 @@
5
5
  border-width: 0px 1px 1px;
6
6
  box-shadow: rgb(0 0 0 / 15%) 0px 14px 36px 2px;
7
7
  padding: 0px;
8
- position: relative;
8
+ position: absolute;
9
9
  overflow: auto;
10
10
  box-sizing: border-box;
11
11
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import "./PopUp.css";
3
- import { PopUpProps } from "./types";
4
- declare const PopUp: ({ open, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle, aditionalClass, }: PopUpProps) => JSX.Element;
3
+ import { PopUpPropsType } from "./types";
4
+ declare const PopUp: ({ open, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle, aditionalClass, activationButtonRef, }: PopUpPropsType) => JSX.Element;
5
5
  export default PopUp;
@@ -1,7 +1,8 @@
1
1
  import React, { useState, useRef } from "react";
2
- import useOutsideClick from "../../hooks/useOutsideClick";
3
2
  import "./PopUp.css";
4
- const PopUp = ({ open = false, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle = {}, aditionalClass, }) => {
3
+ //hooks
4
+ import useOutsideClick from "../../hooks/useOutsideClick";
5
+ const PopUp = ({ open = false, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle = {}, aditionalClass, activationButtonRef, }) => {
5
6
  //Refs
6
7
  const popUpRef = useRef(null);
7
8
  //Hooks
@@ -11,12 +12,11 @@ const PopUp = ({ open = false, children, closeAction, outBoundClickClosesPopUp,
11
12
  if (closeAction)
12
13
  closeAction();
13
14
  }
14
- });
15
- //Estados
16
- const [openState, setOpenState] = useState(open);
15
+ }, activationButtonRef ? [activationButtonRef] : []);
17
16
  //useState
17
+ const [openState, setOpenState] = useState(open);
18
18
  return (React.createElement("div", { ref: popUpRef, className: "pop-up" +
19
19
  ((closeAction && open) || (!closeAction && openState) ? "" : " pop-up-hidden") +
20
- (aditionalClass ? " " + aditionalClass : ""), style: aditionalInlineStyle }, children));
20
+ (aditionalClass ? " " + aditionalClass : ""), style: open ? aditionalInlineStyle : {} }, children));
21
21
  };
22
22
  export default PopUp;
@@ -1,8 +1,9 @@
1
- export interface PopUpProps {
1
+ export interface PopUpPropsType {
2
2
  children: JSX.Element | JSX.Element[];
3
3
  open: boolean;
4
4
  closeAction?: Function;
5
5
  outBoundClickClosesPopUp?: boolean;
6
6
  aditionalInlineStyle?: React.CSSProperties;
7
- aditionalClass: string;
7
+ aditionalClass?: string;
8
+ activationButtonRef?: React.MutableRefObject<HTMLElement | null>;
8
9
  }
@@ -0,0 +1,39 @@
1
+ .progress-bar {
2
+ height: 40px;
3
+ width: 100%;
4
+ position: relative;
5
+ opacity: 0.9;
6
+ backdrop-filter: blur(10px);
7
+ }
8
+
9
+ .progress-bar .fillable-body {
10
+ position: relative;
11
+ height: 100%;
12
+ width: 100%;
13
+ background-color: dimgray;
14
+ border-radius: 100px;
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: flex-start;
18
+ overflow: hidden;
19
+ }
20
+
21
+ .progress-bar .fillable-body .filler {
22
+ height: 100%;
23
+ box-sizing: border-box;
24
+ transition: all 0.2s;
25
+ border-radius: 100px;
26
+ }
27
+
28
+ .progress-bar .fillable-body p {
29
+ position: absolute;
30
+ width: 100%;
31
+ height: 100%;
32
+ text-align: center;
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ font-size: 16px;
37
+ font-weight: 600;
38
+ color: white;
39
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./ProgressBar.css";
3
+ import { ProgressBarPropsType } from "./types";
4
+ declare const ProgressBar: ({ totalSize, currentValue, color, }: ProgressBarPropsType) => JSX.Element;
5
+ export default ProgressBar;
@@ -0,0 +1,31 @@
1
+ import React, { useEffect, useState, useRef } from "react";
2
+ import "./ProgressBar.css";
3
+ const ProgressBar = ({ totalSize, currentValue, color = "var(--secondary-color)", }) => {
4
+ var _a;
5
+ //useRef
6
+ const fillableBodyRef = useRef(null);
7
+ //useStates
8
+ const [currentPercentage, setCurrentPercentage] = useState(totalSize !== 0 ? currentValue / totalSize : 0);
9
+ const [barWidth, setBarWidth] = useState(0);
10
+ //useEffects
11
+ useEffect(() => {
12
+ if (totalSize !== 0) {
13
+ setCurrentPercentage(currentValue / totalSize);
14
+ }
15
+ else {
16
+ setCurrentPercentage(0);
17
+ }
18
+ }, [totalSize, currentValue]);
19
+ useEffect(() => {
20
+ if (fillableBodyRef.current !== null) {
21
+ setBarWidth(fillableBodyRef.current.clientWidth);
22
+ }
23
+ }, [(_a = fillableBodyRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight]);
24
+ return (React.createElement("div", { className: "progress-bar" },
25
+ React.createElement("div", { ref: fillableBodyRef, className: "fillable-body" },
26
+ React.createElement("div", { className: "filler", style: { width: barWidth * currentPercentage, backgroundColor: color } }),
27
+ React.createElement("p", null,
28
+ (currentPercentage * 100).toFixed(0),
29
+ "%"))));
30
+ };
31
+ export default ProgressBar;
@@ -0,0 +1,7 @@
1
+ import { languageType } from "../../../assets/languages/types";
2
+
3
+ export interface ProgressBarPropsType {
4
+ totalSize: number;
5
+ currentValue: number;
6
+ color?: string,
7
+ }
@@ -2,5 +2,5 @@
2
2
  /**
3
3
  * Hook that alerts clicks outside of the passed ref
4
4
  */
5
- declare function useOutsideClick(elementRef: React.MutableRefObject<HTMLElement | null>, onOutsideClickAction: Function): void;
5
+ declare function useOutsideClick(elementRef: React.MutableRefObject<HTMLElement | null>, onOutsideClickAction: Function, elementsRefsExceptions?: React.MutableRefObject<HTMLElement | null>[]): void;
6
6
  export default useOutsideClick;
@@ -2,13 +2,15 @@ import { useEffect } from "react";
2
2
  /**
3
3
  * Hook that alerts clicks outside of the passed ref
4
4
  */
5
- function useOutsideClick(elementRef, onOutsideClickAction) {
5
+ function useOutsideClick(elementRef, onOutsideClickAction, elementsRefsExceptions = []) {
6
6
  useEffect(() => {
7
7
  /**
8
8
  * Alert if clicked on outside of element
9
9
  */
10
10
  function handleClickOutside(event) {
11
- if (elementRef.current && !elementRef.current.contains(event.target)) {
11
+ if (elementRef.current &&
12
+ !elementRef.current.contains(event.target) &&
13
+ elementsRefsExceptions.every((elementRefException) => elementRefException.current !== event.target)) {
12
14
  onOutsideClickAction();
13
15
  }
14
16
  }
@@ -18,6 +20,6 @@ function useOutsideClick(elementRef, onOutsideClickAction) {
18
20
  // Unbind the event listener on clean up
19
21
  document.removeEventListener("mousedown", handleClickOutside);
20
22
  };
21
- }, [elementRef, onOutsideClickAction]);
23
+ }, [elementRef, onOutsideClickAction, elementsRefsExceptions]);
22
24
  }
23
25
  export default useOutsideClick;
@@ -3,5 +3,7 @@ import SideBar from "./components/SideBar/SideBar";
3
3
  import SearchBar from "./components/SearchBar/SearchBar";
4
4
  import Modal from "./components/Modal/Modal";
5
5
  import PopUp from "./components/PopUp/PopUp";
6
+ import ProgressBar from "./components/ProgressBar/ProgressBar";
7
+ import ParallelSelectionList from "./components/ParallelSelectionList/ParallelSelectionList";
6
8
  import { setMulticalendarYScrollPosition } from "./Services/MulticalendarStatesAndSettings";
7
- export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, };
9
+ export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, ProgressBar, ParallelSelectionList };
package/dist/esm/index.js CHANGED
@@ -3,5 +3,7 @@ import SideBar from "./components/SideBar/SideBar";
3
3
  import SearchBar from "./components/SearchBar/SearchBar";
4
4
  import Modal from "./components/Modal/Modal";
5
5
  import PopUp from "./components/PopUp/PopUp";
6
+ import ProgressBar from "./components/ProgressBar/ProgressBar";
7
+ import ParallelSelectionList from "./components/ParallelSelectionList/ParallelSelectionList";
6
8
  import { setMulticalendarYScrollPosition } from "./Services/MulticalendarStatesAndSettings";
7
- export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, };
9
+ export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, ProgressBar, ParallelSelectionList };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "josenanodev-react-components-library",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "author": {
5
5
  "name": "Jose Carlos Cardenas Martinez"
6
6
  },