@agilant/toga-blox 1.0.210 → 1.0.212
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.
- package/dist/components/DropdownContainer/DropdownContainer.d.ts +0 -1
- package/dist/components/DropdownContainer/DropdownContainer.js +6 -5
- package/dist/components/DropdownContainer/DropdownContainer.stories.d.ts +0 -1
- package/dist/components/DropdownContainer/DropdownContainer.stories.js +16 -12
- package/package.json +1 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
2
|
import { motion, AnimatePresence } from "framer-motion";
|
|
4
3
|
const DropdownContainer = ({ isOpen, toggleOpen, title, toggleIcon, children, expandAllLabel = "Expand All", collapseAllLabel = "Collapse All", onGlobalToggle, globalOpen = false, showGlobalToggle = false, additionalContainerClassNames = "", additionalContentClassNames = "", }) => {
|
|
5
|
-
const [isHeaderHovered, setIsHeaderHovered] = useState(false);
|
|
6
4
|
const globalLabel = globalOpen ? collapseAllLabel : expandAllLabel;
|
|
7
5
|
// Only the arrow wrapper gets this style
|
|
8
6
|
const iconStyle = {
|
|
@@ -11,8 +9,11 @@ const DropdownContainer = ({ isOpen, toggleOpen, title, toggleIcon, children, ex
|
|
|
11
9
|
fontSize: "18px",
|
|
12
10
|
display: "flex",
|
|
13
11
|
alignItems: "center",
|
|
12
|
+
cursor: "pointer",
|
|
14
13
|
};
|
|
15
|
-
return (
|
|
14
|
+
return (
|
|
15
|
+
// 1) Add `group` so children can react to container hover
|
|
16
|
+
_jsxs("div", { className: `group ${additionalContainerClassNames}`, children: [_jsxs("div", { onClick: toggleOpen, style: {
|
|
16
17
|
display: "flex",
|
|
17
18
|
alignItems: "center",
|
|
18
19
|
padding: "8px",
|
|
@@ -21,9 +22,9 @@ const DropdownContainer = ({ isOpen, toggleOpen, title, toggleIcon, children, ex
|
|
|
21
22
|
display: "flex",
|
|
22
23
|
alignItems: "center",
|
|
23
24
|
gap: "8px",
|
|
24
|
-
}, children: [showGlobalToggle && onGlobalToggle &&
|
|
25
|
+
}, children: [showGlobalToggle && onGlobalToggle && (_jsx("span", { onClick: (e) => {
|
|
25
26
|
e.stopPropagation();
|
|
26
27
|
onGlobalToggle();
|
|
27
|
-
},
|
|
28
|
+
}, className: "\n opacity-0\n group-hover:opacity-100\n transition-opacity duration-200\n cursor-pointer select-none\n text-sm\n ", children: globalLabel })), toggleIcon && _jsx("div", { style: iconStyle, children: toggleIcon })] })] }), _jsx(AnimatePresence, { initial: false, children: isOpen && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.3 }, style: { overflow: "hidden" }, children: _jsx("div", { className: additionalContentClassNames, children: children }) }, "content")) })] }));
|
|
28
29
|
};
|
|
29
30
|
export default DropdownContainer;
|
|
@@ -10,6 +10,5 @@ export declare const SingleDropdown: StoryObj<typeof DropdownContainer>;
|
|
|
10
10
|
/**
|
|
11
11
|
* 2) Multiple Dropdowns Example
|
|
12
12
|
* Renders multiple DropdownContainer components with a shared global toggle.
|
|
13
|
-
* The global toggle text ("Expand All" / "Collapse All") appears only when the header is hovered over.
|
|
14
13
|
*/
|
|
15
14
|
export declare const MultipleDropdowns: StoryObj<typeof DropdownContainer>;
|
|
@@ -11,7 +11,6 @@ export default {
|
|
|
11
11
|
argTypes: {
|
|
12
12
|
title: { control: "text" },
|
|
13
13
|
toggleIcon: { control: false },
|
|
14
|
-
// The open and toggle handler props are managed internally via stories.
|
|
15
14
|
isOpen: { table: { disable: true } },
|
|
16
15
|
toggleOpen: { table: { disable: true } },
|
|
17
16
|
color: { control: "color" },
|
|
@@ -19,7 +18,7 @@ export default {
|
|
|
19
18
|
tags: ["autodocs"],
|
|
20
19
|
parameters: {
|
|
21
20
|
docs: {
|
|
22
|
-
page: () => (_jsxs(_Fragment, { children: [_jsx(Title, {}), _jsx(Subtitle, {}), _jsx(Description, {
|
|
21
|
+
page: () => (_jsxs(_Fragment, { children: [_jsx(Title, {}), _jsx(Subtitle, {}), _jsx(Description, { children: `
|
|
23
22
|
The **DropdownContainer** component provides:
|
|
24
23
|
|
|
25
24
|
- **Individual Toggle:** Click the header to open/close the container.
|
|
@@ -40,6 +39,15 @@ export const SingleDropdown = {
|
|
|
40
39
|
title: "Sales",
|
|
41
40
|
toggleIcon: _jsx("span", { style: { fontSize: "18px" }, children: "\uD83D\uDD3D" }),
|
|
42
41
|
children: defaultContent,
|
|
42
|
+
// ⬇️ ADDED: make this a hover group + border highlight
|
|
43
|
+
additionalContainerClassNames: "group bg-white rounded border border-transparent hover:border-navy-350",
|
|
44
|
+
additionalContentClassNames: "p-2",
|
|
45
|
+
// ⬇️ ADDED: enable the global toggle label on hover
|
|
46
|
+
showGlobalToggle: true,
|
|
47
|
+
expandAllLabel: "Expand All",
|
|
48
|
+
collapseAllLabel: "Collapse All",
|
|
49
|
+
onGlobalToggle: () => { }, // no-op for single
|
|
50
|
+
globalOpen: false,
|
|
43
51
|
},
|
|
44
52
|
render: (args) => {
|
|
45
53
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -49,7 +57,6 @@ export const SingleDropdown = {
|
|
|
49
57
|
/**
|
|
50
58
|
* 2) Multiple Dropdowns Example
|
|
51
59
|
* Renders multiple DropdownContainer components with a shared global toggle.
|
|
52
|
-
* The global toggle text ("Expand All" / "Collapse All") appears only when the header is hovered over.
|
|
53
60
|
*/
|
|
54
61
|
export const MultipleDropdowns = {
|
|
55
62
|
name: "Multiple Dropdowns",
|
|
@@ -58,9 +65,7 @@ export const MultipleDropdowns = {
|
|
|
58
65
|
},
|
|
59
66
|
render: (args) => {
|
|
60
67
|
const titles = ["Sales", "Marketing", "Development"];
|
|
61
|
-
// Maintain an array of booleans for the open state of each dropdown.
|
|
62
68
|
const [openStates, setOpenStates] = useState(titles.map(() => false));
|
|
63
|
-
// Toggle an individual dropdown.
|
|
64
69
|
const toggleContainer = (index) => {
|
|
65
70
|
setOpenStates((prev) => {
|
|
66
71
|
const newStates = [...prev];
|
|
@@ -68,14 +73,13 @@ export const MultipleDropdowns = {
|
|
|
68
73
|
return newStates;
|
|
69
74
|
});
|
|
70
75
|
};
|
|
71
|
-
// Determine if every dropdown is open.
|
|
72
76
|
const allOpen = openStates.every(Boolean);
|
|
73
|
-
|
|
74
|
-
const globalToggle = () => {
|
|
75
|
-
setOpenStates(openStates.map(() => !allOpen));
|
|
76
|
-
};
|
|
77
|
-
// Show the global toggle text only if at least one dropdown is open.
|
|
77
|
+
const globalToggle = () => setOpenStates(openStates.map(() => !allOpen));
|
|
78
78
|
const showGlobalToggle = openStates.some(Boolean);
|
|
79
|
-
return (_jsx("div", { children: titles.map((title, index) => (_jsx(DropdownContainer, { title: title, isOpen: openStates[index], toggleOpen: () => toggleContainer(index), toggleIcon: _jsx("span", { style: { fontSize: "18px" }, children: "\uD83D\uDD3D" }),
|
|
79
|
+
return (_jsx("div", { children: titles.map((title, index) => (_jsx(DropdownContainer, { title: title, isOpen: openStates[index], toggleOpen: () => toggleContainer(index), toggleIcon: _jsx("span", { style: { fontSize: "18px" }, children: "\uD83D\uDD3D" }),
|
|
80
|
+
// ⬇️ ADDED: same hover‑group + border for each
|
|
81
|
+
additionalContainerClassNames: "group bg-white rounded border border-transparent hover:border-navy-350", additionalContentClassNames: "p-2",
|
|
82
|
+
// ⬇️ ADDED: global toggle props
|
|
83
|
+
showGlobalToggle: showGlobalToggle, expandAllLabel: "Expand All", collapseAllLabel: "Collapse All", onGlobalToggle: globalToggle, globalOpen: allOpen, children: args.children }, index))) }));
|
|
80
84
|
},
|
|
81
85
|
};
|