grommet 2.25.2 → 2.26.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.
Files changed (111) hide show
  1. package/components/Anchor/Anchor.js +1 -1
  2. package/components/Box/stories/BackgroundThemed.js +54 -0
  3. package/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
  4. package/components/Button/Button.js +2 -2
  5. package/components/Calendar/Calendar.js +2 -1
  6. package/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
  7. package/components/CheckBoxGroup/index.d.ts +2 -1
  8. package/components/CheckBoxGroup/propTypes.js +1 -0
  9. package/components/FormField/FormField.js +1 -1
  10. package/components/Heading/Heading.js +31 -2
  11. package/components/Heading/StyledHeading.js +1 -1
  12. package/components/Heading/index.d.ts +1 -0
  13. package/components/Heading/propTypes.js +1 -0
  14. package/components/Heading/stories/All.js +4 -1
  15. package/components/Layer/LayerContainer.js +16 -9
  16. package/components/List/List.js +131 -33
  17. package/components/List/index.d.ts +1 -0
  18. package/components/List/propTypes.js +1 -0
  19. package/components/List/stories/Pinned.js +36 -0
  20. package/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
  21. package/components/Select/DefaultSelectTextInput.js +43 -0
  22. package/components/Select/EmptySearchOption.js +34 -0
  23. package/components/Select/Select.js +30 -95
  24. package/components/Select/SelectContainer.js +19 -59
  25. package/components/Select/StyledSelect.js +58 -2
  26. package/components/Select/index.d.ts +11 -9
  27. package/components/Select/propTypes.js +44 -40
  28. package/components/Select/utils.js +103 -3
  29. package/components/SelectMultiple/README.md +2 -0
  30. package/components/SelectMultiple/SelectMultiple.js +476 -0
  31. package/components/SelectMultiple/SelectMultipleContainer.js +481 -0
  32. package/components/SelectMultiple/SelectMultipleValue.js +166 -0
  33. package/components/SelectMultiple/SelectionSummary.js +104 -0
  34. package/components/SelectMultiple/index.d.ts +21 -0
  35. package/components/SelectMultiple/index.js +8 -0
  36. package/components/SelectMultiple/propTypes.js +28 -0
  37. package/components/SelectMultiple/stories/Default.js +76 -0
  38. package/components/SelectMultiple/stories/Disabled.js +84 -0
  39. package/components/SelectMultiple/stories/FormField.js +66 -0
  40. package/components/SelectMultiple/stories/Limited.js +68 -0
  41. package/components/SelectMultiple/stories/LongList.js +76 -0
  42. package/components/SelectMultiple/stories/ObjectOptions.js +80 -0
  43. package/components/SelectMultiple/stories/ShowSelectedInline.js +76 -0
  44. package/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
  45. package/components/index.d.ts +1 -0
  46. package/components/index.js +8 -0
  47. package/es6/components/Anchor/Anchor.js +2 -2
  48. package/es6/components/Box/stories/BackgroundThemed.js +39 -0
  49. package/es6/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
  50. package/es6/components/Button/Button.js +3 -3
  51. package/es6/components/Calendar/Calendar.js +2 -1
  52. package/es6/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
  53. package/es6/components/CheckBoxGroup/index.d.ts +2 -1
  54. package/es6/components/CheckBoxGroup/propTypes.js +1 -0
  55. package/es6/components/FormField/FormField.js +1 -1
  56. package/es6/components/Heading/Heading.js +30 -3
  57. package/es6/components/Heading/StyledHeading.js +1 -1
  58. package/es6/components/Heading/index.d.ts +1 -0
  59. package/es6/components/Heading/propTypes.js +1 -0
  60. package/es6/components/Heading/stories/All.js +4 -1
  61. package/es6/components/Layer/LayerContainer.js +16 -9
  62. package/es6/components/List/List.js +131 -34
  63. package/es6/components/List/index.d.ts +1 -0
  64. package/es6/components/List/propTypes.js +1 -0
  65. package/es6/components/List/stories/Pinned.js +21 -0
  66. package/es6/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
  67. package/es6/components/Select/DefaultSelectTextInput.js +31 -0
  68. package/es6/components/Select/EmptySearchOption.js +21 -0
  69. package/es6/components/Select/Select.js +26 -89
  70. package/es6/components/Select/SelectContainer.js +19 -58
  71. package/es6/components/Select/StyledSelect.js +45 -1
  72. package/es6/components/Select/index.d.ts +11 -9
  73. package/es6/components/Select/propTypes.js +41 -39
  74. package/es6/components/Select/utils.js +75 -1
  75. package/es6/components/SelectMultiple/README.md +2 -0
  76. package/es6/components/SelectMultiple/SelectMultiple.js +447 -0
  77. package/es6/components/SelectMultiple/SelectMultipleContainer.js +453 -0
  78. package/es6/components/SelectMultiple/SelectMultipleValue.js +152 -0
  79. package/es6/components/SelectMultiple/SelectionSummary.js +91 -0
  80. package/es6/components/SelectMultiple/index.d.ts +21 -0
  81. package/es6/components/SelectMultiple/index.js +1 -0
  82. package/es6/components/SelectMultiple/propTypes.js +18 -0
  83. package/es6/components/SelectMultiple/stories/Default.js +60 -0
  84. package/es6/components/SelectMultiple/stories/Disabled.js +68 -0
  85. package/es6/components/SelectMultiple/stories/FormField.js +50 -0
  86. package/es6/components/SelectMultiple/stories/Limited.js +53 -0
  87. package/es6/components/SelectMultiple/stories/LongList.js +63 -0
  88. package/es6/components/SelectMultiple/stories/ObjectOptions.js +64 -0
  89. package/es6/components/SelectMultiple/stories/ShowSelectedInline.js +61 -0
  90. package/es6/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
  91. package/es6/components/index.d.ts +1 -0
  92. package/es6/components/index.js +1 -0
  93. package/es6/index.d.ts +1 -0
  94. package/es6/themes/base.d.ts +8 -2
  95. package/es6/themes/base.js +54 -38
  96. package/es6/themes/grommet.js +15 -0
  97. package/es6/utils/DOM.js +4 -0
  98. package/es6/utils/background.js +65 -12
  99. package/es6/utils/general-prop-types.js +2 -0
  100. package/es6/utils/index.d.ts +2 -0
  101. package/grommet.min.js +1 -1
  102. package/grommet.min.js.map +1 -1
  103. package/index.d.ts +1 -0
  104. package/package.json +7 -6
  105. package/themes/base.d.ts +8 -2
  106. package/themes/base.js +55 -38
  107. package/themes/grommet.js +15 -0
  108. package/utils/DOM.js +9 -2
  109. package/utils/background.js +64 -12
  110. package/utils/general-prop-types.js +2 -0
  111. package/utils/index.d.ts +2 -0
