@o.z/zui 0.4.3 → 0.4.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 (53) hide show
  1. package/README.md +1 -24
  2. package/dist/_constants-CnGtrSkM.cjs +7 -0
  3. package/dist/_constants-DXNZF5so.js +3 -0
  4. package/dist/decorators/defineElement.cjs +4 -4
  5. package/dist/decorators/defineElement.d.ts +48 -0
  6. package/dist/decorators/defineElement.js +4 -4
  7. package/dist/decorators/event.cjs +3 -2
  8. package/dist/decorators/event.d.ts +48 -0
  9. package/dist/decorators/event.js +3 -2
  10. package/dist/decorators/index.cjs +2 -0
  11. package/dist/decorators/index.d.ts +1 -0
  12. package/dist/decorators/index.js +1 -0
  13. package/dist/decorators/mixin.cjs +7 -0
  14. package/dist/decorators/mixin.d.ts +418 -0
  15. package/dist/decorators/mixin.js +3 -0
  16. package/dist/decorators/property.cjs +4 -4
  17. package/dist/decorators/property.d.ts +60 -0
  18. package/dist/decorators/property.js +4 -4
  19. package/dist/decorators/refs.cjs +2 -2
  20. package/dist/decorators/refs.d.ts +44 -0
  21. package/dist/decorators/refs.js +2 -2
  22. package/dist/decorators/state.cjs +2 -2
  23. package/dist/decorators/state.d.ts +54 -3
  24. package/dist/decorators/state.js +1 -1
  25. package/dist/decorators/types.d.ts +108 -0
  26. package/dist/dom.d.ts +40 -4
  27. package/dist/html.d.ts +93 -5
  28. package/dist/index.cjs +11 -7
  29. package/dist/index.d.ts +18 -361
  30. package/dist/index.js +5 -5
  31. package/dist/utilities/delay.cjs +7 -0
  32. package/dist/utilities/delay.d.ts +18 -0
  33. package/dist/utilities/delay.js +3 -0
  34. package/dist/utilities/index.cjs +15 -0
  35. package/dist/utilities/index.d.ts +10 -0
  36. package/dist/utilities/index.js +4 -0
  37. package/dist/utilities/isBrowser.cjs +7 -0
  38. package/dist/utilities/isBrowser.d.ts +22 -0
  39. package/dist/utilities/isBrowser.js +3 -0
  40. package/dist/utilities/makeReactive.cjs +7 -0
  41. package/dist/utilities/makeReactive.d.ts +41 -0
  42. package/dist/utilities/makeReactive.js +3 -0
  43. package/dist/utilities/toKebabCase.cjs +7 -0
  44. package/dist/utilities/toKebabCase.d.ts +26 -0
  45. package/dist/utilities/toKebabCase.js +3 -0
  46. package/package.json +40 -11
  47. package/dist/_constants-D8uytuQc.cjs +0 -6
  48. package/dist/_constants-DLywjTCf.js +0 -3
  49. package/dist/utilities.cjs +0 -10
  50. package/dist/utilities.d.ts +0 -4
  51. package/dist/utilities.js +0 -3
  52. /package/dist/{_helper-B0T4FTYh.js → index-B0T4FTYh.js} +0 -0
  53. /package/dist/{_helper-YcE1MU2f.cjs → index-YcE1MU2f.cjs} +0 -0
package/README.md CHANGED
@@ -106,30 +106,7 @@ Since we extended the native `div`, we use the `is` attribute:
106
106
  ---
107
107
 
108
108
  ## 📚 API Reference
