@win2win/shared 1.0.0 → 1.0.2

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/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # README #
2
+ version 1.0.1
3
+
4
+ ### Como hacer deploy del repo
5
+
6
+ * Correr el comando
7
+ `npm run deploy`
8
+
9
+
package/dist/index.d.ts CHANGED
@@ -1,4 +1 @@
1
- export interface MyInterface {
2
- id: number;
3
- name: string;
4
- }
1
+ export * from './interfaces';
package/dist/index.js CHANGED
@@ -1,2 +1,17 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./interfaces"), exports);
@@ -0,0 +1 @@
1
+ export * from './props';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./props"), exports);
@@ -0,0 +1,9 @@
1
+ export type GamaPropControlCondition = {
2
+ id: number | null;
3
+ logic: 'AND' | 'OR';
4
+ children: GamaPropControlCondition[];
5
+ operator: GamaPropConditionOperator;
6
+ value: any;
7
+ };
8
+ export declare const OPERATORS: readonly ["==", "!=", ">", "<", ">=", "<=", "contains", "not_contains", "in", "not_in"];
9
+ export type GamaPropConditionOperator = (typeof OPERATORS)[number];
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OPERATORS = void 0;
4
+ exports.OPERATORS = ['==', '!=', '>', '<', '>=', '<=', 'contains', 'not_contains', 'in', 'not_in'];
@@ -0,0 +1,64 @@
1
+ export declare const GAMA_PROP_CONTROL_TYPES: readonly [{
2
+ readonly code: "input_text";
3
+ readonly icon: "title";
4
+ readonly label: "Texto";
5
+ }, {
6
+ readonly code: "input_number";
7
+ readonly icon: "o_looks_one";
8
+ readonly label: "Número";
9
+ }, {
10
+ readonly code: "datetime";
11
+ readonly icon: "event";
12
+ readonly label: "Fecha y hora";
13
+ }, {
14
+ readonly code: "date";
15
+ readonly icon: "calendar_today";
16
+ readonly label: "Fecha";
17
+ }, {
18
+ readonly code: "time";
19
+ readonly icon: "schedule";
20
+ readonly label: "Hora";
21
+ }, {
22
+ readonly code: "switch";
23
+ readonly icon: "toggle_on";
24
+ readonly label: "Switch";
25
+ }, {
26
+ readonly code: "checkbox";
27
+ readonly icon: "o_check_box";
28
+ readonly label: "Checkbox";
29
+ }, {
30
+ readonly code: "select";
31
+ readonly icon: "list";
32
+ readonly label: "Selector simple";
33
+ }, {
34
+ readonly code: "cards_select";
35
+ readonly icon: "grid_view";
36
+ readonly label: "Selector de tarjetas";
37
+ }, {
38
+ readonly code: "location";
39
+ readonly icon: "location_on";
40
+ readonly label: "Ubicación";
41
+ }, {
42
+ readonly code: "dynamic_array";
43
+ readonly icon: "data_array";
44
+ readonly label: "Colección dinámica";
45
+ }, {
46
+ readonly code: "object";
47
+ readonly icon: "data_object";
48
+ readonly label: "Objeto";
49
+ }];
50
+ export type GamaPropControlCode = (typeof GAMA_PROP_CONTROL_TYPES)[number]['code'];
51
+ export declare enum ControlType {
52
+ TEXT = "input_text",
53
+ NUMBER = "input_number",
54
+ DATETIME = "datetime",
55
+ DATE = "date",
56
+ TIME = "time",
57
+ SWITCH = "switch",
58
+ CHECKBOX = "checkbox",
59
+ SELECT = "select",
60
+ CARDS_SELECT = "cards_select",
61
+ LOCATION = "location",
62
+ DYNAMIC_ARRAY = "dynamic_array",
63
+ OBJECT = "object"
64
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ControlType = exports.GAMA_PROP_CONTROL_TYPES = void 0;
4
+ exports.GAMA_PROP_CONTROL_TYPES = [
5
+ { code: 'input_text', icon: 'title', label: 'Texto' },
6
+ { code: 'input_number', icon: 'o_looks_one', label: 'Número' },
7
+ { code: 'datetime', icon: 'event', label: 'Fecha y hora' },
8
+ { code: 'date', icon: 'calendar_today', label: 'Fecha' },
9
+ { code: 'time', icon: 'schedule', label: 'Hora' },
10
+ { code: 'switch', icon: 'toggle_on', label: 'Switch' },
11
+ { code: 'checkbox', icon: 'o_check_box', label: 'Checkbox' },
12
+ { code: 'select', icon: 'list', label: 'Selector simple' },
13
+ { code: 'cards_select', icon: 'grid_view', label: 'Selector de tarjetas' },
14
+ { code: 'location', icon: 'location_on', label: 'Ubicación' },
15
+ { code: 'dynamic_array', icon: 'data_array', label: 'Colección dinámica' },
16
+ { code: 'object', icon: 'data_object', label: 'Objeto' },
17
+ ];
18
+ var ControlType;
19
+ (function (ControlType) {
20
+ ControlType["TEXT"] = "input_text";
21
+ ControlType["NUMBER"] = "input_number";
22
+ ControlType["DATETIME"] = "datetime";
23
+ ControlType["DATE"] = "date";
24
+ ControlType["TIME"] = "time";
25
+ ControlType["SWITCH"] = "switch";
26
+ ControlType["CHECKBOX"] = "checkbox";
27
+ ControlType["SELECT"] = "select";
28
+ ControlType["CARDS_SELECT"] = "cards_select";
29
+ ControlType["LOCATION"] = "location";
30
+ ControlType["DYNAMIC_ARRAY"] = "dynamic_array";
31
+ ControlType["OBJECT"] = "object";
32
+ })(ControlType || (exports.ControlType = ControlType = {}));
@@ -0,0 +1,32 @@
1
+ import { GamaPropControlCode } from "./control-types";
2
+ import { GamaPropMapper } from "./mappers";
3
+ import { GamaPropOption } from "./options";
4
+ import { GamaPropValidator } from "./validators";
5
+ import { GamaPropVisibility } from "./visibility";
6
+ export interface GamaProp {
7
+ id: string;
8
+ controlType: GamaPropControlCode;
9
+ label: string;
10
+ validators: GamaPropValidator[];
11
+ code: string;
12
+ multiple: boolean;
13
+ visibility: GamaPropVisibility;
14
+ structure?: GamaProp[];
15
+ image?: Image | null;
16
+ suffix?: string;
17
+ prefix?: string;
18
+ options?: GamaPropOption[];
19
+ mappers?: GamaPropMapper[];
20
+ }
21
+ export type GamaPropModel = GamaProp & {
22
+ value: any;
23
+ };
24
+ export interface Image {
25
+ src: string;
26
+ }
27
+ export * from "./conditions";
28
+ export * from "./control-types";
29
+ export * from "./mappers";
30
+ export * from "./options";
31
+ export * from "./validators";
32
+ export * from "./visibility";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./conditions"), exports);
18
+ __exportStar(require("./control-types"), exports);
19
+ __exportStar(require("./mappers"), exports);
20
+ __exportStar(require("./options"), exports);
21
+ __exportStar(require("./validators"), exports);
22
+ __exportStar(require("./visibility"), exports);
@@ -0,0 +1,7 @@
1
+ export interface GamaPropMapper {
2
+ table: string;
3
+ value: GamaPropMapperValue[];
4
+ idKey?: string;
5
+ mapEachItem?: boolean;
6
+ }
7
+ export type GamaPropMapperValue = [column: string, value: string];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ export type GamaPropOption = {
2
+ label: string;
3
+ value: string;
4
+ exclusive: boolean;
5
+ image: null | {
6
+ src: string;
7
+ };
8
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,25 @@
1
+ import { GamaPropModel } from "..";
2
+ export declare const GamaPropValidatorsMap: Record<string, {
3
+ fn: (val: number) => (control: GamaPropModel) => boolean;
4
+ message: string;
5
+ label: string;
6
+ }>;
7
+ export declare enum PropValidatorKeys {
8
+ REQUERIDO = "required",
9
+ MINIMO = "min",
10
+ MAXIMO = "max",
11
+ SOLO_NUMEROS = "onlyNumbers",
12
+ EMAIL = "email",
13
+ URL = "url"
14
+ }
15
+ export declare const VALIDATORS: {
16
+ fn: (val: number) => (control: GamaPropModel) => boolean;
17
+ message: string;
18
+ label: string;
19
+ value: string;
20
+ }[];
21
+ export type Validator = keyof typeof GamaPropValidatorsMap;
22
+ export type GamaPropValidator = {
23
+ validator: Validator;
24
+ param?: string | number;
25
+ };
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VALIDATORS = exports.PropValidatorKeys = exports.GamaPropValidatorsMap = void 0;
4
+ exports.GamaPropValidatorsMap = {
5
+ required: {
6
+ fn: () => (control) => {
7
+ return control.value !== null && control.value !== undefined && control.value !== '';
8
+ },
9
+ message: 'Este campo es requerido',
10
+ label: 'Requerido',
11
+ },
12
+ min: {
13
+ fn: (min) => (control) => {
14
+ if (typeof control.value === 'number') {
15
+ return (control.value || 0) >= min;
16
+ }
17
+ if (typeof control.value === 'string') {
18
+ const value = control.value || '';
19
+ if (control.multiple) {
20
+ const array = value.split(',');
21
+ return array.length >= min;
22
+ }
23
+ else {
24
+ return value.length >= min;
25
+ }
26
+ }
27
+ return false;
28
+ },
29
+ message: 'El valor es menor al mínimo permitido',
30
+ label: 'Mínimo',
31
+ },
32
+ max: {
33
+ fn: (max) => (control) => {
34
+ if (typeof control.value === 'number') {
35
+ return (control.value || 0) <= max;
36
+ }
37
+ if (typeof control.value === 'string') {
38
+ const value = control.value || '';
39
+ if (control.multiple) {
40
+ const array = value.split(',');
41
+ return array.length <= max;
42
+ }
43
+ else {
44
+ return (value || '').length <= max;
45
+ }
46
+ }
47
+ return false;
48
+ },
49
+ message: 'El valor es mayor al máximo permitido',
50
+ label: 'Máximo',
51
+ },
52
+ onlyNumbers: {
53
+ fn: () => (control) => {
54
+ return /^[0-9]*$/.test(String(control.value) || '');
55
+ },
56
+ message: 'Este campo solo acepta números',
57
+ label: 'Solo números',
58
+ },
59
+ email: {
60
+ fn: () => (control) => {
61
+ if (!control.value)
62
+ return true;
63
+ return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(control.value) || '');
64
+ },
65
+ message: 'El correo electrónico no es válido',
66
+ label: 'Correo electrónico',
67
+ },
68
+ url: {
69
+ fn: () => (control) => {
70
+ if (!control.value)
71
+ return true;
72
+ return /^(ftp|http|https):\/\/[^ "]+$/.test(String(control.value) || '') || /^www\.[^ "]+$/.test(String(control.value) || '');
73
+ },
74
+ message: 'La URL no es válida',
75
+ label: 'URL',
76
+ },
77
+ // minLength: (length: number) => (control: FormControlModel) => {},
78
+ // maxLength: (length: number) => (control: FormControlModel) => {},
79
+ };
80
+ var PropValidatorKeys;
81
+ (function (PropValidatorKeys) {
82
+ PropValidatorKeys["REQUERIDO"] = "required";
83
+ PropValidatorKeys["MINIMO"] = "min";
84
+ PropValidatorKeys["MAXIMO"] = "max";
85
+ PropValidatorKeys["SOLO_NUMEROS"] = "onlyNumbers";
86
+ PropValidatorKeys["EMAIL"] = "email";
87
+ PropValidatorKeys["URL"] = "url";
88
+ })(PropValidatorKeys || (exports.PropValidatorKeys = PropValidatorKeys = {}));
89
+ exports.VALIDATORS = Object.entries(exports.GamaPropValidatorsMap).map(([key, value]) => ({ value: key, ...value }));
@@ -0,0 +1,7 @@
1
+ export interface GamaPropVisibility {
2
+ summary: boolean;
3
+ detail: boolean;
4
+ form: boolean;
5
+ public: boolean;
6
+ roles: number[];
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@win2win/shared",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
- "build": "tsc"
8
+ "build": "tsc",
9
+ "deploy": "tsc && npm publish --access public"
9
10
  },
10
11
  "keywords": [],
11
12
  "author": "win2win",
package/readme.md ADDED
File without changes