josenanodev-react-components-library 0.0.11 → 0.0.15

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 (188) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/Services/MulticalendarStatesAndSettings.d.ts +17 -17
  3. package/dist/cjs/Services/MulticalendarStatesAndSettings.js +29 -29
  4. package/dist/cjs/Services/accessToken.d.ts +3 -3
  5. package/dist/cjs/Services/accessToken.js +15 -15
  6. package/dist/cjs/common/constants.d.ts +5 -5
  7. package/dist/cjs/common/constants.js +8 -8
  8. package/dist/cjs/common/turboSuiteUrls.d.ts +7 -7
  9. package/dist/cjs/common/turboSuiteUrls.js +9 -9
  10. package/dist/cjs/common/types.d.ts +113 -113
  11. package/dist/cjs/components/Modal/Modal.css +43 -0
  12. package/dist/cjs/components/Modal/Modal.d.ts +5 -0
  13. package/dist/cjs/components/Modal/Modal.js +82 -0
  14. package/dist/cjs/components/Modal/types.d.ts +9 -0
  15. package/dist/cjs/components/Multicalendar/Multicalendar.css +191 -191
  16. package/dist/cjs/components/Multicalendar/Multicalendar.d.ts +5 -5
  17. package/dist/cjs/components/Multicalendar/Multicalendar.js +302 -302
  18. package/dist/cjs/components/Multicalendar/MulticalendarOwnFunctions.d.ts +86 -86
  19. package/dist/cjs/components/Multicalendar/MulticalendarOwnFunctions.js +192 -192
  20. package/dist/cjs/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.css +5 -5
  21. package/dist/cjs/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.d.ts +5 -5
  22. package/dist/cjs/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.js +20 -20
  23. package/dist/cjs/components/Multicalendar/subcomponents/composites/CellsRow/types.d.ts +11 -11
  24. package/dist/cjs/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.css +7 -7
  25. package/dist/cjs/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.d.ts +5 -5
  26. package/dist/cjs/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.js +20 -20
  27. package/dist/cjs/components/Multicalendar/subcomponents/composites/DatesGrid/types.d.ts +13 -13
  28. package/dist/cjs/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.css +3 -3
  29. package/dist/cjs/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.d.ts +5 -5
  30. package/dist/cjs/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.js +15 -15
  31. package/dist/cjs/components/Multicalendar/subcomponents/composites/ListElementsColumn/types.d.ts +9 -9
  32. package/dist/cjs/components/Multicalendar/subcomponents/individuals/Cell/Cell.css +7 -7
  33. package/dist/cjs/components/Multicalendar/subcomponents/individuals/Cell/Cell.d.ts +5 -5
  34. package/dist/cjs/components/Multicalendar/subcomponents/individuals/Cell/Cell.js +12 -12
  35. package/dist/cjs/components/Multicalendar/subcomponents/individuals/Cell/types.d.ts +10 -10
  36. package/dist/cjs/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.css +60 -60
  37. package/dist/cjs/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.d.ts +5 -5
  38. package/dist/cjs/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.js +56 -56
  39. package/dist/cjs/components/Multicalendar/subcomponents/individuals/DatesRow/types.d.ts +10 -10
  40. package/dist/cjs/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.css +13 -13
  41. package/dist/cjs/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.d.ts +5 -5
  42. package/dist/cjs/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.js +13 -13
  43. package/dist/cjs/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/types.d.ts +5 -5
  44. package/dist/cjs/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.css +14 -14
  45. package/dist/cjs/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.d.ts +5 -5
  46. package/dist/cjs/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.js +14 -14
  47. package/dist/cjs/components/Multicalendar/subcomponents/individuals/ListElement/types.d.ts +7 -7
  48. package/dist/cjs/components/Multicalendar/types.d.ts +45 -45
  49. package/dist/cjs/components/PopUp/PopUp.css +15 -0
  50. package/dist/cjs/components/PopUp/PopUp.d.ts +5 -0
  51. package/dist/cjs/components/PopUp/PopUp.js +50 -0
  52. package/dist/cjs/components/PopUp/types.d.ts +8 -0
  53. package/dist/cjs/components/SearchBar/SearchBar.css +35 -0
  54. package/dist/cjs/components/SearchBar/SearchBar.d.ts +5 -0
  55. package/dist/cjs/components/SearchBar/SearchBar.js +67 -0
  56. package/dist/cjs/components/SearchBar/types.d.ts +10 -0
  57. package/dist/cjs/components/SideBar/SideBar.css +50 -50
  58. package/dist/cjs/components/SideBar/SideBar.d.ts +8 -8
  59. package/dist/cjs/components/SideBar/SideBar.js +70 -70
  60. package/dist/cjs/components/SideBar/types.d.ts +8 -8
  61. package/dist/cjs/hooks/useOutsideClick.d.ts +6 -6
  62. package/dist/cjs/hooks/useOutsideClick.js +25 -25
  63. package/dist/cjs/hooks/useResizeObserver.d.ts +7 -7
  64. package/dist/cjs/hooks/useResizeObserver.js +30 -30
  65. package/dist/cjs/hooks/useWindowsSize.d.ts +6 -6
  66. package/dist/cjs/hooks/useWindowsSize.js +20 -20
  67. package/dist/cjs/index.css +77 -77
  68. package/dist/cjs/index.d.ts +7 -4
  69. package/dist/cjs/index.js +18 -12
  70. package/dist/cjs/languages/en-EN.d.ts +3 -3
  71. package/dist/cjs/languages/en-EN.js +25 -25
  72. package/dist/cjs/languages/es-ES.d.ts +3 -3
  73. package/dist/cjs/languages/es-ES.js +25 -25
  74. package/dist/cjs/languages/it-IT.d.ts +3 -3
  75. package/dist/cjs/languages/it-IT.js +25 -25
  76. package/dist/cjs/languages/types.d.ts +21 -21
  77. package/dist/cjs/mocks/ReactComponentMocksForTesting/CellChildrenMock.d.ts +4 -4
  78. package/dist/cjs/mocks/ReactComponentMocksForTesting/CellChildrenMock.js +13 -13
  79. package/dist/cjs/mocks/ReactComponentMocksForTesting/ListElementChildrenMock.d.ts +4 -4
  80. package/dist/cjs/mocks/ReactComponentMocksForTesting/ListElementChildrenMock.js +10 -10
  81. package/dist/cjs/react-app-env.d.ts +1 -1
  82. package/dist/cjs/setupTests.d.ts +2 -2
  83. package/dist/cjs/setupTests.js +8 -8
  84. package/dist/cjs/stories/css-presets.css +77 -77
  85. package/dist/cjs/utils/datesArray.d.ts +8 -8
  86. package/dist/cjs/utils/datesArray.js +23 -23
  87. package/dist/cjs/utils/jsToSqlDate.d.ts +7 -7
  88. package/dist/cjs/utils/jsToSqlDate.js +22 -22
  89. package/dist/cjs/utils/monthYearString.d.ts +3 -3
  90. package/dist/cjs/utils/monthYearString.js +27 -27
  91. package/dist/cjs/utils/numberOfDaysInAMonth.d.ts +6 -6
  92. package/dist/cjs/utils/numberOfDaysInAMonth.js +12 -12
  93. package/dist/cjs/utils/sqlToJsDate.d.ts +7 -7
  94. package/dist/cjs/utils/sqlToJsDate.js +14 -14
  95. package/dist/esm/Services/MulticalendarStatesAndSettings.d.ts +17 -17
  96. package/dist/esm/Services/MulticalendarStatesAndSettings.js +23 -23
  97. package/dist/esm/Services/accessToken.d.ts +3 -3
  98. package/dist/esm/Services/accessToken.js +9 -9
  99. package/dist/esm/common/constants.d.ts +5 -5
  100. package/dist/esm/common/constants.js +5 -5
  101. package/dist/esm/common/turboSuiteUrls.d.ts +7 -7
  102. package/dist/esm/common/turboSuiteUrls.js +7 -7
  103. package/dist/esm/common/types.d.ts +113 -113
  104. package/dist/esm/components/Modal/Modal.css +43 -0
  105. package/dist/esm/components/Modal/Modal.d.ts +5 -0
  106. package/dist/esm/components/Modal/Modal.js +54 -0
  107. package/dist/esm/components/Modal/types.d.ts +9 -0
  108. package/dist/esm/components/Multicalendar/Multicalendar.css +191 -191
  109. package/dist/esm/components/Multicalendar/Multicalendar.d.ts +5 -5
  110. package/dist/esm/components/Multicalendar/Multicalendar.js +274 -274
  111. package/dist/esm/components/Multicalendar/MulticalendarOwnFunctions.d.ts +86 -86
  112. package/dist/esm/components/Multicalendar/MulticalendarOwnFunctions.js +176 -176
  113. package/dist/esm/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.css +5 -5
  114. package/dist/esm/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.d.ts +5 -5
  115. package/dist/esm/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.js +15 -15
  116. package/dist/esm/components/Multicalendar/subcomponents/composites/CellsRow/types.d.ts +11 -11
  117. package/dist/esm/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.css +7 -7
  118. package/dist/esm/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.d.ts +5 -5
  119. package/dist/esm/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.js +15 -15
  120. package/dist/esm/components/Multicalendar/subcomponents/composites/DatesGrid/types.d.ts +13 -13
  121. package/dist/esm/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.css +3 -3
  122. package/dist/esm/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.d.ts +5 -5
  123. package/dist/esm/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.js +10 -10
  124. package/dist/esm/components/Multicalendar/subcomponents/composites/ListElementsColumn/types.d.ts +9 -9
  125. package/dist/esm/components/Multicalendar/subcomponents/individuals/Cell/Cell.css +7 -7
  126. package/dist/esm/components/Multicalendar/subcomponents/individuals/Cell/Cell.d.ts +5 -5
  127. package/dist/esm/components/Multicalendar/subcomponents/individuals/Cell/Cell.js +7 -7
  128. package/dist/esm/components/Multicalendar/subcomponents/individuals/Cell/types.d.ts +10 -10
  129. package/dist/esm/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.css +60 -60
  130. package/dist/esm/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.d.ts +5 -5
  131. package/dist/esm/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.js +51 -51
  132. package/dist/esm/components/Multicalendar/subcomponents/individuals/DatesRow/types.d.ts +10 -10
  133. package/dist/esm/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.css +13 -13
  134. package/dist/esm/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.d.ts +5 -5
  135. package/dist/esm/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.js +8 -8
  136. package/dist/esm/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/types.d.ts +5 -5
  137. package/dist/esm/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.css +14 -14
  138. package/dist/esm/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.d.ts +5 -5
  139. package/dist/esm/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.js +9 -9
  140. package/dist/esm/components/Multicalendar/subcomponents/individuals/ListElement/types.d.ts +7 -7
  141. package/dist/esm/components/Multicalendar/types.d.ts +45 -45
  142. package/dist/esm/components/PopUp/PopUp.css +15 -0
  143. package/dist/esm/components/PopUp/PopUp.d.ts +5 -0
  144. package/dist/esm/components/PopUp/PopUp.js +22 -0
  145. package/dist/esm/components/PopUp/types.d.ts +8 -0
  146. package/dist/esm/components/SearchBar/SearchBar.css +35 -0
  147. package/dist/esm/components/SearchBar/SearchBar.d.ts +5 -0
  148. package/dist/esm/components/SearchBar/SearchBar.js +42 -0
  149. package/dist/esm/components/SearchBar/types.d.ts +10 -0
  150. package/dist/esm/components/SideBar/SideBar.css +50 -50
  151. package/dist/esm/components/SideBar/SideBar.d.ts +8 -8
  152. package/dist/esm/components/SideBar/SideBar.js +42 -42
  153. package/dist/esm/components/SideBar/types.d.ts +8 -8
  154. package/dist/esm/hooks/useOutsideClick.d.ts +6 -6
  155. package/dist/esm/hooks/useOutsideClick.js +23 -23
  156. package/dist/esm/hooks/useResizeObserver.d.ts +7 -7
  157. package/dist/esm/hooks/useResizeObserver.js +28 -28
  158. package/dist/esm/hooks/useWindowsSize.d.ts +6 -6
  159. package/dist/esm/hooks/useWindowsSize.js +18 -18
  160. package/dist/esm/index.css +77 -77
  161. package/dist/esm/index.d.ts +7 -4
  162. package/dist/esm/index.js +7 -4
  163. package/dist/esm/languages/en-EN.d.ts +3 -3
  164. package/dist/esm/languages/en-EN.js +23 -23
  165. package/dist/esm/languages/es-ES.d.ts +3 -3
  166. package/dist/esm/languages/es-ES.js +23 -23
  167. package/dist/esm/languages/it-IT.d.ts +3 -3
  168. package/dist/esm/languages/it-IT.js +23 -23
  169. package/dist/esm/languages/types.d.ts +21 -21
  170. package/dist/esm/mocks/ReactComponentMocksForTesting/CellChildrenMock.d.ts +4 -4
  171. package/dist/esm/mocks/ReactComponentMocksForTesting/CellChildrenMock.js +8 -8
  172. package/dist/esm/mocks/ReactComponentMocksForTesting/ListElementChildrenMock.d.ts +4 -4
  173. package/dist/esm/mocks/ReactComponentMocksForTesting/ListElementChildrenMock.js +5 -5
  174. package/dist/esm/react-app-env.d.ts +1 -1
  175. package/dist/esm/setupTests.d.ts +2 -2
  176. package/dist/esm/setupTests.js +6 -6
  177. package/dist/esm/stories/css-presets.css +77 -77
  178. package/dist/esm/utils/datesArray.d.ts +8 -8
  179. package/dist/esm/utils/datesArray.js +21 -21
  180. package/dist/esm/utils/jsToSqlDate.d.ts +7 -7
  181. package/dist/esm/utils/jsToSqlDate.js +20 -20
  182. package/dist/esm/utils/monthYearString.d.ts +3 -3
  183. package/dist/esm/utils/monthYearString.js +25 -25
  184. package/dist/esm/utils/numberOfDaysInAMonth.d.ts +6 -6
  185. package/dist/esm/utils/numberOfDaysInAMonth.js +8 -8
  186. package/dist/esm/utils/sqlToJsDate.d.ts +7 -7
  187. package/dist/esm/utils/sqlToJsDate.js +12 -12
  188. package/package.json +103 -93
