@ecopages/radiant 0.1.8 → 0.2.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 (150) hide show
  1. package/dist/context/context-provider.js +3 -279
  2. package/dist/context/context-provider.js.map +4 -6
  3. package/dist/context/create-context.js +3 -6
  4. package/dist/context/create-context.js.map +2 -2
  5. package/dist/context/decorators/consume-context.d.ts +3 -3
  6. package/dist/context/decorators/consume-context.js +3 -64
  7. package/dist/context/decorators/consume-context.js.map +4 -5
  8. package/dist/context/decorators/context-selector.d.ts +5 -8
  9. package/dist/context/decorators/context-selector.js +3 -71
  10. package/dist/context/decorators/context-selector.js.map +4 -5
  11. package/dist/context/decorators/legacy/consume-context.d.ts +3 -0
  12. package/dist/context/decorators/legacy/consume-context.js +4 -0
  13. package/dist/context/decorators/legacy/consume-context.js.map +10 -0
  14. package/dist/context/decorators/legacy/context-selector.d.ts +4 -0
  15. package/dist/context/decorators/legacy/context-selector.js +4 -0
  16. package/dist/context/decorators/legacy/context-selector.js.map +10 -0
  17. package/dist/context/decorators/legacy/provide-context.d.ts +4 -0
  18. package/dist/context/decorators/legacy/provide-context.js +4 -0
  19. package/dist/context/decorators/legacy/provide-context.js.map +10 -0
  20. package/dist/context/decorators/provide-context.d.ts +6 -7
  21. package/dist/context/decorators/provide-context.js +3 -291
  22. package/dist/context/decorators/provide-context.js.map +4 -7
  23. package/dist/context/decorators/standard/consume-context.d.ts +3 -0
  24. package/dist/context/decorators/standard/consume-context.js +4 -0
  25. package/dist/context/decorators/standard/consume-context.js.map +10 -0
  26. package/dist/context/decorators/standard/context-selector.d.ts +4 -0
  27. package/dist/context/decorators/standard/context-selector.js +4 -0
  28. package/dist/context/decorators/standard/context-selector.js.map +10 -0
  29. package/dist/context/decorators/standard/provide-context.d.ts +4 -0
  30. package/dist/context/decorators/standard/provide-context.js +4 -0
  31. package/dist/context/decorators/standard/provide-context.js.map +10 -0
  32. package/dist/context/events.d.ts +3 -2
  33. package/dist/context/events.js +3 -53
  34. package/dist/context/events.js.map +3 -3
  35. package/dist/core/radiant-element.d.ts +72 -20
  36. package/dist/core/radiant-element.js +3 -82
  37. package/dist/core/radiant-element.js.map +3 -3
  38. package/dist/decorators/bound.d.ts +2 -6
  39. package/dist/decorators/bound.js +2 -23
  40. package/dist/decorators/bound.js.map +3 -3
  41. package/dist/decorators/custom-element.d.ts +3 -1
  42. package/dist/decorators/custom-element.js +3 -14
  43. package/dist/decorators/custom-element.js.map +3 -3
  44. package/dist/decorators/debounce.d.ts +6 -1
  45. package/dist/decorators/debounce.js +2 -20
  46. package/dist/decorators/debounce.js.map +3 -3
  47. package/dist/decorators/event.d.ts +3 -2
  48. package/dist/decorators/event.js +3 -46
  49. package/dist/decorators/event.js.map +4 -5
  50. package/dist/decorators/legacy/bound.d.ts +9 -0
  51. package/dist/decorators/legacy/bound.js +4 -0
  52. package/dist/decorators/legacy/bound.js.map +10 -0
  53. package/dist/decorators/legacy/custom-element.d.ts +6 -0
  54. package/dist/decorators/legacy/custom-element.js +4 -0
  55. package/dist/decorators/legacy/custom-element.js.map +10 -0
  56. package/dist/decorators/legacy/debounce.d.ts +1 -0
  57. package/dist/decorators/legacy/debounce.js +4 -0
  58. package/dist/decorators/legacy/debounce.js.map +10 -0
  59. package/dist/decorators/legacy/event.d.ts +9 -0
  60. package/dist/decorators/legacy/event.js +3 -0
  61. package/dist/decorators/legacy/event.js.map +10 -0
  62. package/dist/decorators/legacy/on-event.d.ts +26 -0
  63. package/dist/decorators/legacy/on-event.js +4 -0
  64. package/dist/decorators/legacy/on-event.js.map +10 -0
  65. package/dist/decorators/legacy/on-updated.d.ts +6 -0
  66. package/dist/decorators/legacy/on-updated.js +4 -0
  67. package/dist/decorators/legacy/on-updated.js.map +10 -0
  68. package/dist/decorators/legacy/query.d.ts +23 -0
  69. package/dist/decorators/legacy/query.js +4 -0
  70. package/dist/decorators/legacy/query.js.map +10 -0
  71. package/dist/decorators/legacy/reactive-field.d.ts +10 -0
  72. package/dist/decorators/legacy/reactive-field.js +4 -0
  73. package/dist/decorators/legacy/reactive-field.js.map +10 -0
  74. package/dist/decorators/legacy/reactive-prop.d.ts +19 -0
  75. package/dist/decorators/legacy/reactive-prop.js +4 -0
  76. package/dist/decorators/legacy/reactive-prop.js.map +10 -0
  77. package/dist/decorators/on-event.d.ts +4 -7
  78. package/dist/decorators/on-event.js +3 -47
  79. package/dist/decorators/on-event.js.map +3 -3
  80. package/dist/decorators/on-updated.d.ts +3 -4
  81. package/dist/decorators/on-updated.js +3 -29
  82. package/dist/decorators/on-updated.js.map +3 -3
  83. package/dist/decorators/query.d.ts +9 -28
  84. package/dist/decorators/query.js +3 -36
  85. package/dist/decorators/query.js.map +3 -3
  86. package/dist/decorators/reactive-field.d.ts +3 -7
  87. package/dist/decorators/reactive-field.js +3 -26
  88. package/dist/decorators/reactive-field.js.map +3 -3
  89. package/dist/decorators/reactive-prop.d.ts +4 -15
  90. package/dist/decorators/reactive-prop.js +3 -214
  91. package/dist/decorators/reactive-prop.js.map +4 -5
  92. package/dist/decorators/standard/bound.d.ts +2 -0
  93. package/dist/decorators/standard/bound.js +4 -0
  94. package/dist/decorators/standard/bound.js.map +10 -0
  95. package/dist/decorators/standard/custom-element.d.ts +1 -0
  96. package/dist/decorators/standard/custom-element.js +4 -0
  97. package/dist/decorators/standard/custom-element.js.map +10 -0
  98. package/dist/decorators/standard/debounce.d.ts +2 -0
  99. package/dist/decorators/standard/debounce.js +4 -0
  100. package/dist/decorators/standard/debounce.js.map +10 -0
  101. package/dist/decorators/standard/event.d.ts +9 -0
  102. package/dist/decorators/standard/event.js +4 -0
  103. package/dist/decorators/standard/event.js.map +10 -0
  104. package/dist/decorators/standard/on-event.d.ts +27 -0
  105. package/dist/decorators/standard/on-event.js +4 -0
  106. package/dist/decorators/standard/on-event.js.map +10 -0
  107. package/dist/decorators/standard/on-updated.d.ts +2 -0
  108. package/dist/decorators/standard/on-updated.js +4 -0
  109. package/dist/decorators/standard/on-updated.js.map +10 -0
  110. package/dist/decorators/standard/query.d.ts +2 -0
  111. package/dist/decorators/standard/query.js +4 -0
  112. package/dist/decorators/standard/query.js.map +10 -0
  113. package/dist/decorators/standard/reactive-field.d.ts +2 -0
  114. package/dist/decorators/standard/reactive-field.js +4 -0
  115. package/dist/decorators/standard/reactive-field.js.map +10 -0
  116. package/dist/decorators/standard/reactive-prop.d.ts +2 -0
  117. package/dist/decorators/standard/reactive-prop.js +4 -0
  118. package/dist/decorators/standard/reactive-prop.js.map +10 -0
  119. package/dist/index.d.ts +14 -4
  120. package/dist/index.js +2 -716
  121. package/dist/index.js.map +3 -21
  122. package/dist/mixins/index.js +2 -23
  123. package/dist/mixins/index.js.map +3 -4
  124. package/dist/mixins/with-kita.js +3 -23
  125. package/dist/mixins/with-kita.js.map +3 -3
  126. package/dist/tools/event-emitter.d.ts +1 -1
  127. package/dist/tools/event-emitter.js +3 -22
  128. package/dist/tools/event-emitter.js.map +3 -3
  129. package/dist/tools/index.js +2 -28
  130. package/dist/tools/index.js.map +3 -5
  131. package/dist/tools/stringify-typed.js +3 -8
  132. package/dist/tools/stringify-typed.js.map +2 -2
  133. package/dist/types.d.ts +79 -0
  134. package/dist/types.js +3 -0
  135. package/dist/types.js.map +10 -0
  136. package/dist/utils/attribute-utils.d.ts +2 -0
  137. package/dist/utils/attribute-utils.js +3 -137
  138. package/dist/utils/attribute-utils.js.map +3 -3
  139. package/dist/utils/index.js +2 -137
  140. package/dist/utils/index.js.map +3 -4
  141. package/package.json +22 -34
  142. package/dist/context/index.d.ts +0 -7
  143. package/dist/context/index.js +0 -338
  144. package/dist/context/index.js.map +0 -16
  145. package/dist/core/index.d.ts +0 -1
  146. package/dist/core/index.js +0 -83
  147. package/dist/core/index.js.map +0 -10
  148. package/dist/decorators.d.ts +0 -7
  149. package/dist/decorators.js +0 -401
  150. package/dist/decorators.js.map +0 -18
