oolib 2.28.4 → 2.29.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.
@@ -5,8 +5,9 @@ export function PasswordInput({ enableValidation, ...props }: {
5
5
  }): any;
6
6
  export function EmailInput(props: any): any;
7
7
  export function PhoneInput(props: any): any;
8
- export function URLInput({ routesAreValidInputs, ...props }: {
8
+ export function URLInput({ routesAreValidInputs, validationPlugin, ...props }: {
9
9
  [x: string]: any;
10
10
  routesAreValidInputs?: boolean;
11
+ validationPlugin: any;
11
12
  }): any;
12
13
  export function NumberInput(props: any): any;
@@ -90,15 +90,16 @@ var Typo_1 = require("../Typo");
90
90
  var Buttons_1 = require("../Buttons");
91
91
  var _EXPORTS_1 = require("../../utils/_EXPORTS");
92
92
  var LoadersAndProgress_1 = require("../LoadersAndProgress");
93
+ var OKELink_1 = require("../OKELink");
93
94
  var DisplayIcon = function (_a) {
94
95
  var icon = _a.icon, onClick = _a.onClick, size = _a.size;
95
96
  var IconComp = icons_1.icons[icon];
96
97
  return (react_1.default.createElement("div", { style: { cursor: onClick ? 'pointer' : '', display: 'flex' }, onMouseDown: onClick || null }, IconComp && react_1.default.createElement(IconComp, { size: size, weight: "bold" })));
97
98
  };
98
99
  var TextInput = function (props) {
99
- var id = props.id, invert = props.invert, disabled = props.disabled, icon = props.icon, type = props.type, _a = props.placeholder, placeholder = _a === void 0 ? 'Enter Text...' : _a, value = props.value, onChange = props.onChange, onFocus = props.onFocus, readOnly = props.readOnly, iconOnClick = props.iconOnClick, eyeIcon = props.eyeIcon, S = props.S, validateOnBlur = props.validateOnBlur, actionBtn = props.actionBtn, className = props.className, maxLength = props.maxLength, DEPRECATED_maxNumLimiter = props.maxNumLimiter, forceFocus = props.forceFocus //sometimes, when some other elem is clicked, we wanna trigger focus on the textinput. eg. when on mobile, the search icon is clicked on the listingpage
100
+ var id = props.id, invert = props.invert, disabled = props.disabled, icon = props.icon, type = props.type, _a = props.placeholder, placeholder = _a === void 0 ? 'Enter Text...' : _a, _b = props.value, value = _b === void 0 ? '' : _b, onChange = props.onChange, onFocus = props.onFocus, readOnly = props.readOnly, iconOnClick = props.iconOnClick, eyeIcon = props.eyeIcon, S = props.S, validateOnBlur = props.validateOnBlur, actionBtn = props.actionBtn, className = props.className, maxLength = props.maxLength, DEPRECATED_maxNumLimiter = props.maxNumLimiter, forceFocus = props.forceFocus //sometimes, when some other elem is clicked, we wanna trigger focus on the textinput. eg. when on mobile, the search icon is clicked on the listingpage
100
101
  ;
101
- var _b = (0, react_1.useState)(''), inputStatus = _b[0], setInputStatus = _b[1];
102
+ var _c = (0, react_1.useState)(''), inputStatus = _c[0], setInputStatus = _c[1];
102
103
  var composition = icon && !eyeIcon ? 'icon+text' : 'textOnly';
103
104
  var size = S ? 'S' : 'M';
104
105
  var actionBtnEnabaled = !!value && (type !== 'url' ? true : inputStatus.type === 'success');
@@ -147,7 +148,10 @@ var TextInput = function (props) {
147
148
  react_1.default.createElement(LoadersAndProgress_1.LoaderCircle, { S: true, invert: invert }))),
148
149
  actionBtn && (react_1.default.createElement(Buttons_1.ButtonPrimary, { value: actionBtn.text, invert: actionBtn.invert, onClick: actionBtnEnabaled && actionBtn.onClick, disabled: !actionBtnEnabaled, style: { marginRight: '-2rem' } }))),
149
150
  (inputStatus === null || inputStatus === void 0 ? void 0 : inputStatus.msg) && (react_1.default.createElement(index_styled_1.MsgContainer, { invert: invert, status: inputStatus === null || inputStatus === void 0 ? void 0 : inputStatus.type },
150
- react_1.default.createElement(Typo_1.SANS_3, null, inputStatus.msg))))))));
151
+ react_1.default.createElement(Typo_1.SANS_3, null,
152
+ inputStatus.msg,
153
+ inputStatus.link &&
154
+ react_1.default.createElement(OKELink_1.OKELink, { style: { marginLeft: '1rem' }, to: inputStatus.link.to }, inputStatus.link.text)))))))));
151
155
  };
152
156
  exports.TextInput = TextInput;
153
157
  var PasswordInput = function (_a) {
@@ -211,12 +215,21 @@ var PhoneInput = function (props) {
211
215
  exports.PhoneInput = PhoneInput;
212
216
  var URLInput = function (_a) {
213
217
  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
214
- props = __rest(_a, ["routesAreValidInputs"]);
218
+ validationPlugin = _a.validationPlugin, props = __rest(_a, ["routesAreValidInputs", "validationPlugin"]);
215
219
  var handleValidation = function (value) { return __awaiter(void 0, void 0, void 0, function () {
216
- var response, err_1;
220
+ var pluginResponse, response, err_1;
217
221
  return __generator(this, function (_a) {
218
222
  switch (_a.label) {
219
223
  case 0:
224
+ if (!validationPlugin) return [3 /*break*/, 2];
225
+ return [4 /*yield*/, validationPlugin()];
226
+ case 1:
227
+ pluginResponse = _a.sent();
228
+ if (pluginResponse)
229
+ return [2 /*return*/, pluginResponse];
230
+ _a.label = 2;
231
+ case 2:
232
+ //else
220
233
  //if routesAreValidInputs, then first validate for a route
221
234
  if (routesAreValidInputs && value.substring(0, 1) === '/') {
222
235
  return [2 /*return*/, { type: 'success', msg: 'valid route' }];
@@ -225,22 +238,22 @@ var URLInput = function (_a) {
225
238
  if (!/^https?:\/\//i.test(value)) {
226
239
  value = 'https://' + value;
227
240
  }
228
- _a.label = 1;
229
- case 1:
230
- _a.trys.push([1, 3, , 4]);
241
+ _a.label = 3;
242
+ case 3:
243
+ _a.trys.push([3, 5, , 6]);
231
244
  return [4 /*yield*/, fetch(value)];
232
- case 2:
245
+ case 4:
233
246
  response = _a.sent();
234
247
  if (response.status !== 200)
235
248
  throw new Error('');
236
249
  return [2 /*return*/, { type: 'success', msg: 'valid url' }];
237
- case 3:
250
+ case 5:
238
251
  err_1 = _a.sent();
239
252
  if (/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/ig.test(value)) {
240
253
  return [2 /*return*/, { type: 'success', msg: 'valid url' }];
241
254
  }
242
255
  return [2 /*return*/, { type: 'error', msg: 'Enter a valid url...' }];
243
- case 4: return [2 /*return*/];
256
+ case 6: return [2 /*return*/];
244
257
  }
245
258
  });
246
259
  }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.28.4",
3
+ "version": "2.29.0",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",