@thecb/components 5.6.5 → 5.6.9

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.
@@ -0,0 +1,81 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('styled-components')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', 'styled-components'], factory) :
4
+ (global = global || self, factory(global['cb-components'] = {}, global.React, global.styled));
5
+ }(this, (function (exports, React, styled) { 'use strict';
6
+
7
+ React = React && Object.prototype.hasOwnProperty.call(React, 'default') ? React['default'] : React;
8
+ styled = styled && Object.prototype.hasOwnProperty.call(styled, 'default') ? styled['default'] : styled;
9
+
10
+ function _taggedTemplateLiteral(strings, raw) {
11
+ if (!raw) {
12
+ raw = strings.slice(0);
13
+ }
14
+
15
+ return Object.freeze(Object.defineProperties(strings, {
16
+ raw: {
17
+ value: Object.freeze(raw)
18
+ }
19
+ }));
20
+ }
21
+
22
+ /*
23
+ Need to add a new color? Visit http://chir.ag/projects/name-that-color to generate a color name.
24
+
25
+ Name already taken? If you can't use the existing color, then use thesaurus.com to pick a similar name
26
+ to the one generated by name-that-color.
27
+ */
28
+ var PEWTER_GREY = "#DFE1E4";
29
+ var MARINER_BLUE = "#2E75D2";
30
+
31
+ function _templateObject2() {
32
+ var data = _taggedTemplateLiteral(["\n height: 16px;\n width: 16px;\n background-color: ", ";\n border-radius: 8px;\n"]);
33
+
34
+ _templateObject2 = function _templateObject2() {
35
+ return data;
36
+ };
37
+
38
+ return data;
39
+ }
40
+
41
+ function _templateObject() {
42
+ var data = _taggedTemplateLiteral(["\n height: 24px;\n width: 24px;\n border: 1px solid\n ", ";\n border-radius: 12px;\n display: flex;\n justify-content: center;\n align-items: center;\n margin: 10px;\n min-width: 24px;\n min-height: 24px;\n"]);
43
+
44
+ _templateObject = function _templateObject() {
45
+ return data;
46
+ };
47
+
48
+ return data;
49
+ }
50
+ var defaultTheme = {
51
+ theme: {
52
+ accentColor: MARINER_BLUE,
53
+ inactiveColor: PEWTER_GREY
54
+ }
55
+ };
56
+ var RadioButtonBorder = styled.div(_templateObject(), function (_ref) {
57
+ var isSelected = _ref.isSelected,
58
+ theme = _ref.theme;
59
+ return isSelected ? theme.accentColor : theme.inactiveColor;
60
+ });
61
+ RadioButtonBorder.defaultProps = defaultTheme;
62
+ var RadioButtonCenter = styled.div(_templateObject2(), function (_ref2) {
63
+ var theme = _ref2.theme;
64
+ return theme.accentColor;
65
+ });
66
+ RadioButtonCenter.defaultProps = defaultTheme;
67
+
68
+ var RadioButton = function RadioButton(_ref3) {
69
+ var isSelected = _ref3.isSelected,
70
+ name = _ref3.name;
71
+ return React.createElement(RadioButtonBorder, {
72
+ isSelected: isSelected,
73
+ name: name
74
+ }, isSelected && React.createElement(RadioButtonCenter, null));
75
+ };
76
+
77
+ exports.RadioButton = RadioButton;
78
+
79
+ Object.defineProperty(exports, '__esModule', { value: true });
80
+
81
+ })));
package/dist/index.cjs.js CHANGED
@@ -6115,6 +6115,16 @@ var checkDeniedCards = function checkDeniedCards(name) {
6115
6115
  return "";
6116
6116
  }
6117
6117
  };
6118
+ /*
6119
+ An optional style for layout atoms that positions the atom completely off screen
6120
+ This will *not* be visible or accessible to sighted users
6121
+ Use to contain text content or a11y interactive content (skip links when not visible)
6122
+ that is only for users of assistive technologies (screen readers)
6123
+
6124
+ Currently implemented on the Box atom via the srOnly prop
6125
+ */
6126
+
6127
+ var screenReaderOnlyStyle = "\n position: absolute;\n left: -10000px;\n top: auto;\n width: 1px;\n height: 1px;\n overflow: hidden;\n";
6118
6128
 
