@ecopages/radiant 0.1.4 → 0.1.6

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 (62) hide show
  1. package/README.md +2 -0
  2. package/dist/context/context-provider.js +282 -3
  3. package/dist/context/context-provider.js.map +5 -3
  4. package/dist/context/create-context.js +6 -3
  5. package/dist/context/create-context.js.map +2 -2
  6. package/dist/context/decorators/consume-context.js +64 -3
  7. package/dist/context/decorators/consume-context.js.map +4 -3
  8. package/dist/context/decorators/context-selector.js +71 -3
  9. package/dist/context/decorators/context-selector.js.map +5 -4
  10. package/dist/context/decorators/provide-context.js +293 -3
  11. package/dist/context/decorators/provide-context.js.map +6 -3
  12. package/dist/context/events.js +53 -3
  13. package/dist/context/events.js.map +2 -2
  14. package/dist/context/index.js +340 -2
  15. package/dist/context/index.js.map +10 -3
  16. package/dist/context/types.js +1 -1
  17. package/dist/context/types.js.map +1 -1
  18. package/dist/core/index.js +82 -2
  19. package/dist/core/index.js.map +4 -3
  20. package/dist/core/radiant-element.d.ts +21 -1
  21. package/dist/core/radiant-element.js +82 -3
  22. package/dist/core/radiant-element.js.map +3 -3
  23. package/dist/decorators/custom-element.js +14 -3
  24. package/dist/decorators/custom-element.js.map +2 -2
  25. package/dist/decorators/debounce.d.ts +1 -0
  26. package/dist/decorators/debounce.js +21 -0
  27. package/dist/decorators/debounce.js.map +10 -0
  28. package/dist/decorators/event.js +46 -3
  29. package/dist/decorators/event.js.map +4 -3
  30. package/dist/decorators/on-event.d.ts +4 -0
  31. package/dist/decorators/on-event.js +47 -3
  32. package/dist/decorators/on-event.js.map +3 -3
  33. package/dist/decorators/on-updated.d.ts +1 -1
  34. package/dist/decorators/on-updated.js +29 -3
  35. package/dist/decorators/on-updated.js.map +3 -3
  36. package/dist/decorators/query.js +36 -3
  37. package/dist/decorators/query.js.map +3 -3
  38. package/dist/decorators/reactive-field.js +26 -3
  39. package/dist/decorators/reactive-field.js.map +2 -2
  40. package/dist/decorators/reactive-prop.d.ts +1 -1
  41. package/dist/decorators/reactive-prop.js +214 -3
  42. package/dist/decorators/reactive-prop.js.map +5 -4
  43. package/dist/decorators.js +400 -2
  44. package/dist/decorators.js.map +12 -3
  45. package/dist/index.js +719 -2
  46. package/dist/index.js.map +21 -3
  47. package/dist/mixins/index.js +23 -2
  48. package/dist/mixins/index.js.map +4 -3
  49. package/dist/mixins/with-kita.js +23 -3
  50. package/dist/mixins/with-kita.js.map +2 -2
  51. package/dist/tools/event-emitter.js +22 -3
  52. package/dist/tools/event-emitter.js.map +2 -2
  53. package/dist/tools/index.js +28 -2
  54. package/dist/tools/index.js.map +5 -3
  55. package/dist/tools/stringify-attribute.js +8 -3
  56. package/dist/tools/stringify-attribute.js.map +2 -2
  57. package/dist/utils/attribute-utils.d.ts +2 -0
  58. package/dist/utils/attribute-utils.js +137 -3
  59. package/dist/utils/attribute-utils.js.map +3 -3
  60. package/dist/utils/index.js +137 -2
  61. package/dist/utils/index.js.map +4 -3
  62. package/package.json +9 -4
@@ -1,4 +1,215 @@
1
- import{o as J,p as L,q as M,r as N} from"../utils/attribute-utils.js";function Y({type:k,attribute:Q,reflect:R,defaultValue:B}){if(B!==void 0&&!N(k,B))throw new Error(`defaultValue does not match the expected type for ${k.name}`);return(H,C)=>{const q=new WeakMap,D=`__${C}`,G=Q??C,S=(j)=>{if(k===Boolean)return j.hasAttribute(G)||B;const z=j.getAttribute(G);return z!==null?L(z,k):B||J(k)};Object.defineProperty(H,D,{get:function(){if(!q.has(this)){const j=S(this);q.set(this,j)}return q.get(this)},set:function(j){const z=q.get(this);if(z===j)return;if(q.set(this,j),R)this.setAttribute(G,M(j,k));this.updated(C,z,j)},enumerable:!0,configurable:!0}),Object.defineProperty(H,C,{get:function(){return this[D]},set:function(j){this[D]=j},enumerable:!0,configurable:!0})}}export{Y as reactiveProp};
2
- export{Y as w};
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
+ };
3
129
 
