@tecsinapse/cortex-react 1.2.2 → 1.3.0-beta.1

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 (176) hide show
  1. package/dist/cjs/components/Avatar.js +3 -2
  2. package/dist/cjs/components/BaseSnackbar.js +13 -0
  3. package/dist/cjs/components/BreadcrumbItem.js +2 -1
  4. package/dist/cjs/components/Breadcrumbs.js +1 -1
  5. package/dist/cjs/components/Button.js +10 -1
  6. package/dist/cjs/components/Calendar.js +23 -0
  7. package/dist/cjs/components/CalendarCell.js +51 -0
  8. package/dist/cjs/components/CalendarGrid.js +23 -0
  9. package/dist/cjs/components/CalendarGridBodyRows.js +12 -0
  10. package/dist/cjs/components/CalendarGridHeaderRow.js +12 -0
  11. package/dist/cjs/components/CalendarHeader.js +40 -0
  12. package/dist/cjs/components/Card.js +1 -1
  13. package/dist/cjs/components/DateField.js +25 -0
  14. package/dist/cjs/components/DatePickerInput.js +48 -0
  15. package/dist/cjs/components/DatePickerInputBase.js +24 -0
  16. package/dist/cjs/components/DateRangePickerInput.js +62 -0
  17. package/dist/cjs/components/DateSegment.js +20 -0
  18. package/dist/cjs/components/DefaultSnack.js +27 -0
  19. package/dist/cjs/components/Drawer.js +3 -1
  20. package/dist/cjs/components/GroupButton.js +43 -0
  21. package/dist/cjs/components/Input.js +5 -3
  22. package/dist/cjs/components/Modal.js +6 -13
  23. package/dist/cjs/components/ProgressBar.js +71 -0
  24. package/dist/cjs/components/RangeCalendar.js +36 -0
  25. package/dist/cjs/components/SearchInput.js +21 -10
  26. package/dist/cjs/components/Select.js +4 -4
  27. package/dist/cjs/components/Skeleton.js +4 -1
  28. package/dist/cjs/components/Table.js +9 -15
  29. package/dist/cjs/components/TextArea.js +2 -0
  30. package/dist/cjs/components/TimeField.js +12 -0
  31. package/dist/cjs/components/TimeFieldInput.js +22 -0
  32. package/dist/cjs/components/Toggle.js +17 -9
  33. package/dist/cjs/components/utils.js +19 -4
  34. package/dist/cjs/hooks/useCalendar.js +24 -0
  35. package/dist/cjs/hooks/useCalendarCell.js +35 -0
  36. package/dist/cjs/hooks/useCalendarGrid.js +14 -0
  37. package/dist/cjs/hooks/useDatePickerInput.js +31 -0
  38. package/dist/cjs/hooks/useDateRangePickerInput.js +33 -0
  39. package/dist/cjs/hooks/useRangeCalendar.js +36 -0
  40. package/dist/cjs/hooks/useTimeField.js +32 -0
  41. package/dist/cjs/index.js +47 -16
  42. package/dist/cjs/service/SnackbarSonner.js +55 -0
  43. package/dist/cjs/styles/calendar-cell.js +40 -0
  44. package/dist/cjs/styles/groupButton.js +16 -0
  45. package/dist/cjs/styles/progressBar.js +21 -0
  46. package/dist/esm/components/Avatar.js +4 -3
  47. package/dist/esm/components/BaseSnackbar.js +11 -0
  48. package/dist/esm/components/BreadcrumbItem.js +2 -1
  49. package/dist/esm/components/Breadcrumbs.js +1 -1
  50. package/dist/esm/components/Button.js +10 -1
  51. package/dist/esm/components/Calendar.js +21 -0
  52. package/dist/esm/components/CalendarCell.js +49 -0
  53. package/dist/esm/components/CalendarGrid.js +21 -0
  54. package/dist/esm/components/CalendarGridBodyRows.js +10 -0
  55. package/dist/esm/components/CalendarGridHeaderRow.js +10 -0
  56. package/dist/esm/components/CalendarHeader.js +38 -0
  57. package/dist/esm/components/Card.js +1 -1
  58. package/dist/esm/components/DateField.js +23 -0
  59. package/dist/esm/components/DatePickerInput.js +46 -0
  60. package/dist/esm/components/DatePickerInputBase.js +22 -0
  61. package/dist/esm/components/DateRangePickerInput.js +60 -0
  62. package/dist/esm/components/DateSegment.js +18 -0
  63. package/dist/esm/components/DefaultSnack.js +25 -0
  64. package/dist/esm/components/Drawer.js +3 -1
  65. package/dist/esm/components/GroupButton.js +41 -0
  66. package/dist/esm/components/Input.js +5 -3
  67. package/dist/esm/components/Modal.js +6 -13
  68. package/dist/esm/components/ProgressBar.js +69 -0
  69. package/dist/esm/components/RangeCalendar.js +34 -0
  70. package/dist/esm/components/SearchInput.js +21 -10
  71. package/dist/esm/components/Select.js +4 -4
  72. package/dist/esm/components/Skeleton.js +4 -1
  73. package/dist/esm/components/Table.js +10 -15
  74. package/dist/esm/components/TextArea.js +2 -0
  75. package/dist/esm/components/TimeField.js +10 -0
  76. package/dist/esm/components/TimeFieldInput.js +20 -0
  77. package/dist/esm/components/Toggle.js +17 -9
  78. package/dist/esm/components/utils.js +17 -4
  79. package/dist/esm/hooks/useCalendar.js +22 -0
  80. package/dist/esm/hooks/useCalendarCell.js +33 -0
  81. package/dist/esm/hooks/useCalendarGrid.js +12 -0
  82. package/dist/esm/hooks/useDatePickerInput.js +29 -0
  83. package/dist/esm/hooks/useDateRangePickerInput.js +31 -0
  84. package/dist/esm/hooks/useRangeCalendar.js +34 -0
  85. package/dist/esm/hooks/useTimeField.js +30 -0
  86. package/dist/esm/index.js +23 -7
  87. package/dist/esm/service/SnackbarSonner.js +53 -0
  88. package/dist/esm/styles/calendar-cell.js +38 -0
  89. package/dist/esm/styles/groupButton.js +14 -0
  90. package/dist/esm/styles/progressBar.js +19 -0
  91. package/dist/types/components/BaseSnackbar.d.ts +9 -0
  92. package/dist/types/components/BreadcrumbItem.d.ts +1 -3
  93. package/dist/types/components/Calendar.d.ts +6 -0
  94. package/dist/types/components/CalendarCell.d.ts +8 -0
  95. package/dist/types/components/CalendarGrid.d.ts +6 -0
  96. package/dist/types/components/CalendarGridBodyRows.d.ts +6 -0
  97. package/dist/types/components/CalendarGridHeaderRow.d.ts +5 -0
  98. package/dist/types/components/CalendarHeader.d.ts +6 -0
  99. package/dist/types/components/DateField.d.ts +5 -0
  100. package/dist/types/components/DatePickerInput.d.ts +6 -0
  101. package/dist/types/components/DatePickerInputBase.d.ts +8 -0
  102. package/dist/types/components/DateRangePickerInput.d.ts +7 -0
  103. package/dist/types/components/DateSegment.d.ts +7 -0
  104. package/dist/types/components/DefaultSnack.d.ts +6 -0
  105. package/dist/types/components/Drawer.d.ts +1 -1
  106. package/dist/types/components/GroupButton.d.ts +19 -0
  107. package/dist/types/components/Input.d.ts +2 -2
  108. package/dist/types/components/Modal.d.ts +2 -2
  109. package/dist/types/components/ProgressBar.d.ts +9 -0
  110. package/dist/types/components/RangeCalendar.d.ts +10 -0
  111. package/dist/types/components/SearchInput.d.ts +0 -1
  112. package/dist/types/components/Select.d.ts +0 -1
  113. package/dist/types/components/Skeleton.d.ts +4 -2
  114. package/dist/types/components/Table.d.ts +0 -1
  115. package/dist/types/components/TimeField.d.ts +7 -0
  116. package/dist/types/components/TimeFieldInput.d.ts +10 -0
  117. package/dist/types/components/index.d.ts +15 -7
  118. package/dist/types/components/utils.d.ts +4 -1
  119. package/dist/types/hooks/index.d.ts +6 -0
  120. package/dist/types/hooks/useCalendar.d.ts +10 -0
  121. package/dist/types/hooks/useCalendarCell.d.ts +18 -0
  122. package/dist/types/hooks/useCalendarGrid.d.ts +10 -0
  123. package/dist/types/hooks/useDatePickerInput.d.ts +10 -0
  124. package/dist/types/hooks/useDateRangePickerInput.d.ts +12 -0
  125. package/dist/types/hooks/useRangeCalendar.d.ts +12 -0
  126. package/dist/types/hooks/useTimeField.d.ts +7 -0
  127. package/dist/types/index.d.ts +2 -0
  128. package/dist/types/provider/SnackbarProvider.d.ts +10 -0
  129. package/dist/types/service/ISnackbar.d.ts +7 -0
  130. package/dist/types/service/SnackbarSonner.d.ts +7 -0
  131. package/dist/types/service/index.d.ts +2 -0
  132. package/dist/types/styles/calendar-cell.d.ts +199 -0
  133. package/dist/types/styles/groupButton.d.ts +77 -0
  134. package/dist/types/styles/index.d.ts +3 -0
  135. package/dist/types/styles/progressBar.d.ts +78 -0
  136. package/dist/types/tests/Avatar.test.d.ts +1 -0
  137. package/dist/types/tests/Badge.test.d.ts +1 -0
  138. package/dist/types/tests/BreadcrumbItem.test.d.ts +1 -0
  139. package/dist/types/tests/Breadcrumbs.test.d.ts +1 -0
  140. package/dist/types/tests/Button.test.d.ts +1 -0
  141. package/dist/types/tests/Calendar.test.d.ts +1 -0
  142. package/dist/types/tests/CalendarCell.test.d.ts +1 -0
  143. package/dist/types/tests/CalendarGridBodyRows.test.d.ts +1 -0
  144. package/dist/types/tests/CalendarGridHeaderRow.test.d.ts +1 -0
  145. package/dist/types/tests/CalendarHeader.test.d.ts +1 -0
  146. package/dist/types/tests/Card.test.d.ts +1 -0
  147. package/dist/types/tests/DateField.test.d.ts +1 -0
  148. package/dist/types/tests/DatePickerInput.test.d.ts +1 -0
  149. package/dist/types/tests/DatePickerInputBase.test.d.ts +1 -0
  150. package/dist/types/tests/DateRangePickerInput.test.d.ts +1 -0
  151. package/dist/types/tests/DateSegment.test.d.ts +1 -0
  152. package/dist/types/tests/DefaultSnack.test.d.ts +1 -0
  153. package/dist/types/tests/Drawer.test.d.ts +1 -0
  154. package/dist/types/tests/GroupButton.test.d.ts +1 -0
  155. package/dist/types/tests/Hint.test.d.ts +1 -0
  156. package/dist/types/tests/Input.test.d.ts +1 -0
  157. package/dist/types/tests/Modal.test.d.ts +1 -0
  158. package/dist/types/tests/ProgressBar.test.d.ts +1 -0
  159. package/dist/types/tests/RangeCalendar.test.d.ts +1 -0
  160. package/dist/types/tests/SearchInput.test.d.ts +1 -0
  161. package/dist/types/tests/Select.test.d.ts +1 -0
  162. package/dist/types/tests/Skeleton.test.d.ts +1 -0
  163. package/dist/types/tests/Snackbar.test.d.ts +1 -0
  164. package/dist/types/tests/Table.test.d.ts +1 -0
  165. package/dist/types/tests/Tag.test.d.ts +1 -0
  166. package/dist/types/tests/TextArea.test.d.ts +1 -0
  167. package/dist/types/tests/TimeField.test.d.ts +1 -0
  168. package/dist/types/tests/TimeFieldInput.test.d.ts +1 -0
  169. package/dist/types/tests/Toggle.test.d.ts +1 -0
  170. package/dist/types/tests/useCalendarCell.test.d.ts +1 -0
  171. package/dist/types/tests/useDebouncedState.test.d.ts +1 -0
  172. package/dist/types/tests/utils.test.d.ts +1 -0
  173. package/package.json +10 -5
  174. package/dist/cjs/components/Snackbar.js +0 -18
  175. package/dist/esm/components/Snackbar.js +0 -16
  176. package/dist/types/components/Snackbar.d.ts +0 -9
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var sonner = require('sonner');
4
+ var React = require('react');
5
+ require('clsx');
6
+ require('@internationalized/date');
7
+ require('../components/Badge.js');
8
+ require('../components/BaseSnackbar.js');
9
+ require('react-icons/md');
10
+ require('../components/Card.js');
11
+ require('../components/Button.js');
12
+ require('react-aria');
13
+ require('react-stately');
14
+ require('../components/CalendarCell.js');
15
+ require('@tecsinapse/cortex-core');
16
+ require('react-icons/fa');
17
+ require('react-icons/lia');
18
+ require('../components/Input.js');
19
+ var DefaultSnack = require('../components/DefaultSnack.js');
20
+ require('../components/GroupButton.js');
21
+ require('../components/Hint.js');
22
+ require('../components/Modal.js');
23
+ require('../styles/calendar-cell.js');
24
+ require('../styles/groupButton.js');
25
+ require('../styles/progressBar.js');
26
+ require('../components/Select.js');
27
+ require('../components/Tag.js');
28
+ require('../components/TextArea.js');
29
+ require('../components/Toggle.js');
30
+
31
+ class SnackbarSonner {
32
+ custom(Component, options) {
33
+ return sonner.toast.custom(() => Component, {
34
+ ...options,
35
+ duration: options?.duration ?? 5e3
36
+ });
37
+ }
38
+ show(type, message, options) {
39
+ return sonner.toast.custom(
40
+ (t) => {
41
+ return /* @__PURE__ */ React.createElement(
42
+ DefaultSnack.DefaultSnack,
43
+ {
44
+ text: message,
45
+ variants: { intent: type },
46
+ onDismiss: () => sonner.toast.dismiss(t)
47
+ }
48
+ );
49
+ },
50
+ { ...options, duration: options?.duration ?? 5e3 }
51
+ );
52
+ }
53
+ }
54
+
55
+ exports.SnackbarSonner = SnackbarSonner;
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ var tailwindVariants = require('tailwind-variants');
4
+
5
+ const calendarCell = tailwindVariants.tv({
6
+ slots: {
7
+ cell: "text-center rounded-mili text-black hover:bg-primary-light",
8
+ button: "flex aspect-square items-center justify-center"
9
+ },
10
+ variants: {
11
+ isSelected: {
12
+ true: {
13
+ cell: "bg-primary-medium text-white hover:bg-primary-medium"
14
+ }
15
+ },
16
+ isSelectionStart: {
17
+ true: {
18
+ cell: "bg-primary-medium rounded-r-none text-white"
19
+ }
20
+ },
21
+ isSelectionEnd: {
22
+ true: {
23
+ cell: "bg-primary-medium rounded-l-none text-white"
24
+ }
25
+ },
26
+ inRange: {
27
+ true: {
28
+ cell: "bg-primary-light rounded-none text-black"
29
+ }
30
+ },
31
+ isOutsideVisibleRange: {
32
+ true: {
33
+ cell: "text-secondary-light cursor-default hover:bg-white-500",
34
+ button: "cursor-default"
35
+ }
36
+ }
37
+ }
38
+ });
39
+
40
+ exports.calendarCell = calendarCell;
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var tailwindVariants = require('tailwind-variants');
4
+
5
+ const groupButton = tailwindVariants.tv({
6
+ slots: {
7
+ button: "border-[1px] border-secondary-medium px-centi py-mili items-center flex text-sub font-bold",
8
+ inactive: "bg-white text-secondary-medium disabled:bg-secondary-light",
9
+ firstButton: "first:rounded-l-mili first:border-r-0",
10
+ lastButton: "last:rounded-r-mili last:border-l-0",
11
+ container: "flex flex-row flex-1 h-[2rem] w-[500px]",
12
+ active: "text-white bg-secondary-medium"
13
+ }
14
+ });
15
+
16
+ exports.groupButton = groupButton;
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ var tailwindVariants = require('tailwind-variants');
4
+
5
+ const progressBarFilled = tailwindVariants.tv({
6
+ base: "h-full first:rounded-l-pill last:rounded-r-pill",
7
+ variants: {
8
+ intentProgress: {
9
+ default: "bg-primary-medium",
10
+ error: "bg-error-medium",
11
+ info: "bg-info-medium",
12
+ warning: "bg-warning-medium",
13
+ success: "bg-success-medium"
14
+ },
15
+ showAnimation: {
16
+ true: "transition-[width] duration-1000 ease-linear"
17
+ }
18
+ }
19
+ });
20
+
21
+ exports.progressBarFilled = progressBarFilled;
@@ -1,6 +1,6 @@
1
1
  import clsx from 'clsx';
