@htmlplus/element 1.0.0 → 1.1.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 (185) hide show
  1. package/README.md +616 -534
  2. package/bundlers/rollup.d.ts +2 -2
  3. package/bundlers/rollup.js +5 -5
  4. package/bundlers/vite.d.ts +2 -2
  5. package/bundlers/vite.js +5 -5
  6. package/client/decorators/bind.d.ts +4 -0
  7. package/client/decorators/bind.js +4 -0
  8. package/client/decorators/direction.d.ts +5 -0
  9. package/client/decorators/direction.js +8 -0
  10. package/client/decorators/element.d.ts +5 -0
  11. package/client/decorators/element.js +7 -2
  12. package/client/decorators/event.d.ts +21 -7
  13. package/client/decorators/event.js +7 -2
  14. package/client/decorators/host.d.ts +4 -2
  15. package/client/decorators/host.js +5 -8
  16. package/client/decorators/index.d.ts +3 -0
  17. package/client/decorators/index.js +3 -0
  18. package/client/decorators/isRTL.d.ts +4 -0
  19. package/client/decorators/isRTL.js +7 -0
  20. package/client/decorators/listen.d.ts +38 -8
  21. package/client/decorators/listen.js +9 -12
  22. package/client/decorators/method.d.ts +4 -0
  23. package/client/decorators/method.js +4 -0
  24. package/client/decorators/property.d.ts +8 -1
  25. package/client/decorators/property.js +4 -0
  26. package/client/decorators/query.d.ts +9 -2
  27. package/client/decorators/query.js +10 -9
  28. package/client/decorators/queryAll.d.ts +12 -2
  29. package/client/decorators/queryAll.js +13 -9
  30. package/client/decorators/slots.d.ts +4 -0
  31. package/client/decorators/slots.js +7 -0
  32. package/client/decorators/state.d.ts +4 -0
  33. package/client/decorators/state.js +4 -0
  34. package/client/decorators/watch.d.ts +5 -4
  35. package/client/decorators/watch.js +5 -4
  36. package/client/index.d.ts +1 -3
  37. package/client/index.js +1 -3
  38. package/client/utils/classes.d.ts +3 -0
  39. package/client/utils/classes.js +11 -28
  40. package/client/utils/config.d.ts +25 -3
  41. package/client/utils/config.js +18 -10
  42. package/client/utils/direction.d.ts +5 -2
  43. package/client/utils/direction.js +5 -1
  44. package/client/utils/event.d.ts +6 -0
  45. package/client/utils/event.js +6 -0
  46. package/client/utils/host.d.ts +3 -0
  47. package/client/utils/host.js +3 -0
  48. package/client/utils/index.d.ts +4 -1
  49. package/client/utils/index.js +4 -1
  50. package/client/utils/isCSSColor.d.ts +5 -0
  51. package/client/utils/isCSSColor.js +9 -0
  52. package/client/utils/isRTL.d.ts +3 -0
  53. package/client/utils/isRTL.js +3 -0
  54. package/client/utils/isServer.d.ts +3 -0
  55. package/client/utils/isServer.js +3 -0
  56. package/client/utils/query.d.ts +5 -0
  57. package/client/utils/query.js +8 -0
  58. package/client/utils/queryAll.d.ts +5 -0
  59. package/client/utils/queryAll.js +8 -0
  60. package/client/utils/request.d.ts +1 -1
  61. package/client/utils/request.js +1 -1
  62. package/client/utils/slots.d.ts +3 -0
  63. package/client/utils/slots.js +6 -1
  64. package/client/utils/styles.d.ts +3 -0
  65. package/client/utils/styles.js +3 -0
  66. package/client/utils/toDecorator.d.ts +2 -0
  67. package/client/utils/toDecorator.js +10 -0
  68. package/client/utils/toUnit.d.ts +4 -1
  69. package/client/utils/toUnit.js +6 -3
  70. package/constants/index.d.ts +1 -0
  71. package/constants/index.js +2 -0
  72. package/package.json +3 -3
  73. package/transformer/index.d.ts +3 -0
  74. package/transformer/index.js +3 -0
  75. package/transformer/plugins/assets.d.ts +8 -0
  76. package/transformer/plugins/assets.js +29 -0
  77. package/{compiler → transformer}/plugins/copy.d.ts +2 -2
  78. package/{compiler → transformer}/plugins/customElement.d.ts +2 -2
  79. package/{compiler → transformer}/plugins/customElement.js +13 -12
  80. package/{compiler → transformer}/plugins/customElementReact/customElementReact.d.ts +4 -4
  81. package/{compiler → transformer}/plugins/customElementReact/customElementReact.js +18 -18
  82. package/{compiler → transformer}/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +1 -1
  83. package/{compiler → transformer}/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +3 -3
  84. package/transformer/plugins/customElementReact/templates/src/index.ts.hbs +1 -0
  85. package/transformer/plugins/document.d.ts +7 -0
  86. package/{compiler → transformer}/plugins/document.js +18 -18
  87. package/transformer/plugins/extract.d.ts +2 -0
  88. package/{compiler → transformer}/plugins/extract.js +1 -18
  89. package/transformer/plugins/parse.d.ts +6 -0
  90. package/{compiler → transformer}/plugins/parse.js +1 -1
  91. package/transformer/plugins/read.d.ts +8 -0
  92. package/transformer/plugins/read.js +20 -0
  93. package/transformer/plugins/readme.d.ts +6 -0
  94. package/{compiler → transformer}/plugins/readme.js +3 -2
  95. package/transformer/plugins/style.d.ts +6 -0
  96. package/{compiler → transformer}/plugins/style.js +4 -2
  97. package/transformer/plugins/validate.d.ts +2 -0
  98. package/transformer/plugins/validate.js +41 -0
  99. package/transformer/plugins/visualStudioCode.d.ts +8 -0
  100. package/{compiler → transformer}/plugins/visualStudioCode.js +10 -8
  101. package/transformer/plugins/webTypes.d.ts +10 -0
  102. package/{compiler → transformer}/plugins/webTypes.js +11 -7
  103. package/transformer/transformer.d.ts +6 -0
  104. package/{compiler/compiler.js → transformer/transformer.js} +17 -17
  105. package/transformer/transformer.types.d.ts +50 -0
  106. package/{compiler → transformer}/utils/printType.js +2 -2
  107. package/{compiler → transformer}/utils/renderTemplate.js +2 -0
  108. package/types/index.d.ts +2 -4
  109. package/types/index.js +1 -4
  110. package/CHANGELOG.md +0 -7
  111. package/bundlers/index.d.ts +0 -2
  112. package/bundlers/index.js +0 -2
  113. package/client/helpers/index.d.ts +0 -1
  114. package/client/helpers/index.js +0 -1
  115. package/client/services/index.d.ts +0 -1
  116. package/client/services/index.js +0 -1
  117. package/client/services/link.d.ts +0 -4
  118. package/client/services/link.js +0 -196
  119. package/client/utils/getNamespace.d.ts +0 -2
  120. package/client/utils/getNamespace.js +0 -4
  121. package/client/vendors/uhtml.d.ts +0 -29
  122. package/client/vendors/uhtml.js +0 -700
  123. package/compiler/compiler.d.ts +0 -6
  124. package/compiler/index.d.ts +0 -2
  125. package/compiler/index.js +0 -2
  126. package/compiler/plugins/assets.d.ts +0 -8
  127. package/compiler/plugins/assets.js +0 -33
  128. package/compiler/plugins/customElementReact/templates/src/index.ts.hbs +0 -1
  129. package/compiler/plugins/document.d.ts +0 -7
  130. package/compiler/plugins/extract.d.ts +0 -2
  131. package/compiler/plugins/parse.d.ts +0 -5
  132. package/compiler/plugins/read.d.ts +0 -8
  133. package/compiler/plugins/read.js +0 -13
  134. package/compiler/plugins/readme.d.ts +0 -6
  135. package/compiler/plugins/style.d.ts +0 -6
  136. package/compiler/plugins/validate.d.ts +0 -2
  137. package/compiler/plugins/validate.js +0 -37
  138. package/compiler/plugins/visualStudioCode.d.ts +0 -8
  139. package/compiler/plugins/webTypes.d.ts +0 -10
  140. package/types/context.d.ts +0 -31
  141. package/types/global.d.ts +0 -4
  142. package/types/global.js +0 -1
  143. package/types/plugin.d.ts +0 -10
  144. package/types/plugin.js +0 -1
  145. package/types/plusElement.d.ts +0 -2
  146. package/types/plusElement.js +0 -1
  147. /package/{compiler → transformer}/plugins/copy.js +0 -0
  148. /package/{compiler → transformer}/plugins/customElementReact/index.d.ts +0 -0
  149. /package/{compiler → transformer}/plugins/customElementReact/index.js +0 -0
  150. /package/{compiler → transformer}/plugins/customElementReact/templates/README.md.hbs +0 -0
  151. /package/{compiler → transformer}/plugins/customElementReact/templates/_.gitignore.hbs +0 -0
  152. /package/{compiler → transformer}/plugins/customElementReact/templates/package.json.hbs +0 -0
  153. /package/{compiler → transformer}/plugins/customElementReact/templates/rollup.config.js.hbs +0 -0
  154. /package/{compiler → transformer}/plugins/customElementReact/templates/src/components/index.ts.hbs +0 -0
  155. /package/{compiler → transformer}/plugins/customElementReact/templates/src/proxy.ts.hbs +0 -0
  156. /package/{compiler → transformer}/plugins/customElementReact/templates/tsconfig.json.hbs +0 -0
  157. /package/{compiler → transformer}/plugins/index.d.ts +0 -0
  158. /package/{compiler → transformer}/plugins/index.js +0 -0
  159. /package/{types/context.js → transformer/transformer.types.js} +0 -0
  160. /package/{compiler → transformer}/utils/__dirname.d.ts +0 -0
  161. /package/{compiler → transformer}/utils/__dirname.js +0 -0
  162. /package/{compiler → transformer}/utils/addDependency.d.ts +0 -0
  163. /package/{compiler → transformer}/utils/addDependency.js +0 -0
  164. /package/{compiler → transformer}/utils/getInitializer.d.ts +0 -0
  165. /package/{compiler → transformer}/utils/getInitializer.js +0 -0
  166. /package/{compiler → transformer}/utils/getType.d.ts +0 -0
  167. /package/{compiler → transformer}/utils/getType.js +0 -0
  168. /package/{compiler → transformer}/utils/getTypeReference.d.ts +0 -0
  169. /package/{compiler → transformer}/utils/getTypeReference.js +0 -0
  170. /package/{compiler → transformer}/utils/hasDecorator.d.ts +0 -0
  171. /package/{compiler → transformer}/utils/hasDecorator.js +0 -0
  172. /package/{compiler → transformer}/utils/index.d.ts +0 -0
  173. /package/{compiler → transformer}/utils/index.js +0 -0
  174. /package/{compiler → transformer}/utils/isDirectoryEmpty.d.ts +0 -0
  175. /package/{compiler → transformer}/utils/isDirectoryEmpty.js +0 -0
  176. /package/{compiler → transformer}/utils/print.d.ts +0 -0
  177. /package/{compiler → transformer}/utils/print.js +0 -0
  178. /package/{compiler → transformer}/utils/printType.d.ts +0 -0
  179. /package/{compiler → transformer}/utils/removeUnusedImport.d.ts +0 -0
  180. /package/{compiler → transformer}/utils/removeUnusedImport.js +0 -0
  181. /package/{compiler → transformer}/utils/renderTemplate.d.ts +0 -0
  182. /package/{compiler → transformer}/utils/tags.d.ts +0 -0
  183. /package/{compiler → transformer}/utils/tags.js +0 -0
  184. /package/{compiler → transformer}/utils/visitor.d.ts +0 -0
  185. /package/{compiler → transformer}/utils/visitor.js +0 -0
