@tecsinapse/cortex-react 1.3.0-beta.0 → 1.3.0-beta.2

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 (89) hide show
  1. package/dist/cjs/components/Calendar.js +1 -0
  2. package/dist/cjs/components/DateField.js +25 -0
  3. package/dist/cjs/components/DatePickerInput.js +48 -0
  4. package/dist/cjs/components/DatePickerInputBase.js +24 -0
  5. package/dist/cjs/components/DateRangePickerInput.js +62 -0
  6. package/dist/cjs/components/DateSegment.js +9 -1
  7. package/dist/cjs/components/Input.js +16 -16
  8. package/dist/cjs/components/RangeCalendar.js +24 -32
  9. package/dist/cjs/components/Select/GroupedOptions.js +32 -0
  10. package/dist/cjs/components/Select/Option.js +25 -0
  11. package/dist/cjs/components/Select/Options.js +29 -0
  12. package/dist/cjs/components/Select/Popover.js +13 -0
  13. package/dist/cjs/components/Select/Root.js +31 -0
  14. package/dist/cjs/components/Select/Trigger.js +28 -0
  15. package/dist/cjs/components/Select/context.js +10 -0
  16. package/dist/cjs/components/Select/index.js +19 -0
  17. package/dist/cjs/components/Table.js +2 -2
  18. package/dist/cjs/components/utils.js +14 -0
  19. package/dist/cjs/hooks/useCalendar.js +3 -6
  20. package/dist/cjs/hooks/useDatePickerInput.js +31 -0
  21. package/dist/cjs/hooks/useDateRangePickerInput.js +33 -0
  22. package/dist/cjs/hooks/useOutsideClickListener.js +22 -0
  23. package/dist/cjs/hooks/useRangeCalendar.js +36 -0
  24. package/dist/cjs/index.js +33 -17
  25. package/dist/cjs/service/SnackbarSonner.js +10 -3
  26. package/dist/cjs/styles/calendar-cell.js +3 -3
  27. package/dist/esm/components/Calendar.js +1 -0
  28. package/dist/esm/components/DateField.js +23 -0
  29. package/dist/esm/components/DatePickerInput.js +46 -0
  30. package/dist/esm/components/DatePickerInputBase.js +22 -0
  31. package/dist/esm/components/DateRangePickerInput.js +60 -0
  32. package/dist/esm/components/DateSegment.js +9 -1
  33. package/dist/esm/components/Input.js +12 -12
  34. package/dist/esm/components/RangeCalendar.js +24 -32
  35. package/dist/esm/components/Select/GroupedOptions.js +30 -0
  36. package/dist/esm/components/Select/Option.js +23 -0
  37. package/dist/esm/components/Select/Options.js +27 -0
  38. package/dist/esm/components/Select/Popover.js +11 -0
  39. package/dist/esm/components/Select/Root.js +29 -0
  40. package/dist/esm/components/Select/Trigger.js +26 -0
  41. package/dist/esm/components/Select/context.js +8 -0
  42. package/dist/esm/components/Select/index.js +17 -0
  43. package/dist/esm/components/Table.js +2 -2
  44. package/dist/esm/components/utils.js +13 -1
  45. package/dist/esm/hooks/useCalendar.js +4 -7
  46. package/dist/esm/hooks/useDatePickerInput.js +29 -0
  47. package/dist/esm/hooks/useDateRangePickerInput.js +31 -0
  48. package/dist/esm/hooks/useOutsideClickListener.js +20 -0
  49. package/dist/esm/hooks/useRangeCalendar.js +34 -0
  50. package/dist/esm/index.js +17 -7
  51. package/dist/esm/service/SnackbarSonner.js +10 -3
  52. package/dist/esm/styles/calendar-cell.js +3 -3
  53. package/dist/types/components/Calendar.d.ts +1 -1
  54. package/dist/types/components/DateField.d.ts +5 -0
  55. package/dist/types/components/DatePickerInput.d.ts +6 -0
  56. package/dist/types/components/DatePickerInputBase.d.ts +8 -0
  57. package/dist/types/components/DateRangePickerInput.d.ts +7 -0
  58. package/dist/types/components/Input.d.ts +5 -5
  59. package/dist/types/components/RangeCalendar.d.ts +1 -1
  60. package/dist/types/components/SearchInput.d.ts +3 -2
  61. package/dist/types/components/Select/GroupedOptions.d.ts +6 -0
  62. package/dist/types/components/Select/Option.d.ts +5 -0
  63. package/dist/types/components/Select/Options.d.ts +5 -0
  64. package/dist/types/components/Select/Popover.d.ts +5 -0
  65. package/dist/types/components/Select/Root.d.ts +8 -0
  66. package/dist/types/components/Select/Trigger.d.ts +5 -0
  67. package/dist/types/components/Select/context.d.ts +10 -0
  68. package/dist/types/components/Select/index.d.ts +8 -0
  69. package/dist/types/components/index.d.ts +5 -2
  70. package/dist/types/components/utils.d.ts +3 -0
  71. package/dist/types/hooks/index.d.ts +4 -0
  72. package/dist/types/hooks/useCalendar.d.ts +1 -1
  73. package/dist/types/hooks/useDatePickerInput.d.ts +10 -0
  74. package/dist/types/hooks/useDateRangePickerInput.d.ts +12 -0
  75. package/dist/types/hooks/useOutsideClickListener.d.ts +7 -0
  76. package/dist/types/hooks/useRangeCalendar.d.ts +12 -0
  77. package/dist/types/index.d.ts +1 -1
  78. package/dist/types/tests/DateField.test.d.ts +1 -0
  79. package/dist/types/tests/DatePickerInput.test.d.ts +1 -0
  80. package/dist/types/tests/DatePickerInputBase.test.d.ts +1 -0
  81. package/dist/types/tests/DateRangePickerInput.test.d.ts +1 -0
  82. package/dist/types/tests/RangeCalendar.test.d.ts +1 -0
  83. package/dist/types/tests/useOutsideClickListener.test.d.ts +1 -0
  84. package/package.json +6 -4
  85. package/dist/cjs/components/SearchInput.js +0 -82
  86. package/dist/cjs/components/Select.js +0 -101
  87. package/dist/esm/components/SearchInput.js +0 -80
  88. package/dist/esm/components/Select.js +0 -96
  89. package/dist/types/components/Select.d.ts +0 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tecsinapse/cortex-react",
