@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
@@ -0,0 +1,2 @@
1
+ import type { Method } from '../../types';
2
+ export declare function onUpdated(keyOrKeys: string | string[]): <T extends Method>(_: T, context: ClassMethodDecoratorContext) => void;
@@ -0,0 +1,4 @@
1
+ function n(i){return function(e,t){t.addInitializer(function(){if(this[t.name]=this[t.name].bind(this),Array.isArray(i))for(let a of i)this.registerUpdateCallback(a,this[t.name]);else if(typeof i==="string")this.registerUpdateCallback(i,this[t.name])})}}export{n as onUpdated};
2
+ export{n as X};
3
+
4
+ //# debugId=1B72F69206926A9C64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/decorators/standard/on-updated.ts"],
4
+ "sourcesContent": [
5
+ "import type { RadiantElement } from '../../core/radiant-element';\nimport type { Method } from '../../types';\n\nexport function onUpdated(keyOrKeys: string | string[]) {\n return function <T extends Method>(_: T, context: ClassMethodDecoratorContext): void {\n context.addInitializer(function (this: any) {\n this[context.name] = this[context.name].bind(this);\n if (Array.isArray(keyOrKeys)) {\n for (const key of keyOrKeys) {\n (this as RadiantElement).registerUpdateCallback(key, this[context.name]);\n }\n } else if (typeof keyOrKeys === 'string') {\n (this as RadiantElement).registerUpdateCallback(keyOrKeys, this[context.name]);\n }\n });\n };\n}\n"
6
+ ],
7
+ "mappings": "AAGO,SAAS,CAAS,CAAC,EAA8B,CACtD,eAAkC,CAAC,EAAM,EAA4C,CACnF,EAAQ,uBAAwB,EAAY,CAE1C,GADA,KAAK,EAAQ,MAAQ,KAAK,EAAQ,MAAM,KAAK,IAAI,EAC7C,MAAM,QAAQ,CAAS,EACzB,QAAW,KAAO,EAChB,AAAC,KAAwB,uBAAuB,EAAK,KAAK,EAAQ,KAAK,iBAEzD,IAAc,SAC9B,AAAC,KAAwB,uBAAuB,EAAW,KAAK,EAAQ,KAAK,EAEhF",
8
+ "debugId": "1B72F69206926A9C64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,2 @@
1
+ import type { QueryConfig } from '../query';
2
+ export declare function query(options: QueryConfig): <T extends HTMLElement, V extends Element | Element[]>(_: undefined, context: ClassFieldDecoratorContext<T, V>) => void;
@@ -0,0 +1,4 @@
1
+ function o(e){return function(s,t){const n=String(t.name),r=Symbol(`__${String(n)}__cache`),l="selector"in e?e.selector:`[data-ref="${e.ref}"]`,i=(u)=>{let c=[];if(e?.all){const a=u.querySelectorAll(l);return c=a.length?Array.from(a):[],c}return u.querySelector(l)};t.addInitializer(function(){Object.defineProperty(this,n,{get(){if(e?.cache){if(!this[r]||e?.all&&!this[r].length)this[r]=i(this);return this[r]}return i(this)},enumerable:!0,configurable:!0})})}}export{o as query};
2
+ export{o as v};
3
+
4
+ //# debugId=D06D9FAD60782C4364756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/decorators/standard/query.ts"],
4
+ "sourcesContent": [
5
+ "import type { QueryConfig } from '../query';\n\nexport function query(options: QueryConfig) {\n return function <T extends HTMLElement, V extends Element | Element[]>(\n _: undefined,\n context: ClassFieldDecoratorContext<T, V>,\n ) {\n const propertyName = String(context.name);\n const privatePropertyKey = Symbol(`__${String(propertyName)}__cache`);\n\n const selector = 'selector' in options ? options.selector : `[data-ref=\"${options.ref}\"]`;\n\n const executeQuery = (instance: T) => {\n let result: V | V[] = [];\n if (options?.all) {\n const queried = instance.querySelectorAll(selector);\n result = queried.length ? (Array.from(queried) as V) : [];\n return result;\n }\n\n return instance.querySelector(selector);\n };\n\n context.addInitializer(function (this: T) {\n Object.defineProperty(this, propertyName, {\n get() {\n if (options?.cache) {\n if (!this[privatePropertyKey] || (options?.all && !this[privatePropertyKey].length)) {\n this[privatePropertyKey] = executeQuery(this);\n }\n return this[privatePropertyKey];\n }\n return executeQuery(this) as V;\n },\n enumerable: true,\n configurable: true,\n });\n });\n };\n}\n"
6
+ ],
7
+ "mappings": "AAEO,SAAS,CAAK,CAAC,EAAsB,CAC1C,eAAsE,CACpE,EACA,EACA,CACA,MAAM,EAAe,OAAO,EAAQ,IAAI,EAClC,EAAqB,OAAO,KAAK,OAAO,CAAY,UAAU,EAE9D,EAAW,aAAc,EAAU,EAAQ,SAAW,cAAc,EAAQ,QAE5E,EAAe,CAAC,IAAgB,CACpC,IAAI,EAAkB,CAAC,EACvB,GAAI,GAAS,IAAK,CAChB,MAAM,EAAU,EAAS,iBAAiB,CAAQ,EAElD,OADA,EAAS,EAAQ,OAAU,MAAM,KAAK,CAAO,EAAU,CAAC,EACjD,EAGT,OAAO,EAAS,cAAc,CAAQ,GAGxC,EAAQ,uBAAwB,EAAU,CACxC,OAAO,eAAe,KAAM,EAAc,CACxC,GAAG,EAAG,CACJ,GAAI,GAAS,MAAO,CAClB,IAAK,KAAK,IAAwB,GAAS,MAAQ,KAAK,GAAoB,OAC1E,KAAK,GAAsB,EAAa,IAAI,EAE9C,OAAO,KAAK,GAEd,OAAO,EAAa,IAAI,GAE1B,WAAY,GACZ,aAAc,EAChB,CAAC,EACF",
8
+ "debugId": "D06D9FAD60782C4364756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,2 @@
1
+ import type { RadiantElement } from '../../core/radiant-element';
2
+ export declare function reactiveField<T extends RadiantElement, V>(_: undefined, context: ClassFieldDecoratorContext<T, V>): (this: T, value: V) => V;
@@ -0,0 +1,4 @@
1
+ function o(a,e){const n=Symbol(`__${String(e.name)}__value`),r=String(e.name);return e.addInitializer(function(){Object.defineProperty(this,e.name,{get(){return this[n]},set(t){const i=this[n];if(i!==t)this[n]=t,this.notifyUpdate(r,i,t)},enumerable:!0,configurable:!0})}),function(t){return this[n]=t,t}}export{o as reactiveField};
2
+ export{o as B};
3
+
4
+ //# debugId=6D2C82AC75BF57FA64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/decorators/standard/reactive-field.ts"],
4
+ "sourcesContent": [
5
+ "import type { RadiantElement } from '../../core/radiant-element';\n\nexport function reactiveField<T extends RadiantElement, V>(_: undefined, context: ClassFieldDecoratorContext<T, V>) {\n const privatePropertyKey = Symbol(`__${String(context.name)}__value`);\n\n const contextName = String(context.name);\n\n context.addInitializer(function (this: T) {\n Object.defineProperty(this, context.name, {\n get() {\n return this[privatePropertyKey];\n },\n set(newValue: unknown) {\n const oldValue = this[privatePropertyKey];\n if (oldValue !== newValue) {\n this[privatePropertyKey] = newValue;\n (this as RadiantElement).notifyUpdate(contextName, oldValue, newValue);\n }\n },\n enumerable: true,\n configurable: true,\n });\n });\n\n return function (this: T, value: V) {\n (this as any)[privatePropertyKey] = value;\n return value;\n };\n}\n"
6
+ ],
7
+ "mappings": "AAEO,SAAS,CAA0C,CAAC,EAAc,EAA2C,CAClH,MAAM,EAAqB,OAAO,KAAK,OAAO,EAAQ,IAAI,UAAU,EAE9D,EAAc,OAAO,EAAQ,IAAI,EAmBvC,OAjBA,EAAQ,uBAAwB,EAAU,CACxC,OAAO,eAAe,KAAM,EAAQ,KAAM,CACxC,GAAG,EAAG,CACJ,OAAO,KAAK,IAEd,GAAG,CAAC,EAAmB,CACrB,MAAM,EAAW,KAAK,GACtB,GAAI,IAAa,EACf,KAAK,GAAsB,EAC1B,KAAwB,aAAa,EAAa,EAAU,CAAQ,GAGzE,WAAY,GACZ,aAAc,EAChB,CAAC,EACF,UAEe,CAAU,EAAU,CAElC,OADC,KAAa,GAAsB,EAC7B",
8
+ "debugId": "6D2C82AC75BF57FA64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,2 @@
1
+ import type { RadiantElement, ReactivePropertyOptions } from '../../core/radiant-element.js';
2
+ export declare function reactiveProp<P = unknown>({ type, attribute, reflect, defaultValue }: ReactivePropertyOptions<P>): <T extends RadiantElement, V>(_: undefined, context: ClassFieldDecoratorContext<T, V>) => void;
@@ -0,0 +1,4 @@
1
+ function p({type:n,attribute:i,reflect:r,defaultValue:a}){return function(c,t){const e=String(t.name),o=i??e;t.addInitializer(function(){this.createReactiveProp(e,{type:n,reflect:r,attribute:o,defaultValue:a})})}}export{p as reactiveProp};
2
+ export{p as N};
3
+
4
+ //# debugId=BFD78D04A8E9585464756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/decorators/standard/reactive-prop.ts"],
4
+ "sourcesContent": [
5
+ "import type { RadiantElement, ReactivePropertyOptions } from '../../core/radiant-element.js';\n\nexport function reactiveProp<P = unknown>({ type, attribute, reflect, defaultValue }: ReactivePropertyOptions<P>) {\n return function <T extends RadiantElement, V>(_: undefined, context: ClassFieldDecoratorContext<T, V>) {\n const propertyName = String(context.name);\n const attributeKey = attribute ?? propertyName;\n\n context.addInitializer(function (this: T) {\n this.createReactiveProp(propertyName, { type, reflect, attribute: attributeKey, defaultValue });\n });\n };\n}\n"
6
+ ],
7
+ "mappings": "AAEO,SAAS,CAAyB,EAAG,OAAM,YAAW,UAAS,gBAA4C,CAChH,eAA6C,CAAC,EAAc,EAA2C,CACrG,MAAM,EAAe,OAAO,EAAQ,IAAI,EAClC,EAAe,GAAa,EAElC,EAAQ,uBAAwB,EAAU,CACxC,KAAK,mBAAmB,EAAc,CAAE,OAAM,UAAS,UAAW,EAAc,cAAa,CAAC,EAC/F",
8
+ "debugId": "BFD78D04A8E9585464756E2164756E21",
9
+ "names": []
10
+ }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,16 @@
1
- export * from './core';
2
- export * from './decorators';
3
- export * from './context';
4
- export * from './mixins';
1
+ export * from './core/radiant-element';
2
+ export * from './decorators/custom-element';
3
+ export * from './decorators/event';
4
+ export * from './decorators/on-event';
5
+ export * from './decorators/on-updated';
6
+ export * from './decorators/query';
7
+ export * from './decorators/reactive-prop';
8
+ export * from './decorators/reactive-field';
9
+ export * from './context/context-provider';
10
+ export * from './context/create-context';
11
+ export * from './context/decorators/consume-context';
12
+ export * from './context/decorators/context-selector';
13
+ export * from './context/decorators/provide-context';
14
+ export * from './mixins/with-kita';
5
15
  export * from './tools';
6
16
  export * from './utils';