@@ -1,45 +1,45 @@
1
- import { languageType } from "../../languages/types";
2
-
3
- export interface MulticalendarPropsType {
4
- multicalendarId: string;
5
- ReactCellChildren: ReactCellChildrenType;
6
- ReactListElementChildren: ReactListElementChildrenType;
7
- listElementsIdsArray: string[] | number[];
8
- language: languageType;
9
- pastDatesVisible?: boolean
10
- cellsWidth?: number;
11
- cellsHeight?: number;
12
- verticalAxisWidth?: number;
13
- horizontalAxisHeight?: number;
14
- pastDaysInitialQuantity?: number;
15
- futureDaysInitialQuantity?: number;
16
- chunkRenderX?: number;
17
- chunkRenderY?: number;
18
- draggingOverDateCells?: boolean;
19
- dynamicDaysQuantity?: boolean;
20
- waitTimeForCalls?: number;
21
- callsOnScrollingMoves?: Function;
22
- callsOnScrollingStops?: Function;
23
- aditionalControlsComponents?: JSX.Element | JSX.Element[]
24
- upperLeftComponent?: JSX.Element
25
- }
26
-
27
- export interface RenderCoordinatesType {
28
- x: number;
29
- y: number;
30
- }
31
-
32
- export type ReactCellChildrenType = React.ElementType<CellChildrenPropsType>;
33
-
34
- export type ReactListElementChildrenType =
35
- React.ElementType<ListElementChildrenPropsType>;
36
-
37
- export type CellChildrenPropsType = { [key: string]: any } & {
38
- /**Date in SQL format, i.e. 1993-03-29 */
39
- date: string;
40
- listElementId: string | number;
41
- };
42
-
43
- export type ListElementChildrenPropsType = { [key: string]: any } & {
44
- listElementId: string | number;
45
- };
1
+ import { languageType } from "../../languages/types";
2
+
3
+ export interface MulticalendarPropsType {
4
+ multicalendarId: string;
5
+ ReactCellChildren: ReactCellChildrenType;
6
+ ReactListElementChildren: ReactListElementChildrenType;
7
+ listElementsIdsArray: string[] | number[];
8
+ language: languageType;
9
+ pastDatesVisible?: boolean
10
+ cellsWidth?: number;
11
+ cellsHeight?: number;
12
+ verticalAxisWidth?: number;
13
+ horizontalAxisHeight?: number;
14
+ pastDaysInitialQuantity?: number;
15
+ futureDaysInitialQuantity?: number;
16
+ chunkRenderX?: number;
17
+ chunkRenderY?: number;
18
+ draggingOverDateCells?: boolean;
19
+ dynamicDaysQuantity?: boolean;
20
+ waitTimeForCalls?: number;
21
+ callsOnScrollingMoves?: Function;
22
+ callsOnScrollingStops?: Function;
23
+ aditionalControlsComponents?: JSX.Element | JSX.Element[]
24
+ upperLeftComponent?: JSX.Element
25
+ }
26
+
27
+ export interface RenderCoordinatesType {
28
+ x: number;
29
+ y: number;
30
+ }
31
+
32
+ export type ReactCellChildrenType = React.ElementType<CellChildrenPropsType>;
33
+
34
+ export type ReactListElementChildrenType =
35
+ React.ElementType<ListElementChildrenPropsType>;
36
+
37
+ export type CellChildrenPropsType = { [key: string]: any } & {
38
+ /**Date in SQL format, i.e. 1993-03-29 */
39
+ date: string;
40
+ listElementId: string | number;
41
+ };
42
+
43
+ export type ListElementChildrenPropsType = { [key: string]: any } & {
44
+ listElementId: string | number;
45
+ };
@@ -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
+ }
@@ -1,50 +1,50 @@
1
- .side-bar {
2
- position: absolute;
3
- top: 0;
4
- height: 100%;
5
- z-index: 2;
6
- background-color: rgb(253, 253, 253);
7
- box-shadow: 5px 0px 15px 0px rgb(206 206 206);
8
- transition: all 0.5s ease-in-out;
9
- animation: fade-in-side-bar 1s ease-in;
10
- }
11
-
12
- .side-bar .sidebar-close-button {
13
- position: absolute;
14
- top: 0;
15
- height: 30px;
16
- width: 30px;
17
- background-color: transparent;
18
- border: none;
19
- outline: none;
20
- transition: all 0.3s;
21
- color: dimgray;
22
- font-size: 30px;
23
- display: flex;
24
- align-items: center;
25
- justify-content: center;
26
- cursor: pointer;
27
- }
28
-
29
- .side-bar .sidebar-close-button:hover {
30
- color: var(--primary-color);
31
- }
32
-
33
- .side-bar .sidebar-close-button svg.open{
34
- transform: rotate(0deg);
35
- transition: all 0.5s;
36
- }
37
-
38
- .side-bar .sidebar-close-button svg.close{
39
- transform: rotate(180deg);
40
- transition: all 0.5s;
41
- }
42
-
43
- @keyframes fade-in-side-bar {
44
- from {
45
- opacity: 0;
46
- }
47
- to {
48
- opacity: 1;
49
- }
50
- }
1
+ .side-bar {
2
+ position: absolute;
3
+ top: 0;
4
+ height: 100%;
5
+ z-index: 2;
6
+ background-color: rgb(253, 253, 253);
7
+ box-shadow: 5px 0px 15px 0px rgb(206 206 206);
8
+ transition: all 0.5s ease-in-out;
9
+ animation: fade-in-side-bar 1s ease-in;
10
+ }
11
+
12
+ .side-bar .sidebar-close-button {
13
+ position: absolute;
14
+ top: 0;
15
+ height: 30px;
16
+ width: 30px;
17
+ background-color: transparent;
18
+ border: none;
19
+ outline: none;
20
+ transition: all 0.3s;
21
+ color: dimgray;
22
+ font-size: 30px;
23
+ display: flex;
24
+ align-items: center;
25
+ justify-content: center;
26
+ cursor: pointer;
27
+ }
28
+
29
+ .side-bar .sidebar-close-button:hover {
30
+ color: var(--primary-color);
31
+ }
32
+
33
+ .side-bar .sidebar-close-button svg.open{
34
+ transform: rotate(0deg);
35
+ transition: all 0.5s;
36
+ }
37
+
38
+ .side-bar .sidebar-close-button svg.close{
39
+ transform: rotate(180deg);
40
+ transition: all 0.5s;
41
+ }
42
+
43
+ @keyframes fade-in-side-bar {
44
+ from {
45
+ opacity: 0;
46
+ }
47
+ to {
48
+ opacity: 1;
49
+ }
50
+ }
@@ -1,8 +1,8 @@
1
- /// <reference types="react" />
2
- import "./SideBar.css";
3
- import { SideBarPropsType } from "./types";
4
- /**
5
- * NOTE: Parent Node must have position: relative, to work correctly with the side bar
6
- */
7
- declare const SideBar: ({ side, open, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle, }: SideBarPropsType) => JSX.Element;
8
- export default SideBar;
1
+ /// <reference types="react" />
2
+ import "./SideBar.css";
3
+ import { SideBarPropsType } from "./types";
4
+ /**
5
+ * NOTE: Parent Node must have position: relative, to work correctly with the side bar
6
+ */
7
+ declare const SideBar: ({ side, open, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle, }: SideBarPropsType) => JSX.Element;
8
+ export default SideBar;
@@ -1,42 +1,42 @@
1
- import React, { useRef, useState } from "react";
2
- import "./SideBar.css";
3
- //Hooks
4
- import useOutsideClick from "../../hooks/useOutsideClick";
5
- import useResizeObserver from "../../hooks/useResizeObserver";
6
- //Icons
7
- import { BsChevronLeft, BsChevronRight } from "react-icons/bs";
8
- /**
9
- * NOTE: Parent Node must have position: relative, to work correctly with the side bar
10
- */
11
- const SideBar = ({ side, open = false, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle = {}, }) => {
12
- //Refs
13
- const sideBarRef = useRef(null);
14
- //Hooks
15
- const [elementWidth] = useResizeObserver(sideBarRef);
16
- useOutsideClick(sideBarRef, () => {
17
- if (outBoundClickClosesSideBar)
18
- if (closeAction) {
19
- closeAction();
20
- }
21
- else {
22
- setOpenState(false);
23
- }
24
- });
25
- //useState
26
- const [openState, setOpenState] = useState(open);
27
- return (React.createElement("div", { ref: sideBarRef, className: "side-bar", style: Object.assign({ [side === "left" ? "right" : "left"]: (closeAction && open) || (!closeAction && openState)
28
- ? `calc(100% - ${elementWidth}px)`
29
- : closeAction
30
- ? "100%"
31
- : `calc(100% - 30px)` }, aditionalInlineStyle) },
32
- React.createElement("button", { style: side === "left" ? { right: 0 } : { left: 0 }, className: "sidebar-close-button", onClick: () => {
33
- if (closeAction) {
34
- closeAction();
35
- }
36
- else {
37
- setOpenState(!openState);
38
- }
39
- } }, side === "left" ? (React.createElement(BsChevronLeft, { className: (closeAction && open) || (!closeAction && openState) ? "open" : "close" })) : (React.createElement(BsChevronRight, { className: (closeAction && open) || (!closeAction && openState) ? "open" : "close" }))),
40
- children));
41
- };
42
- export default SideBar;
1
+ import React, { useRef, useState } from "react";
2
+ import "./SideBar.css";
3
+ //Hooks
4
+ import useOutsideClick from "../../hooks/useOutsideClick";
5
+ import useResizeObserver from "../../hooks/useResizeObserver";
6
+ //Icons
7
+ import { BsChevronLeft, BsChevronRight } from "react-icons/bs";
8
+ /**
9
+ * NOTE: Parent Node must have position: relative, to work correctly with the side bar
10
+ */
11
+ const SideBar = ({ side, open = false, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle = {}, }) => {
12
+ //Refs
13
+ const sideBarRef = useRef(null);
14
+ //Hooks
15
+ const [elementWidth] = useResizeObserver(sideBarRef);
16
+ useOutsideClick(sideBarRef, () => {
17
+ if (outBoundClickClosesSideBar)
18
+ if (closeAction) {
19
+ closeAction();
20
+ }
21
+ else {
22
+ setOpenState(false);
23
+ }
24
+ });
25
+ //useState
26
+ const [openState, setOpenState] = useState(open);
27
+ return (React.createElement("div", { ref: sideBarRef, className: "side-bar", style: Object.assign({ [side === "left" ? "right" : "left"]: (closeAction && open) || (!closeAction && openState)
28
+ ? `calc(100% - ${elementWidth}px)`
29
+ : closeAction
30
+ ? "100%"
31
+ : `calc(100% - 30px)` }, aditionalInlineStyle) },
32
+ React.createElement("button", { style: side === "left" ? { right: 0 } : { left: 0 }, className: "sidebar-close-button", onClick: () => {
33
+ if (closeAction) {
34
+ closeAction();
35
+ }
36
+ else {
37
+ setOpenState(!openState);
38
+ }
39
+ } }, side === "left" ? (React.createElement(BsChevronLeft, { className: (closeAction && open) || (!closeAction && openState) ? "open" : "close" })) : (React.createElement(BsChevronRight, { className: (closeAction && open) || (!closeAction && openState) ? "open" : "close" }))),
40
+ children));
41
+ };
42
+ export default SideBar;
@@ -1,8 +1,8 @@
1
- export interface SideBarPropsType {
2
- side: "left" | "right";
3
- children: JSX.Element | JSX.Element[];
4
- open: boolean;
5
- closeAction?: Function;
6
- outBoundClickClosesSideBar?: boolean;
7
- aditionalInlineStyle?: React.CSSProperties;
8
- }
1
+ export interface SideBarPropsType {
2
+ side: "left" | "right";
3
+ children: JSX.Element | JSX.Element[];
4
+ open: boolean;
5
+ closeAction?: Function;
6
+ outBoundClickClosesSideBar?: boolean;
7
+ aditionalInlineStyle?: React.CSSProperties;
8
+ }
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
- /**
3
- * Hook that alerts clicks outside of the passed ref
4
- */
5
- declare function useOutsideClick(elementRef: React.MutableRefObject<HTMLElement | null>, onOutsideClickAction: Function): void;
6
- export default useOutsideClick;
1
+ /// <reference types="react" />
2
+ /**
3
+ * Hook that alerts clicks outside of the passed ref
4
+ */
5
+ declare function useOutsideClick(elementRef: React.MutableRefObject<HTMLElement | null>, onOutsideClickAction: Function): void;
6
+ export default useOutsideClick;
@@ -1,23 +1,23 @@
1
- import { useEffect } from "react";
2
- /**
3
- * Hook that alerts clicks outside of the passed ref
4
- */
5
- function useOutsideClick(elementRef, onOutsideClickAction) {
6
- useEffect(() => {
7
- /**
8
- * Alert if clicked on outside of element
9
- */
10
- function handleClickOutside(event) {
11
- if (elementRef.current && !elementRef.current.contains(event.target)) {
12
- onOutsideClickAction();
13
- }
14
- }
15
- // Bind the event listener
16
- document.addEventListener("mousedown", handleClickOutside);
17
- return () => {
18
- // Unbind the event listener on clean up
19
- document.removeEventListener("mousedown", handleClickOutside);
20
- };
21
- }, [elementRef, onOutsideClickAction]);
22
- }
23
- export default useOutsideClick;
1
+ import { useEffect } from "react";
2
+ /**
3
+ * Hook that alerts clicks outside of the passed ref
4
+ */
5
+ function useOutsideClick(elementRef, onOutsideClickAction) {
6
+ useEffect(() => {
7
+ /**
8
+ * Alert if clicked on outside of element
9
+ */
10
+ function handleClickOutside(event) {
11
+ if (elementRef.current && !elementRef.current.contains(event.target)) {
12
+ onOutsideClickAction();
13
+ }
14
+ }
15
+ // Bind the event listener
16
+ document.addEventListener("mousedown", handleClickOutside);
17
+ return () => {
18
+ // Unbind the event listener on clean up
19
+ document.removeEventListener("mousedown", handleClickOutside);
20
+ };
21
+ }, [elementRef, onOutsideClickAction]);
22
+ }
23
+ export default useOutsideClick;
@@ -1,7 +1,7 @@
1
- import React from "react";
2
- /**
3
- * @returns Array [elementWidth, elementHeight], that represent the current
4
- * values of width and height of elementRef
5
- */
6
- declare function useResizeObserver(elementRef: React.MutableRefObject<HTMLElement | null>): number[];
7
- export default useResizeObserver;
1
+ import React from "react";
2
+ /**
3
+ * @returns Array [elementWidth, elementHeight], that represent the current
4
+ * values of width and height of elementRef
5
+ */
6
+ declare function useResizeObserver(elementRef: React.MutableRefObject<HTMLElement | null>): number[];
7
+ export default useResizeObserver;
@@ -1,28 +1,28 @@
1
- import { useState, useRef, useEffect } from "react";
2
- /**
3
- * @returns Array [elementWidth, elementHeight], that represent the current
4
- * values of width and height of elementRef
5
- */
6
- function useResizeObserver(elementRef) {
7
- const [elementWidth, setElementWidth] = useState(0);
8
- const [elementHeight, setElementHeight] = useState(0);
9
- const observer = useRef(new ResizeObserver((entries) => {
10
- const { width, height } = entries[0].contentRect;
11
- setElementWidth(width);
12
- setElementHeight(height);
13
- }));
14
- useEffect(() => {
15
- if (elementRef.current !== null) {
16
- observer.current.observe(elementRef.current);
17
- }
18
- const observerCurrentForCleanUp = observer.current;
19
- const elementRefCurrentForCleanUp = elementRef.current;
20
- return () => {
21
- if (elementRefCurrentForCleanUp !== null) {
22
- observerCurrentForCleanUp.unobserve(elementRefCurrentForCleanUp);
23
- }
24
- };
25
- }, [elementRef, observer]);
26
- return [elementWidth, elementHeight];
27
- }
28
- export default useResizeObserver;
1
+ import { useState, useRef, useEffect } from "react";
2
+ /**
3
+ * @returns Array [elementWidth, elementHeight], that represent the current
4
+ * values of width and height of elementRef
5
+ */
6
+ function useResizeObserver(elementRef) {
7
+ const [elementWidth, setElementWidth] = useState(0);
8
+ const [elementHeight, setElementHeight] = useState(0);
9
+ const observer = useRef(new ResizeObserver((entries) => {
10
+ const { width, height } = entries[0].contentRect;
11
+ setElementWidth(width);
12
+ setElementHeight(height);
13
+ }));
14
+ useEffect(() => {
15
+ if (elementRef.current !== null) {
16
+ observer.current.observe(elementRef.current);
17
+ }
18
+ const observerCurrentForCleanUp = observer.current;
19
+ const elementRefCurrentForCleanUp = elementRef.current;
20
+ return () => {
21
+ if (elementRefCurrentForCleanUp !== null) {
22
+ observerCurrentForCleanUp.unobserve(elementRefCurrentForCleanUp);
23
+ }
24
+ };
25
+ }, [elementRef, observer]);
26
+ return [elementWidth, elementHeight];
27
+ }
28
+ export default useResizeObserver;
@@ -1,6 +1,6 @@
1
- /**
2
- * @returns Array [ancho, alto], de dichos valores refieren
3
- * los valores de window.innerWidth y window.innerHeight
4
- */
5
- declare function useWindowSize(): [number, number];
6
- export default useWindowSize;
1
+ /**
2
+ * @returns Array [ancho, alto], de dichos valores refieren
3
+ * los valores de window.innerWidth y window.innerHeight
4
+ */
5
+ declare function useWindowSize(): [number, number];
6
+ export default useWindowSize;
@@ -1,18 +1,18 @@
1
- import { useLayoutEffect, useState } from "react";
2
- /**
3
- * @returns Array [ancho, alto], de dichos valores refieren
4
- * los valores de window.innerWidth y window.innerHeight
5
- */
6
- function useWindowSize() {
7
- const [size, setSize] = useState([0, 0]);
8
- useLayoutEffect(() => {
9
- function updateSize() {
10
- setSize([window.innerWidth, window.innerHeight]);
11
- }
12
- window.addEventListener("resize", updateSize);
13
- updateSize();
14
- return () => window.removeEventListener("resize", updateSize);
15
- }, []);
16
- return size;
17
- }
18
- export default useWindowSize;
1
+ import { useLayoutEffect, useState } from "react";
2
+ /**
3
+ * @returns Array [ancho, alto], de dichos valores refieren
4
+ * los valores de window.innerWidth y window.innerHeight
5
+ */
6
+ function useWindowSize() {
7
+ const [size, setSize] = useState([0, 0]);
8
+ useLayoutEffect(() => {
9
+ function updateSize() {
10
+ setSize([window.innerWidth, window.innerHeight]);
11
+ }
12
+ window.addEventListener("resize", updateSize);
13
+ updateSize();
14
+ return () => window.removeEventListener("resize", updateSize);
15
+ }, []);
16
+ return size;
17
+ }
18
+ export default useWindowSize;