@tecsinapse/cortex-react 1.3.4 → 1.4.0-beta.0

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 (72) hide show
  1. package/dist/cjs/components/Accordion.js +106 -0
  2. package/dist/cjs/components/Menubar/MostUsedList.js +1 -0
  3. package/dist/cjs/index.js +2 -0
  4. package/dist/cjs/service/SnackbarSonner.js +1 -0
  5. package/dist/esm/components/Accordion.js +104 -0
  6. package/dist/esm/components/Menubar/MostUsedList.js +1 -0
  7. package/dist/esm/index.js +1 -0
  8. package/dist/esm/service/SnackbarSonner.js +1 -0
  9. package/dist/types/components/Accordion.d.ts +16 -0
  10. package/dist/types/components/index.d.ts +1 -0
  11. package/package.json +3 -3
  12. package/dist/types/tests/Avatar.test.d.ts +0 -1
  13. package/dist/types/tests/Badge.test.d.ts +0 -1
  14. package/dist/types/tests/BreadcrumbItem.test.d.ts +0 -1
  15. package/dist/types/tests/Breadcrumbs.test.d.ts +0 -1
  16. package/dist/types/tests/Button.test.d.ts +0 -1
  17. package/dist/types/tests/Calendar.test.d.ts +0 -1
  18. package/dist/types/tests/CalendarCell.test.d.ts +0 -1
  19. package/dist/types/tests/CalendarGridBodyRows.test.d.ts +0 -1
  20. package/dist/types/tests/CalendarGridHeaderRow.test.d.ts +0 -1
  21. package/dist/types/tests/CalendarHeader.test.d.ts +0 -1
  22. package/dist/types/tests/Card.test.d.ts +0 -1
  23. package/dist/types/tests/DateField.test.d.ts +0 -1
  24. package/dist/types/tests/DatePickerInput.test.d.ts +0 -1
  25. package/dist/types/tests/DatePickerInputBase.test.d.ts +0 -1
  26. package/dist/types/tests/DateRangePickerInput.test.d.ts +0 -1
  27. package/dist/types/tests/DateSegment.test.d.ts +0 -1
  28. package/dist/types/tests/DefaultSnack.test.d.ts +0 -1
  29. package/dist/types/tests/Divider.test.d.ts +0 -1
  30. package/dist/types/tests/Drawer.test.d.ts +0 -1
  31. package/dist/types/tests/GroupButton.test.d.ts +0 -1
  32. package/dist/types/tests/Hint.test.d.ts +0 -1
  33. package/dist/types/tests/Input/Box.test.d.ts +0 -1
  34. package/dist/types/tests/Input/Face.test.d.ts +0 -1
  35. package/dist/types/tests/Input/Left.test.d.ts +0 -1
  36. package/dist/types/tests/Input/Mask.test.d.ts +0 -1
  37. package/dist/types/tests/Input/Right.test.d.ts +0 -1
  38. package/dist/types/tests/Input/Root.test.d.ts +0 -1
  39. package/dist/types/tests/Input/Search.test.d.ts +0 -1
  40. package/dist/types/tests/Kanban.test.d.ts +0 -1
  41. package/dist/types/tests/Menubar/Categories.test.d.ts +0 -1
  42. package/dist/types/tests/Menubar/Category.test.d.ts +0 -1
  43. package/dist/types/tests/Menubar/Dropdown.test.d.ts +0 -1
  44. package/dist/types/tests/Menubar/DropdownRoot.test.d.ts +0 -1
  45. package/dist/types/tests/Menubar/Header.test.d.ts +0 -1
  46. package/dist/types/tests/Menubar/HeaderLeft.test.d.ts +0 -1
  47. package/dist/types/tests/Menubar/HeaderRigth.test.d.ts +0 -1
  48. package/dist/types/tests/Menubar/Item.test.d.ts +0 -1
  49. package/dist/types/tests/Menubar/MostUsed.test.d.ts +0 -1
  50. package/dist/types/tests/Menubar/MostUsedItem.test.d.ts +0 -1
  51. package/dist/types/tests/Menubar/MostUsedList.test.d.ts +0 -1
  52. package/dist/types/tests/Menubar/Root.test.d.ts +0 -1
  53. package/dist/types/tests/Menubar/SubItem.test.d.ts +0 -1
  54. package/dist/types/tests/Modal.test.d.ts +0 -1
  55. package/dist/types/tests/Popover.test.d.ts +0 -1
  56. package/dist/types/tests/ProgressBar.test.d.ts +0 -1
  57. package/dist/types/tests/RadioButton.test.d.ts +0 -1
  58. package/dist/types/tests/RangeCalendar.test.d.ts +0 -1
  59. package/dist/types/tests/Select.test.d.ts +0 -1
  60. package/dist/types/tests/Skeleton.test.d.ts +0 -1
  61. package/dist/types/tests/Snackbar.test.d.ts +0 -1
  62. package/dist/types/tests/Table.test.d.ts +0 -1
  63. package/dist/types/tests/Tag.test.d.ts +0 -1
  64. package/dist/types/tests/TextArea.test.d.ts +0 -1
  65. package/dist/types/tests/TimeField.test.d.ts +0 -1
  66. package/dist/types/tests/TimeFieldInput.test.d.ts +0 -1
  67. package/dist/types/tests/Toggle.test.d.ts +0 -1
  68. package/dist/types/tests/Tooltip.test.d.ts +0 -1
  69. package/dist/types/tests/useCalendarCell.test.d.ts +0 -1
  70. package/dist/types/tests/useDebouncedState.test.d.ts +0 -1
  71. package/dist/types/tests/useOutsideClickListener.test.d.ts +0 -1
  72. package/dist/types/tests/utils.test.d.ts +0 -1
