@gustavo-valsechi/utils 1.0.2 → 1.0.4

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,16 @@
1
- type DefaultValue<T> = {
2
- [K in keyof T]: T[K] extends string ? '' : T[K] extends number ? 0 : T[K] extends boolean ? false : T[K] extends Array<infer U> ? DefaultValue<U>[] : T[K] extends object ? DefaultValue<T[K]> : null;
3
- };
4
1
  declare const Default: {
5
- build<T>(schema: T): DefaultValue<T>;
2
+ credentials: {
3
+ page: number;
4
+ limit: number;
5
+ order: {
6
+ createdAt: string;
7
+ };
8
+ };
9
+ pagination: {
10
+ content: never[];
11
+ total: number;
12
+ totalPage: number;
13
+ };
6
14
  };
7
15
 
8
- export { type DefaultValue, Default as default };
16
+ export { Default as default };
@@ -1,8 +1,16 @@
1
- type DefaultValue<T> = {
2
- [K in keyof T]: T[K] extends string ? '' : T[K] extends number ? 0 : T[K] extends boolean ? false : T[K] extends Array<infer U> ? DefaultValue<U>[] : T[K] extends object ? DefaultValue<T[K]> : null;
3
- };
4
1
  declare const Default: {
5
- build<T>(schema: T): DefaultValue<T>;
2
+ credentials: {
3
+ page: number;
4
+ limit: number;
5
+ order: {
6
+ createdAt: string;
7
+ };
8
+ };
9
+ pagination: {
10
+ content: never[];
11
+ total: number;
12
+ totalPage: number;
13
+ };
6
14
  };
7
15
 
8
- export { type DefaultValue, Default as default };
16
+ export { Default as default };
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/default/index.ts
@@ -33,34 +23,16 @@ __export(default_exports, {
33
23
  default: () => default_default
34
24
  });
35
25
  module.exports = __toCommonJS(default_exports);
36
- var import_lodash = __toESM(require("lodash"));
37
26
  var Default = {
38
- build(schema) {
39
- const result = {};
40
- for (const key in schema) {
41
- const value = schema[key];
42
- switch (typeof value) {
43
- case "string":
44
- result[key] = "";
45
- break;
46
- case "number":
47
- result[key] = 0;
48
- break;
49
- case "boolean":
50
- result[key] = "";
51
- break;
52
- case "object":
53
- if (import_lodash.default.isArray(value)) {
54
- result[key] = [];
55
- } else if (value !== null) {
56
- result[key] = Default.build(value);
57
- }
58
- break;
59
- default:
60
- result[key] = null;
61
- }
62
- }
63
- return result;
27
+ credentials: {
28
+ page: 1,
29
+ limit: 10,
30
+ order: { createdAt: "desc" }
31
+ },
32
+ pagination: {
33
+ content: [],
34
+ total: 0,
35
+ totalPage: 0
64
36
  }
65
37
  };
66
38
  var default_default = Default;
@@ -1,32 +1,14 @@
1
1
  // src/default/index.ts
2
- import _ from "lodash";
3
2
  var Default = {
4
- build(schema) {
5
- const result = {};
6
- for (const key in schema) {
7
- const value = schema[key];
8
- switch (typeof value) {
9
- case "string":
10
- result[key] = "";
11
- break;
12
- case "number":
13
- result[key] = 0;
14
- break;
15
- case "boolean":
16
- result[key] = "";
17
- break;
18
- case "object":
19
- if (_.isArray(value)) {
20
- result[key] = [];
21
- } else if (value !== null) {
22
- result[key] = Default.build(value);
23
- }
24
- break;
25
- default:
26
- result[key] = null;
27
- }
28
- }
29
- return result;
3
+ credentials: {
4
+ page: 1,
5
+ limit: 10,
6
+ order: { createdAt: "desc" }
7
+ },
8
+ pagination: {
9
+ content: [],
10
+ total: 0,
11
+ totalPage: 0
30
12
  }
31
13
  };
32
14
  var default_default = Default;
@@ -3,6 +3,7 @@ declare const Format: {
3
3
  address(data: any): string;
4
4
  match(value: any): string | any[];
5
5
  money: (value: any, notSign?: boolean) => string;
6
+ cssProperties: (styles: any) => any;
6
7
  };
7
8
 
8
9
  export { Format as default };
@@ -3,6 +3,7 @@ declare const Format: {
3
3
  address(data: any): string;
4
4
  match(value: any): string | any[];
5
5
  money: (value: any, notSign?: boolean) => string;
6
+ cssProperties: (styles: any) => any;
6
7
  };
7
8
 
8
9
  export { Format as default };
@@ -60,6 +60,18 @@ var Format = {
60
60
  return new Intl.NumberFormat(locale, { style: "currency", currency: "BRL" }).format(value);
61
61
  }
62
62
  return new Intl.NumberFormat(locale, { minimumFractionDigits: 2 }).format(value);
63
+ },
64
+ cssProperties: (styles) => {
65
+ var _a, _b;
66
+ if (!styles) return {};
67
+ if (styles == null ? void 0 : styles.componentStyle) styles = ((_b = (_a = styles == null ? void 0 : styles.componentStyle) == null ? void 0 : _a.rules) == null ? void 0 : _b.join("\n")) || "";
68
+ const style = {};
69
+ styles.split(";").forEach((rule) => {
70
+ const [property, value] = rule.split(":").map((p) => p == null ? void 0 : p.trim());
71
+ if (!property || !value) return;
72
+ style[import_lodash.default.camelCase(property)] = value;
73
+ });
74
+ return style;
63
75
  }
64
76
  };