@@ -1,39 +1,20 @@
1
- import type { RadiantElement } from '../core';
2
- /**
3
- * The base configuration object for the query.
4
- */
1
+ import type { StandardOrLegacyFieldDecoratorArgs } from '../types';
5
2
  type BaseQueryConfig = {
6
3
  all?: boolean;
7
4
  cache?: boolean;
8
5
  };
9
- /**
10
- * The configuration object for the query.
11
- * It can be configured to query by CSS selector or data-ref attribute.
12
- */
13
- export type QueryConfig = BaseQueryConfig & ({
6
+ type QueryBySelector = {
14
7
  selector: string;
15
- } | {
8
+ };
9
+ type QueryByRef = {
16
10
  ref: string;
17
- });
11
+ };
12
+ export type QueryConfig = BaseQueryConfig & (QueryBySelector | QueryByRef);
18
13
  /**
19
14
  * A decorator to query by CSS selector or data-ref attribute.
20
15
  * By default it queries for the first element that matches the selector, but it can be configured to query for all elements.
21
- *
22
- * @param {QueryConfig} options - The configuration object for the query.
23
- * @param {boolean} [options.all] - A flag to query for all elements that match the selector. Defaults to `false`.
24
- * @param {boolean} [options.cache] - A flag to cache the query result. Defaults to `true`.
25
- * @param {string} [options.selector] - A CSS selector to match elements against. This property is mutually exclusive with `options.ref`.
26
- * @param {string} [options.ref] - A reference to an element. This property is mutually exclusive with `options.selector`.
27
- *
28
- * @returns {Function} A decorator function that, when applied to a class property, will replace it with a getter. The getter will return the result of the query when accessed.
29
- *
30
- * @example
31
- * class MyElement extends HTMLElement {
32
- * @query({ selector: '.my-class' })
33
- * myElement;
34
- * }
35
- *
36
- * // Now, `myElement` will return the first element in the light DOM of `MyElement` that matches the selector '.my-class'.
16
+ * It cache the result by default, but it can be configured to not cache it.
17
+ * @param options {@link QueryConfig} The options for the reactive property.
37
18
  */
38
- export declare function query({ cache: shouldBeCached, ...options }: QueryConfig): (proto: RadiantElement, propertyKey: string | symbol) => void;
19
+ export declare function query<T extends Element | Element[]>(options: QueryConfig): (protoOrTarget: StandardOrLegacyFieldDecoratorArgs["protoOrTarget"], nameOrContext: StandardOrLegacyFieldDecoratorArgs["nameOrContext"]) => any;
39
20
  export {};
@@ -1,37 +1,4 @@
1
- // src/decorators/query.ts
2
- function query({
3
- cache: shouldBeCached = true,
4
- ...options
5
- }) {
6
- const cache = new WeakMap;
7
- return (proto, propertyKey) => {
8
- const doQuery = function() {
9
- if (shouldBeCached) {
10
- const cachedResult = cache.get(this);
11
- if (cachedResult !== undefined) {
12
- return cachedResult;
13
- }
14
- }
15
- const selector = "selector" in options ? options.selector : `[data-ref="${options.ref}"]`;
16
- const queryResult = options.all ? this.querySelectorAll(selector) : this.querySelector(selector);
17
- if (shouldBeCached) {
18
- cache.set(this, queryResult);
19
- }
20
- return queryResult;
21
- };
22
- const originalConnectedCallback = proto.connectedCallback;
23
- proto.connectedCallback = function() {
24
- Object.defineProperty(this, propertyKey, {
25
- get: doQuery,
26
- enumerable: true,
27
- configurable: true
28
- });
29
- originalConnectedCallback.call(this);
30
- };
31
- };
32
- }
33
- export {
34
- query
35
- };
1
+ import{u as D}from"./legacy/query.js";import{v as E}from"./standard/query.js";function H(w){return function(z,j){if(typeof j==="object")return E(w)(z,j);return D(w)(z,j)}}export{H as query};
2
+ export{H as t};
36
3
 