109
-
110
- ### ```@defineElement(config)```
111
- Class decorator to register the custom element.
112
- * **tagName**: The kebab-case name for your component.
113
- * **html**: Raw HTML string for the template.
114
- * **css**: (Optional) CSS string to be injected into the Shadow Root.
115
- * **options**: (Optional) Standard `ElementDefinitionOptions` (e.g., `{ extends: 'button' }`).
116
-
117
- ### ```@property(options)```
118
- Used on `accessor` fields to create reactive attributes.
119
- * **type**: `"string" | "number" | "boolean"`. If omitted, it's inferred from the initial value.
120
- * **name**: Custom attribute name (defaults to kebab-case of the property).
121
- * **Hook**: Automatically calls `[propertyName]Update(old, new)` on change.
122
-
123
- ### ```@ref(selector)```
124
- Field decorator that automatically assigns a child element from the Shadow Root to the property using `querySelector`.
125
-
126
- ### ```@event(options)```
127
- Field decorator that initializes an `EventEmitter`.
128
- * **name**: Custom event name (defaults to kebab-case of the property).
129
- * **Usage**: Call `this.propertyName.emit(payload)` to dispatch a `CustomEvent`.
130
-
131
- ### ```Zui(BaseClass)```
132
- A class mixin that enhances the base element (like `HTMLElement` or `HTMLDivElement`) with improved TypeScript definitions for `addEventListener`, ensuring custom events have correct payload types.
109
+ [API Docs](docs/api/README.md)
133
110
 
134
111
  ---
135
112
 
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var REF_CONSTRUCTOR_KEY=Symbol("constructor");var EVENT_CONSTRUCTOR_KEY=Symbol("constructor");var OBSERVED_ATTRS_KEY=Symbol("observedAttributes");
4
+
5
+ exports.EVENT_CONSTRUCTOR_KEY = EVENT_CONSTRUCTOR_KEY;
6
+ exports.OBSERVED_ATTRS_KEY = OBSERVED_ATTRS_KEY;
7
+ exports.REF_CONSTRUCTOR_KEY = REF_CONSTRUCTOR_KEY;
@@ -0,0 +1,3 @@
1
+ var REF_CONSTRUCTOR_KEY=Symbol("constructor");var EVENT_CONSTRUCTOR_KEY=Symbol("constructor");var OBSERVED_ATTRS_KEY=Symbol("observedAttributes");
2
+
3
+ export { EVENT_CONSTRUCTOR_KEY as E, OBSERVED_ATTRS_KEY as O, REF_CONSTRUCTOR_KEY as R };
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const html = require('../html.cjs');
6
- const utilities = require('../utilities.cjs');
7
- const _helper = require('../_helper-YcE1MU2f.cjs');
8
- const _constants = require('../_constants-D8uytuQc.cjs');
6
+ const utilities_isBrowser = require('../utilities/isBrowser.cjs');
7
+ const index = require('../index-YcE1MU2f.cjs');
8
+ const _constants = require('../_constants-CnGtrSkM.cjs');
9
9
 
