oolib 2.187.12 → 2.188.1

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.
@@ -1,8 +1,9 @@
1
- export function URLInput({ routesAreValidInputs, validationPlugin, passValidationErrorToFormValidation, content, ...props }: {
1
+ export function URLInput({ routesAreValidInputs, validationPlugin: _validationPlugin, passValidationErrorToFormValidation, content, plugin, ...props }: {
2
2
  [x: string]: any;
3
3
  routesAreValidInputs?: boolean;
4
4
  validationPlugin: any;
5
5
  passValidationErrorToFormValidation: any;
6
6
  content: any;
7
+ plugin: any;
7
8
  }): React.JSX.Element;
8
9
  import React from "react";
@@ -63,15 +63,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
63
63
  Object.defineProperty(exports, "__esModule", { value: true });
64
64
  exports.URLInput = void 0;
65
65
  var react_1 = __importDefault(require("react"));
66
+ var styled_components_1 = require("styled-components");
66
67
  var __1 = require("..");
67
68
  var URLInput = function (_a) {
68
69
  var _b = _a.routesAreValidInputs, routesAreValidInputs = _b === void 0 ? false : _b, //if we want react route declarations to be considered as 'valid' then set this to true
69
- validationPlugin = _a.validationPlugin, passValidationErrorToFormValidation = _a.passValidationErrorToFormValidation, content = _a.content, props = __rest(_a, ["routesAreValidInputs", "validationPlugin", "passValidationErrorToFormValidation", "content"]);
70
+ _validationPlugin = _a.validationPlugin, passValidationErrorToFormValidation = _a.passValidationErrorToFormValidation, content = _a.content, plugin = _a.plugin, props = __rest(_a, ["routesAreValidInputs", "validationPlugin", "passValidationErrorToFormValidation", "content", "plugin"]);
71
+ var theme = (0, styled_components_1.useTheme)();
70
72
  var handleValidation = function (value) { return __awaiter(void 0, void 0, void 0, function () {
71
- var pluginResponse, successObj, response, successObj, err_1, successObj, errorObj;
72
- return __generator(this, function (_a) {
73
- switch (_a.label) {
73
+ var validationPlugin, pluginResponse, successObj, response, successObj, err_1, successObj, errorObj;
74
+ var _a;
75
+ return __generator(this, function (_b) {
76
+ switch (_b.label) {
74
77
  case 0:
78
+ validationPlugin = (_validationPlugin ||
79
+ ((plugin === null || plugin === void 0 ? void 0 : plugin.validation) && ((_a = theme.pluginConfigs) === null || _a === void 0 ? void 0 : _a.tplBlockPlugins[plugin.validation])));
75
80
  if (!validationPlugin) return [3 /*break*/, 2];
76
81
  return [4 /*yield*/, validationPlugin({
77
82
  value: value,
@@ -79,10 +84,10 @@ var URLInput = function (_a) {
79
84
  passValidationErrorToFormValidation: passValidationErrorToFormValidation,
80
85
  })];
81
86
  case 1:
82
- pluginResponse = _a.sent();
87
+ pluginResponse = _b.sent();
83
88
  if (pluginResponse)
84
89
  return [2 /*return*/, pluginResponse];
85
- _a.label = 2;
90
+ _b.label = 2;
86
91
  case 2:
87
92
  //else
88
93
  //if routesAreValidInputs, then first validate for a route
@@ -96,12 +101,12 @@ var URLInput = function (_a) {
96
101
  if (!/^https?:\/\//i.test(value)) {
97
102
  value = "https://" + value;
98
103
  }
99
- _a.label = 3;
104
+ _b.label = 3;
100
105
  case 3:
101
- _a.trys.push([3, 5, , 6]);
106
+ _b.trys.push([3, 5, , 6]);
102
107
  return [4 /*yield*/, fetch(value)];
103
108
  case 4:
104
- response = _a.sent();
109
+ response = _b.sent();
105
110
  if (response.status !== 200)
106
111
  throw new Error("");
107
112
  successObj = { type: "success", msg: "valid url" };
@@ -109,7 +114,7 @@ var URLInput = function (_a) {
109
114
  passValidationErrorToFormValidation(successObj.type);
110
115
  return [2 /*return*/, successObj];
111
116
  case 5:
112
- err_1 = _a.sent();
117
+ err_1 = _b.sent();
113
118
  if (/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi.test(value)) {
114
119
  successObj = { type: "success", msg: "valid url" };
115
120
  if (passValidationErrorToFormValidation)
@@ -124,6 +129,6 @@ var URLInput = function (_a) {
124
129
  }
125
130
  });
126
131
  }); };
127
- return (react_1.default.createElement(__1.TextInput, __assign({ type: "url", handleValidation: handleValidation, placeholder: "Enter a valid url..." }, props)));
132
+ return (react_1.default.createElement(__1.TextInput, __assign({ type: "url", handleValidation: handleValidation, placeholder: "Enter a valid url...", content: content, passValidationErrorToFormValidation: passValidationErrorToFormValidation }, props)));
128
133
  };
129
134
  exports.URLInput = URLInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.187.12",
3
+ "version": "2.188.1",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",