6119
6129
  var general = /*#__PURE__*/Object.freeze({
6120
6130
  __proto__: null,
@@ -6126,7 +6136,8 @@ var general = /*#__PURE__*/Object.freeze({
6126
6136
  generateClickHandler: generateClickHandler,
6127
6137
  checkCardBrand: checkCardBrand,
6128
6138
  displayCardBrand: displayCardBrand,
6129
- checkDeniedCards: checkDeniedCards
6139
+ checkDeniedCards: checkDeniedCards,
6140
+ screenReaderOnlyStyle: screenReaderOnlyStyle
6130
6141
  });
6131
6142
 
6132
6143
  var _excluded$1 = ["themeValues", "weight", "color", "extraStyles", "hoverStyles", "onClick", "onKeyPress", "as", "dataQa", "children"];
@@ -6269,10 +6280,13 @@ var BoxWrapper = styled__default(function (_ref) {
6269
6280
  });
6270
6281
  /* eslint-enable no-unused-vars */
6271
6282
 
6272
- var _excluded$3 = ["padding", "borderSize", "borderColor", "borderRadius", "boxShadow", "background", "color", "minHeight", "width", "minWidth", "maxWidth", "borderWidthOverride", "border", "textAlign", "hoverStyles", "activeStyles", "disabledStyles", "variant", "as", "onClick", "onKeyDown", "onMouseEnter", "onMouseLeave", "onFocus", "onBlur", "onTouchEnd", "theme", "hiddenStyles", "extraStyles", "dataQa", "children"];
6283
+ var _excluded$3 = ["padding", "borderSize", "borderColor", "borderRadius", "boxShadow", "background", "color", "minHeight", "width", "minWidth", "maxWidth", "borderWidthOverride", "border", "textAlign", "hoverStyles", "activeStyles", "disabledStyles", "variant", "as", "onClick", "onKeyDown", "onMouseEnter", "onMouseLeave", "onFocus", "onBlur", "onTouchEnd", "theme", "hiddenStyles", "extraStyles", "srOnly", "dataQa", "children"];
6273
6284
  /*
6274
6285
  Box component to create generic boxes
6275
6286
  Supply padding, border, background, and color values
6287
+
6288
+ srOnly prop enables special screen-reader style that is used to position content
6289
+ completely off screen (only for users of screen readers)
6276
6290
  */
6277
6291
 
6278
6292
  var Box = function Box(_ref) {
@@ -6309,6 +6323,8 @@ var Box = function Box(_ref) {
6309
6323
  theme = _ref.theme,
6310
6324
  hiddenStyles = _ref.hiddenStyles,
6311
6325
  extraStyles = _ref.extraStyles,
6326
+ _ref$srOnly = _ref.srOnly,
6327
+ srOnly = _ref$srOnly === void 0 ? false : _ref$srOnly,
6312
6328
  dataQa = _ref.dataQa,
6313
6329
  children = _ref.children,
6314
6330
  rest = _objectWithoutProperties(_ref, _excluded$3);
@@ -6335,7 +6351,7 @@ var Box = function Box(_ref) {
6335
6351
  onClick: onClick,
6336
6352
  hiddenStyles: hiddenStyles,
6337
6353
  onKeyDown: onKeyDown,
6338
- extraStyles: extraStyles,
6354
+ extraStyles: srOnly ? "".concat(screenReaderOnlyStyle).concat(extraStyles) : extraStyles,
6339
6355
  theme: theme,
6340
6356
  textAlign: textAlign,
6341
6357
  "data-qa": dataQa,
@@ -6401,17 +6417,17 @@ var ClusterWrapper = styled__default(function (_ref) {
6401
6417
  var overflow = _ref2.overflow;
6402
6418
  return overflow ? "visible" : "hidden";
6403
6419
  }, function (_ref3) {
6404
- var justifySelf = _ref3.justifySelf;
6405
- return justifySelf;
6420
+ var $justifySelf = _ref3.$justifySelf;
6421
+ return $justifySelf;
6406
6422
  }, function (_ref4) {
6407
- var alignSelf = _ref4.alignSelf;
6408
- return alignSelf;
6423
+ var $alignSelf = _ref4.$alignSelf;
6424
+ return $alignSelf;
6409
6425
  }, function (_ref5) {
6410
- var flexGrow = _ref5.flexGrow;
6411
- return flexGrow;
6426
+ var $flexGrow = _ref5.$flexGrow;
6427
+ return $flexGrow;
6412
6428
  }, function (_ref6) {
6413
- var extraStyles = _ref6.extraStyles;
6414
- return extraStyles;
6429
+ var $extraStyles = _ref6.$extraStyles;
6430
+ return $extraStyles;
6415
6431
  });
6416
6432
  var ClusterInnerWrapper = styled__default.div.withConfig({
6417
6433
  displayName: "Clusterstyled__ClusterInnerWrapper",
@@ -6468,10 +6484,10 @@ var Cluster = function Cluster(_ref) {
6468
6484
  return /*#__PURE__*/React__default.createElement(ClusterWrapper, _extends({
6469
6485
  overflow: overflow
6470
6486
  }, rest, {
6471
- justifySelf: justifySelf,
6472
- alignSelf: alignSelf,
6473
- flexGrow: flexGrow,
6474
- extraStyles: extraStyles
6487
+ $justifySelf: justifySelf,
6488
+ $alignSelf: alignSelf,
6489
+ $flexGrow: flexGrow,
6490
+ $extraStyles: extraStyles
6475
6491
  }), /*#__PURE__*/React__default.createElement(ClusterInnerWrapper, {
6476
6492
  justify: justify,
6477
6493
  align: align,
@@ -21063,8 +21079,8 @@ var InputField = styled__default.input.withConfig({
21063
21079
  themeValues = _ref.themeValues;
21064
21080
  return field.dirty && field.hasErrors || field.hasErrors && showErrors ? ERROR_COLOR : themeValues.borderColor;
21065
21081
  }, function (_ref2) {
21066
- var customHeight = _ref2.customHeight;
21067
- return customHeight ? customHeight : "48px";
21082
+ var $customHeight = _ref2.$customHeight;
21083
+ return $customHeight ? $customHeight : "48px";
21068
21084
  }, FONT_WEIGHT_REGULAR, function (_ref3) {
21069
21085
  var themeValues = _ref3.themeValues;
21070
21086
  return themeValues.inputBackgroundColor && themeValues.inputBackgroundColor;
@@ -21079,8 +21095,8 @@ var InputField = styled__default.input.withConfig({
21079
21095
  var disabled = _ref6.disabled;
21080
21096
  return disabled && styled.css(["color:#6e727e;background-color:#f7f7f7;"]);
21081
21097
  }, function (_ref7) {
21082
- var extraStyles = _ref7.extraStyles;
21083
- return styled.css(["", ""], extraStyles);
21098
+ var $extraStyles = _ref7.$extraStyles;
21099
+ return styled.css(["", ""], $extraStyles);
21084
21100
  }); // eslint-disable-next-line no-unused-vars
21085
21101
 
21086
21102
  var FormattedInputField = styled__default(function (_ref8) {
@@ -21098,8 +21114,8 @@ var FormattedInputField = styled__default(function (_ref8) {
21098
21114
  themeValues = _ref9.themeValues;
21099
21115
  return field.dirty && field.hasErrors || field.hasErrors && showErrors ? ERROR_COLOR : themeValues.borderColor;
21100
21116
  }, function (_ref10) {
21101
- var customHeight = _ref10.customHeight;
21102
- return customHeight ? customHeight : "48px";
21117
+ var $customHeight = _ref10.$customHeight;
21118
+ return $customHeight ? $customHeight : "48px";
21103
21119
  }, FONT_WEIGHT_REGULAR, function (_ref11) {
21104
21120
  var themeValues = _ref11.themeValues;
21105
21121
  return themeValues.inputBackgroundColor && themeValues.inputBackgroundColor;
@@ -21209,8 +21225,8 @@ var FormInput = function FormInput(_ref15) {
21209
21225
  showErrors: showErrors,
21210
21226
  "data-qa": labelTextWhenNoError,
21211
21227
  themeValues: themeValues,
21212
- customHeight: customHeight,
21213
- extraStyles: extraStyles
21228
+ $customHeight: customHeight,
21229
+ $extraStyles: extraStyles
21214
21230
  }, props)) : /*#__PURE__*/React__default.createElement(InputField, _extends({
21215
21231
  "aria-labelledby": labelTextWhenNoError.replace(/\s+/g, "-"),
21216
21232
  onChange: function onChange(e) {
@@ -21225,8 +21241,8 @@ var FormInput = function FormInput(_ref15) {
21225
21241
  "data-qa": labelTextWhenNoError,
21226
21242
  themeValues: themeValues,
21227
21243
  background: background,
21228
- customHeight: customHeight,
21229
- extraStyles: extraStyles
21244
+ $customHeight: customHeight,
21245
+ $extraStyles: extraStyles
21230
21246
  }, props))), /*#__PURE__*/React__default.createElement(Stack, {
21231
21247
  direction: "row",
21232
21248
  justify: "space-between"
@@ -33310,12 +33326,12 @@ const MATCHES_FIELD_ERROR$1 = "error/MATCHES_FIELD";
33310
33326
  const matchesField = createValidator(MATCHES_FIELD, MATCHES_FIELD_ERROR$1);
33311
33327
  validatorFns[MATCHES_FIELD] = (value, args, form) => {
33312
33328
  const dependentField = form[args[0]];
33313
- const dependentFieldValue = dependentField?.rawValue ?? "";
33314
33329
  if (dependentField === undefined) {
33315
33330
  throw new Error(
33316
33331
  `${args[0]} was passed to matchesField, but that field does not exist in the form`
33317
33332
  );
33318
33333
  }
33334
+ const dependentFieldValue = dependentField.rawValue;
33319
33335
  return value === dependentFieldValue;
33320
33336
  };
33321
33337
 
@@ -41115,9 +41131,11 @@ var Tabs = function Tabs(_ref) {
41115
41131
  className: "tab-list"
41116
41132
  }, tabsDisplayMode == HORIZONTAL ? showHorozontal(tabsConfig, activeTab) : showVertical(tabsConfig, activeTab)), /*#__PURE__*/React__default.createElement(Box, {
41117
41133
  className: "tab-content"
41118
- }, /*#__PURE__*/React__default.createElement(Box, null, tabsConfig.tabs.map(function (tab) {
41134
+ }, /*#__PURE__*/React__default.createElement(Box, null, tabsConfig.tabs.map(function (tab, idx) {
41119
41135
  if (tab.label !== activeTab) return undefined;
41120
- return tab.content;
41136
+ return /*#__PURE__*/React__default.createElement(React.Fragment, {
41137
+ key: idx
41138
+ }, tab.content);
41121
41139
  }))));
41122
41140
  };
41123
41141
 
@@ -41444,6 +41462,119 @@ var WorkflowTile = function WorkflowTile(_ref) {
41444
41462
  }))));
41445
41463
  };
41446
41464
 
41465
+ var DashboardIframe = styled__default.iframe.withConfig({
41466
+ displayName: "PeriscopeDashboardIframestyled__DashboardIframe",
41467
+ componentId: "sc-j0cucj-0"
41468
+ })(["border:none;box-shadow:0 0 5px 0 ", ";display:none;"], ALTO_GREY);
41469
+
41470
+ /**
41471
+ * Component: PeriscopeDashboardIframe
41472
+ *
41473
+ * Used for rendering Citybase's periscope reporting dashboards in iframes.
41474
+ * Receives action props to trigger a request on mount for the iframe's url.
41475
+ * Receives a string prop if/when we receive the url result.
41476
+ * And receives action props to emit errors from failed iframe loading.
41477
+ *
41478
+ * The logic and api client methods to handle requests/response,
41479
+ * store the url, etc. should be provided from the app consuming this library.
41480
+ *
41481
+ * If the url request is pending, render a spinner.
41482
+ * If the url request failed, render a UI error state.
41483
+ **/
41484
+
41485
+ var DASHBOARD_SIZE_MESSAGE_TYPE = "dashboard_resize";
41486
+ var PERISCOPE_ORIGIN = "https://app.periscopedata.com";
41487
+
41488
+ var isValidMessage = function isValidMessage(message) {
41489
+ return message.isTrusted && message.origin === PERISCOPE_ORIGIN && message.data && message.data.event_type === DASHBOARD_SIZE_MESSAGE_TYPE;
41490
+ };
41491
+
41492
+ var PeriscopeDashboardIframe = function PeriscopeDashboardIframe(_ref) {
41493
+ var url = _ref.url,
41494
+ requestDashboardUrl = _ref.requestDashboardUrl,
41495
+ periscopeDataPending = _ref.periscopeDataPending,
41496
+ periscopeDataSuccess = _ref.periscopeDataSuccess,
41497
+ periscopeDataFailure = _ref.periscopeDataFailure,
41498
+ periscopeDataRequestSuccess = _ref.periscopeDataRequestSuccess,
41499
+ periscopeDataRequestFailure = _ref.periscopeDataRequestFailure;
41500
+
41501
+ var _useState = React.useState(0),
41502
+ _useState2 = _slicedToArray(_useState, 2),
41503
+ height = _useState2[0],
41504
+ setHeight = _useState2[1];
41505
+
41506
+ var time = {
41507
+ timer: null
41508
+ };
41509
+ React.useEffect(function () {
41510
+ time.timer = setTimeout(function () {
41511
+ periscopeDataRequestFailure();
41512
+ }, 10000);
41513
+ }, []);
41514
+
41515
+ var Dashboard = function Dashboard(height) {
41516
+ return function (url) {
41517
+ return /*#__PURE__*/React__default.createElement(DashboardIframe, {
41518
+ src: url,
41519
+ width: "100%",
41520
+ height: height,
41521
+ "data-qa": "DashboardIframe",
41522
+ onLoad: function onLoad() {
41523
+ var iframe = document.querySelector("iframe");
41524
+ iframe.style.display = "initial";
41525
+ }
41526
+ });
41527
+ };
41528
+ };
41529
+
41530
+ var validatePeriscope = function validatePeriscope(message) {
41531
+ if (isValidMessage(message)) {
41532
+ setHeight(message.data.dashboard_height + 100);
41533
+ clearTimeout(time.timer);
41534
+ periscopeDataRequestSuccess();
41535
+ }
41536
+ };
41537
+
41538
+ React.useLayoutEffect(function () {
41539
+ window.addEventListener("message", validatePeriscope);
41540
+ requestDashboardUrl();
41541
+ return function () {
41542
+ return window.removeEventListener("message", validatePeriscope);
41543
+ };
41544
+ }, [requestDashboardUrl]);
41545
+ return /*#__PURE__*/React__default.createElement(React.Fragment, null, /*#__PURE__*/React__default.createElement(BoxWithShadow$1, {
41546
+ padding: "0",
41547
+ minWidth: "100%",
41548
+ minHeight: "592px",
41549
+ variant: "baseStandard",
41550
+ background: "#fff",
41551
+ borderRadius: "4px",
41552
+ extraStyles: "display: flex; justify-content: center; align-items: center; flex-direction: column;"
41553
+ }, periscopeDataPending && !periscopeDataSuccess && /*#__PURE__*/React__default.createElement(Cover, {
41554
+ minHeight: "100%",
41555
+ singleChild: true
41556
+ }, /*#__PURE__*/React__default.createElement(Center, {
41557
+ intrinsic: true
41558
+ }, /*#__PURE__*/React__default.createElement(Spinner$2, {
41559
+ size: "100"
41560
+ }))), periscopeDataFailure && !periscopeDataSuccess && /*#__PURE__*/React__default.createElement(Box, {
41561
+ padding: "64px"
41562
+ }, /*#__PURE__*/React__default.createElement(Center, {
41563
+ intrinsic: true
41564
+ }, /*#__PURE__*/React__default.createElement(Box, {
41565
+ padding: "0 0 2rem"
41566
+ }, /*#__PURE__*/React__default.createElement(PeriscopeFailedIcon, null)), /*#__PURE__*/React__default.createElement(Heading$1, {
41567
+ variant: "h3",
41568
+ weight: "700"
41569
+ }, "Something Went Wrong"), /*#__PURE__*/React__default.createElement(Paragraph$1, {
41570
+ variant: "p",
41571
+ extraStyles: "text-align: center;"
41572
+ }, "There was an issue trying to load the dashboard."), /*#__PURE__*/React__default.createElement(Paragraph$1, {
41573
+ variant: "p",
41574
+ extraStyles: "text-align: center;"
41575
+ }, "Your organization may not have a dashboard configured."))), !periscopeDataFailure && url && Dashboard(height)(url)));
41576
+ };
41577
+
41447
41578
  var pageBackground = "#F6F6F9";
41448
41579
  var fallbackValues$H = {
41449
41580
  pageBackground: pageBackground
@@ -41822,6 +41953,7 @@ exports.PaymentMethodIcon = PaymentMethodIcon$1;
41822
41953
  exports.PaymentSearchIcon = PaymentSearchIcon;
41823
41954
  exports.PaymentsIconSmall = PaymentsIconSmall$1;
41824
41955
  exports.PendingIcon = PendingIcon;
41956
+ exports.PeriscopeDashboardIframe = PeriscopeDashboardIframe;
41825
41957
  exports.PeriscopeFailedIcon = PeriscopeFailedIcon;
41826
41958
  exports.PhoneForm = PhoneForm;
41827
41959
  exports.Placeholder = Placeholder$1;