10
- function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else {obj[key]=value;}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass);}function _instanceof(left,right){if(right!=null&&typeof Symbol!=="undefined"&&right[Symbol.hasInstance]){return !!right[Symbol.hasInstance](left)}else {return left instanceof right}}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(_){}return (_is_native_reflect_construct=function(){return !!result})()}var defineElement=function(param){var tagName=param.tagName,html$1=param.html,_param_css=param.css,css=_param_css===void 0?"":_param_css,options=param.options;return function(originalClass,context){var attributes=context.metadata[_constants.OBSERVED_ATTRS_KEY];var htmlString=_instanceof(html$1,html.SafeHTML)?html$1.value:html$1;if(!htmlString)throw "Html is empty!";var template=document.createElement("template");template.innerHTML="<style>".concat(css,"</style>").concat(htmlString);var NewClass=/*#__PURE__*/function(originalClass){_inherits(NewClass,originalClass);function NewClass(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_class_call_check(this,NewClass);var _this;_this=_call_super(this,NewClass,_to_consumable_array(args)),_define_property(_this,"shadowRoot",void 0);_this.setAttribute("z-is",tagName);_this.shadowRoot=_this.attachShadow({mode:"closed"});_this.shadowRoot.appendChild(template.content.cloneNode(true));return _this}_create_class(NewClass,[{key:"connectedCallback",value:function connectedCallback(){var _this=this;queueMicrotask(function(){var _zuiThis_connected;var zuiThis=_this;(_zuiThis_connected=zuiThis.connected)===null||_zuiThis_connected===void 0?void 0:_zuiThis_connected.call(zuiThis);});}},{key:"disconnectedCallback",value:function disconnectedCallback(){var _this=this;queueMicrotask(function(){var _zuiThis_disconnected;var zuiThis=_this;(_zuiThis_disconnected=zuiThis.disconnected)===null||_zuiThis_disconnected===void 0?void 0:_zuiThis_disconnected.call(zuiThis);});}},{key:"attributeChangedCallback",value:function attributeChangedCallback(attributeName,oldValue,newValue){var zuiThis=this;if(oldValue!==newValue){var _zuiThis_attributeChanged;(_zuiThis_attributeChanged=zuiThis.attributeChanged)===null||_zuiThis_attributeChanged===void 0?void 0:_zuiThis_attributeChanged.call(zuiThis,attributeName,oldValue,newValue);}if(oldValue!==newValue){_helper.callFun(attributes.find(function(i){return i.name===attributeName}),oldValue,newValue,zuiThis);}}}]);return NewClass}(originalClass);NewClass.observedAttributes=attributes.map(function(i){return i.name});if(utilities.isBrowser&&!customElements.get(tagName)){customElements.define(tagName,NewClass,options);}return NewClass}};
10
+ function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else {obj[key]=value;}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass);}function _instanceof(left,right){if(right!=null&&typeof Symbol!=="undefined"&&right[Symbol.hasInstance]){return !!right[Symbol.hasInstance](left)}else {return left instanceof right}}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(_){}return (_is_native_reflect_construct=function(){return !!result})()}var defineElement=function(param){var tagName=param.tagName,html$1=param.html,_param_css=param.css,css=_param_css===void 0?"":_param_css,options=param.options;return function(originalClass,context){var attributes=context.metadata[_constants.OBSERVED_ATTRS_KEY];var htmlString=_instanceof(html$1,html.SafeHTML)?html$1.value:html$1;if(!htmlString)throw "Html is empty!";var template=document.createElement("template");template.innerHTML="<style>".concat(css,"</style>").concat(htmlString);var NewClass=/*#__PURE__*/function(originalClass){_inherits(NewClass,originalClass);function NewClass(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_class_call_check(this,NewClass);var _this;var _this_EVENT_CONSTRUCTOR_KEY,_this1,_this_REF_CONSTRUCTOR_KEY,_this2;_this=_call_super(this,NewClass,_to_consumable_array(args)),_define_property(_this,"shadowRoot",void 0);_this.setAttribute("z-is",tagName);_this.shadowRoot=_this.attachShadow({mode:"closed"});_this.shadowRoot.appendChild(template.content.cloneNode(true));(_this1=_this)===null||_this1===void 0?void 0:(_this_EVENT_CONSTRUCTOR_KEY=_this1[_constants.EVENT_CONSTRUCTOR_KEY])===null||_this_EVENT_CONSTRUCTOR_KEY===void 0?void 0:_this_EVENT_CONSTRUCTOR_KEY.call(_this1);(_this2=_this)===null||_this2===void 0?void 0:(_this_REF_CONSTRUCTOR_KEY=_this2[_constants.REF_CONSTRUCTOR_KEY])===null||_this_REF_CONSTRUCTOR_KEY===void 0?void 0:_this_REF_CONSTRUCTOR_KEY.call(_this2);return _this}_create_class(NewClass,[{key:"connectedCallback",value:function connectedCallback(){var _this=this;queueMicrotask(function(){var _zuiThis_connected;var zuiThis=_this;(_zuiThis_connected=zuiThis.connected)===null||_zuiThis_connected===void 0?void 0:_zuiThis_connected.call(zuiThis);});}},{key:"disconnectedCallback",value:function disconnectedCallback(){var _this=this;queueMicrotask(function(){var _zuiThis_disconnected;var zuiThis=_this;(_zuiThis_disconnected=zuiThis.disconnected)===null||_zuiThis_disconnected===void 0?void 0:_zuiThis_disconnected.call(zuiThis);});}},{key:"attributeChangedCallback",value:function attributeChangedCallback(attributeName,oldValue,newValue){var zuiThis=this;if(oldValue!==newValue){var _zuiThis_attributeChanged;zuiThis===null||zuiThis===void 0?void 0:(_zuiThis_attributeChanged=zuiThis.attributeChanged)===null||_zuiThis_attributeChanged===void 0?void 0:_zuiThis_attributeChanged.call(zuiThis,attributeName,oldValue,newValue);index.callFun(attributes.find(function(i){return i.name===attributeName}),oldValue,newValue,zuiThis);}}}]);return NewClass}(originalClass);NewClass.observedAttributes=attributes.map(function(i){return i.name});if(utilities_isBrowser.isBrowser&&!customElements.get(tagName)){customElements.define(tagName,NewClass,options);}return NewClass}};
11
11
 
