@sb1/ffe-grid-react 13.2.14 → 14.0.0

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/README.md CHANGED
@@ -10,11 +10,6 @@ npm install --save @sb1/ffe-grid-react
10
10
 
11
11
  Full documentation on grid usage is available at https://design.sparebank1.no/komponenter/grid/.
12
12
 
13
- ## TypeScript definition files
14
-
15
- This component supports TypeScript - please update `index.d.ts` if you change any
16
- of the external methods or properties in this component.
17
-
18
13
  ## DevTool: Grid overlay
19
14
 
20
15
  For å lettere inspisere hvordan innholdet legger seg i kolonner, eller for å se hvordan gridden vil kunne passe inn på en eksisterende webside eksporteres det et separat util som vil lage en full-skjerm overlay med kolonner på en eksisterende side. Fra denne modulen eksporteres bare en funksjon som lager en fixed positioned div og det er opp til applikasjonen hvordan man ønsker å bruke den.
package/es/Grid.js CHANGED
@@ -1,32 +1,31 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["children", "className", "gap", "element"];
3
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
8
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
9
23
  import React from 'react';
10
24
  import classNames from 'classnames';
11
- import { node, string, oneOf } from 'prop-types';
12
- export default function Grid(_ref) {
13
- var children = _ref.children,
14
- className = _ref.className,
15
- gap = _ref.gap,
16
- element = _ref.element,
17
- rest = _objectWithoutProperties(_ref, _excluded);
18
- var Element = element || 'div';
19
- return /*#__PURE__*/React.createElement(Element, _extends({
20
- className: classNames(className, 'ffe-grid', _defineProperty({}, "ffe-grid--gap-".concat(gap), gap))
21
- }, rest), children);
22
- }
23
- Grid.propTypes = {
24
- /** Any children of a Grid must be a GridRow */
25
- children: node,
26
- /** Any extra classes are attached to the root node, in addition to ffe-grid classes */
27
- className: string,
28
- /** Specify the internal gutter of the grid */
29
- gap: oneOf(['none', '2xs', 'xs', 'sm', 'md', 'lg']),
30
- /** Specify the DOM element being used to create the Grid */
31
- element: string
32
- };
25
+ export var Grid = function (_a) {
26
+ var _b;
27
+ var children = _a.children, className = _a.className, gap = _a.gap, _c = _a.as, Comp = _c === void 0 ? 'div' : _c, rest = __rest(_a, ["children", "className", "gap", "as"]);
28
+ return (React.createElement(Comp, __assign({ className: classNames(className, 'ffe-grid', (_b = {},
29
+ _b["ffe-grid--gap-".concat(gap)] = gap,
30
+ _b)) }, rest), children));
31
+ };
package/es/GridCol.js CHANGED
@@ -1,129 +1,65 @@
1
- var _excluded = ["background", "backgroundDark", "className", "element", "centerText", "center", "children", "sm", "md", "lg"];
2
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
5
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
10
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
12
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
14
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
19
- import React, { Component, createRef } from 'react';
20
- import { bool, node, number, oneOf, oneOfType, shape, string } from 'prop-types';
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import React from 'react';
21
24
  import classNames from 'classnames';
