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

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.d.ts CHANGED
@@ -3,3 +3,6 @@ export * from './lib/layout';
3
3
  export * from './lib/card/card';
4
4
  export * from './lib/alert/alert';
5
5
  export * from './lib/form';
6
+ export * from './lib/list/list';
7
+ export * from './lib/navbar/navbar';
8
+ export * from './lib/link/link';
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { ModalRole, randomId } from '@sebgroup/extract';
3
- import { useState, useEffect, useMemo, useRef } from 'react';
3
+ import React, { useState, useEffect, useMemo, useRef } from 'react';
4
4
 
5
5
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
6
 
@@ -301,7 +301,7 @@ var store$2 = sharedStore;
301
301
  (shared$3.exports = function (key, value) {
302
302
  return store$2[key] || (store$2[key] = value !== undefined ? value : {});
303
303
  })('versions', []).push({
304
- version: '3.19.0',
304
+ version: '3.19.3',
305
305
  mode: 'global',
306
306
  copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
307
307
  });
@@ -1097,15 +1097,16 @@ const ModalFooter = ({
1097
1097
 
1098
1098
  const Modal = _a => {
1099
1099
  var {
1100
- type = 'default'
1100
+ type = 'default',
1101
+ isOpen
1101
1102
  } = _a,
1102
- props = __rest(_a, ["type"]);
1103
+ props = __rest(_a, ["type", "isOpen"]);
1103
1104
 
1104
- return jsxs("section", Object.assign({
1105
+ return isOpen ? jsxs("section", Object.assign({
1105
1106
  role: ModalRole[type]
1106
1107
  }, {
1107
1108
  children: [jsx(ModalHeader, Object.assign({}, props), void 0), jsx(ModalBody, Object.assign({}, props), void 0), jsx(ModalFooter, Object.assign({}, props), void 0)]
1108
- }), void 0);
1109
+ }), void 0) : null;
1109
1110
  };
1110
1111
 
1111
1112
  var DESCRIPTORS = descriptors;
@@ -1335,9 +1336,9 @@ var Iterators$2 = iterators;
1335
1336
 
1336
1337
  var returnThis$1 = function () { return this; };
1337
1338
 
1338
- var createIteratorConstructor$1 = function (IteratorConstructor, NAME, next) {
1339
+ var createIteratorConstructor$1 = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
1339
1340
  var TO_STRING_TAG = NAME + ' Iterator';
1340
- IteratorConstructor.prototype = create(IteratorPrototype$1, { next: createPropertyDescriptor(1, next) });
1341
+ IteratorConstructor.prototype = create(IteratorPrototype$1, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
1341
1342
  setToStringTag$1(IteratorConstructor, TO_STRING_TAG, false);
1342
1343
  Iterators$2[TO_STRING_TAG] = returnThis$1;
1343
1344
  return IteratorConstructor;
@@ -1658,29 +1659,26 @@ function Group({
1658
1659
 
1659
1660
  function Card({
1660
1661
  children,
1661
- headline,
1662
- buttons
1662
+ header,
1663
+ footer
1663
1664
  }) {
1664
- return jsx("section", Object.assign({
1665
+ return jsxs("section", Object.assign({
1665
1666
  className: "card"
1666
1667
  }, {
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)
1668
+ children: [jsx("header", {
1669
+ children: header
1670
+ }, void 0), jsx("p", {
1671
+ children: children
1672
+ }, void 0), jsx("footer", {
1673
+ children: footer
1674
+ }, void 0)]
1678
1675
  }), void 0);
1679
1676
  }
1680
1677
 
1681
1678
  function Alert({
1682
1679
  type,
1683
- heading,
1680
+ header,
1681
+ footer,
1684
1682
  children,
1685
1683
  closeText,
1686
1684
  isCloseable = true
@@ -1690,9 +1688,15 @@ function Alert({
1690
1688
  if (!isCloseable) {
1691
1689
  setCloseButton(null);
1692
1690
  } else {
1693
- if (closeText) setCloseButton(jsx(Button, {
1694
- children: closeText
1695
- }, void 0));else setCloseButton(jsx("button", {
1691
+ if (closeText) setCloseButton(jsx(Button, Object.assign({
1692
+ variant: "ghost"
1693
+ }, {
1694
+ children: jsx("span", Object.assign({
1695
+ className: "sr-only"
1696
+ }, {
1697
+ children: closeText
1698
+ }), void 0)
1699
+ }), void 0));else setCloseButton(jsx("button", {
1696
1700
  className: "close"
1697
1701
  }, void 0));
1698
1702
  }
@@ -1701,11 +1705,15 @@ function Alert({
1701
1705
  role: "alert",
1702
1706
  className: type
1703
1707
  }, {
1704
- children: [heading && jsx("h3", {
1705
- children: heading
1708
+ children: [header && jsxs("header", {
1709
+ children: [/*#__PURE__*/React.isValidElement(header) ? header : jsx("h3", {
1710
+ children: header
1711
+ }, void 0), closeButton]
1706
1712
  }, void 0), jsx("p", {
1707
1713
  children: children
1708
- }, void 0), closeButton]
1714
+ }, void 0), footer && jsx("footer", {
1715
+ children: footer
1716
+ }, void 0)]
1709
1717
  }), void 0);
1710
1718
  }
1711
1719
 
@@ -1740,10 +1748,10 @@ const ButtonGroup = ({
1740
1748
  function Form({
1741
1749
  children,
1742
1750
  direction = 'vertical',
1743
- size = 'md'
1751
+ formSize = 'md'
1744
1752
  }) {
1745
1753
  return jsx("form", Object.assign({
1746
- className: [direction, `size-${size}`].join(' ')
1754
+ className: [direction, `size-${formSize}`].join(' ')
1747
1755
  }, {
1748
1756
  children: children
1749
1757
  }), void 0);
@@ -1980,4 +1988,154 @@ const Checkbox = _a => {
1980
1988
  }), void 0);
1981
1989
  };
1982
1990
 
1983
- export { Alert, Button, ButtonGroup, Card, Checkbox, EmailInput, Flexbox, Form, Group, Modal, NumberInput, TextInput };
1991
+ const Text = ({
1992
+ children
1993
+ }) => jsx("span", Object.assign({
1994
+ className: "form-text"
1995
+ }, {
1996
+ children: children
1997
+ }), void 0);
1998
+
1999
+ const ListItem = _a => {
2000
+ var {
2001
+ listType,
2002
+ tableRowData,
2003
+ children
2004
+ } = _a,
2005
+ props = __rest(_a, ["listType", "tableRowData", "children"]);
2006
+
2007
+ if (listType === 'table') {
2008
+ return jsx("dl", {
2009
+ children: jsxs("div", {
2010
+ children: [jsx("dt", {
2011
+ children: tableRowData === null || tableRowData === void 0 ? void 0 : tableRowData.title
2012
+ }, void 0), tableRowData === null || tableRowData === void 0 ? void 0 : tableRowData.definition.map((item, index) => jsx("dd", {
2013
+ children: item
2014
+ }, index))]
2015
+ }, void 0)
2016
+ }, void 0);
2017
+ } else {
2018
+ return jsx("li", Object.assign({}, props, {
2019
+ children: children
2020
+ }), void 0);
2021
+ }
2022
+ };
2023
+
2024
+ const List = _a => {
2025
+ var {
2026
+ listType,
2027
+ tableCaption,
2028
+ tableData,
2029
+ children
2030
+ } = _a,
2031
+ props = __rest(_a, ["listType", "tableCaption", "tableData", "children"]);
2032
+
2033
+ if (listType === 'ordered') {
2034
+ return jsx("ol", Object.assign({}, props, {
2035
+ children: children === null || children === void 0 ? void 0 : children.map((child, index) => jsx(ListItem, {
2036
+ children: child
2037
+ }, index))
2038
+ }), void 0);
2039
+ } else if (listType !== 'table') {
2040
+ return jsx("ul", Object.assign({}, props, {
2041
+ className: listType
2042
+ }, {
2043
+ children: children === null || children === void 0 ? void 0 : children.map((child, index) => jsx(ListItem, {
2044
+ children: child
2045
+ }, index))
2046
+ }), void 0);
2047
+ } else {
2048
+ return jsxs("figure", {
2049
+ children: [jsx("figcaption", Object.assign({
2050
+ className: "table-list-caption"
2051
+ }, {
2052
+ children: tableCaption
2053
+ }), void 0), jsx("dl", {
2054
+ children: tableData === null || tableData === void 0 ? void 0 : tableData.map((data, index) => jsx(ListItem, {
2055
+ listType: listType,
2056
+ tableRowData: data
2057
+ }, index))
2058
+ }, void 0)]
2059
+ }, void 0);
2060
+ }
2061
+ };
2062
+
2063
+ const Link = _a => {
2064
+ var {
2065
+ button,
2066
+ children
2067
+ } = _a,
2068
+ props = __rest(_a, ["button", "children"]);
2069
+
2070
+ const [anchorProps, setAnchorProps] = useState({});
2071
+ useEffect(() => {
2072
+ const className = button ? typeof button === 'string' ? `button ${button}` : 'button' : undefined;
2073
+ const newProps = Object.assign({
2074
+ role: button ? 'button' : undefined,
2075
+ className: className
2076
+ }, props);
2077
+ setAnchorProps(newProps);
2078
+ }, [button]);
2079
+ return jsx("a", Object.assign({}, anchorProps, {
2080
+ children: children
2081
+ }), void 0);
2082
+ };
2083
+
2084
+ const Navbar = ({
2085
+ children,
2086
+ variant,
2087
+ title,
2088
+ titleLink,
2089
+ brandLink: _brandLink = 'https://www.seb.se',
2090
+ brandAriaLabel: _brandAriaLabel = 'Open seb.se in new tab'
2091
+ }) => {
2092
+ const [props, setProps] = useState({});
2093
+ useEffect(() => {
2094
+ const classNames = [];
2095
+ if (variant) classNames.push(variant);
2096
+ setProps(Object.assign(Object.assign({}, props), {
2097
+ className: classNames.join(' ')
2098
+ })); // eslint-disable-next-line react-hooks/exhaustive-deps
2099
+ }, [variant]);
2100
+ return jsxs("nav", Object.assign({
2101
+ role: "navigation"
2102
+ }, props, {
2103
+ children: [jsx(Link, {
2104
+ "aria-label": _brandAriaLabel,
2105
+ href: _brandLink,
2106
+ target: "_blank",
2107
+ className: "brand"
2108
+ }, void 0), jsx("div", Object.assign({
2109
+ className: "container-fluid"
2110
+ }, {
2111
+ children: jsxs("div", Object.assign({
2112
+ className: "row justify-content-between align-items-center"
2113
+ }, {
2114
+ children: [jsx("div", Object.assign({
2115
+ className: "col-auto"
2116
+ }, {
2117
+ children: titleLink ? jsx(Link, Object.assign({
2118
+ className: "mx-4",
2119
+ href: titleLink
2120
+ }, {
2121
+ children: jsx("h1", {
2122
+ children: title
2123
+ }, void 0)
2124
+ }), void 0) : jsx("h1", {
2125
+ children: title
2126
+ }, void 0)
2127
+ }), void 0), jsx("div", Object.assign({
2128
+ className: "col-auto"
2129
+ }, {
2130
+ children: jsx("div", Object.assign({
2131
+ className: "group size-sm"
2132
+ }, {
2133
+ children: children
2134
+ }), void 0)
2135
+ }), void 0)]
2136
+ }), void 0)
2137
+ }), void 0)]
2138
+ }), void 0);
2139
+ };
2140
+
2141
+ export { Alert, Button, ButtonGroup, Card, Checkbox, EmailInput, Flexbox, Form, Group, Link, List, Modal, Navbar, NumberInput, Text, TextInput };
@@ -2,7 +2,11 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('@sebgroup/extract'), require('react')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', '@sebgroup/extract', 'react'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.React = {}, global.jsxRuntime, global.extract, global.React));
5
- })(this, (function (exports, jsxRuntime, extract, react) { 'use strict';
5
+ })(this, (function (exports, jsxRuntime, extract, React) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
6
10
 
7
11
  /*! *****************************************************************************
8
12
  Copyright (c) Microsoft Corporation.
@@ -136,13 +140,14 @@
136
140
  var Modal = function Modal(_a) {
137
141
  var _b = _a.type,
138
142
  type = _b === void 0 ? 'default' : _b,
139
- props = __rest(_a, ["type"]);
143
+ isOpen = _a.isOpen,
144
+ props = __rest(_a, ["type", "isOpen"]);
140
145
 
141
- return jsxRuntime.jsxs("section", __assign({
146
+ return isOpen ? jsxRuntime.jsxs("section", __assign({
142
147
  role: extract.ModalRole[type]
143
148
  }, {
144
149
  children: [jsxRuntime.jsx(ModalHeader, __assign({}, props), void 0), jsxRuntime.jsx(ModalBody, __assign({}, props), void 0), jsxRuntime.jsx(ModalFooter, __assign({}, props), void 0)]
145
- }), void 0);
150
+ }), void 0) : null;
146
151
  };
147
152
 
148
153
  var Flexbox = function Flexbox(_a) {
@@ -152,26 +157,26 @@
152
157
  children = _a.children,
153
158
  justifyContent = _a.justifyContent;
154
159
 
155
- var _b = react.useState(['d-flex']),
160
+ var _b = React.useState(['d-flex']),
156
161
  classes = _b[0],
157
162
  setClasses = _b[1];
158
163
 
159
- var _c = react.useState('d-flex'),
164
+ var _c = React.useState('d-flex'),
160
165
  className = _c[0],
161
166
  setClassName = _c[1]; // update className when classes change
162
167
 
163
168
 
164
- react.useEffect(function () {
169
+ React.useEffect(function () {
165
170
  var newClassName = classes.join(' ');
166
171
  if (newClassName !== className) setClassName(newClassName);
167
172
  }, [classes, className]); // update classes when props change
168
173
 
169
- react.useEffect(function () {
174
+ React.useEffect(function () {
170
175
  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);
176
+ if (alignItems) newClasses.push("align-items-".concat(alignItems));
177
+ if (alignContent) newClasses.push("align-content-".concat(alignContent));
178
+ if (alignSelf) newClasses.push("align-content-".concat(alignSelf));
179
+ if (justifyContent) newClasses.push("justify-content-".concat(justifyContent));
175
180
  setClasses(newClasses);
176
181
  }, [alignContent, alignItems, alignSelf, justifyContent]);
177
182
  return jsxRuntime.jsx("div", __assign({
@@ -192,44 +197,47 @@
192
197
 
193
198
  function Card(_a) {
194
199
  var children = _a.children,
195
- headline = _a.headline,
196
- buttons = _a.buttons;
197
- return jsxRuntime.jsx("section", __assign({
200
+ header = _a.header,
201
+ footer = _a.footer;
202
+ return jsxRuntime.jsxs("section", __assign({
198
203
  className: "card"
199
204
  }, {
200
- children: jsxRuntime.jsxs("div", __assign({
201
- className: "card-body"
202
- }, {
203
- children: [headline && jsxRuntime.jsx("h2", {
204
- children: headline
205
- }, void 0), jsxRuntime.jsx("p", {
206
- children: children
207
- }, void 0), buttons && jsxRuntime.jsx("footer", {
208
- children: buttons
209
- }, void 0)]
210
- }), void 0)
205
+ children: [jsxRuntime.jsx("header", {
206
+ children: header
207
+ }, void 0), jsxRuntime.jsx("p", {
208
+ children: children
209
+ }, void 0), jsxRuntime.jsx("footer", {
210
+ children: footer
211
+ }, void 0)]
211
212
  }), void 0);
212
213
  }
213
214
 
214
215
  function Alert(_a) {
215
216
  var type = _a.type,
216
- heading = _a.heading,
217
+ header = _a.header,
218
+ footer = _a.footer,
217
219
  children = _a.children,
218
220
  closeText = _a.closeText,
219
221
  _b = _a.isCloseable,
220
222
  isCloseable = _b === void 0 ? true : _b;
221
223
 
222
- var _c = react.useState(),
224
+ var _c = React.useState(),
223
225
  closeButton = _c[0],
224
226
  setCloseButton = _c[1];
225
227
 
226
- react.useEffect(function () {
228
+ React.useEffect(function () {
227
229
  if (!isCloseable) {
228
230
  setCloseButton(null);
229
231
  } else {
230
- if (closeText) setCloseButton(jsxRuntime.jsx(Button, {
231
- children: closeText
232
- }, void 0));else setCloseButton(jsxRuntime.jsx("button", {
232
+ if (closeText) setCloseButton(jsxRuntime.jsx(Button, __assign({
233
+ variant: "ghost"
234
+ }, {
235
+ children: jsxRuntime.jsx("span", __assign({
236
+ className: "sr-only"
237
+ }, {
238
+ children: closeText
239
+ }), void 0)
240
+ }), void 0));else setCloseButton(jsxRuntime.jsx("button", {
233
241
  className: "close"
234
242
  }, void 0));
235
243
  }
@@ -238,11 +246,15 @@
238
246
  role: "alert",
239
247
  className: type
240
248
  }, {
241
- children: [heading && jsxRuntime.jsx("h3", {
242
- children: heading
249
+ children: [header && jsxRuntime.jsxs("header", {
250
+ children: [/*#__PURE__*/React__default["default"].isValidElement(header) ? header : jsxRuntime.jsx("h3", {
251
+ children: header
252
+ }, void 0), closeButton]
243
253
  }, void 0), jsxRuntime.jsx("p", {
244
254
  children: children
245
- }, void 0), closeButton]
255
+ }, void 0), footer && jsxRuntime.jsx("footer", {
256
+ children: footer
257
+ }, void 0)]
246
258
  }), void 0);
247
259
  }
248
260
 
@@ -251,15 +263,15 @@
251
263
  selectedIndex = _a.selectedIndex,
252
264
  variant = _a.variant;
253
265
 
254
- var _b = react.useState(selectedIndex),
266
+ var _b = React.useState(selectedIndex),
255
267
  selected = _b[0],
256
268
  setSelected = _b[1];
257
269
 
258
- var _c = react.useState([]),
270
+ var _c = React.useState([]),
259
271
  buttons = _c[0],
260
272
  setButtons = _c[1];
261
273
 
262
- react.useEffect(function () {
274
+ React.useEffect(function () {
263
275
  var buttonProps = (children instanceof Array ? children : [children]).filter(function (b) {
264
276
  return b && b.props;
265
277
  }).map(function (b, ix) {
@@ -267,7 +279,7 @@
267
279
 
268
280
  var props = __assign(__assign({}, bp), {
269
281
  variant: variant,
270
- key: bp.key || "btn_" + ix,
282
+ key: bp.key || "btn_".concat(ix),
271
283
  active: ix === selected,
272
284
  onClick: function (e) {
273
285
  setSelected(ix);
@@ -290,10 +302,10 @@
290
302
  var children = _a.children,
291
303
  _b = _a.direction,
292
304
  direction = _b === void 0 ? 'vertical' : _b,
293
- _c = _a.size,
294
- size = _c === void 0 ? 'md' : _c;
305
+ _c = _a.formSize,
306
+ formSize = _c === void 0 ? 'md' : _c;
295
307
  return jsxRuntime.jsx("form", __assign({
296
- className: [direction, "size-" + size].join(' ')
308
+ className: [direction, "size-".concat(formSize)].join(' ')
297
309
  }, {
298
310
  children: children
299
311
  }), void 0);
@@ -598,7 +610,7 @@
598
610
  (shared$3.exports = function (key, value) {
599
611
  return store$2[key] || (store$2[key] = value !== undefined ? value : {});
600
612
  })('versions', []).push({
601
- version: '3.19.0',
613
+ version: '3.19.3',
602
614
  mode: 'global',
603
615
  copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
604
616
  });
@@ -1317,20 +1329,20 @@
1317
1329
  });
1318
1330
 
1319
1331
  var useInput = function useInput(props, evaluator, notify) {
1320
- var id = react.useMemo(function () {
1332
+ var id = React.useMemo(function () {
1321
1333
  return props.id || extract.randomId();
1322
1334
  }, [props.id]);
1323
- var ref = react.useRef(null);
1335
+ var ref = React.useRef(null);
1324
1336
 
1325
- var _a = react.useState(props.value),
1337
+ var _a = React.useState(props.value),
1326
1338
  value = _a[0],
1327
1339
  setValue = _a[1];
1328
1340
 
1329
- var _b = react.useState(props.checked),
1341
+ var _b = React.useState(props.checked),
1330
1342
  checked = _b[0],
1331
1343
  setChecked = _b[1];
1332
1344
 
1333
- react.useEffect(function () {
1345
+ React.useEffect(function () {
1334
1346
  if (ref.current && ref.current.form) {
1335
1347
  var resetListener_1 = function resetListener_1() {
1336
1348
  setValue(props.value);
@@ -1369,7 +1381,7 @@
1369
1381
  inputProps = __rest(_a, ["value"]);
1370
1382
 
1371
1383
  var propsWithDescription = info ? __assign(__assign({}, inputProps), {
1372
- 'aria-describedby': inputProps.id + "_info"
1384
+ 'aria-describedby': "".concat(inputProps.id, "_info")
1373
1385
  }) : inputProps;
1374
1386
  return jsxRuntime.jsxs("div", __assign({
1375
1387
  className: "form-field"
@@ -1438,6 +1450,169 @@
1438
1450
  }), void 0);
1439
1451
  };
1440
1452
 
1453
+ var Text = function Text(_a) {
1454
+ var children = _a.children;
1455
+ return jsxRuntime.jsx("span", __assign({
1456
+ className: "form-text"
1457
+ }, {
1458
+ children: children
1459
+ }), void 0);
1460
+ };
1461
+
1462
+ var ListItem = function ListItem(_a) {
1463
+ var listType = _a.listType,
1464
+ tableRowData = _a.tableRowData,
1465
+ children = _a.children,
1466
+ props = __rest(_a, ["listType", "tableRowData", "children"]);
1467
+
1468
+ if (listType === 'table') {
1469
+ return jsxRuntime.jsx("dl", {
1470
+ children: jsxRuntime.jsxs("div", {
1471
+ children: [jsxRuntime.jsx("dt", {
1472
+ children: tableRowData === null || tableRowData === void 0 ? void 0 : tableRowData.title
1473
+ }, void 0), tableRowData === null || tableRowData === void 0 ? void 0 : tableRowData.definition.map(function (item, index) {
1474
+ return jsxRuntime.jsx("dd", {
1475
+ children: item
1476
+ }, index);
1477
+ })]
1478
+ }, void 0)
1479
+ }, void 0);
1480
+ } else {
1481
+ return jsxRuntime.jsx("li", __assign({}, props, {
1482
+ children: children
1483
+ }), void 0);
1484
+ }
1485
+ };
1486
+
1487
+ var List = function List(_a) {
1488
+ var listType = _a.listType,
1489
+ tableCaption = _a.tableCaption,
1490
+ tableData = _a.tableData,
1491
+ children = _a.children,
1492
+ props = __rest(_a, ["listType", "tableCaption", "tableData", "children"]);
1493
+
1494
+ if (listType === 'ordered') {
1495
+ return jsxRuntime.jsx("ol", __assign({}, props, {
1496
+ children: children === null || children === void 0 ? void 0 : children.map(function (child, index) {
1497
+ return jsxRuntime.jsx(ListItem, {
1498
+ children: child
1499
+ }, index);
1500
+ })
1501
+ }), void 0);
1502
+ } else if (listType !== 'table') {
1503
+ return jsxRuntime.jsx("ul", __assign({}, props, {
1504
+ className: listType
1505
+ }, {
1506
+ children: children === null || children === void 0 ? void 0 : children.map(function (child, index) {
1507
+ return jsxRuntime.jsx(ListItem, {
1508
+ children: child
1509
+ }, index);
1510
+ })
1511
+ }), void 0);
1512
+ } else {
1513
+ return jsxRuntime.jsxs("figure", {
1514
+ children: [jsxRuntime.jsx("figcaption", __assign({
1515
+ className: "table-list-caption"
1516
+ }, {
1517
+ children: tableCaption
1518
+ }), void 0), jsxRuntime.jsx("dl", {
1519
+ children: tableData === null || tableData === void 0 ? void 0 : tableData.map(function (data, index) {
1520
+ return jsxRuntime.jsx(ListItem, {
1521
+ listType: listType,
1522
+ tableRowData: data
1523
+ }, index);
1524
+ })
1525
+ }, void 0)]
1526
+ }, void 0);
1527
+ }
1528
+ };
1529
+
1530
+ var Link = function Link(_a) {
1531
+ var button = _a.button,
1532
+ children = _a.children,
1533
+ props = __rest(_a, ["button", "children"]);
1534
+
1535
+ var _b = React.useState({}),
1536
+ anchorProps = _b[0],
1537
+ setAnchorProps = _b[1];
1538
+
1539
+ React.useEffect(function () {
1540
+ var className = button ? typeof button === 'string' ? "button ".concat(button) : 'button' : undefined;
1541
+
1542
+ var newProps = __assign({
1543
+ role: button ? 'button' : undefined,
1544
+ className: className
1545
+ }, props);
1546
+
1547
+ setAnchorProps(newProps);
1548
+ }, [button]);
1549
+ return jsxRuntime.jsx("a", __assign({}, anchorProps, {
1550
+ children: children
1551
+ }), void 0);
1552
+ };
1553
+
1554
+ var Navbar = function Navbar(_a) {
1555
+ var children = _a.children,
1556
+ variant = _a.variant,
1557
+ title = _a.title,
1558
+ titleLink = _a.titleLink,
1559
+ _b = _a.brandLink,
1560
+ brandLink = _b === void 0 ? 'https://www.seb.se' : _b,
1561
+ _c = _a.brandAriaLabel,
1562
+ brandAriaLabel = _c === void 0 ? 'Open seb.se in new tab' : _c;
1563
+
1564
+ var _d = React.useState({}),
1565
+ props = _d[0],
1566
+ setProps = _d[1];
1567
+
1568
+ React.useEffect(function () {
1569
+ var classNames = [];
1570
+ if (variant) classNames.push(variant);
1571
+ setProps(__assign(__assign({}, props), {
1572
+ className: classNames.join(' ')
1573
+ })); // eslint-disable-next-line react-hooks/exhaustive-deps
1574
+ }, [variant]);
1575
+ return jsxRuntime.jsxs("nav", __assign({
1576
+ role: "navigation"
1577
+ }, props, {
1578
+ children: [jsxRuntime.jsx(Link, {
1579
+ "aria-label": brandAriaLabel,
1580
+ href: brandLink,
1581
+ target: "_blank",
1582
+ className: "brand"
1583
+ }, void 0), jsxRuntime.jsx("div", __assign({
1584
+ className: "container-fluid"
1585
+ }, {
1586
+ children: jsxRuntime.jsxs("div", __assign({
1587
+ className: "row justify-content-between align-items-center"
1588
+ }, {
1589
+ children: [jsxRuntime.jsx("div", __assign({
1590
+ className: "col-auto"
1591
+ }, {
1592
+ children: titleLink ? jsxRuntime.jsx(Link, __assign({
1593
+ className: "mx-4",
1594
+ href: titleLink
1595
+ }, {
1596
+ children: jsxRuntime.jsx("h1", {
1597
+ children: title
1598
+ }, void 0)
1599
+ }), void 0) : jsxRuntime.jsx("h1", {
1600
+ children: title
1601
+ }, void 0)
1602
+ }), void 0), jsxRuntime.jsx("div", __assign({
1603
+ className: "col-auto"
1604
+ }, {
1605
+ children: jsxRuntime.jsx("div", __assign({
1606
+ className: "group size-sm"
1607
+ }, {
1608
+ children: children
1609
+ }), void 0)
1610
+ }), void 0)]
1611
+ }), void 0)
1612
+ }), void 0)]
1613
+ }), void 0);
1614
+ };
1615
+
1441
1616
  exports.Alert = Alert;
1442
1617
  exports.Button = Button;
1443
1618
  exports.ButtonGroup = ButtonGroup;
@@ -1447,8 +1622,12 @@
1447
1622
  exports.Flexbox = Flexbox;
1448
1623
  exports.Form = Form;
1449
1624
  exports.Group = Group;
1625
+ exports.Link = Link;
1626
+ exports.List = List;
1450
1627
  exports.Modal = Modal;
1628
+ exports.Navbar = Navbar;
1451
1629
  exports.NumberInput = NumberInput;
1630
+ exports.Text = Text;
1452
1631
  exports.TextInput = TextInput;
1453
1632
 
1454
1633
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -3,9 +3,10 @@ import { ReactNode } from 'react';
3
3
  export interface AlertProps {
4
4
  children: ReactNode;
5
5
  type: AlertType;
6
- heading?: string;
6
+ header?: ReactNode;
7
+ footer?: ReactNode;
7
8
  isCloseable?: boolean;
8
9
  closeText?: string;
9
10
  }
10
- export declare function Alert({ type, heading, children, closeText, isCloseable, }: AlertProps): JSX.Element;
11
+ export declare function Alert({ type, header, footer, children, closeText, isCloseable, }: AlertProps): JSX.Element;
11
12
  export default Alert;
@@ -1,9 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
- import Button from '../form/button';
3
2
  export interface CardProps {
4
3
  children?: ReactNode;
5
- headline?: string;
6
- buttons?: typeof Button[];
4
+ header?: ReactNode;
5
+ footer?: ReactNode;
7
6
  }
8
- export declare function Card({ children, headline, buttons }: CardProps): JSX.Element;
7
+ export declare function Card({ children, header, footer }: CardProps): JSX.Element;
9
8
  export default Card;
File without changes
@@ -1,10 +1,10 @@
1
1
  import { ReactElement } from 'react';
2
2
  import { ButtonVariant } from '@sebgroup/extract';
3
- import { ButtonProps } from './button';
3
+ import { ButtonProps } from '../button/button';
4
4
  interface ButtonGroupProps {
5
5
  children: ReactElement<ButtonProps> | ReactElement<ButtonProps>[];
6
6
  selectedIndex?: number;
7
7
  variant?: ButtonVariant;
8
8
  }
9
- export declare const ButtonGroup: ({ children, selectedIndex, variant }: ButtonGroupProps) => JSX.Element;
9
+ export declare const ButtonGroup: ({ children, selectedIndex, variant, }: ButtonGroupProps) => JSX.Element;
10
10
  export default ButtonGroup;
@@ -1,9 +1,9 @@
1
1
  import { FormDirection, Size } from '@sebgroup/extract';
2
- import { ReactNode } from 'react';
3
- export interface FormProps {
2
+ import { HTMLProps, ReactNode } from 'react';
3
+ export interface FormProps extends HTMLProps<HTMLFormElement> {
4
4
  children?: ReactNode;
5
5
  direction?: FormDirection;
6
- size?: Size;
6
+ formSize?: Size;
7
7
  }
8
- export declare function Form({ children, direction, size, }: FormProps): JSX.Element;
8
+ export declare function Form({ children, direction, formSize, }: FormProps): JSX.Element;
9
9
  export default Form;
@@ -1,5 +1,5 @@
1
- export * from './button';
2
- export * from './buttonGroup';
1
+ export * from './button/button';
2
+ export * from './buttonGroup/buttonGroup';
3
3
  export * from './form';
4
- export * from './input';
5
- export * from './text';
4
+ export * from './input/input';
5
+ export * from './text/text';
@@ -1,4 +1,4 @@
1
- import { CheckboxProps, TextInputProps } from './types';
1
+ import { CheckboxProps, TextInputProps } from '../types';
2
2
  export declare const TextInput: ({ label, info, onChangeText, ...props }: TextInputProps<string>) => JSX.Element;
3
3
  export declare const EmailInput: ({ label, info, onChangeText, ...props }: TextInputProps<string>) => JSX.Element;
4
4
  export declare const NumberInput: ({ label, info, onChangeText, ...props }: TextInputProps<number>) => JSX.Element;
@@ -2,5 +2,5 @@ import { ReactNode } from 'react';
2
2
  interface TextProps {
3
3
  children: ReactNode;
4
4
  }
5
- declare const Text: ({ children }: TextProps) => JSX.Element;
5
+ export declare const Text: ({ children }: TextProps) => JSX.Element;
6
6
  export default Text;
File without changes
@@ -1,2 +1,2 @@
1
- export * from './flexbox';
2
- export * from './group';
1
+ export * from './flexbox/flexbox';
2
+ export * from './group/group';
@@ -0,0 +1,7 @@
1
+ import { HTMLProps, PropsWithChildren } from 'react';
2
+ import { ButtonVariant } from '@sebgroup/extract';
3
+ interface LinkProps extends HTMLProps<HTMLAnchorElement> {
4
+ button?: boolean | ButtonVariant;
5
+ }
6
+ export declare const Link: ({ button, children, ...props }: PropsWithChildren<LinkProps>) => JSX.Element;
7
+ export default Link;
@@ -0,0 +1,14 @@
1
+ import { ListType } from '@sebgroup/extract';
2
+ import { ReactNode, HTMLAttributes } from 'react';
3
+ export interface ListProps extends HTMLAttributes<HTMLOListElement | HTMLUListElement> {
4
+ listType?: ListType;
5
+ tableCaption?: string;
6
+ tableData?: TableListProps[];
7
+ children?: ReactNode[];
8
+ }
9
+ export interface TableListProps {
10
+ title: string;
11
+ definition: string[];
12
+ }
13
+ export declare const List: ({ listType, tableCaption, tableData, children, ...props }: ListProps) => JSX.Element;
14
+ export default List;
@@ -0,0 +1,10 @@
1
+ import { ListType } from '@sebgroup/extract';
2
+ import { HTMLAttributes, ReactNode } from 'react';
3
+ import { TableListProps } from './list';
4
+ interface ListItemProps extends HTMLAttributes<HTMLLIElement> {
5
+ listType?: ListType;
6
+ tableRowData?: TableListProps;
7
+ children?: ReactNode;
8
+ }
9
+ declare const ListItem: ({ listType, tableRowData, children, ...props }: ListItemProps) => JSX.Element;
10
+ export default ListItem;
@@ -8,9 +8,10 @@ export interface ModalProps {
8
8
  confirm?: string;
9
9
  dismiss?: string;
10
10
  size?: Size;
11
+ isOpen?: boolean;
11
12
  onClose?: ModalEventListener;
12
13
  onConfirm?: ModalEventListener;
13
14
  onDismiss?: ModalEventListener;
14
15
  }
15
- export declare const Modal: ({ type, ...props }: ModalProps) => JSX.Element;
16
+ export declare const Modal: ({ type, isOpen, ...props }: ModalProps) => JSX.Element | null;
16
17
  export default Modal;
@@ -0,0 +1,12 @@
1
+ import { NavbarVariant } from '@sebgroup/extract';
2
+ import { HTMLAttributes, ReactNode } from 'react';
3
+ export interface NavProps extends HTMLAttributes<HTMLElement> {
4
+ title?: string;
5
+ titleLink?: string;
6
+ brandLink?: string;
7
+ brandAriaLabel?: string;
8
+ variant?: NavbarVariant;
9
+ children?: ReactNode;
10
+ }
11
+ export declare const Navbar: ({ children, variant, title, titleLink, brandLink, brandAriaLabel, }: NavProps) => JSX.Element;
12
+ export default Navbar;
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ interface IList {
3
+ text?: string;
4
+ href?: string;
5
+ }
6
+ interface TabsProps {
7
+ list?: IList[];
8
+ disabled?: boolean;
9
+ children?: ReactNode[];
10
+ }
11
+ export declare const Tabs: ({ list, disabled, children, ...props }: TabsProps) => JSX.Element;
12
+ export default Tabs;
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@sebgroup/green-react",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.4",
4
4
  "peerDependencies": {
5
- "react": "^17.0.2",
6
- "react-dom": "^17.0.2",
5
+ "react": "^17.0.0",
6
+ "react-dom": "^17.0.0",
7
+ "merge": "^2.1.1",
7
8
  "@popperjs/core": "^2.11.0",
8
- "rxjs": "^6.6.7",
9
- "merge": "^2.1.1"
9
+ "rxjs": "^6.6.7"
10
10
  },
11
11
  "dependencies": {
12
- "@sebgroup/chlorophyll": "^1.0.0-beta.3",
13
- "@sebgroup/extract": "^1.0.0-beta.3"
12
+ "@sebgroup/chlorophyll": "^1.0.0-beta.4",
13
+ "@sebgroup/extract": "^1.0.0-beta.4"
14
14
  },
15
15
  "description": "React components built on top of @sebgroup/chlorophyll.",
16
16
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "url": "https://github.com/sebgroup/green/labels/react"
29
29
  },
30
30
  "homepage": "https://sebgroup.github.io/green/latest/react/",
31
- "main": "./react.umd.js",
32
- "module": "./react.esm.js",
31
+ "main": "./index.umd.js",
32
+ "module": "./index.esm.js",
33
33
  "typings": "./index.d.ts"
34
34
  }