12
12
  exports.defineElement = defineElement;
@@ -1,11 +1,59 @@
1
1
  import { SafeHTML } from '../html';
2
2
  import { UpdateMethods } from './types';
3
+ /**
4
+ * Configuration options for defining a custom element.
5
+ *
6
+ * @interface DefineElementOptions
7
+ * @property {string} tagName - The custom element tag name (must contain hyphen, e.g., 'my-counter')
8
+ * @property {string|SafeHTML} html - HTML template string or SafeHTML object for the element's shadow DOM
9
+ * @property {string} [css] - Optional CSS string to inject into the shadow DOM
10
+ * @property {ElementDefinitionOptions} [options] - Custom element definition options including extension support
11
+ *
12
+ * @example
13
+ * @defineElement({
14
+ * tagName: 'my-counter',
15
+ * html: '<div>Count: <span class="count"></span></div>',
16
+ * css: ':host { display: block; }',
17
+ * options: { extends: 'div' }
18
+ * })
19
+ */
3
20
  export interface DefineElementOptions {
4
21
  tagName: string;
5
22
  html: string | SafeHTML;
6
23
  css?: string;
7
24
  options?: ElementDefinitionOptions;
8
25
  }
26
+ /**
27
+ * Class decorator that registers a custom element with the browser's Custom Elements registry.
28
+ *
29
+ * This decorator:
30
+ * 1. Creates a Shadow DOM for the element
31
+ * 2. Injects HTML and CSS templates
32
+ * 3. Sets up lifecycle callbacks (connected/disconnected)
33
+ * 4. Handles attribute change observation
34
+ * 5. Registers the element with customElements.define()
35
+ *
36
+ * @template T - Constructor type extending CustomElementConstructor
37
+ * @param {DefineElementOptions} config - Element configuration object
38
+ * @returns {ClassDecorator} A class decorator function
39
+ *
40
+ * @throws {string} If HTML template is empty
41
+ * @example
42
+ * ```typescript
43
+ * @defineElement({
44
+ * tagName: 'my-counter',
45
+ * html: counterTemplate,
46
+ * css: counterStyles,
47
+ * options: { extends: 'div' }
48
+ * })
49
+ * class Counter extends Zui(HTMLDivElement) {
50
+ * // class implementation
51
+ * }
52
+ * ```
53
+ *
54
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define}
55
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow}
56
+ */
9
57
  export declare const defineElement: ({ tagName, html, css, options }: DefineElementOptions) => <T extends CustomElementConstructor>(originalClass: T & {
10
58
  prototype: UpdateMethods<InstanceType<T>>;
11
59
  }, context: ClassDecoratorContext<T>) => T;
@@ -1,8 +1,8 @@
1
1
  import { SafeHTML } from '../html.js';
2
- import { isBrowser } from '../utilities.js';
3
- import { c as callFun } from '../_helper-B0T4FTYh.js';
4
- import { O as OBSERVED_ATTRS_KEY } from '../_constants-DLywjTCf.js';
2
+ import { isBrowser } from '../utilities/isBrowser.js';
3
+ import { c as callFun } from '../index-B0T4FTYh.js';
4
+ import { O as OBSERVED_ATTRS_KEY, E as EVENT_CONSTRUCTOR_KEY, R as REF_CONSTRUCTOR_KEY } from '../_constants-DXNZF5so.js';
5
5
 
