@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,54 +1,4 @@
1
- // src/context/events.ts
2
- var ContextEventsTypes;
3
- ((ContextEventsTypes2) => {
4
- ContextEventsTypes2["SUBSCRIPTION_REQUEST"] = "context--subscription-request";
5
- ContextEventsTypes2["CONTEXT_REQUEST"] = "context-request";
6
- ContextEventsTypes2["ON_MOUNT"] = "context--on-mount";
7
- })(ContextEventsTypes ||= {});
1
+ var z;((j)=>{j.SUBSCRIPTION_REQUEST="context-subscription-request";j.CONTEXT_REQUEST="context-request";j.ON_MOUNT="context-on-mount";j.MOUNTED="context-mounted"})(z||={});class B extends Event{k;q;w;constructor(k,q,w){super("context-request",{bubbles:!0,composed:!0});this.context=k;this.callback=q;this.subscribe=w}}class D extends CustomEvent{constructor(k){super("context-on-mount",{detail:{context:k},bubbles:!0,composed:!0})}}class F extends Event{k;q;w;G;constructor(k,q,w,G){super("context-subscription-request",{bubbles:!0,composed:!0});this.context=k;this.callback=q;this.select=w;this.subscribe=G}}export{F as ContextSubscriptionRequestEvent,B as ContextRequestEvent,D as ContextOnMountEvent,z as ContextEventsTypes};
2
+ export{B as p,D as q,F as r};
8
3
 
9
- class ContextRequestEvent extends Event {
10
- context;
11
- callback;
12
- subscribe;
13
- constructor(context, callback, subscribe) {
14
- super("context-request" /* CONTEXT_REQUEST */, { bubbles: true, composed: true });
15
- this.context = context;
16
- this.callback = callback;
17
- this.subscribe = subscribe;
18
- }
19
- }
20
-
21
- class ContextOnMountEvent extends CustomEvent {
22
- constructor(context) {
23
- super("context--on-mount" /* ON_MOUNT */, {
24
- detail: { context },
25
- bubbles: true,
26
- composed: true
27
- });
28
- }
29
- }
30
-
31
- class ContextSubscriptionRequestEvent extends Event {
32
- context;
33
- callback;
34
- select;
35
- subscribe;
36
- constructor(context, callback, select, subscribe) {
37
- super("context--subscription-request" /* SUBSCRIPTION_REQUEST */, {
38
- bubbles: true,
39
- composed: true
40
- });
41
- this.context = context;
42
- this.callback = callback;
43
- this.select = select;
44
- this.subscribe = subscribe;
45
- }
46
- }
47
- export {
48
- ContextSubscriptionRequestEvent,
49
- ContextRequestEvent,
50
- ContextOnMountEvent,
51
- ContextEventsTypes
52
- };
53
-
54
- //# debugId=85CDB913AD2268D764756E2164756E21
4
+ //# debugId=CD57E830D3B70B5964756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/context/events.ts"],
4
4
  "sourcesContent": [
5
- "import type { Context, ContextCallback, ContextType, UnknownContext } from './types';\n\n/**\n * List of events which can be emitted by a context provider or requester.\n */\nexport enum ContextEventsTypes {\n SUBSCRIPTION_REQUEST = 'context--subscription-request',\n CONTEXT_REQUEST = 'context-request',\n ON_MOUNT = 'context--on-mount',\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n */\nexport class ContextRequestEvent<T extends UnknownContext> extends Event {\n public constructor(\n public readonly context: T,\n public readonly callback: ContextCallback<ContextType<T>>,\n public readonly subscribe?: boolean,\n ) {\n super(ContextEventsTypes.CONTEXT_REQUEST, { bubbles: true, composed: true });\n }\n}\n\n/**\n * A type which represents a subscription to a context value.\n */\nexport type ContextSubscription<T extends UnknownContext> = {\n select?: (context: ContextType<T>) => unknown;\n callback: (value: unknown) => void;\n};\n\n/**\n * An event fired by a context provider to signal that a context value has been mounted and is available for consumption.\n */\nexport class ContextOnMountEvent extends CustomEvent<{ context: UnknownContext }> {\n public constructor(context: UnknownContext) {\n super(ContextEventsTypes.ON_MOUNT, {\n detail: { context },\n bubbles: true,\n composed: true,\n });\n }\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n *\n * It accepts a `selector` property which can be used to request a specific property of the context value.\n */\nexport class ContextSubscriptionRequestEvent<T extends UnknownContext> extends Event {\n public constructor(\n public readonly context: T,\n public readonly callback: (value: ContextType<T> | { [K in keyof ContextType<T>]: ContextType<T>[K] }) => void,\n public readonly select?: (context: ContextType<T>) => unknown,\n public readonly subscribe?: boolean,\n ) {\n super(ContextEventsTypes.SUBSCRIPTION_REQUEST, {\n bubbles: true,\n composed: true,\n });\n }\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n /**\n * A 'context-request-subscription' event can be emitted by any element which desires\n * a context value to be injected by an external provider.\n */\n [ContextEventsTypes.SUBSCRIPTION_REQUEST]: ContextSubscriptionRequestEvent<UnknownContext>;\n /**\n * A context-request-provider event can be emitted by a context requester to signal\n * that it desires a context value to be provided by a context provider.\n */\n [ContextEventsTypes.CONTEXT_REQUEST]: ContextRequestEvent<Context<unknown, unknown>>;\n /**\n * A 'context-mount' event can be emitted by a context provider to signal\n * that a context value has been mounted and is available for consumption.\n */\n [ContextEventsTypes.ON_MOUNT]: ContextOnMountEvent;\n }\n}\n"
5
+ "import type { Context, ContextCallback, ContextType, UnknownContext } from './types';\n\n/**\n * List of events which can be emitted by a context provider or requester.\n */\nexport enum ContextEventsTypes {\n SUBSCRIPTION_REQUEST = 'context-subscription-request',\n CONTEXT_REQUEST = 'context-request',\n ON_MOUNT = 'context-on-mount',\n MOUNTED = 'context-mounted',\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n */\nexport class ContextRequestEvent<T extends UnknownContext> extends Event {\n public constructor(\n public readonly context: T,\n public readonly callback: ContextCallback<ContextType<T>>,\n public readonly subscribe?: boolean,\n ) {\n super(ContextEventsTypes.CONTEXT_REQUEST, { bubbles: true, composed: true });\n }\n}\n\n/**\n * A type which represents a subscription to a context value.\n */\nexport type ContextSubscription<T extends UnknownContext> = {\n select?: (context: ContextType<T>) => unknown;\n callback: (value: unknown) => void;\n};\n\n/**\n * An event fired by a context provider to signal that a context value has been mounted and is available for consumption.\n */\nexport class ContextOnMountEvent extends CustomEvent<{ context: UnknownContext }> {\n public constructor(context: UnknownContext) {\n super(ContextEventsTypes.ON_MOUNT, {\n detail: { context },\n bubbles: true,\n composed: true,\n });\n }\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n *\n * It accepts a `selector` property which can be used to request a specific property of the context value.\n */\nexport class ContextSubscriptionRequestEvent<T extends UnknownContext> extends Event {\n public constructor(\n public readonly context: T,\n public readonly callback: (value: ContextType<T> | { [K in keyof ContextType<T>]: ContextType<T>[K] }) => void,\n public readonly select?: (context: ContextType<T>) => unknown,\n public readonly subscribe?: boolean,\n ) {\n super(ContextEventsTypes.SUBSCRIPTION_REQUEST, {\n bubbles: true,\n composed: true,\n });\n }\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n /**\n * A 'context-request-subscription' event can be emitted by any element which desires\n * a context value to be injected by an external provider.\n */\n [ContextEventsTypes.SUBSCRIPTION_REQUEST]: ContextSubscriptionRequestEvent<UnknownContext>;\n /**\n * A context-request-provider event can be emitted by a context requester to signal\n * that it desires a context value to be provided by a context provider.\n */\n [ContextEventsTypes.CONTEXT_REQUEST]: ContextRequestEvent<Context<unknown, unknown>>;\n /**\n * A 'context-mount' event can be emitted by a context provider to signal\n * that a context value has been mounted and is available for consumption.\n */\n [ContextEventsTypes.ON_MOUNT]: ContextOnMountEvent;\n }\n}\n"
6
6
  ],
