@thecb/components 4.2.8-beta.5 → 4.3.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 (2) hide show
  1. package/dist/index.cjs.js +39 -13
  2. package/package.json +2 -2
package/dist/index.cjs.js CHANGED
@@ -15609,10 +15609,19 @@ function _assertThisInitialized(self) {
15609
15609
  return self;
15610
15610
  }
15611
15611
 
15612
+ function _setPrototypeOf(o, p) {
15613
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
15614
+ o.__proto__ = p;
15615
+ return o;
15616
+ };
15617
+
15618
+ return _setPrototypeOf(o, p);
15619
+ }
15620
+
15612
15621
  function _inheritsLoose(subClass, superClass) {
15613
15622
  subClass.prototype = Object.create(superClass.prototype);
15614
15623
  subClass.prototype.constructor = subClass;
15615
- subClass.__proto__ = superClass;
15624
+ _setPrototypeOf(subClass, superClass);
15616
15625
  }
15617
15626
 
15618
15627
  function _getPrototypeOf(o) {
@@ -15622,15 +15631,6 @@ function _getPrototypeOf(o) {
15622
15631
  return _getPrototypeOf(o);
15623
15632
  }
15624
15633
 
15625
- function _setPrototypeOf(o, p) {
15626
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
15627
- o.__proto__ = p;
15628
- return o;
15629
- };
15630
-
15631
- return _setPrototypeOf(o, p);
15632
- }
15633
-
15634
15634
  function _isNativeFunction(fn) {
15635
15635
  return Function.toString.call(fn).indexOf("[native code]") !== -1;
15636
15636
  }
@@ -15641,7 +15641,7 @@ function _isNativeReflectConstruct() {
15641
15641
  if (typeof Proxy === "function") return true;
15642
15642
 
15643
15643
  try {
15644
- Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
15644
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
15645
15645
  return true;
15646
15646
  } catch (e) {
15647
15647
  return false;
@@ -15781,7 +15781,9 @@ var ERRORS = {
15781
15781
  "73": "Please provide a valid CSS variable.\n\n",
15782
15782
  "74": "CSS variable not found and no default was provided.\n\n",
15783
15783
  "75": "important requires a valid style object, got a %s instead.\n\n",
15784
- "76": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n"
15784
+ "76": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",
15785
+ "77": "remToPx expects a value in \"rem\" but you provided it in \"%s\".\n\n",
15786
+ "78": "base must be set in \"px\" or \"%\" but you set it in \"%s\".\n"
15785
15787
  };
15786
15788
  /**
15787
15789
  * super basic version of sprintf
@@ -34466,6 +34468,12 @@ const set$2 = fieldName => value => ({
34466
34468
  const CLEAR = "form/CLEAR";
34467
34469
  const clear = () => ({ type: CLEAR });
34468
34470
 
34471
+ const ADD_VALIDATOR = "field/ADD_VALIDATOR";
34472
+ const addValidator = fieldName => validator => ({
34473
+ type: ADD_VALIDATOR,
34474
+ payload: { fieldName, validator }
34475
+ });
34476
+
34469
34477
  const createFormReducer = formConfig => (
34470
34478
  state = createInitialState(formConfig),
34471
34479
  action
@@ -34497,6 +34505,23 @@ const createFormReducer = formConfig => (
34497
34505
  });
34498
34506
  case CLEAR:
34499
34507
  return createInitialState(formConfig);
34508
+ case ADD_VALIDATOR:
34509
+ const fieldWithOverride = action.payload.fieldName;
34510
+ const newValidator = action.payload.validator;
34511
+
34512
+ return produce(state, draftState => {
34513
+ draftState[fieldWithOverride].validators.push(newValidator);
34514
+ const fields = Object.entries(draftState);
34515
+ for (let entry of fields) {
34516
+ let fieldName = entry[0];
34517
+ let field = entry[1];
34518
+ let errors = computeErrors(fieldName, draftState);
34519
+ let dirty = field.dirty;
34520
+ draftState[fieldName].errors = errors;
34521
+ draftState[fieldName].dirty = dirty;
34522
+ draftState[fieldName].hasErrors = errors.length > 0;
34523
+ }
34524
+ });
34500
34525
  default:
34501
34526
  return state;
34502
34527
  }
@@ -34515,7 +34540,8 @@ const createMapDispatchToProps = formConfig => {
34515
34540
  const keys = Object.keys(formConfig);
34516
34541
  for (let fieldName of keys) {
34517
34542
  dispatchObj.fields[fieldName] = {
34518
- set: value => dispatch(set$2(fieldName)(value))
34543
+ set: value => dispatch(set$2(fieldName)(value)),
34544
+ addValidator: validator => dispatch(addValidator(fieldName)(validator))
34519
34545
  };
34520
34546
  }
34521
34547
  dispatchObj.form = { clear: () => dispatch(clear()) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "4.2.8-beta.5",
3
+ "version": "4.3.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -80,6 +80,6 @@
80
80
  "ramda": "^0.27.0",
81
81
  "react-aria-modal": "^4.0.0",
82
82
  "react-pose": "^4.0.10",
83
- "redux-freeform": "^5.0.0"
83
+ "redux-freeform": "^5.0.1"
84
84
  }
85
85
  }