6
- function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else {obj[key]=value;}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass);}function _instanceof(left,right){if(right!=null&&typeof Symbol!=="undefined"&&right[Symbol.hasInstance]){return !!right[Symbol.hasInstance](left)}else {return left instanceof right}}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(_){}return (_is_native_reflect_construct=function(){return !!result})()}var defineElement=function(param){var tagName=param.tagName,html=param.html,_param_css=param.css,css=_param_css===void 0?"":_param_css,options=param.options;return function(originalClass,context){var attributes=context.metadata[OBSERVED_ATTRS_KEY];var htmlString=_instanceof(html,SafeHTML)?html.value:html;if(!htmlString)throw "Html is empty!";var template=document.createElement("template");template.innerHTML="<style>".concat(css,"</style>").concat(htmlString);var NewClass=/*#__PURE__*/function(originalClass){_inherits(NewClass,originalClass);function NewClass(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_class_call_check(this,NewClass);var _this;_this=_call_super(this,NewClass,_to_consumable_array(args)),_define_property(_this,"shadowRoot",void 0);_this.setAttribute("z-is",tagName);_this.shadowRoot=_this.attachShadow({mode:"closed"});_this.shadowRoot.appendChild(template.content.cloneNode(true));return _this}_create_class(NewClass,[{key:"connectedCallback",value:function connectedCallback(){var _this=this;queueMicrotask(function(){var _zuiThis_connected;var zuiThis=_this;(_zuiThis_connected=zuiThis.connected)===null||_zuiThis_connected===void 0?void 0:_zuiThis_connected.call(zuiThis);});}},{key:"disconnectedCallback",value:function disconnectedCallback(){var _this=this;queueMicrotask(function(){var _zuiThis_disconnected;var zuiThis=_this;(_zuiThis_disconnected=zuiThis.disconnected)===null||_zuiThis_disconnected===void 0?void 0:_zuiThis_disconnected.call(zuiThis);});}},{key:"attributeChangedCallback",value:function attributeChangedCallback(attributeName,oldValue,newValue){var zuiThis=this;if(oldValue!==newValue){var _zuiThis_attributeChanged;(_zuiThis_attributeChanged=zuiThis.attributeChanged)===null||_zuiThis_attributeChanged===void 0?void 0:_zuiThis_attributeChanged.call(zuiThis,attributeName,oldValue,newValue);}if(oldValue!==newValue){callFun(attributes.find(function(i){return i.name===attributeName}),oldValue,newValue,zuiThis);}}}]);return NewClass}(originalClass);NewClass.observedAttributes=attributes.map(function(i){return i.name});if(isBrowser&&!customElements.get(tagName)){customElements.define(tagName,NewClass,options);}return NewClass}};
6
+ function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else {obj[key]=value;}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass);}function _instanceof(left,right){if(right!=null&&typeof Symbol!=="undefined"&&right[Symbol.hasInstance]){return !!right[Symbol.hasInstance](left)}else {return left instanceof right}}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(_){}return (_is_native_reflect_construct=function(){return !!result})()}var defineElement=function(param){var tagName=param.tagName,html=param.html,_param_css=param.css,css=_param_css===void 0?"":_param_css,options=param.options;return function(originalClass,context){var attributes=context.metadata[OBSERVED_ATTRS_KEY];var htmlString=_instanceof(html,SafeHTML)?html.value:html;if(!htmlString)throw "Html is empty!";var template=document.createElement("template");template.innerHTML="<style>".concat(css,"</style>").concat(htmlString);var NewClass=/*#__PURE__*/function(originalClass){_inherits(NewClass,originalClass);function NewClass(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_class_call_check(this,NewClass);var _this;var _this_EVENT_CONSTRUCTOR_KEY,_this1,_this_REF_CONSTRUCTOR_KEY,_this2;_this=_call_super(this,NewClass,_to_consumable_array(args)),_define_property(_this,"shadowRoot",void 0);_this.setAttribute("z-is",tagName);_this.shadowRoot=_this.attachShadow({mode:"closed"});_this.shadowRoot.appendChild(template.content.cloneNode(true));(_this1=_this)===null||_this1===void 0?void 0:(_this_EVENT_CONSTRUCTOR_KEY=_this1[EVENT_CONSTRUCTOR_KEY])===null||_this_EVENT_CONSTRUCTOR_KEY===void 0?void 0:_this_EVENT_CONSTRUCTOR_KEY.call(_this1);(_this2=_this)===null||_this2===void 0?void 0:(_this_REF_CONSTRUCTOR_KEY=_this2[REF_CONSTRUCTOR_KEY])===null||_this_REF_CONSTRUCTOR_KEY===void 0?void 0:_this_REF_CONSTRUCTOR_KEY.call(_this2);return _this}_create_class(NewClass,[{key:"connectedCallback",value:function connectedCallback(){var _this=this;queueMicrotask(function(){var _zuiThis_connected;var zuiThis=_this;(_zuiThis_connected=zuiThis.connected)===null||_zuiThis_connected===void 0?void 0:_zuiThis_connected.call(zuiThis);});}},{key:"disconnectedCallback",value:function disconnectedCallback(){var _this=this;queueMicrotask(function(){var _zuiThis_disconnected;var zuiThis=_this;(_zuiThis_disconnected=zuiThis.disconnected)===null||_zuiThis_disconnected===void 0?void 0:_zuiThis_disconnected.call(zuiThis);});}},{key:"attributeChangedCallback",value:function attributeChangedCallback(attributeName,oldValue,newValue){var zuiThis=this;if(oldValue!==newValue){var _zuiThis_attributeChanged;zuiThis===null||zuiThis===void 0?void 0:(_zuiThis_attributeChanged=zuiThis.attributeChanged)===null||_zuiThis_attributeChanged===void 0?void 0:_zuiThis_attributeChanged.call(zuiThis,attributeName,oldValue,newValue);callFun(attributes.find(function(i){return i.name===attributeName}),oldValue,newValue,zuiThis);}}}]);return NewClass}(originalClass);NewClass.observedAttributes=attributes.map(function(i){return i.name});if(isBrowser&&!customElements.get(tagName)){customElements.define(tagName,NewClass,options);}return NewClass}};
7
7
 