2
2
  import React from 'react';
3
- import { getInitialsName } from './utils.js';
3
+ import { getNameInitials } from './utils.js';
4
4
 
5
5
  const Avatar = ({ src, name, className, ...rest }) => {
6
6
  const [hasError, setHasError] = React.useState(false);
@@ -22,9 +22,10 @@ const Avatar = ({ src, name, className, ...rest }) => {
22
22
  src,
23
23
  alt: name,
24
24
  className: "rounded-pill",
25
- onError: () => setHasError(true)
25
+ onError: () => setHasError(true),
26
+ "data-testid": "avatar-img"
26
27
  }
27
- ) : /* @__PURE__ */ React.createElement("p", { className: "font-bold text-white text-base" }, getInitialsName(name))
28
+ ) : /* @__PURE__ */ React.createElement("p", { className: "font-bold text-white text-base", "data-testid": "avatar-p" }, getNameInitials(name))
28
29
  );
29
30
  };
30
31
 
@@ -0,0 +1,11 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { snackbar } from '@tecsinapse/cortex-core';
3
+
4
+ const BaseSnackbar = forwardRef(
5
+ (props, ref) => {
6
+ const { children, show, variants } = props;
7
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, show ? /* @__PURE__ */ React.createElement("div", { className: snackbar(variants), ref, "data-testid": "snackbar" }, children) : /* @__PURE__ */ React.createElement(React.Fragment, null));
8
+ }
9
+ );
10
+
11
+ export { BaseSnackbar };
@@ -16,7 +16,8 @@ const BreadcrumbItem = ({
16
16
  ), !isLast ? /* @__PURE__ */ React.createElement(
17
17
  MdOutlineKeyboardDoubleArrowRight,
18
18
  {
19
- className: "mt-[0.125rem] text-primary-medium"
19
+ className: "mt-[0.125rem] text-primary-medium",
20
+ "data-testid": "breadcrumb-item-icon"
20
21
  }
21
22
  ) : /* @__PURE__ */ React.createElement(React.Fragment, null)));
