@sebgroup/green-react 1.9.0 → 1.9.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.
package/index.js
CHANGED
|
@@ -1620,6 +1620,85 @@ for (var COLLECTION_NAME in DOMIterables) {
|
|
|
1620
1620
|
|
|
1621
1621
|
handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
|
|
1622
1622
|
|
|
1623
|
+
const AccordionItem = ({
|
|
1624
|
+
item,
|
|
1625
|
+
index,
|
|
1626
|
+
uuid
|
|
1627
|
+
}) => {
|
|
1628
|
+
const {
|
|
1629
|
+
labelElementLevel,
|
|
1630
|
+
label,
|
|
1631
|
+
subLabel,
|
|
1632
|
+
content
|
|
1633
|
+
} = item;
|
|
1634
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
1635
|
+
const handleOnClick = event => {
|
|
1636
|
+
item.onClick && item.onClick(event);
|
|
1637
|
+
setIsOpen(state => {
|
|
1638
|
+
if (!state) {
|
|
1639
|
+
item.onOpen && item.onOpen(event);
|
|
1640
|
+
} else {
|
|
1641
|
+
item.onClose && item.onClose(event);
|
|
1642
|
+
}
|
|
1643
|
+
return !state;
|
|
1644
|
+
});
|
|
1645
|
+
};
|
|
1646
|
+
return jsxs("div", {
|
|
1647
|
+
children: [jsx("div", Object.assign({
|
|
1648
|
+
role: "heading",
|
|
1649
|
+
"aria-level": labelElementLevel
|
|
1650
|
+
}, {
|
|
1651
|
+
children: jsxs("button", Object.assign({
|
|
1652
|
+
id: `accordion-item-button-${index}-${uuid}`,
|
|
1653
|
+
"aria-expanded": isOpen,
|
|
1654
|
+
"aria-controls": `accordion-item-region-${index}-${uuid}`,
|
|
1655
|
+
onClick: event => {
|
|
1656
|
+
handleOnClick(event);
|
|
1657
|
+
}
|
|
1658
|
+
}, {
|
|
1659
|
+
children: [jsx("span", {
|
|
1660
|
+
children: label
|
|
1661
|
+
}), subLabel && jsx("span", {
|
|
1662
|
+
children: subLabel
|
|
1663
|
+
}), jsx("svg", Object.assign({
|
|
1664
|
+
viewBox: "0 0 24 24",
|
|
1665
|
+
fill: "none",
|
|
1666
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1667
|
+
}, {
|
|
1668
|
+
children: jsx("path", {
|
|
1669
|
+
d: "M18.8095 9.22817L18.1907 8.60942C18.0438 8.46255 17.8063 8.46255 17.6595 8.60942L12.0001 14.2563L6.34072 8.60942C6.19385 8.46255 5.95635 8.46255 5.80947 8.60942L5.19072 9.22817C5.04385 9.37505 5.04385 9.61255 5.19072 9.75942L11.7345 16.3032C11.8813 16.45 12.1188 16.45 12.2657 16.3032L18.8095 9.75942C18.9563 9.61255 18.9563 9.37505 18.8095 9.22817Z",
|
|
1670
|
+
fill: "#333333"
|
|
1671
|
+
})
|
|
1672
|
+
}))]
|
|
1673
|
+
}))
|
|
1674
|
+
})), jsx("div", Object.assign({
|
|
1675
|
+
role: "region",
|
|
1676
|
+
id: `accordion-item-region-${index}-${uuid}`,
|
|
1677
|
+
"aria-labelledby": `accordion-item-button-${index}-${uuid}`,
|
|
1678
|
+
hidden: !isOpen
|
|
1679
|
+
}, {
|
|
1680
|
+
children: jsx("div", {
|
|
1681
|
+
children: content
|
|
1682
|
+
})
|
|
1683
|
+
}))]
|
|
1684
|
+
});
|
|
1685
|
+
};
|
|
1686
|
+
|
|
1687
|
+
const Accordion = ({
|
|
1688
|
+
items
|
|
1689
|
+
}) => {
|
|
1690
|
+
const uuid = randomId();
|
|
1691
|
+
return jsx("div", Object.assign({
|
|
1692
|
+
className: "accordion"
|
|
1693
|
+
}, {
|
|
1694
|
+
children: items && items.map((item, index) => jsx(AccordionItem, {
|
|
1695
|
+
item: item,
|
|
1696
|
+
index: index,
|
|
1697
|
+
uuid: uuid
|
|
1698
|
+
}, `accordion-${uuid}-${index}`))
|
|
1699
|
+
}));
|
|
1700
|
+
};
|
|
1701
|
+
|
|
1623
1702
|
/******************************************************************************
|
|
1624
1703
|
Copyright (c) Microsoft Corporation.
|
|
1625
1704
|
|
|
@@ -2402,6 +2481,7 @@ function Button({
|
|
|
2402
2481
|
}
|
|
2403
2482
|
|
|
2404
2483
|
const IconButton = _a => {
|
|
2484
|
+
var _b;
|
|
2405
2485
|
var {
|
|
2406
2486
|
children,
|
|
2407
2487
|
onClick
|
|
@@ -2411,7 +2491,8 @@ const IconButton = _a => {
|
|
|
2411
2491
|
className: "icon",
|
|
2412
2492
|
onClick: onClick,
|
|
2413
2493
|
"aria-controls": props['aria-controls'],
|
|
2414
|
-
"aria-expanded": props['aria-expanded']
|
|
2494
|
+
"aria-expanded": props['aria-expanded'],
|
|
2495
|
+
type: (_b = props.type) !== null && _b !== void 0 ? _b : 'button'
|
|
2415
2496
|
}, {
|
|
2416
2497
|
children: children
|
|
2417
2498
|
}));
|
|
@@ -3914,4 +3995,4 @@ const Modal = _a => {
|
|
|
3914
3995
|
return isOpen ? modalContent() : null;
|
|
3915
3996
|
};
|
|
3916
3997
|
|
|
3917
|
-
export { AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItem, FormItems, Group, Link, List$1 as List, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, RenderInput, Select, Slider, Stepper, Tabs, Text, TextInput, valueList$1 as ValueList };
|
|
3998
|
+
export { Accordion, AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItem, FormItems, Group, Link, List$1 as List, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, RenderInput, Select, Slider, Stepper, Tabs, Text, TextInput, valueList$1 as ValueList };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebgroup/green-react",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": "^17 || ^18",
|
|
6
6
|
"react-dom": "^17 || ^18"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@sebgroup/chlorophyll": "^1.10.
|
|
10
|
-
"@sebgroup/extract": "^1.3.
|
|
9
|
+
"@sebgroup/chlorophyll": "^1.10.1",
|
|
10
|
+
"@sebgroup/extract": "^1.3.2",
|
|
11
11
|
"classnames": "^2.3.2"
|
|
12
12
|
},
|
|
13
13
|
"description": "React components built on top of @sebgroup/chlorophyll.",
|
|
@@ -2,5 +2,5 @@ import { AccordionItemInterface } from './accordion-item';
|
|
|
2
2
|
export interface AccordionInterface {
|
|
3
3
|
items: AccordionItemInterface[];
|
|
4
4
|
}
|
|
5
|
-
declare const Accordion: ({ items }: AccordionInterface) => JSX.Element;
|
|
5
|
+
export declare const Accordion: ({ items }: AccordionInterface) => JSX.Element;
|
|
6
6
|
export default Accordion;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ReactNode, MouseEvent } from 'react';
|
|
2
|
+
import { ButtonType } from '@sebgroup/extract';
|
|
2
3
|
interface IconButtonInterface {
|
|
3
4
|
children: ReactNode;
|
|
5
|
+
type?: ButtonType;
|
|
4
6
|
onClick: (event: MouseEvent) => void;
|
|
5
7
|
'aria-expanded'?: boolean;
|
|
6
8
|
'aria-controls'?: string;
|