chayns-api 2.6.9 → 2.6.11

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.
@@ -616,6 +616,10 @@ class AppWrapper {
616
616
  });
617
617
  },
618
618
  createDialog: config => {
619
+ if (config.type === _IChaynsReact.DialogType.INPUT && typeof config.formatter === 'function') {
620
+ console.warn('[chayns-api] passing a function as formatter is not supported in the app environment, the formatter will be ignored');
621
+ delete config.formatter;
622
+ }
619
623
  return new _DialogHandler.default(config, this.functions.openDialog, this.functions.closeDialog, this.functions.dispatchEventToDialogClient, this.functions.addDialogClientEventListener);
620
624
  },
621
625
  openDialog: async (config, callback) => {
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.FrameWrapper = void 0;
7
7
  var comlink = _interopRequireWildcard(require("comlink"));
8
- var _DialogHandler = _interopRequireDefault(require("../handler/DialogHandler"));
9
- var _visibilityChangeListener = require("../calls/visibilityChangeListener");
10
8
  var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
11
9
  var _sendMessage = require("../calls/sendMessage");
10
+ var _visibilityChangeListener = require("../calls/visibilityChangeListener");
11
+ var _DialogHandler = _interopRequireDefault(require("../handler/DialogHandler"));
12
+ var _IChaynsReact = require("../types/IChaynsReact");
12
13
  var _heightHelper = require("../util/heightHelper");
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
15
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
@@ -248,6 +249,9 @@ class FrameWrapper {
248
249
  return this.exposedFunctions.scrollByY(value, duration);
249
250
  },
250
251
  createDialog: config => {
252
+ if (config.type === _IChaynsReact.DialogType.INPUT && typeof config.formatter === 'function') {
253
+ config.formatter = comlink.proxy(config.formatter);
254
+ }
251
255
  return new _DialogHandler.default(config, this.functions.openDialog, this.exposedFunctions.closeDialog, this.functions.dispatchEventToDialogClient, this.functions.addDialogClientEventListener);
252
256
  },
253
257
  closeDialog: async dialogId => {
@@ -578,6 +578,10 @@ export class AppWrapper {
578
578
  });
579
579
  },
580
580
  createDialog: config => {
581
+ if (config.type === DialogType.INPUT && typeof config.formatter === 'function') {
582
+ console.warn('[chayns-api] passing a function as formatter is not supported in the app environment, the formatter will be ignored');
583
+ delete config.formatter;
584
+ }
581
585
  return new DialogHandler(config, this.functions.openDialog, this.functions.closeDialog, this.functions.dispatchEventToDialogClient, this.functions.addDialogClientEventListener);
582
586
  },
583
587
  openDialog: async (config, callback) => {
@@ -2,10 +2,11 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
2
2
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
3
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
4
  import * as comlink from 'comlink';
5
- import DialogHandler from '../handler/DialogHandler';
6
- import { addVisibilityChangeListener, removeVisibilityChangeListener } from '../calls/visibilityChangeListener';
7
5
  import getUserInfo from '../calls/getUserInfo';
8
6
  import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../calls/sendMessage';
7
+ import { addVisibilityChangeListener, removeVisibilityChangeListener } from '../calls/visibilityChangeListener';
8
+ import DialogHandler from '../handler/DialogHandler';
9
+ import { DialogType } from '../types/IChaynsReact';
9
10
  import { setTappHeight } from '../util/heightHelper';
10
11
  export class FrameWrapper {
11
12
  constructor() {
@@ -244,6 +245,9 @@ export class FrameWrapper {
244
245
  return this.exposedFunctions.scrollByY(value, duration);
245
246
  },
246
247
  createDialog: config => {
248
+ if (config.type === DialogType.INPUT && typeof config.formatter === 'function') {
249
+ config.formatter = comlink.proxy(config.formatter);
250
+ }
247
251
  return new DialogHandler(config, this.functions.openDialog, this.exposedFunctions.closeDialog, this.functions.dispatchEventToDialogClient, this.functions.addDialogClientEventListener);
248
252
  },
249
253
  closeDialog: async dialogId => {
@@ -128,6 +128,11 @@ export interface DialogInput {
128
128
  placeholder?: string;
129
129
  inputType?: DialogInputType;
130
130
  defaultValue?: string;
131
+ /**
132
+ * Formats the input value shown in the dialog.
133
+ * Not supported in app environments due to security reasons.
134
+ * @param input
135
+ */
131
136
  formatter?: (input: string) => string;
132
137
  regex?: string;
133
138
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "2.6.9",
3
+ "version": "2.6.11",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",