@hybridly/utils 0.4.1 → 0.4.3

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.
package/dist/index.cjs CHANGED
@@ -1,17 +1,15 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const baseMerge = require('deepmerge');
6
4
  const isPlainObject = require('is-plain-object');
7
5
  const lodash_clonedeep = require('lodash.clonedeep');
8
6
  const makeDebugger = require('debug');
9
7
 
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
8
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
11
9
 
12
- const baseMerge__default = /*#__PURE__*/_interopDefaultLegacy(baseMerge);
13
- const lodash_clonedeep__default = /*#__PURE__*/_interopDefaultLegacy(lodash_clonedeep);
14
- const makeDebugger__default = /*#__PURE__*/_interopDefaultLegacy(makeDebugger);
10
+ const baseMerge__default = /*#__PURE__*/_interopDefaultCompat(baseMerge);
11
+ const lodash_clonedeep__default = /*#__PURE__*/_interopDefaultCompat(lodash_clonedeep);
12
+ const makeDebugger__default = /*#__PURE__*/_interopDefaultCompat(makeDebugger);
15
13
 
16
14
  function hasFiles(data) {
17
15
  if (!data) {
@@ -60,12 +58,23 @@ function append(form, key, value) {
60
58
  objectToFormData(value, form, key);
61
59
  }
62
60
 
61
+ var __defProp = Object.defineProperty;
62
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
63
+ var __publicField = (obj, key, value) => {
64
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
65
+ return value;
66
+ };
63
67
  const stack = [];
64
68
  class Modal {
65
69
  constructor(html, id) {
66
70
  this.html = html;
67
71
  this.id = id;
68
- this.animationDurationInMs = 200;
72
+ __publicField(this, "main");
73
+ __publicField(this, "overlay");
74
+ __publicField(this, "iframe");
75
+ __publicField(this, "style");
76
+ __publicField(this, "hideOnEscape");
77
+ __publicField(this, "animationDurationInMs", 200);
69
78
  if (stack.includes(id)) {
70
79
  return;
71
80
  }
@@ -0,0 +1,85 @@
1
+ import makeDebugger from 'debug';
2
+ export { default as clone } from 'lodash.clonedeep';
3
+
4
+ type RequestData = Record<string, FormDataConvertible> | FormDataConvertible | FormData;
5
+ type FormDataConvertible = {
6
+ [key: string]: FormDataConvertible;
7
+ } | Array<FormDataConvertible> | Set<FormDataConvertible> | Blob | File | FormDataEntryValue | Date | boolean | number | null | undefined | string;
8
+ /**
9
+ * Checks if the given object has a file.
10
+ */
11
+ declare function hasFiles(data?: RequestData): boolean;
12
+ /**
13
+ * Converts an object literal to a `FormData` object.
14
+ */
15
+ declare function objectToFormData(source?: RequestData, form?: FormData, parentKey?: string): FormData;
16
+
17
+ declare class Modal {
18
+ private html;
19
+ private id;
20
+ private main;
21
+ private overlay;
22
+ private iframe;
23
+ private style;
24
+ private hideOnEscape?;
25
+ private animationDurationInMs;
26
+ constructor(html: string, id: string);
27
+ static fromException(response: string, id: string): Modal;
28
+ static forPageComponent(component: string, id: string): Modal;
29
+ static domainsDisabled(component: string, id: string): Modal;
30
+ initializeDOM(): false | undefined;
31
+ show(): void;
32
+ destroy(): void;
33
+ }
34
+ declare function showResponseErrorModal(response: string): Modal;
35
+ declare function showPageComponentErrorModal(response: string): Modal;
36
+ declare function showDomainsDisabledErrorModal(response: string): Modal;
37
+
38
+ declare function random(length?: number): string;
39
+ /** Simple pattern matching util. */
40
+ declare function match<TValue extends string | number = string, TReturnValue = unknown>(value: TValue, lookup: Record<TValue | 'default', TReturnValue | ((...args: any[]) => TReturnValue)>, ...args: any[]): TReturnValue | Promise<TReturnValue>;
41
+ declare function debounce<F extends (...params: any[]) => ReturnType<F>>(fn: F, delay: number): F;
42
+ declare function value<T>(value: T | (() => T)): T;
43
+ declare function when<T, D>(condition: any, data: T, _default?: D): T | D | undefined;
44
+ interface MergeOptions {
45
+ overwriteArray?: boolean;
46
+ mergePlainObjects?: boolean;
47
+ arrayMerge?: (target: any[], source: any[]) => any[];
48
+ }
49
+ declare function merge<T>(x: Partial<T>, y: Partial<T>, options?: MergeOptions): T;
50
+ declare function removeTrailingSlash(string: string): string;
51
+ /**
52
+ * Sets a value at a path in an object
53
+ *
54
+ * This function will set a value at a path in an object, creating any missing
55
+ * objects along the way. The object is modified in place.
56
+ *
57
+ * @param obj the object to set the value in
58
+ * @param path a dot-separated path to the property to set
59
+ * @param value the value to set
60
+ */
61
+ declare function setValueAtPath(obj: any, path: string, value: any): void;
62
+ /**
63
+ * Unsets a property at a path in an object
64
+ *
65
+ * This function will unset a property at a path in an object, deleting any
66
+ * objects along the way that are empty. The object is modified in place.
67
+ *
68
+ * @param obj the object to unset the property in
69
+ * @param path a dot-separated path to the property to unset
70
+ */
71
+ declare function unsetPropertyAtPath(obj: any, path: string): void;
72
+
73
+ declare const debug: {
74
+ router: makeDebugger.Debugger;
75
+ history: makeDebugger.Debugger;
76
+ url: makeDebugger.Debugger;
77
+ context: makeDebugger.Debugger;
78
+ external: makeDebugger.Debugger;
79
+ scroll: makeDebugger.Debugger;
80
+ hook: makeDebugger.Debugger;
81
+ plugin: (name: string, ...args: any[]) => void;
82
+ adapter: (name: string, ...args: any[]) => void;
83
+ };
84
+
85
+ export { type FormDataConvertible, type RequestData, debounce, debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showDomainsDisabledErrorModal, showPageComponentErrorModal, showResponseErrorModal, unsetPropertyAtPath, value, when };
@@ -0,0 +1,85 @@
1
+ import makeDebugger from 'debug';
2
+ export { default as clone } from 'lodash.clonedeep';
3
+
4
+ type RequestData = Record<string, FormDataConvertible> | FormDataConvertible | FormData;
5
+ type FormDataConvertible = {
6
+ [key: string]: FormDataConvertible;
7
+ } | Array<FormDataConvertible> | Set<FormDataConvertible> | Blob | File | FormDataEntryValue | Date | boolean | number | null | undefined | string;
8
+ /**
9
+ * Checks if the given object has a file.
10
+ */
11
+ declare function hasFiles(data?: RequestData): boolean;
12
+ /**
13
+ * Converts an object literal to a `FormData` object.
14
+ */
15
+ declare function objectToFormData(source?: RequestData, form?: FormData, parentKey?: string): FormData;
16
+
17
+ declare class Modal {
18
+ private html;
19
+ private id;
20
+ private main;
21
+ private overlay;
22
+ private iframe;
23
+ private style;
24
+ private hideOnEscape?;
25
+ private animationDurationInMs;
26
+ constructor(html: string, id: string);
27
+ static fromException(response: string, id: string): Modal;
28
+ static forPageComponent(component: string, id: string): Modal;
29
+ static domainsDisabled(component: string, id: string): Modal;
30
+ initializeDOM(): false | undefined;
31
+ show(): void;
32
+ destroy(): void;
33
+ }
34
+ declare function showResponseErrorModal(response: string): Modal;
35
+ declare function showPageComponentErrorModal(response: string): Modal;
36
+ declare function showDomainsDisabledErrorModal(response: string): Modal;
37
+
38
+ declare function random(length?: number): string;
39
+ /** Simple pattern matching util. */
40
+ declare function match<TValue extends string | number = string, TReturnValue = unknown>(value: TValue, lookup: Record<TValue | 'default', TReturnValue | ((...args: any[]) => TReturnValue)>, ...args: any[]): TReturnValue | Promise<TReturnValue>;
41
+ declare function debounce<F extends (...params: any[]) => ReturnType<F>>(fn: F, delay: number): F;
42
+ declare function value<T>(value: T | (() => T)): T;
43
+ declare function when<T, D>(condition: any, data: T, _default?: D): T | D | undefined;
44
+ interface MergeOptions {
45
+ overwriteArray?: boolean;
46
+ mergePlainObjects?: boolean;
47
+ arrayMerge?: (target: any[], source: any[]) => any[];
48
+ }
49
+ declare function merge<T>(x: Partial<T>, y: Partial<T>, options?: MergeOptions): T;
50
+ declare function removeTrailingSlash(string: string): string;
51
+ /**
52
+ * Sets a value at a path in an object
53
+ *
54
+ * This function will set a value at a path in an object, creating any missing
55
+ * objects along the way. The object is modified in place.
56
+ *
57
+ * @param obj the object to set the value in
58
+ * @param path a dot-separated path to the property to set
59
+ * @param value the value to set
60
+ */
61
+ declare function setValueAtPath(obj: any, path: string, value: any): void;
62
+ /**
63
+ * Unsets a property at a path in an object
64
+ *
65
+ * This function will unset a property at a path in an object, deleting any
66
+ * objects along the way that are empty. The object is modified in place.
67
+ *
68
+ * @param obj the object to unset the property in
69
+ * @param path a dot-separated path to the property to unset
70
+ */
71
+ declare function unsetPropertyAtPath(obj: any, path: string): void;
72
+
73
+ declare const debug: {
74
+ router: makeDebugger.Debugger;
75
+ history: makeDebugger.Debugger;
76
+ url: makeDebugger.Debugger;
77
+ context: makeDebugger.Debugger;
78
+ external: makeDebugger.Debugger;
79
+ scroll: makeDebugger.Debugger;
80
+ hook: makeDebugger.Debugger;
81
+ plugin: (name: string, ...args: any[]) => void;
82
+ adapter: (name: string, ...args: any[]) => void;
83
+ };
84
+
85
+ export { type FormDataConvertible, type RequestData, debounce, debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showDomainsDisabledErrorModal, showPageComponentErrorModal, showResponseErrorModal, unsetPropertyAtPath, value, when };
package/dist/index.d.ts CHANGED
@@ -82,4 +82,4 @@ declare const debug: {
82
82
  adapter: (name: string, ...args: any[]) => void;
83
83
  };
84
84
 
85
- export { FormDataConvertible, RequestData, debounce, debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showDomainsDisabledErrorModal, showPageComponentErrorModal, showResponseErrorModal, unsetPropertyAtPath, value, when };
85
+ export { type FormDataConvertible, type RequestData, debounce, debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showDomainsDisabledErrorModal, showPageComponentErrorModal, showResponseErrorModal, unsetPropertyAtPath, value, when };
package/dist/index.mjs CHANGED
@@ -50,12 +50,23 @@ function append(form, key, value) {
50
50
  objectToFormData(value, form, key);
51
51
  }
52
52
 
53
+ var __defProp = Object.defineProperty;
54
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
55
+ var __publicField = (obj, key, value) => {
56
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
57
+ return value;
58
+ };
53
59
  const stack = [];
54
60
  class Modal {
55
61
  constructor(html, id) {
56
62
  this.html = html;
57
63
  this.id = id;
58
- this.animationDurationInMs = 200;
64
+ __publicField(this, "main");
65
+ __publicField(this, "overlay");
66
+ __publicField(this, "iframe");
67
+ __publicField(this, "style");
68
+ __publicField(this, "hideOnEscape");
69
+ __publicField(this, "animationDurationInMs", 200);
59
70
  if (stack.includes(id)) {
60
71
  return;
61
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hybridly/utils",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Utils used in Hybridly packages",
5
5
  "keywords": [
6
6
  "hybridly"