josenanodev-react-components-library 0.0.17 → 0.0.19

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 (35) hide show
  1. package/dist/cjs/components/Modal/Modal.css +3 -3
  2. package/dist/cjs/components/Modal/Modal.d.ts +1 -1
  3. package/dist/cjs/components/Modal/Modal.js +2 -2
  4. package/dist/cjs/components/Modal/types.d.ts +0 -1
  5. package/dist/cjs/components/MultipleJoinedButtonsBar/MultipleJoinedButtonsBar.css +40 -0
  6. package/dist/cjs/components/MultipleJoinedButtonsBar/MultipleJoinedButtonsBar.d.ts +5 -0
  7. package/dist/cjs/components/MultipleJoinedButtonsBar/MultipleJoinedButtonsBar.js +48 -0
  8. package/dist/cjs/components/MultipleJoinedButtonsBar/types.d.ts +6 -0
  9. package/dist/cjs/components/ParallelSelectionList/types.d.ts +1 -1
  10. package/dist/cjs/components/Slider/Slider.css +51 -0
  11. package/dist/cjs/components/Slider/Slider.d.ts +5 -0
  12. package/dist/cjs/components/Slider/Slider.js +165 -0
  13. package/dist/cjs/components/Slider/SliderOwnFunctions.d.ts +2 -0
  14. package/dist/cjs/components/Slider/SliderOwnFunctions.js +11 -0
  15. package/dist/cjs/components/Slider/types.d.ts +13 -0
  16. package/dist/cjs/index.d.ts +3 -1
  17. package/dist/cjs/index.js +5 -1
  18. package/dist/esm/components/Modal/Modal.css +3 -3
  19. package/dist/esm/components/Modal/Modal.d.ts +1 -1
  20. package/dist/esm/components/Modal/Modal.js +2 -2
  21. package/dist/esm/components/Modal/types.d.ts +0 -1
  22. package/dist/esm/components/MultipleJoinedButtonsBar/MultipleJoinedButtonsBar.css +40 -0
  23. package/dist/esm/components/MultipleJoinedButtonsBar/MultipleJoinedButtonsBar.d.ts +5 -0
  24. package/dist/esm/components/MultipleJoinedButtonsBar/MultipleJoinedButtonsBar.js +23 -0
  25. package/dist/esm/components/MultipleJoinedButtonsBar/types.d.ts +6 -0
  26. package/dist/esm/components/ParallelSelectionList/types.d.ts +1 -1
  27. package/dist/esm/components/Slider/Slider.css +51 -0
  28. package/dist/esm/components/Slider/Slider.d.ts +5 -0
  29. package/dist/esm/components/Slider/Slider.js +140 -0
  30. package/dist/esm/components/Slider/SliderOwnFunctions.d.ts +2 -0
  31. package/dist/esm/components/Slider/SliderOwnFunctions.js +6 -0
  32. package/dist/esm/components/Slider/types.d.ts +13 -0
  33. package/dist/esm/index.d.ts +3 -1
  34. package/dist/esm/index.js +3 -1
  35. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- #modal,
2
- #close-modal {
1
+ .modal,
2
+ .close-modal {
3
3
  position: fixed;
4
4
  width: 100vw;
5
5
  height: 100vh;
@@ -14,7 +14,7 @@
14
14
  animation-duration: 500ms;
15
15
  }
16
16
 
17
- #close-modal {
17
+ .close-modal {
18
18
  animation-name: close-modal;
19
19
  animation-duration: 500ms;
20
20
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import "./Modal.css";
3
3
  import { ModalPropsType } from "./types";
4
- declare const Modal: ({ children, parentElement, visibility, forced, onOpen, onClose, transitionTime, }: ModalPropsType) => JSX.Element;
4
+ declare const Modal: ({ children, visibility, forced, onOpen, onClose, transitionTime, }: ModalPropsType) => JSX.Element;
5
5
  export default Modal;
@@ -31,7 +31,7 @@ const react_dom_1 = __importDefault(require("react-dom"));
31
31
  require("./Modal.css");
32
32
  //Hooks
33
33
  const useOutsideClick_1 = __importDefault(require("../../hooks/useOutsideClick"));
34
- const Modal = ({ children, parentElement, visibility, forced = false, onOpen, onClose, transitionTime = 500, }) => {
34
+ const Modal = ({ children, visibility, forced = false, onOpen, onClose, transitionTime = 500, }) => {
35
35
  //Refs
36
36
  const modalRef = (0, react_1.useRef)(null);
37
37
  //Estados
@@ -73,7 +73,7 @@ const Modal = ({ children, parentElement, visibility, forced = false, onOpen, on
73
73
  onClose();
74
74
  }, transitionTime - 50);
75
75
  }
76
- } }, children), parentElement);
76
+ } }, children), document.body);
77
77
  }