8
8
  export { defineElement };
@@ -2,9 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const utilities = require('../utilities.cjs');
5
+ const utilities_toKebabCase = require('../utilities/toKebabCase.cjs');
6
+ const _constants = require('../_constants-CnGtrSkM.cjs');
6
7
  const decorators_types = require('./types.cjs');
7
8
 
8
- var event=function(){var options=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return function(_target,context){var _options_name;var eventName=(_options_name=options.name)!==null&&_options_name!==void 0?_options_name:utilities.toKebabCase(context.name.toString());context.addInitializer(function(){var _this=this;queueMicrotask(function(){var zuiThis=_this;zuiThis[context.name.toString()]=new decorators_types.EventEmitter(zuiThis,eventName);});});}};
9
+ var event=function(){var options=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return function(_target,context){var _options_name;var eventName=(_options_name=options.name)!==null&&_options_name!==void 0?_options_name:utilities_toKebabCase.toKebabCase(context.name.toString());context.addInitializer(function(){var zuiThis=this;var refInit=zuiThis===null||zuiThis===void 0?void 0:zuiThis[_constants.EVENT_CONSTRUCTOR_KEY];zuiThis[_constants.EVENT_CONSTRUCTOR_KEY]=function(){if(typeof refInit==="function")refInit.call(this);zuiThis[context.name.toString()]=new decorators_types.EventEmitter(zuiThis,eventName);};});}};
9
10
 
10
11
  exports.event = event;
@@ -1,5 +1,53 @@
1
1
  import { EventEmitter } from './types';
2
+ /**
3
+ * Configuration options for the @event decorator.
4
+ *
5
+ * @interface EventOptions
6
+ * @property {string} [name] - Custom event name (defaults to kebab-case of property name)
7
+ *
8
+ * @example
9
+ * @event({ name: 'count-changed' })
10
+ * onChange!: EventEmitter<number>;
11
+ */
2
12
  export interface EventOptions {
3
13
  name?: string;
4
14
  }
15
+ /**
16
+ * Field decorator that creates a typed EventEmitter instance for dispatching custom events.
17
+ *
18
+ * Features:
19
+ * - Automatic event naming (camelCase → kebab-case)
20
+ * - Type-safe event payloads
21
+ * - Bubbles and composed by default
22
+ * - Asynchronous initialization via queueMicrotask
23
+ *
24
+ * @template T - Element type extending HTMLElement
25
+ * @template V - Event detail type
26
+ * @param {EventOptions} [options={}] - Event configuration options
27
+ * @returns {ClassFieldDecorator} A field decorator function
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * // Basic usage with automatic naming
32
+ * @event()
33
+ * counterClick!: EventEmitter<{ count: number }>;
34
+ * // Dispatches 'counter-click' event
35
+ *
36
+ * // With custom event name
37
+ * @event({ name: 'value-changed' })
38
+ * onChange!: EventEmitter<number>;
39
+ * // Dispatches 'value-changed' event
40
+ *
41
+ * // Usage in component
42
+ * this.counterClick.emit({ count: this.count });
43
+ * ```
44
+ *
45
+ * @remarks
46
+ * - Events bubble up the DOM tree by default
47
+ * - Events can cross shadow DOM boundaries (composed: true)
48
+ * - Event name is converted to kebab-case automatically
49
+ *
50
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent}
51
+ * @see {@link EventEmitter}
52
+ */
5
53
  export declare const event: (options?: EventOptions) => <T extends HTMLElement, V>(_target: undefined, context: ClassFieldDecoratorContext<T, EventEmitter<V>>) => void;