7
- "mappings": ";AAKO,IAAK;AAAL,EAAK,wBAAL;AACL,gDAAuB;AACvB,2CAAkB;AAClB,oCAAW;AAAA,GAHD;AAgBL;AAAA,MAAM,4BAAsD,MAAM;AAAA,EAErD;AAAA,EACA;AAAA,EACA;AAAA,EAHX,WAAW,CACA,SACA,UACA,WAChB;AACA,UAAM,yCAAoC,EAAE,SAAS,MAAM,UAAU,KAAK,CAAC;AAJ3D;AACA;AACA;AAAA;AAIpB;AAaO;AAAA,MAAM,4BAA4B,YAAyC;AAAA,EACzE,WAAW,CAAC,SAAyB;AAC1C,UAAM,oCAA6B;AAAA,MACjC,QAAQ,EAAE,QAAQ;AAAA,MAClB,SAAS;AAAA,MACT,UAAU;AAAA,IACZ,CAAC;AAAA;AAEL;AAcO;AAAA,MAAM,wCAAkE,MAAM;AAAA,EAEjE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAJX,WAAW,CACA,SACA,UACA,QACA,WAChB;AACA,UAAM,4DAAyC;AAAA,MAC7C,SAAS;AAAA,MACT,UAAU;AAAA,IACZ,CAAC;AARe;AACA;AACA;AACA;AAAA;AAOpB;",
8
- "debugId": "85CDB913AD2268D764756E2164756E21",
7
+ "mappings": "AAKO,IAAK,EAAL,EAAK,IAAL,CACL,uBAAuB,+BACvB,kBAAkB,kBAClB,WAAW,mBACX,UAAU,oBAJA,QAiBL,MAAM,UAAsD,KAAM,CAErD,EACA,EACA,EAHX,WAAW,CACA,EACA,EACA,EAChB,CACA,MAAM,kBAAoC,CAAE,QAAS,GAAM,SAAU,EAAK,CAAC,EAJ3D,eACA,gBACA,iBAIpB,CAaO,MAAM,UAA4B,WAAyC,CACzE,WAAW,CAAC,EAAyB,CAC1C,MAAM,mBAA6B,CACjC,OAAQ,CAAE,SAAQ,EAClB,QAAS,GACT,SAAU,EACZ,CAAC,EAEL,CAcO,MAAM,UAAkE,KAAM,CAEjE,EACA,EACA,EACA,EAJX,WAAW,CACA,EACA,EACA,EACA,EAChB,CACA,MAAM,+BAAyC,CAC7C,QAAS,GACT,SAAU,EACZ,CAAC,EARe,eACA,gBACA,cACA,iBAOpB",
8
+ "debugId": "CD57E830D3B70B5964756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,6 @@
1
+ import type { EventEmitter } from '../tools';
1
2
  import type { UnknownContext } from '../context/types';
2
- import type { AttributeTypeConstant, ReadAttributeValueReturnType, WriteAttributeValueReturnType } from '../utils';
3
+ import { type AttributeTypeConstant, type ReadAttributeValueReturnType, type WriteAttributeValueReturnType } from '../utils/attribute-utils';
3
4
  /**
4
5
  * Possible positions to insert a rendered template.
5
6
  */
@@ -11,21 +12,36 @@ export type RadiantElementEventListener = {
11
12
  selector: string;
12
13
  type: string;
13
14
  listener: EventListener;
14
- id: string;
15
15
  options?: AddEventListenerOptions;
16
16
  };
17
17
  /**
18
18
  * Represents a property metadata object.
19
19
  */
