josenanodev-react-components-library 0.0.10 → 0.0.12

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 +43 -0
  2. package/dist/cjs/components/Modal/Modal.d.ts +5 -0
  3. package/dist/cjs/components/Modal/Modal.js +82 -0
  4. package/dist/cjs/components/Modal/types.d.ts +9 -0
  5. package/dist/cjs/components/PopUp/PopUp.css +15 -0
  6. package/dist/cjs/components/PopUp/PopUp.d.ts +5 -0
  7. package/dist/cjs/components/PopUp/PopUp.js +50 -0
  8. package/dist/cjs/components/PopUp/types.d.ts +8 -0
  9. package/dist/cjs/components/SearchBar/SearchBar.css +35 -0
  10. package/dist/cjs/components/SearchBar/SearchBar.d.ts +5 -0
  11. package/dist/cjs/components/SearchBar/SearchBar.js +67 -0
  12. package/dist/cjs/components/SearchBar/types.d.ts +10 -0
  13. package/dist/cjs/components/SideBar/SideBar.d.ts +1 -1
  14. package/dist/cjs/components/SideBar/SideBar.js +3 -5
  15. package/dist/cjs/components/SideBar/types.d.ts +1 -0
  16. package/dist/cjs/index.d.ts +5 -1
  17. package/dist/cjs/index.js +9 -1
  18. package/dist/esm/components/Modal/Modal.css +43 -0
  19. package/dist/esm/components/Modal/Modal.d.ts +5 -0
  20. package/dist/esm/components/Modal/Modal.js +54 -0
  21. package/dist/esm/components/Modal/types.d.ts +9 -0
  22. package/dist/esm/components/PopUp/PopUp.css +15 -0
  23. package/dist/esm/components/PopUp/PopUp.d.ts +5 -0
  24. package/dist/esm/components/PopUp/PopUp.js +22 -0
  25. package/dist/esm/components/PopUp/types.d.ts +8 -0
  26. package/dist/esm/components/SearchBar/SearchBar.css +35 -0
  27. package/dist/esm/components/SearchBar/SearchBar.d.ts +5 -0
  28. package/dist/esm/components/SearchBar/SearchBar.js +42 -0
  29. package/dist/esm/components/SearchBar/types.d.ts +10 -0
  30. package/dist/esm/components/SideBar/SideBar.d.ts +1 -1
  31. package/dist/esm/components/SideBar/SideBar.js +3 -5
  32. package/dist/esm/components/SideBar/types.d.ts +1 -0
  33. package/dist/esm/index.d.ts +5 -1
  34. package/dist/esm/index.js +5 -1
  35. package/package.json +1 -1