@@ -1,6 +1,7 @@
1
- import { toKebabCase } from '../utilities.js';
1
+ import { toKebabCase } from '../utilities/toKebabCase.js';
2
+ import { E as EVENT_CONSTRUCTOR_KEY } from '../_constants-DXNZF5so.js';
2
3
  import { EventEmitter } from './types.js';
3
4
 
4
- var event=function(){var options=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return function(_target,context){var _options_name;var eventName=(_options_name=options.name)!==null&&_options_name!==void 0?_options_name:toKebabCase(context.name.toString());context.addInitializer(function(){var _this=this;queueMicrotask(function(){var zuiThis=_this;zuiThis[context.name.toString()]=new EventEmitter(zuiThis,eventName);});});}};
5
+ var event=function(){var options=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return function(_target,context){var _options_name;var eventName=(_options_name=options.name)!==null&&_options_name!==void 0?_options_name:toKebabCase(context.name.toString());context.addInitializer(function(){var zuiThis=this;var refInit=zuiThis===null||zuiThis===void 0?void 0:zuiThis[EVENT_CONSTRUCTOR_KEY];zuiThis[EVENT_CONSTRUCTOR_KEY]=function(){if(typeof refInit==="function")refInit.call(this);zuiThis[context.name.toString()]=new EventEmitter(zuiThis,eventName);};});}};
5
6
 
6
7
  export { event };
@@ -4,6 +4,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const decorators_defineElement = require('./defineElement.cjs');
6
6
  const decorators_event = require('./event.cjs');
7
+ const decorators_mixin = require('./mixin.cjs');
7
8
  const decorators_property = require('./property.cjs');
8
9
  const decorators_refs = require('./refs.cjs');
9
10
  const decorators_state = require('./state.cjs');
@@ -13,6 +14,7 @@ const decorators_types = require('./types.cjs');
13
14
 
14
15
  exports.defineElement = decorators_defineElement.defineElement;
15
16
  exports.event = decorators_event.event;
17
+ exports.Zui = decorators_mixin.Zui;
16
18
  exports.property = decorators_property.property;
17
19
  exports.ref = decorators_refs.ref;
18
20
  exports.state = decorators_state.state;
@@ -1,5 +1,6 @@
1
1
  export * from './defineElement.ts';
2
2
  export * from './event.ts';
3
+ export * from './mixin.ts';
3
4
  export * from './property.ts';
4
5
  export * from './refs.ts';
5
6
  export * from './state.ts';
@@ -1,5 +1,6 @@
1
1
  export { defineElement } from './defineElement.js';
2
2
  export { event } from './event.js';
3
+ export { Zui } from './mixin.js';
3
4
  export { property } from './property.js';
4
5
  export { ref } from './refs.js';
5
6
  export { state } from './state.js';
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);return Constructor}function _get(target,property,receiver){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get;}else {_get=function get(target,property,receiver){var base=_super_prop_base(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(receiver||target)}return desc.value};}return _get(target,property,receiver||target)}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass);}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _super_prop_base(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_get_prototype_of(object);if(object===null)break}return object}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(_){}return (_is_native_reflect_construct=function(){return !!result})()}function Zui(Base){var ZuiElement=/*#__PURE__*/function(Base){_inherits(ZuiElement,Base);function ZuiElement(){_class_call_check(this,ZuiElement);return _call_super(this,ZuiElement,arguments)}_create_class(ZuiElement,[{key:"addEventListener",value:function addEventListener(type,listener,options){_get(_get_prototype_of(ZuiElement.prototype),"addEventListener",this).call(this,type,listener,options);}}]);return ZuiElement}(Base);return ZuiElement}
6
+
7
+ exports.Zui = Zui;