65
77
  var format_default = Format;
@@ -26,6 +26,18 @@ var Format = {
26
26
  return new Intl.NumberFormat(locale, { style: "currency", currency: "BRL" }).format(value);
27
27
  }
28
28
  return new Intl.NumberFormat(locale, { minimumFractionDigits: 2 }).format(value);
29
+ },
30
+ cssProperties: (styles) => {
31
+ var _a, _b;
32
+ if (!styles) return {};
33
+ if (styles == null ? void 0 : styles.componentStyle) styles = ((_b = (_a = styles == null ? void 0 : styles.componentStyle) == null ? void 0 : _a.rules) == null ? void 0 : _b.join("\n")) || "";
34
+ const style = {};
35
+ styles.split(";").forEach((rule) => {
36
+ const [property, value] = rule.split(":").map((p) => p == null ? void 0 : p.trim());
37
+ if (!property || !value) return;
38
+ style[_.camelCase(property)] = value;
39
+ });
40
+ return style;
29
41
  }
30
42
  };
31
43
  var format_default = Format;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- import { DefaultValue } from './src/default/index.mjs';
2
1
  import * as moment from 'moment';
3
2
 
4
3
  declare class Utils {
@@ -8,6 +7,7 @@ declare class Utils {
8
7
  address(data: any): string;
9
8
  match(value: any): string | any[];
10
9
  money: (value: any, notSign?: boolean) => string;
10
+ cssProperties: (styles: any) => any;
11
11
  };
12
12
  static mask: {
13
13
  docNumber: (value: any) => any;
@@ -31,8 +31,19 @@ declare class Utils {
31
31
  number: (value: any) => any;
32
32
  };
33
33
  static default: {
34
- build<T>(schema: T): DefaultValue<T>;
34
+ credentials: {
35
+ page: number;
36
+ limit: number;
37
+ order: {
38
+ createdAt: string;
39
+ };
40
+ };
41
+ pagination: {
42
+ content: never[];
43
+ total: number;
44
+ totalPage: number;
45
+ };
35
46
  };
36
47
  }
37
48
 
38
- export { DefaultValue, Utils as default };
49
+ export { Utils as default };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { DefaultValue } from './src/default/index.js';
2
1
  import * as moment from 'moment';
3
2
 
4
3
  declare class Utils {
@@ -8,6 +7,7 @@ declare class Utils {
8
7
  address(data: any): string;
9
8
  match(value: any): string | any[];
10
9
  money: (value: any, notSign?: boolean) => string;
10
+ cssProperties: (styles: any) => any;
11
11
  };
12
12
  static mask: {
13
13
  docNumber: (value: any) => any;
@@ -31,8 +31,19 @@ declare class Utils {
31
31
  number: (value: any) => any;
32
32
  };
33
33
  static default: {
34
- build<T>(schema: T): DefaultValue<T>;
34
+ credentials: {
35
+ page: number;
36
+ limit: number;
37
+ order: {
38
+ createdAt: string;
39
+ };
40
+ };
41
+ pagination: {
42
+ content: never[];
43
+ total: number;
44
+ totalPage: number;
45
+ };
35
46
  };
36
47
  }
37
48
 
38
- export { DefaultValue, Utils as default };
49
+ export { Utils as default };
package/dist/index.js CHANGED
@@ -70,6 +70,18 @@ var Format = {
70
70
  return new Intl.NumberFormat(locale, { style: "currency", currency: "BRL" }).format(value);
71
71
  }
72
72
  return new Intl.NumberFormat(locale, { minimumFractionDigits: 2 }).format(value);
73
+ },
74
+ cssProperties: (styles) => {
75
+ var _a, _b;
76
+ if (!styles) return {};
77
+ if (styles == null ? void 0 : styles.componentStyle) styles = ((_b = (_a = styles == null ? void 0 : styles.componentStyle) == null ? void 0 : _a.rules) == null ? void 0 : _b.join("\n")) || "";
78
+ const style = {};
79
+ styles.split(";").forEach((rule) => {
80
+ const [property, value] = rule.split(":").map((p) => p == null ? void 0 : p.trim());
81
+ if (!property || !value) return;
82
+ style[import_lodash.default.camelCase(property)] = value;
83
+ });
84
+ return style;
73
85
  }
74
86
  };