@@ -0,0 +1,106 @@
1
+ 'use strict';
2
+
3
+ var clsx = require('clsx');
4
+ var React = require('react');
5
+ var lia = require('react-icons/lia');
6
+
7
+ const Context = React.createContext({ open: false });
8
+ const useAccordionContext = () => {
9
+ const context = React.useContext(Context);
10
+ if (!context) {
11
+ throw new Error("useAccordionContext must be used within a Accordion");
12
+ }
13
+ return context;
14
+ };
15
+ const Trigger = ({
16
+ label,
17
+ floating = false,
18
+ /**
19
+ * Only applied to trigger arrow
20
+ */
21
+ className
22
+ }) => {
23
+ const { open, toggle } = useAccordionContext();
24
+ if (!floating && !label) {
25
+ throw new Error(
26
+ "A label must be specified if the trigger is not floating variant"
27
+ );
28
+ }
29
+ return /* @__PURE__ */ React.createElement(
30
+ "div",
31
+ {
32
+ className: clsx(
33
+ "flex flex-col justify-between align-center px-mili border-r border-secondary-light cursor-pointer",
34
+ { "mr-deca": floating }
35
+ ),
36
+ onClick: toggle
37
+ },
38
+ /* @__PURE__ */ React.createElement(
39
+ "div",
40
+ {
41
+ className: clsx(
42
+ "rounded-mili border border-secondary-light flex align-center justify-center p-micro",
43
+ {
44
+ "absolute -translate-x-micro translate-y-deca bg-white": floating
45
+ },
46
+ className
47
+ )
48
+ },
49
+ /* @__PURE__ */ React.createElement(
50
+ lia.LiaAngleRightSolid,
51
+ {
52
+ className: clsx(
53
+ "text-secondary-medium transition-transform duration-200",
54
+ {
55
+ "rotate-180": open
56
+ }
57
+ )
58
+ }
59
+ )
60
+ ),
61
+ !floating ? /* @__PURE__ */ React.createElement("span", { className: "-rotate-180 [writing-mode:vertical-lr]" }, label) : null
62
+ );
63
+ };
64
+ const Content = ({ children }) => {
65
+ const container = React.useRef(null);
66
+ const [width, setWidth] = React.useState(null);
67
+ const { open } = useAccordionContext();
68
+ React.useLayoutEffect(() => {
69
+ const size = Array.from(
70
+ container.current?.children || []
71
+ ).reduce((prev, curr) => prev + curr.clientWidth, 0);
72
+ setWidth(`${size}px`);
73
+ }, []);
74
+ return /* @__PURE__ */ React.createElement(
75
+ "div",
76
+ {
77
+ className: clsx(
78
+ `overflow-hidden transition-[width] ease-in-out duration-200`,
79
+ { [`w-[${width}]`]: !!width && open },
80
+ { "w-0": !open }
81
+ ),
82
+ ref: container,
83
+ "data-testid": "accordion-container"
84
+ },
85
+ children
86
+ );
87
+ };
88
+ const Face = ({
89
+ children,
90
+ defaultOpen = false
91
+ }) => {
92
+ const [open, setOpen] = React.useState(defaultOpen);
93
+ const toggle = React.useCallback(() => setOpen((prev) => !prev), []);
94
+ return /* @__PURE__ */ React.createElement(Context.Provider, { value: { open, toggle } }, /* @__PURE__ */ React.createElement("div", { className: "flex flex-row" }, children));
95
+ };
96
+ const Root = ({ children, defaultOpen, label, floating }) => {
97
+ return /* @__PURE__ */ React.createElement(Face, { defaultOpen }, /* @__PURE__ */ React.createElement(Trigger, { label, floating }), /* @__PURE__ */ React.createElement(Content, null, children));
98
+ };
99
+ const Accordion = {
100
+ Face,
101
+ Root,
102
+ Trigger,
103
+ Content
104
+ };
105
+
106
+ exports.Accordion = Accordion;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ require('../Accordion.js');
4
5
  require('clsx');
