@htmlplus/element 0.5.7 → 0.5.9
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/client/decorators/element.js +12 -5
- package/client/decorators/property.d.ts +4 -0
- package/client/decorators/property.js +3 -2
- package/client/utils/addMember.d.ts +2 -0
- package/client/utils/addMember.js +6 -0
- package/client/utils/fromAttribute.d.ts +1 -0
- package/client/utils/fromAttribute.js +53 -0
- package/client/utils/getMembers.js +1 -1
- package/client/utils/index.d.ts +2 -1
- package/client/utils/index.js +2 -1
- package/compiler/compiler.js +9 -2
- package/compiler/plugins/customElement.js +79 -39
- package/compiler/utils/getType.d.ts +2 -2
- package/compiler/utils/getType.js +18 -12
- package/constants/index.d.ts +10 -5
- package/constants/index.js +10 -5
- package/package.json +1 -1
- package/client/utils/parseValue.d.ts +0 -1
- package/client/utils/parseValue.js +0 -15
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import { camelCase, paramCase } from 'change-case';
|
|
2
2
|
import * as CONSTANTS from '../../constants/index.js';
|
|
3
|
-
import { call, getMembers, isServer,
|
|
3
|
+
import { call, fromAttribute, getMembers, isServer, request } from '../utils/index.js';
|
|
4
4
|
export function Element(tag) {
|
|
5
5
|
return function (constructor) {
|
|
6
6
|
if (isServer())
|
|
7
7
|
return;
|
|
8
8
|
if (customElements.get(tag))
|
|
9
9
|
return;
|
|
10
|
+
const members = getMembers(constructor);
|
|
10
11
|
class Plus extends HTMLElement {
|
|
11
12
|
constructor() {
|
|
12
13
|
super();
|
|
13
14
|
this.attachShadow({ mode: 'open' });
|
|
14
15
|
this[CONSTANTS.API_INSTANCE] = new constructor();
|
|
16
|
+
Object.keys(members)
|
|
17
|
+
.filter((key) => members[key].type != CONSTANTS.TYPE_FUNCTION)
|
|
18
|
+
.forEach((key) => {
|
|
19
|
+
members[key].default = this[CONSTANTS.API_INSTANCE][key];
|
|
20
|
+
});
|
|
15
21
|
this[CONSTANTS.API_INSTANCE][CONSTANTS.API_HOST] = () => this;
|
|
16
22
|
}
|
|
17
|
-
// TODO: ignore functions
|
|
18
23
|
static get observedAttributes() {
|
|
19
|
-
return Object.keys(
|
|
24
|
+
return Object.keys(members)
|
|
25
|
+
.filter((key) => members[key].type != CONSTANTS.TYPE_FUNCTION)
|
|
26
|
+
.map((key) => paramCase(key));
|
|
20
27
|
}
|
|
21
28
|
adoptedCallback() {
|
|
22
29
|
call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_ADOPTED);
|
|
@@ -27,8 +34,8 @@ export function Element(tag) {
|
|
|
27
34
|
if (instance[CONSTANTS.API_LOCKED])
|
|
28
35
|
return;
|
|
29
36
|
const name = camelCase(attribute);
|
|
30
|
-
const type = (_a =
|
|
31
|
-
const value =
|
|
37
|
+
const type = (_a = members[name]) === null || _a === void 0 ? void 0 : _a.type;
|
|
38
|
+
const value = fromAttribute(next, type);
|
|
32
39
|
if (instance[name] === value)
|
|
33
40
|
return;
|
|
34
41
|
instance[name] = value;
|
|
@@ -4,5 +4,9 @@ export interface PropertyOptions {
|
|
|
4
4
|
* Whether property value is reflected back to the associated attribute. default is `false`.
|
|
5
5
|
*/
|
|
6
6
|
reflect?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* TODO
|
|
9
|
+
*/
|
|
10
|
+
type?: number;
|
|
7
11
|
}
|
|
8
12
|
export declare function Property(options?: PropertyOptions): (target: PlusElement, propertyKey: PropertyKey) => void;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as CONSTANTS from '../../constants/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { addMember, appendToMethod, defineProperty, getConfig, getMembers, getTag, host, request, updateAttribute } from '../utils/index.js';
|
|
3
3
|
export function Property(options) {
|
|
4
4
|
return function (target, propertyKey) {
|
|
5
5
|
const name = String(propertyKey);
|
|
6
6
|
const symbol = Symbol();
|
|
7
|
+
addMember(target.constructor, name, options);
|
|
7
8
|
function get() {
|
|
8
9
|
return this[symbol];
|
|
9
10
|
}
|
|
@@ -25,7 +26,7 @@ export function Property(options) {
|
|
|
25
26
|
var _a;
|
|
26
27
|
const element = host(this);
|
|
27
28
|
// TODO: experimental for global config
|
|
28
|
-
if (((_a = getMembers(this)[name]) === null || _a === void 0 ? void 0 : _a.default) === this[name]) {
|
|
29
|
+
if (((_a = getMembers(this.constructor)[name]) === null || _a === void 0 ? void 0 : _a.default) === this[name]) {
|
|
29
30
|
const config = getConfig('component', getTag(target), 'property', name);
|
|
30
31
|
if (typeof config != 'undefined')
|
|
31
32
|
this[name] = config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fromAttribute: (input: any, type: any) => any;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as CONSTANTS from '../../constants/index.js';
|
|
2
|
+
import { typeOf } from './typeOf.js';
|
|
3
|
+
export const fromAttribute = (input, type) => {
|
|
4
|
+
const string = `${input}`;
|
|
5
|
+
if (CONSTANTS.TYPE_BOOLEAN & type) {
|
|
6
|
+
if (string === '')
|
|
7
|
+
return true;
|
|
8
|
+
if (string === 'false')
|
|
9
|
+
return false;
|
|
10
|
+
if (string === 'true')
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (CONSTANTS.TYPE_NUMBER & type) {
|
|
14
|
+
if (string != '' && !isNaN(input)) {
|
|
15
|
+
return parseFloat(input);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (CONSTANTS.TYPE_NULL & type) {
|
|
19
|
+
if (string === 'null') {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (CONSTANTS.TYPE_DATE & type) {
|
|
24
|
+
const value = new Date(input);
|
|
25
|
+
if (value.toString() != 'Invalid Date') {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (CONSTANTS.TYPE_ARRAY & type) {
|
|
30
|
+
try {
|
|
31
|
+
const value = JSON.parse(input);
|
|
32
|
+
if (typeOf(value) == 'array') {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (_a) { }
|
|
37
|
+
}
|
|
38
|
+
if (CONSTANTS.TYPE_OBJECT & type) {
|
|
39
|
+
try {
|
|
40
|
+
const value = JSON.parse(input);
|
|
41
|
+
if (typeOf(value) == 'object') {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (_b) { }
|
|
46
|
+
}
|
|
47
|
+
if (CONSTANTS.TYPE_UNDEFINED & type) {
|
|
48
|
+
if (string === 'undefined') {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return input;
|
|
53
|
+
};
|
package/client/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
export * from './addMember.js';
|
|
1
2
|
export * from './appendToMethod.js';
|
|
2
3
|
export * from './call.js';
|
|
3
4
|
export * from './config.js';
|
|
4
5
|
export * from './defineProperty.js';
|
|
6
|
+
export * from './fromAttribute.js';
|
|
5
7
|
export * from './getFramework.js';
|
|
6
8
|
export * from './getMembers.js';
|
|
7
9
|
export * from './getStyles.js';
|
|
@@ -11,7 +13,6 @@ export * from './isEvent.js';
|
|
|
11
13
|
export * from './isServer.js';
|
|
12
14
|
export * from './off.js';
|
|
13
15
|
export * from './on.js';
|
|
14
|
-
export * from './parseValue.js';
|
|
15
16
|
export * from './request.js';
|
|
16
17
|
export * from './shadowRoot.js';
|
|
17
18
|
export * from './syncAttributes.js';
|
package/client/utils/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
export * from './addMember.js';
|
|
1
2
|
export * from './appendToMethod.js';
|
|
2
3
|
export * from './call.js';
|
|
3
4
|
export * from './config.js';
|
|
4
5
|
export * from './defineProperty.js';
|
|
6
|
+
export * from './fromAttribute.js';
|
|
5
7
|
export * from './getFramework.js';
|
|
6
8
|
export * from './getMembers.js';
|
|
7
9
|
export * from './getStyles.js';
|
|
@@ -11,7 +13,6 @@ export * from './isEvent.js';
|
|
|
11
13
|
export * from './isServer.js';
|
|
12
14
|
export * from './off.js';
|
|
13
15
|
export * from './on.js';
|
|
14
|
-
export * from './parseValue.js';
|
|
15
16
|
export * from './request.js';
|
|
16
17
|
export * from './shadowRoot.js';
|
|
17
18
|
export * from './syncAttributes.js';
|
package/compiler/compiler.js
CHANGED
|
@@ -29,11 +29,18 @@ export const compiler = (...plugins) => {
|
|
|
29
29
|
let context = {
|
|
30
30
|
filePath
|
|
31
31
|
};
|
|
32
|
+
const parsed = path.parse(filePath);
|
|
32
33
|
for (const plugin of plugins) {
|
|
33
34
|
if (!plugin.run)
|
|
34
35
|
continue;
|
|
35
|
-
log(`Plugin '${plugin.name}' is executing on '${path.basename(
|
|
36
|
-
|
|
36
|
+
log(`Plugin '${plugin.name}' is executing on '${path.basename(parsed.dir)}/${parsed.base}' file.`);
|
|
37
|
+
try {
|
|
38
|
+
context = (await plugin.run(context, global)) || context;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
log(`Error in '${plugin.name}' plugin on '${path.basename(parsed.dir)}/${parsed.base}' file.`, true);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
37
44
|
global.contexts = global.contexts
|
|
38
45
|
.filter((current) => {
|
|
39
46
|
return current.filePath != context.filePath;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import t from '@babel/types';
|
|
2
2
|
import { pascalCase } from 'change-case';
|
|
3
3
|
import * as CONSTANTS from '../../constants/index.js';
|
|
4
|
-
import { addDependency, print, visitor } from '../utils/index.js';
|
|
4
|
+
import { addDependency, getType, print, visitor } from '../utils/index.js';
|
|
5
5
|
export const CUSTOM_ELEMENT_OPTIONS = {
|
|
6
6
|
// prefix: undefined,
|
|
7
7
|
typings: true
|
|
@@ -98,47 +98,87 @@ export const customElement = (options) => {
|
|
|
98
98
|
t.addComment(node, 'leading', CONSTANTS.COMMENT_AUTO_ADDED_DEPENDENCY, true);
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
-
//
|
|
101
|
+
// adds type to properties
|
|
102
102
|
visitor(ast, {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
Decorator(path) {
|
|
104
|
+
var _a, _b;
|
|
105
|
+
const { expression } = path.node;
|
|
106
|
+
if (((_a = expression.callee) === null || _a === void 0 ? void 0 : _a.name) != CONSTANTS.DECORATOR_PROPERTY)
|
|
106
107
|
return;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
108
|
+
let type = 0;
|
|
109
|
+
const extract = (input) => {
|
|
110
|
+
switch (input === null || input === void 0 ? void 0 : input.type) {
|
|
111
|
+
case 'BooleanLiteral':
|
|
112
|
+
type |= CONSTANTS.TYPE_BOOLEAN;
|
|
113
|
+
break;
|
|
114
|
+
case 'NumericLiteral':
|
|
115
|
+
type |= CONSTANTS.TYPE_NUMBER;
|
|
116
|
+
break;
|
|
117
|
+
case 'StringLiteral':
|
|
118
|
+
type |= CONSTANTS.TYPE_ENUM;
|
|
119
|
+
break;
|
|
120
|
+
case 'TSArrayType':
|
|
121
|
+
type |= CONSTANTS.TYPE_ARRAY;
|
|
122
|
+
break;
|
|
123
|
+
case 'TSBooleanKeyword':
|
|
124
|
+
type |= CONSTANTS.TYPE_BOOLEAN;
|
|
125
|
+
break;
|
|
126
|
+
case 'TSLiteralType':
|
|
127
|
+
extract(input.literal);
|
|
128
|
+
break;
|
|
129
|
+
case 'TSNullKeyword':
|
|
130
|
+
type |= CONSTANTS.TYPE_NULL;
|
|
131
|
+
break;
|
|
132
|
+
case 'TSNumberKeyword':
|
|
133
|
+
type |= CONSTANTS.TYPE_NUMBER;
|
|
134
|
+
break;
|
|
135
|
+
case 'TSObjectKeyword':
|
|
136
|
+
type |= CONSTANTS.TYPE_OBJECT;
|
|
137
|
+
break;
|
|
138
|
+
case 'TSStringKeyword':
|
|
139
|
+
type |= CONSTANTS.TYPE_STRING;
|
|
140
|
+
break;
|
|
141
|
+
case 'TSTypeLiteral':
|
|
142
|
+
type |= CONSTANTS.TYPE_OBJECT;
|
|
143
|
+
break;
|
|
144
|
+
case 'TSTypeReference':
|
|
145
|
+
if (!input.typeName)
|
|
146
|
+
break;
|
|
147
|
+
switch (input.typeName.name) {
|
|
148
|
+
case 'Array':
|
|
149
|
+
type |= CONSTANTS.TYPE_ARRAY;
|
|
150
|
+
break;
|
|
151
|
+
case 'Boolean':
|
|
152
|
+
type |= CONSTANTS.TYPE_BOOLEAN;
|
|
153
|
+
break;
|
|
154
|
+
case 'bool':
|
|
155
|
+
type |= CONSTANTS.TYPE_BOOLEAN;
|
|
156
|
+
break;
|
|
157
|
+
case 'Date':
|
|
158
|
+
type |= CONSTANTS.TYPE_DATE;
|
|
159
|
+
break;
|
|
160
|
+
case 'Number':
|
|
161
|
+
type |= CONSTANTS.TYPE_NUMBER;
|
|
162
|
+
break;
|
|
163
|
+
case 'Object':
|
|
164
|
+
type |= CONSTANTS.TYPE_OBJECT;
|
|
165
|
+
break;
|
|
123
166
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
]), undefined, undefined, undefined, true);
|
|
140
|
-
t.addComment(node, 'leading', CONSTANTS.COMMENT_AUTO_ADDED_PROPERTY, true);
|
|
141
|
-
body.body.unshift(node);
|
|
167
|
+
break;
|
|
168
|
+
case 'TSUnionType':
|
|
169
|
+
input.types.forEach(extract);
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
extract(getType(ast, (_b = path.parentPath.node.typeAnnotation) === null || _b === void 0 ? void 0 : _b.typeAnnotation, { directory: context.directoryPath }));
|
|
174
|
+
if (!expression.arguments.length) {
|
|
175
|
+
expression.arguments.push(t.objectExpression([]));
|
|
176
|
+
}
|
|
177
|
+
const [argument] = expression.arguments;
|
|
178
|
+
argument.properties = argument.properties.filter((property) => {
|
|
179
|
+
return property.key.name != CONSTANTS.STATIC_MEMBERS_TYPE;
|
|
180
|
+
});
|
|
181
|
+
argument.properties.push(t.objectProperty(t.identifier(CONSTANTS.STATIC_MEMBERS_TYPE), t.numericLiteral(type)));
|
|
142
182
|
}
|
|
143
183
|
});
|
|
144
184
|
// attaches typings
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { File } from '@babel/types';
|
|
2
|
-
export declare const getType: (file: File, node:
|
|
1
|
+
import { File, Node } from '@babel/types';
|
|
2
|
+
export declare const getType: (file: File, node: Node, options: any) => any;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { parse } from '@babel/parser';
|
|
2
|
+
import glob from 'fast-glob';
|
|
2
3
|
import fs from 'fs-extra';
|
|
3
4
|
import { dirname, resolve } from 'path';
|
|
5
|
+
import { join } from 'path';
|
|
4
6
|
import { visitor } from './visitor.js';
|
|
5
7
|
// TODO: return type
|
|
6
8
|
export const getType = (file, node, options) => {
|
|
@@ -12,7 +14,7 @@ export const getType = (file, node, options) => {
|
|
|
12
14
|
let result;
|
|
13
15
|
visitor(file, {
|
|
14
16
|
ClassDeclaration(path) {
|
|
15
|
-
if (path.node.id.name != node.typeName
|
|
17
|
+
if (path.node.id.name != node.typeName['name'])
|
|
16
18
|
return;
|
|
17
19
|
result = path.node;
|
|
18
20
|
path.stop();
|
|
@@ -20,7 +22,7 @@ export const getType = (file, node, options) => {
|
|
|
20
22
|
ImportDeclaration(path) {
|
|
21
23
|
for (const specifier of path.node.specifiers) {
|
|
22
24
|
const alias = specifier.local.name;
|
|
23
|
-
if (alias != node.typeName
|
|
25
|
+
if (alias != node.typeName['name'])
|
|
24
26
|
continue;
|
|
25
27
|
let key;
|
|
26
28
|
switch (specifier.type) {
|
|
@@ -35,14 +37,18 @@ export const getType = (file, node, options) => {
|
|
|
35
37
|
break;
|
|
36
38
|
}
|
|
37
39
|
try {
|
|
40
|
+
const reference = glob
|
|
41
|
+
.sync(['.ts*', '/index.ts*'].map((key) => {
|
|
42
|
+
return join(directory, path.node.source.value).replace(/\\/g, '/') + key;
|
|
43
|
+
}))
|
|
44
|
+
.find((reference) => fs.existsSync(reference));
|
|
45
|
+
const content = fs.readFileSync(reference, 'utf8');
|
|
38
46
|
const filePath = resolve(directory, path.node.source.value + '.ts');
|
|
39
|
-
path.$ast =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
ranges: false
|
|
45
|
-
});
|
|
47
|
+
path.$ast || (path.$ast = parse(content, {
|
|
48
|
+
allowImportExportEverywhere: true,
|
|
49
|
+
plugins: ['typescript'],
|
|
50
|
+
ranges: false
|
|
51
|
+
}));
|
|
46
52
|
result = getType(path.$ast, node, {
|
|
47
53
|
directory: dirname(filePath)
|
|
48
54
|
});
|
|
@@ -53,15 +59,15 @@ export const getType = (file, node, options) => {
|
|
|
53
59
|
}
|
|
54
60
|
},
|
|
55
61
|
TSInterfaceDeclaration(path) {
|
|
56
|
-
if (path.node.id.name != node.typeName
|
|
62
|
+
if (path.node.id.name != node.typeName['name'])
|
|
57
63
|
return;
|
|
58
64
|
result = path.node;
|
|
59
65
|
path.stop();
|
|
60
66
|
},
|
|
61
67
|
TSTypeAliasDeclaration(path) {
|
|
62
|
-
if (path.node.id.name != node.typeName
|
|
68
|
+
if (path.node.id.name != node.typeName['name'])
|
|
63
69
|
return;
|
|
64
|
-
result = path.node;
|
|
70
|
+
result = path.node.typeAnnotation;
|
|
65
71
|
path.stop();
|
|
66
72
|
}
|
|
67
73
|
});
|
package/constants/index.d.ts
CHANGED
|
@@ -27,10 +27,15 @@ export declare const STATIC_MEMBERS_TYPE = "type";
|
|
|
27
27
|
export declare const STATIC_STYLES = "STYLES";
|
|
28
28
|
export declare const STATIC_TAG = "TAG";
|
|
29
29
|
export declare const STYLE_IMPORTED = "STYLE_IMPORTED";
|
|
30
|
-
export declare const
|
|
31
|
-
export declare const
|
|
32
|
-
export declare const
|
|
33
|
-
export declare const
|
|
34
|
-
export declare const
|
|
30
|
+
export declare const TYPE_ARRAY = 1;
|
|
31
|
+
export declare const TYPE_BOOLEAN = 2;
|
|
32
|
+
export declare const TYPE_DATE = 4;
|
|
33
|
+
export declare const TYPE_ENUM = 8;
|
|
34
|
+
export declare const TYPE_FUNCTION = 16;
|
|
35
|
+
export declare const TYPE_NULL = 32;
|
|
36
|
+
export declare const TYPE_NUMBER = 64;
|
|
37
|
+
export declare const TYPE_OBJECT = 128;
|
|
38
|
+
export declare const TYPE_STRING = 256;
|
|
39
|
+
export declare const TYPE_UNDEFINED = 512;
|
|
35
40
|
export declare const UTIL_STYLE_MAPPER = "styles";
|
|
36
41
|
export declare const VENDOR_UHTML_PATH = "@htmlplus/element/client/vendors/uhtml.js";
|
package/constants/index.js
CHANGED
|
@@ -35,11 +35,16 @@ export const STATIC_TAG = 'TAG';
|
|
|
35
35
|
// style
|
|
36
36
|
export const STYLE_IMPORTED = 'STYLE_IMPORTED';
|
|
37
37
|
// types
|
|
38
|
-
export const
|
|
39
|
-
export const
|
|
40
|
-
export const
|
|
41
|
-
export const
|
|
42
|
-
export const
|
|
38
|
+
export const TYPE_ARRAY = 1;
|
|
39
|
+
export const TYPE_BOOLEAN = 2;
|
|
40
|
+
export const TYPE_DATE = 4;
|
|
41
|
+
export const TYPE_ENUM = 8;
|
|
42
|
+
export const TYPE_FUNCTION = 16;
|
|
43
|
+
export const TYPE_NULL = 32;
|
|
44
|
+
export const TYPE_NUMBER = 64;
|
|
45
|
+
export const TYPE_OBJECT = 128;
|
|
46
|
+
export const TYPE_STRING = 256;
|
|
47
|
+
export const TYPE_UNDEFINED = 512;
|
|
43
48
|
// utils
|
|
44
49
|
export const UTIL_STYLE_MAPPER = 'styles';
|
|
45
50
|
// vendors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlplus/element",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Masood Abdolian <m.abdolian@gmail.com>",
|
|
6
6
|
"description": "A powerful library for building scalable, reusable, fast, tastable and lightweight design system for any web technologies. Powerd by Web Component.",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const parseValue: (value: any, type: any) => any;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as CONSTANTS from '../../constants/index.js';
|
|
2
|
-
import { toBoolean } from './toBoolean.js';
|
|
3
|
-
// TODO: input type & validate date
|
|
4
|
-
export const parseValue = (value, type) => {
|
|
5
|
-
switch (type) {
|
|
6
|
-
case CONSTANTS.TYPE_BOOLEAN:
|
|
7
|
-
return toBoolean(value);
|
|
8
|
-
case CONSTANTS.TYPE_DATE:
|
|
9
|
-
return new Date(value);
|
|
10
|
-
case CONSTANTS.TYPE_NUMBER:
|
|
11
|
-
return isNaN(value) ? value : parseFloat(value);
|
|
12
|
-
default:
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
};
|