@sebgroup/green-react 1.9.0 → 1.9.1

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
 
@@ -3914,4 +3993,4 @@ const Modal = _a => {
3914
3993
  return isOpen ? modalContent() : null;
3915
3994
  };
3916
3995
 
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 };
3996
+ 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.0",
3
+ "version": "1.9.1",
4
4
  "peerDependencies": {
5
5
  "react": "^17 || ^18",
6
6
  "react-dom": "^17 || ^18"
7
7
  },
8
8
  "dependencies": {
9
9
  "@sebgroup/chlorophyll": "^1.10.0",
10
- "@sebgroup/extract": "^1.3.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;