37
- //# debugId=E7593899A4A7CB9A64756E2164756E21
4
+ //# debugId=0DD98124DFF9C20D64756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/decorators/query.ts"],
4
4
  "sourcesContent": [
5
- "import type { RadiantElement } from '@/core';\n\n/**\n * The base configuration object for the query.\n */\ntype BaseQueryConfig = {\n all?: boolean;\n cache?: boolean;\n};\n\n/**\n * The configuration object for the query.\n * It can be configured to query by CSS selector or data-ref attribute.\n */\nexport type QueryConfig = BaseQueryConfig &\n (\n | {\n selector: string;\n }\n | {\n ref: string;\n }\n );\n\n/**\n * A decorator to query by CSS selector or data-ref attribute.\n * By default it queries for the first element that matches the selector, but it can be configured to query for all elements.\n *\n * @param {QueryConfig} options - The configuration object for the query.\n * @param {boolean} [options.all] - A flag to query for all elements that match the selector. Defaults to `false`.\n * @param {boolean} [options.cache] - A flag to cache the query result. Defaults to `true`.\n * @param {string} [options.selector] - A CSS selector to match elements against. This property is mutually exclusive with `options.ref`.\n * @param {string} [options.ref] - A reference to an element. This property is mutually exclusive with `options.selector`.\n *\n * @returns {Function} A decorator function that, when applied to a class property, will replace it with a getter. The getter will return the result of the query when accessed.\n *\n * @example\n * class MyElement extends HTMLElement {\n * @query({ selector: '.my-class' })\n * myElement;\n * }\n *\n * // Now, `myElement` will return the first element in the light DOM of `MyElement` that matches the selector '.my-class'.\n */\nexport function query({\n cache: shouldBeCached = true,\n ...options\n}: QueryConfig): (proto: RadiantElement, propertyKey: string | symbol) => void {\n const cache = new WeakMap<Element, Element | NodeList | null>();\n\n return (proto: RadiantElement, propertyKey: string | symbol) => {\n const doQuery = function (this: Element) {\n if (shouldBeCached) {\n const cachedResult = cache.get(this);\n if (cachedResult !== undefined) {\n return cachedResult;\n }\n }\n\n const selector = 'selector' in options ? options.selector : `[data-ref=\"${options.ref}\"]`;\n const queryResult = options.all ? this.querySelectorAll(selector) : this.querySelector(selector);\n\n if (shouldBeCached) {\n cache.set(this, queryResult);\n }\n\n return queryResult;\n };\n\n const originalConnectedCallback = proto.connectedCallback;\n\n proto.connectedCallback = function (this: RadiantElement) {\n Object.defineProperty(this, propertyKey, {\n get: doQuery,\n enumerable: true,\n configurable: true,\n });\n\n originalConnectedCallback.call(this);\n };\n };\n}\n"
5
+ "import type {\n LegacyFieldDecoratorArgs,\n StandardFieldDecoratorArgs,\n StandardOrLegacyFieldDecoratorArgs,\n} from '../types';\nimport { query as legacyQuery } from './legacy/query';\nimport { query as standardQuery } from './standard/query';\n\ntype BaseQueryConfig = {\n all?: boolean;\n cache?: boolean;\n};\n\ntype QueryBySelector = { selector: string };\n\ntype QueryByRef = { ref: string };\n\nexport type QueryConfig = BaseQueryConfig & (QueryBySelector | QueryByRef);\n\n/**\n * A decorator to query by CSS selector or data-ref attribute.\n * By default it queries for the first element that matches the selector, but it can be configured to query for all elements.\n * It cache the result by default, but it can be configured to not cache it.\n * @param options {@link QueryConfig} The options for the reactive property.\n */\nexport function query<T extends Element | Element[]>(options: QueryConfig) {\n return function (\n protoOrTarget: StandardOrLegacyFieldDecoratorArgs['protoOrTarget'],\n nameOrContext: StandardOrLegacyFieldDecoratorArgs['nameOrContext'],\n ): any {\n if (typeof nameOrContext === 'object') {\n return standardQuery(options)(\n protoOrTarget as StandardFieldDecoratorArgs['protoOrTarget'],\n nameOrContext as StandardFieldDecoratorArgs<HTMLElement, Element | Element[]>['nameOrContext'],\n );\n }\n return legacyQuery<T>(options)(\n protoOrTarget as LegacyFieldDecoratorArgs['protoOrTarget'],\n nameOrContext as LegacyFieldDecoratorArgs['nameOrContext'],\n );\n };\n}\n"
6
6
  ],
7
- "mappings": ";AA4CO,SAAS,KAAK;AAAA,EACnB,OAAO,iBAAiB;AAAA,KACrB;AAAA,GAC0E;AAC7E,QAAM,QAAQ,IAAI;AAElB,SAAO,CAAC,OAAuB,gBAAiC;AAC9D,UAAM,kBAAmB,GAAgB;AACvC,UAAI,gBAAgB;AAClB,cAAM,eAAe,MAAM,IAAI,IAAI;AACnC,YAAI,iBAAiB,WAAW;AAC9B,iBAAO;AAAA,QACT;AAAA,MACF;AAEA,YAAM,WAAW,cAAc,UAAU,QAAQ,WAAW,cAAc,QAAQ;AAClF,YAAM,cAAc,QAAQ,MAAM,KAAK,iBAAiB,QAAQ,IAAI,KAAK,cAAc,QAAQ;AAE/F,UAAI,gBAAgB;AAClB,cAAM,IAAI,MAAM,WAAW;AAAA,MAC7B;AAEA,aAAO;AAAA;AAGT,UAAM,4BAA4B,MAAM;AAExC,UAAM,4BAA6B,GAAuB;AACxD,aAAO,eAAe,MAAM,aAAa;AAAA,QACvC,KAAK;AAAA,QACL,YAAY;AAAA,QACZ,cAAc;AAAA,MAChB,CAAC;AAED,gCAA0B,KAAK,IAAI;AAAA;AAAA;AAAA;",
8
- "debugId": "E7593899A4A7CB9A64756E2164756E21",
7
+ "mappings": "oFAyBO,GAAS,CAAoC,CAAC,EAAsB,CACzE,eAAgB,CACd,EACA,EACK,CACL,UAAW,IAAkB,SAC3B,OAAO,EAAc,CAAO,EAC1B,EACA,CACF,EAEF,OAAO,EAAe,CAAO,EAC3B,EACA,CACF",
8
+ "debugId": "0DD98124DFF9C20D64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,10 +1,6 @@
1
- import type { RadiantElement } from '../core/radiant-element';
1
+ import type { StandardOrLegacyFieldDecoratorArgs } from '../types';
2
2
  /**
3
3
  * A decorator to define a reactive field.
4
- * Every time the property changes, the `updated` method will be called.
5
- * Due the fact the value is always undefined before the first update,
6
- * we are adding a `isDefined` WeakSet to track if the property has been defined.
7
- * @param target The target element.
8
- * @param propertyKey The property key.
4
+ * Every time the field changes, the `notifyUpdate` method will be called.
9
5
  */
10
- export declare function reactiveField(proto: RadiantElement, propertyKey: string): void;
6
+ export declare function reactiveField(protoOrTarget: StandardOrLegacyFieldDecoratorArgs['protoOrTarget'], nameOrContext: StandardOrLegacyFieldDecoratorArgs['nameOrContext']): any;
@@ -1,27 +1,4 @@
1
- // src/decorators/reactive-field.ts
2
- function reactiveField(proto, propertyKey) {
3
- const originalValues = new WeakMap;
4
- const isDefined = new WeakSet;
5
- Object.defineProperty(proto, propertyKey, {
6
- get: function() {
7
- return originalValues.get(this);
8
- },
9
- set: function(newValue) {
10
- if (isDefined.has(this)) {
11
- const oldValue = originalValues.get(this);
12
- if (oldValue !== newValue) {
13
- originalValues.set(this, newValue);
14
- this.updated(propertyKey, oldValue, newValue);
15
- }
16
- } else {
17
- originalValues.set(this, newValue);
18
- isDefined.add(this);
19
- }
20
- }
21
- });
22
- }
23
- export {
24
- reactiveField
25
- };
1
+ import{A as q}from"./legacy/reactive-field.js";import{B as u}from"./standard/reactive-field.js";function D(k,j){if(typeof j==="object")return u(k,j);return q(k,j)}export{D as reactiveField};
2
+ export{D as z};
26
3
 