@@ -0,0 +1,43 @@
1
+ #modal,
2
+ #close-modal {
3
+ position: fixed;
4
+ width: 100vw;
5
+ height: 100vh;
6
+ backdrop-filter: blur(10px);
7
+ top: 0;
8
+ left: 0;
9
+ z-index: 10;
10
+ display: flex;
11
+ justify-content: center;
12
+ align-items: center;
13
+ animation-name: modal;
14
+ animation-duration: 500ms;
15
+ }
16
+
17
+ #close-modal {
18
+ animation-name: close-modal;
19
+ animation-duration: 500ms;
20
+ }
21
+
22
+ @keyframes modal {
23
+ from {
24
+ backdrop-filter: none;
25
+ opacity: 0;
26
+ }
27
+ to {
28
+ backdrop-filter: blur(10px);
29
+ opacity: 1;
30
+ }
31
+ }
32
+
33
+ @keyframes close-modal {
34
+ from {
35
+ backdrop-filter: blur(10px);
36
+ opacity: 1;
37
+ }
38
+ to {
39
+ backdrop-filter: none;
40
+ opacity: 0;
41
+ display: none;
42
+ }
43
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./Modal.css";
3
+ import { ModalPropsType } from "./types";
4
+ declare const Modal: ({ children, parentElement, visibility, forced, onOpen, onClose, transitionTime, }: ModalPropsType) => JSX.Element;
5
+ export default Modal;
@@ -0,0 +1,82 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const react_1 = __importStar(require("react"));
30
+ const react_dom_1 = __importDefault(require("react-dom"));
31
+ require("./Modal.css");
32
+ //Hooks
33
+ const useOutsideClick_1 = __importDefault(require("../../hooks/useOutsideClick"));
34
+ const Modal = ({ children, parentElement, visibility, forced = false, onOpen, onClose, transitionTime = 500, }) => {
35
+ //Refs
36
+ const modalRef = (0, react_1.useRef)(null);
37
+ //Estados
38
+ const [visible, setVisible] = (0, react_1.useState)(visibility);
39
+ //Hooks
40
+ (0, useOutsideClick_1.default)(modalRef, () => {
41
+ if (modalRef.current !== null && !forced) {
42
+ modalRef.current.className = "close-modal";
43
+ setTimeout(() => {
44
+ setVisible(false);
45
+ if (onClose)
46
+ onClose();
47
+ }, transitionTime - 50);
48
+ }
49
+ });
50
+ //UseEffect
51
+ (0, react_1.useEffect)(() => {
52
+ if (visibility) {
53
+ setVisible(true);
54
+ if (onOpen)
55
+ onOpen();
56
+ }
57
+ else if (!visibility) {
58
+ setTimeout(() => {
59
+ setVisible(false);
60
+ if (onClose)
61
+ onClose();
62
+ }, transitionTime - 50);
63
+ }
64
+ }, [visibility, transitionTime, onOpen, onClose]);
65
+ //Render
66
+ if (visible) {
67
+ return react_dom_1.default.createPortal(react_1.default.createElement("div", { ref: modalRef, className: visibility ? "modal" : "close-modal", style: { animationDuration: `${transitionTime}ms` }, onClick: (event) => {
68
+ if (event.target.id === "modal" && !forced) {
69
+ event.target.id = "close-modal";
70
+ setTimeout(() => {
71
+ setVisible(false);
72
+ if (onClose)
73
+ onClose();
74
+ }, transitionTime - 50);
75
+ }
76
+ } }, children), parentElement);
77
+ }
78
+ else {
79
+ return react_1.default.createElement(react_1.default.Fragment, null);
80
+ }
81
+ };
82
+ exports.default = Modal;
@@ -0,0 +1,9 @@
1
+ export interface ModalPropsType {
2
+ children: JSX.Element;
3
+ parentElement: HTMLElement;
4
+ visibility: boolean;
5
+ forced?: boolean;
6
+ onOpen?: Function;
7
+ onClose?: Function;
8
+ transitionTime?: number;
9
+ }
@@ -0,0 +1,15 @@
1
+ .pop-up {
2
+ background-color: rgb(255, 255, 255);
3
+ border-color: rgb(235, 235, 235);
4
+ border-style: solid;
5
+ border-width: 0px 1px 1px;
6
+ box-shadow: rgb(0 0 0 / 15%) 0px 14px 36px 2px;
7
+ padding: 0px;
8
+ position: relative;
9
+ overflow: auto;
10
+ box-sizing: border-box;
11
+ }
12
+
13
+ .pop-up.pop-up-hidden {
14
+ display: none;
15
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./PopUp.css";
3
+ import { PopUpProps } from "./types";
4
+ declare const PopUp: ({ open, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle, aditionalClass, }: PopUpProps) => JSX.Element;
5
+ export default PopUp;
@@ -0,0 +1,50 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const react_1 = __importStar(require("react"));
30
+ const useOutsideClick_1 = __importDefault(require("../../hooks/useOutsideClick"));
31
+ require("./PopUp.css");
32
+ const PopUp = ({ open = false, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle = {}, aditionalClass, }) => {
33
+ //Refs
34
+ const popUpRef = (0, react_1.useRef)(null);
35
+ //Hooks
36
+ (0, useOutsideClick_1.default)(popUpRef, () => {
37
+ if (outBoundClickClosesPopUp) {
38
+ setOpenState(false);
39
+ if (closeAction)
40
+ closeAction();
41
+ }
42
+ });
43
+ //Estados
44
+ const [openState, setOpenState] = (0, react_1.useState)(open);
45
+ //useState
46
+ return (react_1.default.createElement("div", { ref: popUpRef, className: "pop-up" +
47
+ ((closeAction && open) || (!closeAction && openState) ? "" : " pop-up-hidden") +
48
+ (aditionalClass ? " " + aditionalClass : ""), style: aditionalInlineStyle }, children));
49
+ };
50
+ exports.default = PopUp;
@@ -0,0 +1,8 @@
1
+ export interface PopUpProps {
2
+ children: JSX.Element | JSX.Element[];
3
+ open: boolean;
4
+ closeAction?: Function;
5
+ outBoundClickClosesPopUp?: boolean;
6
+ aditionalInlineStyle?: React.CSSProperties;
7
+ aditionalClass: string;
8
+ }
@@ -0,0 +1,35 @@
1
+ .search-bar .div-search-bar {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ border: 1px solid rgb(185, 185, 185);
6
+ box-sizing: border-box;
7
+ margin: 2px 10px;
8
+ padding: 5px 0px;
9
+ border-radius: 6px;
10
+ }
11
+
12
+ .search-bar .div-search-bar input {
13
+ width: 100%;
14
+ border: none;
15
+ }
16
+
17
+ .search-bar .div-search-bar input:focus {
18
+ border: none;
19
+ outline: none;
20
+ }
21
+
22
+ .search-bar .div-search-bar svg {
23
+ width: 36px;
24
+ padding: 0px 10px;
25
+ }
26
+
27
+ .search-bar .div-search-bar .icono-search-bar-opciones {
28
+ cursor: pointer;
29
+ transition: all 0.5s;
30
+ }
31
+
32
+ .search-bar .div-search-bar .icono-search-bar-opciones.icono-search-bar-opciones-desactivado {
33
+ cursor: not-allowed;
34
+ color: rgb(184, 184, 184);
35
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./SearchBar.css";
3
+ import { SearchBarPropsType } from "./types";
4
+ declare const SearchBar: ({ actionOnEnter, actionOnAlteringText, actionOnEmptyText, optionsButtonVisible, actionOnClickOptionsButton, placeholder, initialValue, disabled, }: SearchBarPropsType) => JSX.Element;
5
+ export default SearchBar;
@@ -0,0 +1,67 @@
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("./SearchBar.css");
28
+ //Icons
29
+ const bs_1 = require("react-icons/bs");
30
+ const SearchBar = ({ actionOnEnter = () => { }, actionOnAlteringText = () => { }, actionOnEmptyText = () => { }, optionsButtonVisible, actionOnClickOptionsButton = () => { }, placeholder = "", initialValue = "", disabled = false, }) => {
31
+ //Estados
32
+ const [searchValue, setSearchValue] = (0, react_1.useState)(initialValue);
33
+ const [cachedSearchValue, setCachedSearchValue] = (0, react_1.useState)(initialValue);
34
+ //useEffect
35
+ (0, react_1.useEffect)(() => {
36
+ if (searchValue !== cachedSearchValue) {
37
+ if (searchValue !== "") {
38
+ actionOnAlteringText(searchValue);
39
+ }
40
+ else if (searchValue === "") {
41
+ actionOnEmptyText();
42
+ }
43
+ setCachedSearchValue(searchValue);
44
+ }
45
+ }, [searchValue, cachedSearchValue, actionOnAlteringText, actionOnEmptyText]);
46
+ return (react_1.default.createElement("form", { className: "search-bar", onSubmit: (e) => {
47
+ e.preventDefault();
48
+ let searchElement = e.target.elements.namedItem("search-bar-name");
49
+ if (searchElement !== null)
50
+ actionOnEnter(searchElement.value);
51
+ } },
52
+ react_1.default.createElement("div", { className: "div-search-bar" },
53
+ react_1.default.createElement("div", null,
54
+ react_1.default.createElement(bs_1.BsSearch, null)),
55
+ react_1.default.createElement("input", { name: "search-bar-name", type: "text", placeholder: placeholder, disabled: disabled, onChange: (e) => {
56
+ setSearchValue(e.target.value);
57
+ if (e.target.value)
58
+ actionOnAlteringText();
59
+ if (!e.target.value)
60
+ actionOnEmptyText();
61
+ }, value: searchValue }),
62
+ optionsButtonVisible && (react_1.default.createElement("div", { className: disabled
63
+ ? "icono-search-bar-opciones icono-search-bar-opciones-disabled"
64
+ : "icono-search-bar-opciones", onClick: () => actionOnClickOptionsButton() },
65
+ react_1.default.createElement(bs_1.BsSliders, null))))));
66
+ };
67
+ exports.default = SearchBar;
@@ -0,0 +1,10 @@
1
+ export interface SearchBarPropsType {
2
+ actionOnEnter?: function;
3
+ actionOnAlteringText?: function;
4
+ actionOnEmptyText?: function;
5
+ optionsButtonVisible: boolean;
6
+ actionOnClickOptionsButton?: function;
7
+ placeholder: string;
8
+ initialValue?: string;
9
+ disabled?: boolean;
10
+ }
@@ -4,5 +4,5 @@ import { SideBarPropsType } from "./types";
4
4
  /**
5
5
  * NOTE: Parent Node must have position: relative, to work correctly with the side bar
6
6
  */
7
- declare const SideBar: ({ side, open, children, closeAction, outBoundClickClosesSideBar, }: SideBarPropsType) => JSX.Element;
7
+ declare const SideBar: ({ side, open, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle, }: SideBarPropsType) => JSX.Element;
8
8
  export default SideBar;
@@ -36,7 +36,7 @@ const bs_1 = require("react-icons/bs");
36
36
  /**
37
37
  * NOTE: Parent Node must have position: relative, to work correctly with the side bar
38
38
  */
39
- const SideBar = ({ side, open = false, children, closeAction, outBoundClickClosesSideBar, }) => {
39
+ const SideBar = ({ side, open = false, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle = {}, }) => {
40
40
  //Refs
41
41
  const sideBarRef = (0, react_1.useRef)(null);
42
42
  //Hooks
@@ -52,13 +52,11 @@ const SideBar = ({ side, open = false, children, closeAction, outBoundClickClose
52
52
  });
53
53
  //useState
54
54
  const [openState, setOpenState] = (0, react_1.useState)(open);
55
- return (react_1.default.createElement("div", { ref: sideBarRef, className: "side-bar", style: {
56
- [side === "left" ? "right" : "left"]: (closeAction && open) || (!closeAction && openState)
55
+ return (react_1.default.createElement("div", { ref: sideBarRef, className: "side-bar", style: Object.assign({ [side === "left" ? "right" : "left"]: (closeAction && open) || (!closeAction && openState)
57
56
  ? `calc(100% - ${elementWidth}px)`
58
57
  : closeAction
59
58
  ? "100%"
60
- : `calc(100% - 30px)`,
61
- } },
59
+ : `calc(100% - 30px)` }, aditionalInlineStyle) },
62
60
  react_1.default.createElement("button", { style: side === "left" ? { right: 0 } : { left: 0 }, className: "sidebar-close-button", onClick: () => {
63
61
  if (closeAction) {
64
62
  closeAction();
@@ -4,4 +4,5 @@ export interface SideBarPropsType {
4
4
  open: boolean;
5
5
  closeAction?: Function;
6
6
  outBoundClickClosesSideBar?: boolean;
7
+ aditionalInlineStyle?: React.CSSProperties;
7
8
  }
@@ -1,3 +1,7 @@
1
1
  import Multicalendar from "./components/Multicalendar/Multicalendar";
2
+ import SideBar from "./components/SideBar/SideBar";
3
+ import SearchBar from "./components/SearchBar/SearchBar";
4
+ import Modal from "./components/Modal/Modal";
5
+ import PopUp from "./components/PopUp/PopUp";
2
6
  import { setMulticalendarYScrollPosition } from "./Services/MulticalendarStatesAndSettings";
3
- export { Multicalendar, setMulticalendarYScrollPosition };
7
+ export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, };
package/dist/cjs/index.js CHANGED
@@ -3,8 +3,16 @@ 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.setMulticalendarYScrollPosition = exports.Multicalendar = void 0;
6
+ 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
+ const SideBar_1 = __importDefault(require("./components/SideBar/SideBar"));
10
+ exports.SideBar = SideBar_1.default;
11
+ const SearchBar_1 = __importDefault(require("./components/SearchBar/SearchBar"));
12
+ exports.SearchBar = SearchBar_1.default;
13
+ const Modal_1 = __importDefault(require("./components/Modal/Modal"));
14
+ exports.Modal = Modal_1.default;
15
+ const PopUp_1 = __importDefault(require("./components/PopUp/PopUp"));
16
+ exports.PopUp = PopUp_1.default;
9
17
  const MulticalendarStatesAndSettings_1 = require("./Services/MulticalendarStatesAndSettings");
10
18
  Object.defineProperty(exports, "setMulticalendarYScrollPosition", { enumerable: true, get: function () { return MulticalendarStatesAndSettings_1.setMulticalendarYScrollPosition; } });
@@ -0,0 +1,43 @@
1
+ #modal,
2
+ #close-modal {
3
+ position: fixed;
4
+ width: 100vw;
5
+ height: 100vh;
6
+ backdrop-filter: blur(10px);
7
+ top: 0;
8
+ left: 0;
9
+ z-index: 10;
10
+ display: flex;
11
+ justify-content: center;
12
+ align-items: center;
13
+ animation-name: modal;
14
+ animation-duration: 500ms;
15
+ }
16
+
17
+ #close-modal {
18
+ animation-name: close-modal;
19
+ animation-duration: 500ms;
20
+ }
21
+
22
+ @keyframes modal {
23
+ from {
24
+ backdrop-filter: none;
25
+ opacity: 0;
26
+ }
27
+ to {
28
+ backdrop-filter: blur(10px);
29
+ opacity: 1;
30
+ }
31
+ }
32
+
33
+ @keyframes close-modal {
34
+ from {
35
+ backdrop-filter: blur(10px);
36
+ opacity: 1;
37
+ }
38
+ to {
39
+ backdrop-filter: none;
40
+ opacity: 0;
41
+ display: none;
42
+ }
43
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./Modal.css";
3
+ import { ModalPropsType } from "./types";
4
+ declare const Modal: ({ children, parentElement, visibility, forced, onOpen, onClose, transitionTime, }: ModalPropsType) => JSX.Element;
5
+ export default Modal;
@@ -0,0 +1,54 @@
1
+ import React, { useState, useEffect, useRef } from "react";
2
+ import ReactDOM from "react-dom";
3
+ import "./Modal.css";
4
+ //Hooks
5
+ import useOutsideClick from "../../hooks/useOutsideClick";
6
+ const Modal = ({ children, parentElement, visibility, forced = false, onOpen, onClose, transitionTime = 500, }) => {
7
+ //Refs
8
+ const modalRef = useRef(null);
9
+ //Estados
10
+ const [visible, setVisible] = useState(visibility);
11
+ //Hooks
12
+ useOutsideClick(modalRef, () => {
13
+ if (modalRef.current !== null && !forced) {
14
+ modalRef.current.className = "close-modal";
15
+ setTimeout(() => {
16
+ setVisible(false);
17
+ if (onClose)
18
+ onClose();
19
+ }, transitionTime - 50);
20
+ }
21
+ });
22
+ //UseEffect
23
+ useEffect(() => {
24
+ if (visibility) {
25
+ setVisible(true);
26
+ if (onOpen)
27
+ onOpen();
28
+ }
29
+ else if (!visibility) {
30
+ setTimeout(() => {
31
+ setVisible(false);
32
+ if (onClose)
33
+ onClose();
34
+ }, transitionTime - 50);
35
+ }
36
+ }, [visibility, transitionTime, onOpen, onClose]);
37
+ //Render
38
+ if (visible) {
39
+ return ReactDOM.createPortal(React.createElement("div", { ref: modalRef, className: visibility ? "modal" : "close-modal", style: { animationDuration: `${transitionTime}ms` }, onClick: (event) => {
40
+ if (event.target.id === "modal" && !forced) {
41
+ event.target.id = "close-modal";
42
+ setTimeout(() => {
43
+ setVisible(false);
44
+ if (onClose)
45
+ onClose();
46
+ }, transitionTime - 50);
47
+ }
48
+ } }, children), parentElement);
49
+ }
50
+ else {
51
+ return React.createElement(React.Fragment, null);
52
+ }
53
+ };
54
+ export default Modal;
@@ -0,0 +1,9 @@
1
+ export interface ModalPropsType {
2
+ children: JSX.Element;
3
+ parentElement: HTMLElement;
4
+ visibility: boolean;
5
+ forced?: boolean;
6
+ onOpen?: Function;
7
+ onClose?: Function;
8
+ transitionTime?: number;
9
+ }
@@ -0,0 +1,15 @@
1
+ .pop-up {
2
+ background-color: rgb(255, 255, 255);
3
+ border-color: rgb(235, 235, 235);
4
+ border-style: solid;
5
+ border-width: 0px 1px 1px;
6
+ box-shadow: rgb(0 0 0 / 15%) 0px 14px 36px 2px;
7
+ padding: 0px;
8
+ position: relative;
9
+ overflow: auto;
10
+ box-sizing: border-box;
11
+ }
12
+
13
+ .pop-up.pop-up-hidden {
14
+ display: none;
15
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./PopUp.css";
3
+ import { PopUpProps } from "./types";
4
+ declare const PopUp: ({ open, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle, aditionalClass, }: PopUpProps) => JSX.Element;
5
+ export default PopUp;
@@ -0,0 +1,22 @@
1
+ import React, { useState, useRef } from "react";
2
+ import useOutsideClick from "../../hooks/useOutsideClick";
3
+ import "./PopUp.css";
4
+ const PopUp = ({ open = false, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle = {}, aditionalClass, }) => {
5
+ //Refs
6
+ const popUpRef = useRef(null);
7
+ //Hooks
8
+ useOutsideClick(popUpRef, () => {
9
+ if (outBoundClickClosesPopUp) {
10
+ setOpenState(false);
11
+ if (closeAction)
12
+ closeAction();
13
+ }
14
+ });
15
+ //Estados
16
+ const [openState, setOpenState] = useState(open);
17
+ //useState
18
+ return (React.createElement("div", { ref: popUpRef, className: "pop-up" +
19
+ ((closeAction && open) || (!closeAction && openState) ? "" : " pop-up-hidden") +
20
+ (aditionalClass ? " " + aditionalClass : ""), style: aditionalInlineStyle }, children));
21
+ };
22
+ export default PopUp;
@@ -0,0 +1,8 @@
1
+ export interface PopUpProps {
2
+ children: JSX.Element | JSX.Element[];
3
+ open: boolean;
4
+ closeAction?: Function;
5
+ outBoundClickClosesPopUp?: boolean;
6
+ aditionalInlineStyle?: React.CSSProperties;
7
+ aditionalClass: string;
8
+ }
@@ -0,0 +1,35 @@
1
+ .search-bar .div-search-bar {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ border: 1px solid rgb(185, 185, 185);
6
+ box-sizing: border-box;
7
+ margin: 2px 10px;
8
+ padding: 5px 0px;
9
+ border-radius: 6px;
10
+ }
11
+
12
+ .search-bar .div-search-bar input {
13
+ width: 100%;
14
+ border: none;
15
+ }
16
+
17
+ .search-bar .div-search-bar input:focus {
18
+ border: none;
19
+ outline: none;
20
+ }
21
+
22
+ .search-bar .div-search-bar svg {
23
+ width: 36px;
24
+ padding: 0px 10px;
25
+ }
26
+
27
+ .search-bar .div-search-bar .icono-search-bar-opciones {
28
+ cursor: pointer;
29
+ transition: all 0.5s;
30
+ }
31
+
32
+ .search-bar .div-search-bar .icono-search-bar-opciones.icono-search-bar-opciones-desactivado {
33
+ cursor: not-allowed;
34
+ color: rgb(184, 184, 184);
35
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import "./SearchBar.css";
3
+ import { SearchBarPropsType } from "./types";
4
+ declare const SearchBar: ({ actionOnEnter, actionOnAlteringText, actionOnEmptyText, optionsButtonVisible, actionOnClickOptionsButton, placeholder, initialValue, disabled, }: SearchBarPropsType) => JSX.Element;
5
+ export default SearchBar;
@@ -0,0 +1,42 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import "./SearchBar.css";
3
+ //Icons
4
+ import { BsSearch, BsSliders } from "react-icons/bs";
5
+ const SearchBar = ({ actionOnEnter = () => { }, actionOnAlteringText = () => { }, actionOnEmptyText = () => { }, optionsButtonVisible, actionOnClickOptionsButton = () => { }, placeholder = "", initialValue = "", disabled = false, }) => {
6
+ //Estados
7
+ const [searchValue, setSearchValue] = useState(initialValue);
8
+ const [cachedSearchValue, setCachedSearchValue] = useState(initialValue);
9
+ //useEffect
10
+ useEffect(() => {
11
+ if (searchValue !== cachedSearchValue) {
12
+ if (searchValue !== "") {
13
+ actionOnAlteringText(searchValue);
14
+ }
15
+ else if (searchValue === "") {
16
+ actionOnEmptyText();
17
+ }
18
+ setCachedSearchValue(searchValue);
19
+ }
20
+ }, [searchValue, cachedSearchValue, actionOnAlteringText, actionOnEmptyText]);
21
+ return (React.createElement("form", { className: "search-bar", onSubmit: (e) => {
22
+ e.preventDefault();
23
+ let searchElement = e.target.elements.namedItem("search-bar-name");
24
+ if (searchElement !== null)
25
+ actionOnEnter(searchElement.value);
26
+ } },
27
+ React.createElement("div", { className: "div-search-bar" },
28
+ React.createElement("div", null,
29
+ React.createElement(BsSearch, null)),
30
+ React.createElement("input", { name: "search-bar-name", type: "text", placeholder: placeholder, disabled: disabled, onChange: (e) => {
31
+ setSearchValue(e.target.value);
32
+ if (e.target.value)
33
+ actionOnAlteringText();
34
+ if (!e.target.value)
35
+ actionOnEmptyText();
36
+ }, value: searchValue }),
37
+ optionsButtonVisible && (React.createElement("div", { className: disabled
38
+ ? "icono-search-bar-opciones icono-search-bar-opciones-disabled"
39
+ : "icono-search-bar-opciones", onClick: () => actionOnClickOptionsButton() },
40
+ React.createElement(BsSliders, null))))));
41
+ };
42
+ export default SearchBar;
@@ -0,0 +1,10 @@
1
+ export interface SearchBarPropsType {
2
+ actionOnEnter?: function;
3
+ actionOnAlteringText?: function;
4
+ actionOnEmptyText?: function;
5
+ optionsButtonVisible: boolean;
6
+ actionOnClickOptionsButton?: function;
7
+ placeholder: string;
8
+ initialValue?: string;
9
+ disabled?: boolean;
10
+ }
@@ -4,5 +4,5 @@ import { SideBarPropsType } from "./types";
4
4
  /**
5
5
  * NOTE: Parent Node must have position: relative, to work correctly with the side bar
6
6
  */
7
- declare const SideBar: ({ side, open, children, closeAction, outBoundClickClosesSideBar, }: SideBarPropsType) => JSX.Element;
7
+ declare const SideBar: ({ side, open, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle, }: SideBarPropsType) => JSX.Element;
8
8
  export default SideBar;
@@ -8,7 +8,7 @@ import { BsChevronLeft, BsChevronRight } from "react-icons/bs";
8
8
  /**
9
9
  * NOTE: Parent Node must have position: relative, to work correctly with the side bar
10
10
  */
11
- const SideBar = ({ side, open = false, children, closeAction, outBoundClickClosesSideBar, }) => {
11
+ const SideBar = ({ side, open = false, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle = {}, }) => {
12
12
  //Refs
13
13
  const sideBarRef = useRef(null);
14
14
  //Hooks
@@ -24,13 +24,11 @@ const SideBar = ({ side, open = false, children, closeAction, outBoundClickClose
24
24
  });
25
25
  //useState
26
26
  const [openState, setOpenState] = useState(open);
27
- return (React.createElement("div", { ref: sideBarRef, className: "side-bar", style: {
28
- [side === "left" ? "right" : "left"]: (closeAction && open) || (!closeAction && openState)
27
+ return (React.createElement("div", { ref: sideBarRef, className: "side-bar", style: Object.assign({ [side === "left" ? "right" : "left"]: (closeAction && open) || (!closeAction && openState)
29
28
  ? `calc(100% - ${elementWidth}px)`
30
29
  : closeAction
31
30
  ? "100%"
32
- : `calc(100% - 30px)`,
33
- } },
31
+ : `calc(100% - 30px)` }, aditionalInlineStyle) },
34
32
  React.createElement("button", { style: side === "left" ? { right: 0 } : { left: 0 }, className: "sidebar-close-button", onClick: () => {
35
33
  if (closeAction) {
36
34
  closeAction();
@@ -4,4 +4,5 @@ export interface SideBarPropsType {
4
4
  open: boolean;
5
5
  closeAction?: Function;
6
6
  outBoundClickClosesSideBar?: boolean;
7
+ aditionalInlineStyle?: React.CSSProperties;
7
8
  }
@@ -1,3 +1,7 @@
1
1
  import Multicalendar from "./components/Multicalendar/Multicalendar";
2
+ import SideBar from "./components/SideBar/SideBar";
3
+ import SearchBar from "./components/SearchBar/SearchBar";
4
+ import Modal from "./components/Modal/Modal";
5
+ import PopUp from "./components/PopUp/PopUp";
2
6
  import { setMulticalendarYScrollPosition } from "./Services/MulticalendarStatesAndSettings";
3
- export { Multicalendar, setMulticalendarYScrollPosition };
7
+ export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, };
package/dist/esm/index.js CHANGED
@@ -1,3 +1,7 @@
1
1
  import Multicalendar from "./components/Multicalendar/Multicalendar";
2
+ import SideBar from "./components/SideBar/SideBar";
3
+ import SearchBar from "./components/SearchBar/SearchBar";
4
+ import Modal from "./components/Modal/Modal";
5
+ import PopUp from "./components/PopUp/PopUp";
2
6
  import { setMulticalendarYScrollPosition } from "./Services/MulticalendarStatesAndSettings";
3
- export { Multicalendar, setMulticalendarYScrollPosition };
7
+ export { Multicalendar, setMulticalendarYScrollPosition, SideBar, SearchBar, Modal, PopUp, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "josenanodev-react-components-library",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "author": "Jose Carlos Cardenas Martinez",
5
5
  "description": "Libreria de componentes React personales",
6
6
  "license": "MIT",