3
- "version": "1.3.0-beta.0",
3
+ "version": "1.3.0-beta.2",
4
4
  "description": "React components based in @tecsinapse/cortex-core",
5
5
  "license": "MIT",
6
6
  "main": "dist/esm/index.js",
@@ -18,12 +18,14 @@
18
18
  "test:watch": "jest --watch"
19
19
  },
20
20
  "dependencies": {
21
- "@tecsinapse/cortex-core": "0.2.2-beta.2",
21
+ "@internationalized/date": "*",
22
+ "@tecsinapse/cortex-core": "0.3.0-beta.0",
22
23
  "clsx": "*",
23
24
  "react-aria": "^3.33.1",
24
25
  "react-icons": "^5.2.1",
25
26
  "react-stately": "^3.31.1",
26
- "sonner": "^1.5.0"
27
+ "sonner": "^1.5.0",
28
+ "tailwind-merge": "*"
27
29
  },
28
30
  "repository": {
29
31
  "type": "git",
@@ -39,5 +41,5 @@
39
41
  "react-dom": ">=18.0.0",
40
42
  "tailwind": ">=3.3.0"
41
43
  },
42
- "gitHead": "0ecb7949c627cb5d2fe9395f148e48a0bb071599"
44
+ "gitHead": "cc8903eb4c3ec693fa6dbd384bfc407f39e144ae"
43
45
  }