22
23
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { Card } from './Card.js';
3
2
  import { BreadcrumbItem } from './BreadcrumbItem.js';
3
+ import { Card } from './Card.js';
4
4
 
5
5
  const Breadcrumbs = (props) => {
6
6
  const { breadcrumbs, ...rest } = props;
@@ -3,7 +3,16 @@ import { button } from '@tecsinapse/cortex-core';
3
3
 
4
4
  const Button = forwardRef((props, ref) => {
5
5
  const { variants, children, ...rest } = props;
6
- return /* @__PURE__ */ React.createElement("button", { className: button(variants), ref, ...rest }, children);
6
+ return /* @__PURE__ */ React.createElement(
7
+ "button",
8
+ {
9
+ className: button(variants),
10
+ ref,
11
+ "data-testid": "button",
12
+ ...rest
13
+ },
14
+ children
15
+ );
7
16
  });
8
17
 
9
18
  export { Button };
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { useCalendar } from '../hooks/useCalendar.js';
3
+ import '@internationalized/date';
4
+ import 'react-aria';
5
+ import 'react-stately';
6
+ import { CalendarGrid } from './CalendarGrid.js';
7
+ import { CalendarHeader } from './CalendarHeader.js';
8
+
9
+ const Calendar = ({ value, onChange }) => {
10
+ const { calendarProps, title, state } = useCalendar({ value, onChange });
11
+ return /* @__PURE__ */ React.createElement("div", { ...calendarProps, className: "calendar", "data-testid": "calendar-div" }, /* @__PURE__ */ React.createElement(
12
+ CalendarHeader,
13
+ {
14
+ onClickPrevButton: () => state.focusPreviousPage(),
15
+ onClickNextButton: () => state.focusNextPage(),
16
+ title
17
+ }
18
+ ), /* @__PURE__ */ React.createElement(CalendarGrid, { state }));
19
+ };
20
+
21
+ export { Calendar };
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import '@internationalized/date';
3
+ import 'react-aria';
4
+ import 'react-stately';
5
+ import { useCalendarCell } from '../hooks/useCalendarCell.js';
6
+ import { calendarCell } from '../styles/calendar-cell.js';
7
+ import '../styles/groupButton.js';
8
+ import '../styles/progressBar.js';
9
+ import { Td } from './Table.js';
10
+
11
+ const { cell, button } = calendarCell();
12
+ const CalendarCell = ({ state, date }) => {
13
+ const {
14
+ ref,
15
+ cellProps,
16
+ buttonProps,
17
+ isSelected,
18
+ isOutsideVisibleRange,
19
+ formattedDate,
20
+ isSelectionStart,
21
+ isSelectionEnd,
22
+ inRange
23
+ } = useCalendarCell({ state, date });
24
+ return /* @__PURE__ */ React.createElement(
25
+ Td,
26
+ {
27
+ ...cellProps,
28
+ "data-testid": "calendar-cell-td",
29
+ className: cell({
30
+ isOutsideVisibleRange,
31
+ isSelected,
32
+ isSelectionStart,
33
+ isSelectionEnd,
34
+ inRange
35
+ })
36
+ },
37
+ /* @__PURE__ */ React.createElement(
38
+ "div",
39
+ {
40
+ ...buttonProps,
41
+ ref,
42
+ className: button({ isOutsideVisibleRange })
43
+ },
44
+ formattedDate
45
+ )
46
+ );
47
+ };
48
+
49
+ export { CalendarCell };
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import '@internationalized/date';
3
+ import 'react-aria';
4
+ import 'react-stately';
5
+ import { useCalendarGrid } from '../hooks/useCalendarGrid.js';
6
+ import { CalendarGridBodyRows } from './CalendarGridBodyRows.js';
7
+ import { CalendarGridHeaderRow } from './CalendarGridHeaderRow.js';
8
+
9
+ const CalendarGrid = ({ state }) => {
10
+ const { gridProps, headerProps, weekDays } = useCalendarGrid({ state });
11
+ return /* @__PURE__ */ React.createElement(
12
+ "div",
13
+ {
14
+ className: "bg-white rounded-micro px-deca py-mili",
15
+ "data-testid": "calendar-grid"
16
+ },
17
+ /* @__PURE__ */ React.createElement("table", { ...gridProps, className: "border-separate border-spacing-y-nano" }, /* @__PURE__ */ React.createElement("thead", { ...headerProps }, /* @__PURE__ */ React.createElement(CalendarGridHeaderRow, { weekDays })), /* @__PURE__ */ React.createElement("tbody", null, /* @__PURE__ */ React.createElement(CalendarGridBodyRows, { state })))
18
+ );
19
+ };
20
+
21
+ export { CalendarGrid };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { CalendarCell } from './CalendarCell.js';
3
+
4
+ const CalendarGridBodyRows = ({ state }) => {
5
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, [...new Array(6).keys()].map((weekIndex) => /* @__PURE__ */ React.createElement("tr", { key: weekIndex, className: "shadow-0 px-deca" }, state.getDatesInWeek(weekIndex).map((date, i) => {
6
+ return date ? /* @__PURE__ */ React.createElement(CalendarCell, { key: i, state, date }) : /* @__PURE__ */ React.createElement("td", { key: i });
7
+ }))));
8
+ };
9
+
10
+ export { CalendarGridBodyRows };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { THeadCell } from './Table.js';
3
+
4
+ const CalendarGridHeaderRow = ({
5
+ weekDays
6
+ }) => {
7
+ return /* @__PURE__ */ React.createElement("tr", { "data-testid": "calendar-grid-header-row" }, weekDays.map((day, index) => /* @__PURE__ */ React.createElement(THeadCell, { key: index }, day)));
8
+ };
9
+
10
+ export { CalendarGridHeaderRow };
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { FaChevronLeft, FaChevronRight } from 'react-icons/fa';
3
+ import { Button } from './Button.js';
4
+
5
+ const CalendarHeader = ({
6
+ onClickPrevButton,
7
+ onClickNextButton,
8
+ title
9
+ }) => {
10
+ return /* @__PURE__ */ React.createElement(
11
+ "div",
12
+ {
13
+ className: "flex flex-row justify-between items-center gap-x-deca bg-miscellaneous-body p-mili",
14
+ "data-testid": "calendar-header"
15
+ },
16
+ /* @__PURE__ */ React.createElement(
17
+ Button,
18
+ {
19
+ onClick: onClickPrevButton,
20
+ variants: { variant: "text", intent: "secondary", size: "small" },
21
+ "data-testid": "calendar-header-prev-button"
22
+ },
23
+ /* @__PURE__ */ React.createElement(FaChevronLeft, null)
24
+ ),
25
+ /* @__PURE__ */ React.createElement("span", { className: "font-bold capitalize" }, title),
26
+ /* @__PURE__ */ React.createElement(
27
+ Button,
28
+ {
29
+ onClick: onClickNextButton,
30
+ variants: { variant: "text", intent: "secondary", size: "small" },
31
+ "data-testid": "calendar-header-next-button"
32
+ },
33
+ /* @__PURE__ */ React.createElement(FaChevronRight, null)
34
+ )
35
+ );
36
+ };
37
+
38
+ export { CalendarHeader };
@@ -1,5 +1,5 @@
1
- import React, { forwardRef } from 'react';
2
1
  import { card } from '@tecsinapse/cortex-core';