75
87
  var format_default = Format;
@@ -196,34 +208,16 @@ var RemoveMask = {
196
208
  var remove_mask_default = RemoveMask;
197
209
 
198
210
  // src/default/index.ts
199
- var import_lodash3 = __toESM(require("lodash"));
200
211
  var Default = {
201
- build(schema) {
202
- const result = {};
203
- for (const key in schema) {
204
- const value = schema[key];
205
- switch (typeof value) {
206
- case "string":
207
- result[key] = "";
208
- break;
209
- case "number":
210
- result[key] = 0;
211
- break;
212
- case "boolean":
213
- result[key] = "";
214
- break;
215
- case "object":
216
- if (import_lodash3.default.isArray(value)) {
217
- result[key] = [];
218
- } else if (value !== null) {
219
- result[key] = Default.build(value);
220
- }
221
- break;
222
- default:
223
- result[key] = null;
224
- }
225
- }
226
- return result;
212
+ credentials: {
213
+ page: 1,
214
+ limit: 10,
215
+ order: { createdAt: "desc" }
216
+ },
217
+ pagination: {
218
+ content: [],
219
+ total: 0,
220
+ totalPage: 0
227
221
  }
228
222
  };
229
223
  var default_default = Default;
package/dist/index.mjs CHANGED
@@ -34,6 +34,18 @@ var Format = {
34
34
  return new Intl.NumberFormat(locale, { style: "currency", currency: "BRL" }).format(value);
35
35
  }
36
36
  return new Intl.NumberFormat(locale, { minimumFractionDigits: 2 }).format(value);
37
+ },
38
+ cssProperties: (styles) => {
39
+ var _a, _b;
40
+ if (!styles) return {};
41
+ if (styles == null ? void 0 : styles.componentStyle) styles = ((_b = (_a = styles == null ? void 0 : styles.componentStyle) == null ? void 0 : _a.rules) == null ? void 0 : _b.join("\n")) || "";
42
+ const style = {};
43
+ styles.split(";").forEach((rule) => {
44
+ const [property, value] = rule.split(":").map((p) => p == null ? void 0 : p.trim());
45
+ if (!property || !value) return;
46
+ style[_.camelCase(property)] = value;
47
+ });
48
+ return style;
37
49
  }
38
50
  };
39
51
  var format_default = Format;
@@ -160,34 +172,16 @@ var RemoveMask = {
160
172
  var remove_mask_default = RemoveMask;
161
173
 
162
174
  // src/default/index.ts
163
- import _3 from "lodash";
164
175
  var Default = {
165
- build(schema) {
166
- const result = {};
167
- for (const key in schema) {
168
- const value = schema[key];
169
- switch (typeof value) {
170
- case "string":
171
- result[key] = "";
172
- break;
173
- case "number":
174
- result[key] = 0;
175
- break;
176
- case "boolean":
177
- result[key] = "";
178
- break;
179
- case "object":
180
- if (_3.isArray(value)) {
181
- result[key] = [];
182
- } else if (value !== null) {
183
- result[key] = Default.build(value);
184
- }
185
- break;
186
- default:
187
- result[key] = null;
188
- }
189
- }
190
- return result;
176
+ credentials: {
177
+ page: 1,
178
+ limit: 10,
179
+ order: { createdAt: "desc" }
180
+ },
181
+ pagination: {
182
+ content: [],
183
+ total: 0,
184
+ totalPage: 0
191
185
  }
192
186
  };
193
187
  var default_default = Default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/utils",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",