27
- //# debugId=6BDE160AC013151B64756E2164756E21
4
+ //# debugId=00F5476E4FB6968164756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/decorators/reactive-field.ts"],
4
4
  "sourcesContent": [
5
- "import type { RadiantElement } from '@/core/radiant-element';\n\n/**\n * A decorator to define a reactive field.\n * Every time the property changes, the `updated` method will be called.\n * Due the fact the value is always undefined before the first update,\n * we are adding a `isDefined` WeakSet to track if the property has been defined.\n * @param target The target element.\n * @param propertyKey The property key.\n */\nexport function reactiveField(proto: RadiantElement, propertyKey: string) {\n const originalValues = new WeakMap<WeakKey, unknown>();\n const isDefined = new WeakSet<WeakKey>();\n\n Object.defineProperty(proto, propertyKey, {\n get: function () {\n return originalValues.get(this);\n },\n set: function (newValue: unknown) {\n if (isDefined.has(this)) {\n const oldValue = originalValues.get(this);\n if (oldValue !== newValue) {\n originalValues.set(this, newValue);\n this.updated(propertyKey, oldValue, newValue);\n }\n } else {\n originalValues.set(this, newValue);\n isDefined.add(this);\n }\n },\n });\n}\n"
5
+ "import type {\n LegacyFieldDecoratorArgs,\n StandardFieldDecoratorArgs,\n StandardOrLegacyFieldDecoratorArgs,\n} from '../types';\nimport { reactiveField as legacyReactiveField } from './legacy/reactive-field';\nimport { reactiveField as standardReactiveField } from './standard/reactive-field';\n\n/**\n * A decorator to define a reactive field.\n * Every time the field changes, the `notifyUpdate` method will be called.\n */\nexport function reactiveField(\n protoOrTarget: StandardOrLegacyFieldDecoratorArgs['protoOrTarget'],\n nameOrContext: StandardOrLegacyFieldDecoratorArgs['nameOrContext'],\n): any {\n if (typeof nameOrContext === 'object') {\n return standardReactiveField(\n protoOrTarget as StandardFieldDecoratorArgs['protoOrTarget'],\n nameOrContext as StandardFieldDecoratorArgs['nameOrContext'],\n );\n }\n return legacyReactiveField(\n protoOrTarget as LegacyFieldDecoratorArgs['protoOrTarget'],\n nameOrContext as LegacyFieldDecoratorArgs['nameOrContext'],\n );\n}\n"
6
6
  ],
7
- "mappings": ";AAUO,SAAS,aAAa,CAAC,OAAuB,aAAqB;AACxE,QAAM,iBAAiB,IAAI;AAC3B,QAAM,YAAY,IAAI;AAEtB,SAAO,eAAe,OAAO,aAAa;AAAA,IACxC,aAAc,GAAG;AACf,aAAO,eAAe,IAAI,IAAI;AAAA;AAAA,IAEhC,aAAc,CAAC,UAAmB;AAChC,UAAI,UAAU,IAAI,IAAI,GAAG;AACvB,cAAM,WAAW,eAAe,IAAI,IAAI;AACxC,YAAI,aAAa,UAAU;AACzB,yBAAe,IAAI,MAAM,QAAQ;AACjC,eAAK,QAAQ,aAAa,UAAU,QAAQ;AAAA,QAC9C;AAAA,MACF,OAAO;AACL,uBAAe,IAAI,MAAM,QAAQ;AACjC,kBAAU,IAAI,IAAI;AAAA;AAAA;AAAA,EAGxB,CAAC;AAAA;",
8
- "debugId": "6BDE160AC013151B64756E2164756E21",
7
+ "mappings": "6FAYO,YAAS,CAAa,CAC3B,EACA,EACK,CACL,UAAW,IAAkB,SAC3B,OAAO,EACL,EACA,CACF,EAEF,OAAO,EACL,EACA,CACF",
8
+ "debugId": "00F5476E4FB6968164756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,19 +1,8 @@
1
- import type { RadiantElement } from '../core/radiant-element';
2
- import { type AttributeTypeConstant } from '../utils/attribute-utils';
3
- type ReactivePropertyOptions<T> = {
4
- type: AttributeTypeConstant;
5
- reflect?: boolean;
6
- attribute?: string;
7
- defaultValue?: T;
8
- };
1
+ import type { ReactivePropertyOptions } from '../core/radiant-element';
2
+ import type { StandardOrLegacyFieldDecoratorArgs } from '../types';
9
3
  /**
10
4
  * A decorator to define a reactive property.
11
5
  * Every time the property changes, the `updated` method will be called.
12
- * @param options The options for the reactive property.
13
- * @param options.type The type of the property value.
14
- * @param options.reflect Whether to reflect the property to the attribute.
15
- * @param options.attribute The name of the attribute.
16
- * @param options.defaultValue The default value of the property.
6
+ * @param options {@link ReactivePropertyOptions} The options for the reactive property.
17
7
  */
18
- export declare function reactiveProp<T = unknown>({ type, attribute, reflect, defaultValue }: ReactivePropertyOptions<T>): (target: RadiantElement, propertyName: string) => void;
19
- export {};
8
+ export declare function reactiveProp<T = unknown>(options: ReactivePropertyOptions<T>): (protoOrTarget: StandardOrLegacyFieldDecoratorArgs["protoOrTarget"], nameOrContext: StandardOrLegacyFieldDecoratorArgs["nameOrContext"]) => any;
@@ -1,215 +1,4 @@
1
- // src/utils/attribute-utils.ts
2
- function parseAttributeTypeConstant(constant) {
3
- switch (constant) {
4
- case Array:
5
- return "array";
6
- case Boolean:
7
- return "boolean";
8
- case Number:
9
- return "number";
10
- case Object:
11
- return "object";
12
- case String:
13
- return "string";
14
- }
15
- }
16
- function parseAttributeTypeDefault(defaultValue) {
17
- switch (typeof defaultValue) {
18
- case "boolean":
19
- return "boolean";
20
- case "number":
21
- return "number";
22
- case "string":
23
- return "string";
24
- }
25
- if (Array.isArray(defaultValue))
26
- return "array";
27
- if (Object.prototype.toString.call(defaultValue) === "[object Object]")
28
- return "object";
29
- }
30
- function defaultValueForType(type) {
31
- switch (type) {
32
- case Number:
33
- return 0;
34
- case String:
35
- return "";
36
- case Boolean:
37
- return false;
38
- default:
39
- return null;
40
- }
41
- }
42
- function parseJSON(value) {
43
- try {
44
- return JSON.parse(value);
45
- } catch (error) {
46
- throw new TypeError("Invalid JSON string");
47
- }
48
- }
49
- function writeJSON(value) {
50
- return JSON.stringify(value);
51
- }
52
- function writeString(value) {
53
- return `${value}`;
54
- }
55
- function readAttributeValue(value, type) {
56
- const readerType = parseAttributeTypeConstant(type);
57
- if (!readerType)
58
- throw new TypeError(`[radiant-element] Unknown type "${type}"`);
59
- return readers[readerType](value);
60
- }
61
- function writeAttributeValue(value, type) {
62
- const writerType = parseAttributeTypeConstant(type);
63
- if (!writerType)
64
- throw new TypeError(`[radiant-element] Unknown type "${type}"`);
65
- return (writers[writerType] || writers.default)(value);
66
- }
67
- function isBoolean(value) {
68
- return typeof value === "boolean";
69
- }
70
- function isNumber(value) {
71
- return typeof value === "number";
72
- }
73
- function isString(value) {
74
- return typeof value === "string";
75
- }
76
- function isArray(value) {
77
- return Array.isArray(value);
78
- }
79
- function isObject(value) {
80
- return typeof value === "object" && !Array.isArray(value) && value !== null;
81
- }
82
- function isValueOfType(type, defaultValue) {
83
- switch (type) {
84
- case Boolean:
85
- return isBoolean(defaultValue);
86
- case Number:
87
- return isNumber(defaultValue);
88
- case String:
89
- return isString(defaultValue);
90
- case Array:
91
- return isArray(defaultValue);
92
- case Object:
93
- return isObject(defaultValue);
94
- default:
95
- return false;
96
- }
97
- }
98
- var readers = {
99
- array(value) {
100
- const array = parseJSON(value);
101
- if (!Array.isArray(array)) {
102
- throw new TypeError(`Expected an array but got a value of type "${typeof array}"`);
103
- }
104
- return array;
105
- },
106
- boolean(value) {
107
- return !(value === "0" || String(value).toLowerCase() === "false");
108
- },
109
- number(value) {
110
- const number = Number(value.replace(/_/g, ""));
111
- return number;
112
- },
113
- object(value) {
114
- const object = JSON.parse(value);
115
- if (object === null || typeof object !== "object" || Array.isArray(object)) {
116
- throw new TypeError(`expected value of type "object" but instead got value "${value}" of type "${parseAttributeTypeDefault(object)}"`);
117
- }
118
- return object;
119
- },
120
- string(value) {
121
- return value;
122
- }
123
- };
124
- var writers = {
125
- default: writeString,
126
- array: writeJSON,
127
- object: writeJSON
128
- };
1
+ import{F as B}from"./legacy/reactive-prop.js";import"../utils/attribute-utils.js";import{N as D}from"./standard/reactive-prop.js";function H(q){return function(z,j){if(typeof j==="object")return D(q)(z,j);return B(q)(z,j)}}export{H as reactiveProp};
2
+ export{H as E};
129
3
 