5
6
  require('@internationalized/date');
6
7
  require('../Badge.js');
package/dist/cjs/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var Accordion = require('./components/Accordion.js');
3
4
  var Avatar = require('./components/Avatar.js');
4
5
  var Badge = require('./components/Badge.js');
5
6
  var BreadcrumbItem = require('./components/Breadcrumbs/BreadcrumbItem.js');
@@ -55,6 +56,7 @@ var masks = require('./components/Input/masks.js');
55
56
 
56
57
 
57
58
 
59
+ exports.Accordion = Accordion.Accordion;
58
60
  exports.Avatar = Avatar.Avatar;
59
61
  exports.Badge = Badge.Badge;
60
62
  exports.BadgeAnchor = Badge.BadgeAnchor;
@@ -2,6 +2,7 @@
2
2
 
3
3
  var sonner = require('sonner');
4
4
  var React = require('react');
5
+ require('../components/Accordion.js');
5
6
  require('clsx');
6
7
  require('@internationalized/date');
7
8
  require('../components/Badge.js');
@@ -0,0 +1,104 @@
1
+ import clsx from 'clsx';
2
+ import React__default, { createContext, useRef, useState, useLayoutEffect, useCallback, useContext } from 'react';
3
+ import { LiaAngleRightSolid } from 'react-icons/lia';
4
+
5
+ const Context = createContext({ open: false });
6
+ const useAccordionContext = () => {
7
+ const context = useContext(Context);
8
+ if (!context) {
9
+ throw new Error("useAccordionContext must be used within a Accordion");
10
+ }
11
+ return context;
12
+ };
13
+ const Trigger = ({
14
+ label,
15
+ floating = false,
16
+ /**
17
+ * Only applied to trigger arrow
18
+ */
19
+ className
20
+ }) => {
21
+ const { open, toggle } = useAccordionContext();
22
+ if (!floating && !label) {
23
+ throw new Error(
24
+ "A label must be specified if the trigger is not floating variant"
25
+ );
26
+ }
27
+ return /* @__PURE__ */ React__default.createElement(
28
+ "div",
29
+ {
30
+ className: clsx(
31
+ "flex flex-col justify-between align-center px-mili border-r border-secondary-light cursor-pointer",
32
+ { "mr-deca": floating }
33
+ ),
34
+ onClick: toggle
35
+ },
36
+ /* @__PURE__ */ React__default.createElement(
37
+ "div",
38
+ {
39
+ className: clsx(
40
+ "rounded-mili border border-secondary-light flex align-center justify-center p-micro",
41
+ {
42
+ "absolute -translate-x-micro translate-y-deca bg-white": floating
43
+ },
44
+ className
45
+ )
46
+ },
47
+ /* @__PURE__ */ React__default.createElement(
48
+ LiaAngleRightSolid,
49
+ {
50
+ className: clsx(
51
+ "text-secondary-medium transition-transform duration-200",
52
+ {
53
+ "rotate-180": open
54
+ }
55
+ )
56
+ }
57
+ )
58
+ ),
59
+ !floating ? /* @__PURE__ */ React__default.createElement("span", { className: "-rotate-180 [writing-mode:vertical-lr]" }, label) : null
60
+ );
61
+ };
62
+ const Content = ({ children }) => {
63
+ const container = useRef(null);
64
+ const [width, setWidth] = useState(null);
65
+ const { open } = useAccordionContext();
66
+ useLayoutEffect(() => {
67
+ const size = Array.from(
68
+ container.current?.children || []
69
+ ).reduce((prev, curr) => prev + curr.clientWidth, 0);
70
+ setWidth(`${size}px`);
71
+ }, []);
72
+ return /* @__PURE__ */ React__default.createElement(
73
+ "div",
74
+ {
75
+ className: clsx(
76
+ `overflow-hidden transition-[width] ease-in-out duration-200`,
77
+ { [`w-[${width}]`]: !!width && open },
78
+ { "w-0": !open }
79
+ ),
80
+ ref: container,
81
+ "data-testid": "accordion-container"
82
+ },
83
+ children
84
+ );
85
+ };
86
+ const Face = ({
87
+ children,
88
+ defaultOpen = false
89
+ }) => {
90
+ const [open, setOpen] = useState(defaultOpen);
91
+ const toggle = useCallback(() => setOpen((prev) => !prev), []);
92
+ return /* @__PURE__ */ React__default.createElement(Context.Provider, { value: { open, toggle } }, /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-row" }, children));
93
+ };
94
+ const Root = ({ children, defaultOpen, label, floating }) => {
95
+ return /* @__PURE__ */ React__default.createElement(Face, { defaultOpen }, /* @__PURE__ */ React__default.createElement(Trigger, { label, floating }), /* @__PURE__ */ React__default.createElement(Content, null, children));
96
+ };
97
+ const Accordion = {
98
+ Face,
99
+ Root,
100
+ Trigger,
101
+ Content
102
+ };
103
+
104
+ export { Accordion };
@@ -1,4 +1,5 @@
1
1
  import React__default, { Fragment } from 'react';
2
+ import '../Accordion.js';
2
3
  import 'clsx';
3
4
  import '@internationalized/date';
4
5
  import '../Badge.js';
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { Accordion } from './components/Accordion.js';
1
2
  export { Avatar } from './components/Avatar.js';
2
3
  export { Badge, BadgeAnchor } from './components/Badge.js';
3
4
  export { BreadcrumbItem } from './components/Breadcrumbs/BreadcrumbItem.js';
@@ -1,5 +1,6 @@
1
1
  import { toast } from 'sonner';
2
2
  import React__default from 'react';
3
+ import '../components/Accordion.js';
3
4
  import 'clsx';
4
5
  import '@internationalized/date';
5
6
  import '../components/Badge.js';
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ interface AccordionProps {
3
+ children?: React.ReactNode;
4
+ defaultOpen?: boolean;
5
+ label?: string;
6
+ floating?: boolean;
7
+ }
8
+ export declare const Accordion: {
9
+ Face: ({ children, defaultOpen, }: Pick<AccordionProps, 'children' | 'defaultOpen'>) => JSX.Element;
10
+ Root: ({ children, defaultOpen, label, floating }: AccordionProps) => JSX.Element;
11
+ Trigger: ({ label, floating, className, }: Pick<AccordionProps, 'floating' | 'label'> & {
12
+ className?: string;
13
+ }) => JSX.Element;
14
+ Content: ({ children }: Pick<AccordionProps, 'children'>) => JSX.Element;
15
+ };
16
+ export {};
@@ -1,3 +1,4 @@
1
+ export * from './Accordion';
1
2
  export * from './Avatar';
2
3
  export * from './Badge';
3
4
  export * from './Breadcrumbs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tecsinapse/cortex-react",
3
- "version": "1.3.4",
3
+ "version": "1.4.0-beta.0",
4
4
  "description": "React components based in @tecsinapse/cortex-core",
5
5
  "license": "MIT",
6
6
  "main": "dist/esm/index.js",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@floating-ui/react": "^0.26.18",
22
22
  "@internationalized/date": "*",
23
- "@tecsinapse/cortex-core": "0.3.1",
23
+ "@tecsinapse/cortex-core": "0.3.1-beta.2",
24
24
  "clsx": "*",
25
25
  "react-aria": "^3.33.1",
26
26
  "react-icons": "^5.2.1",
@@ -43,5 +43,5 @@
43
43
  "react-dom": ">=18.0.0",
44
44
  "tailwind": ">=3.3.0"
45
45
  },
46
- "gitHead": "01bd621b6459e9ed136a902aaeb9a33236dd4772"
46
+ "gitHead": "4f0144f31a476ce82c25a425fa95ef703c91a926"
47
47
  }
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';