@rovula/ui 0.0.16 → 0.0.17

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 (33) hide show
  1. package/dist/cjs/bundle.css +45 -0
  2. package/dist/cjs/bundle.js +3 -3
  3. package/dist/cjs/bundle.js.map +1 -1
  4. package/dist/cjs/types/components/Collapsible/Collapsible.d.ts +23 -0
  5. package/dist/cjs/types/components/Collapsible/Collapsible.stories.d.ts +8 -0
  6. package/dist/cjs/types/components/Collapsible/Collapsible.styles.d.ts +11 -0
  7. package/dist/cjs/types/components/Collapsible/CollapsibleContext.d.ts +16 -0
  8. package/dist/cjs/types/components/Collapsible/index.d.ts +1 -0
  9. package/dist/cjs/types/index.d.ts +1 -0
  10. package/dist/components/Collapsible/Collapsible.js +37 -0
  11. package/dist/components/Collapsible/Collapsible.stories.js +44 -0
  12. package/dist/components/Collapsible/Collapsible.styles.js +47 -0
  13. package/dist/components/Collapsible/CollapsibleContext.js +25 -0
  14. package/dist/components/Collapsible/index.js +1 -0
  15. package/dist/esm/bundle.css +45 -0
  16. package/dist/esm/bundle.js +3 -3
  17. package/dist/esm/bundle.js.map +1 -1
  18. package/dist/esm/types/components/Collapsible/Collapsible.d.ts +23 -0
  19. package/dist/esm/types/components/Collapsible/Collapsible.stories.d.ts +8 -0
  20. package/dist/esm/types/components/Collapsible/Collapsible.styles.d.ts +11 -0
  21. package/dist/esm/types/components/Collapsible/CollapsibleContext.d.ts +16 -0
  22. package/dist/esm/types/components/Collapsible/index.d.ts +1 -0
  23. package/dist/esm/types/index.d.ts +1 -0
  24. package/dist/index.d.ts +23 -1
  25. package/dist/index.js +1 -0
  26. package/dist/src/theme/global.css +56 -0
  27. package/package.json +1 -1
  28. package/src/components/Collapsible/Collapsible.stories.tsx +65 -0
  29. package/src/components/Collapsible/Collapsible.styles.ts +62 -0
  30. package/src/components/Collapsible/Collapsible.tsx +113 -0
  31. package/src/components/Collapsible/CollapsibleContext.tsx +61 -0
  32. package/src/components/Collapsible/index.ts +1 -0
  33. package/src/index.ts +1 -0
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ declare const CollapsibleButton: React.ForwardRefExoticComponent<{
3
+ children: React.ReactNode;
4
+ className?: string | undefined;
5
+ hideExpandIcon?: boolean | undefined;
6
+ } & React.RefAttributes<HTMLButtonElement>>;
7
+ declare const CollapsiblePanel: React.ForwardRefExoticComponent<{
8
+ children: React.ReactNode;
9
+ className?: string | undefined;
10
+ } & React.RefAttributes<HTMLDivElement>>;
11
+ interface CollapsibleComponent extends React.ForwardRefExoticComponent<CollapsibleProps & React.RefAttributes<HTMLDivElement>> {
12
+ Button: typeof CollapsibleButton;
13
+ Panel: typeof CollapsiblePanel;
14
+ }
15
+ interface CollapsibleProps {
16
+ size?: "sm" | "md" | "lg";
17
+ children: React.ReactNode;
18
+ isExpand?: boolean;
19
+ className?: string;
20
+ onToggle?: (isExpand: boolean) => void;
21
+ }
22
+ declare const Collapsible: CollapsibleComponent;
23
+ export default Collapsible;
@@ -0,0 +1,8 @@
1
+ declare const meta: any;
2
+ export default meta;
3
+ export declare const Default: {
4
+ args: {
5
+ size: string;
6
+ };
7
+ render: (args: {}) => import("react/jsx-runtime").JSX.Element;
8
+ };
@@ -0,0 +1,11 @@
1
+ export declare const collapseButtonVariants: (props?: ({
2
+ size?: "sm" | "md" | "lg" | null | undefined;
3
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
4
+ export declare const collapseIconVariants: (props?: ({
5
+ size?: "sm" | "md" | "lg" | null | undefined;
6
+ isExpand?: boolean | null | undefined;
7
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
8
+ export declare const collapsePanelVariants: (props?: ({
9
+ size?: "sm" | "md" | "lg" | null | undefined;
10
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
11
+ export declare const collapseContainerVariants: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
@@ -0,0 +1,16 @@
1
+ import React, { ReactNode } from "react";
2
+ interface CollapsibleContextProps {
3
+ size?: "sm" | "md" | "lg";
4
+ isExpand: boolean;
5
+ toggle: () => void;
6
+ setIsExpand: React.Dispatch<React.SetStateAction<boolean>>;
7
+ }
8
+ export declare const useCollapsible: () => CollapsibleContextProps;
9
+ interface CollapsibleProviderProps {
10
+ size?: "sm" | "md" | "lg";
11
+ children: ReactNode;
12
+ isExpandControlled?: boolean;
13
+ onToggle?: (isExpand: boolean) => void;
14
+ }
15
+ export declare const CollapsibleProvider: React.FC<CollapsibleProviderProps>;
16
+ export {};
@@ -0,0 +1 @@
1
+ export { default as Collapsible } from "./Collapsible";
@@ -10,6 +10,7 @@ export { Input } from "./components/Input/Input";
10
10
  export { Navbar } from "./components/Navbar";
11
11
  export { default as ActionButton } from "./components/ActionButton/ActionButton";
12
12
  export { Avatar, AvatarGroup } from "./components/Avatar";
13
+ export { Collapsible } from "./components/Collapsible";
13
14
  export * from "./components/Table/Table";
14
15
  export * from "./components/DataTable/DataTable";
15
16
  export * from "./components/Dialog/Dialog";
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useRef, useState } from "react";
3
+ import { ChevronDownIcon } from "@heroicons/react/16/solid";
4
+ import { CollapsibleProvider, useCollapsible } from "./CollapsibleContext";
5
+ import { cn } from "@/utils/cn";
6
+ import { collapseButtonVariants, collapseContainerVariants, collapseIconVariants, collapsePanelVariants, } from "./Collapsible.styles";
7
+ var CollapsibleButton = forwardRef(function (_a, ref) {
8
+ var children = _a.children, className = _a.className, _b = _a.hideExpandIcon, hideExpandIcon = _b === void 0 ? false : _b;
9
+ var _c = useCollapsible(), toggle = _c.toggle, isExpand = _c.isExpand, size = _c.size;
10
+ var collapseButtonClassName = collapseButtonVariants({ size: size });
11
+ var collapseIconClassName = collapseIconVariants({ isExpand: isExpand, size: size });
12
+ return (_jsxs("button", { onClick: toggle, className: cn(collapseButtonClassName, className), ref: ref, children: [_jsx("span", { className: "flex flex-1", children: children }), !hideExpandIcon && (_jsx("span", { className: cn(collapseIconClassName), children: _jsx(ChevronDownIcon, { className: cn("size-full") }) }))] }));
13
+ });
14
+ CollapsibleButton.displayName = "CollapsibleButton";
15
+ var CollapsiblePanel = forwardRef(function (_a, ref) {
16
+ var children = _a.children, className = _a.className;
17
+ var _b = useCollapsible(), isExpand = _b.isExpand, size = _b.size;
18
+ var collapsePanelClassName = collapsePanelVariants({ size: size });
19
+ var _c = useState("0px"), height = _c[0], setHeight = _c[1];
20
+ var contentRef = useRef(null);
21
+ useEffect(function () {
22
+ if (contentRef.current) {
23
+ setHeight(isExpand ? "".concat(contentRef.current.scrollHeight, "px") : "0px");
24
+ }
25
+ }, [isExpand, children]); // Add `children` to the dependency array to recalculate height on content change
26
+ return (_jsx("div", { ref: ref, className: cn("overflow-hidden transition-all ease-in-out"), style: { height: height }, children: _jsx("div", { ref: contentRef, className: cn(collapsePanelClassName, className), children: children }) }));
27
+ });
28
+ CollapsiblePanel.displayName = "CollapsiblePanel";
29
+ var Collapsible = forwardRef(function (_a, ref) {
30
+ var children = _a.children, isExpand = _a.isExpand, size = _a.size, className = _a.className, onToggle = _a.onToggle;
31
+ var collapseContainerClassName = collapseContainerVariants();
32
+ return (_jsx(CollapsibleProvider, { size: size, isExpandControlled: isExpand, onToggle: onToggle, children: _jsx("div", { ref: ref, className: cn(collapseContainerClassName, className), children: children }) }));
33
+ });
34
+ Collapsible.displayName = "Collapsible";
35
+ Collapsible.Button = CollapsibleButton;
36
+ Collapsible.Panel = CollapsiblePanel;
37
+ export default Collapsible;
@@ -0,0 +1,44 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useEffect } from "react";
14
+ import Collapsible from "./Collapsible";
15
+ var meta = {
16
+ title: "Components/Collapsible",
17
+ component: Collapsible,
18
+ tags: ["autodocs"],
19
+ parameters: {
20
+ layout: "fullscreen",
21
+ },
22
+ decorators: [
23
+ function (Story) { return (_jsx("div", { className: "p-5 flex w-full", children: _jsx(Story, {}) })); },
24
+ ],
25
+ };
26
+ export default meta;
27
+ var Test = function () {
28
+ useEffect(function () {
29
+ console.log("Mont");
30
+ return function () {
31
+ console.log("UnMont");
32
+ };
33
+ }, []);
34
+ return _jsx("p", { children: "This is the content of section 1." });
35
+ };
36
+ export var Default = {
37
+ args: {
38
+ size: "md",
39
+ },
40
+ render: function (args) {
41
+ var props = __assign({}, args);
42
+ return (_jsxs("div", { className: "flex flex-col gap-1 w-full ", children: [_jsxs(Collapsible, __assign({ isExpand: true }, props, { children: [_jsx(Collapsible.Button, { children: "Section 1" }), _jsx(Collapsible.Panel, { children: "This is the content of section 1." })] })), _jsxs(Collapsible, { children: [_jsx(Collapsible.Button, { children: "Section 2" }), _jsx(Collapsible.Panel, { children: _jsx("p", { children: "This is the content of section 2." }) })] }), _jsxs(Collapsible, { children: [_jsx(Collapsible.Button, { children: "Section 3" }), _jsx(Collapsible.Panel, { children: _jsx("p", { children: "This is the content of section 3." }) })] })] }));
43
+ },
44
+ };
@@ -0,0 +1,47 @@
1
+ import { cva } from "class-variance-authority";
2
+ export var collapseButtonVariants = cva([
3
+ "flex flex-1 bg-gray-100 hover:bg-gray-200",
4
+ "focus:outline-none focus-visible:ring focus-visible:ring-gray-500 focus-visible:ring-opacity-75",
5
+ ], {
6
+ variants: {
7
+ size: {
8
+ sm: "py-2 px-3",
9
+ md: "py-3 px-4",
10
+ lg: "py-4 px-5",
11
+ },
12
+ },
13
+ defaultVariants: {
14
+ size: "md",
15
+ },
16
+ });
17
+ export var collapseIconVariants = cva(["transition-all flex content-center justify-center "], {
18
+ variants: {
19
+ size: {
20
+ sm: "size-5",
21
+ md: "size-6",
22
+ lg: "size-7",
23
+ },
24
+ isExpand: {
25
+ true: "rotate-180",
26
+ },
27
+ },
28
+ defaultVariants: {
29
+ size: "md",
30
+ isExpand: false,
31
+ },
32
+ });
33
+ export var collapsePanelVariants = cva(["flex flex-1 border-t", "transition ease-in-out delay-150 duration-300"], {
34
+ variants: {
35
+ size: {
36
+ sm: "py-2 px-3",
37
+ md: "py-3 px-4",
38
+ lg: "py-4 px-5",
39
+ },
40
+ },
41
+ defaultVariants: {
42
+ size: "md",
43
+ },
44
+ });
45
+ export var collapseContainerVariants = cva([
46
+ "flex flex-col border rounded overflow-hidden",
47
+ ]);
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useState, useEffect, } from "react";
3
+ var CollapsibleContext = createContext(undefined);
4
+ export var useCollapsible = function () {
5
+ var context = useContext(CollapsibleContext);
6
+ if (!context) {
7
+ throw new Error("useCollapsible must be used within a CollapsibleProvider");
8
+ }
9
+ return context;
10
+ };
11
+ export var CollapsibleProvider = function (_a) {
12
+ var size = _a.size, children = _a.children, isExpandControlled = _a.isExpandControlled, onToggle = _a.onToggle;
13
+ var _b = useState(false), isExpand = _b[0], setIsExpand = _b[1];
14
+ var toggle = function () {
15
+ setIsExpand(function (prev) { return !prev; });
16
+ if (onToggle)
17
+ onToggle(!isExpand);
18
+ };
19
+ useEffect(function () {
20
+ if (isExpandControlled !== undefined) {
21
+ setIsExpand(isExpandControlled);
22
+ }
23
+ }, [isExpandControlled]);
24
+ return (_jsx(CollapsibleContext.Provider, { value: { size: size, isExpand: isExpand, toggle: toggle, setIsExpand: setIsExpand }, children: children }));
25
+ };
@@ -0,0 +1 @@
1
+ export { default as Collapsible } from "./Collapsible";
@@ -896,10 +896,18 @@ video {
896
896
  width: 1.5rem;
897
897
  height: 1.5rem;
898
898
  }
899
+ .size-7 {
900
+ width: 1.75rem;
901
+ height: 1.75rem;
902
+ }
899
903
  .size-\[14px\] {
900
904
  width: 14px;
901
905
  height: 14px;
902
906
  }
907
+ .size-full {
908
+ width: 100%;
909
+ height: 100%;
910
+ }
903
911
  .h-10 {
904
912
  height: 2.5rem;
905
913
  }
@@ -1079,6 +1087,9 @@ video {
1079
1087
  .flex-wrap {
1080
1088
  flex-wrap: wrap;
1081
1089
  }
1090
+ .content-center {
1091
+ align-content: center;
1092
+ }
1082
1093
  .items-center {
1083
1094
  align-items: center;
1084
1095
  }
@@ -1301,6 +1312,10 @@ video {
1301
1312
  --tw-bg-opacity: 1;
1302
1313
  background-color: rgb(var(--error-100) / var(--tw-bg-opacity));
1303
1314
  }
1315
+ .bg-gray-100 {
1316
+ --tw-bg-opacity: 1;
1317
+ background-color: rgb(243 244 246 / var(--tw-bg-opacity));
1318
+ }
1304
1319
  .bg-gray-200 {
1305
1320
  --tw-bg-opacity: 1;
1306
1321
  background-color: rgb(229 231 235 / var(--tw-bg-opacity));
@@ -1448,6 +1463,10 @@ video {
1448
1463
  padding-left: 1rem;
1449
1464
  padding-right: 1rem;
1450
1465
  }
1466
+ .px-5 {
1467
+ padding-left: 1.25rem;
1468
+ padding-right: 1.25rem;
1469
+ }
1451
1470
  .px-6 {
1452
1471
  padding-left: 1.5rem;
1453
1472
  padding-right: 1.5rem;
@@ -1824,6 +1843,13 @@ video {
1824
1843
  .filter {
1825
1844
  filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
1826
1845
  }
1846
+ .transition {
1847
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;
1848
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
1849
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;
1850
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
1851
+ transition-duration: 150ms;
1852
+ }
1827
1853
  .transition-all {
1828
1854
  transition-property: all;
1829
1855
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
@@ -1839,6 +1865,9 @@ video {
1839
1865
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
1840
1866
  transition-duration: 150ms;
1841
1867
  }
1868
+ .delay-150 {
1869
+ transition-delay: 150ms;
1870
+ }
1842
1871
  .duration-200 {
1843
1872
  transition-duration: 200ms;
1844
1873
  }
@@ -1990,6 +2019,10 @@ video {
1990
2019
  --tw-bg-opacity: 1;
1991
2020
  background-color: rgb(243 244 246 / var(--tw-bg-opacity));
1992
2021
  }
2022
+ .hover\:bg-gray-200:hover {
2023
+ --tw-bg-opacity: 1;
2024
+ background-color: rgb(229 231 235 / var(--tw-bg-opacity));
2025
+ }
1993
2026
  .hover\:bg-info-100:hover {
1994
2027
  --tw-bg-opacity: 1;
1995
2028
  background-color: rgb(var(--info-100)) / var(--tw-bg-opacity));
@@ -2109,14 +2142,26 @@ video {
2109
2142
  outline: 2px solid transparent;
2110
2143
  outline-offset: 2px;
2111
2144
  }
2145
+ .focus-visible\:ring:focus-visible {
2146
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
2147
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);
2148
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
2149
+ }
2112
2150
  .focus-visible\:ring-2:focus-visible {
2113
2151
  --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
2114
2152
  --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
2115
2153
  box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
2116
2154
  }
2155
+ .focus-visible\:ring-gray-500:focus-visible {
2156
+ --tw-ring-opacity: 1;
2157
+ --tw-ring-color: rgb(107 114 128 / var(--tw-ring-opacity));
2158
+ }
2117
2159
  .focus-visible\:ring-ring:focus-visible {
2118
2160
  --tw-ring-color: hsl(var(--ring));
2119
2161
  }
2162
+ .focus-visible\:ring-opacity-75:focus-visible {
2163
+ --tw-ring-opacity: 0.75;
2164
+ }
2120
2165
  .focus-visible\:ring-offset-2:focus-visible {
2121
2166
  --tw-ring-offset-width: 2px;
2122
2167
  }