package/index.d.ts CHANGED
@@ -56,6 +56,7 @@ export * from './components/RangeSelector';
56
56
  export * from './components/RoutedAnchor';
57
57
  export * from './components/RoutedButton';
58
58
  export * from './components/Select';
59
+ export * from './components/SelectMultiple';
59
60
  export * from './components/Sidebar';
60
61
  export * from './components/SkipLink';
61
62
  export * from './components/SkipLinks';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grommet",
3
- "version": "2.25.2",
3
+ "version": "2.26.0",
4
4
  "main": "index.js",
5
5
  "module": "es6/index.js",
6
6
  "jsnext:main": "es6/index.js",
@@ -53,12 +53,10 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@testing-library/testcafe": "^4.4.1",
56
- "grommet-icons": "^4.7.0",
56
+ "grommet-icons": "^4.8.0",
57
57
  "hoist-non-react-statics": "^3.2.0",
58
58
  "markdown-to-jsx": "^7.1.5",
59
- "prop-types": "^15.8.1",
60
- "testcafe": "^1.20.1",
61
- "testcafe-react-selectors": "^5.0.2"
59
+ "prop-types": "^15.8.1"
62
60
  },
63
61
  "devDependencies": {
64
62
  "@babel/cli": "^7.18.9",
@@ -83,6 +81,7 @@
83
81
  "@testing-library/dom": "8.14.0",
84
82
  "@testing-library/jest-dom": "^5.16.4",
85
83
  "@testing-library/react": "^13.3.0",
84
+ "@testing-library/testcafe": "^4.4.1",
86
85
  "@testing-library/user-event": "14.2.1",
87
86
  "@types/jest": "^28.1.6",
88
87
  "@types/jest-axe": "^3.5.4",
@@ -138,6 +137,8 @@
138
137
  "simple-git": "^3.10.0",
139
138
  "styled-components": "^5.3.5",
140
139
  "tarball-extract": "^0.0.6",
140
+ "testcafe": "^2.0.0",
141
+ "testcafe-react-selectors": "^5.0.2",
141
142
  "ts-jest": "^28.0.7",
142
143
  "ts-loader": "^8.4.0",
143
144
  "typescript": "^4.7.4",
@@ -202,7 +203,7 @@
202
203
  "bundlesize": [
203
204
  {
204
205
  "path": "./dist/grommet.min.js",
205
- "maxSize": "134 kB"
206
+ "maxSize": "140 kB"
206
207
  }
207
208
  ],
208
209
  "keywords": [
package/themes/base.d.ts CHANGED
@@ -278,6 +278,9 @@ export interface ThemeType {
278
278
  duration?: string;
279
279
  };
280
280
  };
281
+ backgrounds?: {
282
+ [x: string]: BackgroundType | { dark?: string; light?: string };
283
+ };
281
284
  borderSize?: {
282
285
  xsmall?: string;
283
286
  small?: string;
@@ -782,8 +785,8 @@ export interface ThemeType {
782
785
  margin?: MarginType;
783
786
  pad?: PadType;
784
787
  };
785
- checkBox: {
786
- pad: PadType;
788
+ checkBox?: {
789
+ pad?: PadType;
787
790
  };
788
791
  disabled?: {
789
792
  background?: BackgroundType;
@@ -1395,6 +1398,9 @@ export interface ThemeType {
1395
1398
  searchInput?: ReactComponentElement<any>;
1396
1399
  step?: number;
1397
1400
  };
1401
+ selectMultiple?: {
1402
+ maxInline?: number;
1403
+ };
1398
1404
  skipLinks?: {
1399
1405
  position?: LayerPositionType;
1400
1406
  container?: BoxProps;
package/themes/base.js CHANGED
@@ -29,6 +29,8 @@ var _Pause = require("grommet-icons/icons/Pause");
29
29
 
30
30
  var _Play = require("grommet-icons/icons/Play");
31
31
 
32
+ var _FormPin = require("grommet-icons/icons/FormPin");
33
+
32
34
  var _Previous = require("grommet-icons/icons/Previous");
33
35
 
34
36
  var _StatusCriticalSmall = require("grommet-icons/icons/StatusCriticalSmall");
@@ -184,6 +186,7 @@ var generate = function generate(baseSpacing, scale) {
184
186
  duration: '0.1s'
185
187
  }
186
188
  },
189
+ // backgrounds: undefined,
187
190
  borderSize: {
188
191
  xsmall: '1px',
189
192
  small: '2px',
@@ -1163,6 +1166,13 @@ var generate = function generate(baseSpacing, scale) {
1163
1166
  color: 'status-disabled',
1164
1167
  cursor: 'default'
1165
1168
  },
1169
+ pinned: {
1170
+ background: 'background-contrast',
1171
+ icon: {
1172
+ size: 'medium',
1173
+ pad: 'small'
1174
+ }
1175
+ },
1166
1176
  pad: {
1167
1177
  horizontal: 'medium',
1168
1178
  vertical: 'small'
@@ -1171,7 +1181,8 @@ var generate = function generate(baseSpacing, scale) {
1171
1181
  },
1172
1182
  icons: {
1173
1183
  down: _FormDown.FormDown,
1174
- up: _FormUp.FormUp
1184
+ up: _FormUp.FormUp,
1185
+ pin: _FormPin.FormPin
1175
1186
  } // extend: undefined,
1176
1187
 
1177
1188
  },
@@ -1257,6 +1268,7 @@ var generate = function generate(baseSpacing, scale) {
1257
1268
  direction: 'column',
1258
1269
  container: {
1259
1270
  // any box props
1271
+ round: 'xsmall',
1260
1272
  pad: {
1261
1273
  horizontal: 'small',
1262
1274
  vertical: 'xsmall'
@@ -1269,6 +1281,7 @@ var generate = function generate(baseSpacing, scale) {
1269
1281
  direction: 'row',
1270
1282
  container: {
1271
1283
  // any box props
1284
+ round: 'none',
1272
1285
  pad: {
1273
1286
  horizontal: 'large',
1274
1287
  vertical: 'xsmall'
@@ -1280,7 +1293,6 @@ var generate = function generate(baseSpacing, scale) {
1280
1293
  container: {
1281
1294
  // any box props
1282
1295
  elevation: 'medium',
1283
- round: 'xsmall',
1284
1296
  width: 'medium'
1285
1297
  },
1286
1298
  layer: {
@@ -1313,58 +1325,60 @@ var generate = function generate(baseSpacing, scale) {
1313
1325
  },
1314
1326
  critical: {
1315
1327
  icon: _StatusCriticalSmall.StatusCriticalSmall,
1316
- // background: undefined,
1328
+ background: {
1329
+ color: 'status-critical',
1330
+ opacity: 'weak'
1331
+ },
1317
1332
  color: 'status-critical',
1318
- global: {
1319
- background: {
1320
- color: 'status-critical',
1321
- opacity: 'weak'
1322
- }
1323
- } // toast: {},
1324
-
1333
+ // global: {},
1334
+ toast: {
1335
+ background: 'background-front'
1336
+ }
1325
1337
  },
1326
1338
  warning: {
1327
1339
  icon: _StatusWarningSmall.StatusWarningSmall,
1328
- // background: undefined,
1340
+ background: {
1341
+ color: 'status-warning',
1342
+ opacity: 'weak'
1343
+ },
1329
1344
  color: 'status-warning',
1330
- global: {
1331
- background: {
1332
- color: 'status-warning',
1333
- opacity: 'weak'
1334
- }
1335
- } // toast: {},
1336
-
1345
+ // global: {},
1346
+ toast: {
1347
+ background: 'background-front'
1348
+ }
1337
1349
  },
1338
1350
  normal: {
1339
1351
  icon: _StatusGoodSmall.StatusGoodSmall,
1340
- // background: undefined,
1352
+ background: {
1353
+ color: 'status-ok',
1354
+ opacity: 'weak'
1355
+ },
1341
1356
  color: 'status-ok',
1342
- global: {
1343
- background: {
1344
- color: 'status-ok',
1345
- opacity: 'weak'
1346
- }
1347
- } // toast: {},
1348
-
1357
+ // global: {},
1358
+ toast: {
1359
+ background: 'background-front'
1360
+ }
1349
1361
  },
1350
1362
  info: {
1351
1363
  icon: _CircleInformation.CircleInformation,
1352
- // background: undefined,
1353
- color: 'text-strong' // global: {},
1354
- // toast: {},
1355
-
1364
+ background: 'background-contrast',
1365
+ color: 'text-strong',
1366
+ // global: {},
1367
+ toast: {
1368
+ background: 'background-front'
1369
+ }
1356
1370
  },
1357
1371
  unknown: {
1358
1372
  icon: _StatusUnknownSmall.StatusUnknownSmall,
1359
- // background: undefined,
1373
+ background: {
1374
+ color: 'status-unknown',
1375
+ opacity: 'weak'
1376
+ },
1360
1377
  color: 'status-unknown',
1361
- global: {
1362
- background: {
1363
- color: 'status-unknown',
1364
- opacity: 'weak'
1365
- }
1366
- } // toast: {},
1367
-
1378
+ // global: {},
1379
+ toast: {
1380
+ background: 'background-front'
1381
+ }
1368
1382
  },
1369
1383
  // deprecate "undefined" in v3
1370
1384
  // and if undefined, no icon
@@ -1761,6 +1775,9 @@ var generate = function generate(baseSpacing, scale) {
1761
1775
  // searchInput: undefined,
1762
1776
  step: 20
1763
1777
  },
1778
+ selectMultiple: {
1779
+ maxInline: 5
1780
+ },
1764
1781
  skipLinks: {
1765
1782
  position: 'top',
1766
1783
  container: {
package/themes/grommet.js CHANGED
@@ -15,6 +15,21 @@ var grommet = (0, _object.deepFreeze)({
15
15
  dark: '#000000'
16
16
  }
17
17
  },
18
+ backgrounds: {
19
+ stack: {
20
+ color: 'light-1',
21
+ image: "url(https://v2.grommet.io/img/stak-hurrah.svg)"
22
+ },
23
+ 'gradient-purple-blue': {
24
+ color: 'neutral-3',
25
+ image: "linear-gradient(\n #3D138D 0%, /* neutral-2 */\n #00739D 100% /* neutral-3 */\n );",
26
+ rotate: 145
27
+ },
28
+ 'gradient-purple-gold': {
29
+ color: 'neutral-2',
30
+ image: "linear-gradient(\n #3D138D 0%, /* neutral-2 */\n #EB0F79 75%,\n #FFCA58 100% /* accent-4 */\n );"
31
+ }
32
+ },
18
33
  font: {
19
34
  family: "-apple-system,\n BlinkMacSystemFont, \n \"Segoe UI\", \n Roboto, \n Oxygen, \n Ubuntu, \n Cantarell, \n \"Fira Sans\", \n \"Droid Sans\", \n \"Helvetica Neue\", \n Arial, sans-serif, \n \"Apple Color Emoji\", \n \"Segoe UI Emoji\", \n \"Segoe UI Symbol\""
20
35
  }
package/utils/DOM.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.shouldKeepFocus = exports.setFocusWithoutScroll = exports.makeNodeUnfocusable = exports.makeNodeFocusable = exports.isNodeBeforeScroll = exports.isNodeAfterScroll = exports.isFocusable = exports.getNewContainer = exports.getFirstFocusableDescendant = exports.findVisibleParent = exports.findScrollParents = exports.findScrollParent = exports.containsFocus = void 0;
4
+ exports.shouldKeepFocus = exports.setFocusWithoutScroll = exports.makeNodeUnfocusable = exports.makeNodeFocusable = exports.isNodeBeforeScroll = exports.isNodeAfterScroll = exports.isFocusable = exports.getNewContainer = exports.getFirstFocusableDescendant = exports.findVisibleParent = exports.findScrollParents = exports.findScrollParent = exports.findButtonParent = exports.containsFocus = void 0;
5
5
 
6
6
  var findScrollParent = function findScrollParent(element, horizontal) {
7
7
  var result;
@@ -242,4 +242,11 @@ var isNodeBeforeScroll = function isNodeBeforeScroll(node, target) {
242
242
  return top <= targetTop;
243
243
  };
244
244
 
245
- exports.isNodeBeforeScroll = isNodeBeforeScroll;
245
+ exports.isNodeBeforeScroll = isNodeBeforeScroll;
246
+
247
+ var findButtonParent = function findButtonParent(element) {
248
+ if (element && element.nodeName !== 'BUTTON' && element.nodeName !== 'A') return findButtonParent(element.parentElement);
249
+ return element;
250
+ };
251
+
252
+ exports.findButtonParent = findButtonParent;
@@ -18,9 +18,11 @@ var evalStyle = function evalStyle(arg, theme) {
18
18
  return arg;
19
19
  };
20
20
 
21
- var normalizeBackground = function normalizeBackground(background, theme) {
22
- // If the background has a light or dark object, use that
23
- var result = background;
21
+ var normalizeBackground = function normalizeBackground(backgroundArg, theme) {
22
+ var _theme$global$backgro;
23
+
24
+ var background = ((_theme$global$backgro = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro[backgroundArg]) || backgroundArg;
25
+ var result = background; // If the background has a light or dark object, use that
24
26
 
25
27
  if (background) {
26
28
  if (theme.dark && background.dark && typeof background.dark !== 'boolean') {
@@ -37,6 +39,49 @@ var normalizeBackground = function normalizeBackground(background, theme) {
37
39
 
38
40
  exports.normalizeBackground = normalizeBackground;
39
41
 
42
+ var normalizeBackgroundColor = function normalizeBackgroundColor(backgroundArg, theme) {
43
+ var _theme$global$backgro2;
44
+
45
+ var background = backgroundArg.color || backgroundArg;
46
+ var result = (0, _colors.normalizeColor)( // Background color may be defined by theme.global.backgrounds or
47
+ // theme.global.colors.
48
+ ((_theme$global$backgro2 = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro2[background]) || background, theme, backgroundArg.dark);
49
+ return result;
50
+ };
51
+
52
+ var normalizeBackgroundImage = function normalizeBackgroundImage(background, theme) {
53
+ var result;
54
+
55
+ if (background.image) {
56
+ var _theme$global$backgro3, _theme$global$backgro4;
57
+
58
+ result = normalizeBackground(background.dark ? (_theme$global$backgro3 = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro3[background.image].dark : (_theme$global$backgro4 = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro4[background.image], theme) || background.image;
59
+ } else {
60
+ var _theme$global$backgro5;
61
+
62
+ var normalized = normalizeBackground((_theme$global$backgro5 = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro5[background], theme);
63
+ result = typeof normalized === 'object' ? normalizeBackgroundImage(normalized, theme) : normalized;
64
+ }
65
+
66
+ return result;
67
+ };
68
+
69
+ var rotateBackground = function rotateBackground(background, theme) {
70
+ var backgroundImage = normalizeBackgroundImage(background, theme);
71
+ var result = backgroundImage;
72
+
73
+ if (backgroundImage.lastIndexOf('linear-gradient', 0) === 0) {
74
+ var regex = /\d{1,}deg\b,/gm; // Contains rotation specified in degrees. Only targets 'deg' string with a trailing comma. Do not match 'deg' string for hsl, etc..
75
+
76
+ result = backgroundImage.lastIndexOf('deg,') >= 0 ? backgroundImage.replace(regex, background.rotate + "deg,") : backgroundImage.replace('linear-gradient(', "linear-gradient(" + background.rotate + "deg, ");
77
+ } else {
78
+ console.warn( // eslint-disable-next-line max-len
79
+ "'background.rotate' property only supports 'background.image' containing a linear-gradient string.");
80
+ }
81
+
82
+ return result;
83
+ };
84
+
40
85
  var backgroundIsDark = function backgroundIsDark(backgroundArg, theme) {
41
86
  var background = normalizeBackground(backgroundArg, theme);
42
87
  var result;
@@ -96,7 +141,7 @@ var backgroundAndTextColors = function backgroundAndTextColors(backgroundArg, te
96
141
  }
97
142
 
98
143
  if (background.color) {
99
- var color = (0, _colors.normalizeColor)(background.color, theme, background.dark);
144
+ var color = normalizeBackgroundColor(background, theme);
100
145
  var opacity = background.opacity === true ? global.opacity.medium : global.opacity[background.opacity] || background.opacity;
101
146
  backgroundColor = (0, _colors.getRGBA)(color, opacity) || color; // If we don't have a textColor already, and we aren't too translucent,
102
147
  // set the textColor to have the best contrast against the background
@@ -108,7 +153,7 @@ var backgroundAndTextColors = function backgroundAndTextColors(backgroundArg, te
108
153
  }
109
154
  }
110
155
  } else {
111
- backgroundColor = (0, _colors.normalizeColor)(background, theme);
156
+ backgroundColor = normalizeBackgroundColor(background, theme);
112
157
 
113
158
  var _shade = darkContext(backgroundColor, theme);
114
159
 
@@ -134,21 +179,28 @@ var backgroundStyle = function backgroundStyle(backgroundArg, theme, textColorAr
134
179
  if (backgroundArg === undefined) return undefined;
135
180
  var background = normalizeBackground(backgroundArg, theme);
136
181
 
137
- if (typeof background === 'string' && background.lastIndexOf('url', 0) === 0) {
138
- return (0, _styledComponents.css)(["background:", " no-repeat center center;background-size:cover;"], background);
139
- }
140
-
141
182
  var _backgroundAndTextCol = backgroundAndTextColors(background, textColorArg, theme),
142
183
  backgroundColor = _backgroundAndTextCol[0],
143
184
  textColor = _backgroundAndTextCol[1];
144
185
 
145
- if (background.image) {
146
- var backgroundStyles = "\n " + (backgroundColor ? "background-color: " + backgroundColor + ";" : '') + "\n background-image: " + background.image + ";\n background-repeat: " + (background.repeat || 'no-repeat') + ";\n background-position: " + (background.position || 'center center') + ";\n background-size: " + (background.size || 'cover') + ";\n "; // allow both background color and image, in case the image doesn't fill
186
+ var backgroundImage = background.rotate ? rotateBackground(background, theme) : normalizeBackgroundImage(background, theme);
187
+ var backgroundClipStyle = '';
188
+
189
+ if (background.clip) {
190
+ backgroundClipStyle = background.clip === 'text' ? "-webkit-text-fill-color: transparent; \n -webkit-background-clip: text; \n background-clip: text;" : "background-clip: " + background.clip + ";";
191
+ }
192
+
193
+ if (typeof background === 'string' && background.lastIndexOf('url', 0) === 0) {
194
+ return (0, _styledComponents.css)(["background:", " no-repeat center center;background-size:cover;"], background);
195
+ }
196
+
197
+ if (backgroundImage) {
198
+ var backgroundStyles = "\n " + (backgroundColor ? "background-color: " + backgroundColor + ";" : '') + "\n background-image: " + backgroundImage + ";\n background-repeat: " + (typeof background === 'object' && background.repeat || 'no-repeat') + ";\n background-position: " + (background.position || 'center center') + ";\n background-size: " + (background.size || 'cover') + ";\n " + backgroundClipStyle + "\n "; // allow both background color and image, in case the image doesn't fill
147
199
  // when image and opacity are used together, we need to use pseudo :before
148
200
  // to ensure that only image and background color are affected by opacity
149
201
  // but not the container contents
150
202
 
151
- return (0, _styledComponents.css)(["", " ", ""], textColor ? "color: " + textColor + ";" : '', !background.opacity ? backgroundStyles : "position: relative;\n z-index: 0;\n &:before {\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n bottom: 0;\n z-index: -1;\n " + backgroundStyles + "\n opacity: " + (background.opacity === true ? theme.global.opacity.medium : theme.global.opacity[background.opacity] || background.opacity) + ";\n }");
203
+ return (0, _styledComponents.css)(["", " ", ""], textColor ? "color: " + textColor + ";" : '', !background.opacity ? backgroundStyles : "position: relative;\n z-index: 0;\n &:before {\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n bottom: 0;\n z-index: -1;\n border-radius: inherit;\n " + backgroundStyles + "\n opacity: " + (background.opacity === true ? theme.global.opacity.medium : theme.global.opacity[background.opacity] || background.opacity) + ";\n }");
152
204
  }
153
205
 
154
206
  if (backgroundColor) {
@@ -22,12 +22,14 @@ var colorPropType = _propTypes["default"].oneOfType([_propTypes["default"].strin
22
22
  exports.colorPropType = colorPropType;
23
23
 
24
24
  var backgroundPropType = _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].shape({
25
+ clip: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['text']), _propTypes["default"].string]),
25
26
  color: colorPropType,
26
27
  dark: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].string]),
27
28
  image: _propTypes["default"].string,
28
29
  position: _propTypes["default"].string,
29
30
  opacity: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].bool, _propTypes["default"].number, _propTypes["default"].oneOf(['weak', 'medium', 'strong'])]),
30
31
  repeat: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['no-repeat', 'repeat']), _propTypes["default"].string]),
32
+ rotate: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string]),
31
33
  size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['cover', 'contain']), _propTypes["default"].string]),
32
34
  light: _propTypes["default"].string
33
35
  })]);
package/utils/index.d.ts CHANGED
@@ -139,6 +139,8 @@ export interface BackgroundObject {
139
139
  repeat?: 'no-repeat' | 'repeat' | string;
140
140
  size?: 'cover' | 'contain' | string;
141
141
  light?: string;
142
+ clip?: 'text' | string;
143
+ rotate?: number | string;
142
144
  }
143
145
  export type BackgroundType = string | BackgroundObject;
144
146
  export type HoverIndicatorType =