22
- import { backgroundColors, backgroundDarkColors, removedColors } from './background-colors';
23
- var sizeClasses = function sizeClasses(size, def) {
24
- switch (_typeof(def)) {
25
- case 'undefined':
26
- return '';
27
- case 'object':
28
- return classNames(_defineProperty(_defineProperty({}, "ffe-grid__col--".concat(size, "-").concat(def.cols), def.cols || def.cols === 0), "ffe-grid__col--".concat(size, "-offset-").concat(def.offset), def.offset || def.offset === 0));
29
- default:
30
- return "ffe-grid__col--".concat(size, "-").concat(def);
31
- }
25
+ var sizeClasses = function (size, def) {
26
+ var _a;
27
+ if (def === undefined) {
28
+ return null;
29
+ }
30
+ else if (typeof def === 'number' || typeof def === 'string') {
31
+ return "ffe-grid__col--".concat(size, "-").concat(def);
32
+ }
33
+ return classNames((_a = {},
34
+ _a["ffe-grid__col--".concat(size, "-").concat(def.cols)] = def.cols || def.cols === 0,
35
+ _a["ffe-grid__col--".concat(size, "-offset-").concat(def.offset)] = def.offset || def.offset === 0,
36
+ _a));
32
37
  };
33
- var centerTextClass = function centerTextClass(centerText) {
34
- return centerText ? 'ffe-grid__col--center-text' : null;
38
+ var centerTextClass = function (centerText) {
39
+ return centerText ? 'ffe-grid__col--center-text' : null;
35
40
  };
36
- var centerClass = function centerClass(center) {
37
- return center ? 'ffe-grid__col--center' : null;
41
+ var centerClass = function (center) {
42
+ return center ? 'ffe-grid__col--center' : null;
38
43
  };
39
- var backgroundClass = function backgroundClass(background) {
40
- if (!background) {
41
- return null;
42
- }
43
- if (removedColors.includes(background)) {
44
- throw new Error("Support for the ".concat(background, " background on <GridCol> has been removed, please see the CHANGELOG"));
45
- }
46
- return backgroundColors.includes(background) ? "ffe-grid__col--bg-".concat(background) : null;
44
+ var backgroundClass = function (background) {
45
+ return background ? "ffe-grid__col--bg-".concat(background) : null;
47
46
  };
48
- var backgroundDarkClass = function backgroundDarkClass(backgroundDark) {
49
- return backgroundDarkColors.includes(backgroundDark) ? "ffe-grid__col--bg-dark-".concat(backgroundDark) : null;
47
+ var backgroundDarkClass = function (backgroundDark) {
48
+ return backgroundDark ? "ffe-grid__col--bg-dark-".concat(backgroundDark) : null;
49
+ };
50
+ export var GridCol = function (_a) {
51
+ var background = _a.background, backgroundDark = _a.backgroundDark, className = _a.className, _b = _a.as, Comp = _b === void 0 ? 'div' : _b, centerText = _a.centerText, center = _a.center, children = _a.children, sm = _a.sm, md = _a.md, lg = _a.lg, rest = __rest(_a, ["background", "backgroundDark", "className", "as", "centerText", "center", "children", "sm", "md", "lg"]);
52
+ return (React.createElement(Comp, __assign({ className: [
53
+ 'ffe-grid__col',
54
+ className,
55
+ sizeClasses('lg', lg),
56
+ sizeClasses('md', md),
57
+ sizeClasses('sm', !sm && !lg && !md ? 12 : sm),
58
+ centerTextClass(centerText),
59
+ centerClass(center),
60
+ backgroundClass(background),
61
+ backgroundDarkClass(backgroundDark),
62
+ ]
63
+ .filter(function (x) { return x; })
64
+ .join(' ') }, rest), children));
50
65
  };
51
- var GridCol = /*#__PURE__*/function (_Component) {
52
- function GridCol() {
53
- var _this;
54
- _classCallCheck(this, GridCol);
55
- _this = _callSuper(this, GridCol);
56
- _this.ref = /*#__PURE__*/createRef();
57
- return _this;
58
- }
59
- _inherits(GridCol, _Component);
60
- return _createClass(GridCol, [{
61
- key: "render",
62
- value: function render() {
63
- var _this$props = this.props,
64
- background = _this$props.background,
65
- backgroundDark = _this$props.backgroundDark,
66
- className = _this$props.className,
67
- _this$props$element = _this$props.element,
68
- Element = _this$props$element === void 0 ? 'div' : _this$props$element,
69
- centerText = _this$props.centerText,
70
- center = _this$props.center,
71
- children = _this$props.children,
72
- sm = _this$props.sm,
73
- md = _this$props.md,
74
- lg = _this$props.lg,
75
- rest = _objectWithoutProperties(_this$props, _excluded);
76
- var classes = ['ffe-grid__col', className, sizeClasses('lg', lg), sizeClasses('md', md), sizeClasses('sm', !sm && !lg && !md ? 12 : sm), centerTextClass(centerText), centerClass(center), backgroundClass(background), backgroundDarkClass(backgroundDark)].filter(function (x) {
77
- return x;
78
- }).join(' ');
79
- return /*#__PURE__*/React.createElement(Element, _extends({
80
- className: classes,
81
- ref: this.ref
82
- }, rest), children);
83
- }
84
- }]);
85
- }(Component);
86
- export { GridCol as default };
87
- GridCol.propTypes = {
88
- /** Supported background colors */
89
- background: oneOf(backgroundColors),
90
- /** Supported dark background colors */
91
- backgroundDark: oneOf(backgroundDarkColors),
92
- /** Any extra classes are attached to the root node, in addition to ffe-grid__col classes */
93
- className: string,
94
- /** Specify the DOM element being used to create the GridCol */
95
- element: node,
96
- /** Center text content horizontally */
97
- centerText: bool,
98
- /** Center content vertically */
99
- center: bool,
100
- /** The content of the column */
101
- children: node,
102
- /** Size modifiers for small screen sizes */
103
- sm: oneOfType([/** Number of columns, 0-12 */
104
- number, /** Number of columns, 0-12 */
105
- string, shape({
106
- /** Number of columns, 0-12 */
107
- cols: oneOfType([number, string]),
108
- /** Number of colums offset, 0-12 */
109
- offset: oneOfType([number, string])
110
- })]),
111
- /** Size modifiers for medium screen sizes */
112
- md: oneOfType([/** Number of columns, 0-12 */
113
- number, /** Number of columns, 0-12 */
114
- string, shape({
115
- /** Number of columns, 0-12 */
116
- cols: oneOfType([number, string]),
117
- /** Number of colums offset, 0-12 */
118
- offset: oneOfType([number, string])
119
- })]),
120
- /** Size modifiers for large screen sizes */
121
- lg: oneOfType([/** Number of columns, 0-12 */
122
- number, /** Number of columns, 0-12 */
123
- string, shape({
124
- /** Number of columns, 0-12 */
125
- cols: oneOfType([number, string]),
126
- /** Number of colums offset, 0-12 */
127
- offset: oneOfType([number, string])
128
- })])
129
- };
package/es/GridRow.js CHANGED
@@ -1,51 +1,34 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["background", "backgroundDark", "className", "children", "element", "padding", "margin"];
3
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
8
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
9
23
  import React from 'react';
10
- import { node, oneOf, string } from 'prop-types';
11
24
  import classNames from 'classnames';
12
- import { backgroundColors, backgroundDarkColors, removedColors } from './background-colors';
13
- export default function GridRow(_ref) {
14
- var background = _ref.background,
15
- backgroundDark = _ref.backgroundDark,
16
- className = _ref.className,
17
- children = _ref.children,
18
- element = _ref.element,
19
- padding = _ref.padding,
20
- margin = _ref.margin,
21
- rest = _objectWithoutProperties(_ref, _excluded);
22
- var hasBackgroundColor = backgroundColors.includes(background);
23
- var hasBackgroundDarkColor = backgroundDarkColors.includes(backgroundDark);
24
- var hasRemovedColor = removedColors.includes(background);
25
- var content = hasBackgroundColor || hasBackgroundDarkColor ? /*#__PURE__*/React.createElement("div", {
26
- className: "ffe-grid__row-wrapper"
27
- }, children) : children;
28
- if (hasRemovedColor) {
29
- throw new Error("Support for the ".concat(background, " background on <GridRow> has been removed, please see the CHANGELOG"));
30
- }
31
- var Element = element || 'div';
32
- return /*#__PURE__*/React.createElement(Element, _extends({
33
- className: classNames(className, 'ffe-grid__row', _defineProperty({}, "ffe-grid__row--bg-".concat(background), hasBackgroundColor), _defineProperty({}, "ffe-grid__row--bg-dark-".concat(backgroundDark), hasBackgroundDarkColor), _defineProperty({}, "ffe-grid__row--padding-".concat(padding), padding), _defineProperty({}, "ffe-grid__row--margin-".concat(margin), margin))
34
- }, rest), content);
35
- }
36
- GridRow.propTypes = {
37
- /** Supported background colors */
38
- background: oneOf(backgroundColors),
39
- /** Supported dark background colors */
40
- backgroundDark: oneOf(backgroundDarkColors),
41
- /** Padding in the top and bottom of the row */
42
- padding: oneOf(['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl']),
43
- /** Margin in the top and bottom of the row */
44
- margin: oneOf(['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl']),
45
- /** Any extra classes are attached to the root node, in addition to ffe-grid__row classes */
46
- className: string,
47
- /** All children of a `<GridRow />` must be `<GridCol />`. */
48
- children: node,
49
- /** Specify the DOM element being used to create the GridRow */
50
- element: string
51
- };
25
+ export var GridRow = function (_a) {
26
+ var _b, _c, _d, _e;
27
+ var background = _a.background, backgroundDark = _a.backgroundDark, className = _a.className, children = _a.children, _f = _a.as, Comp = _f === void 0 ? 'div' : _f, padding = _a.padding, margin = _a.margin, rest = __rest(_a, ["background", "backgroundDark", "className", "children", "as", "padding", "margin"]);
28
+ var hasBackgroundColor = !!background;
29
+ var hasBackgroundDarkColor = !!backgroundDark;
30
+ var content = hasBackgroundColor || hasBackgroundDarkColor ? (React.createElement("div", { className: "ffe-grid__row-wrapper" }, children)) : (children);
31
+ return (React.createElement(Comp, __assign({ className: classNames(className, 'ffe-grid__row', (_b = {}, _b["ffe-grid__row--bg-".concat(background)] = hasBackgroundColor, _b), (_c = {},
32
+ _c["ffe-grid__row--bg-dark-".concat(backgroundDark)] = hasBackgroundDarkColor,
33
+ _c), (_d = {}, _d["ffe-grid__row--padding-".concat(padding)] = padding, _d), (_e = {}, _e["ffe-grid__row--margin-".concat(margin)] = margin, _e)) }, rest), content));
34
+ };
package/es/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { default as Grid } from './Grid';
2
- export { default as GridRow } from './GridRow';
3
- export { default as GridCol } from './GridCol';
1
+ export { Grid } from './Grid';
2
+ export { GridRow } from './GridRow';
3
+ export { GridCol } from './GridCol';
package/es/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/lib/Grid.js CHANGED
@@ -1,39 +1,38 @@
1
1
  "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = Grid;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _classnames = _interopRequireDefault(require("classnames"));
10
- var _propTypes = require("prop-types");
11
- var _excluded = ["children", "className", "gap", "element"];
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
14
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
18
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
19
- function Grid(_ref) {
20
- var children = _ref.children,
21
- className = _ref.className,
22
- gap = _ref.gap,
23
- element = _ref.element,
24
- rest = _objectWithoutProperties(_ref, _excluded);
25
- var Element = element || 'div';
26
- return /*#__PURE__*/_react.default.createElement(Element, _extends({
27
- className: (0, _classnames.default)(className, 'ffe-grid', _defineProperty({}, "ffe-grid--gap-".concat(gap), gap))
28
- }, rest), children);
29
- }
30
- Grid.propTypes = {
31
- /** Any children of a Grid must be a GridRow */
32
- children: _propTypes.node,
33
- /** Any extra classes are attached to the root node, in addition to ffe-grid classes */
34
- className: _propTypes.string,
35
- /** Specify the internal gutter of the grid */
36
- gap: (0, _propTypes.oneOf)(['none', '2xs', 'xs', 'sm', 'md', 'lg']),
37
- /** Specify the DOM element being used to create the Grid */
38
- element: _propTypes.string
39
- };
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.Grid = void 0;
29
+ var react_1 = __importDefault(require("react"));
30
+ var classnames_1 = __importDefault(require("classnames"));
31
+ var Grid = function (_a) {
32
+ var _b;
33
+ var children = _a.children, className = _a.className, gap = _a.gap, _c = _a.as, Comp = _c === void 0 ? 'div' : _c, rest = __rest(_a, ["children", "className", "gap", "as"]);
34
+ return (react_1.default.createElement(Comp, __assign({ className: (0, classnames_1.default)(className, 'ffe-grid', (_b = {},
35
+ _b["ffe-grid--gap-".concat(gap)] = gap,
36
+ _b)) }, rest), children));
37
+ };
38
+ exports.Grid = Grid;
package/lib/GridCol.js CHANGED
@@ -1,137 +1,72 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _propTypes = require("prop-types");
9
- var _classnames = _interopRequireDefault(require("classnames"));
10
- var _backgroundColors = require("./background-colors");
11
- var _excluded = ["background", "backgroundDark", "className", "element", "centerText", "center", "children", "sm", "md", "lg"];
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
16
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
17
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
18
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
20
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
21
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
22
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
23
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
24
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
25
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
27
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
28
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
30
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
31
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
32
- var sizeClasses = function sizeClasses(size, def) {
33
- switch (_typeof(def)) {
34
- case 'undefined':
35
- return '';
36
- case 'object':
37
- return (0, _classnames.default)(_defineProperty(_defineProperty({}, "ffe-grid__col--".concat(size, "-").concat(def.cols), def.cols || def.cols === 0), "ffe-grid__col--".concat(size, "-offset-").concat(def.offset), def.offset || def.offset === 0));
38
- default:
39
- return "ffe-grid__col--".concat(size, "-").concat(def);
40
- }
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
41
12
  };
42
- var centerTextClass = function centerTextClass(centerText) {
43
- return centerText ? 'ffe-grid__col--center-text' : null;
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
44
23
  };
45
- var centerClass = function centerClass(center) {
46
- return center ? 'ffe-grid__col--center' : null;
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
47
26
  };
48
- var backgroundClass = function backgroundClass(background) {
49
- if (!background) {
50
- return null;
51
- }
52
- if (_backgroundColors.removedColors.includes(background)) {
53
- throw new Error("Support for the ".concat(background, " background on <GridCol> has been removed, please see the CHANGELOG"));
54
- }
55
- return _backgroundColors.backgroundColors.includes(background) ? "ffe-grid__col--bg-".concat(background) : null;
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.GridCol = void 0;
29
+ var react_1 = __importDefault(require("react"));
30
+ var classnames_1 = __importDefault(require("classnames"));
31
+ var sizeClasses = function (size, def) {
32
+ var _a;
33
+ if (def === undefined) {
34
+ return null;
35
+ }
36
+ else if (typeof def === 'number' || typeof def === 'string') {
37
+ return "ffe-grid__col--".concat(size, "-").concat(def);
38
+ }
39
+ return (0, classnames_1.default)((_a = {},
40
+ _a["ffe-grid__col--".concat(size, "-").concat(def.cols)] = def.cols || def.cols === 0,
41
+ _a["ffe-grid__col--".concat(size, "-offset-").concat(def.offset)] = def.offset || def.offset === 0,
42
+ _a));
56
43
  };
57
- var backgroundDarkClass = function backgroundDarkClass(backgroundDark) {
58
- return _backgroundColors.backgroundDarkColors.includes(backgroundDark) ? "ffe-grid__col--bg-dark-".concat(backgroundDark) : null;
44
+ var centerTextClass = function (centerText) {
45
+ return centerText ? 'ffe-grid__col--center-text' : null;
59
46
  };
60
- var GridCol = exports.default = /*#__PURE__*/function (_Component) {
61
- function GridCol() {
62
- var _this;
63
- _classCallCheck(this, GridCol);
64
- _this = _callSuper(this, GridCol);
65
- _this.ref = /*#__PURE__*/(0, _react.createRef)();
66
- return _this;
67
- }
68
- _inherits(GridCol, _Component);
69
- return _createClass(GridCol, [{
70
- key: "render",
71
- value: function render() {
72
- var _this$props = this.props,
73
- background = _this$props.background,
74
- backgroundDark = _this$props.backgroundDark,
75
- className = _this$props.className,
76
- _this$props$element = _this$props.element,
77
- Element = _this$props$element === void 0 ? 'div' : _this$props$element,
78
- centerText = _this$props.centerText,
79
- center = _this$props.center,
80
- children = _this$props.children,
81
- sm = _this$props.sm,
82
- md = _this$props.md,
83
- lg = _this$props.lg,
84
- rest = _objectWithoutProperties(_this$props, _excluded);
85
- var classes = ['ffe-grid__col', className, sizeClasses('lg', lg), sizeClasses('md', md), sizeClasses('sm', !sm && !lg && !md ? 12 : sm), centerTextClass(centerText), centerClass(center), backgroundClass(background), backgroundDarkClass(backgroundDark)].filter(function (x) {
86
- return x;
87
- }).join(' ');
88
- return /*#__PURE__*/_react.default.createElement(Element, _extends({
89
- className: classes,
90
- ref: this.ref
91
- }, rest), children);
92
- }
93
- }]);
94
- }(_react.Component);
95
- GridCol.propTypes = {
96
- /** Supported background colors */
97
- background: (0, _propTypes.oneOf)(_backgroundColors.backgroundColors),
98
- /** Supported dark background colors */
99
- backgroundDark: (0, _propTypes.oneOf)(_backgroundColors.backgroundDarkColors),
100
- /** Any extra classes are attached to the root node, in addition to ffe-grid__col classes */
101
- className: _propTypes.string,
102
- /** Specify the DOM element being used to create the GridCol */
103
- element: _propTypes.node,
104
- /** Center text content horizontally */
105
- centerText: _propTypes.bool,
106
- /** Center content vertically */
107
- center: _propTypes.bool,
108
- /** The content of the column */
109
- children: _propTypes.node,
110
- /** Size modifiers for small screen sizes */
111
- sm: (0, _propTypes.oneOfType)([/** Number of columns, 0-12 */
112
- _propTypes.number, /** Number of columns, 0-12 */
113
- _propTypes.string, (0, _propTypes.shape)({
114
- /** Number of columns, 0-12 */
115
- cols: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string]),
116
- /** Number of colums offset, 0-12 */
117
- offset: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string])
118
- })]),
119
- /** Size modifiers for medium screen sizes */
120
- md: (0, _propTypes.oneOfType)([/** Number of columns, 0-12 */
121
- _propTypes.number, /** Number of columns, 0-12 */
122
- _propTypes.string, (0, _propTypes.shape)({
123
- /** Number of columns, 0-12 */
124
- cols: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string]),
125
- /** Number of colums offset, 0-12 */
126
- offset: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string])
127
- })]),
128
- /** Size modifiers for large screen sizes */
129
- lg: (0, _propTypes.oneOfType)([/** Number of columns, 0-12 */
130
- _propTypes.number, /** Number of columns, 0-12 */
131
- _propTypes.string, (0, _propTypes.shape)({
132
- /** Number of columns, 0-12 */
133
- cols: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string]),
134
- /** Number of colums offset, 0-12 */
135
- offset: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string])
136
- })])
137
- };
47
+ var centerClass = function (center) {
48
+ return center ? 'ffe-grid__col--center' : null;
49
+ };
50
+ var backgroundClass = function (background) {
51
+ return background ? "ffe-grid__col--bg-".concat(background) : null;
52
+ };
53
+ var backgroundDarkClass = function (backgroundDark) {
54
+ return backgroundDark ? "ffe-grid__col--bg-dark-".concat(backgroundDark) : null;
55
+ };
56
+ var GridCol = function (_a) {
57
+ var background = _a.background, backgroundDark = _a.backgroundDark, className = _a.className, _b = _a.as, Comp = _b === void 0 ? 'div' : _b, centerText = _a.centerText, center = _a.center, children = _a.children, sm = _a.sm, md = _a.md, lg = _a.lg, rest = __rest(_a, ["background", "backgroundDark", "className", "as", "centerText", "center", "children", "sm", "md", "lg"]);
58
+ return (react_1.default.createElement(Comp, __assign({ className: [
59
+ 'ffe-grid__col',
60
+ className,
61
+ sizeClasses('lg', lg),
62
+ sizeClasses('md', md),
63
+ sizeClasses('sm', !sm && !lg && !md ? 12 : sm),
64
+ centerTextClass(centerText),
65
+ centerClass(center),
66
+ backgroundClass(background),
67
+ backgroundDarkClass(backgroundDark),
68
+ ]
69
+ .filter(function (x) { return x; })
70
+ .join(' ') }, rest), children));
71
+ };
72
+ exports.GridCol = GridCol;
package/lib/GridRow.js CHANGED
@@ -1,58 +1,41 @@
1
1
  "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = GridRow;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _propTypes = require("prop-types");
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- var _backgroundColors = require("./background-colors");
12
- var _excluded = ["background", "backgroundDark", "className", "children", "element", "padding", "margin"];
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
20
- function GridRow(_ref) {
21
- var background = _ref.background,
22
- backgroundDark = _ref.backgroundDark,
23
- className = _ref.className,
24
- children = _ref.children,
25
- element = _ref.element,
26
- padding = _ref.padding,
27
- margin = _ref.margin,
28
- rest = _objectWithoutProperties(_ref, _excluded);
29
- var hasBackgroundColor = _backgroundColors.backgroundColors.includes(background);
30
- var hasBackgroundDarkColor = _backgroundColors.backgroundDarkColors.includes(backgroundDark);
31
- var hasRemovedColor = _backgroundColors.removedColors.includes(background);
32
- var content = hasBackgroundColor || hasBackgroundDarkColor ? /*#__PURE__*/_react.default.createElement("div", {
33
- className: "ffe-grid__row-wrapper"
34
- }, children) : children;
35
- if (hasRemovedColor) {
36
- throw new Error("Support for the ".concat(background, " background on <GridRow> has been removed, please see the CHANGELOG"));
37
- }
38
- var Element = element || 'div';
39
- return /*#__PURE__*/_react.default.createElement(Element, _extends({
40
- className: (0, _classnames.default)(className, 'ffe-grid__row', _defineProperty({}, "ffe-grid__row--bg-".concat(background), hasBackgroundColor), _defineProperty({}, "ffe-grid__row--bg-dark-".concat(backgroundDark), hasBackgroundDarkColor), _defineProperty({}, "ffe-grid__row--padding-".concat(padding), padding), _defineProperty({}, "ffe-grid__row--margin-".concat(margin), margin))
41
- }, rest), content);
42
- }
43
- GridRow.propTypes = {
44
- /** Supported background colors */
45
- background: (0, _propTypes.oneOf)(_backgroundColors.backgroundColors),
46
- /** Supported dark background colors */
47
- backgroundDark: (0, _propTypes.oneOf)(_backgroundColors.backgroundDarkColors),
48
- /** Padding in the top and bottom of the row */
49
- padding: (0, _propTypes.oneOf)(['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl']),
50
- /** Margin in the top and bottom of the row */
51
- margin: (0, _propTypes.oneOf)(['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl']),
52
- /** Any extra classes are attached to the root node, in addition to ffe-grid__row classes */
53
- className: _propTypes.string,
54
- /** All children of a `<GridRow />` must be `<GridCol />`. */
55
- children: _propTypes.node,
56
- /** Specify the DOM element being used to create the GridRow */
57
- element: _propTypes.string
58
- };
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.GridRow = void 0;
29
+ var react_1 = __importDefault(require("react"));
30
+ var classnames_1 = __importDefault(require("classnames"));
31
+ var GridRow = function (_a) {
32
+ var _b, _c, _d, _e;
33
+ var background = _a.background, backgroundDark = _a.backgroundDark, className = _a.className, children = _a.children, _f = _a.as, Comp = _f === void 0 ? 'div' : _f, padding = _a.padding, margin = _a.margin, rest = __rest(_a, ["background", "backgroundDark", "className", "children", "as", "padding", "margin"]);
34
+ var hasBackgroundColor = !!background;
35
+ var hasBackgroundDarkColor = !!backgroundDark;
36
+ var content = hasBackgroundColor || hasBackgroundDarkColor ? (react_1.default.createElement("div", { className: "ffe-grid__row-wrapper" }, children)) : (children);
37
+ return (react_1.default.createElement(Comp, __assign({ className: (0, classnames_1.default)(className, 'ffe-grid__row', (_b = {}, _b["ffe-grid__row--bg-".concat(background)] = hasBackgroundColor, _b), (_c = {},
38
+ _c["ffe-grid__row--bg-dark-".concat(backgroundDark)] = hasBackgroundDarkColor,
39
+ _c), (_d = {}, _d["ffe-grid__row--padding-".concat(padding)] = padding, _d), (_e = {}, _e["ffe-grid__row--margin-".concat(margin)] = margin, _e)) }, rest), content));
40
+ };
41
+ exports.GridRow = GridRow;
package/lib/index.js CHANGED
@@ -1,27 +1,9 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "Grid", {
7
- enumerable: true,
8
- get: function get() {
9
- return _Grid.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "GridCol", {
13
- enumerable: true,
14
- get: function get() {
15
- return _GridCol.default;
16
- }
17
- });
18
- Object.defineProperty(exports, "GridRow", {
19
- enumerable: true,
20
- get: function get() {
21
- return _GridRow.default;
22
- }
23
- });
24
- var _Grid = _interopRequireDefault(require("./Grid"));
25
- var _GridRow = _interopRequireDefault(require("./GridRow"));
26
- var _GridCol = _interopRequireDefault(require("./GridCol"));
27
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GridCol = exports.GridRow = exports.Grid = void 0;
4
+ var Grid_1 = require("./Grid");
5
+ Object.defineProperty(exports, "Grid", { enumerable: true, get: function () { return Grid_1.Grid; } });
6
+ var GridRow_1 = require("./GridRow");
7
+ Object.defineProperty(exports, "GridRow", { enumerable: true, get: function () { return GridRow_1.GridRow; } });
8
+ var GridCol_1 = require("./GridCol");
9
+ Object.defineProperty(exports, "GridCol", { enumerable: true, get: function () { return GridCol_1.GridCol; } });
package/lib/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sb1/ffe-grid-react",
3
- "version": "13.2.14",
3
+ "version": "14.0.0",
4
4
  "license": "MIT",
5
5
  "author": "SpareBank1",
6
6
  "files": [
@@ -17,7 +17,7 @@
17
17
  "url": "ssh://git@github.com:SpareBank1/designsystem.git"
18
18
  },
19
19
  "scripts": {
20
- "build": "ffe-buildtool babel",
20
+ "build": "ffe-buildtool tsc",
21
21
  "watch": "ffe-buildtool babel-watch",
22
22
  "lint": "eslint src",
23
23
  "lint:fix": "eslint src --fix",
@@ -25,7 +25,7 @@
25
25
  "test:watch": "ffe-buildtool jest --watch"
26
26
  },
27
27
  "dependencies": {
28
- "@sb1/ffe-grid": "^14.2.14",
28
+ "@sb1/ffe-grid": "^14.2.15",
29
29
  "classnames": "^2.3.1"
30
30
  },
31
31
  "devDependencies": {
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "12285ee4ecea525ee235bc88aee2ffe38c32f0d1"
42
+ "gitHead": "279a4e7d3afe4b4679448a28d1cdd8557740fdd5"
43
43
  }
@@ -0,0 +1,7 @@
1
+ import React, { ElementType } from 'react';
2
+ import { ComponentWithoutRefAsPropParams } from './types';
3
+ export type GridProps<As extends ElementType = any> = ComponentWithoutRefAsPropParams<As> & {
4
+ /** Specify the internal gutter of the grid */
5
+ gap?: 'none' | '2xs' | 'xs' | 'sm' | 'md' | 'lg';
6
+ };
7
+ export declare const Grid: React.FC<GridProps>;
@@ -0,0 +1,26 @@
1
+ import React, { ElementType } from 'react';
2
+ import { BackgroundColor, BackgroundColorDark, ComponentWithoutRefAsPropParams } from './types';
3
+ type ColumnsRange = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12';
4
+ interface GridColSize {
5
+ cols: ColumnsRange;
6
+ offset?: ColumnsRange;
7
+ }
8
+ type SizeModifier = ColumnsRange | GridColSize;
9
+ export type GridColProps<As extends ElementType = any> = ComponentWithoutRefAsPropParams<As> & {
10
+ /** Supported background colors */
11
+ background?: BackgroundColor;
12
+ /** Supported dark background colors */
13
+ backgroundDark?: BackgroundColorDark;
14
+ /** Center text content horizontally */
15
+ centerText?: boolean;
16
+ /** Center content vertically */
17
+ center?: boolean;
18
+ /** Size modifiers for small screen sizes */
19
+ sm?: SizeModifier;
20
+ /** Size modifiers for medium screen sizes */
21
+ md?: SizeModifier;
22
+ /** Size modifiers for large screen sizes */
23
+ lg?: SizeModifier;
24
+ };
25
+ export declare const GridCol: React.FC<GridColProps>;
26
+ export {};
@@ -0,0 +1,13 @@
1
+ import React, { ElementType } from 'react';
2
+ import { ComponentWithoutRefAsPropParams, BackgroundColor, BackgroundColorDark, Margin, Padding } from './types';
3
+ export type GridRowProps<As extends ElementType = any> = ComponentWithoutRefAsPropParams<As> & {
4
+ /** Padding in the top and bottom of the row */
5
+ padding?: Padding;
6
+ /** Margin in the top and bottom of the row */
7
+ margin?: Margin;
8
+ /** Supported background colors */
9
+ background?: BackgroundColor;
10
+ /** Supported dark background colors */
11
+ backgroundDark?: BackgroundColorDark;
12
+ };
13
+ export declare const GridRow: React.FC<GridRowProps>;
package/types/index.d.ts CHANGED
@@ -1,82 +1,3 @@
1
- import * as React from 'react';
2
-
3
- type Gap = 'none' | '2xs' | 'xs' | 'md' | 'lg';
4
-
5
- export interface GridProps extends React.ComponentProps<'div'> {
6
- children: React.ReactNode;
7
- className?: string;
8
- element?: string;
9
- gap?: Gap;
10
- }
11
-
12
- type BackgroundColors =
13
- | 'frost-30'
14
- | 'sand'
15
- | 'sand-70'
16
- | 'sand-30'
17
- | 'syrin-70'
18
- | 'syrin-30'
19
- | 'vann'
20
- | 'vann-30'
21
- | 'fjell'
22
- | 'hvit';
23
-
24
- type BackgroundDarkColors = 'svart' | 'natt' | 'koksgraa';
25
-
26
- type Margin =
27
- | '2xs'
28
- | 'xs'
29
- | 'sm'
30
- | 'md'
31
- | 'lg'
32
- | 'xl'
33
- | '2xl'
34
- | '3xl'
35
- | '4xl'
36
- | '5xl';
37
-
38
- type Padding =
39
- | '2xs'
40
- | 'xs'
41
- | 'sm'
42
- | 'md'
43
- | 'lg'
44
- | 'xl'
45
- | '2xl'
46
- | '3xl'
47
- | '4xl'
48
- | '5xl';
49
-
50
- export interface GridRowProps extends React.ComponentProps<'div'> {
51
- background?: BackgroundColors;
52
- backgroundDark?: BackgroundDarkColors;
53
- children: React.ReactNode;
54
- className?: string;
55
- element?: string;
56
- padding?: Padding;
57
- margin?: Margin;
58
- }
59
-
60
- type ColumnsRange = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
61
-
62
- export interface GridColSize {
63
- cols: ColumnsRange | string;
64
- offset: ColumnsRange | string;
65
- }
66
-
67
- export interface GridColProps extends React.ComponentProps<'div'> {
68
- background?: BackgroundColors;
69
- backgroundDark?: BackgroundDarkColors;
70
- children?: React.ReactNode;
71
- className?: string;
72
- element?: React.ReactNode;
73
- center?: boolean;
74
- centerText?: boolean;
75
- sm?: ColumnsRange | string | GridColSize;
76
- md?: ColumnsRange | string | GridColSize;
77
- lg?: ColumnsRange | string | GridColSize;
78
- }
79
-
80
- declare class Grid extends React.Component<GridProps, any> {}
81
- declare class GridRow extends React.Component<GridRowProps, any> {}
82
- declare class GridCol extends React.Component<GridColProps, any> {}
1
+ export { Grid, GridProps } from './Grid';
2
+ export { GridRow, GridRowProps } from './GridRow';
3
+ export { GridCol, GridColProps } from './GridCol';
@@ -0,0 +1,10 @@
1
+ import { ComponentPropsWithoutRef, ElementType } from 'react';
2
+ export type DistributiveOmit<T, Omitted extends PropertyKey> = T extends any ? Omit<T, Omitted> : never;
3
+ export type ComponentWithoutRefAsPropParams<As extends ElementType = any> = {
4
+ as?: As;
5
+ } & DistributiveOmit<ComponentPropsWithoutRef<ElementType extends As ? 'div' : As>, 'as'>;
6
+ export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
7
+ export type Margin = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl';
8
+ export type Padding = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl';
9
+ export type BackgroundColor = 'frost-30' | 'sand' | 'sand-70' | 'sand-30' | 'syrin-70' | 'syrin-30' | 'vann' | 'vann-30' | 'fjell' | 'hvit';
10
+ export type BackgroundColorDark = 'svart' | 'natt' | 'koksgraa';
@@ -1,3 +0,0 @@
1
- export var backgroundColors = ['frost-30', 'sand', 'sand-70', 'sand-30', 'syrin-70', 'syrin-30', 'vann', 'vann-30', 'fjell', 'hvit'];
2
- export var backgroundDarkColors = ['svart', 'natt', 'koksgraa'];
3
- export var removedColors = ['blue-cobalt', 'blue-royal', 'purple-magenta', 'blue-ice', 'blue-pale', 'green-mint', 'grey-cloud', 'grey-warm', 'orange-salmon', 'red', 'blue-sky', 'white'];
package/es/index.d.js DELETED
@@ -1 +0,0 @@
1
- import * as React from 'react';
package/es/show-grid.js DELETED
@@ -1,36 +0,0 @@
1
- import React from 'react';
2
- import { Grid, GridRow, GridCol } from '@sb1/ffe-grid-react';
3
- import { render } from 'react-dom';
4
- var createGridContainer = function createGridContainer() {
5
- var css = "\n .ffe-grid-react-debug__grid-content {\n background: #e1e1e1;\n height: 100vh;\n opacity: 0.6;\n width: 100%;\n }\n\n .ffe-grid-react-debug__grid-container {\n height: 100%;\n pointer-events: none;\n position: fixed;\n top: 0;\n z-index: 9999;\n width: 100%;\n }\n ";
6
- var style = document.createElement('style');
7
- style.id = 'gridViewStyle';
8
- style.type = 'text/css';
9
- style.appendChild(document.createTextNode(css));
10
- document.head.appendChild(style);
11
- var div = document.createElement('div');
12
- div.id = 'gridView';
13
- div.classList.add('ffe-grid-react-debug__grid-container');
14
- document.body.appendChild(div);
15
- return div;
16
- };
17
- var showGrid = function showGrid() {
18
- var div = document.getElementById('gridView');
19
- if (div) {
20
- var styleDiv = document.getElementById('gridViewStyle');
21
- styleDiv.parentNode.removeChild(styleDiv);
22
- return div.parentNode.removeChild(div);
23
- }
24
- var grid = /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(GridRow, null, new Array(12).fill(null).map(function (_, index) {
25
- return /*#__PURE__*/React.createElement(GridCol, {
26
- lg: 1,
27
- md: 2,
28
- sm: 3,
29
- key: index
30
- }, /*#__PURE__*/React.createElement("div", {
31
- className: "ffe-grid-react-debug__grid-content"
32
- }));
33
- })));
34
- render(grid, createGridContainer());
35
- };
36
- export default showGrid;
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.removedColors = exports.backgroundDarkColors = exports.backgroundColors = void 0;
7
- var backgroundColors = exports.backgroundColors = ['frost-30', 'sand', 'sand-70', 'sand-30', 'syrin-70', 'syrin-30', 'vann', 'vann-30', 'fjell', 'hvit'];
8
- var backgroundDarkColors = exports.backgroundDarkColors = ['svart', 'natt', 'koksgraa'];
9
- var removedColors = exports.removedColors = ['blue-cobalt', 'blue-royal', 'purple-magenta', 'blue-ice', 'blue-pale', 'green-mint', 'grey-cloud', 'grey-warm', 'orange-salmon', 'red', 'blue-sky', 'white'];
package/lib/index.d.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- var React = _interopRequireWildcard(require("react"));
5
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
6
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
package/lib/show-grid.js DELETED
@@ -1,43 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _ffeGridReact = require("@sb1/ffe-grid-react");
9
- var _reactDom = require("react-dom");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- var createGridContainer = function createGridContainer() {
12
- var css = "\n .ffe-grid-react-debug__grid-content {\n background: #e1e1e1;\n height: 100vh;\n opacity: 0.6;\n width: 100%;\n }\n\n .ffe-grid-react-debug__grid-container {\n height: 100%;\n pointer-events: none;\n position: fixed;\n top: 0;\n z-index: 9999;\n width: 100%;\n }\n ";
13
- var style = document.createElement('style');
14
- style.id = 'gridViewStyle';
15
- style.type = 'text/css';
16
- style.appendChild(document.createTextNode(css));
17
- document.head.appendChild(style);
18
- var div = document.createElement('div');
19
- div.id = 'gridView';
20
- div.classList.add('ffe-grid-react-debug__grid-container');
21
- document.body.appendChild(div);
22
- return div;
23
- };
24
- var showGrid = function showGrid() {
25
- var div = document.getElementById('gridView');
26
- if (div) {
27
- var styleDiv = document.getElementById('gridViewStyle');
28
- styleDiv.parentNode.removeChild(styleDiv);
29
- return div.parentNode.removeChild(div);
30
- }
31
- var grid = /*#__PURE__*/_react.default.createElement(_ffeGridReact.Grid, null, /*#__PURE__*/_react.default.createElement(_ffeGridReact.GridRow, null, new Array(12).fill(null).map(function (_, index) {
32
- return /*#__PURE__*/_react.default.createElement(_ffeGridReact.GridCol, {
33
- lg: 1,
34
- md: 2,
35
- sm: 3,
36
- key: index
37
- }, /*#__PURE__*/_react.default.createElement("div", {
38
- className: "ffe-grid-react-debug__grid-content"
39
- }));
40
- })));
41
- (0, _reactDom.render)(grid, createGridContainer());
42
- };
43
- var _default = exports.default = showGrid;