78
78
  else {
79
79
  return react_1.default.createElement(react_1.default.Fragment, null);
@@ -1,6 +1,5 @@
1
1
  export interface ModalPropsType {
2
2
  children: JSX.Element;
3
- parentElement: HTMLElement;
4
3
  visibility: boolean;
5
4
  forced?: boolean;
6
5
  onOpen?: Function;
@@ -0,0 +1,40 @@
1
+ .multiple-joined-buttons-bar {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ }
6
+
7
+ .multiple-joined-buttons-bar button {
8
+ border: var(--primary-color) solid 2px;
9
+ border-left-width: 1px;
10
+ border-right-width: 1px;
11
+ color: var(--primary-color);
12
+ background-color: rgb(255, 255, 255);
13
+ padding: 5px 15px;
14
+ box-sizing: border-box;
15
+ font-weight: 600;
16
+ font-size: 16px;
17
+ cursor: pointer;
18
+ transition: all 0.3s;
19
+ }
20
+
21
+ .multiple-joined-buttons-bar button:hover {
22
+ background-color: rgb(240, 240, 240);
23
+ }
24
+
25
+ .multiple-joined-buttons-bar button.selected {
26
+ background-color: var(--primary-color);
27
+ color: white;
28
+ }
29
+
30
+ .multiple-joined-buttons-bar button.left-side-button {
31
+ border-left-width: 2px;
32
+ border-top-left-radius: 6px;
33
+ border-bottom-left-radius: 6px;
34
+ }
35
+
36
+ .multiple-joined-buttons-bar button.right-side-button {
37
+ border-right-width: 2px;
38
+ border-top-right-radius: 6px;
39
+ border-bottom-right-radius: 6px;
40
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./MultipleJoinedButtonsBar.css";
3
+ import { MultipleJoinedButtonsBarPropsType } from "./types";
4
+ declare const MultipleJoinedButtonsBar: ({ options, onSelectOption, initialSelectedValue, externalSelectedValue, }: MultipleJoinedButtonsBarPropsType) => JSX.Element;
5
+ export default MultipleJoinedButtonsBar;
@@ -0,0 +1,48 @@
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("./MultipleJoinedButtonsBar.css");
28
+ const MultipleJoinedButtonsBar = ({ options, onSelectOption, initialSelectedValue, externalSelectedValue, }) => {
29
+ //States
30
+ const [selectedValue, setSelectedValue] = (0, react_1.useState)(initialSelectedValue);
31
+ //Effects
32
+ (0, react_1.useEffect)(() => {
33
+ if (externalSelectedValue &&
34
+ options.map((option) => option._id).includes(externalSelectedValue)) {
35
+ setSelectedValue(externalSelectedValue);
36
+ }
37
+ }, [externalSelectedValue]);
38
+ return (react_1.default.createElement("div", { className: "multiple-joined-buttons-bar" }, options.map((option, index) => (react_1.default.createElement("button", { key: option._id, className: (selectedValue === option._id ? "selected" : "") +
39
+ (index === 0
40
+ ? " left-side-button"
41
+ : index === options.length - 1
42
+ ? " right-side-button"
43
+ : ""), onClick: () => {
44
+ setSelectedValue(option._id);
45
+ onSelectOption(option._id);
46
+ } }, option.visibleValue)))));
47
+ };
48
+ exports.default = MultipleJoinedButtonsBar;
@@ -0,0 +1,6 @@
1
+ export interface MultipleJoinedButtonsBarPropsType {
2
+ options: { _id: string; visibleValue: string }[];
3
+ onSelectOption: (selectedValue: string) => void;
4
+ initialSelectedValue?: string;
5
+ externalSelectedValue?: string;
6
+ }
@@ -1,6 +1,6 @@
1
1
  export interface ParallelSelectionListPropsTypes {
2
2
  dataList: ListDatumType[];
3
- applyAction: (dataListId: ListDatumType["_id"][]) => Fuction;
3
+ applyAction: (dataListId: ListDatumType["_id"][]) => void;
4
4
  cancelAction: Function;
5
5
  leftListTitle?: string;
6
6
  rightListTitle?: string;
@@ -0,0 +1,51 @@
1
+ .slider {
2
+ display: flex;
3
+ align-items: center;
4
+ }
5
+
6
+ .slider .left-fill {
7
+ border: 2px solid rgb(216, 216, 216);
8
+ background-color: var(--secondary-color);
9
+ }
10
+
11
+ .slider .right-fill {
12
+ border: 2px solid rgb(216, 216, 216);
13
+ background-color: rgb(211, 211, 211);
14
+ }
15
+
16
+ .slider .sphere {
17
+ border-radius: 100%;
18
+ box-shadow: 0px 0px 20px 2px #a7a7a7;
19
+ background-color: rgb(255, 255, 255);
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: center;
23
+ cursor: grab;
24
+ z-index: 2;
25
+ }
26
+
27
+ .slider .sphere p {
28
+ margin: 0;
29
+ font-size: 12px;
30
+ font-weight: 600;
31
+ color: #757575;
32
+ width: 25%;
33
+ }
34
+
35
+ .slider .sphere input {
36
+ width: 70%;
37
+ border: none;
38
+ background-color: transparent;
39
+ text-align: right;
40
+ font-size: 12px;
41
+ font-weight: 600;
42
+ color: #757575;
43
+ }
44
+
45
+ .slider .sphere input::-webkit-inner-spin-button {
46
+ display: none;
47
+ }
48
+
49
+ .slider .sphere input:focus {
50
+ outline: none;
51
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./Slider.css";
3
+ import { SliderPropsType } from "./types";
4
+ declare const Slider: ({ minimumValue, maximumValue, onChange, initialValue, value, showValueInsideButton, editableValueInsideButton, height, width, sufix, prefix, }: SliderPropsType) => JSX.Element;
5
+ export default Slider;
@@ -0,0 +1,165 @@
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
+ const ownFunctions = __importStar(require("./SliderOwnFunctions"));
28
+ require("./Slider.css");
29
+ const Slider = ({ minimumValue, maximumValue, onChange, initialValue = 0, value, showValueInsideButton, editableValueInsideButton, height = 40, width = 300, sufix, prefix, }) => {
30
+ //Refs
31
+ const sliderRef = (0, react_1.useRef)(null);
32
+ //Estados
33
+ const [position, setPosition] = (0, react_1.useState)(initialValue !== undefined
34
+ ? ownFunctions.definePostionByValue(initialValue, width, maximumValue, minimumValue)
35
+ : width / 2);
36
+ const [visibleValue, setVisibleValue] = (0, react_1.useState)(initialValue);
37
+ const [temporalVisibleValue, setTemporalVisibleValue] = (0, react_1.useState)(undefined);
38
+ const [cancelTransition, setCancelTransition] = (0, react_1.useState)(false);
39
+ (0, react_1.useEffect)(() => {
40
+ if (value !== undefined) {
41
+ setVisibleValue(value);
42
+ setPosition(ownFunctions.definePostionByValue(value, width, maximumValue, minimumValue));
43
+ }
44
+ }, [value, width, maximumValue, minimumValue]);
45
+ return (react_1.default.createElement("div", { ref: sliderRef, style: { width: width, height: height }, className: "slider", onMouseDown: (event1) => {
46
+ var nuevovisibleValue;
47
+ if (sliderRef.current !== null && sliderRef.current !== undefined) {
48
+ setCancelTransition(false);
49
+ const newPosition = event1.clientX - sliderRef.current.getBoundingClientRect().x;
50
+ setPosition(newPosition);
51
+ nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
52
+ setVisibleValue(nuevovisibleValue);
53
+ }
54
+ function repositioning(event2) {
55
+ setCancelTransition(true);
56
+ if (sliderRef.current !== null && sliderRef.current !== undefined) {
57
+ setTemporalVisibleValue(undefined);
58
+ let newPosition = event2.clientX - sliderRef.current.getBoundingClientRect().x;
59
+ if (newPosition < 0)
60
+ newPosition = 0;
61
+ if (newPosition > width)
62
+ newPosition = width;
63
+ setPosition(newPosition);
64
+ nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
65
+ setVisibleValue(nuevovisibleValue);
66
+ }
67
+ }
68
+ document.addEventListener("mousemove", repositioning);
69
+ function removeEventListeners() {
70
+ document.removeEventListener("mousemove", repositioning);
71
+ document.removeEventListener("mouseup", removeEventListeners);
72
+ setCancelTransition(false);
73
+ onChange(nuevovisibleValue);
74
+ }
75
+ document.addEventListener("mouseup", removeEventListeners);
76
+ }, onTouchStart: (event1) => {
77
+ var nuevovisibleValue;
78
+ if (sliderRef.current !== null && sliderRef.current !== undefined) {
79
+ setCancelTransition(false);
80
+ const newPosition = event1.touches[0].clientX - sliderRef.current.getBoundingClientRect().x;
81
+ setPosition(newPosition);
82
+ nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
83
+ setVisibleValue(nuevovisibleValue);
84
+ }
85
+ function repositioning(event2) {
86
+ setCancelTransition(true);
87
+ if (sliderRef.current !== null && sliderRef.current !== undefined) {
88
+ setTemporalVisibleValue(undefined);
89
+ let newPosition = event2.touches[0].clientX - sliderRef.current.getBoundingClientRect().x;
90
+ if (newPosition < 0)
91
+ newPosition = 0;
92
+ if (newPosition > width)
93
+ newPosition = width;
94
+ setPosition(newPosition);
95
+ nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
96
+ setVisibleValue(nuevovisibleValue);
97
+ }
98
+ }
99
+ document.addEventListener("touchmove", repositioning);
100
+ function removeEventListeners() {
101
+ document.removeEventListener("touchmove", repositioning);
102
+ document.removeEventListener("touchend", removeEventListeners);
103
+ setCancelTransition(false);
104
+ onChange(nuevovisibleValue);
105
+ }
106
+ document.addEventListener("touchend", removeEventListeners);
107
+ } },
108
+ react_1.default.createElement("div", { style: {
109
+ width: position,
110
+ height: height * 0.8,
111
+ borderTopLeftRadius: (height * 0.8) / 2,
112
+ borderBottomLeftRadius: (height * 0.8) / 2,
113
+ marginRight: -height / 2,
114
+ transition: cancelTransition ? "none" : "all 0.3s",
115
+ }, className: "left-fill" }),
116
+ react_1.default.createElement("div", { style: { width: height, height: height }, className: "sphere" }, showValueInsideButton && (react_1.default.createElement(react_1.Fragment, null,
117
+ prefix !== undefined && react_1.default.createElement("p", null, prefix),
118
+ react_1.default.createElement("input", { disabled: !editableValueInsideButton, type: "number", min: minimumValue, max: maximumValue, value: temporalVisibleValue !== undefined ? temporalVisibleValue : visibleValue, onChange: (event) => {
119
+ setTemporalVisibleValue(Number(event.target.value));
120
+ }, onFocus: () => {
121
+ setTemporalVisibleValue(visibleValue);
122
+ }, onKeyDown: (event) => {
123
+ if (event.key === "Enter" && temporalVisibleValue !== undefined) {
124
+ let nuevovalue = temporalVisibleValue;
125
+ if (nuevovalue < minimumValue)
126
+ nuevovalue = minimumValue;
127
+ if (nuevovalue > maximumValue)
128
+ nuevovalue = maximumValue;
129
+ const newPosition = ownFunctions.definePostionByValue(nuevovalue, width, maximumValue, minimumValue);
130
+ setPosition(newPosition);
131
+ const nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
132
+ setVisibleValue(nuevovisibleValue);
133
+ onChange(nuevovisibleValue);
134
+ setTemporalVisibleValue(undefined);
135
+ }
136
+ if (event.key === "Escape") {
137
+ setPosition(ownFunctions.definePostionByValue(visibleValue, width, maximumValue, minimumValue));
138
+ setTemporalVisibleValue(undefined);
139
+ }
140
+ }, onBlur: () => {
141
+ if (temporalVisibleValue !== undefined) {
142
+ let nuevovalue = temporalVisibleValue;
143
+ if (nuevovalue < minimumValue)
144
+ nuevovalue = minimumValue;
145
+ if (nuevovalue > maximumValue)
146
+ nuevovalue = maximumValue;
147
+ const newPosition = ownFunctions.definePostionByValue(nuevovalue, width, maximumValue, minimumValue);
148
+ setPosition(newPosition);
149
+ const nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
150
+ setVisibleValue(nuevovisibleValue);
151
+ onChange(nuevovisibleValue);
152
+ setTemporalVisibleValue(undefined);
153
+ }
154
+ } }),
155
+ sufix !== undefined && react_1.default.createElement("p", null, sufix)))),
156
+ react_1.default.createElement("div", { style: {
157
+ width: width - position,
158
+ height: height * 0.8,
159
+ borderTopRightRadius: (height * 0.8) / 2,
160
+ borderBottomRightRadius: (height * 0.8) / 2,
161
+ marginLeft: -height / 2,
162
+ transition: cancelTransition ? "none" : "all 0.3s",
163
+ }, className: "right-fill" })));
164
+ };
165
+ exports.default = Slider;
@@ -0,0 +1,2 @@
1
+ export declare function defineVisibleValue(posicion: number, ancho: number, valorMaximo: number, valorMinimo: number): number;
2
+ export declare function definePostionByValue(nuevoValor: number, ancho: number, valorMaximo: number, valorMinimo: number): number;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.definePostionByValue = exports.defineVisibleValue = void 0;
4
+ function defineVisibleValue(posicion, ancho, valorMaximo, valorMinimo) {
5
+ return Math.round((posicion / (ancho)) * (valorMaximo - valorMinimo) + valorMinimo);
6
+ }
7
+ exports.defineVisibleValue = defineVisibleValue;
8
+ function definePostionByValue(nuevoValor, ancho, valorMaximo, valorMinimo) {
9
+ return ((nuevoValor - valorMinimo) / (valorMaximo - valorMinimo)) * (ancho);
10
+ }
11
+ exports.definePostionByValue = definePostionByValue;
@@ -0,0 +1,13 @@
1
+ export interface SliderPropsType {
2
+ minimumValue: number;
3
+ maximumValue: number;
4
+ onChange: (newValue: number) => Function;
5
+ initialValue?: number;
6
+ value?: number;
7
+ showValueInsideButton?: boolean;
8
+ editableValueInsideButton?: boolean;
9
+ height?: number;
10
+ width?: number;
11
+ sufix?: string;
12
+ prefix?: string;
13
+ }
@@ -5,5 +5,7 @@ import Modal from "./components/Modal/Modal";
5
5
  import PopUp from "./components/PopUp/PopUp";
6
6
  import ProgressBar from "./components/ProgressBar/ProgressBar";
7
7
  import ParallelSelectionList from "./components/ParallelSelectionList/ParallelSelectionList";
8
+ import Slider from "./components/Slider/Slider";
9
+ import MultipleJoinedButtonsBar from "./components/MultipleJoinedButtonsBar/MultipleJoinedButtonsBar";
8
10
  import { setMulticalendarYScrollPosition } from "./Services/MulticalendarStatesAndSettings";
9
- export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, ProgressBar, ParallelSelectionList };
11
+ export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, ProgressBar, ParallelSelectionList, Slider, MultipleJoinedButtonsBar, };
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.ParallelSelectionList = exports.ProgressBar = exports.PopUp = exports.Modal = exports.SearchBar = exports.SideBar = exports.setMulticalendarYScrollPosition = exports.Multicalendar = void 0;
6
+ exports.MultipleJoinedButtonsBar = exports.Slider = 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"));
@@ -18,5 +18,9 @@ const ProgressBar_1 = __importDefault(require("./components/ProgressBar/Progress
18
18
  exports.ProgressBar = ProgressBar_1.default;
19
19
  const ParallelSelectionList_1 = __importDefault(require("./components/ParallelSelectionList/ParallelSelectionList"));
20
20
  exports.ParallelSelectionList = ParallelSelectionList_1.default;
21
+ const Slider_1 = __importDefault(require("./components/Slider/Slider"));
22
+ exports.Slider = Slider_1.default;
23
+ const MultipleJoinedButtonsBar_1 = __importDefault(require("./components/MultipleJoinedButtonsBar/MultipleJoinedButtonsBar"));
24
+ exports.MultipleJoinedButtonsBar = MultipleJoinedButtonsBar_1.default;
21
25
  const MulticalendarStatesAndSettings_1 = require("./Services/MulticalendarStatesAndSettings");
22
26
  Object.defineProperty(exports, "setMulticalendarYScrollPosition", { enumerable: true, get: function () { return MulticalendarStatesAndSettings_1.setMulticalendarYScrollPosition; } });
@@ -1,5 +1,5 @@
1
- #modal,
2
- #close-modal {
1
+ .modal,
2
+ .close-modal {
3
3
  position: fixed;
4
4
  width: 100vw;
5
5
  height: 100vh;
@@ -14,7 +14,7 @@
14
14
  animation-duration: 500ms;
15
15
  }
16
16
 
17
- #close-modal {
17
+ .close-modal {
18
18
  animation-name: close-modal;
19
19
  animation-duration: 500ms;
20
20
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import "./Modal.css";
3
3
  import { ModalPropsType } from "./types";
4
- declare const Modal: ({ children, parentElement, visibility, forced, onOpen, onClose, transitionTime, }: ModalPropsType) => JSX.Element;
4
+ declare const Modal: ({ children, visibility, forced, onOpen, onClose, transitionTime, }: ModalPropsType) => JSX.Element;
5
5
  export default Modal;
@@ -3,7 +3,7 @@ import ReactDOM from "react-dom";
3
3
  import "./Modal.css";
4
4
  //Hooks
5
5
  import useOutsideClick from "../../hooks/useOutsideClick";
6
- const Modal = ({ children, parentElement, visibility, forced = false, onOpen, onClose, transitionTime = 500, }) => {
6
+ const Modal = ({ children, visibility, forced = false, onOpen, onClose, transitionTime = 500, }) => {
7
7
  //Refs
8
8
  const modalRef = useRef(null);
9
9
  //Estados
@@ -45,7 +45,7 @@ const Modal = ({ children, parentElement, visibility, forced = false, onOpen, on
45
45
  onClose();
46
46
  }, transitionTime - 50);
47
47
  }
48
- } }, children), parentElement);
48
+ } }, children), document.body);
49
49
  }
