@sb1/ffe-grid-react 13.1.0 → 13.2.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/es/GridCol.js CHANGED
@@ -1,4 +1,4 @@
1
- var _excluded = ["children", "className", "element", "lg", "md", "sm"];
1
+ var _excluded = ["background", "backgroundDark", "className", "element", "centerText", "center", "children", "sm", "md", "lg"];
2
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
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
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -19,13 +19,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
19
19
  import React, { Component, createRef } from 'react';
20
20
  import { bool, node, number, oneOf, oneOfType, shape, string } from 'prop-types';
21
21
  import classNames from 'classnames';
22
- import { backgroundColors, removedColors } from './background-colors';
23
- function camelCaseToDashCase(str) {
24
- return str.split('').reduce(function (previous, current) {
25
- return /[A-Z]/.test(current) ? "".concat(previous, "-").concat(current.toLowerCase()) : "".concat(previous).concat(current);
26
- });
27
- }
28
- var MODIFIER_LIST = ['background', 'centerText', 'center'];
22
+ import { backgroundColors, backgroundDarkColors, removedColors } from './background-colors';
29
23
  var sizeClasses = function sizeClasses(size, def) {
30
24
  switch (_typeof(def)) {
31
25
  case 'undefined':
@@ -36,15 +30,13 @@ var sizeClasses = function sizeClasses(size, def) {
36
30
  return "ffe-grid__col--".concat(size, "-").concat(def);
37
31
  }
38
32
  };
39
- var modifiers = function modifiers(props) {
40
- return Object.keys(props).filter(function (key) {
41
- return MODIFIER_LIST.indexOf(key) !== -1 && !!props[key];
42
- }).map(function (key) {
43
- return "ffe-grid__col--".concat(camelCaseToDashCase(key));
44
- }).join(' ');
33
+ var centerTextClass = function centerTextClass(centerText) {
34
+ return centerText ? 'ffe-grid__col--center-text' : null;
45
35
  };
46
- var backgroundClass = function backgroundClass(_ref) {
47
- var background = _ref.background;
36
+ var centerClass = function centerClass(center) {
37
+ return center ? 'ffe-grid__col--center' : null;
38
+ };
39
+ var backgroundClass = function backgroundClass(background) {
48
40
  if (!background) {
49
41
  return null;
50
42
  }
@@ -53,6 +45,9 @@ var backgroundClass = function backgroundClass(_ref) {
53
45
  }
54
46
  return backgroundColors.includes(background) ? "ffe-grid__col--bg-".concat(background) : null;
55
47
  };
48
+ var backgroundDarkClass = function backgroundDarkClass(backgroundDark) {
49
+ return backgroundDarkColors.includes(backgroundDark) ? "ffe-grid__col--bg-dark-".concat(backgroundDark) : null;
50
+ };
56
51
  var GridCol = /*#__PURE__*/function (_Component) {
57
52
  _inherits(GridCol, _Component);
58
53
  var _super = _createSuper(GridCol);
@@ -67,19 +62,18 @@ var GridCol = /*#__PURE__*/function (_Component) {
67
62
  key: "render",
68
63
  value: function render() {
69
64
  var _this$props = this.props,
70
- children = _this$props.children,
65
+ background = _this$props.background,
66
+ backgroundDark = _this$props.backgroundDark,
71
67
  className = _this$props.className,
72
68
  Element = _this$props.element,
73
- lg = _this$props.lg,
74
- md = _this$props.md,
69
+ centerText = _this$props.centerText,
70
+ center = _this$props.center,
71
+ children = _this$props.children,
75
72
  sm = _this$props.sm,
73
+ md = _this$props.md,
74
+ lg = _this$props.lg,
76
75
  rest = _objectWithoutProperties(_this$props, _excluded);
77
- Object.keys(rest).forEach(function (key) {
78
- if (MODIFIER_LIST.includes(key)) {
79
- delete rest[key];
80
- }
81
- });
82
- var classes = ['ffe-grid__col', className, sizeClasses('lg', lg), sizeClasses('md', md), sizeClasses('sm', !sm && !lg && !md ? 12 : sm), modifiers(this.props), backgroundClass(this.props)].filter(function (x) {
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) {
83
77
  return x;
84
78
  }).join(' ');
85
79
  return /*#__PURE__*/React.createElement(Element, _extends({
@@ -96,7 +90,9 @@ GridCol.defaultProps = {
96
90
  };
97
91
  GridCol.propTypes = {
98
92
  /** Supported background colors */
99
- background: oneOf(['frost-30', 'sand', 'sand-70', 'sand-30', 'syrin-70', 'syrin-30', 'vann', 'vann-30', 'fjell', 'hvit']),
93
+ background: oneOf(backgroundColors),
94
+ /** Supported dark background colors */
95
+ backgroundDark: oneOf(backgroundDarkColors),
100
96
  /** Any extra classes are attached to the root node, in addition to ffe-grid__col classes */
101
97
  className: string,
102
98
  /** Specify the DOM element being used to create the GridCol */
package/lib/GridCol.js CHANGED
@@ -8,7 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = require("prop-types");
9
9
  var _classnames = _interopRequireDefault(require("classnames"));
10
10
  var _backgroundColors = require("./background-colors");
11
- var _excluded = ["children", "className", "element", "lg", "md", "sm"];
11
+ var _excluded = ["background", "backgroundDark", "className", "element", "centerText", "center", "children", "sm", "md", "lg"];
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
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
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 && Object.prototype.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; }
@@ -29,12 +29,6 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
29
29
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
30
30
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
31
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
- function camelCaseToDashCase(str) {
33
- return str.split('').reduce(function (previous, current) {
34
- return /[A-Z]/.test(current) ? "".concat(previous, "-").concat(current.toLowerCase()) : "".concat(previous).concat(current);
35
- });
36
- }
37
- var MODIFIER_LIST = ['background', 'centerText', 'center'];
38
32
  var sizeClasses = function sizeClasses(size, def) {
39
33
  switch (_typeof(def)) {
40
34
  case 'undefined':
@@ -45,15 +39,13 @@ var sizeClasses = function sizeClasses(size, def) {
45
39
  return "ffe-grid__col--".concat(size, "-").concat(def);
46
40
  }
47
41
  };
48
- var modifiers = function modifiers(props) {
49
- return Object.keys(props).filter(function (key) {
50
- return MODIFIER_LIST.indexOf(key) !== -1 && !!props[key];
51
- }).map(function (key) {
52
- return "ffe-grid__col--".concat(camelCaseToDashCase(key));
53
- }).join(' ');
42
+ var centerTextClass = function centerTextClass(centerText) {
43
+ return centerText ? 'ffe-grid__col--center-text' : null;
54
44
  };
55
- var backgroundClass = function backgroundClass(_ref) {
56
- var background = _ref.background;
45
+ var centerClass = function centerClass(center) {
46
+ return center ? 'ffe-grid__col--center' : null;
47
+ };
48
+ var backgroundClass = function backgroundClass(background) {
57
49
  if (!background) {
58
50
  return null;
59
51
  }
@@ -62,6 +54,9 @@ var backgroundClass = function backgroundClass(_ref) {
62
54
  }
63
55
  return _backgroundColors.backgroundColors.includes(background) ? "ffe-grid__col--bg-".concat(background) : null;
64
56
  };
57
+ var backgroundDarkClass = function backgroundDarkClass(backgroundDark) {
58
+ return _backgroundColors.backgroundDarkColors.includes(backgroundDark) ? "ffe-grid__col--bg-dark-".concat(backgroundDark) : null;
59
+ };
65
60
  var GridCol = exports.default = /*#__PURE__*/function (_Component) {
66
61
  _inherits(GridCol, _Component);
67
62
  var _super = _createSuper(GridCol);
@@ -76,19 +71,18 @@ var GridCol = exports.default = /*#__PURE__*/function (_Component) {
76
71
  key: "render",
77
72
  value: function render() {
78
73
  var _this$props = this.props,
79
- children = _this$props.children,
74
+ background = _this$props.background,
75
+ backgroundDark = _this$props.backgroundDark,
80
76
  className = _this$props.className,
81
77
  Element = _this$props.element,
82
- lg = _this$props.lg,
83
- md = _this$props.md,
78
+ centerText = _this$props.centerText,
79
+ center = _this$props.center,
80
+ children = _this$props.children,
84
81
  sm = _this$props.sm,
82
+ md = _this$props.md,
83
+ lg = _this$props.lg,
85
84
  rest = _objectWithoutProperties(_this$props, _excluded);
86
- Object.keys(rest).forEach(function (key) {
87
- if (MODIFIER_LIST.includes(key)) {
88
- delete rest[key];
89
- }
90
- });
91
- var classes = ['ffe-grid__col', className, sizeClasses('lg', lg), sizeClasses('md', md), sizeClasses('sm', !sm && !lg && !md ? 12 : sm), modifiers(this.props), backgroundClass(this.props)].filter(function (x) {
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) {
92
86
  return x;
93
87
  }).join(' ');
94
88
  return /*#__PURE__*/_react.default.createElement(Element, _extends({
@@ -104,7 +98,9 @@ GridCol.defaultProps = {
104
98
  };
105
99
  GridCol.propTypes = {
106
100
  /** Supported background colors */
107
- background: (0, _propTypes.oneOf)(['frost-30', 'sand', 'sand-70', 'sand-30', 'syrin-70', 'syrin-30', 'vann', 'vann-30', 'fjell', 'hvit']),
101
+ background: (0, _propTypes.oneOf)(_backgroundColors.backgroundColors),
102
+ /** Supported dark background colors */
103
+ backgroundDark: (0, _propTypes.oneOf)(_backgroundColors.backgroundDarkColors),
108
104
  /** Any extra classes are attached to the root node, in addition to ffe-grid__col classes */
109
105
  className: _propTypes.string,
110
106
  /** Specify the DOM element being used to create the GridCol */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sb1/ffe-grid-react",
3
- "version": "13.1.0",
3
+ "version": "13.2.0",
4
4
  "license": "MIT",
5
5
  "author": "SpareBank1",
6
6
  "files": [
@@ -24,7 +24,7 @@
24
24
  "test:watch": "ffe-buildtool jest --watch"
25
25
  },
26
26
  "dependencies": {
27
- "@sb1/ffe-grid": "^14.1.0",
27
+ "@sb1/ffe-grid": "^14.2.0",
28
28
  "classnames": "^2.3.1"
29
29
  },
30
30
  "devDependencies": {
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "f8ef90c54a8eaf40fcfaa20b5b66ea5b1e0ed62d"
41
+ "gitHead": "2fbed8952cbf28eb2fde5a97d00cf4e48a18f535"
42
42
  }
package/types/index.d.ts CHANGED
@@ -66,6 +66,7 @@ export interface GridColSize {
66
66
 
67
67
  export interface GridColProps extends React.ComponentProps<'div'> {
68
68
  background?: BackgroundColors;
69
+ backgroundDark?: BackgroundDarkColors;
69
70
  children?: React.ReactNode;
70
71
  className?: string;
71
72
  element?: React.ReactNode;