4
- //# debugId=D94321FDF9DD649064756E2164756E21
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
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/decorators/reactive-prop.ts"],
3
+ "sources": ["../src/utils/attribute-utils.ts", "../src/decorators/reactive-prop.ts"],
4
4
  "sourcesContent": [
5
- "import type { 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 (proto: RadiantElement, propertyKey: string) => {\n const originalValues = new WeakMap<WeakKey, unknown>();\n const prefixedPropertyKey = `__${propertyKey}`;\n const attributeKey = attribute ?? propertyKey;\n\n const getInitialValue = (context: RadiantElement) => {\n if (type === Boolean) {\n const hasAttribute = context.hasAttribute(attributeKey);\n return hasAttribute || defaultValue;\n }\n\n const attributeValue = context.getAttribute(attributeKey);\n return attributeValue !== null\n ? readAttributeValue(attributeValue, type)\n : defaultValue || defaultValueForType(type);\n };\n\n Object.defineProperty(proto, prefixedPropertyKey, {\n get: function () {\n if (!originalValues.has(this)) {\n const initialValue = getInitialValue(this);\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) this.setAttribute(attributeKey, writeAttributeValue(newValue, type));\n this.updated(propertyKey, oldValue, newValue);\n },\n enumerable: true,\n configurable: true,\n });\n\n Object.defineProperty(proto, propertyKey, {\n get: function () {\n return this[prefixedPropertyKey];\n },\n set: function (newValue: string) {\n this[prefixedPropertyKey] = newValue;\n },\n enumerable: true,\n configurable: true,\n });\n };\n}\n"
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"
6
7
  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AAO,OAAO;AACpB,QAAM,6BAA8B,KAAa,sBAAsB,CAAC;AACxE,OAAK,2BAA2B,SAAS,SAAS,GAAG;AACnD,UAAM,wBAAwB,CAAC,GAAG,4BAA4B,SAAS;AACvE,WAAO,eAAe,MAAM,sBAAsB;AAAA,MAChD,GAAG,GAAG;AACJ,eAAO;AAAA;AAAA,MAET,cAAc;AAAA,IAChB,CAAC;AAAA,EACH;AAAA;AAvCF,IAAM,kBAAkB,CACtB,QACA,MACA,cACA,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",
9
10
  "names": []
10
11
  }
@@ -1,3 +1,401 @@
1
- import"./utils/attribute-utils.js";import"./tools/event-emitter.js";import{u as c} from"./decorators/on-event.js";import{v as b} from"./decorators/event.js";import{w as h} from"./decorators/reactive-prop.js";import{x as d} from"./decorators/on-updated.js";import{y as i} from"./decorators/reactive-field.js";import{z as g} from"./decorators/query.js";import{A as a} from"./decorators/custom-element.js";export{h as reactiveProp,i as reactiveField,g as query,d as onUpdated,c as onEvent,b as event,a as customElement};
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
+ }
2
11
 
