@carbonplan/components 10.4.0 → 10.5.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/dst/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { cloneElement, useCallback, useState, useEffect, useRef } from 'react';
2
- import { Box, Link as Link$1, Grid, IconButton, useColorMode, Container, useThemeUI, Text, Flex, Styled, Input as Input$1, Slider as Slider$1 } from 'theme-ui';
2
+ import { Box, Link as Link$1, Flex, Grid, IconButton, useColorMode, Container, useThemeUI, Text, Styled, Input as Input$1, Slider as Slider$1 } from 'theme-ui';
3
3
  import { transparentize } from '@theme-ui/color';
4
4
  import NextLink from 'next/link';
5
5
  import { Arrow, Sun } from '@carbonplan/icons';
@@ -40,10 +40,12 @@ function _objectWithoutPropertiesLoose(source, excluded) {
40
40
  return target;
41
41
  }
42
42
 
43
+ var _excluded$g = ["sx", "children"];
44
+
43
45
  var Badge = function Badge(_ref) {
44
46
  var sx = _ref.sx,
45
47
  children = _ref.children,
46
- props = _objectWithoutPropertiesLoose(_ref, ["sx", "children"]);
48
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$g);
47
49
 
48
50
  var color = sx && sx.color ? sx.color : 'primary';
49
51
  return /*#__PURE__*/React.createElement(Box, _extends({
@@ -68,6 +70,8 @@ var Badge = function Badge(_ref) {
68
70
  }, children));
69
71
  };
70
72
 