@@ -1,82 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- require('clsx');
5
- require('./Badge.js');
6
- require('./BaseSnackbar.js');
7
- require('react-icons/md');
8
- require('./Card.js');
9
- var Button = require('./Button.js');
10
- require('@internationalized/date');
11
- require('react-aria');
12
- require('react-stately');
13
- var useDebouncedState = require('../hooks/useDebouncedState.js');
14
- require('./CalendarCell.js');
15
- require('@tecsinapse/cortex-core');
16
- require('react-icons/fa');
17
- require('react-icons/io');
18
- require('./GroupButton.js');
19
- require('./Hint.js');
20
- var Input = require('./Input.js');
21
- require('./Modal.js');
22
- require('../styles/calendar-cell.js');
23
- require('../styles/groupButton.js');
24
- require('../styles/progressBar.js');
25
- require('./Select.js');
26
- require('./Tag.js');
27
- require('./TextArea.js');
28
- require('./Toggle.js');
29
- var ai = require('react-icons/ai');
30
- var io5 = require('react-icons/io5');
31
-
32
- const inputFace = "bg-white w-full";
33
- const inputLeft = "flex items-center";
34
- const SearchInput = ({
35
- label,
36
- placeholder,
37
- isSubmitting = false,
38
- onChange,
39
- onClick,
40
- BOUNCE_TIMEOUT = 1e3
41
- }) => {
42
- const [bouncedText, setBouncedText] = React.useState("");
43
- const [searchInput, setSearchInput] = useDebouncedState.useDebouncedState(
44
- "",
45
- setBouncedText,
46
- BOUNCE_TIMEOUT
47
- );
48
- React.useEffect(() => {
49
- if (onChange) {
50
- onChange(bouncedText);
51
- }
52
- }, [bouncedText]);
53
- const handleEnterKey = (e) => {
54
- if (e.key === "Enter" && onClick && searchInput) {
55
- onClick(searchInput);
56
- }
57
- };
58
- return /* @__PURE__ */ React.createElement("div", { className: "flex flex-row w-full space-x-mili" }, /* @__PURE__ */ React.createElement(Input.Input.Face, { variants: { className: inputFace } }, !onClick && /* @__PURE__ */ React.createElement(Input.Input.Left, { className: inputLeft }, /* @__PURE__ */ React.createElement(io5.IoSearchOutline, { "data-testid": "icon-search-left" })), /* @__PURE__ */ React.createElement(
59
- Input.Input.Box,
60
- {
61
- placeholder,
62
- label,
63
- onChange: (e) => setSearchInput(e.target.value),
64
- onKeyDown: handleEnterKey,
65
- disabled: isSubmitting
66
- }
67
- )), onClick && /* @__PURE__ */ React.createElement(
68
- Button.Button,
69
- {
70
- variants: {
71
- intent: "primary",
72
- size: "square",
73
- className: "h-11"
74
- },
75
- onClick: () => onClick(searchInput),
76
- disabled: !searchInput || isSubmitting
77
- },
78
- isSubmitting ? /* @__PURE__ */ React.createElement("div", { className: "animate-spin" }, /* @__PURE__ */ React.createElement(ai.AiOutlineLoading, { "data-testid": "icon-loading" })) : /* @__PURE__ */ React.createElement(io5.IoSearchOutline, { "data-testid": "icon-search-button" })
79
- ));
80
- };
81
-
82
- module.exports = SearchInput;
@@ -1,101 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var cortexCore = require('@tecsinapse/cortex-core');
6
- var React = require('react');
7
- var io = require('react-icons/io');
8
- var io5 = require('react-icons/io5');
9
- var Hint = require('./Hint.js');
10
- var SearchInput = require('./SearchInput.js');
11
-
12
- const { button, dropdown, groupedTitle, containerGrouped, hintBody } = cortexCore.selectVariants();
13
- const Select = (props) => {
14
- const {
15
- label,
16
- keyExtractor,
17
- labelExtractor,
18
- options,
19
- value,
20
- onSelect,
21
- onSearch,
22
- disabled,
23
- grouped,
24
- groupedLabelExtractor,
25
- hint,
26
- placeholderSearchInput,
27
- variant = "default"
28
- } = props;
29
- const [open, setOpen] = React.useState(false);
30
- const placeholder = React.useMemo(
31
- () => value ? labelExtractor(value) : label,
32
- [label, labelExtractor, value]
33
- );
34
- const ref = React.useRef(null);
35
- const handleClickOutside = React.useCallback((event) => {
36
- if (ref.current && !ref.current.contains(event.target)) {
37
- setOpen(false);
38
- }
39
- }, []);
40
- const handleSelect = React.useCallback(
41
- (option) => {
42
- onSelect(option);
43
- setOpen(false);
44
- },
45
- [onSelect]
46
- );
47
- React.useEffect(() => {
48
- document.addEventListener("click", handleClickOutside, true);
49
- return () => {
50
- document.removeEventListener("click", handleClickOutside, true);
51
- };
52
- }, [handleClickOutside]);
53
- const Option = ({ option }) => /* @__PURE__ */ React.createElement(
54
- "li",
55
- {
56
- onClick: () => handleSelect(option),
57
- className: cortexCore.option(),
58
- role: "option"
59
- },
60
- labelExtractor(option)
61
- );
62
- const GroupedOptions = ({ options: options2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, [...options2 ?? []].map(([key, value2]) => /* @__PURE__ */ React.createElement("div", { key, className: containerGrouped() }, /* @__PURE__ */ React.createElement("span", { className: groupedTitle() }, groupedLabelExtractor?.(key)), value2.map((option) => /* @__PURE__ */ React.createElement(Option, { option, key: keyExtractor(option) })))));
63
- const DefaultOptions = ({ options: options2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, (options2 ?? []).map((option) => /* @__PURE__ */ React.createElement(Option, { option, key: keyExtractor(option) })));
64
- return /* @__PURE__ */ React.createElement("div", { className: "w-full relative bg-white", ref }, /* @__PURE__ */ React.createElement(
65
- "button",
66
- {
67
- className: button({ disabled, intent: variant }),
68
- onClick: () => setOpen((prevState) => !prevState),
69
- disabled
70
- },
71
- /* @__PURE__ */ React.createElement("span", { "data-testid": "select-placeholder" }, placeholder),
72
- /* @__PURE__ */ React.createElement(io5.IoChevronDownOutline, null)
73
- ), /* @__PURE__ */ React.createElement(
74
- "ul",
75
- {
76
- role: "select",
77
- className: dropdown({
78
- open
79
- })
80
- },
81
- onSearch ? /* @__PURE__ */ React.createElement("div", { className: "m-mili" }, /* @__PURE__ */ React.createElement(
82
- SearchInput,
83
- {
84
- placeholder: placeholderSearchInput,
85
- onChange: onSearch
86
- }
87
- )) : /* @__PURE__ */ React.createElement(React.Fragment, null),
88
- grouped ? /* @__PURE__ */ React.createElement(GroupedOptions, { options }) : /* @__PURE__ */ React.createElement(DefaultOptions, { options })
89
- ), hint && /* @__PURE__ */ React.createElement(
90
- Hint.Hint,
91
- {
92
- variants: {
93
- intent: variant
94
- }
95
- },
96
- /* @__PURE__ */ React.createElement("div", { className: hintBody() }, variant === "error" ? /* @__PURE__ */ React.createElement(io.IoIosCloseCircleOutline, { "data-testid": "select-hint-error-icon" }) : /* @__PURE__ */ React.createElement(React.Fragment, null), /* @__PURE__ */ React.createElement("span", null, hint))
97
- ));
98
- };
99
-
100
- exports.Select = Select;
101
- exports.default = Select;
@@ -1,80 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import 'clsx';
3
- import './Badge.js';
4
- import './BaseSnackbar.js';
5
- import 'react-icons/md';
6
- import './Card.js';
7
- import { Button } from './Button.js';
8
- import '@internationalized/date';
9
- import 'react-aria';
10
- import 'react-stately';
11
- import { useDebouncedState } from '../hooks/useDebouncedState.js';
12
- import './CalendarCell.js';
13
- import '@tecsinapse/cortex-core';
14
- import 'react-icons/fa';
15
- import 'react-icons/io';
16
- import './GroupButton.js';
17
- import './Hint.js';
18
- import { Input } from './Input.js';
19
- import './Modal.js';
20
- import '../styles/calendar-cell.js';
21
- import '../styles/groupButton.js';
22
- import '../styles/progressBar.js';
23
- import './Select.js';
24
- import './Tag.js';
25
- import './TextArea.js';
26
- import './Toggle.js';
27
- import { AiOutlineLoading } from 'react-icons/ai';
28
- import { IoSearchOutline } from 'react-icons/io5';
29
-
30
- const inputFace = "bg-white w-full";
31
- const inputLeft = "flex items-center";
32
- const SearchInput = ({
33
- label,
34
- placeholder,
35
- isSubmitting = false,
36
- onChange,
37
- onClick,
38
- BOUNCE_TIMEOUT = 1e3
39
- }) => {
40
- const [bouncedText, setBouncedText] = useState("");
41
- const [searchInput, setSearchInput] = useDebouncedState(
42
- "",
43
- setBouncedText,
44
- BOUNCE_TIMEOUT
45
- );
46
- useEffect(() => {
47
- if (onChange) {
48
- onChange(bouncedText);
49
- }
50
- }, [bouncedText]);
51
- const handleEnterKey = (e) => {
52
- if (e.key === "Enter" && onClick && searchInput) {
53
- onClick(searchInput);
54
- }
55
- };
56
- return /* @__PURE__ */ React.createElement("div", { className: "flex flex-row w-full space-x-mili" }, /* @__PURE__ */ React.createElement(Input.Face, { variants: { className: inputFace } }, !onClick && /* @__PURE__ */ React.createElement(Input.Left, { className: inputLeft }, /* @__PURE__ */ React.createElement(IoSearchOutline, { "data-testid": "icon-search-left" })), /* @__PURE__ */ React.createElement(
57
- Input.Box,
58
- {
59
- placeholder,
60
- label,
61
- onChange: (e) => setSearchInput(e.target.value),
62
- onKeyDown: handleEnterKey,
63
- disabled: isSubmitting
64
- }
65
- )), onClick && /* @__PURE__ */ React.createElement(
66
- Button,
67
- {
68
- variants: {
69
- intent: "primary",
70
- size: "square",
71
- className: "h-11"
72
- },
73
- onClick: () => onClick(searchInput),
74
- disabled: !searchInput || isSubmitting
75
- },
76
- isSubmitting ? /* @__PURE__ */ React.createElement("div", { className: "animate-spin" }, /* @__PURE__ */ React.createElement(AiOutlineLoading, { "data-testid": "icon-loading" })) : /* @__PURE__ */ React.createElement(IoSearchOutline, { "data-testid": "icon-search-button" })
77
- ));
78
- };
79
-
80
- export { SearchInput as default };
@@ -1,96 +0,0 @@
1
- import { selectVariants, option } from '@tecsinapse/cortex-core';
2
- import React, { useState, useMemo, useRef, useCallback, useEffect } from 'react';
3
- import { IoIosCloseCircleOutline } from 'react-icons/io';
4
- import { IoChevronDownOutline } from 'react-icons/io5';
5
- import { Hint } from './Hint.js';
6
- import SearchInput from './SearchInput.js';
7
-
8
- const { button, dropdown, groupedTitle, containerGrouped, hintBody } = selectVariants();
9
- const Select = (props) => {
10
- const {
11
- label,
12
- keyExtractor,
13
- labelExtractor,
14
- options,
15
- value,
16
- onSelect,
17
- onSearch,
18
- disabled,
19
- grouped,
20
- groupedLabelExtractor,
21
- hint,
22
- placeholderSearchInput,
23
- variant = "default"
24
- } = props;
25
- const [open, setOpen] = useState(false);
26
- const placeholder = useMemo(
27
- () => value ? labelExtractor(value) : label,
28
- [label, labelExtractor, value]
29
- );
30
- const ref = useRef(null);
31
- const handleClickOutside = useCallback((event) => {
32
- if (ref.current && !ref.current.contains(event.target)) {
33
- setOpen(false);
34
- }
35
- }, []);
36
- const handleSelect = useCallback(
37
- (option) => {
38
- onSelect(option);
39
- setOpen(false);
40
- },
41
- [onSelect]
42
- );
43
- useEffect(() => {
44
- document.addEventListener("click", handleClickOutside, true);
45
- return () => {
46
- document.removeEventListener("click", handleClickOutside, true);
47
- };
48
- }, [handleClickOutside]);
49
- const Option = ({ option: option$1 }) => /* @__PURE__ */ React.createElement(
50
- "li",
51
- {
52
- onClick: () => handleSelect(option$1),
53
- className: option(),
54
- role: "option"
55
- },
56
- labelExtractor(option$1)
57
- );
58
- const GroupedOptions = ({ options: options2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, [...options2 ?? []].map(([key, value2]) => /* @__PURE__ */ React.createElement("div", { key, className: containerGrouped() }, /* @__PURE__ */ React.createElement("span", { className: groupedTitle() }, groupedLabelExtractor?.(key)), value2.map((option) => /* @__PURE__ */ React.createElement(Option, { option, key: keyExtractor(option) })))));
59
- const DefaultOptions = ({ options: options2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, (options2 ?? []).map((option) => /* @__PURE__ */ React.createElement(Option, { option, key: keyExtractor(option) })));
60
- return /* @__PURE__ */ React.createElement("div", { className: "w-full relative bg-white", ref }, /* @__PURE__ */ React.createElement(
61
- "button",
62
- {
63
- className: button({ disabled, intent: variant }),
64
- onClick: () => setOpen((prevState) => !prevState),
65
- disabled
66
- },
67
- /* @__PURE__ */ React.createElement("span", { "data-testid": "select-placeholder" }, placeholder),
68
- /* @__PURE__ */ React.createElement(IoChevronDownOutline, null)
69
- ), /* @__PURE__ */ React.createElement(
70
- "ul",
71
- {
72
- role: "select",
73
- className: dropdown({
74
- open
75
- })
76
- },
77
- onSearch ? /* @__PURE__ */ React.createElement("div", { className: "m-mili" }, /* @__PURE__ */ React.createElement(
78
- SearchInput,
79
- {
80
- placeholder: placeholderSearchInput,
81
- onChange: onSearch
82
- }
83
- )) : /* @__PURE__ */ React.createElement(React.Fragment, null),
84
- grouped ? /* @__PURE__ */ React.createElement(GroupedOptions, { options }) : /* @__PURE__ */ React.createElement(DefaultOptions, { options })
85
- ), hint && /* @__PURE__ */ React.createElement(
86
- Hint,
87
- {
88
- variants: {
89
- intent: variant
90
- }
91
- },
92
- /* @__PURE__ */ React.createElement("div", { className: hintBody() }, variant === "error" ? /* @__PURE__ */ React.createElement(IoIosCloseCircleOutline, { "data-testid": "select-hint-error-icon" }) : /* @__PURE__ */ React.createElement(React.Fragment, null), /* @__PURE__ */ React.createElement("span", null, hint))
93
- ));
94
- };
95
-
96
- export { Select, Select as default };
@@ -1,27 +0,0 @@
1
- interface CommonProps<T> {
2
- label: string;
3
- value: T | undefined;
4
- onSelect: (value: T) => void;
5
- keyExtractor: (value: T) => string;
6
- labelExtractor: (value: T) => string;
7
- onSearch?: (search: string) => void;
8
- disabled?: boolean;
9
- grouped?: boolean;
10
- variant?: 'error' | 'default';
11
- hint?: string;
12
- placeholderSearchInput?: string;
13
- }
14
- interface GroupedProps<T> {
15
- options?: Map<string, T[]>;
16
- groupedLabelExtractor: (value: string) => string;
17
- grouped: true;
18
- }
19
- interface DefaultProps<T> {
20
- options?: T[];
21
- groupedLabelExtractor?: never;
22
- grouped?: never;
23
- }
24
- type ConditionalProps<T> = GroupedProps<T> | DefaultProps<T>;
25
- type SelectProps<T> = CommonProps<T> & ConditionalProps<T>;
26
- export declare const Select: <T>(props: SelectProps<T>) => JSX.Element;
27
- export default Select;