@sebgroup/green-react 1.0.0-beta.2 → 1.0.0-beta.3

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.
@@ -1,19 +1,19 @@
1
- import { DropdownOption } from '@sebgroup/extract';
2
- import { HTMLAttributes } from 'react';
1
+ import { DropdownHandler, DropdownOption } from '@sebgroup/extract';
2
+ import { HTMLAttributes, RefObject } from 'react';
3
3
  interface HookArgs {
4
4
  id?: string;
5
5
  text?: string;
6
6
  options: DropdownOption[];
7
7
  loop?: boolean;
8
+ togglerRef: RefObject<HTMLElement>;
9
+ listboxRef: RefObject<HTMLElement>;
8
10
  }
9
11
  declare type Props = HTMLAttributes<HTMLElement>;
10
12
  interface HookResult {
13
+ dropdown?: DropdownHandler;
11
14
  togglerProps: Props;
12
15
  listboxProps: Props;
13
16
  listItems: Props[];
14
- activate: () => void;
15
- deactivate: () => void;
16
- close: () => void;
17
17
  }
18
- export declare const useDropdown: ({ id, text, options, loop }: HookArgs) => HookResult;
18
+ export declare const useDropdown: ({ id, text, options, loop, togglerRef, listboxRef }: HookArgs) => HookResult;
19
19
  export {};
@@ -0,0 +1,9 @@
1
+ import { PropsWithChildren } from 'react';
2
+ interface FlexboxProps {
3
+ alignContent?: 'start' | 'between' | 'center' | 'stretch' | 'around' | 'end';
4
+ alignItems?: 'start' | 'end' | 'center' | 'baseline' | 'stretch';
5
+ alignSelf?: 'auto' | 'start' | 'end' | 'center' | 'baseline' | 'stretch';
6
+ justifyContent?: 'start' | 'between' | 'center' | 'evenly' | 'around' | 'end';
7
+ }
8
+ export declare const Flexbox: ({ alignContent, alignItems, alignSelf, children, justifyContent, }: PropsWithChildren<FlexboxProps>) => JSX.Element;
9
+ export default Flexbox;
@@ -1 +1,2 @@
1
+ export * from './flexbox';
1
2
  export * from './group';
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@sebgroup/green-react",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "peerDependencies": {
5
5
  "react": "^17.0.2",
6
6
  "react-dom": "^17.0.2",
7
+ "@popperjs/core": "^2.11.0",
7
8
  "rxjs": "^6.6.7",
8
9
  "merge": "^2.1.1"
9
10
  },
10
11
  "dependencies": {
11
- "@sebgroup/chlorophyll": "1.0.0-beta.2",
12
- "@sebgroup/extract": "1.0.0-beta.2",
13
- "react-popper": "^2.2.5"
12
+ "@sebgroup/chlorophyll": "^1.0.0-beta.3",
13
+ "@sebgroup/extract": "^1.0.0-beta.3"
14
14
  },
15
15
  "description": "React components built on top of @sebgroup/chlorophyll.",
16
16
  "repository": {
package/react.esm.js CHANGED
@@ -1108,38 +1108,6 @@ const Modal = _a => {
1108
1108
  }), void 0);
1109
1109
  };
1110
1110
 
1111
- function Group({
1112
- children
1113
- }) {
1114
- return jsx("div", Object.assign({
1115
- className: "group"
1116
- }, {
1117
- children: children
1118
- }), void 0);
1119
- }
1120
-
1121
- function Card({
1122
- children,
1123
- headline,
1124
- buttons
1125
- }) {
1126
- return jsx("section", Object.assign({
1127
- className: "card"
1128
- }, {
1129
- children: jsxs("div", Object.assign({
1130
- className: "card-body"
1131
- }, {
1132
- children: [headline && jsx("h2", {
1133
- children: headline
1134
- }, void 0), jsx("p", {
1135
- children: children
1136
- }, void 0), buttons && jsx("footer", {
1137
- children: buttons
1138
- }, void 0)]
1139
- }), void 0)
1140
- }), void 0);
1141
- }
1142
-
1143
1111
  var DESCRIPTORS = descriptors;
1144
1112
  var definePropertyModule$1 = objectDefineProperty;
1145
1113
  var anObject$2 = anObject$5;
