@htmlplus/element 2.12.0 → 2.13.0

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.
Files changed (175) hide show
  1. package/README.md +2 -2
  2. package/bundlers.d.ts +20 -0
  3. package/{bundlers/vite.js → bundlers.js} +39 -3
  4. package/client-5FqNUiuz.d.ts +309 -0
  5. package/client-Dse96R-O.js +1805 -0
  6. package/client.d.ts +1 -0
  7. package/client.js +3 -0
  8. package/constants.d.ts +48 -0
  9. package/constants.js +60 -0
  10. package/internal.d.ts +1 -0
  11. package/internal.js +3 -0
  12. package/package.json +8 -4
  13. package/transformer.d.ts +139 -0
  14. package/transformer.js +1277 -0
  15. package/bundlers/rollup.d.ts +0 -7
  16. package/bundlers/rollup.js +0 -23
  17. package/bundlers/vite.d.ts +0 -8
  18. package/client/decorators/bind.d.ts +0 -8
  19. package/client/decorators/bind.js +0 -21
  20. package/client/decorators/context.d.ts +0 -3
  21. package/client/decorators/context.js +0 -121
  22. package/client/decorators/direction.d.ts +0 -5
  23. package/client/decorators/direction.js +0 -8
  24. package/client/decorators/element.d.ts +0 -7
  25. package/client/decorators/element.js +0 -65
  26. package/client/decorators/event.d.ts +0 -35
  27. package/client/decorators/event.js +0 -53
  28. package/client/decorators/host.d.ts +0 -4
  29. package/client/decorators/host.js +0 -7
  30. package/client/decorators/index.d.ts +0 -15
  31. package/client/decorators/index.js +0 -15
  32. package/client/decorators/isRTL.d.ts +0 -4
  33. package/client/decorators/isRTL.js +0 -7
  34. package/client/decorators/listen.d.ts +0 -52
  35. package/client/decorators/listen.js +0 -37
  36. package/client/decorators/method.d.ts +0 -6
  37. package/client/decorators/method.js +0 -15
  38. package/client/decorators/property.d.ts +0 -25
  39. package/client/decorators/property.js +0 -94
  40. package/client/decorators/query.d.ts +0 -9
  41. package/client/decorators/query.js +0 -12
  42. package/client/decorators/queryAll.d.ts +0 -12
  43. package/client/decorators/queryAll.js +0 -15
  44. package/client/decorators/slots.d.ts +0 -4
  45. package/client/decorators/slots.js +0 -7
  46. package/client/decorators/state.d.ts +0 -6
  47. package/client/decorators/state.js +0 -23
  48. package/client/decorators/watch.d.ts +0 -11
  49. package/client/decorators/watch.js +0 -31
  50. package/client/index.d.ts +0 -2
  51. package/client/index.js +0 -2
  52. package/client/utils/appendToMethod.d.ts +0 -1
  53. package/client/utils/appendToMethod.js +0 -15
  54. package/client/utils/attributes.d.ts +0 -2
  55. package/client/utils/attributes.js +0 -33
  56. package/client/utils/call.d.ts +0 -1
  57. package/client/utils/call.js +0 -3
  58. package/client/utils/classes.d.ts +0 -4
  59. package/client/utils/classes.js +0 -45
  60. package/client/utils/config.d.ts +0 -39
  61. package/client/utils/config.js +0 -28
  62. package/client/utils/defineProperty.d.ts +0 -1
  63. package/client/utils/defineProperty.js +0 -1
  64. package/client/utils/direction.d.ts +0 -6
  65. package/client/utils/direction.js +0 -8
  66. package/client/utils/event.d.ts +0 -13
  67. package/client/utils/event.js +0 -48
  68. package/client/utils/getFramework.d.ts +0 -2
  69. package/client/utils/getFramework.js +0 -20
  70. package/client/utils/getStyles.d.ts +0 -2
  71. package/client/utils/getStyles.js +0 -4
  72. package/client/utils/getTag.d.ts +0 -2
  73. package/client/utils/getTag.js +0 -4
  74. package/client/utils/host.d.ts +0 -5
  75. package/client/utils/host.js +0 -12
  76. package/client/utils/index.d.ts +0 -32
  77. package/client/utils/index.js +0 -32
  78. package/client/utils/isCSSColor.d.ts +0 -5
  79. package/client/utils/isCSSColor.js +0 -9
  80. package/client/utils/isEvent.d.ts +0 -1
  81. package/client/utils/isEvent.js +0 -3
  82. package/client/utils/isRTL.d.ts +0 -5
  83. package/client/utils/isRTL.js +0 -5
  84. package/client/utils/isServer.d.ts +0 -4
  85. package/client/utils/isServer.js +0 -6
  86. package/client/utils/merge.d.ts +0 -1
  87. package/client/utils/merge.js +0 -22
  88. package/client/utils/query.d.ts +0 -5
  89. package/client/utils/query.js +0 -7
  90. package/client/utils/queryAll.d.ts +0 -5
  91. package/client/utils/queryAll.js +0 -7
  92. package/client/utils/request.d.ts +0 -9
  93. package/client/utils/request.js +0 -106
  94. package/client/utils/shadowRoot.d.ts +0 -2
  95. package/client/utils/shadowRoot.js +0 -4
  96. package/client/utils/slots.d.ts +0 -9
  97. package/client/utils/slots.js +0 -18
  98. package/client/utils/styles.d.ts +0 -4
  99. package/client/utils/styles.js +0 -10
  100. package/client/utils/task.d.ts +0 -6
  101. package/client/utils/task.js +0 -34
  102. package/client/utils/toBoolean.d.ts +0 -1
  103. package/client/utils/toBoolean.js +0 -3
  104. package/client/utils/toDecorator.d.ts +0 -2
  105. package/client/utils/toDecorator.js +0 -10
  106. package/client/utils/toEvent.d.ts +0 -1
  107. package/client/utils/toEvent.js +0 -3
  108. package/client/utils/toProperty.d.ts +0 -1
  109. package/client/utils/toProperty.js +0 -55
  110. package/client/utils/toUnit.d.ts +0 -4
  111. package/client/utils/toUnit.js +0 -10
  112. package/client/utils/typeOf.d.ts +0 -3
  113. package/client/utils/typeOf.js +0 -6
  114. package/client/utils/uhtml.d.ts +0 -22
  115. package/client/utils/uhtml.js +0 -703
  116. package/client/utils/updateAttribute.d.ts +0 -2
  117. package/client/utils/updateAttribute.js +0 -10
  118. package/constants/index.d.ts +0 -48
  119. package/constants/index.js +0 -60
  120. package/transformer/index.d.ts +0 -3
  121. package/transformer/index.js +0 -3
  122. package/transformer/plugins/assets.d.ts +0 -7
  123. package/transformer/plugins/assets.js +0 -26
  124. package/transformer/plugins/copy.d.ts +0 -9
  125. package/transformer/plugins/copy.js +0 -29
  126. package/transformer/plugins/customElement.d.ts +0 -7
  127. package/transformer/plugins/customElement.js +0 -392
  128. package/transformer/plugins/document.d.ts +0 -7
  129. package/transformer/plugins/document.js +0 -206
  130. package/transformer/plugins/extract.d.ts +0 -2
  131. package/transformer/plugins/extract.js +0 -22
  132. package/transformer/plugins/index.d.ts +0 -12
  133. package/transformer/plugins/index.js +0 -12
  134. package/transformer/plugins/parse.d.ts +0 -6
  135. package/transformer/plugins/parse.js +0 -13
  136. package/transformer/plugins/read.d.ts +0 -7
  137. package/transformer/plugins/read.js +0 -19
  138. package/transformer/plugins/readme.d.ts +0 -6
  139. package/transformer/plugins/readme.js +0 -24
  140. package/transformer/plugins/style.d.ts +0 -6
  141. package/transformer/plugins/style.js +0 -42
  142. package/transformer/plugins/validate.d.ts +0 -2
  143. package/transformer/plugins/validate.js +0 -40
  144. package/transformer/plugins/visualStudioCode.d.ts +0 -8
  145. package/transformer/plugins/visualStudioCode.js +0 -73
  146. package/transformer/plugins/webTypes.d.ts +0 -10
  147. package/transformer/plugins/webTypes.js +0 -74
  148. package/transformer/transformer.d.ts +0 -8
  149. package/transformer/transformer.js +0 -78
  150. package/transformer/transformer.types.d.ts +0 -52
  151. package/transformer/transformer.types.js +0 -1
  152. package/transformer/utils/addDependency.d.ts +0 -7
  153. package/transformer/utils/addDependency.js +0 -64
  154. package/transformer/utils/extractAttribute.d.ts +0 -2
  155. package/transformer/utils/extractAttribute.js +0 -10
  156. package/transformer/utils/extractFromComment.d.ts +0 -4
  157. package/transformer/utils/extractFromComment.js +0 -51
  158. package/transformer/utils/getInitializer.d.ts +0 -2
  159. package/transformer/utils/getInitializer.js +0 -3
  160. package/transformer/utils/getType.d.ts +0 -2
  161. package/transformer/utils/getType.js +0 -89
  162. package/transformer/utils/getTypeReference.d.ts +0 -2
  163. package/transformer/utils/getTypeReference.js +0 -33
  164. package/transformer/utils/hasDecorator.d.ts +0 -1
  165. package/transformer/utils/hasDecorator.js +0 -5
  166. package/transformer/utils/index.d.ts +0 -10
  167. package/transformer/utils/index.js +0 -10
  168. package/transformer/utils/print.d.ts +0 -2
  169. package/transformer/utils/print.js +0 -5
  170. package/transformer/utils/printType.d.ts +0 -1
  171. package/transformer/utils/printType.js +0 -69
  172. package/transformer/utils/visitor.d.ts +0 -2
  173. package/transformer/utils/visitor.js +0 -5
  174. package/types/index.d.ts +0 -2
  175. package/types/index.js +0 -1