130
- // src/decorators/reactive-prop.ts
131
- function reactiveProp({ type, attribute, reflect, defaultValue }) {
132
- if (defaultValue !== undefined && !isValueOfType(type, defaultValue)) {
133
- throw new Error(`defaultValue does not match the expected type for ${type.name}`);
134
- }
135
- return (target, propertyName) => {
136
- const originalValues = new WeakMap;
137
- const attributeKey = attribute ?? propertyName;
138
- if (propertyName in target) {
139
- throw new Error(`Property "${propertyName}" already exists on ${target.constructor.name}`);
140
- }
141
- const propertyMapping = {
142
- type,
143
- propertyName,
144
- attributeKey,
145
- converter: {
146
- fromAttribute: (value) => readAttributeValue(value, type),
147
- toAttribute: (value) => writeAttributeValue(value, type)
148
- }
149
- };
150
- addPropertyToMappings(target, propertyMapping);
151
- Object.defineProperty(target, propertyName, {
152
- get: function() {
153
- if (!originalValues.has(this)) {
154
- const initialValue = getInitialValue(this, type, attributeKey, defaultValue);
155
- originalValues.set(this, initialValue);
156
- }
157
- return originalValues.get(this);
158
- },
159
- set: function(newValue) {
160
- const oldValue = originalValues.get(this);
161
- if (oldValue === newValue)
162
- return;
163
- originalValues.set(this, newValue);
164
- if (reflect) {
165
- const attributeValue = propertyMapping.converter.toAttribute(newValue);
166
- this.setAttribute(attributeKey, attributeValue);
167
- }
168
- this.updated(propertyName, oldValue, newValue);
169
- },
170
- enumerable: true,
171
- configurable: true
172
- });
173
- const originalConnectedCallback = target.connectedCallback;
174
- target.connectedCallback = function() {
175
- originalConnectedCallback.call(this);
176
- this.updated(propertyName, null, defaultValue);
177
- };
178
- addObservedAttribute(target, attributeKey);
179
- };
180
- }
181
- function addObservedAttribute(target, attribute) {
182
- const ctor = target.constructor;
183
- const existingObservedAttributes = ctor.observedAttributes || [];
184
- if (!existingObservedAttributes.includes(attribute)) {
185
- const newObservedAttributes = [...existingObservedAttributes, attribute];
186
- Object.defineProperty(ctor, "observedAttributes", {
187
- get() {
188
- return newObservedAttributes;
189
- },
190
- configurable: true
191
- });
192
- }
193
- }
194
- var getInitialValue = (target, type, attributeKey, defaultValue) => {
195
- if (type === Boolean) {
196
- const hasAttribute = target.hasAttribute(attributeKey);
197
- return hasAttribute || defaultValue;
198
- }
199
- const attributeValue = target.getAttribute(attributeKey);
200
- return attributeValue !== null ? readAttributeValue(attributeValue, type) : defaultValue || defaultValueForType(type);
201
- };
202
- var addPropertyToMappings = (target, propertyMapping) => {
203
- if (!("propertyConfigMap" in target)) {
204
- Object.defineProperty(target, "propertyConfigMap", {
205
- value: new Map,
206
- configurable: true
207
- });
208
- }
209
- target.propertyConfigMap.set(propertyMapping.propertyName, propertyMapping);
210
- };
211
- export {
212
- reactiveProp
213
- };
214
-
215
- //# debugId=1F23EE7729F124F364756E2164756E21
4
+ //# debugId=9B2752CFBE31C96A64756E2164756E21
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/utils/attribute-utils.ts", "../src/decorators/reactive-prop.ts"],
3
+ "sources": ["../src/decorators/reactive-prop.ts"],
4
4
  "sourcesContent": [
5
- "export type AttributeTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String;\n\nexport type AttributeTypeDefault = Array<unknown> | boolean | number | Record<string, unknown> | string;\n\n/**\n * Parses the given attribute type constant and returns its corresponding string representation.\n *\n * @param constant - The attribute type constant to parse.\n * @returns The string representation of the attribute type constant.\n */\nexport function parseAttributeTypeConstant(constant?: AttributeTypeConstant) {\n switch (constant) {\n case Array:\n return 'array';\n case Boolean:\n return 'boolean';\n case Number:\n return 'number';\n case Object:\n return 'object';\n case String:\n return 'string';\n }\n}\n\n/**\n * Parses the attribute type default value and returns its type as a string.\n *\n * @param defaultValue - The default value of the attribute type.\n * @returns The type of the default value as a string.\n */\nexport function parseAttributeTypeDefault(defaultValue?: AttributeTypeDefault) {\n switch (typeof defaultValue) {\n case 'boolean':\n return 'boolean';\n case 'number':\n return 'number';\n case 'string':\n return 'string';\n }\n\n if (Array.isArray(defaultValue)) return 'array';\n if (Object.prototype.toString.call(defaultValue) === '[object Object]') return 'object';\n}\n\n/**\n * Returns the default value for a given attribute type.\n *\n * @param type - The attribute type constant.\n * @returns The default value for the specified attribute type.\n */\nexport function defaultValueForType(type: AttributeTypeConstant): unknown {\n switch (type) {\n case Number:\n return 0;\n case String:\n return '';\n case Boolean:\n return false;\n default:\n return null;\n }\n}\n\ntype Reader = (value: string) => number | string | boolean | object | unknown[];\n\n/**\n * Utility function to parse a JSON string safely\n */\nfunction parseJSON<T>(value: string): T {\n try {\n return JSON.parse(value);\n } catch (error) {\n throw new TypeError('Invalid JSON string');\n }\n}\n\n/**\n * Object that maps attribute types to reader functions.\n * @type {Object.<string, Reader>}\n */\nconst readers: { [type: string]: Reader } = {\n array(value: string): unknown[] {\n const array = parseJSON<unknown[]>(value);\n if (!Array.isArray(array)) {\n throw new TypeError(`Expected an array but got a value of type \"${typeof array}\"`);\n }\n return array;\n },\n\n boolean(value: string): boolean {\n return !(value === '0' || String(value).toLowerCase() === 'false');\n },\n\n number(value: string): number {\n const number = Number(value.replace(/_/g, ''));\n return number;\n },\n\n object(value: string): object {\n const object = JSON.parse(value);\n if (object === null || typeof object !== 'object' || Array.isArray(object)) {\n throw new TypeError(\n `expected value of type \"object\" but instead got value \"${value}\" of type \"${parseAttributeTypeDefault(\n object,\n )}\"`,\n );\n }\n return object;\n },\n\n string(value: string): string {\n return value;\n },\n};\n\ntype Writer = (value: unknown) => string;\n\n/**\n * Object that maps attribute types to writer functions.\n * @type {Object.<string, Writer>}\n */\nconst writers: { [type: string]: Writer } = {\n default: writeString,\n array: writeJSON,\n object: writeJSON,\n};\n\nfunction writeJSON(value: unknown) {\n return JSON.stringify(value);\n}\n\nfunction writeString(value: unknown) {\n return `${value}`;\n}\n\n/**\n * Reads the attribute value based on the provided type.\n * @param value - The attribute value to be read.\n * @param type - The type of the attribute.\n * @returns The parsed attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function readAttributeValue(value: string, type: AttributeTypeConstant) {\n const readerType = parseAttributeTypeConstant(type);\n if (!readerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n return readers[readerType](value);\n}\n\nexport type ReadAttributeValueReturnType = ReturnType<typeof readAttributeValue>;\n\n/**\n * Writes the attribute value based on the provided type.\n *\n * @param value - The value to be written.\n * @param type - The type of the attribute.\n * @returns The written attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function writeAttributeValue(value: unknown, type: AttributeTypeConstant) {\n const writerType = parseAttributeTypeConstant(type);\n if (!writerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n return (writers[writerType] || writers.default)(value);\n}\n\nexport type WriteAttributeValueReturnType = ReturnType<typeof writeAttributeValue>;\n\n/*\n * Type guard functions for each type in AttributeTypeConstant\n */\nfunction isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\nfunction isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\nfunction isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\nfunction isArray(value: unknown): value is Array<unknown> {\n return Array.isArray(value);\n}\n\nfunction isObject(value: unknown): value is object {\n return typeof value === 'object' && !Array.isArray(value) && value !== null;\n}\n\n/*\n * Check function to ensure defaultValue matches the type\n */\nexport function isValueOfType(type: AttributeTypeConstant, defaultValue: unknown): boolean {\n switch (type) {\n case Boolean:\n return isBoolean(defaultValue);\n case Number:\n return isNumber(defaultValue);\n case String:\n return isString(defaultValue);\n case Array:\n return isArray(defaultValue);\n case Object:\n return isObject(defaultValue);\n default:\n return false;\n }\n}\n",
6
- "import type { PropertyConfig, RadiantElement } from '@/core/radiant-element';\nimport {\n type AttributeTypeConstant,\n defaultValueForType,\n isValueOfType,\n readAttributeValue,\n writeAttributeValue,\n} from '@/utils/attribute-utils';\n\ntype ReactivePropertyOptions<T> = {\n type: AttributeTypeConstant;\n reflect?: boolean;\n attribute?: string;\n defaultValue?: T;\n};\n\n/**\n * A decorator to define a reactive property.\n * Every time the property changes, the `updated` method will be called.\n * @param options The options for the reactive property.\n * @param options.type The type of the property value.\n * @param options.reflect Whether to reflect the property to the attribute.\n * @param options.attribute The name of the attribute.\n * @param options.defaultValue The default value of the property.\n */\nexport function reactiveProp<T = unknown>({ type, attribute, reflect, defaultValue }: ReactivePropertyOptions<T>) {\n if (defaultValue !== undefined && !isValueOfType(type, defaultValue)) {\n throw new Error(`defaultValue does not match the expected type for ${type.name}`);\n }\n\n return (target: RadiantElement, propertyName: string) => {\n const originalValues = new WeakMap<WeakKey, unknown>();\n const attributeKey = attribute ?? propertyName;\n\n if (propertyName in target) {\n throw new Error(`Property \"${propertyName}\" already exists on ${target.constructor.name}`);\n }\n\n const propertyMapping: PropertyConfig = {\n type,\n propertyName,\n attributeKey,\n converter: {\n fromAttribute: (value) => readAttributeValue(value, type),\n toAttribute: (value) => writeAttributeValue(value, type),\n },\n };\n\n addPropertyToMappings(target, propertyMapping);\n\n Object.defineProperty(target, propertyName, {\n get: function () {\n if (!originalValues.has(this)) {\n const initialValue = getInitialValue(this, type, attributeKey, defaultValue as T);\n originalValues.set(this, initialValue);\n }\n return originalValues.get(this);\n },\n set: function (newValue: T) {\n const oldValue = originalValues.get(this);\n if (oldValue === newValue) return;\n originalValues.set(this, newValue);\n if (reflect) {\n const attributeValue = propertyMapping.converter.toAttribute(newValue);\n this.setAttribute(attributeKey, attributeValue);\n }\n this.updated(propertyName, oldValue, newValue);\n },\n enumerable: true,\n configurable: true,\n });\n\n const originalConnectedCallback = target.connectedCallback;\n\n target.connectedCallback = function (this: RadiantElement) {\n originalConnectedCallback.call(this);\n this.updated(propertyName, null, defaultValue);\n };\n\n addObservedAttribute(target, attributeKey);\n };\n}\n\nconst getInitialValue = (\n target: RadiantElement,\n type: AttributeTypeConstant,\n attributeKey: string,\n defaultValue: unknown,\n) => {\n if (type === Boolean) {\n const hasAttribute = target.hasAttribute(attributeKey);\n return hasAttribute || defaultValue;\n }\n\n const attributeValue = target.getAttribute(attributeKey);\n return attributeValue !== null\n ? readAttributeValue(attributeValue, type)\n : defaultValue || (defaultValueForType(type) as typeof defaultValue);\n};\n\nconst addPropertyToMappings = (target: RadiantElement, propertyMapping: PropertyConfig) => {\n if (!('propertyConfigMap' in target)) {\n Object.defineProperty(target, 'propertyConfigMap', {\n value: new Map<string, PropertyConfig>(),\n configurable: true,\n });\n }\n\n target.propertyConfigMap.set(propertyMapping.propertyName, propertyMapping);\n};\n\nfunction addObservedAttribute(target: RadiantElement, attribute: string) {\n const ctor = target.constructor as typeof RadiantElement;\n const existingObservedAttributes = (ctor as any).observedAttributes || [];\n if (!existingObservedAttributes.includes(attribute)) {\n const newObservedAttributes = [...existingObservedAttributes, attribute];\n Object.defineProperty(ctor, 'observedAttributes', {\n get() {\n return newObservedAttributes;\n },\n configurable: true,\n });\n }\n}\n"
5
+ "import type { ReactivePropertyOptions } from '../core/radiant-element';\nimport type {\n LegacyFieldDecoratorArgs,\n StandardFieldDecoratorArgs,\n StandardOrLegacyFieldDecoratorArgs,\n} from '../types';\nimport { reactiveProp as legacyReactiveProp } from './legacy/reactive-prop';\nimport { reactiveProp as standardReactiveProp } from './standard/reactive-prop';\n\n/**\n * A decorator to define a reactive property.\n * Every time the property changes, the `updated` method will be called.\n * @param options {@link ReactivePropertyOptions} The options for the reactive property.\n */\nexport function reactiveProp<T = unknown>(options: ReactivePropertyOptions<T>) {\n return function (\n protoOrTarget: StandardOrLegacyFieldDecoratorArgs['protoOrTarget'],\n nameOrContext: StandardOrLegacyFieldDecoratorArgs['nameOrContext'],\n ): any {\n if (typeof nameOrContext === 'object') {\n return standardReactiveProp(options)(\n protoOrTarget as StandardFieldDecoratorArgs['protoOrTarget'],\n nameOrContext as StandardFieldDecoratorArgs['nameOrContext'],\n );\n }\n return legacyReactiveProp(options)(\n protoOrTarget as LegacyFieldDecoratorArgs['protoOrTarget'],\n nameOrContext as LegacyFieldDecoratorArgs['nameOrContext'],\n );\n };\n}\n"
7
6
  ],