50
50
  else {
51
51
  return React.createElement(React.Fragment, null);
@@ -1,6 +1,5 @@
1
1
  export interface ModalPropsType {
2
2
  children: JSX.Element;
3
- parentElement: HTMLElement;
4
3
  visibility: boolean;
5
4
  forced?: boolean;
6
5
  onOpen?: Function;
@@ -0,0 +1,40 @@
1
+ .multiple-joined-buttons-bar {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ }
6
+
7
+ .multiple-joined-buttons-bar button {
8
+ border: var(--primary-color) solid 2px;
9
+ border-left-width: 1px;
10
+ border-right-width: 1px;
11
+ color: var(--primary-color);
12
+ background-color: rgb(255, 255, 255);
13
+ padding: 5px 15px;
14
+ box-sizing: border-box;
15
+ font-weight: 600;
16
+ font-size: 16px;
17
+ cursor: pointer;
18
+ transition: all 0.3s;
19
+ }
20
+
21
+ .multiple-joined-buttons-bar button:hover {
22
+ background-color: rgb(240, 240, 240);
23
+ }
24
+
25
+ .multiple-joined-buttons-bar button.selected {
26
+ background-color: var(--primary-color);
27
+ color: white;
28
+ }
29
+
30
+ .multiple-joined-buttons-bar button.left-side-button {
31
+ border-left-width: 2px;
32
+ border-top-left-radius: 6px;
33
+ border-bottom-left-radius: 6px;
34
+ }
35
+
36
+ .multiple-joined-buttons-bar button.right-side-button {
37
+ border-right-width: 2px;
38
+ border-top-right-radius: 6px;
39
+ border-bottom-right-radius: 6px;
40
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./MultipleJoinedButtonsBar.css";
3
+ import { MultipleJoinedButtonsBarPropsType } from "./types";
4
+ declare const MultipleJoinedButtonsBar: ({ options, onSelectOption, initialSelectedValue, externalSelectedValue, }: MultipleJoinedButtonsBarPropsType) => JSX.Element;
5
+ export default MultipleJoinedButtonsBar;
@@ -0,0 +1,23 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import "./MultipleJoinedButtonsBar.css";
3
+ const MultipleJoinedButtonsBar = ({ options, onSelectOption, initialSelectedValue, externalSelectedValue, }) => {
4
+ //States
5
+ const [selectedValue, setSelectedValue] = useState(initialSelectedValue);
6
+ //Effects
7
+ useEffect(() => {
8
+ if (externalSelectedValue &&
9
+ options.map((option) => option._id).includes(externalSelectedValue)) {
10
+ setSelectedValue(externalSelectedValue);
11
+ }
12
+ }, [externalSelectedValue]);
13
+ return (React.createElement("div", { className: "multiple-joined-buttons-bar" }, options.map((option, index) => (React.createElement("button", { key: option._id, className: (selectedValue === option._id ? "selected" : "") +
14
+ (index === 0
15
+ ? " left-side-button"
16
+ : index === options.length - 1
17
+ ? " right-side-button"
18
+ : ""), onClick: () => {
19
+ setSelectedValue(option._id);
20
+ onSelectOption(option._id);
21
+ } }, option.visibleValue)))));
22
+ };
23
+ export default MultipleJoinedButtonsBar;
@@ -0,0 +1,6 @@
1
+ export interface MultipleJoinedButtonsBarPropsType {
2
+ options: { _id: string; visibleValue: string }[];
3
+ onSelectOption: (selectedValue: string) => void;
4
+ initialSelectedValue?: string;
5
+ externalSelectedValue?: string;
6
+ }
@@ -1,6 +1,6 @@
1
1
  export interface ParallelSelectionListPropsTypes {
2
2
  dataList: ListDatumType[];
3
- applyAction: (dataListId: ListDatumType["_id"][]) => Fuction;
3
+ applyAction: (dataListId: ListDatumType["_id"][]) => void;
4
4
  cancelAction: Function;
5
5
  leftListTitle?: string;
6
6
  rightListTitle?: string;
@@ -0,0 +1,51 @@
1
+ .slider {
2
+ display: flex;
3
+ align-items: center;
4
+ }
5
+
6
+ .slider .left-fill {
7
+ border: 2px solid rgb(216, 216, 216);
8
+ background-color: var(--secondary-color);
9
+ }
10
+
11
+ .slider .right-fill {
12
+ border: 2px solid rgb(216, 216, 216);
13
+ background-color: rgb(211, 211, 211);
14
+ }
15
+
16
+ .slider .sphere {
17
+ border-radius: 100%;
18
+ box-shadow: 0px 0px 20px 2px #a7a7a7;
19
+ background-color: rgb(255, 255, 255);
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: center;
23
+ cursor: grab;
24
+ z-index: 2;
25
+ }
26
+
27
+ .slider .sphere p {
28
+ margin: 0;
29
+ font-size: 12px;
30
+ font-weight: 600;
31
+ color: #757575;
32
+ width: 25%;
33
+ }
34
+
35
+ .slider .sphere input {
36
+ width: 70%;
37
+ border: none;
38
+ background-color: transparent;
39
+ text-align: right;
40
+ font-size: 12px;
41
+ font-weight: 600;
42
+ color: #757575;
43
+ }
44
+
45
+ .slider .sphere input::-webkit-inner-spin-button {
46
+ display: none;
47
+ }
48
+
49
+ .slider .sphere input:focus {
50
+ outline: none;
51
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./Slider.css";
3
+ import { SliderPropsType } from "./types";
4
+ declare const Slider: ({ minimumValue, maximumValue, onChange, initialValue, value, showValueInsideButton, editableValueInsideButton, height, width, sufix, prefix, }: SliderPropsType) => JSX.Element;
5
+ export default Slider;
@@ -0,0 +1,140 @@
1
+ import React, { useState, useRef, useEffect, Fragment } from "react";
2
+ import * as ownFunctions from "./SliderOwnFunctions";
3
+ import "./Slider.css";
4
+ const Slider = ({ minimumValue, maximumValue, onChange, initialValue = 0, value, showValueInsideButton, editableValueInsideButton, height = 40, width = 300, sufix, prefix, }) => {
5
+ //Refs
6
+ const sliderRef = useRef(null);
7
+ //Estados
8
+ const [position, setPosition] = useState(initialValue !== undefined
9
+ ? ownFunctions.definePostionByValue(initialValue, width, maximumValue, minimumValue)
10
+ : width / 2);
11
+ const [visibleValue, setVisibleValue] = useState(initialValue);
12
+ const [temporalVisibleValue, setTemporalVisibleValue] = useState(undefined);
13
+ const [cancelTransition, setCancelTransition] = useState(false);
14
+ useEffect(() => {
15
+ if (value !== undefined) {
16
+ setVisibleValue(value);
17
+ setPosition(ownFunctions.definePostionByValue(value, width, maximumValue, minimumValue));
18
+ }
19
+ }, [value, width, maximumValue, minimumValue]);
20
+ return (React.createElement("div", { ref: sliderRef, style: { width: width, height: height }, className: "slider", onMouseDown: (event1) => {
21
+ var nuevovisibleValue;
22
+ if (sliderRef.current !== null && sliderRef.current !== undefined) {
23
+ setCancelTransition(false);
24
+ const newPosition = event1.clientX - sliderRef.current.getBoundingClientRect().x;
25
+ setPosition(newPosition);
26
+ nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
27
+ setVisibleValue(nuevovisibleValue);
28
+ }
29
+ function repositioning(event2) {
30
+ setCancelTransition(true);
31
+ if (sliderRef.current !== null && sliderRef.current !== undefined) {
32
+ setTemporalVisibleValue(undefined);
33
+ let newPosition = event2.clientX - sliderRef.current.getBoundingClientRect().x;
34
+ if (newPosition < 0)
35
+ newPosition = 0;
36
+ if (newPosition > width)
37
+ newPosition = width;
38
+ setPosition(newPosition);
39
+ nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
40
+ setVisibleValue(nuevovisibleValue);
41
+ }
42
+ }
43
+ document.addEventListener("mousemove", repositioning);
44
+ function removeEventListeners() {
45
+ document.removeEventListener("mousemove", repositioning);
46
+ document.removeEventListener("mouseup", removeEventListeners);
47
+ setCancelTransition(false);
48
+ onChange(nuevovisibleValue);
49
+ }
50
+ document.addEventListener("mouseup", removeEventListeners);
51
+ }, onTouchStart: (event1) => {
52
+ var nuevovisibleValue;
53
+ if (sliderRef.current !== null && sliderRef.current !== undefined) {
54
+ setCancelTransition(false);
55
+ const newPosition = event1.touches[0].clientX - sliderRef.current.getBoundingClientRect().x;
56
+ setPosition(newPosition);
57
+ nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
58
+ setVisibleValue(nuevovisibleValue);
59
+ }
60
+ function repositioning(event2) {
61
+ setCancelTransition(true);
62
+ if (sliderRef.current !== null && sliderRef.current !== undefined) {
63
+ setTemporalVisibleValue(undefined);
64
+ let newPosition = event2.touches[0].clientX - sliderRef.current.getBoundingClientRect().x;
65
+ if (newPosition < 0)
66
+ newPosition = 0;
67
+ if (newPosition > width)
68
+ newPosition = width;
69
+ setPosition(newPosition);
70
+ nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
71
+ setVisibleValue(nuevovisibleValue);
72
+ }
73
+ }
74
+ document.addEventListener("touchmove", repositioning);
75
+ function removeEventListeners() {
76
+ document.removeEventListener("touchmove", repositioning);
77
+ document.removeEventListener("touchend", removeEventListeners);
78
+ setCancelTransition(false);
79
+ onChange(nuevovisibleValue);
80
+ }
81
+ document.addEventListener("touchend", removeEventListeners);
82
+ } },
83
+ React.createElement("div", { style: {
84
+ width: position,
85
+ height: height * 0.8,
86
+ borderTopLeftRadius: (height * 0.8) / 2,
87
+ borderBottomLeftRadius: (height * 0.8) / 2,
88
+ marginRight: -height / 2,
89
+ transition: cancelTransition ? "none" : "all 0.3s",
90
+ }, className: "left-fill" }),
91
+ React.createElement("div", { style: { width: height, height: height }, className: "sphere" }, showValueInsideButton && (React.createElement(Fragment, null,
92
+ prefix !== undefined && React.createElement("p", null, prefix),
93
+ React.createElement("input", { disabled: !editableValueInsideButton, type: "number", min: minimumValue, max: maximumValue, value: temporalVisibleValue !== undefined ? temporalVisibleValue : visibleValue, onChange: (event) => {
94
+ setTemporalVisibleValue(Number(event.target.value));
95
+ }, onFocus: () => {
96
+ setTemporalVisibleValue(visibleValue);
97
+ }, onKeyDown: (event) => {
98
+ if (event.key === "Enter" && temporalVisibleValue !== undefined) {
99
+ let nuevovalue = temporalVisibleValue;
100
+ if (nuevovalue < minimumValue)
101
+ nuevovalue = minimumValue;
102
+ if (nuevovalue > maximumValue)
103
+ nuevovalue = maximumValue;
104
+ const newPosition = ownFunctions.definePostionByValue(nuevovalue, width, maximumValue, minimumValue);
105
+ setPosition(newPosition);
106
+ const nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
107
+ setVisibleValue(nuevovisibleValue);
108
+ onChange(nuevovisibleValue);
109
+ setTemporalVisibleValue(undefined);
110
+ }
111
+ if (event.key === "Escape") {
112
+ setPosition(ownFunctions.definePostionByValue(visibleValue, width, maximumValue, minimumValue));
113
+ setTemporalVisibleValue(undefined);
114
+ }
115
+ }, onBlur: () => {
116
+ if (temporalVisibleValue !== undefined) {
117
+ let nuevovalue = temporalVisibleValue;
118
+ if (nuevovalue < minimumValue)
119
+ nuevovalue = minimumValue;
120
+ if (nuevovalue > maximumValue)
121
+ nuevovalue = maximumValue;
122
+ const newPosition = ownFunctions.definePostionByValue(nuevovalue, width, maximumValue, minimumValue);
123
+ setPosition(newPosition);
124
+ const nuevovisibleValue = ownFunctions.defineVisibleValue(newPosition, width, maximumValue, minimumValue);
125
+ setVisibleValue(nuevovisibleValue);
126
+ onChange(nuevovisibleValue);
127
+ setTemporalVisibleValue(undefined);
128
+ }
129
+ } }),
130
+ sufix !== undefined && React.createElement("p", null, sufix)))),
131
+ React.createElement("div", { style: {
132
+ width: width - position,
133
+ height: height * 0.8,
134
+ borderTopRightRadius: (height * 0.8) / 2,
135
+ borderBottomRightRadius: (height * 0.8) / 2,
136
+ marginLeft: -height / 2,
137
+ transition: cancelTransition ? "none" : "all 0.3s",
138
+ }, className: "right-fill" })));
139
+ };
140
+ export default Slider;
@@ -0,0 +1,2 @@
1
+ export declare function defineVisibleValue(posicion: number, ancho: number, valorMaximo: number, valorMinimo: number): number;
2
+ export declare function definePostionByValue(nuevoValor: number, ancho: number, valorMaximo: number, valorMinimo: number): number;
@@ -0,0 +1,6 @@
1
+ export function defineVisibleValue(posicion, ancho, valorMaximo, valorMinimo) {
2
+ return Math.round((posicion / (ancho)) * (valorMaximo - valorMinimo) + valorMinimo);
3
+ }
4
+ export function definePostionByValue(nuevoValor, ancho, valorMaximo, valorMinimo) {
5
+ return ((nuevoValor - valorMinimo) / (valorMaximo - valorMinimo)) * (ancho);
6
+ }
@@ -0,0 +1,13 @@
1
+ export interface SliderPropsType {
2
+ minimumValue: number;
3
+ maximumValue: number;
4
+ onChange: (newValue: number) => Function;
5
+ initialValue?: number;
6
+ value?: number;
7
+ showValueInsideButton?: boolean;
8
+ editableValueInsideButton?: boolean;
9
+ height?: number;
10
+ width?: number;
11
+ sufix?: string;
12
+ prefix?: string;
13
+ }
@@ -5,5 +5,7 @@ import Modal from "./components/Modal/Modal";
5
5
  import PopUp from "./components/PopUp/PopUp";
6
6
  import ProgressBar from "./components/ProgressBar/ProgressBar";
7
7
  import ParallelSelectionList from "./components/ParallelSelectionList/ParallelSelectionList";
8
+ import Slider from "./components/Slider/Slider";
9
+ import MultipleJoinedButtonsBar from "./components/MultipleJoinedButtonsBar/MultipleJoinedButtonsBar";
8
10
  import { setMulticalendarYScrollPosition } from "./Services/MulticalendarStatesAndSettings";
9
- export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, ProgressBar, ParallelSelectionList };
11
+ export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, ProgressBar, ParallelSelectionList, Slider, MultipleJoinedButtonsBar, };
package/dist/esm/index.js CHANGED
@@ -5,5 +5,7 @@ import Modal from "./components/Modal/Modal";
5
5
  import PopUp from "./components/PopUp/PopUp";
6
6
  import ProgressBar from "./components/ProgressBar/ProgressBar";
7
7
  import ParallelSelectionList from "./components/ParallelSelectionList/ParallelSelectionList";
8
+ import Slider from "./components/Slider/Slider";
9
+ import MultipleJoinedButtonsBar from "./components/MultipleJoinedButtonsBar/MultipleJoinedButtonsBar";
8
10
  import { setMulticalendarYScrollPosition } from "./Services/MulticalendarStatesAndSettings";
9
- export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, ProgressBar, ParallelSelectionList };
11
+ export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, ProgressBar, ParallelSelectionList, Slider, MultipleJoinedButtonsBar, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "josenanodev-react-components-library",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "author": {
5
5
  "name": "Jose Carlos Cardenas Martinez"
6
6
  },