20
- export interface PropertyConfig {
20
+ export interface ReactiveProperty<T = unknown> {
21
21
  type: AttributeTypeConstant;
22
- propertyName: string;
23
- attributeKey: string;
22
+ value?: T;
23
+ initialValue?: T;
24
+ name: string;
25
+ attribute: string;
24
26
  converter: {
25
27
  fromAttribute: (value: string) => ReadAttributeValueReturnType;
26
28
  toAttribute: (value: any) => WriteAttributeValueReturnType;
27
29
  };
28
30
  }
31
+ /**
32
+ * Represents the options for a reactive property.
33
+ */
34
+ export type ReactivePropertyOptions<T> = {
35
+ type: AttributeTypeConstant;
36
+ reflect?: boolean;
37
+ attribute?: string;
38
+ defaultValue?: T;
39
+ };
40
+ export type ReactiveField<T = unknown> = {
41
+ name: string;
42
+ value: T;
43
+ initialValue: T;
44
+ };
29
45
  /**
30
46
  * Represents an interface for a Radiant element.
31
47
  */
@@ -36,7 +52,7 @@ export interface IRadiantElement {
36
52
  * @param oldValue - The old value of the property.
37
53
  * @param newValue - The new value of the property.
38
54
  */
39
- updated(changedProperty: string, oldValue: unknown, newValue: unknown): void;
55
+ notifyUpdate(changedProperty: string, oldValue: unknown, newValue: unknown): void;
40
56
  /**
41
57
  * Subscribes to a Radiant element event.
42
58
  * @param event - The event listener to subscribe to.
@@ -48,14 +64,9 @@ export interface IRadiantElement {
48
64
  */
49
65
  subscribeEvents(events: RadiantElementEventListener[]): void;
50
66
  /**
51
- * Unsubscribes from a Radiant element event.
52
- * @param id - The ID of the event listener to unsubscribe from.
53
- */
54
- unsubscribeEvent(id: string): void;
55
- /**
56
- * Removes all subscribed events from the Radiant element.
67
+ * It adds a callback to be executed when the Radiant element is disconnected from the DOM.
57
68
  */
58
- removeAllSubscribedEvents(): void;
69
+ registerCleanupCallback(callback: () => void): void;
59
70
  /**
60
71
  * Renders a template into the specified target element.
61
72
  * @param options - The rendering options.
@@ -73,6 +84,13 @@ export interface IRadiantElement {
73
84
  * @param context - The connected context.
74
85
  */
75
86
  connectedContextCallback(context: UnknownContext): void;
87
+ /**
88
+ * Gets a reference to a child element by its data-ref attribute.
89
+ * @param ref - The data-ref attribute value of the element to get.
90
+ * @param all - Whether to get all elements with the specified data-ref attribute value.
91
+ * @returns The element with the specified data-ref attribute value, an array of elements or null if no element was found.
92
+ */
93
+ getRef<T extends Element = Element>(ref: string, all: boolean): T | T[];
76
94
  }
77
95
  /**
78
96
  * A base class for creating custom elements with reactive properties and event subscriptions.
@@ -80,22 +98,56 @@ export interface IRadiantElement {
80
98
  * @implements IRadiantElement
81
99
  */
82
100
  export declare class RadiantElement extends HTMLElement implements IRadiantElement {
83
- propertyConfigMap: Map<string, PropertyConfig>;
84
- updatesRegistry: Map<string, Set<string>>;
101
+ /**
102
+ * A map of property metadata objects, it contains useful information about the properties configured via decorators.
103
+ */
104
+ private reactiveProperties;
105
+ /**
106
+ * A map of reactive fields, it contains the reactive fields configured via decorators.
107
+ */
108
+ private reactiveFields;
109
+ /**
110
+ * A map of property update callbacks. These callbacks are called when a property is updated.
111
+ */
112
+ private updateCallbacks;
113
+ /**
114
+ * A map of event subscriptions used to manage event listeners on the Radiant element.
115
+ */
85
116
  private eventSubscriptions;
117
+ /**
118
+ * A map for event emitters
119
+ */
120
+ private eventEmitters;
121
+ /**
122
+ * An array of cleanup callbacks to be executed when the Radiant element is disconnected from the DOM.
123
+ */
124
+ private onDisconnectedCallback;
125
+ /**
126
+ * A flag indicating whether the element has been connected to the DOM.
127
+ */
86
128
  private elementReady;
87
129
  connectedCallback(): void;
88
130
  connectedContextCallback(_contextName: UnknownContext): void;
89
131
  disconnectedCallback(): void;
90
- updated(changedProperty: string, oldValue: unknown, value: unknown): void;
132
+ notifyUpdate(changedProperty: string, oldValue: unknown, value: unknown): void;
133
+ private transformAttributeValue;
91
134
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
92
135
  renderTemplate({ target, template, insert, }: {
93
136
  target: HTMLElement;
94
137
  template: string;
95
138
  insert?: RenderInsertPosition;
96
139
  }): void;
97
- subscribeEvents(events: RadiantElementEventListener[]): void;
98
- subscribeEvent(eventConfig: RadiantElementEventListener): void;
99
- unsubscribeEvent(id: string): void;
100
- removeAllSubscribedEvents(): void;
140
+ registerReactiveProperty(config: ReactiveProperty): void;
141
+ registerReactiveField<T>(config: ReactiveField<T>): void;
142
+ registerUpdateCallback(property: string, update: (...rest: any[]) => any): void;
143
+ subscribeEvents(events: RadiantElementEventListener[]): Array<() => void>;
144
+ subscribeEvent(eventConfig: RadiantElementEventListener): () => void;
145
+ private unsubscribeEvent;
146
+ private removeAllSubscribedEvents;
147
+ registerCleanupCallback(callback: () => void): void;
148
+ registerEventEmitter(name: string, emitter: EventEmitter): void;
149
+ getRef<T extends Element = Element>(ref: string, all: true): T[];
150
+ getRef<T extends Element = Element>(ref: string, all?: false): T;
151
+ createReactiveField<T>(propertyName: string, initialValue: T): void;
152
+ createReactiveProp<T = unknown>(propertyName: string, options: ReactivePropertyOptions<T>): void;
101
153
  }
@@ -1,83 +1,4 @@
1
- // src/core/radiant-element.ts
2
- class RadiantElement extends HTMLElement {
3
- eventSubscriptions = new Map;
4
- elementReady = false;
5
- connectedCallback() {
6
- this.elementReady = true;
7
- }
8
- connectedContextCallback(_contextName) {
9
- }
10
- disconnectedCallback() {
11
- this.removeAllSubscribedEvents();
12
- }
13
- updated(changedProperty, oldValue, value) {
14
- if (!this.elementReady || !this.updatesRegistry || oldValue === value)
15
- return;
16
- const updates = this.updatesRegistry.get(changedProperty);
17
- if (updates) {
18
- for (const update of updates) {
19
- this[update]();
20
- }
21
- }
22
- }
23
- attributeChangedCallback(name, oldValue, newValue) {
24
- if (oldValue === newValue || !this.elementReady)
25
- return;
26
- if (name in this) {
27
- const config = this.propertyConfigMap.get(name);
28
- const transformedValue = newValue ? config?.converter.fromAttribute(newValue) : newValue;
29
- const transformedOldValue = oldValue ? config?.converter.fromAttribute(oldValue) : oldValue;
30
- this[name] = transformedValue;
31
- this.updated(name, transformedOldValue, transformedValue);
32
- }
33
- }
34
- renderTemplate({
35
- target = this,
36
- template,
37
- insert = "replace"
38
- }) {
39
- switch (insert) {
40
- case "replace":
41
- target.innerHTML = template;
42
- break;
43
- case "beforeend":
44
- target.insertAdjacentHTML("beforeend", template);
45
- break;
46
- case "afterbegin":
47
- target.insertAdjacentHTML("afterbegin", template);
48
- break;
49
- }
50
- }
51
- subscribeEvents(events) {
52
- for (const event of events) {
53
- this.subscribeEvent(event);
54
- }
55
- }
56
- subscribeEvent(eventConfig) {
57
- const delegatedListener = (delegatedEvent) => {
58
- if (delegatedEvent.target && delegatedEvent.target.matches(eventConfig.selector)) {
59
- eventConfig.listener.call(this, delegatedEvent);
60
- }
61
- };
62
- this.addEventListener(eventConfig.type, delegatedListener, eventConfig.options);
63
- this.eventSubscriptions.set(eventConfig.id, { ...eventConfig, listener: delegatedListener });
64
- }
65
- unsubscribeEvent(id) {
66
- const eventSubscription = this.eventSubscriptions.get(id);
67
- if (eventSubscription) {
68
- this.removeEventListener(eventSubscription.type, eventSubscription.listener, eventSubscription.options);
69
- this.eventSubscriptions.delete(id);
70
- }
71
- }
72
- removeAllSubscribedEvents() {
73
- for (const eventSubscription of this.eventSubscriptions.values()) {
74
- this.removeEventListener(eventSubscription.type, eventSubscription.listener, eventSubscription.options);
75
- }
76
- this.eventSubscriptions.clear();
77
- }
78
- }
79
- export {
80
- RadiantElement
81
- };
1
+ import{J as Z,K as _,L as $,M as D}from"../utils/attribute-utils.js";class T extends HTMLElement{reactiveProperties=new Map;reactiveFields=new Map;updateCallbacks=new Map;eventSubscriptions=new Map;eventEmitters=new Map;onDisconnectedCallback=[];elementReady=!1;connectedCallback(){this.elementReady=!0}connectedContextCallback(j){}disconnectedCallback(){this.removeAllSubscribedEvents();for(let j of this.onDisconnectedCallback)j()}notifyUpdate(j,x,B){if(!this.updateCallbacks||x===B)return;const z=this.updateCallbacks.get(j);if(z)for(let G of z)G()}transformAttributeValue(j,x){return j?x?.converter.fromAttribute(j):j}attributeChangedCallback(j,x,B){if(x===B||!this.elementReady)return;if(this.reactiveProperties.has(j)){const z=this.reactiveProperties.get(j),G=this.transformAttributeValue(B,z),J=this.transformAttributeValue(x,z),Q=z?z.attribute:j;this[Q]=G,this.notifyUpdate(j,J,G)}}renderTemplate({target:j=this,template:x,insert:B="replace"}){switch(B){case"replace":j.innerHTML=x;break;case"beforeend":j.insertAdjacentHTML("beforeend",x);break;case"afterbegin":j.insertAdjacentHTML("afterbegin",x);break}}registerReactiveProperty(j){this.reactiveProperties.set(j.name,j)}registerReactiveField(j){this.reactiveFields.set(j.name,j)}registerUpdateCallback(j,x){if(!this.updateCallbacks.has(j))this.updateCallbacks.set(j,new Set);this.updateCallbacks.get(j)?.add(x)}subscribeEvents(j){const x=[];for(let B of j)x.push(this.subscribeEvent(B));return x}subscribeEvent(j){const x=(z)=>{if(z.target&&z.target.matches(j.selector))j.listener.call(this,z)},B=`${j.type}:${j.selector}`;return this.addEventListener(j.type,x,j.options),this.eventSubscriptions.set(B,{...j,listener:x}),this.unsubscribeEvent.bind(this,B)}unsubscribeEvent(j){const x=this.eventSubscriptions.get(j);if(x)this.removeEventListener(x.type,x.listener,x.options),this.eventSubscriptions.delete(j)}removeAllSubscribedEvents(){for(let j of this.eventSubscriptions.values())this.removeEventListener(j.type,j.listener,j.options);this.eventSubscriptions.clear()}registerCleanupCallback(j){this.onDisconnectedCallback.push(j)}registerEventEmitter(j,x){this.eventEmitters.set(j,x)}getRef(j,x=!1){const B=`[data-ref="${j}"]`;let z;if(x){if(z=Array.from(this.querySelectorAll(B)),z.length===0)z=[]}else if(z=this.querySelector(B),!z)z=document.createDocumentFragment();return z}createReactiveField(j,x){const B={name:j,value:x,initialValue:x};this.registerReactiveField(B),Object.defineProperty(this,j,{get(){return this.reactiveFields.get(j)?.value??void 0},set(z){const G=this.reactiveFields.get(j)?.value;if(G!==z)this.reactiveFields.set(j,{...B,value:z}),this.notifyUpdate(j,G,z)},enumerable:!0,configurable:!0}),this.notifyUpdate(j,void 0,x)}createReactiveProp(j,x){const{type:B,attribute:z,reflect:G,defaultValue:J}=x,Q=z??j;if(J!==void 0&&!$(B,J))throw new Error(`defaultValue does not match the expected type for ${B.name}`);const U=D(this,B,Q,J),X={type:B,name:j,value:U,initialValue:U,attribute:Q,converter:{fromAttribute:(H)=>Z(H,B),toAttribute:(H)=>_(H,B)}};this.registerReactiveProperty(X);const Y=(H)=>{if(G){const W=X.converter.toAttribute(H);this.setAttribute(Q,W)}};if(Object.defineProperty(this,j,{get:function(){return this.reactiveProperties.get(j)?.value??void 0},set:function(H){const W=this.reactiveProperties.get(j)?.value;if(W!==H)this.reactiveProperties.set(j,{...X,value:H}),Y(H),this.notifyUpdate(j,W,H)},enumerable:!0,configurable:!0}),U!==void 0)Y(U),queueMicrotask(()=>{this.notifyUpdate(j,void 0,U)})}}export{T as RadiantElement};
2
+ export{T as s};
82
3
 
83
- //# debugId=494A682B938300F764756E2164756E21
4
+ //# debugId=02C394B602FFC5B564756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/core/radiant-element.ts"],
4
4
  "sourcesContent": [
5
- "import type { UnknownContext } from '@/context/types';\nimport type { AttributeTypeConstant, ReadAttributeValueReturnType, WriteAttributeValueReturnType } from '@/utils';\n\n/**\n * Possible positions to insert a rendered template.\n */\nexport type RenderInsertPosition = 'replace' | 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend';\n\n/**\n * Represents a Radiant element event listener.\n */\nexport type RadiantElementEventListener = {\n selector: string;\n type: string;\n listener: EventListener;\n id: string;\n options?: AddEventListenerOptions;\n};\n\n/**\n * Represents a property metadata object.\n */\nexport interface PropertyConfig {\n type: AttributeTypeConstant;\n propertyName: string;\n attributeKey: string;\n converter: {\n fromAttribute: (value: string) => ReadAttributeValueReturnType;\n toAttribute: (value: any) => WriteAttributeValueReturnType;\n };\n}\n\n/**\n * Represents an interface for a Radiant element.\n */\nexport interface IRadiantElement {\n /**\n * Called when a property of the element is updated.\n * @param changedProperty - The name of the changed property.\n * @param oldValue - The old value of the property.\n * @param newValue - The new value of the property.\n */\n updated(changedProperty: string, oldValue: unknown, newValue: unknown): void;\n\n /**\n * Subscribes to a Radiant element event.\n * @param event - The event listener to subscribe to.\n */\n subscribeEvent(event: RadiantElementEventListener): void;\n\n /**\n * Subscribes to multiple Radiant element events.\n * @param events - The array of event listeners to subscribe to.\n */\n subscribeEvents(events: RadiantElementEventListener[]): void;\n\n /**\n * Unsubscribes from a Radiant element event.\n * @param id - The ID of the event listener to unsubscribe from.\n */\n unsubscribeEvent(id: string): void;\n\n /**\n * Removes all subscribed events from the Radiant element.\n */\n removeAllSubscribedEvents(): void;\n\n /**\n * Renders a template into the specified target element.\n * @param options - The rendering options.\n * @param options.target - The target element to render the template into.\n * @param options.template - The template string to render.\n * @param options.insert - The position to insert the rendered template. (optional)\n */\n renderTemplate(options: {\n target: HTMLElement;\n template: string;\n insert?: RenderInsertPosition;\n }): void;\n\n /**\n * Called when the Radiant element is connected to a context.\n * @param context - The connected context.\n */\n connectedContextCallback(context: UnknownContext): void;\n}\n\n/**\n * A base class for creating custom elements with reactive properties and event subscriptions.\n * @extends HTMLElement\n * @implements IRadiantElement\n */\nexport class RadiantElement extends HTMLElement implements IRadiantElement {\n declare propertyConfigMap: Map<string, PropertyConfig>;\n declare updatesRegistry: Map<string, Set<string>>;\n private eventSubscriptions = new Map<string, RadiantElementEventListener>();\n private elementReady = false;\n\n connectedCallback() {\n this.elementReady = true;\n }\n\n connectedContextCallback(_contextName: UnknownContext): void {}\n\n disconnectedCallback() {\n this.removeAllSubscribedEvents();\n }\n\n updated(changedProperty: string, oldValue: unknown, value: unknown) {\n if (!this.elementReady || !this.updatesRegistry || oldValue === value) return;\n const updates = this.updatesRegistry.get(changedProperty);\n if (updates) {\n for (const update of updates) {\n (this as any)[update]();\n }\n }\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (oldValue === newValue || !this.elementReady) return;\n\n if (name in this) {\n const config = this.propertyConfigMap.get(name);\n const transformedValue = newValue ? config?.converter.fromAttribute(newValue) : newValue;\n const transformedOldValue = oldValue ? config?.converter.fromAttribute(oldValue) : oldValue;\n (this as RadiantElement & { [key: string]: any })[name] = transformedValue;\n this.updated(name, transformedOldValue, transformedValue);\n }\n }\n\n renderTemplate({\n target = this,\n template,\n insert = 'replace',\n }: {\n target: HTMLElement;\n template: string;\n insert?: RenderInsertPosition;\n }) {\n switch (insert) {\n case 'replace':\n target.innerHTML = template;\n break;\n case 'beforeend':\n target.insertAdjacentHTML('beforeend', template);\n break;\n case 'afterbegin':\n target.insertAdjacentHTML('afterbegin', template);\n break;\n }\n }\n\n public subscribeEvents(events: RadiantElementEventListener[]): void {\n for (const event of events) {\n this.subscribeEvent(event);\n }\n }\n\n public subscribeEvent(eventConfig: RadiantElementEventListener): void {\n const delegatedListener = (delegatedEvent: Event) => {\n if (delegatedEvent.target && (delegatedEvent.target as Element).matches(eventConfig.selector)) {\n eventConfig.listener.call(this, delegatedEvent);\n }\n };\n\n this.addEventListener(eventConfig.type, delegatedListener, eventConfig.options);\n this.eventSubscriptions.set(eventConfig.id, { ...eventConfig, listener: delegatedListener });\n }\n\n public unsubscribeEvent(id: string): void {\n const eventSubscription = this.eventSubscriptions.get(id);\n if (eventSubscription) {\n this.removeEventListener(eventSubscription.type, eventSubscription.listener, eventSubscription.options);\n this.eventSubscriptions.delete(id);\n }\n }\n\n public removeAllSubscribedEvents(): void {\n for (const eventSubscription of this.eventSubscriptions.values()) {\n this.removeEventListener(eventSubscription.type, eventSubscription.listener, eventSubscription.options);\n }\n this.eventSubscriptions.clear();\n }\n}\n"
5
+ "import type { EventEmitter } from '@/tools';\nimport type { UnknownContext } from '../context/types';\nimport {\n type AttributeTypeConstant,\n type ReadAttributeValueReturnType,\n type WriteAttributeValueReturnType,\n getInitialValue,\n isValueOfType,\n readAttributeValue,\n writeAttributeValue,\n} from '../utils/attribute-utils';\n\n/**\n * Possible positions to insert a rendered template.\n */\nexport type RenderInsertPosition = 'replace' | 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend';\n\n/**\n * Represents a Radiant element event listener.\n */\nexport type RadiantElementEventListener = {\n selector: string;\n type: string;\n listener: EventListener;\n options?: AddEventListenerOptions;\n};\n\n/**\n * Represents a property metadata object.\n */\nexport interface ReactiveProperty<T = unknown> {\n type: AttributeTypeConstant;\n value?: T;\n initialValue?: T;\n name: string;\n attribute: string;\n converter: {\n fromAttribute: (value: string) => ReadAttributeValueReturnType;\n toAttribute: (value: any) => WriteAttributeValueReturnType;\n };\n}\n\n/**\n * Represents the options for a reactive property.\n */\nexport type ReactivePropertyOptions<T> = {\n type: AttributeTypeConstant;\n reflect?: boolean;\n attribute?: string;\n defaultValue?: T;\n};\n\nexport type ReactiveField<T = unknown> = {\n name: string;\n value: T;\n initialValue: T;\n};\n\n/**\n * Represents an interface for a Radiant element.\n */\nexport interface IRadiantElement {\n /**\n * Called when a property of the element is updated.\n * @param changedProperty - The name of the changed property.\n * @param oldValue - The old value of the property.\n * @param newValue - The new value of the property.\n */\n notifyUpdate(changedProperty: string, oldValue: unknown, newValue: unknown): void;\n\n /**\n * Subscribes to a Radiant element event.\n * @param event - The event listener to subscribe to.\n */\n subscribeEvent(event: RadiantElementEventListener): void;\n\n /**\n * Subscribes to multiple Radiant element events.\n * @param events - The array of event listeners to subscribe to.\n */\n subscribeEvents(events: RadiantElementEventListener[]): void;\n\n /**\n * It adds a callback to be executed when the Radiant element is disconnected from the DOM.\n */\n registerCleanupCallback(callback: () => void): void;\n\n /**\n * Renders a template into the specified target element.\n * @param options - The rendering options.\n * @param options.target - The target element to render the template into.\n * @param options.template - The template string to render.\n * @param options.insert - The position to insert the rendered template. (optional)\n */\n renderTemplate(options: {\n target: HTMLElement;\n template: string;\n insert?: RenderInsertPosition;\n }): void;\n\n /**\n * Called when the Radiant element is connected to a context.\n * @param context - The connected context.\n */\n connectedContextCallback(context: UnknownContext): void;\n\n /**\n * Gets a reference to a child element by its data-ref attribute.\n * @param ref - The data-ref attribute value of the element to get.\n * @param all - Whether to get all elements with the specified data-ref attribute value.\n * @returns The element with the specified data-ref attribute value, an array of elements or null if no element was found.\n */\n getRef<T extends Element = Element>(ref: string, all: boolean): T | T[];\n}\n\n/**\n * A base class for creating custom elements with reactive properties and event subscriptions.\n * @extends HTMLElement\n * @implements IRadiantElement\n */\nexport class RadiantElement extends HTMLElement implements IRadiantElement {\n /**\n * A map of property metadata objects, it contains useful information about the properties configured via decorators.\n */\n private reactiveProperties = new Map<string, ReactiveProperty>();\n\n /**\n * A map of reactive fields, it contains the reactive fields configured via decorators.\n */\n private reactiveFields = new Map<string, ReactiveField>();\n\n /**\n * A map of property update callbacks. These callbacks are called when a property is updated.\n */\n private updateCallbacks = new Map<string, Set<(...rest: any[]) => any>>();\n\n /**\n * A map of event subscriptions used to manage event listeners on the Radiant element.\n */\n private eventSubscriptions = new Map<string, RadiantElementEventListener>();\n\n /**\n * A map for event emitters\n */\n private eventEmitters = new Map<string, EventEmitter>();\n\n /**\n * An array of cleanup callbacks to be executed when the Radiant element is disconnected from the DOM.\n */\n private onDisconnectedCallback: (() => void)[] = [];\n\n /**\n * A flag indicating whether the element has been connected to the DOM.\n */\n private elementReady = false;\n\n connectedCallback() {\n this.elementReady = true;\n }\n\n connectedContextCallback(_contextName: UnknownContext): void {}\n\n disconnectedCallback() {\n this.removeAllSubscribedEvents();\n for (const cleanup of this.onDisconnectedCallback) {\n cleanup();\n }\n }\n\n public notifyUpdate(changedProperty: string, oldValue: unknown, value: unknown) {\n if (!this.updateCallbacks || oldValue === value) return;\n const updates = this.updateCallbacks.get(changedProperty);\n\n if (updates) {\n for (const update of updates) {\n update();\n }\n }\n }\n\n private transformAttributeValue(value: string | null, config: any): unknown {\n return value ? config?.converter.fromAttribute(value) : value;\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (oldValue === newValue || !this.elementReady) return;\n\n if (this.reactiveProperties.has(name)) {\n const config = this.reactiveProperties.get(name);\n\n const transformedValue = this.transformAttributeValue(newValue, config);\n const transformedOldValue = this.transformAttributeValue(oldValue, config);\n\n const key = config ? config.attribute : name;\n (this as any)[key] = transformedValue;\n this.notifyUpdate(name, transformedOldValue, transformedValue);\n }\n }\n\n public renderTemplate({\n target = this,\n template,\n insert = 'replace',\n }: {\n target: HTMLElement;\n template: string;\n insert?: RenderInsertPosition;\n }) {\n switch (insert) {\n case 'replace':\n target.innerHTML = template;\n break;\n case 'beforeend':\n target.insertAdjacentHTML('beforeend', template);\n break;\n case 'afterbegin':\n target.insertAdjacentHTML('afterbegin', template);\n break;\n }\n }\n\n public registerReactiveProperty(config: ReactiveProperty) {\n this.reactiveProperties.set(config.name, config);\n }\n\n public registerReactiveField<T>(config: ReactiveField<T>) {\n this.reactiveFields.set(config.name, config);\n }\n\n public registerUpdateCallback(property: string, update: (...rest: any[]) => any) {\n if (!this.updateCallbacks.has(property)) {\n this.updateCallbacks.set(property, new Set());\n }\n this.updateCallbacks.get(property)?.add(update);\n }\n\n public subscribeEvents(events: RadiantElementEventListener[]): Array<() => void> {\n const unsubscribers: Array<() => void> = [];\n for (const event of events) {\n unsubscribers.push(this.subscribeEvent(event));\n }\n return unsubscribers;\n }\n\n public subscribeEvent(eventConfig: RadiantElementEventListener): () => void {\n const delegatedListener = (delegatedEvent: Event) => {\n if (delegatedEvent.target && (delegatedEvent.target as Element).matches(eventConfig.selector)) {\n eventConfig.listener.call(this, delegatedEvent);\n }\n };\n const subscriptionId = `${eventConfig.type}:${eventConfig.selector}`;\n this.addEventListener(eventConfig.type, delegatedListener, eventConfig.options);\n this.eventSubscriptions.set(subscriptionId, {\n ...eventConfig,\n listener: delegatedListener,\n });\n\n return this.unsubscribeEvent.bind(this, subscriptionId);\n }\n\n private unsubscribeEvent(id: string): void {\n const eventSubscription = this.eventSubscriptions.get(id);\n if (eventSubscription) {\n this.removeEventListener(eventSubscription.type, eventSubscription.listener, eventSubscription.options);\n this.eventSubscriptions.delete(id);\n }\n }\n\n private removeAllSubscribedEvents(): void {\n for (const eventSubscription of this.eventSubscriptions.values()) {\n this.removeEventListener(eventSubscription.type, eventSubscription.listener, eventSubscription.options);\n }\n this.eventSubscriptions.clear();\n }\n\n public registerCleanupCallback(callback: () => void): void {\n this.onDisconnectedCallback.push(callback);\n }\n\n public registerEventEmitter(name: string, emitter: EventEmitter) {\n this.eventEmitters.set(name, emitter);\n }\n\n public getRef<T extends Element = Element>(ref: string, all: true): T[];\n public getRef<T extends Element = Element>(ref: string, all?: false): T;\n public getRef<T extends Element = Element>(ref: string, all = false): T | T[] {\n const selector = `[data-ref=\"${ref}\"]`;\n let result: T | T[];\n if (all) {\n result = Array.from(this.querySelectorAll(selector)) as T[];\n if (result.length === 0) result = [];\n } else {\n result = this.querySelector(selector) as T;\n if (!result) {\n const fragment = document.createDocumentFragment();\n result = fragment as unknown as T;\n }\n }\n return result;\n }\n\n public createReactiveField<T>(propertyName: string, initialValue: T): void {\n const reactiveField: ReactiveField<T> = {\n name: propertyName,\n value: initialValue,\n initialValue: initialValue,\n };\n\n this.registerReactiveField(reactiveField);\n\n Object.defineProperty(this, propertyName, {\n get(this: RadiantElement) {\n return this.reactiveFields.get(propertyName)?.value ?? undefined;\n },\n set(this: RadiantElement, newValue: T) {\n const oldValue = this.reactiveFields.get(propertyName)?.value;\n if (oldValue !== newValue) {\n this.reactiveFields.set(propertyName, { ...reactiveField, value: newValue });\n this.notifyUpdate(propertyName, oldValue, newValue);\n }\n },\n enumerable: true,\n configurable: true,\n });\n\n this.notifyUpdate(propertyName, undefined, initialValue);\n }\n\n public createReactiveProp<T = unknown>(propertyName: string, options: ReactivePropertyOptions<T>): void {\n const { type, attribute, reflect, defaultValue } = options;\n const attributeKey = attribute ?? propertyName;\n\n if (defaultValue !== undefined && !isValueOfType(type, defaultValue)) {\n throw new Error(`defaultValue does not match the expected type for ${type.name}`);\n }\n\n const initialValue: T | undefined = getInitialValue(this, type, attributeKey, defaultValue) as T;\n\n const propertyMapping: ReactiveProperty<T> = {\n type,\n name: propertyName,\n value: initialValue,\n initialValue,\n attribute: attributeKey,\n converter: {\n fromAttribute: (value) => readAttributeValue(value, type),\n toAttribute: (value) => writeAttributeValue(value, type),\n },\n };\n\n this.registerReactiveProperty(propertyMapping);\n\n const handleReflectRequest = (value: T) => {\n if (reflect) {\n const attributeValue = propertyMapping.converter.toAttribute(value);\n this.setAttribute(attributeKey, attributeValue);\n }\n };\n\n Object.defineProperty(this, propertyName, {\n get: function (this: RadiantElement) {\n return this.reactiveProperties.get(propertyName)?.value ?? undefined;\n },\n set: function (this: RadiantElement, newValue: T) {\n const oldValue = this.reactiveProperties.get(propertyName)?.value;\n if (oldValue !== newValue) {\n this.reactiveProperties.set(propertyName, { ...propertyMapping, value: newValue });\n handleReflectRequest(newValue);\n this.notifyUpdate(propertyName, oldValue, newValue);\n }\n },\n enumerable: true,\n configurable: true,\n });\n\n if (initialValue !== undefined) {\n handleReflectRequest(initialValue as T);\n queueMicrotask(() => {\n this.notifyUpdate(propertyName, undefined, initialValue);\n });\n }\n }\n}\n"
6
6
  ],
7
- "m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,aAAa,EAAc,EAAU,CAAQ,GAGtD,WAAY,GACZ,aAAc,EAChB,CAAC,EAED,KAAK,aAAa,EAAc,OAAW,CAAY,EAGlD,kBAA+B,CAAC,EAAsB,EAA2C,CACtG,MAAQ,OAAM,YAAW,UAAS,gBAAiB,EAC7C,EAAe,GAAa,EAElC,GAAI,IAAiB,SAAc,EAAc,EAAM,CAAY,EACjE,MAAM,IAAI,MAAM,qDAAqD,EAAK,MAAM,EAGlF,MAAM,EAA8B,EAAgB,KAAM,EAAM,EAAc,CAAY,EAEpF,EAAuC,CAC3C,OACA,KAAM,EACN,MAAO,EACP,eACA,UAAW,EACX,UAAW,CACT,cAAe,CAAC,IAAU,EAAmB,EAAO,CAAI,EACxD,YAAa,CAAC,IAAU,EAAoB,EAAO,CAAI,CACzD,CACF,EAEA,KAAK,yBAAyB,CAAe,EAE7C,MAAM,EAAuB,CAAC,IAAa,CACzC,GAAI,EAAS,CACX,MAAM,EAAiB,EAAgB,UAAU,YAAY,CAAK,EAClE,KAAK,aAAa,EAAc,CAAc,IAoBlD,GAhBA,OAAO,eAAe,KAAM,EAAc,CACxC,YAAc,EAAuB,CACnC,OAAO,KAAK,mBAAmB,IAAI,CAAY,GAAG,OAAS,QAE7D,YAAc,CAAuB,EAAa,CAChD,MAAM,EAAW,KAAK,mBAAmB,IAAI,CAAY,GAAG,MAC5D,GAAI,IAAa,EACf,KAAK,mBAAmB,IAAI,EAAc,IAAK,EAAiB,MAAO,CAAS,CAAC,EACjF,EAAqB,CAAQ,EAC7B,KAAK,aAAa,EAAc,EAAU,CAAQ,GAGtD,WAAY,GACZ,aAAc,EAChB,CAAC,EAEG,IAAiB,OACnB,EAAqB,CAAiB,EACtC,eAAe,IAAM,CACnB,KAAK,aAAa,EAAc,OAAW,CAAY,EACxD,EAGP",
8
+ "debugId": "02C394B602FFC5B564756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,9 +1,5 @@
1
- import type { RadiantElement } from '../core/radiant-element';
1
+ import type { StandardOrLegacyMethodDecoratorArgs } from '../types';
2
2
  /**
3
3
  * A decorator to bind a method to the instance.
4
- * @param target {@link RadiantElement}
5
- * @param propertyKey string
6
- * @param descriptor {@link PropertyDescriptor}
7
- * @returns
8
4
  */
9
- export declare function bound(target: RadiantElement, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
5
+ export declare function bound(protoOrTarget: StandardOrLegacyMethodDecoratorArgs['protoOrTarget'], nameOrContext: StandardOrLegacyMethodDecoratorArgs['nameOrContext'], descriptor?: StandardOrLegacyMethodDecoratorArgs['descriptor']): any;
@@ -1,24 +1,3 @@
1
- // src/decorators/bound.ts
2
- function bound(target, propertyKey, descriptor) {
3
- const originalMethod = descriptor.value;
4
- return {
5
- configurable: true,
6
- get() {
7
- if (this === target.prototype || Object.hasOwn(this, propertyKey)) {
8
- return originalMethod;
9
- }
10
- const boundMethod = originalMethod.bind(this);
11
- Object.defineProperty(this, propertyKey, {
12
- value: boundMethod,
13
- configurable: true,
14
- writable: true
15
- });
16
- return boundMethod;
17
- }
18
- };
19
- }
20
- export {
21
- bound
22
- };
1
+ import{a as k}from"./legacy/bound.js";import{b as q}from"./standard/bound.js";function D(j,f,v){if(typeof f==="object")return q(j,f);return k(j,f,v)}export{D as bound};
23
2
 
24
- //# debugId=90091E999EB96B5364756E2164756E21
3
+ //# debugId=59B76D711A0E9E7C64756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/decorators/bound.ts"],
4
4
  "sourcesContent": [
5
- "import type { RadiantElement } from '@/core/radiant-element';\n\n/**\n * A decorator to bind a method to the instance.\n * @param target {@link RadiantElement}\n * @param propertyKey string\n * @param descriptor {@link PropertyDescriptor}\n * @returns\n */\nexport function bound(target: RadiantElement, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value;\n\n return {\n configurable: true,\n get() {\n /**\n * Check if the method is already bound to the instance.\n */\n if (this === (target as any).prototype || Object.hasOwn(this, propertyKey)) {\n return originalMethod;\n }\n\n /**\n * Bind the method to the instance.\n */\n const boundMethod = originalMethod.bind(this);\n Object.defineProperty(this, propertyKey, {\n value: boundMethod,\n configurable: true,\n writable: true,\n });\n return boundMethod;\n },\n };\n}\n"
5
+ "import type {\n LegacyMethodDecoratorArgs,\n StandardMethodDecoratorArgs,\n StandardOrLegacyMethodDecoratorArgs,\n} from '../types';\nimport { bound as legacyBound } from './legacy/bound';\nimport { bound as standardBound } from './standard/bound';\n\n/**\n * A decorator to bind a method to the instance.\n */\nexport function bound(\n protoOrTarget: StandardOrLegacyMethodDecoratorArgs['protoOrTarget'],\n nameOrContext: StandardOrLegacyMethodDecoratorArgs['nameOrContext'],\n descriptor?: StandardOrLegacyMethodDecoratorArgs['descriptor'],\n): any {\n if (typeof nameOrContext === 'object') {\n return standardBound(\n protoOrTarget as StandardMethodDecoratorArgs['protoOrTarget'],\n nameOrContext as StandardMethodDecoratorArgs['nameOrContext'],\n );\n }\n return legacyBound(\n protoOrTarget as LegacyMethodDecoratorArgs['protoOrTarget'],\n nameOrContext as LegacyMethodDecoratorArgs['nameOrContext'],\n descriptor as LegacyMethodDecoratorArgs['descriptor'],\n );\n}\n"
6
6
  ],
7
- "mappings": ";AASO,SAAS,KAAK,CAAC,QAAwB,aAAqB,YAAoD;AACrH,QAAM,iBAAiB,WAAW;AAElC,SAAO;AAAA,IACL,cAAc;AAAA,IACd,GAAG,GAAG;AAIJ,UAAI,SAAU,OAAe,aAAa,OAAO,OAAO,MAAM,WAAW,GAAG;AAC1E,eAAO;AAAA,MACT;AAKA,YAAM,cAAc,eAAe,KAAK,IAAI;AAC5C,aAAO,eAAe,MAAM,aAAa;AAAA,QACvC,OAAO;AAAA,QACP,cAAc;AAAA,QACd,UAAU;AAAA,MACZ,CAAC;AACD,aAAO;AAAA;AAAA,EAEX;AAAA;",
8
- "debugId": "90091E999EB96B5364756E2164756E21",
7
+ "mappings": "oFAWO,GAAS,CAAK,CACnB,EACA,EACA,EACK,CACL,UAAW,IAAkB,SAC3B,OAAO,EACL,EACA,CACF,EAEF,OAAO,EACL,EACA,EACA,CACF",
8
+ "debugId": "59B76D711A0E9E7C64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,7 @@
1
+ import type { StandardOrLegacyClassDecoratorArgs } from '../types';
1
2
  /**
2
3
  * Registers a web component with the given name on the global `window.customElements` registry.
3
4
  * @param name selector name.
5
+ * @param options {@link ElementDefinitionOptions}
4
6
  */
5
- export declare function customElement(name: string): (target: CustomElementConstructor) => void;
7
+ export declare function customElement(name: string, options?: ElementDefinitionOptions): (protoOrTarget: StandardOrLegacyClassDecoratorArgs["protoOrTarget"], nameOrContext?: StandardOrLegacyClassDecoratorArgs["nameOrContext"]) => any;
@@ -1,15 +1,4 @@
1
- // src/decorators/custom-element.ts
2
- function customElement(name) {
3
- return (target) => {
4
- if (!globalThis.window)
5
- return;
6
- if (!window.customElements.get(name)) {
7
- window.customElements.define(name, target);
8
- }
9
- };
10
- }
11
- export {
12
- customElement
13
- };
1
+ import{x as B}from"./legacy/custom-element.js";import{y as F}from"./standard/custom-element.js";function I(j,q){return function(z,A){if(typeof A!=="undefined")return F(j,q)(z,A);return B(j,q)(z)}}export{I as customElement};
2
+ export{I as w};
14
3
 
15
- //# debugId=5286B58DE50049BA64756E2164756E21
4
+ //# debugId=09A2FAA985EB9AE564756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/decorators/custom-element.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * Registers a web component with the given name on the global `window.customElements` registry.\n * @param name selector name.\n */\nexport function customElement(name: string) {\n return (target: CustomElementConstructor) => {\n if (!globalThis.window) return;\n if (!window.customElements.get(name)) {\n window.customElements.define(name, target);\n }\n };\n}\n"
5
+ "import type {\n LegacyClassDecoratorArgs,\n StandardClassDecoratorArgs,\n StandardOrLegacyClassDecoratorArgs,\n} from '../types';\nimport { customElement as legacyCustomElement } from './legacy/custom-element';\nimport { customElement as standardCustomElement } from './standard/custom-element';\n\n/**\n * Registers a web component with the given name on the global `window.customElements` registry.\n * @param name selector name.\n * @param options {@link ElementDefinitionOptions}\n */\nexport function customElement(name: string, options?: ElementDefinitionOptions) {\n return function (\n protoOrTarget: StandardOrLegacyClassDecoratorArgs['protoOrTarget'],\n nameOrContext?: StandardOrLegacyClassDecoratorArgs['nameOrContext'],\n ): any {\n if (typeof nameOrContext !== 'undefined') {\n return standardCustomElement(name, options)(\n protoOrTarget as StandardClassDecoratorArgs['protoOrTarget'],\n nameOrContext as StandardClassDecoratorArgs['nameOrContext'],\n );\n }\n return legacyCustomElement(name, options)(protoOrTarget as LegacyClassDecoratorArgs['protoOrTarget']);\n };\n}\n"
6
6
  ],
7
- "mappings": ";AAIO,SAAS,aAAa,CAAC,MAAc;AAC1C,SAAO,CAAC,WAAqC;AAC3C,SAAK,WAAW;AAAQ;AACxB,SAAK,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,aAAO,eAAe,OAAO,MAAM,MAAM;AAAA,IAC3C;AAAA;AAAA;",
8
- "debugId": "5286B58DE50049BA64756E2164756E21",
7
+ "mappings": "6FAaO,YAAS,CAAa,CAAC,EAAc,EAAoC,CAC9E,eAAgB,CACd,EACA,EACK,CACL,UAAW,IAAkB,YAC3B,OAAO,EAAsB,EAAM,CAAO,EACxC,EACA,CACF,EAEF,OAAO,EAAoB,EAAM,CAAO,EAAE,CAA0D",
8
+ "debugId": "09A2FAA985EB9AE564756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1 +1,6 @@
1
- export declare function debounce(timeout: number): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
1
+ import type { StandardOrLegacyMethodDecoratorArgs } from '../types';
2
+ /**
3
+ * A decorator to debounce a method.
4
+ * @param timeout The debounce timeout in milliseconds.
5
+ */
6
+ export declare function debounce(timeout: number): (protoOrTarget: StandardOrLegacyMethodDecoratorArgs["protoOrTarget"], nameOrContext: StandardOrLegacyMethodDecoratorArgs["nameOrContext"], descriptor?: StandardOrLegacyMethodDecoratorArgs["descriptor"]) => any;
@@ -1,21 +1,3 @@
1
- // src/decorators/debounce.ts
2
- function debounce(timeout) {
3
- let timeoutRef = null;
4
- return (_target, _propertyKey, descriptor) => {
5
- const originalMethod = descriptor.value;
6
- descriptor.value = function debounce(...args) {
7
- if (timeoutRef !== null) {
8
- clearTimeout(timeoutRef);
9
- }
10
- timeoutRef = setTimeout(() => {
11
- originalMethod.apply(this, args);
12
- }, timeout);
13
- };
14
- return descriptor;
15
- };
16
- }
17
- export {
18
- debounce
19
- };
1
+ import{C as q}from"./legacy/debounce.js";import{D as v}from"./standard/debounce.js";function E(j){return function(k,f,w){if(typeof f==="object")return v(j)(k,f);return q(j)(k,f,w)}}export{E as debounce};
20
2
 
21
- //# debugId=30A0CC4182AD504664756E2164756E21
3
+ //# debugId=7989BE13E335452D64756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/decorators/debounce.ts"],
4
4
  "sourcesContent": [
5
- "import type { RadiantElement } from '@/core/radiant-element';\n\nexport function debounce(\n timeout: number,\n): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor {\n let timeoutRef: ReturnType<typeof setTimeout> | null = null;\n\n return (_target: RadiantElement, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor => {\n const originalMethod = descriptor.value;\n\n descriptor.value = function debounce(...args: any[]) {\n if (timeoutRef !== null) {\n clearTimeout(timeoutRef);\n }\n\n timeoutRef = setTimeout(() => {\n originalMethod.apply(this, args);\n }, timeout);\n };\n\n return descriptor;\n };\n}\n"
5
+ "import type {\n LegacyMethodDecoratorArgs,\n StandardMethodDecoratorArgs,\n StandardOrLegacyMethodDecoratorArgs,\n} from '../types';\nimport { debounce as legacyDebounce } from './legacy/debounce';\nimport { debounce as standardDebounce } from './standard/debounce';\n\n/**\n * A decorator to debounce a method.\n * @param timeout The debounce timeout in milliseconds.\n */\nexport function debounce(timeout: number) {\n return function (\n protoOrTarget: StandardOrLegacyMethodDecoratorArgs['protoOrTarget'],\n nameOrContext: StandardOrLegacyMethodDecoratorArgs['nameOrContext'],\n descriptor?: StandardOrLegacyMethodDecoratorArgs['descriptor'],\n ): any {\n if (typeof nameOrContext === 'object') {\n return standardDebounce(timeout)(\n protoOrTarget as StandardMethodDecoratorArgs['protoOrTarget'],\n nameOrContext as StandardMethodDecoratorArgs['nameOrContext'],\n );\n }\n return legacyDebounce(timeout)(\n protoOrTarget as LegacyMethodDecoratorArgs['protoOrTarget'],\n nameOrContext as LegacyMethodDecoratorArgs['nameOrContext'],\n descriptor as LegacyMethodDecoratorArgs['descriptor'],\n );\n };\n}\n"
6
6
  ],
7
- "mappings": ";AAEO,SAAS,QAAQ,CACtB,SAC0F;AAC1F,MAAI,aAAmD;AAEvD,SAAO,CAAC,SAAyB,cAAsB,eAAuD;AAC5G,UAAM,iBAAiB,WAAW;AAElC,eAAW,iBAAiB,QAAQ,IAAI,MAAa;AACnD,UAAI,eAAe,MAAM;AACvB,qBAAa,UAAU;AAAA,MACzB;AAEA,mBAAa,WAAW,MAAM;AAC5B,uBAAe,MAAM,MAAM,IAAI;AAAA,SAC9B,OAAO;AAAA;AAGZ,WAAO;AAAA;AAAA;",
8
- "debugId": "30A0CC4182AD504664756E2164756E21",
7
+ "mappings": "uFAYO,MAAS,CAAQ,CAAC,EAAiB,CACxC,eAAgB,CACd,EACA,EACA,EACK,CACL,UAAW,IAAkB,SAC3B,OAAO,EAAiB,CAAO,EAC7B,EACA,CACF,EAEF,OAAO,EAAe,CAAO,EAC3B,EACA,EACA,CACF",
8
+ "debugId": "7989BE13E335452D64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,8 +1,9 @@
1
1
  import { type EventEmitterConfig } from '../tools/event-emitter';
2
+ import type { StandardOrLegacyFieldDecoratorArgs } from '../types';
2
3
  /**
3
4
  * Decorator that attaches an EventEmitter to the class field property.
4
5
  * The EventEmitter can be used to dispatch custom events from the target element.
5
- * @param eventConfig Configuration for the event emitter.
6
+ * @param eventConfig {@link EventEmitterConfig} Configuration for the event emitter.
6
7
  * @see {@link EventEmitter} for more details about how the EventEmitter works.
7
8
  */
8
- export declare function event(eventConfig: EventEmitterConfig): (target: any, propertyKey: string) => void;
9
+ export declare function event(eventConfig: EventEmitterConfig): (protoOrTarget: StandardOrLegacyFieldDecoratorArgs["protoOrTarget"], nameOrContext: StandardOrLegacyFieldDecoratorArgs["nameOrContext"]) => any;