@@ -1648,6 +1616,68 @@ for (var COLLECTION_NAME in DOMIterables) {
1648
1616
 
1649
1617
  handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
1650
1618
 
1619
+ const Flexbox = ({
1620
+ alignContent,
1621
+ alignItems,
1622
+ alignSelf,
1623
+ children,
1624
+ justifyContent
1625
+ }) => {
1626
+ const [classes, setClasses] = useState(['d-flex']);
1627
+ const [className, setClassName] = useState('d-flex'); // update className when classes change
1628
+
1629
+ useEffect(() => {
1630
+ const newClassName = classes.join(' ');
1631
+ if (newClassName !== className) setClassName(newClassName);
1632
+ }, [classes, className]); // update classes when props change
1633
+
1634
+ useEffect(() => {
1635
+ const newClasses = ['d-flex'];
1636
+ if (alignItems) newClasses.push(`align-items-${alignItems}`);
1637
+ if (alignContent) newClasses.push(`align-content-${alignContent}`);
1638
+ if (alignSelf) newClasses.push(`align-content-${alignSelf}`);
1639
+ if (justifyContent) newClasses.push(`justify-content-${justifyContent}`);
1640
+ setClasses(newClasses);
1641
+ }, [alignContent, alignItems, alignSelf, justifyContent]);
1642
+ return jsx("div", Object.assign({
1643
+ className: className
1644
+ }, {
1645
+ children: children
1646
+ }), void 0);
1647
+ };
1648
+
1649
+ function Group({
1650
+ children
1651
+ }) {
1652
+ return jsx("div", Object.assign({
1653
+ className: "group"
1654
+ }, {
1655
+ children: children
1656
+ }), void 0);
1657
+ }
1658
+
1659
+ function Card({
1660
+ children,
1661
+ headline,
1662
+ buttons
1663
+ }) {
1664
+ return jsx("section", Object.assign({
1665
+ className: "card"
1666
+ }, {
1667
+ children: jsxs("div", Object.assign({
1668
+ className: "card-body"
1669
+ }, {
1670
+ children: [headline && jsx("h2", {
1671
+ children: headline
1672
+ }, void 0), jsx("p", {
1673
+ children: children
1674
+ }, void 0), buttons && jsx("footer", {
1675
+ children: buttons
1676
+ }, void 0)]
1677
+ }), void 0)
1678
+ }), void 0);
1679
+ }
1680
+
1651
1681
  function Alert({
1652
1682
  type,
1653
1683
  heading,
@@ -1950,4 +1980,4 @@ const Checkbox = _a => {
1950
1980
  }), void 0);
1951
1981
  };
1952
1982
 
1953
- export { Alert, Button, ButtonGroup, Card, Checkbox, EmailInput, Form, Group, Modal, NumberInput, TextInput };
1983
+ export { Alert, Button, ButtonGroup, Card, Checkbox, EmailInput, Flexbox, Form, Group, Modal, NumberInput, TextInput };
package/react.umd.js CHANGED
@@ -145,6 +145,42 @@
145
145
  }), void 0);
146
146
  };
147
147
 
148
+ var Flexbox = function Flexbox(_a) {
149
+ var alignContent = _a.alignContent,
150
+ alignItems = _a.alignItems,
151
+ alignSelf = _a.alignSelf,
152
+ children = _a.children,
153
+ justifyContent = _a.justifyContent;
154
+
155
+ var _b = react.useState(['d-flex']),
156
+ classes = _b[0],
157
+ setClasses = _b[1];
158
+
159
+ var _c = react.useState('d-flex'),
160
+ className = _c[0],
161
+ setClassName = _c[1]; // update className when classes change
162
+
163
+
164
+ react.useEffect(function () {
165
+ var newClassName = classes.join(' ');
166
+ if (newClassName !== className) setClassName(newClassName);
167
+ }, [classes, className]); // update classes when props change
168
+
169
+ react.useEffect(function () {
170
+ var newClasses = ['d-flex'];
171
+ if (alignItems) newClasses.push("align-items-" + alignItems);
172
+ if (alignContent) newClasses.push("align-content-" + alignContent);
173
+ if (alignSelf) newClasses.push("align-content-" + alignSelf);
174
+ if (justifyContent) newClasses.push("justify-content-" + justifyContent);
175
+ setClasses(newClasses);
176
+ }, [alignContent, alignItems, alignSelf, justifyContent]);
177
+ return jsxRuntime.jsx("div", __assign({
178
+ className: className
179
+ }, {
180
+ children: children
181
+ }), void 0);
182
+ };
183
+
148
184
  function Group(_a) {
149
185
  var children = _a.children;
150
186
  return jsxRuntime.jsx("div", __assign({
@@ -1408,6 +1444,7 @@
1408
1444
  exports.Card = Card;
1409
1445
  exports.Checkbox = Checkbox;
1410
1446
  exports.EmailInput = EmailInput;
1447
+ exports.Flexbox = Flexbox;
1411
1448
  exports.Form = Form;
1412
1449
  exports.Group = Group;
1413
1450
  exports.Modal = Modal;