@@ -1,5 +1,5 @@
1
- import { Plugin } from '../types';
2
- export declare const rollup: (...plugins: Array<Plugin>) => {
1
+ import { TransformerPlugin } from '../transformer/index.js';
2
+ export declare const htmlplus: (...plugins: Array<TransformerPlugin>) => {
3
3
  name: string;
4
4
  buildStart(): Promise<void>;
5
5
  load(id: any): Promise<string | undefined>;
@@ -1,6 +1,6 @@
1
- import { compiler } from '../compiler/index.js';
2
- export const rollup = (...plugins) => {
3
- const { start, run, finish } = compiler(...plugins);
1
+ import { transformer } from '../transformer/index.js';
2
+ export const htmlplus = (...plugins) => {
3
+ const { start, run, finish } = transformer(...plugins);
4
4
  return {
5
5
  name: 'htmlplus',
6
6
  async buildStart() {
@@ -9,8 +9,8 @@ export const rollup = (...plugins) => {
9
9
  async load(id) {
10
10
  if (!id.endsWith('.tsx'))
11
11
  return;
12
- const { isInvalid, script } = await run(id);
13
- if (isInvalid)
12
+ const { script, skipped } = await run(id);
13
+ if (skipped)
14
14
  return;
15
15
  return script;
16
16
  },
@@ -1,5 +1,5 @@
1
- import { Plugin } from '../types';
2
- export declare const vite: (...plugins: Array<Plugin>) => {
1
+ import { TransformerPlugin } from '../transformer/index.js';
2
+ export declare const htmlplus: (...plugins: Array<TransformerPlugin>) => {
3
3
  name: string;
4
4
  buildStart(): Promise<void>;
5
5
  load(id: any): Promise<string | undefined>;
package/bundlers/vite.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import path from 'path';
2
- import { compiler } from '../compiler/index.js';
3
- export const vite = (...plugins) => {
4
- const { start, run, finish } = compiler(...plugins);
2
+ import { transformer } from '../transformer/index.js';
3
+ export const htmlplus = (...plugins) => {
4
+ const { start, run, finish } = transformer(...plugins);
5
5
  return {
6
6
  name: 'htmlplus',
7
7
  async buildStart() {
@@ -10,8 +10,8 @@ export const vite = (...plugins) => {
10
10
  async load(id) {
11
11
  if (!id.endsWith('.tsx'))
12
12
  return;
13
- let { isInvalid, script, stylePath } = await run(id);
14
- if (isInvalid)
13
+ let { script, skipped, stylePath } = await run(id);
14
+ if (skipped)
15
15
  return;
16
16
  if (script && stylePath) {
17
17
  script = script.replace(path.basename(stylePath), `${path.basename(stylePath)}?inline`);
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Used to bind a method of a class to the current context,
3
+ * making it easier to reference `this` within the method.
4
+ */
1
5
  export declare function Bind(): (target: Object, propertyKey: PropertyKey, descriptor: PropertyDescriptor) => {
2
6
  configurable: boolean;
3
7
  get(): any;
@@ -1,4 +1,8 @@
1
1
  import { defineProperty } from '../utils/index.js';
2
+ /**
3
+ * Used to bind a method of a class to the current context,
4
+ * making it easier to reference `this` within the method.
5
+ */
2
6
  export function Bind() {
3
7
  return function (target, propertyKey, descriptor) {
4
8
  return {
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Indicates whether the [Direction](https://mdn.io/css-direction)
3
+ * of the element is `Right-To-Left` or `Left-To-Right`.
4
+ */
5
+ export declare function Direction(): (target: import("../../types/index.js").PlusElement, propertyKey: PropertyKey) => void;
@@ -0,0 +1,8 @@
1
+ import { direction, toDecorator } from '../utils/index.js';
2
+ /**
3
+ * Indicates whether the [Direction](https://mdn.io/css-direction)
4
+ * of the element is `Right-To-Left` or `Left-To-Right`.
5
+ */
6
+ export function Direction() {
7
+ return toDecorator(direction);
8
+ }
@@ -1,2 +1,7 @@
1
1
  import { PlusElement } from '../../types';
2
+ /**
3
+ * The class marked with this decorator is considered a
4
+ * [Custom Element](https://mdn.io/using-custom-elements),
5
+ * and its name, in kebab-case, serves as the element name.
6
+ */
2
7
  export declare function Element(): (constructor: PlusElement) => void;
@@ -1,6 +1,11 @@
1
1
  import { camelCase, kebabCase } from 'change-case';
2
2
  import * as CONSTANTS from '../../constants/index.js';
3
- import { call, getConfig, getMembers, getNamespace, getTag, isServer, request, toProperty } from '../utils/index.js';
3
+ import { call, getConfig, getMembers, getTag, isServer, request, toProperty } from '../utils/index.js';
4
+ /**
5
+ * The class marked with this decorator is considered a
6
+ * [Custom Element](https://mdn.io/using-custom-elements),
7
+ * and its name, in kebab-case, serves as the element name.
8
+ */
4
9
  export function Element() {
5
10
  return function (constructor) {
6
11
  if (isServer())
@@ -46,7 +51,7 @@ export function Element() {
46
51
  connectedCallback() {
47
52
  const instance = this[CONSTANTS.API_INSTANCE];
48
53
  // TODO: experimental for global config
49
- Object.assign(instance, getConfig(getNamespace(instance), 'component', getTag(instance), 'property'));
54
+ Object.assign(instance, getConfig('element', getTag(instance), 'property'));
50
55
  const connect = () => {
51
56
  instance[CONSTANTS.API_CONNECTED] = true;
52
57
  call(instance, CONSTANTS.LIFECYCLE_CONNECTED);
@@ -1,21 +1,35 @@
1
1
  import { PlusElement } from '../../types';
2
+ /**
3
+ * A function type that generates a `CustomEvent`.
4
+ */
2
5
  export type EventEmitter<T = any> = (data?: T) => CustomEvent<T>;
6
+ /**
7
+ * An object that configures
8
+ * [options](https://developer.mozilla.org/docs/Web/API/Event/EventEvent#options)
9
+ * for the event dispatcher.
10
+ */
3
11
  export interface EventOptions {
4
12
  /**
5
- * A string custom event name to override the default.
6
- */
7
- name?: string;
8
- /**
9
- * A Boolean indicating whether the event bubbles up through the DOM or not. default is `false`.
13
+ * A boolean value indicating whether the event bubbles.
14
+ * The default is `false`.
10
15
  */
11
16
  bubbles?: boolean;
12
17
  /**
13
- * A Boolean indicating whether the event is cancelable. default is `false`.
18
+ * A boolean value indicating whether the event can be cancelled.
19
+ * The default is `false`.
14
20
  */
15
21
  cancelable?: boolean;
16
22
  /**
17
- * A Boolean value indicating whether or not the event can bubble across the boundary between the shadow DOM and the regular DOM. The default is false.
23
+ * A boolean value indicating whether the event will trigger listeners outside of a shadow root
24
+ * (see [Event.composed](https://mdn.io/event-composed) for more details).
25
+ * The default is `false`.
18
26
  */
19
27
  composed?: boolean;
20
28
  }
29
+ /**
30
+ * Provides the capability to dispatch a [CustomEvent](https://mdn.io/custom-event)
31
+ * from an element.
32
+ *
33
+ * @param options An object that configures options for the event dispatcher.
34
+ */
21
35
  export declare function Event<T = any>(options?: EventOptions): (target: PlusElement, propertyKey: PropertyKey) => void;
@@ -1,5 +1,11 @@
1
1
  import { kebabCase, pascalCase } from 'change-case';
2
2
  import { defineProperty, getFramework, host } from '../utils/index.js';
3
+ /**
4
+ * Provides the capability to dispatch a [CustomEvent](https://mdn.io/custom-event)
5
+ * from an element.
6
+ *
7
+ * @param options An object that configures options for the event dispatcher.
8
+ */
3
9
  export function Event(options = {}) {
4
10
  return function (target, propertyKey) {
5
11
  defineProperty(target, propertyKey, {
@@ -9,14 +15,13 @@ export function Event(options = {}) {
9
15
  const element = host(this);
10
16
  const framework = getFramework(element);
11
17
  (_a = options.bubbles) !== null && _a !== void 0 ? _a : (options.bubbles = false);
12
- let name = options.name || String(propertyKey);
18
+ let name = String(propertyKey);
13
19
  switch (framework) {
14
20
  case 'qwik':
15
21
  case 'solid':
16
22
  name = pascalCase(name).toLowerCase();
17
23
  break;
18
24
  case 'preact':
19
- case 'react':
20
25
  name = pascalCase(name);
21
26
  break;
22
27
  default:
@@ -1,2 +1,4 @@
1
- import { PlusElement } from '../../types';
2
- export declare function Host(): (target: PlusElement, propertyKey: PropertyKey) => void;
1
+ /**
2
+ * Indicates the host of the element.
3
+ */
4
+ export declare function Host(): (target: import("../../types/index.js").PlusElement, propertyKey: PropertyKey) => void;
@@ -1,10 +1,7 @@
1
- import { defineProperty, host } from '../utils/index.js';
1
+ import { host, toDecorator } from '../utils/index.js';
2
+ /**
3
+ * Indicates the host of the element.
4
+ */
2
5
  export function Host() {
3
- return function (target, propertyKey) {
4
- defineProperty(target, propertyKey, {
5
- get() {
6
- return host(this);
7
- }
8
- });
9
- };
6
+ return toDecorator(host);
10
7
  }
@@ -1,11 +1,14 @@
1
1
  export * from './bind.js';
2
+ export * from './direction.js';
2
3
  export * from './element.js';
3
4
  export * from './event.js';
4
5
  export * from './host.js';
6
+ export * from './isRTL.js';
5
7
  export * from './listen.js';
6
8
  export * from './method.js';
7
9
  export * from './property.js';
8
10
  export * from './query.js';
9
11
  export * from './queryAll.js';
12
+ export * from './slots.js';
10
13
  export * from './state.js';
11
14
  export * from './watch.js';
@@ -1,11 +1,14 @@
1
1
  export * from './bind.js';
2
+ export * from './direction.js';
2
3
  export * from './element.js';
3
4
  export * from './event.js';
4
5
  export * from './host.js';
6
+ export * from './isRTL.js';
5
7
  export * from './listen.js';
6
8
  export * from './method.js';
7
9
  export * from './property.js';
8
10
  export * from './query.js';
9
11
  export * from './queryAll.js';
12
+ export * from './slots.js';
10
13
  export * from './state.js';
11
14
  export * from './watch.js';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Indicates whether the direction of the element is `Right-To-Left` or not.
3
+ */
4
+ export declare function IsRTL(): (target: import("../../types/index.js").PlusElement, propertyKey: PropertyKey) => void;
@@ -0,0 +1,7 @@
1
+ import { isRTL, toDecorator } from '../utils/index.js';
2
+ /**
3
+ * Indicates whether the direction of the element is `Right-To-Left` or not.
4
+ */
5
+ export function IsRTL() {
6
+ return toDecorator(isRTL);
7
+ }
@@ -1,20 +1,50 @@
1
1
  import { PlusElement } from '../../types';
2
+ /**
3
+ * An object that configures
4
+ * [options](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener#options)
5
+ * for the event listener.
6
+ */
2
7
  export interface ListenOptions {
8
+ /**
9
+ * A boolean value indicating that events of this type will be dispatched to the registered
10
+ * `listener` before being dispatched to any `EventTarget` beneath it in the DOM tree.
11
+ * If not specified, defaults to `false`.
12
+ */
3
13
  capture?: boolean;
14
+ /**
15
+ * A boolean value indicating that the `listener` should be invoked at most once after being added.
16
+ * If `true`, the `listener` would be automatically removed when invoked.
17
+ * If not specified, defaults to `false`.
18
+ */
4
19
  once?: boolean;
20
+ /**
21
+ * A boolean value that, if `true`,
22
+ * indicates that the function specified by `listener` will never call
23
+ * [preventDefault()](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault).
24
+ * If a passive listener does call `preventDefault()`,
25
+ * the user agent will do nothing other than generate a console warning.
26
+ */
5
27
  passive?: boolean;
28
+ /**
29
+ * An [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
30
+ * The listener will be removed when the given `AbortSignal` object's
31
+ * [abort()](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort) method is called.
32
+ * If not specified, no `AbortSignal` is associated with the listener.
33
+ */
6
34
  signal?: AbortSignal;
35
+ /**
36
+ * The target element, defaults to `host`.
37
+ */
7
38
  target?: 'host' | 'body' | 'document' | 'window';
8
39
  }
9
40
  /**
10
- * The default options.
11
- */
12
- export declare const ListenOptionsDefault: ListenOptions;
13
- /**
14
- * Will be called whenever the specified event is delivered to the target.
15
- * [More](https://mdn.io/addEventListener).
16
- * @param type A case-sensitive string representing the [event type](https://mdn.io/events) to listen for.
17
- * @param options An object that specifies characteristics about the event listener.
41
+ * Will be called whenever the specified event is delivered to the target
42
+ * [More](https://mdn.io/add-event-listener).
43
+ *
44
+ * @param type A case-sensitive string representing the [Event Type](https://mdn.io/events) to listen for.
45
+ * @param options An object that configures
46
+ * [options](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener#options)
47
+ * for the event listener.
18
48
  */
19
49
  export declare function Listen(type: string, options?: ListenOptions): (target: PlusElement, propertyKey: PropertyKey, descriptor: PropertyDescriptor) => {
20
50
  configurable: boolean;
@@ -2,22 +2,19 @@ import * as CONSTANTS from '../../constants/index.js';
2
2
  import { appendToMethod, host, on, off } from '../utils/index.js';
3
3
  import { Bind } from './bind.js';
4
4
  /**
5
- * The default options.
6
- */
7
- export const ListenOptionsDefault = {
8
- target: 'host'
9
- };
10
- /**
11
- * Will be called whenever the specified event is delivered to the target.
12
- * [More](https://mdn.io/addEventListener).
13
- * @param type A case-sensitive string representing the [event type](https://mdn.io/events) to listen for.
14
- * @param options An object that specifies characteristics about the event listener.
5
+ * Will be called whenever the specified event is delivered to the target
6
+ * [More](https://mdn.io/add-event-listener).
7
+ *
8
+ * @param type A case-sensitive string representing the [Event Type](https://mdn.io/events) to listen for.
9
+ * @param options An object that configures
10
+ * [options](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener#options)
11
+ * for the event listener.
15
12
  */
16
13
  export function Listen(type, options) {
17
14
  return function (target, propertyKey, descriptor) {
18
- options = Object.assign({}, ListenOptionsDefault, options);
15
+ options = Object.assign({ target: 'host' }, options);
19
16
  const element = (instance) => {
20
- switch (options === null || options === void 0 ? void 0 : options.target) {
17
+ switch (options.target) {
21
18
  case 'body':
22
19
  return window.document.body;
23
20
  case 'document':
@@ -1,2 +1,6 @@
1
1
  import { PlusElement } from '../../types';
2
+ /**
3
+ * Provides a way to encapsulate functionality within an element
4
+ * and invoke it as needed, both internally and externally.
5
+ */
2
6
  export declare function Method(): (target: PlusElement, propertyKey: PropertyKey) => void;
@@ -1,5 +1,9 @@
1
1
  import * as CONSTANTS from '../../constants/index.js';
2
2
  import { appendToMethod, defineProperty, host } from '../utils/index.js';
3
+ /**
4
+ * Provides a way to encapsulate functionality within an element
5
+ * and invoke it as needed, both internally and externally.
6
+ */
3
7
  export function Method() {
4
8
  return function (target, propertyKey) {
5
9
  appendToMethod(target, CONSTANTS.LIFECYCLE_CONNECTED, function () {
@@ -1,12 +1,19 @@
1
1
  import { PlusElement } from '../../types';
2
+ /**
3
+ * The configuration for property decorator.
4
+ */
2
5
  export interface PropertyOptions {
3
6
  /**
4
7
  * Whether property value is reflected back to the associated attribute. default is `false`.
5
8
  */
6
9
  reflect?: boolean;
7
10
  /**
8
- * TODO
11
+ * Do not set the value to this property. This value is automatically set during transpiling.
9
12
  */
10
13
  type?: number;
11
14
  }
15
+ /**
16
+ * Creates a reactive property, reflecting a corresponding attribute value,
17
+ * and updates the element when the property is set.
18
+ */
12
19
  export declare function Property(options?: PropertyOptions): (target: PlusElement, propertyKey: PropertyKey) => void;
@@ -1,5 +1,9 @@
1
1
  import * as CONSTANTS from '../../constants/index.js';
2
2
  import { addMember, appendToMethod, defineProperty, host, request, toProperty, updateAttribute } from '../utils/index.js';
3
+ /**
4
+ * Creates a reactive property, reflecting a corresponding attribute value,
5
+ * and updates the element when the property is set.
6
+ */
3
7
  export function Property(options) {
4
8
  return function (target, propertyKey) {
5
9
  const name = String(propertyKey);
@@ -1,2 +1,9 @@
1
- import { PlusElement } from '../../types';
2
- export declare function Query(selectors: string): (target: PlusElement, propertyKey: PropertyKey) => void;
1
+ /**
2
+ * Selects the first element in the shadow dom that matches a specified CSS selector.
3
+ *
4
+ * @param selectors A string containing one or more selectors to match.
5
+ * This string must be a valid CSS selector string; if it isn't, a `SyntaxError` exception is thrown. See
6
+ * [Locating DOM elements using selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors)
7
+ * for more about selectors and how to manage them.
8
+ */
9
+ export declare function Query(selectors: string): (target: import("../../types/index.js").PlusElement, propertyKey: PropertyKey) => void;
@@ -1,11 +1,12 @@
1
- import { defineProperty, shadowRoot } from '../utils/index.js';
1
+ import { query, toDecorator } from '../utils/index.js';
2
+ /**
3
+ * Selects the first element in the shadow dom that matches a specified CSS selector.
4
+ *
5
+ * @param selectors A string containing one or more selectors to match.
6
+ * This string must be a valid CSS selector string; if it isn't, a `SyntaxError` exception is thrown. See
7
+ * [Locating DOM elements using selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors)
8
+ * for more about selectors and how to manage them.
9
+ */
2
10
  export function Query(selectors) {
3
- return function (target, propertyKey) {
4
- defineProperty(target, propertyKey, {
5
- get() {
6
- var _a;
7
- return (_a = shadowRoot(this)) === null || _a === void 0 ? void 0 : _a.querySelector(selectors);
8
- }
9
- });
10
- };
11
+ return toDecorator(query, selectors);
11
12
  }
@@ -1,2 +1,12 @@
1
- import { PlusElement } from '../../types';
2
- export declare function QueryAll(selectors: string): (target: PlusElement, propertyKey: PropertyKey) => void;
1
+ /**
2
+ * Selects all elements in the shadow dom that match a specified CSS selector.
3
+ *
4
+ * @param selectors A string containing one or more selectors to match against.
5
+ * This string must be a valid
6
+ * [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors)
7
+ * string; if it's not, a `SyntaxError` exception is thrown. See
8
+ * [Locating DOM elements using selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors)
9
+ * for more information about using selectors to identify elements.
10
+ * Multiple selectors may be specified by separating them using commas.
11
+ */
12
+ export declare function QueryAll(selectors: string): (target: import("../../types/index.js").PlusElement, propertyKey: PropertyKey) => void;
@@ -1,11 +1,15 @@
1
- import { defineProperty, shadowRoot } from '../utils/index.js';
1
+ import { queryAll, toDecorator } from '../utils/index.js';
2
+ /**
3
+ * Selects all elements in the shadow dom that match a specified CSS selector.
4
+ *
5
+ * @param selectors A string containing one or more selectors to match against.
6
+ * This string must be a valid
7
+ * [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors)
8
+ * string; if it's not, a `SyntaxError` exception is thrown. See
9
+ * [Locating DOM elements using selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors)
10
+ * for more information about using selectors to identify elements.
11
+ * Multiple selectors may be specified by separating them using commas.
12
+ */
2
13
  export function QueryAll(selectors) {
3
- return function (target, propertyKey) {
4
- defineProperty(target, propertyKey, {
5
- get() {
6
- var _a;
7
- return (_a = shadowRoot(this)) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selectors);
8
- }
9
- });
10
- };
14
+ return toDecorator(queryAll, selectors);
11
15
  }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Returns the slots name.
3
+ */
4
+ export declare function Slots(): (target: import("../../types/index.js").PlusElement, propertyKey: PropertyKey) => void;
@@ -0,0 +1,7 @@
1
+ import { slots, toDecorator } from '../utils/index.js';
2
+ /**
3
+ * Returns the slots name.
4
+ */
5
+ export function Slots() {
6
+ return toDecorator(slots);
7
+ }
@@ -1,2 +1,6 @@
1
1
  import { PlusElement } from '../../types';
2
+ /**
3
+ * Applying this decorator to any `class property` will trigger the
4
+ * element to re-render upon the desired property changes.
5
+ */
2
6
  export declare function State(): (target: PlusElement, propertyKey: PropertyKey) => void;
@@ -1,4 +1,8 @@
1
1
  import { defineProperty, request } from '../utils/index.js';
2
+ /**
3
+ * Applying this decorator to any `class property` will trigger the
4
+ * element to re-render upon the desired property changes.
5
+ */
2
6
  export function State() {
3
7
  return function (target, propertyKey) {
4
8
  const name = String(propertyKey);
@@ -1,9 +1,10 @@
1
1
  import { PlusElement } from '../../types';
2
2
  /**
3
- * Monitors `@Property` and `@State` to catch changes.
4
- * The decorated method will be invoked after any
5
- * changes with the `key`, `newValue`, and `oldValue` as parameters.
6
- * If the arguments aren't defined, all of the `@Property` and `@State` are considered.
3
+ * Monitors `@Property` and `@State` to detect changes.
4
+ * The decorated method will be called after any changes,
5
+ * with the `key`, `newValue`, and `oldValue` as parameters.
6
+ * If the `key` is not defined, all `@Property` and `@State` are considered.
7
+ *
7
8
  * @param keys Collection of `@Property` and `@State` names.
8
9
  * @param immediate Triggers the callback immediately after initialization.
9
10
  */
@@ -1,10 +1,11 @@
1
1
  import * as CONSTANTS from '../../constants/index.js';
2
2
  import { appendToMethod } from '../utils/index.js';
3
3
  /**
4
- * Monitors `@Property` and `@State` to catch changes.
5
- * The decorated method will be invoked after any
6
- * changes with the `key`, `newValue`, and `oldValue` as parameters.
7
- * If the arguments aren't defined, all of the `@Property` and `@State` are considered.
4
+ * Monitors `@Property` and `@State` to detect changes.
5
+ * The decorated method will be called after any changes,
6
+ * with the `key`, `newValue`, and `oldValue` as parameters.
7
+ * If the `key` is not defined, all `@Property` and `@State` are considered.
8
+ *
8
9
  * @param keys Collection of `@Property` and `@State` names.
9
10
  * @param immediate Triggers the callback immediately after initialization.
10
11
  */
package/client/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  export * from './decorators/index.js';
2
- export * from './helpers/index.js';
3
- export * from './services/index.js';
4
- export { getConfig, setConfig } from './utils/config.js';
2
+ export { classes, direction, getConfig, host, isCSSColor, isRTL, query, queryAll, on, off, slots, styles, toUnit, setConfig, type Config, type ConfigOptions } from './utils/index.js';
package/client/index.js CHANGED
@@ -1,4 +1,2 @@
1
1
  export * from './decorators/index.js';
2
- export * from './helpers/index.js';
3
- export * from './services/index.js';
4
- export { getConfig, setConfig } from './utils/config.js';
2
+ export { classes, direction, getConfig, host, isCSSColor, isRTL, query, queryAll, on, off, slots, styles, toUnit, setConfig } from './utils/index.js';
@@ -1 +1,4 @@
1
+ /**
2
+ * TODO
3
+ */
1
4
  export declare const classes: (input: any, smart?: boolean) => string;