73
+ var _excluded$f = ["href", "children", "internal", "tracking"];
74
+
71
75
  var event = function event(_ref) {
72
76
  var action = _ref.action,
73
77
  category = _ref.category,
@@ -93,7 +97,7 @@ var Link = function Link(_ref2) {
93
97
  internal = _ref2$internal === void 0 ? false : _ref2$internal,
94
98
  _ref2$tracking = _ref2.tracking,
95
99
  tracking = _ref2$tracking === void 0 ? false : _ref2$tracking,
96
- props = _objectWithoutPropertiesLoose(_ref2, ["href", "children", "internal", "tracking"]);
100
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$f);
97
101
 
98
102
  if (internal || href && href.startsWith('/')) {
99
103
  return /*#__PURE__*/React.createElement(NextLink, {
@@ -182,6 +186,8 @@ var getSizeStyles = function getSizeStyles(size) {
182
186
  };
183
187
  };
184
188
 
189
+ var _excluded$e = ["size", "prefix", "suffix", "inverted", "sx", "children", "align", "href", "internal", "tracking"];
190
+
185
191
  var Button = function Button(_ref) {
186
192
  var _ref$size = _ref.size,
187
193
  size = _ref$size === void 0 ? 'sm' : _ref$size,
@@ -194,7 +200,7 @@ var Button = function Button(_ref) {
194
200
  href = _ref.href,
195
201
  internal = _ref.internal,
196
202
  tracking = _ref.tracking,
197
- props = _objectWithoutPropertiesLoose(_ref, ["size", "prefix", "suffix", "inverted", "sx", "children", "align", "href", "internal", "tracking"]);
203
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$e);
198
204
 
199
205
  if (!['xs', 'sm', 'md', 'lg', 'xl'].includes(size)) {
200
206
  throw new Error('Size must be xs, sm, md, lg, or xl');
@@ -368,6 +374,8 @@ var Button = function Button(_ref) {
368
374
  }
369
375
  };
370
376
 
377
+ var _excluded$d = ["label", "children", "inverted", "color", "href", "internal", "tracking", "sx"];
378
+
371
379
  var Callout = function Callout(_ref) {
372
380
  var label = _ref.label,
373
381
  children = _ref.children,
@@ -377,7 +385,7 @@ var Callout = function Callout(_ref) {
377
385
  internal = _ref.internal,
378
386
  tracking = _ref.tracking,
379
387
  sx = _ref.sx,
380
- props = _objectWithoutPropertiesLoose(_ref, ["label", "children", "inverted", "color", "href", "internal", "tracking", "sx"]);
388
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
381
389
 
382
390
  var baseColor = color || (inverted ? 'secondary' : 'primary');
383
391
  var hoverColor = color ? 'primary' : inverted ? 'primary' : 'secondary';
@@ -456,6 +464,148 @@ var Callout = function Callout(_ref) {
456
464
  }
457
465
  };
458
466
 
467
+ var _excluded$c = ["colormap", "label", "clim", "discrete", "units", "width", "height", "format", "horizontal"];
468
+ var sx$2 = {
469
+ clim: {
470
+ fontFamily: 'mono',
471
+ fontSize: ['9px', 0, 0, 1],
472
+ letterSpacing: 'smallcaps',
473
+ textTransform: 'uppercase'
474
+ }
475
+ };
476
+ var DIMENSIONS = {
477
+ width: ['10px', '16px', '16px', '17px'],
478
+ height: ['80px', '110px', '110px', '130px']
479
+ };
480
+
481
+ var Gradient = function Gradient(_ref) {
482
+ var colormap = _ref.colormap,
483
+ discrete = _ref.discrete,
484
+ horizontal = _ref.horizontal,
485
+ width = _ref.width,
486
+ height = _ref.height;
487
+ var step = 1 / colormap.length * 100;
488
+ var values = colormap.map(function (d, i) {
489
+ return "rgb(" + d + ") " + i * step + "% " + (discrete && i < colormap.length - 1 ? (i + 1) * step + "%" : '');
490
+ });
491
+ var css = "linear-gradient(to " + (horizontal ? 'right' : 'top') + ", " + values.join(',') + ")";
492
+ return /*#__PURE__*/React.createElement(Box, {
493
+ sx: _extends({}, horizontal ? {
494
+ width: width || DIMENSIONS.height,
495
+ height: height || DIMENSIONS.width
496
+ } : {
497
+ width: width || DIMENSIONS.width,
498
+ minHeight: height || DIMENSIONS.height
499
+ }, {
500
+ mt: horizontal ? [0, '1px', '1px', 0] : 0,
501
+ border: function border(_ref2) {
502
+ var colors = _ref2.colors;
503
+ return "solid 1px " + colors.hinted;
504
+ },
505
+ background: css
506
+ })
507
+ });
508
+ };
509
+
510
+ var Label = function Label(_ref3) {
511
+ var label = _ref3.label,
512
+ units = _ref3.units,
513
+ horizontal = _ref3.horizontal;
514
+ return /*#__PURE__*/React.createElement(Box, {
515
+ sx: !horizontal && {
516
+ alignSelf: 'flex-end'
517
+ }
518
+ }, /*#__PURE__*/React.createElement(Box, {
519
+ sx: _extends({
520
+ mb: horizontal ? 0 : ['-4px', '-4px', '-4px', '-3px'],
521
+ fontFamily: 'mono',
522
+ fontSize: ['9px', 0, 0, 1],
523
+ letterSpacing: 'smallcaps',
524
+ textTransform: 'uppercase'
525
+ }, horizontal ? {} : {
526
+ writingMode: 'vertical-rl',
527
+ transform: 'rotate(180deg)',
528
+ whiteSpace: 'nowrap',
529
+ display: 'inline-block',
530
+ overflow: 'visible'
531
+ })
532
+ }, label, ' ', /*#__PURE__*/React.createElement(Box, {
533
+ as: "span",
534
+ sx: {
535
+ textTransform: 'none',
536
+ color: 'secondary',
537
+ display: 'inline-block'
538
+ }
539
+ }, units)));
540
+ };
541
+
542
+ var Colorbar = function Colorbar(_ref4) {
543
+ var colormap = _ref4.colormap,
544
+ label = _ref4.label,
545
+ clim = _ref4.clim,
546
+ discrete = _ref4.discrete,
547
+ units = _ref4.units,
548
+ width = _ref4.width,
549
+ height = _ref4.height,
550
+ _ref4$format = _ref4.format,
551
+ format = _ref4$format === void 0 ? function (d) {
552
+ return d;
553
+ } : _ref4$format,
554
+ _ref4$horizontal = _ref4.horizontal,
555
+ horizontal = _ref4$horizontal === void 0 ? false : _ref4$horizontal,
556
+ props = _objectWithoutPropertiesLoose(_ref4, _excluded$c);
557
+
558
+ if (!Array.isArray(colormap)) {
559
+ throw new Error("expected array for colormap, got '" + colormap + "'.");
560
+ }
561
+
562
+ var ClimMin = function ClimMin() {
563
+ return /*#__PURE__*/React.createElement(Box, {
564
+ sx: _extends({}, sx$2.clim, {
565
+ ml: label ? horizontal ? '10px' : '2px' : 0,
566
+ mr: horizontal ? ['2px', '1px', '1px', '2px'] : 0,
567
+ mb: horizontal ? 0 : ['-2px', '-2px', '-2px', '-3px']
568
+ })
569
+ }, format(clim[0]));
570
+ };
571
+
572
+ var ClimMax = function ClimMax() {
573
+ return /*#__PURE__*/React.createElement(Box, {
574
+ sx: _extends({}, sx$2.clim, {
575
+ ml: horizontal ? ['2px', '1px', '1px', '2px'] : '2px',
576
+ mt: horizontal ? 0 : ['-2px', '-3px', '-3px', '-3px']
577
+ })
578
+ }, format(clim[1]));
579
+ };
580
+
581
+ return /*#__PURE__*/React.createElement(Flex, {
582
+ sx: _extends({}, props.sx, {
583
+ flexDirection: 'row',
584
+ alignItems: 'center',
585
+ justifyContent: 'flex-start',
586
+ gap: ['3px', '6px', '6px', '7px']
587
+ })
588
+ }, label && /*#__PURE__*/React.createElement(Label, {
589
+ label: label,
590
+ units: units,
591
+ horizontal: horizontal
592
+ }), horizontal && clim && /*#__PURE__*/React.createElement(ClimMin, null), /*#__PURE__*/React.createElement(Gradient, {
593
+ colormap: colormap,
594
+ horizontal: horizontal,
595
+ discrete: discrete,
596
+ width: width,
597
+ height: height
598
+ }), horizontal && clim && /*#__PURE__*/React.createElement(ClimMax, null), !horizontal && /*#__PURE__*/React.createElement(Flex, {
599
+ sx: {
600
+ flexDirection: 'column-reverse',
601
+ justifyContent: 'space-between',
602
+ height: height || DIMENSIONS.height
603
+ }
604
+ }, clim && /*#__PURE__*/React.createElement(ClimMin, null), clim && /*#__PURE__*/React.createElement(ClimMax, null)));
605
+ };
606
+
607
+ var _excluded$b = ["start", "width", "dl", "dr", "children", "sx"];
608
+
459
609
  var Column = function Column(_ref) {
460
610
  var start = _ref.start,
461
611
  width = _ref.width,
@@ -463,7 +613,7 @@ var Column = function Column(_ref) {
463
613
  dr = _ref.dr,
464
614
  children = _ref.children,
465
615
  sx = _ref.sx,
466
- props = _objectWithoutPropertiesLoose(_ref, ["start", "width", "dl", "dr", "children", "sx"]);
616
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$b);
467
617
 
468
618
  start = start || 'auto';
469
619
  width = width || 'auto';
@@ -670,12 +820,14 @@ var Logo = function Logo(_ref) {
670
820
  })));
671
821
  };
672
822
 
823
+ var _excluded$a = ["children", "sx", "columns", "gap"];
824
+
673
825
  var Row = function Row(_ref) {
674
826
  var children = _ref.children,
675
827
  sx = _ref.sx,
676
828
  columns = _ref.columns,
677
829
  gap = _ref.gap,
678
- props = _objectWithoutPropertiesLoose(_ref, ["children", "sx", "columns", "gap"]);
830
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$a);
679
831
 
680
832
  var makeArray = function makeArray(input) {
681
833
  if (!Array.isArray(input)) {
@@ -727,10 +879,12 @@ var Row = function Row(_ref) {
727
879
  }), children);
728
880
  };
729
881
 
882
+ var _excluded$9 = ["value", "sx"];
883
+
730
884
  var Menu = function Menu(_ref) {
731
885
  var value = _ref.value,
732
886
  sx = _ref.sx,
733
- props = _objectWithoutPropertiesLoose(_ref, ["value", "sx"]);
887
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
734
888
 
735
889
  return /*#__PURE__*/React.createElement(IconButton, _extends({
736
890
  sx: _extends({
@@ -818,10 +972,12 @@ var Menu = function Menu(_ref) {
818
972
  })));
819
973
  };
820
974
 
975
+ var _excluded$8 = ["value", "sx"];
976
+
821
977
  var Settings = function Settings(_ref) {
822
978
  var value = _ref.value,
823
979
  sx = _ref.sx,
824
- props = _objectWithoutPropertiesLoose(_ref, ["value", "sx"]);
980
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
825
981
 
826
982
  return /*#__PURE__*/React.createElement(IconButton, _extends({
827
983
  sx: _extends({
@@ -922,9 +1078,11 @@ var Settings = function Settings(_ref) {
922
1078
  })));
923
1079
  };
924
1080
 
1081
+ var _excluded$7 = ["sx"];
1082
+
925
1083
  var Dimmer = function Dimmer(_ref) {
926
1084
  var sx = _ref.sx,
927
- props = _objectWithoutPropertiesLoose(_ref, ["sx"]);
1085
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
928
1086
 
929
1087
  var _useColorMode = useColorMode(),
930
1088
  colorMode = _useColorMode[0],
@@ -957,7 +1115,7 @@ var Dimmer = function Dimmer(_ref) {
957
1115
  }));
958
1116
  };
959
1117
 
960
- var sx = {
1118
+ var sx$1 = {
961
1119
  link: function link(current, label, first) {
962
1120
  if (first === void 0) {
963
1121
  first = false;
@@ -1040,12 +1198,12 @@ var Nav = function Nav(_ref) {
1040
1198
  onClick: function onClick() {
1041
1199
  if (nav === url) setExpanded(false);
1042
1200
  },
1043
- sx: sx.link(nav, url, first)
1201
+ sx: sx$1.link(nav, url, first)
1044
1202
  }, /*#__PURE__*/React.createElement(HoverArrow, null), display));
1045
1203
  } else {
1046
1204
  return /*#__PURE__*/React.createElement(Link$1, {
1047
1205
  href: href,
1048
- sx: sx.link(nav, url, first)
1206
+ sx: sx$1.link(nav, url, first)
1049
1207
  }, /*#__PURE__*/React.createElement(HoverArrow, null), display);
1050
1208
  }
1051
1209
  };
@@ -1535,6 +1693,7 @@ function scrollFraction(window, documnt) {
1535
1693
  return Math.min(window.scrollY / (document.body.offsetHeight - 770), 0.99);
1536
1694
  }
1537
1695
 
1696
+ var _excluded$6 = ["duration", "delay", "children"];
1538
1697
  var fade = keyframes({
1539
1698
  from: {
1540
1699
  opacity: 0
@@ -1550,7 +1709,7 @@ var FadeIn = function FadeIn(_ref) {
1550
1709
  _ref$delay = _ref.delay,
1551
1710
  delay = _ref$delay === void 0 ? 0 : _ref$delay,
1552
1711
  children = _ref.children,
1553
- delegated = _objectWithoutPropertiesLoose(_ref, ["duration", "delay", "children"]);
1712
+ delegated = _objectWithoutPropertiesLoose(_ref, _excluded$6);
1554
1713
 
1555
1714
  return /*#__PURE__*/React.createElement(Box, _extends({}, delegated, {
1556
1715
  sx: {
@@ -1872,12 +2031,14 @@ var Expander = function Expander(_ref) {
1872
2031
  })));
1873
2032
  };
1874
2033
 
2034
+ var _excluded$5 = ["label", "value", "sx", "children"];
2035
+
1875
2036
  var Tag = function Tag(_ref) {
1876
2037
  var label = _ref.label,
1877
2038
  value = _ref.value,
1878
2039
  sx = _ref.sx,
1879
2040
  children = _ref.children,
1880
- props = _objectWithoutPropertiesLoose(_ref, ["label", "value", "sx", "children"]);
2041
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
1881
2042
 
1882
2043
  var color = sx && sx.color ? sx.color : 'primary';
1883
2044
  var isClickable = props && (props.onClick || props.onDoubleClick);
@@ -1911,7 +2072,8 @@ var Tag = function Tag(_ref) {
1911
2072
  }, props), children);
1912
2073
  };
1913
2074
 
1914
- var sx$1 = {
2075
+ var _excluded$4 = ["values", "setValues", "label", "colors", "showAll", "multiSelect"];
2076
+ var sx = {
1915
2077
  label: {
1916
2078
  fontFamily: 'mono',
1917
2079
  letterSpacing: 'mono',
@@ -1988,10 +2150,10 @@ var Filter = function Filter(_ref2) {
1988
2150
  showAll = _ref2$showAll === void 0 ? false : _ref2$showAll,
1989
2151
  _ref2$multiSelect = _ref2.multiSelect,
1990
2152
  multiSelect = _ref2$multiSelect === void 0 ? false : _ref2$multiSelect,
1991
- props = _objectWithoutPropertiesLoose(_ref2, ["values", "setValues", "label", "colors", "showAll", "multiSelect"]);
2153
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$4);
1992
2154
 
1993
2155
  return /*#__PURE__*/React.createElement(Box, props, label && /*#__PURE__*/React.createElement(Box, {
1994
- sx: sx$1.label
2156
+ sx: sx.label
1995
2157
  }, label), /*#__PURE__*/React.createElement(Box, {
1996
2158
  sx: {
1997
2159
  mt: label ? [3] : 0
@@ -2086,6 +2248,8 @@ var Group = function Group(_ref) {
2086
2248
  }));
2087
2249
  };
2088
2250
 
2251
+ var _excluded$3 = ["size", "inverted", "sx"];
2252
+
2089
2253
  var Input = function Input(_ref) {
2090
2254
  var _extends2;
2091
2255
 
@@ -2093,7 +2257,7 @@ var Input = function Input(_ref) {
2093
2257
  size = _ref$size === void 0 ? 'sm' : _ref$size,
2094
2258
  inverted = _ref.inverted,
2095
2259
  sx = _ref.sx,
2096
- props = _objectWithoutPropertiesLoose(_ref, ["size", "inverted", "sx"]);
2260
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
2097
2261
 
2098
2262
  var defaultColor = inverted ? 'secondary' : 'primary';
2099
2263
 
@@ -2135,6 +2299,8 @@ var getProps = function getProps(test) {
2135
2299
  };
2136
2300
  };
2137
2301
 
2302
+ var _excluded$2 = ["children", "size", "sx"];
2303
+
2138
2304
  var Select = function Select(_ref) {
2139
2305
  var _extends2;
2140
2306
 
@@ -2142,7 +2308,7 @@ var Select = function Select(_ref) {
2142
2308
  _ref$size = _ref.size,
2143
2309
  size = _ref$size === void 0 ? 'sm' : _ref$size,
2144
2310
  sx = _ref.sx,
2145
- props = _objectWithoutPropertiesLoose(_ref, ["children", "size", "sx"]);
2311
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
2146
2312
 
2147
2313
  var color = sx && sx.color ? sx.color : 'primary';
2148
2314
  var sizeStyles = getSizeStyles(size);
@@ -2228,9 +2394,11 @@ var Select = function Select(_ref) {
2228
2394
  }));
2229
2395
  };
2230
2396
 
2397
+ var _excluded$1 = ["sx"];
2398
+
2231
2399
  var Slider = function Slider(_ref) {
2232
2400
  var sx = _ref.sx,
2233
- props = _objectWithoutPropertiesLoose(_ref, ["sx"]);
2401
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
2234
2402
 
2235
2403
  var color = sx && sx.color ? sx.color : 'primary';
2236
2404
 
@@ -2372,12 +2540,14 @@ var Table = function Table(_ref) {
2372
2540
  })));
2373
2541
  };
2374
2542
 
2543
+ var _excluded = ["value", "onClick", "disabled", "sx"];
2544
+
2375
2545
  var Toggle = function Toggle(_ref) {
2376
2546
  var value = _ref.value,
2377
2547
  onClick = _ref.onClick,
2378
2548
  disabled = _ref.disabled,
2379
2549
  sx = _ref.sx,
2380
- props = _objectWithoutPropertiesLoose(_ref, ["value", "onClick", "disabled", "sx"]);
2550
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
2381
2551
 
2382
2552
  var color = sx && sx.color ? sx.color : 'primary';
2383
2553
  value = disabled ? false : value;
@@ -2517,5 +2687,5 @@ var formatDate = function formatDate(date, options) {
2517
2687
  return [month, day, year].filter(Boolean).join(' ');
2518
2688
  };
2519
2689
 
2520
- export { Badge, Button, Callout, Column, Custom404, Dimmer, Expander, FadeIn, Filter, Footer, Group, Guide, Header, Input, Layout, Link, Logo, Menu, Meta, Monogram, Row, Scrollbar, Select, Settings, Slider, Table, Tag, Toggle, Tracking, Tray, formatDate, getScrollbarWidth };
2690
+ export { Badge, Button, Callout, Colorbar, Column, Custom404, Dimmer, Expander, FadeIn, Filter, Footer, Group, Guide, Header, Input, Layout, Link, Logo, Menu, Meta, Monogram, Row, Scrollbar, Select, Settings, Slider, Table, Tag, Toggle, Tracking, Tray, formatDate, getScrollbarWidth };
2521
2691
  //# sourceMappingURL=index.esm.js.map