2
+ import React, { forwardRef } from 'react';
3
3
 
4
4
  const Card = forwardRef((props, ref) => {
5
5
  const { children, className, ...rest } = props;
@@ -0,0 +1,23 @@
1
+ import { createCalendar } from '@internationalized/date';
2
+ import React from 'react';
3
+ import { useLocale, useDateField } from 'react-aria';
4
+ import { useDateFieldState } from 'react-stately';
5
+ import { DateSegment } from './DateSegment.js';
6
+
7
+ const DateField = (props) => {
8
+ const { locale } = useLocale();
9
+ const state = useDateFieldState({
10
+ ...props,
11
+ createCalendar,
12
+ locale
13
+ });
14
+ const ref = React.useRef(null);
15
+ const { fieldProps } = useDateField(
16
+ { "aria-label": "date-field" },
17
+ state,
18
+ ref
19
+ );
20
+ return /* @__PURE__ */ React.createElement("div", { ...fieldProps, ref, className: "flex flex-row" }, state.segments.map((segment, i) => /* @__PURE__ */ React.createElement(DateSegment, { key: i, segment, state })));
21
+ };
22
+
23
+ export { DateField };
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import '@internationalized/date';
3
+ import 'react-aria';
4
+ import 'react-stately';
5
+ import { dateToCalendarDate } from './utils.js';
6
+ import { useDatePickerInput } from '../hooks/useDatePickerInput.js';
7
+ import { Calendar } from './Calendar.js';
8
+ import { DateField } from './DateField.js';
9
+ import { DatePickerInputBase } from './DatePickerInputBase.js';
10
+
11
+ const DatePickerInput = (props) => {
12
+ const { onChange, value, label, variants } = props;
13
+ const { fieldProps, state, ref } = useDatePickerInput({ value, onChange });
14
+ return /* @__PURE__ */ React.createElement("div", { "data-testid": "date-picker-input" }, /* @__PURE__ */ React.createElement(
15
+ DatePickerInputBase,
16
+ {
17
+ onClickCalendar: () => state.isOpen ? state.close() : state.open(),
18
+ variants: {
19
+ ...variants,
20
+ intent: state.isInvalid ? "error" : variants?.intent
21
+ },
22
+ label
23
+ },
24
+ /* @__PURE__ */ React.createElement("div", { ref }, /* @__PURE__ */ React.createElement(
25
+ DateField,
26
+ {
27
+ ...fieldProps,
28
+ onChange: (value2) => {
29
+ state.setDateValue(value2);
30
+ state.close();
31
+ }
32
+ }
33
+ ))
34
+ ), state.isOpen ? /* @__PURE__ */ React.createElement("div", { className: "absolute" }, /* @__PURE__ */ React.createElement(
35
+ Calendar,
36
+ {
37
+ value,
38
+ onChange: (value2) => {
39
+ state.setDateValue(dateToCalendarDate(value2));
40
+ state.close();
41
+ }
42
+ }
43
+ )) : /* @__PURE__ */ React.createElement(React.Fragment, null));
44
+ };
45
+
46
+ export { DatePickerInput };
@@ -0,0 +1,22 @@
1
+ import { labelStyle, inputBox } from '@tecsinapse/cortex-core';
2
+ import React from 'react';
3
+ import { LiaCalendar } from 'react-icons/lia';
4
+ import { Input } from './Input.js';
5
+
6
+ const DatePickerInputBase = ({
7
+ children,
8
+ variants,
9
+ label,
10
+ onClickCalendar
11
+ }) => {
12
+ return /* @__PURE__ */ React.createElement(Input.Face, { variants, "data-testid": "date-picker-input-base" }, /* @__PURE__ */ React.createElement("span", { className: labelStyle({}) }, label), /* @__PURE__ */ React.createElement("div", { className: inputBox("", label) }, children), /* @__PURE__ */ React.createElement(Input.Right, { className: "" }, /* @__PURE__ */ React.createElement(
13
+ LiaCalendar,
14
+ {
15
+ className: "cursor-pointer mt-centi",
16
+ onClick: onClickCalendar,
17
+ "data-testid": "date-picker-input-base-calendar"
18
+ }
19
+ )));
20
+ };
21
+
22
+ export { DatePickerInputBase };
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import '@internationalized/date';
3
+ import 'react-aria';
4
+ import 'react-stately';
5
+ import { dateToCalendarDate } from './utils.js';
6
+ import { useDateRangePickerInput } from '../hooks/useDateRangePickerInput.js';
7
+ import { DateField } from './DateField.js';
8
+ import { DatePickerInputBase } from './DatePickerInputBase.js';
9
+ import { RangeCalendar } from './RangeCalendar.js';
10
+
11
+ const DateRangePickerInput = (props) => {
12
+ const { onChange, value, label, variants } = props;
13
+ const { endFieldProps, startFieldProps, ref, state } = useDateRangePickerInput({ value, onChange });
14
+ return /* @__PURE__ */ React.createElement("div", { "data-testid": "date-range-picker-input" }, /* @__PURE__ */ React.createElement(
15
+ DatePickerInputBase,
16
+ {
17
+ onClickCalendar: () => state.isOpen ? state.close() : state.open(),
18
+ variants: {
19
+ ...variants,
20
+ intent: state.isInvalid ? "error" : variants?.intent
21
+ },
22
+ label
23
+ },
24
+ /* @__PURE__ */ React.createElement("div", { ref, className: "flex flex-row gap-x-micro items-center" }, /* @__PURE__ */ React.createElement(
25
+ DateField,
26
+ {
27
+ ...startFieldProps,
28
+ value: dateToCalendarDate(value?.start),
29
+ onChange: (value2) => {
30
+ state.setDate("start", value2);
31
+ state.close();
32
+ }
33
+ }
34
+ ), /* @__PURE__ */ React.createElement("span", null, "-"), /* @__PURE__ */ React.createElement(
35
+ DateField,
36
+ {
37
+ ...endFieldProps,
38
+ value: dateToCalendarDate(value?.end),
39
+ onChange: (value2) => {
40
+ state.setDate("end", value2);
41
+ state.close();
42
+ }
43
+ }
44
+ ))
45
+ ), state.isOpen ? /* @__PURE__ */ React.createElement("div", { className: "absolute" }, /* @__PURE__ */ React.createElement(
46
+ RangeCalendar,
47
+ {
48
+ value,
49
+ onChange: (value2) => {
50
+ state.setDateRange({
51
+ start: dateToCalendarDate(value2.start),
52
+ end: dateToCalendarDate(value2.end)
53
+ });
54
+ state.close();
55
+ }
56
+ }
57
+ )) : /* @__PURE__ */ React.createElement(React.Fragment, null));
58
+ };
59
+
60
+ export { DateRangePickerInput };
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { useDateSegment } from 'react-aria';
3
+
4
+ const DateSegment = ({ segment, state }) => {
5
+ const ref = React.useRef(null);
6
+ const { segmentProps } = useDateSegment(segment, state, ref);
7
+ return /* @__PURE__ */ React.createElement(
8
+ "div",
9
+ {
10
+ ...segmentProps,
11
+ ref,
12
+ className: "focus:outline-none focus:bg-secondary-light"
13
+ },
14
+ segment.text
15
+ );
16
+ };
17
+
18
+ export { DateSegment };
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { BaseSnackbar } from './BaseSnackbar.js';
3
+ import { IoMdInformationCircleOutline, IoMdClose } from 'react-icons/io';
4
+
5
+ const DefaultSnack = ({
6
+ text,
7
+ onDismiss,
8
+ variants
9
+ }) => /* @__PURE__ */ React.createElement(BaseSnackbar, { show: true, variants: { intent: variants?.intent } }, /* @__PURE__ */ React.createElement("div", { className: "flex justify-between items-center flex-row gap-x-mili" }, /* @__PURE__ */ React.createElement(
10
+ IoMdInformationCircleOutline,
11
+ {
12
+ className: "w-[20px] h-[20px] shrink-0",
13
+ "data-testid": "icon-info"
14
+ }
15
+ ), /* @__PURE__ */ React.createElement("p", null, text), /* @__PURE__ */ React.createElement(
16
+ IoMdClose,
17
+ {
18
+ "data-testid": "icon-close",
19
+ onClick: onDismiss,
20
+ size: 24,
21
+ className: "cursor-pointer w-[20px] h-[20px] shrink-0"
22
+ }
23
+ )));
24
+
25
+ export { DefaultSnack };
@@ -10,12 +10,14 @@ const Drawer = ({
10
10
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
11
11
  "div",
12
12
  {
13
+ "data-testid": "overlay",
13
14
  className: overlay({ show: open }),
14
- onClick: () => onClose(false)
15
+ onClick: onClose
15
16
  }
16
17
  ), /* @__PURE__ */ React.createElement(
17
18
  "div",
18
19
  {
20
+ "data-testid": "drawer",
19
21
  className: drawer({
20
22
  position,
21
23
  open
@@ -0,0 +1,41 @@
1
+ import clsx from 'clsx';
2
+ import React from 'react';
3
+ import '../styles/calendar-cell.js';
4
+ import { groupButton } from '../styles/groupButton.js';
5
+ import '../styles/progressBar.js';
6
+
7
+ const { button, container, active, inactive, firstButton, lastButton } = groupButton();
8
+ const GroupButton = (props) => {
9
+ const {
10
+ options,
11
+ value,
12
+ renderKey,
13
+ renderOption,
14
+ onChange,
15
+ customStyles,
16
+ disableAllOptions
17
+ } = props;
18
+ return /* @__PURE__ */ React.createElement("div", { className: container(), "data-testid": "group-button-container" }, options.map((option) => {
19
+ const key = renderKey?.(option.value);
20
+ const isActive = key === renderKey?.(value);
21
+ return /* @__PURE__ */ React.createElement(
22
+ "button",
23
+ {
24
+ disabled: disableAllOptions,
25
+ value: String(value),
26
+ onClick: () => onChange(option.value),
27
+ className: clsx(
28
+ button(),
29
+ firstButton({ className: customStyles?.firstButton }),
30
+ lastButton({ className: customStyles?.lastButton }),
31
+ !isActive && inactive({ className: customStyles?.inactive }),
32
+ isActive && active({ className: customStyles?.active })
33
+ ),
34
+ key
35
+ },
36
+ renderOption(option.value)
37
+ );
38
+ }));
39
+ };
40
+
41
+ export { GroupButton };
@@ -1,6 +1,6 @@
1
- import React from 'react';
2
1
  import { inputBox, labelStyle, input } from '@tecsinapse/cortex-core';
3
2
  import { clsx } from 'clsx';
3
+ import React from 'react';
4
4
 
5
5
  const getValidChildren = (children) => {
6
6
  return React.Children.toArray(children).filter(
@@ -17,13 +17,15 @@ const Box = React.forwardRef(
17
17
  placeholder: placeholder ?? " ",
18
18
  className: clsx(inputBox(placeholder, label, className)),
19
19
  ...rest,
20
- ref
20
+ ref,
21
+ "data-testid": "input-input"
21
22
  }
22
23
  ), /* @__PURE__ */ React.createElement(
23
24
  "label",
24
25
  {
25
26
  htmlFor: id ?? name,
26
- className: labelStyle({ intent: variants?.intent, placeholder })
27
+ className: labelStyle({ intent: variants?.intent, placeholder }),
28
+ "data-testid": "input-label"
27
29
  },
28
30
  label
29
31
  ));