8
- "mappings": ";AAUO,SAAS,0BAA0B,CAAC,UAAkC;AAC3E,UAAQ;AAAA,SACD;AACH,aAAO;AAAA,SACJ;AACH,aAAO;AAAA,SACJ;AACH,aAAO;AAAA,SACJ;AACH,aAAO;AAAA,SACJ;AACH,aAAO;AAAA;AAAA;AAUN,SAAS,yBAAyB,CAAC,cAAqC;AAC7E,iBAAe;AAAA,SACR;AACH,aAAO;AAAA,SACJ;AACH,aAAO;AAAA,SACJ;AACH,aAAO;AAAA;AAGX,MAAI,MAAM,QAAQ,YAAY;AAAG,WAAO;AACxC,MAAI,OAAO,UAAU,SAAS,KAAK,YAAY,MAAM;AAAmB,WAAO;AAAA;AAS1E,SAAS,mBAAmB,CAAC,MAAsC;AACxE,UAAQ;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ACA,iBACG;AACH,MAAI,SAAS,SAAS;AACpB,UAAM,eAAe,OAAO,aAAa,YAAY;AACrD,WAAO,gBAAgB;AAAA,EACzB;AAEA,QAAM,iBAAiB,OAAO,aAAa,YAAY;AACvD,SAAO,mBAAmB,OACtB,mBAAmB,gBAAgB,IAAI,IACvC,gBAAiB,oBAAoB,IAAI;AAAA;AAG/C,IAAM,wBAAwB,CAAC,QAAwB,oBAAoC;AACzF,QAAM,uBAAuB,SAAS;AACpC,WAAO,eAAe,QAAQ,qBAAqB;AAAA,MACjD,OAAO,IAAI;AAAA,MACX,cAAc;AAAA,IAChB,CAAC;AAAA,EACH;AAEA,SAAO,kBAAkB,IAAI,gBAAgB,cAAc,eAAe;AAAA;",
9
- "debugId": "1F23EE7729F124F364756E2164756E21",
7
+ "mappings": "8HAcO,WAAS,GAAyB,CAAC,EAAqC,CAC7E,eAAgB,CACd,EACA,EACK,CACL,UAAW,IAAkB,SAC3B,OAAO,EAAqB,CAAO,EACjC,EACA,CACF,EAEF,OAAO,EAAmB,CAAO,EAC/B,EACA,CACF",
8
+ "debugId": "9B2752CFBE31C96A64756E2164756E21",
10
9
  "names": []