3
- //# debugId=71830EA449072B8A64756E2164756E21
12
+ // src/tools/event-emitter.ts
13
+ class EventEmitter {
14
+ host;
15
+ eventConfig;
16
+ constructor(host, eventConfig) {
17
+ this.host = host;
18
+ this.eventConfig = eventConfig;
19
+ }
20
+ emit(detail) {
21
+ const event = new CustomEvent(this.eventConfig.name, {
22
+ detail,
23
+ bubbles: this.eventConfig.bubbles,
24
+ cancelable: this.eventConfig.cancelable,
25
+ composed: this.eventConfig.composed
26
+ });
27
+ this.host.dispatchEvent(event);
28
+ }
29
+ }
30
+
31
+ // src/decorators/event.ts
32
+ function event(eventConfig) {
33
+ return (target, propertyKey) => {
34
+ if (!propertyKey) {
35
+ throw new Error("The propertyKey is missing for the event decorator.");
36
+ }
37
+ if (!eventConfig || !eventConfig.name) {
38
+ throw new Error("Invalid eventConfig provided.");
39
+ }
40
+ const uniqueKey = Symbol(eventConfig.name);
41
+ Object.defineProperty(target, propertyKey, {
42
+ get() {
43
+ const emittersMap = eventEmitters.get(this) || new Map;
44
+ if (!emittersMap.has(uniqueKey)) {
45
+ emittersMap.set(uniqueKey, new EventEmitter(this, eventConfig));
46
+ eventEmitters.set(this, emittersMap);
47
+ }
48
+ return emittersMap.get(uniqueKey);
49
+ }
50
+ });
51
+ };
52
+ }
53
+ var eventEmitters = new WeakMap;
54
+
55
+ // src/decorators/on-event.ts
56
+ function onEvent(eventConfig) {
57
+ return (proto, _, descriptor) => {
58
+ const originalConnectedCallback = proto.connectedCallback;
59
+ const originalDisconnectedCallback = proto.disconnectedCallback;
60
+ if ("window" in eventConfig) {
61
+ proto.connectedCallback = function() {
62
+ window.addEventListener(eventConfig.type, descriptor.value.bind(this), eventConfig.options);
63
+ originalConnectedCallback.call(this);
64
+ };
65
+ proto.disconnectedCallback = function() {
66
+ window.removeEventListener(eventConfig.type, descriptor.value.bind(this), eventConfig.options);
67
+ originalDisconnectedCallback.call(this);
68
+ };
69
+ return descriptor;
70
+ }
71
+ if ("document" in eventConfig) {
72
+ proto.connectedCallback = function() {
73
+ document.addEventListener(eventConfig.type, descriptor.value.bind(this), eventConfig.options);
74
+ originalConnectedCallback.call(this);
75
+ };
76
+ proto.disconnectedCallback = function() {
77
+ document.removeEventListener(eventConfig.type, descriptor.value.bind(this), eventConfig.options);
78
+ originalDisconnectedCallback.call(this);
79
+ };
80
+ return descriptor;
81
+ }
82
+ const selector = "selector" in eventConfig ? eventConfig.selector : `[data-ref="${eventConfig.ref}"]`;
83
+ const originalMethod = descriptor.value;
84
+ const subscriptionId = `${eventConfig.type}-${selector}`;
85
+ proto.connectedCallback = function() {
86
+ this.subscribeEvent({
87
+ id: subscriptionId,
88
+ selector,
89
+ type: eventConfig.type,
90
+ listener: originalMethod.bind(this),
91
+ options: eventConfig?.options ?? undefined
92
+ });
93
+ originalConnectedCallback.call(this);
94
+ };
95
+ return descriptor;
96
+ };
97
+ }
98
+
99
+ // src/decorators/on-updated.ts
100
+ function onUpdated(keyOrKeys) {
101
+ return (proto, methodName) => {
102
+ if (!("updatesRegistry" in proto)) {
103
+ Object.defineProperty(proto, "updatesRegistry", {
104
+ value: new Map,
105
+ configurable: true
106
+ });
107
+ }
108
+ const updatesRegistry = proto.updatesRegistry;
109
+ if (Array.isArray(keyOrKeys)) {
110
+ for (const key of keyOrKeys) {
111
+ if (!updatesRegistry.has(key)) {
112
+ updatesRegistry.set(key, new Set);
113
+ }
114
+ updatesRegistry.get(key)?.add(methodName);
115
+ }
116
+ } else if (typeof keyOrKeys === "string") {
117
+ if (!updatesRegistry.has(keyOrKeys)) {
118
+ updatesRegistry.set(keyOrKeys, new Set);
119
+ }
120
+ updatesRegistry.get(keyOrKeys)?.add(methodName);
121
+ }
122
+ };
123
+ }
124
+
125
+ // src/decorators/query.ts
126
+ function query({
127
+ cache: shouldBeCached = true,
128
+ ...options
129
+ }) {
130
+ const cache = new WeakMap;
131
+ return (proto, propertyKey) => {
132
+ const doQuery = function() {
133
+ if (shouldBeCached) {
134
+ const cachedResult = cache.get(this);
135
+ if (cachedResult !== undefined) {
136
+ return cachedResult;
137
+ }
138
+ }
139
+ const selector = "selector" in options ? options.selector : `[data-ref="${options.ref}"]`;
140
+ const queryResult = options.all ? this.querySelectorAll(selector) : this.querySelector(selector);
141
+ if (shouldBeCached) {
142
+ cache.set(this, queryResult);
143
+ }
144
+ return queryResult;
145
+ };
146
+ const originalConnectedCallback = proto.connectedCallback;
147
+ proto.connectedCallback = function() {
148
+ Object.defineProperty(this, propertyKey, {
149
+ get: doQuery,
150
+ enumerable: true,
151
+ configurable: true
152
+ });
153
+ originalConnectedCallback.call(this);
154
+ };
155
+ };
156
+ }
157
+
158
+ // src/utils/attribute-utils.ts
159
+ function parseAttributeTypeConstant(constant) {
160
+ switch (constant) {
161
+ case Array:
162
+ return "array";
163
+ case Boolean:
164
+ return "boolean";
165
+ case Number:
166
+ return "number";
167
+ case Object:
168
+ return "object";
169
+ case String:
170
+ return "string";
171
+ }
172
+ }
173
+ function parseAttributeTypeDefault(defaultValue) {
174
+ switch (typeof defaultValue) {
175
+ case "boolean":
176
+ return "boolean";
177
+ case "number":
178
+ return "number";
179
+ case "string":
180
+ return "string";
181
+ }
182
+ if (Array.isArray(defaultValue))
183
+ return "array";
184
+ if (Object.prototype.toString.call(defaultValue) === "[object Object]")
185
+ return "object";
186
+ }
187
+ function defaultValueForType(type) {
188
+ switch (type) {
189
+ case Number:
190
+ return 0;
191
+ case String:
192
+ return "";
193
+ case Boolean:
194
+ return false;
195
+ default:
196
+ return null;
197
+ }
198
+ }
199
+ function parseJSON(value) {
200
+ try {
201
+ return JSON.parse(value);
202
+ } catch (error) {
203
+ throw new TypeError("Invalid JSON string");
204
+ }
205
+ }
206
+ function writeJSON(value) {
207
+ return JSON.stringify(value);
208
+ }
209
+ function writeString(value) {
210
+ return `${value}`;
211
+ }
212
+ function readAttributeValue(value, type) {
213
+ const readerType = parseAttributeTypeConstant(type);
214
+ if (!readerType)
215
+ throw new TypeError(`[radiant-element] Unknown type "${type}"`);
216
+ return readers[readerType](value);
217
+ }
218
+ function writeAttributeValue(value, type) {
219
+ const writerType = parseAttributeTypeConstant(type);
220
+ if (!writerType)
221
+ throw new TypeError(`[radiant-element] Unknown type "${type}"`);
222
+ return (writers[writerType] || writers.default)(value);
223
+ }
224
+ function isBoolean(value) {
225
+ return typeof value === "boolean";
226
+ }
227
+ function isNumber(value) {
228
+ return typeof value === "number";
229
+ }
230
+ function isString(value) {
231
+ return typeof value === "string";
232
+ }
233
+ function isArray(value) {
234
+ return Array.isArray(value);
235
+ }
236
+ function isObject(value) {
237
+ return typeof value === "object" && !Array.isArray(value) && value !== null;
238
+ }
239
+ function isValueOfType(type, defaultValue) {
240
+ switch (type) {
241
+ case Boolean:
242
+ return isBoolean(defaultValue);
243
+ case Number:
244
+ return isNumber(defaultValue);
245
+ case String:
246
+ return isString(defaultValue);
247
+ case Array:
248
+ return isArray(defaultValue);
249
+ case Object:
250
+ return isObject(defaultValue);
251
+ default:
252
+ return false;
253
+ }
254
+ }
255
+ var readers = {
256
+ array(value) {
257
+ const array = parseJSON(value);
258
+ if (!Array.isArray(array)) {
259
+ throw new TypeError(`Expected an array but got a value of type "${typeof array}"`);
260
+ }
261
+ return array;
262
+ },
263
+ boolean(value) {
264
+ return !(value === "0" || String(value).toLowerCase() === "false");
265
+ },
266
+ number(value) {
267
+ const number = Number(value.replace(/_/g, ""));
268
+ return number;
269
+ },
270
+ object(value) {
271
+ const object = JSON.parse(value);
272
+ if (object === null || typeof object !== "object" || Array.isArray(object)) {
273
+ throw new TypeError(`expected value of type "object" but instead got value "${value}" of type "${parseAttributeTypeDefault(object)}"`);
274
+ }
275
+ return object;
276
+ },
277
+ string(value) {
278
+ return value;
279
+ }
280
+ };
281
+ var writers = {
282
+ default: writeString,
283
+ array: writeJSON,
284
+ object: writeJSON
285
+ };
286
+
287
+ // src/decorators/reactive-prop.ts
288
+ function reactiveProp({ type, attribute, reflect, defaultValue }) {
289
+ if (defaultValue !== undefined && !isValueOfType(type, defaultValue)) {
290
+ throw new Error(`defaultValue does not match the expected type for ${type.name}`);
291
+ }
292
+ return (target, propertyName) => {
293
+ const originalValues = new WeakMap;
294
+ const attributeKey = attribute ?? propertyName;
295
+ if (propertyName in target) {
296
+ throw new Error(`Property "${propertyName}" already exists on ${target.constructor.name}`);
297
+ }
298
+ const propertyMapping = {
299
+ type,
300
+ propertyName,
301
+ attributeKey,
302
+ converter: {
303
+ fromAttribute: (value) => readAttributeValue(value, type),
304
+ toAttribute: (value) => writeAttributeValue(value, type)
305
+ }
306
+ };
307
+ addPropertyToMappings(target, propertyMapping);
308
+ Object.defineProperty(target, propertyName, {
309
+ get: function() {
310
+ if (!originalValues.has(this)) {
311
+ const initialValue = getInitialValue(this, type, attributeKey, defaultValue);
312
+ originalValues.set(this, initialValue);
313
+ }
314
+ return originalValues.get(this);
315
+ },
316
+ set: function(newValue) {
317
+ const oldValue = originalValues.get(this);
318
+ if (oldValue === newValue)
319
+ return;
320
+ originalValues.set(this, newValue);
321
+ if (reflect) {
322
+ const attributeValue = propertyMapping.converter.toAttribute(newValue);
323
+ this.setAttribute(attributeKey, attributeValue);
324
+ }
325
+ this.updated(propertyName, oldValue, newValue);
326
+ },
327
+ enumerable: true,
328
+ configurable: true
329
+ });
330
+ const originalConnectedCallback = target.connectedCallback;
331
+ target.connectedCallback = function() {
332
+ originalConnectedCallback.call(this);
333
+ this.updated(propertyName, null, defaultValue);
334
+ };
335
+ addObservedAttribute(target, attributeKey);
336
+ };
337
+ }
338
+ function addObservedAttribute(target, attribute) {
339
+ const ctor = target.constructor;
340
+ const existingObservedAttributes = ctor.observedAttributes || [];
341
+ if (!existingObservedAttributes.includes(attribute)) {
342
+ const newObservedAttributes = [...existingObservedAttributes, attribute];
343
+ Object.defineProperty(ctor, "observedAttributes", {
344
+ get() {
345
+ return newObservedAttributes;
346
+ },
347
+ configurable: true
348
+ });
349
+ }
350
+ }
351
+ var getInitialValue = (target, type, attributeKey, defaultValue) => {
352
+ if (type === Boolean) {
353
+ const hasAttribute = target.hasAttribute(attributeKey);
354
+ return hasAttribute || defaultValue;
355
+ }
356
+ const attributeValue = target.getAttribute(attributeKey);
357
+ return attributeValue !== null ? readAttributeValue(attributeValue, type) : defaultValue || defaultValueForType(type);
358
+ };
359
+ var addPropertyToMappings = (target, propertyMapping) => {
360
+ if (!("propertyConfigMap" in target)) {
361
+ Object.defineProperty(target, "propertyConfigMap", {
362
+ value: new Map,
363
+ configurable: true
364
+ });
365
+ }
366
+ target.propertyConfigMap.set(propertyMapping.propertyName, propertyMapping);
367
+ };
368
+
369
+ // src/decorators/reactive-field.ts
370
+ function reactiveField(proto, propertyKey) {
371
+ const originalValues = new WeakMap;
372
+ const isDefined = new WeakSet;
373
+ Object.defineProperty(proto, propertyKey, {
374
+ get: function() {
375
+ return originalValues.get(this);
376
+ },
377
+ set: function(newValue) {
378
+ if (isDefined.has(this)) {
379
+ const oldValue = originalValues.get(this);
380
+ if (oldValue !== newValue) {
381
+ originalValues.set(this, newValue);
382
+ this.updated(propertyKey, oldValue, newValue);
383
+ }
384
+ } else {
385
+ originalValues.set(this, newValue);
386
+ isDefined.add(this);
387
+ }
388
+ }
389
+ });
390
+ }
391
+ export {
392
+ reactiveProp,
393
+ reactiveField,
394
+ query,
395
+ onUpdated,
396
+ onEvent,
397
+ event,
398
+ customElement
399
+ };
400
+
401
+ //# debugId=4CC8B2D8AD40ADE664756E2164756E21