@@ -1,32 +0,0 @@
1
- export * from './appendToMethod.js';
2
- export * from './attributes.js';
3
- export * from './call.js';
4
- export * from './classes.js';
5
- export * from './config.js';
6
- export * from './defineProperty.js';
7
- export * from './direction.js';
8
- export * from './event.js';
9
- export * from './getFramework.js';
10
- export * from './getStyles.js';
11
- export * from './getTag.js';
12
- export * from './host.js';
13
- export * from './isCSSColor.js';
14
- export * from './isEvent.js';
15
- export * from './isRTL.js';
16
- export * from './isServer.js';
17
- export * from './merge.js';
18
- export * from './query.js';
19
- export * from './queryAll.js';
20
- export * from './request.js';
21
- export * from './shadowRoot.js';
22
- export * from './slots.js';
23
- export * from './styles.js';
24
- export * from './task.js';
25
- export * from './toBoolean.js';
26
- export * from './toDecorator.js';
27
- export * from './toEvent.js';
28
- export * from './toProperty.js';
29
- export * from './toUnit.js';
30
- export * from './typeOf.js';
31
- export * from './uhtml.js';
32
- export * from './updateAttribute.js';
@@ -1,5 +0,0 @@
1
- /**
2
- * Determines whether the given input string is a valid
3
- * [CSS Color](https://mdn.io/color-value) or not.
4
- */
5
- export declare const isCSSColor: (input: string) => boolean;
@@ -1,9 +0,0 @@
1
- /**
2
- * Determines whether the given input string is a valid
3
- * [CSS Color](https://mdn.io/color-value) or not.
4
- */
5
- export const isCSSColor = (input) => {
6
- const option = new Option();
7
- option.style.color = input;
8
- return option.style.color !== '';
9
- };
@@ -1 +0,0 @@
1
- export declare const isEvent: (input: string) => boolean;
@@ -1,3 +0,0 @@
1
- export const isEvent = (input) => {
2
- return !!input?.match(/on[A-Z]\w+/g);
3
- };
@@ -1,5 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- /**
3
- * Indicates whether the direction of the element is `Right-To-Left` or not.
4
- */
5
- export declare const isRTL: (target: HTMLPlusElement) => boolean;
@@ -1,5 +0,0 @@
1
- import { direction } from './direction.js';
2
- /**
3
- * Indicates whether the direction of the element is `Right-To-Left` or not.
4
- */
5
- export const isRTL = (target) => direction(target) == 'rtl';
@@ -1,4 +0,0 @@
1
- /**
2
- * Indicates whether the current code is running on a server.
3
- */
4
- export declare const isServer: () => boolean;
@@ -1,6 +0,0 @@
1
- /**
2
- * Indicates whether the current code is running on a server.
3
- */
4
- export const isServer = () => {
5
- return !(typeof window != 'undefined' && window.document);
6
- };
@@ -1 +0,0 @@
1
- export declare const merge: (target: any, ...sources: any[]) => any;
@@ -1,22 +0,0 @@
1
- import { typeOf } from './typeOf.js';
2
- export const merge = (target, ...sources) => {
3
- for (const source of sources) {
4
- if (!source)
5
- continue;
6
- if (typeOf(source) != 'object') {
7
- target = source;
8
- continue;
9
- }
10
- for (const key of Object.keys(source)) {
11
- if (target[key] instanceof Object &&
12
- source[key] instanceof Object &&
13
- target[key] !== source[key]) {
14
- target[key] = merge(target[key], source[key]);
15
- }
16
- else {
17
- target[key] = source[key];
18
- }
19
- }
20
- }
21
- return target;
22
- };
@@ -1,5 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- /**
3
- * Selects the first element in the shadow dom that matches a specified CSS selector.
4
- */
5
- export declare function query(target: HTMLPlusElement, selectors: string): Element | null | undefined;
@@ -1,7 +0,0 @@
1
- import { shadowRoot } from './shadowRoot.js';
2
- /**
3
- * Selects the first element in the shadow dom that matches a specified CSS selector.
4
- */
5
- export function query(target, selectors) {
6
- return shadowRoot(target)?.querySelector(selectors);
7
- }
@@ -1,5 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- /**
3
- * Selects all elements in the shadow dom that match a specified CSS selector.
4
- */
5
- export declare function queryAll(target: HTMLPlusElement, selectors: string): NodeListOf<Element> | undefined;
@@ -1,7 +0,0 @@
1
- import { shadowRoot } from './shadowRoot.js';
2
- /**
3
- * Selects all elements in the shadow dom that match a specified CSS selector.
4
- */
5
- export function queryAll(target, selectors) {
6
- return shadowRoot(target)?.querySelectorAll(selectors);
7
- }
@@ -1,9 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- /**
3
- * Updates the DOM with a scheduled task.
4
- * @param target The element instance.
5
- * @param name Property/State name.
6
- * @param previous The previous value of Property/State.
7
- * @param callback Invoked when the rendering phase is completed.
8
- */
9
- export declare const request: (target: HTMLPlusElement, name?: string, previous?: any, callback?: (skipped: boolean) => void) => void;
@@ -1,106 +0,0 @@
1
- import * as CONSTANTS from '../../constants/index.js';
2
- import { call } from './call.js';
3
- import { getStyles } from './getStyles.js';
4
- import { shadowRoot } from './shadowRoot.js';
5
- import { task } from './task.js';
6
- import { render } from './uhtml.js';
7
- /**
8
- * Updates the DOM with a scheduled task.
9
- * @param target The element instance.
10
- * @param name Property/State name.
11
- * @param previous The previous value of Property/State.
12
- * @param callback Invoked when the rendering phase is completed.
13
- */
14
- export const request = (target, name, previous, callback) => {
15
- // Creates/Gets a stacks.
16
- const stacks = (target[CONSTANTS.API_STACKS] ||= new Map());
17
- // Creates/Updates a stack.
18
- const stack = stacks.get(name) || { callbacks: [], previous };
19
- // Adds the callback to the stack, if exists.
20
- callback && stack.callbacks.push(callback);
21
- // Stores the stack.
22
- stacks.set(name, stack);
23
- // Defines a handler.
24
- const handler = () => {
25
- // Skips the rendering phase if DOM isn't ready.
26
- if (!target[CONSTANTS.API_CONNECTED])
27
- return;
28
- // Calculates the states to pass into lifecycles' callbacks.
29
- const states = new Map(Array.from(stacks)
30
- .filter((stack) => stack[0])
31
- .map((stack) => [stack[0], stack[1].previous]));
32
- // Calls the lifecycle's callback before the rendering phase.
33
- call(target, CONSTANTS.LIFECYCLE_UPDATE, states);
34
- // Renders template to the DOM.
35
- render(shadowRoot(target), () => call(target, CONSTANTS.METHOD_RENDER));
36
- // Invokes requests' callback.
37
- stacks.forEach((state) => {
38
- state.callbacks.forEach((callback, index, callbacks) => {
39
- callback(callbacks.length - 1 != index);
40
- });
41
- });
42
- // TODO
43
- (() => {
44
- const raw = getStyles(target);
45
- if (!raw)
46
- return;
47
- const regex1 = /this-([\w-]+)(?:-([\w-]+))?/g;
48
- const regex2 = /(\s*\w+\s*:\s*(undefined|null)\s*;?)/g;
49
- const hasGlobal = raw.includes(':global');
50
- const hasVariable = raw.includes('this-');
51
- let localSheet = target[CONSTANTS.API_STYLE];
52
- let globalSheet = target.constructor[CONSTANTS.API_STYLE];
53
- if (!hasVariable && localSheet)
54
- return;
55
- const parsed = raw
56
- .replace(regex1, (match, key) => {
57
- let value = target;
58
- for (const section of key.split('-')) {
59
- value = value?.[section];
60
- }
61
- return value;
62
- })
63
- .replace(regex2, '');
64
- if (!localSheet) {
65
- localSheet = new CSSStyleSheet();
66
- target[CONSTANTS.API_STYLE] = localSheet;
67
- shadowRoot(target).adoptedStyleSheets.push(localSheet);
68
- }
69
- const localStyle = parsed;
70
- localSheet.replace(localStyle);
71
- if (!hasGlobal || globalSheet)
72
- return;
73
- if (!globalSheet) {
74
- globalSheet = new CSSStyleSheet();
75
- target.constructor[CONSTANTS.API_STYLE] = globalSheet;
76
- document.adoptedStyleSheets.push(globalSheet);
77
- }
78
- const globalStyle = parsed
79
- .split('}')
80
- .map((rule) => {
81
- let [selectors, properties] = rule.split('{');
82
- selectors = selectors
83
- .split(',')
84
- .map((selector) => selector.trim())
85
- .filter((selector) => selector.startsWith(':global'))
86
- .map((selector) => selector.replace(':global', ''))
87
- .map((selector) => selector.trim())
88
- .join(',');
89
- return selectors ? `${selectors}{${properties}}` : '';
90
- })
91
- .filter((selector) => !!selector)
92
- .join('');
93
- globalSheet.replace(globalStyle);
94
- })();
95
- // Calls the lifecycle's callback after the rendering phase.
96
- call(target, CONSTANTS.LIFECYCLE_UPDATED, states);
97
- // Clears stacks.
98
- stacks.clear();
99
- // TODO: related to the @Watch decorator.
100
- target[CONSTANTS.API_RENDER_COMPLETED] = true;
101
- };
102
- // Creates/Gets a micro task function.
103
- target[CONSTANTS.API_REQUEST] ||= task({ handler });
104
- // Calls the micro task.
105
- call(target, CONSTANTS.API_REQUEST);
106
- };
@@ -1,2 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- export declare const shadowRoot: (target: HTMLElement | HTMLPlusElement) => ShadowRoot | null;
@@ -1,4 +0,0 @@
1
- import { host } from './host.js';
2
- export const shadowRoot = (target) => {
3
- return host(target)?.shadowRoot;
4
- };
@@ -1,9 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- type Slots = {
3
- [key: string]: boolean;
4
- };
5
- /**
6
- * Returns the slots name.
7
- */
8
- export declare const slots: (target: HTMLElement | HTMLPlusElement) => Slots;
9
- export {};
@@ -1,18 +0,0 @@
1
- import { host } from './host.js';
2
- /**
3
- * Returns the slots name.
4
- */
5
- export const slots = (target) => {
6
- const element = host(target);
7
- const slots = {};
8
- const children = Array.from(element.childNodes);
9
- for (const child of children) {
10
- if (child.nodeName == '#comment')
11
- continue;
12
- const name = child['slot'] || (child.nodeValue?.trim() && 'default') || ('slot' in child && 'default');
13
- if (!name)
14
- continue;
15
- slots[name] = true;
16
- }
17
- return slots;
18
- };
@@ -1,4 +0,0 @@
1
- /**
2
- * Converts a JavaScript object containing CSS styles to a CSS string.
3
- */
4
- export declare const styles: (input: object) => string;
@@ -1,10 +0,0 @@
1
- import { kebabCase } from 'change-case';
2
- /**
3
- * Converts a JavaScript object containing CSS styles to a CSS string.
4
- */
5
- export const styles = (input) => {
6
- return Object.keys(input)
7
- .filter((key) => input[key] !== undefined && input[key] !== null)
8
- .map((key) => `${key.startsWith('--') ? '--' : ''}${kebabCase(key)}: ${input[key]}`)
9
- .join('; ');
10
- };
@@ -1,6 +0,0 @@
1
- export interface QueueOptions {
2
- canStart?: () => boolean;
3
- canRun?: () => boolean;
4
- handler: () => void;
5
- }
6
- export declare const task: (options: QueueOptions) => () => Promise<boolean>;
@@ -1,34 +0,0 @@
1
- export const task = (options) => {
2
- let running, promise;
3
- const run = () => {
4
- if (options.canStart && !options.canStart())
5
- return Promise.resolve(false);
6
- if (!running)
7
- promise = enqueue();
8
- return promise;
9
- };
10
- const enqueue = async () => {
11
- running = true;
12
- try {
13
- await promise;
14
- }
15
- catch (error) {
16
- Promise.reject(error);
17
- }
18
- // TODO: maybe is optional
19
- if (!running)
20
- return promise;
21
- try {
22
- if (options.canRun && !options.canRun())
23
- return (running = false);
24
- options.handler();
25
- running = false;
26
- return true;
27
- }
28
- catch (error) {
29
- running = false;
30
- throw error;
31
- }
32
- };
33
- return run;
34
- };
@@ -1 +0,0 @@
1
- export declare const toBoolean: (input: any) => boolean;
@@ -1,3 +0,0 @@
1
- export const toBoolean = (input) => {
2
- return ![undefined, null, false, 'false'].includes(input);
3
- };
@@ -1,2 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- export declare function toDecorator(util: Function, ...parameters: any[]): (target: HTMLPlusElement, key: PropertyKey) => void;
@@ -1,10 +0,0 @@
1
- import { defineProperty } from './defineProperty.js';
2
- export function toDecorator(util, ...parameters) {
3
- return function (target, key) {
4
- defineProperty(target, key, {
5
- get() {
6
- return util(this, ...parameters);
7
- }
8
- });
9
- };
10
- }
@@ -1 +0,0 @@
1
- export declare const toEvent: (input: string) => string;
@@ -1,3 +0,0 @@
1
- export const toEvent = (input) => {
2
- return input?.slice(2).toLowerCase();
3
- };
@@ -1 +0,0 @@
1
- export declare const toProperty: (input: any, type?: any) => any;
@@ -1,55 +0,0 @@
1
- import * as CONSTANTS from '../../constants/index.js';
2
- import { typeOf } from './typeOf.js';
3
- export const toProperty = (input, type) => {
4
- if (type === undefined)
5
- return input;
6
- const string = `${input}`;
7
- if (CONSTANTS.TYPE_BOOLEAN & type || type === Boolean) {
8
- if (string === '')
9
- return true;
10
- if (string === 'true')
11
- return true;
12
- if (string === 'false')
13
- return false;
14
- }
15
- if (CONSTANTS.TYPE_NUMBER & type || type === Number) {
16
- if (string != '' && !isNaN(input)) {
17
- return parseFloat(input);
18
- }
19
- }
20
- if (CONSTANTS.TYPE_NULL & type || type === null) {
21
- if (string === 'null') {
22
- return null;
23
- }
24
- }
25
- if (CONSTANTS.TYPE_DATE & type || type === Date) {
26
- const value = new Date(input);
27
- if (value.toString() != 'Invalid Date') {
28
- return value;
29
- }
30
- }
31
- if (CONSTANTS.TYPE_ARRAY & type || type === Array) {
32
- try {
33
- const value = JSON.parse(input);
34
- if (typeOf(value) == 'array') {
35
- return value;
36
- }
37
- }
38
- catch { }
39
- }
40
- if (CONSTANTS.TYPE_OBJECT & type || type === Object) {
41
- try {
42
- const value = JSON.parse(input);
43
- if (typeOf(value) == 'object') {
44
- return value;
45
- }
46
- }
47
- catch { }
48
- }
49
- if (CONSTANTS.TYPE_UNDEFINED & type || type === undefined) {
50
- if (string === 'undefined') {
51
- return undefined;
52
- }
53
- }
54
- return input;
55
- };
@@ -1,4 +0,0 @@
1
- /**
2
- * Converts a value to a unit.
3
- */
4
- export declare const toUnit: (input: string | number, unit?: string) => string;
@@ -1,10 +0,0 @@
1
- /**
2
- * Converts a value to a unit.
3
- */
4
- export const toUnit = (input, unit = 'px') => {
5
- if (input === null || input === undefined || input === '')
6
- return input;
7
- if (isNaN(+input))
8
- return String(input);
9
- return Number(input) + unit;
10
- };
@@ -1,3 +0,0 @@
1
- type Types = 'array' | 'boolean' | 'function' | 'number' | 'object' | 'string';
2
- export declare const typeOf: (input: any) => Types;
3
- export {};
@@ -1,6 +0,0 @@
1
- export const typeOf = (input) => {
2
- return Object.prototype.toString
3
- .call(input)
4
- .replace(/\[|\]|object| /g, '')
5
- .toLowerCase();
6
- };
@@ -1,22 +0,0 @@
1
- /**
2
- * Holds all details wrappers needed to render the content further on.
3
- * @constructor
4
- * @param {string} type The hole type, either `html` or `svg`.
5
- * @param {string[]} template The template literals used to the define the content.
6
- * @param {Array} values Zero, one, or more interpolated values to render.
7
- */
8
- export class Hole {
9
- constructor(type: any, template: any, values: any);
10
- type: any;
11
- template: any;
12
- values: any;
13
- }
14
- export const html: ((template: any, ...values: any[]) => Hole) & {
15
- for(ref: any, id: any): any;
16
- node: (template: any, ...values: any[]) => any;
17
- };
18
- export function render(where: any, what: any): any;
19
- export const svg: ((template: any, ...values: any[]) => Hole) & {
20
- for(ref: any, id: any): any;
21
- node: (template: any, ...values: any[]) => any;
22
- };