11
10
  }
@@ -0,0 +1,2 @@
1
+ import type { Method } from '../../types';
2
+ export declare function bound<T extends Method>(_: T, context: ClassMethodDecoratorContext): void;
@@ -0,0 +1,4 @@
1
+ function o(i,t){const e=String(t.name);if(t.private)throw new Error(`'bound' cannot decorate private properties like ${e}.`);t.addInitializer(function(){this[e]=this[e].bind(this)})}export{o as bound};
2
+ export{o as b};
3
+
4
+ //# debugId=5E969AAAFC48310564756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/decorators/standard/bound.ts"],
4
+ "sourcesContent": [
5
+ "import type { Method } from '../../types';\n\nexport function bound<T extends Method>(_: T, context: ClassMethodDecoratorContext) {\n const methodName = String(context.name);\n if (context.private) {\n throw new Error(`'bound' cannot decorate private properties like ${methodName as string}.`);\n }\n context.addInitializer(function (this: any) {\n this[methodName] = this[methodName].bind(this);\n });\n}\n"
6
+ ],
7
+ "mappings": "AAEO,SAAS,CAAuB,CAAC,EAAM,EAAsC,CAClF,MAAM,EAAa,OAAO,EAAQ,IAAI,EACtC,GAAI,EAAQ,QACV,MAAM,IAAI,MAAM,mDAAmD,IAAuB,EAE5F,EAAQ,uBAAwB,EAAY,CAC1C,KAAK,GAAc,KAAK,GAAY,KAAK,IAAI,EAC9C",
8
+ "debugId": "5E969AAAFC48310564756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1 @@
1
+ export declare function customElement(name: string, options?: ElementDefinitionOptions): <T extends CustomElementConstructor>(_: T, context: ClassDecoratorContext<T>) => void;
@@ -0,0 +1,4 @@
1
+ function i(t,n){return function(o,e){e.addInitializer(function(){if(!window.customElements.get(t))customElements.define(t,this,n)})}}export{i as customElement};
2
+ export{i as y};
3
+
4
+ //# debugId=E1F3CF85FE4BDE1464756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/decorators/standard/custom-element.ts"],
4
+ "sourcesContent": [
5
+ "export function customElement(name: string, options?: ElementDefinitionOptions) {\n return function <T extends CustomElementConstructor>(_: T, context: ClassDecoratorContext<T>) {\n context.addInitializer(function () {\n if (!window.customElements.get(name)) {\n customElements.define(name, this, options);\n }\n });\n };\n}\n"
6
+ ],
7
+ "mappings": "AAAO,SAAS,CAAa,CAAC,EAAc,EAAoC,CAC9E,eAAoD,CAAC,EAAM,EAAmC,CAC5F,EAAQ,uBAAwB,EAAG,CACjC,IAAK,OAAO,eAAe,IAAI,CAAI,EACjC,eAAe,OAAO,EAAM,KAAM,CAAO,EAE5C",
8
+ "debugId": "E1F3CF85FE4BDE1464756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,2 @@
1
+ import type { Method } from '../../types';
2
+ export declare function debounce(timeout: number): Method;
@@ -0,0 +1,4 @@
1
+ function o(n){let e=null;return(t)=>{return function(...u){if(e!==null)clearTimeout(e);return e=setTimeout(()=>{t.apply(this,u)},n),t}}}export{o as debounce};
2
+ export{o as D};
3
+
4
+ //# debugId=DF32024986E9C26864756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/decorators/standard/debounce.ts"],
4
+ "sourcesContent": [
5
+ "import type { Method } from '../../types';\n\nexport function debounce(timeout: number): Method {\n let timeoutRef: ReturnType<typeof setTimeout> | null = null;\n\n return <T extends Method>(originalMethod: T): Method => {\n return function (this: any, ...args: any[]): T {\n if (timeoutRef !== null) {\n clearTimeout(timeoutRef);\n }\n\n timeoutRef = setTimeout(() => {\n originalMethod.apply(this, args);\n }, timeout);\n\n return originalMethod;\n };\n };\n}\n"
6
+ ],
7
+ "mappings": "AAEO,SAAS,CAAQ,CAAC,EAAyB,CAChD,IAAI,EAAmD,KAEvD,MAAO,CAAmB,IAA8B,CACtD,eAAgB,IAAe,EAAgB,CAC7C,GAAI,IAAe,KACjB,aAAa,CAAU,EAOzB,OAJA,EAAa,WAAW,IAAM,CAC5B,EAAe,MAAM,KAAM,CAAI,GAC9B,CAAO,EAEH",
8
+ "debugId": "DF32024986E9C26864756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,9 @@
1
+ import type { RadiantElement } from '../../core/radiant-element';
2
+ import { type EventEmitterConfig } from '../../tools/event-emitter';
3
+ /**
4
+ * Decorator that attaches an EventEmitter to the class field property.
5
+ * The EventEmitter can be used to dispatch custom events from the target element.
6
+ * @param eventConfig Configuration for the event emitter.
7
+ * @see {@link EventEmitter} for more details about how the EventEmitter works.
8
+ */
9
+ export declare function event(eventConfig: EventEmitterConfig): <T extends RadiantElement, V>(_: undefined, context: ClassFieldDecoratorContext<T, V>) => void;
@@ -0,0 +1,4 @@
1
+ import{U as z}from"../../tools/event-emitter.js";function F(j){return function(A,q){q.addInitializer(function(){this.registerEventEmitter(j.name,new z(this,j)),Object.defineProperty(this,q.name,{get(){return this.eventEmitters.get(j.name)},enumerable:!0,configurable:!0})})}}export{F as event};
2
+ export{F as T};
3
+
4
+ //# debugId=60C8B5654FFB2E2B64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/decorators/standard/event.ts"],
4
+ "sourcesContent": [
5
+ "import type { RadiantElement } from '../../core/radiant-element';\nimport { EventEmitter, type EventEmitterConfig } from '../../tools/event-emitter';\n\n/**\n * Decorator that attaches an EventEmitter to the class field property.\n * The EventEmitter can be used to dispatch custom events from the target element.\n * @param eventConfig Configuration for the event emitter.\n * @see {@link EventEmitter} for more details about how the EventEmitter works.\n */\nexport function event(eventConfig: EventEmitterConfig) {\n return function <T extends RadiantElement, V>(_: undefined, context: ClassFieldDecoratorContext<T, V>) {\n context.addInitializer(function (this: T) {\n this.registerEventEmitter(eventConfig.name, new EventEmitter(this, eventConfig));\n\n Object.defineProperty(this, context.name, {\n get() {\n return this.eventEmitters.get(eventConfig.name);\n },\n enumerable: true,\n configurable: true,\n });\n });\n };\n}\n"
6
+ ],
7
+ "mappings": "iDASO,SAAS,CAAK,CAAC,EAAiC,CACrD,eAA6C,CAAC,EAAc,EAA2C,CACrG,EAAQ,uBAAwB,EAAU,CACxC,KAAK,qBAAqB,EAAY,KAAM,IAAI,EAAa,KAAM,CAAW,CAAC,EAE/E,OAAO,eAAe,KAAM,EAAQ,KAAM,CACxC,GAAG,EAAG,CACJ,OAAO,KAAK,cAAc,IAAI,EAAY,IAAI,GAEhD,WAAY,GACZ,aAAc,EAChB,CAAC,EACF",
8
+ "debugId": "60C8B5654FFB2E2B64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,27 @@
1
+ import type { RadiantElementEventListener } from '../../core/radiant-element';
2
+ import type { Method } from '../../types';
3
+ type OnEventConfig = Pick<RadiantElementEventListener, 'type' | 'options'> & ({
4
+ selector: string;
5
+ } | {
6
+ ref: string;
7
+ } | {
8
+ window: boolean;
9
+ } | {
10
+ document: boolean;
11
+ });
12
+ /**
13
+ * A decorator to subscribe to an event on the target element.
14
+ * The event listener will be automatically unsubscribed when the element is disconnected.
15
+ *
16
+ * Note: This decorator uses event delegation, which means it relies on event bubbling.
17
+ * Therefore, it will not work with events that do not bubble, such as `focus`, `blur`, `load`, `unload`, `scroll`, etc.
18
+ * For focus and blur events, consider using `focusin` and `focusout` which are similar but do bubble.
19
+ *
20
+ * @param eventConfig The event configuration.
21
+ * @param eventConfig.selectors The CSS selector(s) of the target element(s).
22
+ * @param eventConfig.ref The data-ref attribute of the target element.
23
+ * @param eventConfig.type The type of the event to listen for.
24
+ * @param eventConfig.options Optional. An options object that specifies characteristics about the event listener.
25
+ */
26
+ export declare function onEvent(eventConfig: OnEventConfig): <T extends Method>(originalMethod: T, context: ClassMethodDecoratorContext) => void;
27
+ export {};
@@ -0,0 +1,4 @@
1
+ function G(q){return function(D,E){E.addInitializer(function(){const z=D.bind(this);if("window"in q)window.addEventListener(q.type,z,q.options),this.registerCleanupCallback(()=>{window.removeEventListener(q.type,z,q.options)});if("document"in q)document.addEventListener(q.type,z,q.options),this.registerCleanupCallback(()=>{document.removeEventListener(q.type,z,q.options)});const B="selector"in q?q.selector:("ref"in q)&&`[data-ref="${q.ref}"]`;if(B)this.subscribeEvent({selector:B,type:q.type,listener:z,options:q?.options??void 0})})}}export{G as onEvent};
2
+ export{G as Q};
3
+
4
+ //# debugId=5CF41968C454A83F64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/decorators/standard/on-event.ts"],
4
+ "sourcesContent": [
5
+ "import type { RadiantElement, RadiantElementEventListener } from '../../core/radiant-element';\nimport type { Method } from '../../types';\n\ntype OnEventConfig = Pick<RadiantElementEventListener, 'type' | 'options'> &\n (\n | {\n selector: string;\n }\n | {\n ref: string;\n }\n | {\n window: boolean;\n }\n | {\n document: boolean;\n }\n );\n\n/**\n * A decorator to subscribe to an event on the target element.\n * The event listener will be automatically unsubscribed when the element is disconnected.\n *\n * Note: This decorator uses event delegation, which means it relies on event bubbling.\n * Therefore, it will not work with events that do not bubble, such as `focus`, `blur`, `load`, `unload`, `scroll`, etc.\n * For focus and blur events, consider using `focusin` and `focusout` which are similar but do bubble.\n *\n * @param eventConfig The event configuration.\n * @param eventConfig.selectors The CSS selector(s) of the target element(s).\n * @param eventConfig.ref The data-ref attribute of the target element.\n * @param eventConfig.type The type of the event to listen for.\n * @param eventConfig.options Optional. An options object that specifies characteristics about the event listener.\n */\nexport function onEvent(eventConfig: OnEventConfig) {\n return function <T extends Method>(originalMethod: T, context: ClassMethodDecoratorContext): void {\n context.addInitializer(function (this: any) {\n const boundMethod = originalMethod.bind(this);\n\n if ('window' in eventConfig) {\n window.addEventListener(eventConfig.type, boundMethod, eventConfig.options);\n (this as RadiantElement).registerCleanupCallback(() => {\n window.removeEventListener(eventConfig.type, boundMethod, eventConfig.options);\n });\n }\n\n if ('document' in eventConfig) {\n document.addEventListener(eventConfig.type, boundMethod, eventConfig.options);\n (this as RadiantElement).registerCleanupCallback(() => {\n document.removeEventListener(eventConfig.type, boundMethod, eventConfig.options);\n });\n }\n\n const selector =\n 'selector' in eventConfig ? eventConfig.selector : 'ref' in eventConfig && `[data-ref=\"${eventConfig.ref}\"]`;\n\n if (selector) {\n (this as RadiantElement).subscribeEvent({\n selector: selector,\n type: eventConfig.type,\n listener: boundMethod,\n options: eventConfig?.options ?? undefined,\n });\n }\n });\n };\n}\n"
6
+ ],
7
+ "mappings": "AAiCO,SAAS,CAAO,CAAC,EAA4B,CAClD,eAAkC,CAAC,EAAmB,EAA4C,CAChG,EAAQ,uBAAwB,EAAY,CAC1C,MAAM,EAAc,EAAe,KAAK,IAAI,EAE5C,GAAI,WAAY,EACd,OAAO,iBAAiB,EAAY,KAAM,EAAa,EAAY,OAAO,EACzE,KAAwB,wBAAwB,IAAM,CACrD,OAAO,oBAAoB,EAAY,KAAM,EAAa,EAAY,OAAO,EAC9E,EAGH,GAAI,aAAc,EAChB,SAAS,iBAAiB,EAAY,KAAM,EAAa,EAAY,OAAO,EAC3E,KAAwB,wBAAwB,IAAM,CACrD,SAAS,oBAAoB,EAAY,KAAM,EAAa,EAAY,OAAO,EAChF,EAGH,MAAM,EACJ,aAAc,EAAc,EAAY,UAAW,QAAS,IAAe,cAAc,EAAY,QAEvG,GAAI,EACF,AAAC,KAAwB,eAAe,CACtC,SAAU,EACV,KAAM,EAAY,KAClB,SAAU,EACV,QAAS,GAAa,SAAW,MACnC,CAAC,EAEJ",
8
+ "debugId": "5CF41968C454A83F64756E2164756E21",
9
+ "names": []
10
+ }