@o.z/zui 0.1.1 → 0.2.1

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.
package/README.md CHANGED
@@ -36,94 +36,70 @@ pnpm add @o.z/zui
36
36
 
37
37
  ## 🛠️ Usage Example
38
38
 
39
- ZUI works best with Vite's string imports for HTML and CSS. Below is a complete example of a **Reactive Counter** that extends a native `div`.
39
+ ZUI is designed to work seamlessly with Vites raw and inline string imports for templates and styles.
40
40
 
41
- ### 1. The Component (`counter.ts`)
41
+ ### 1. The Component (```counter.ts```)
42
42
 
43
43
  ```typescript
44
- import { defineElement, event, property, ref } from "@o.z/zui";
45
- import htmlStr from "./counter.html?raw";
46
- import cssStr from "./counter.scss?inline";
44
+ import { defineElement, event, property, ref, Zui, EventEmitter } from "@o.z/zui"
45
+ import htmlStr from "./counter.html?raw"
46
+ import cssStr from "./counter.scss?inline"
47
+
48
+ export type CounterClickEvent = { count: number; e?: MouseEvent }
47
49
 
48
50
  @defineElement({
49
51
  tagName: "my-counter",
50
52
  html: htmlStr,
51
53
  css: cssStr,
52
- options: { extends: 'div' } // Extends native HTMLDivElement
54
+ options: { extends: 'div' } // Extend native div functionality
53
55
  })
54
- export class Counter extends HTMLDivElement {
55
-
56
- // 1. Reactive State: Auto-observes attributes and updates
56
+ export class Counter extends Zui(HTMLDivElement) {
57
+ // 1. Reactive State: Synchronized with 'count' attribute
57
58
  @property()
58
- accessor count = 0;
59
-
60
- // 2. DOM References: Selects elements from the template
61
- @ref(".counter")
62
- counterRef!: HTMLDivElement;
59
+ accessor count = 0
63
60
 
64
- @ref(".increase")
65
- increaseRef!: HTMLButtonElement;
61
+ // 2. DOM References: Automatically queried from Shadow Root
62
+ @ref(".counter-display")
63
+ displayRef!: HTMLDivElement
66
64
 
67
- @ref(".decrease")
68
- decreaseRef!: HTMLButtonElement;
65
+ @ref(".btn-inc")
66
+ incBtn!: HTMLButtonElement
69
67
 
70
- // 3. Event Emitter: Generates 'emitCounterClick' method
71
- @event({ name: "counter-click" })
72
- counterClick!: CustomEvent<any>;
68
+ // 3. Event Emitter: Typed event dispatcher
69
+ @event()
70
+ counterClick!: EventEmitter<CounterClickEvent>
73
71
 
74
72
  connected() {
75
- // 'connected' is a ZUI shorthand for connectedCallback
76
- this.increaseRef.addEventListener("click", this.incHandler);
77
- this.decreaseRef.addEventListener("click", this.decHandler);
78
- }
79
-
80
- disconnected() {
81
- this.increaseRef.removeEventListener("click", this.incHandler);
82
- this.decreaseRef.removeEventListener("click", this.decHandler);
73
+ this.incBtn.addEventListener("click", () => {
74
+ this.counterClick.emit({ count: 1 })
75
+ })
83
76
  }
84
77
 
85
- incHandler = (e: MouseEvent) => {
86
- // Magic method generated by @event
87
- (this as any).emitCounterClick({ e, count: 1 });
88
- }
89
-
90
- decHandler = (e: MouseEvent) => {
91
- (this as any).emitCounterClick({ e, count: -1 });
92
- }
93
-
94
- // 4. Lifecycle Hook: Called automatically when 'count' changes
95
- countUpdate(_oldVal: number, newVal: number) {
96
- this.counterRef.innerHTML = newVal.toString();
78
+ // 4. Reactive Hook: Called when 'count' changes
79
+ countUpdate(oldValue: number, newValue: number) {
80
+ this.displayRef.innerHTML = newValue.toString()
97
81
  }
98
82
  }
99
83
  ```
100
84
 
101
- ### 2. The Template (`counter.html`)
85
+ ### 2. Usage in HTML
102
86
 
103
- ```html
104
- <div class="container">
105
- <div class="counter">0</div>
106
- <button class="increase">+</button>
107
- <button class="decrease">-</button>
108
- </div>
109
- ```
110
-
111
- ### 3. Usage in HTML
112
-
113
- Because ZUI supports **Customized Built-in Elements**, you can enhance standard tags:
87
+ Since we extended the native `div`, we use the `is` attribute:
114
88
 
115
89
  ```html
116
- <div id="counter" is="my-counter"></div>
90
+ <div id="counter" is="my-counter">
91
+ <span slot="increase">Increment</span>
92
+ </div>
117
93
 
118
94
  <script type="module">
119
- import "./counter";
95
+ import { Counter } from "./counter"
120
96
 
121
- const el = document.querySelector("#counter");
97
+ const el = document.querySelector("#counter")
122
98
 
123
- // Listen to the strongly typed custom event
99
+ // Fully typed event details via e.detail.value
124
100
  el.addEventListener("counter-click", (e) => {
125
- el.count += e.detail.value.count;
126
- });
101
+ el.count += e.detail.value.count
102
+ })
127
103
  </script>
128
104
  ```
129
105
 
@@ -131,40 +107,34 @@ Because ZUI supports **Customized Built-in Elements**, you can enhance standard
131
107
 
132
108
  ## 📚 API Reference
133
109
 
134
- ### `@defineElement(config)`
110
+ ### ```@defineElement(config)```
135
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' }`).
136
116
 
137
- * **tagName** `string`: The kebab-case tag name (e.g., `my-counter`).
138
- * **html** `string`: Raw HTML string for the Shadow DOM.
139
- * **css** `string`: (Optional) Raw CSS string.
140
- * **options** `ElementDefinitionOptions`: (Optional) Used for `extends` (e.g., `{ extends: 'div' }`).
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.
141
122
 
142
- ### `@property(options)`
143
- Decorator for class accessors. It handles attribute observation and type conversion.
123
+ ### ```@ref(selector)```
124
+ Field decorator that automatically assigns a child element from the Shadow Root to the property using `querySelector`.
144
125
 
145
- * **type**: `"string" | "number" | "boolean"` (Auto-inferred from initial value if omitted).
146
- * **name**: Attribute name (defaults to kebab-case of property name).
147
- * **Lifecycle Hook**: When `myProp` changes, ZUI looks for a method named `myPropUpdate(oldVal, newVal)` and calls it.
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`.
148
130
 
149
- ### `@ref(selector)`
150
- Field decorator to cache DOM queries.
151
-
152
- * **selector** `string`: The CSS selector to find the element within the component's Shadow Root.
153
- * Populates the property automatically after the component connects.
154
-
155
- ### `@event(config)`
156
- Field decorator to generate event emitters.
157
-
158
- * **name** `string`: The name of the custom event to dispatch.
159
- * **Generates**: A method on the instance named `emit[PropertyName capitalized]`.
160
- * **Payload**: Arguments passed to the emit method are available in `event.detail.value`.
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.
161
133
 
162
134
  ---
163
135
 
164
136
  ## 💻 Development
165
137
 
166
- This project uses **Vite** and **TypeScript**.
167
-
168
138
  ```bash
169
139
  # Install dependencies
170
140
  yarn install
@@ -2,9 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
+ const types = require('./types.cjs');
5
6
  const utilities = require('./utilities.cjs');
6
7
 
7
- 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 _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 OBSERVED_ATTRS_KEY=Symbol("observedAttributes");var callFun=function(attribute,oldValue,newValue,bindThis){if(attribute){var funName=attribute.callbackName;if(funName in bindThis){if(attribute.type==="string"){bindThis[funName](oldValue,newValue);}else if(attribute.type==="number"){bindThis[funName](+oldValue,+newValue);}else if(attribute.type==="boolean"){bindThis[funName](typeof oldValue==="string"?oldValue===""||String(oldValue).toLowerCase()==="true":Boolean(oldValue),typeof newValue==="string"?newValue===""||String(newValue).toLowerCase()==="true":Boolean(newValue));}}}};var getConvertor=function(param,bindThis){var type=param.type,name=param.name;var value=bindThis.getAttribute(name);if(value!==undefined&&value!==null){if(type==="number")return +value;else if(type==="string")return value;else if(type==="boolean"){return value===""||(value===null||value===void 0?void 0:value.toLowerCase())==="true"}else throw 'Only accept type of "string", "number", "boolean"'}};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];if(!html)throw "Html is empty!";var template=document.createElement("template");template.innerHTML="<style>".concat(css,"</style>").concat(html);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("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 _this1;(_this1=_this)===null||_this1===void 0?void 0:_this1["connected"]();});}},{key:"disconnectedCallback",value:function disconnectedCallback(){var _this=this;queueMicrotask(function(){var _this1;(_this1=_this)===null||_this1===void 0?void 0:_this1["disconnected"]();});}},{key:"attributeChangedCallback",value:function attributeChangedCallback(attributeName,oldValue,newValue){if(oldValue!==newValue){var _this_attributyyeChanged,_this;(_this=this)===null||_this===void 0?void 0:(_this_attributyyeChanged=_this["attributyyeChanged"])===null||_this_attributyyeChanged===void 0?void 0:_this_attributyyeChanged.call(_this,attributeName,oldValue,newValue);}if(oldValue!==newValue){callFun(attributes.find(function(i){return i.name===attributeName}),oldValue,newValue,this);}}}]);return NewClass}(originalClass);NewClass.observedAttributes=attributes.map(function(i){return i.name});if(!customElements.get(tagName)){customElements.define(tagName,NewClass,options);}return NewClass}};var property=function(){var _ref=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},type=_ref.type,name=_ref.name,callbackName=_ref.callbackName;return function(_accessor,context){var _context_metadata,_OBSERVED_ATTRS_KEY,_;var attributName=name!==null&&name!==void 0?name:utilities.toKebabCase(context.name.toString());var attributCallbackName=callbackName!==null&&callbackName!==void 0?callbackName:"".concat(context.name.toString(),"Update");var attribute={type:type,name:attributName,callbackName:attributCallbackName};(_=(_context_metadata=context.metadata)[_OBSERVED_ATTRS_KEY=OBSERVED_ATTRS_KEY])!==null&&_!==void 0?_:_context_metadata[_OBSERVED_ATTRS_KEY]=[];var attributes=context.metadata[OBSERVED_ATTRS_KEY];attributes.push(attribute);return {init:function init(initialValue){var _this=this;attribute.type=type!==null&&type!==void 0?type:typeof initialValue==="undefined"?"undefined":_type_of(initialValue);this.setAttribute(attribute.name,String(initialValue));queueMicrotask(function(){callFun(attribute,initialValue,initialValue,_this);});return initialValue},get:function get(){return getConvertor(attribute,this)},set:function set(value){var _this=this;queueMicrotask(function(){var oldValue=getConvertor(attribute,_this);if(attribute.type==="string"||attribute.type==="number"){_this.setAttribute(attributName,String(value));}else if(attribute.type==="boolean"){_this.setAttribute(attributName,value?"true":"false");}else throw 'Only accept type of "string", "number", "boolean"';if(oldValue!==value)callFun(attribute,oldValue,value,_this);});}}}};var ref=function(selector){return function(_target,context){context.addInitializer(function(){var _this=this;queueMicrotask(function(){_this[context.name]=_this.shadowRoot.querySelector(selector);});});}};var event=function(param){var name=param.name,init=param.init,emitName=param.emitName;return function(_target,context){init!==null&&init!==void 0?init:init={};context.addInitializer(function(){var _this=this;queueMicrotask(function(){var prototype=Object.getPrototypeOf(_this);var methodName=emitName!==null&&emitName!==void 0?emitName:"emit".concat(String(context.name).charAt(0).toUpperCase()+String(context.name).slice(1));_this[context.name]=new CustomEvent(name,{detail:{value:init}});if(!prototype[methodName]){prototype[methodName]=function(value){this[context.name].detail.value=value;this.dispatchEvent(this[context.name]);};}});});}};
8
+ 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 _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 OBSERVED_ATTRS_KEY=Symbol("observedAttributes");var callFun=function(attribute,oldValue,newValue,zuiThis){if(attribute){var funName=attribute.callbackName;if(funName in zuiThis){if(attribute.type==="string"){zuiThis[funName](oldValue,newValue);}else if(attribute.type==="number"){zuiThis[funName](+oldValue,+newValue);}else if(attribute.type==="boolean"){zuiThis[funName](typeof oldValue==="string"?oldValue===""||String(oldValue).toLowerCase()==="true":Boolean(oldValue),typeof newValue==="string"?newValue===""||String(newValue).toLowerCase()==="true":Boolean(newValue));}}}};var getConvertor=function(param,zuiThis){var type=param.type,name=param.name;var value=zuiThis.getAttribute(name);if(value!==undefined&&value!==null){if(type==="number")return +value;else if(type==="string")return value;else if(type==="boolean"){return value===""||(value===null||value===void 0?void 0:value.toLowerCase())==="true"}else throw 'Only accept type of "string", "number", "boolean"'}};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];if(!html)throw "Html is empty!";var template=document.createElement("template");template.innerHTML="<style>".concat(css,"</style>").concat(html);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("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(!customElements.get(tagName)){customElements.define(tagName,NewClass,options);}return NewClass}};var property=function(){var _ref=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},type=_ref.type,name=_ref.name,callbackName=_ref.callbackName;return function(_accessor,context){var _context_metadata,_OBSERVED_ATTRS_KEY,_;var attributName=name!==null&&name!==void 0?name:utilities.toKebabCase(context.name.toString());var attributCallbackName=callbackName!==null&&callbackName!==void 0?callbackName:"".concat(context.name.toString(),"Update");var attribute={type:type,name:attributName,callbackName:attributCallbackName};(_=(_context_metadata=context.metadata)[_OBSERVED_ATTRS_KEY=OBSERVED_ATTRS_KEY])!==null&&_!==void 0?_:_context_metadata[_OBSERVED_ATTRS_KEY]=[];var attributes=context.metadata[OBSERVED_ATTRS_KEY];attributes.push(attribute);return {init:function init(initialValue){attribute.type=type!==null&&type!==void 0?type:typeof initialValue==="undefined"?"undefined":_type_of(initialValue);var zuiThis=this;zuiThis.setAttribute(attribute.name,String(initialValue));queueMicrotask(function(){callFun(attribute,initialValue,initialValue,zuiThis);});return initialValue},get:function get(){var zuiThis=this;return getConvertor(attribute,zuiThis)},set:function set(value){var _this=this;queueMicrotask(function(){var zuiThis=_this;var oldValue=getConvertor(attribute,zuiThis);if(attribute.type==="string"||attribute.type==="number"){zuiThis.setAttribute(attributName,String(value));}else if(attribute.type==="boolean"){zuiThis.setAttribute(attributName,value?"true":"false");}else throw 'Only accept type of "string", "number", "boolean"';if(oldValue!==value)callFun(attribute,oldValue,value,zuiThis);});}}}};var ref=function(selector){return function(_target,context){context.addInitializer(function(){var _this=this;queueMicrotask(function(){var zuiThis=_this;zuiThis[context.name.toString()]=zuiThis.shadowRoot.querySelector(selector);});});}};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 types.EventEmitter(zuiThis,eventName);});});}};
8
9
 
9
10
  exports.defineElement = defineElement;
10
11
  exports.event = event;
@@ -1,3 +1,4 @@
1
+ import { EventEmitter } from './types';
1
2
  export interface DefineElementProp {
2
3
  tagName: string;
3
4
  html: string;
@@ -24,9 +25,7 @@ export declare const property: ({ type, name, callbackName }?: PropertyProp) =>
24
25
  };
25
26
  export declare const ref: (selector: string) => <T extends HTMLElement, V extends HTMLElement>(_target: undefined, context: ClassFieldDecoratorContext<T, V>) => void;
26
27
  interface EventProp {
27
- name: string;
28
- init?: any;
29
- emitName?: string;
28
+ name?: string;
30
29
  }
31
- export declare const event: ({ name, init, emitName }: EventProp) => <T extends HTMLElement, V extends CustomEvent>(_target: undefined, context: ClassFieldDecoratorContext<T, V>) => void;
30
+ export declare const event: (options?: EventProp) => <T extends HTMLElement, V>(_target: undefined, context: ClassFieldDecoratorContext<T, EventEmitter<V>>) => void;
32
31
  export {};
@@ -1,5 +1,6 @@
1
+ import { EventEmitter } from './types.js';
1
2
  import { toKebabCase } from './utilities.js';
2
3
 
3
- 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 _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 OBSERVED_ATTRS_KEY=Symbol("observedAttributes");var callFun=function(attribute,oldValue,newValue,bindThis){if(attribute){var funName=attribute.callbackName;if(funName in bindThis){if(attribute.type==="string"){bindThis[funName](oldValue,newValue);}else if(attribute.type==="number"){bindThis[funName](+oldValue,+newValue);}else if(attribute.type==="boolean"){bindThis[funName](typeof oldValue==="string"?oldValue===""||String(oldValue).toLowerCase()==="true":Boolean(oldValue),typeof newValue==="string"?newValue===""||String(newValue).toLowerCase()==="true":Boolean(newValue));}}}};var getConvertor=function(param,bindThis){var type=param.type,name=param.name;var value=bindThis.getAttribute(name);if(value!==undefined&&value!==null){if(type==="number")return +value;else if(type==="string")return value;else if(type==="boolean"){return value===""||(value===null||value===void 0?void 0:value.toLowerCase())==="true"}else throw 'Only accept type of "string", "number", "boolean"'}};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];if(!html)throw "Html is empty!";var template=document.createElement("template");template.innerHTML="<style>".concat(css,"</style>").concat(html);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("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 _this1;(_this1=_this)===null||_this1===void 0?void 0:_this1["connected"]();});}},{key:"disconnectedCallback",value:function disconnectedCallback(){var _this=this;queueMicrotask(function(){var _this1;(_this1=_this)===null||_this1===void 0?void 0:_this1["disconnected"]();});}},{key:"attributeChangedCallback",value:function attributeChangedCallback(attributeName,oldValue,newValue){if(oldValue!==newValue){var _this_attributyyeChanged,_this;(_this=this)===null||_this===void 0?void 0:(_this_attributyyeChanged=_this["attributyyeChanged"])===null||_this_attributyyeChanged===void 0?void 0:_this_attributyyeChanged.call(_this,attributeName,oldValue,newValue);}if(oldValue!==newValue){callFun(attributes.find(function(i){return i.name===attributeName}),oldValue,newValue,this);}}}]);return NewClass}(originalClass);NewClass.observedAttributes=attributes.map(function(i){return i.name});if(!customElements.get(tagName)){customElements.define(tagName,NewClass,options);}return NewClass}};var property=function(){var _ref=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},type=_ref.type,name=_ref.name,callbackName=_ref.callbackName;return function(_accessor,context){var _context_metadata,_OBSERVED_ATTRS_KEY,_;var attributName=name!==null&&name!==void 0?name:toKebabCase(context.name.toString());var attributCallbackName=callbackName!==null&&callbackName!==void 0?callbackName:"".concat(context.name.toString(),"Update");var attribute={type:type,name:attributName,callbackName:attributCallbackName};(_=(_context_metadata=context.metadata)[_OBSERVED_ATTRS_KEY=OBSERVED_ATTRS_KEY])!==null&&_!==void 0?_:_context_metadata[_OBSERVED_ATTRS_KEY]=[];var attributes=context.metadata[OBSERVED_ATTRS_KEY];attributes.push(attribute);return {init:function init(initialValue){var _this=this;attribute.type=type!==null&&type!==void 0?type:typeof initialValue==="undefined"?"undefined":_type_of(initialValue);this.setAttribute(attribute.name,String(initialValue));queueMicrotask(function(){callFun(attribute,initialValue,initialValue,_this);});return initialValue},get:function get(){return getConvertor(attribute,this)},set:function set(value){var _this=this;queueMicrotask(function(){var oldValue=getConvertor(attribute,_this);if(attribute.type==="string"||attribute.type==="number"){_this.setAttribute(attributName,String(value));}else if(attribute.type==="boolean"){_this.setAttribute(attributName,value?"true":"false");}else throw 'Only accept type of "string", "number", "boolean"';if(oldValue!==value)callFun(attribute,oldValue,value,_this);});}}}};var ref=function(selector){return function(_target,context){context.addInitializer(function(){var _this=this;queueMicrotask(function(){_this[context.name]=_this.shadowRoot.querySelector(selector);});});}};var event=function(param){var name=param.name,init=param.init,emitName=param.emitName;return function(_target,context){init!==null&&init!==void 0?init:init={};context.addInitializer(function(){var _this=this;queueMicrotask(function(){var prototype=Object.getPrototypeOf(_this);var methodName=emitName!==null&&emitName!==void 0?emitName:"emit".concat(String(context.name).charAt(0).toUpperCase()+String(context.name).slice(1));_this[context.name]=new CustomEvent(name,{detail:{value:init}});if(!prototype[methodName]){prototype[methodName]=function(value){this[context.name].detail.value=value;this.dispatchEvent(this[context.name]);};}});});}};
4
+ 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 _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 OBSERVED_ATTRS_KEY=Symbol("observedAttributes");var callFun=function(attribute,oldValue,newValue,zuiThis){if(attribute){var funName=attribute.callbackName;if(funName in zuiThis){if(attribute.type==="string"){zuiThis[funName](oldValue,newValue);}else if(attribute.type==="number"){zuiThis[funName](+oldValue,+newValue);}else if(attribute.type==="boolean"){zuiThis[funName](typeof oldValue==="string"?oldValue===""||String(oldValue).toLowerCase()==="true":Boolean(oldValue),typeof newValue==="string"?newValue===""||String(newValue).toLowerCase()==="true":Boolean(newValue));}}}};var getConvertor=function(param,zuiThis){var type=param.type,name=param.name;var value=zuiThis.getAttribute(name);if(value!==undefined&&value!==null){if(type==="number")return +value;else if(type==="string")return value;else if(type==="boolean"){return value===""||(value===null||value===void 0?void 0:value.toLowerCase())==="true"}else throw 'Only accept type of "string", "number", "boolean"'}};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];if(!html)throw "Html is empty!";var template=document.createElement("template");template.innerHTML="<style>".concat(css,"</style>").concat(html);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("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(!customElements.get(tagName)){customElements.define(tagName,NewClass,options);}return NewClass}};var property=function(){var _ref=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},type=_ref.type,name=_ref.name,callbackName=_ref.callbackName;return function(_accessor,context){var _context_metadata,_OBSERVED_ATTRS_KEY,_;var attributName=name!==null&&name!==void 0?name:toKebabCase(context.name.toString());var attributCallbackName=callbackName!==null&&callbackName!==void 0?callbackName:"".concat(context.name.toString(),"Update");var attribute={type:type,name:attributName,callbackName:attributCallbackName};(_=(_context_metadata=context.metadata)[_OBSERVED_ATTRS_KEY=OBSERVED_ATTRS_KEY])!==null&&_!==void 0?_:_context_metadata[_OBSERVED_ATTRS_KEY]=[];var attributes=context.metadata[OBSERVED_ATTRS_KEY];attributes.push(attribute);return {init:function init(initialValue){attribute.type=type!==null&&type!==void 0?type:typeof initialValue==="undefined"?"undefined":_type_of(initialValue);var zuiThis=this;zuiThis.setAttribute(attribute.name,String(initialValue));queueMicrotask(function(){callFun(attribute,initialValue,initialValue,zuiThis);});return initialValue},get:function get(){var zuiThis=this;return getConvertor(attribute,zuiThis)},set:function set(value){var _this=this;queueMicrotask(function(){var zuiThis=_this;var oldValue=getConvertor(attribute,zuiThis);if(attribute.type==="string"||attribute.type==="number"){zuiThis.setAttribute(attributName,String(value));}else if(attribute.type==="boolean"){zuiThis.setAttribute(attributName,value?"true":"false");}else throw 'Only accept type of "string", "number", "boolean"';if(oldValue!==value)callFun(attribute,oldValue,value,zuiThis);});}}}};var ref=function(selector){return function(_target,context){context.addInitializer(function(){var _this=this;queueMicrotask(function(){var zuiThis=_this;zuiThis[context.name.toString()]=zuiThis.shadowRoot.querySelector(selector);});});}};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);});});}};
4
5
 
5
6
  export { defineElement, event, property, ref };
package/dist/index.cjs CHANGED
@@ -5,8 +5,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
  const utilities = require('./utilities.cjs');
6
6
  const decorators = require('./decorators.cjs');
7
7
  const dom = require('./dom.cjs');
8
+ const types = require('./types.cjs');
8
9
 
9
-
10
+ 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){return /*#__PURE__*/function(Base){_inherits(_class,Base);function _class(){_class_call_check(this,_class);return _call_super(this,_class,arguments)}_create_class(_class,[{key:"addEventListener",value:function addEventListener(type,listener,options){_get(_get_prototype_of(_class.prototype),"addEventListener",this).call(this,type,listener,options);}}]);return _class}(Base)}
10
11
 
11
12
  exports.delay = utilities.delay;
12
13
  exports.toKebabCase = utilities.toKebabCase;
@@ -15,3 +16,5 @@ exports.event = decorators.event;
15
16
  exports.property = decorators.property;
16
17
  exports.ref = decorators.ref;
17
18
  exports.createElement = dom.createElement;
19
+ exports.EventEmitter = types.EventEmitter;
20
+ exports.Zui = Zui;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,362 @@
1
+ import { EventEmitter } from './types.ts';
1
2
  export * from './utilities';
2
3
  export * from './decorators';
3
4
  export * from './dom';
5
+ export * from './types.ts';
6
+ type InferEventDetail<T, K extends keyof T> = T[K] extends EventEmitter<infer P> ? P : never;
7
+ export declare function Zui<TBase extends new (...args: any[]) => HTMLElement>(Base: TBase): {
8
+ new (...args: any[]): {
9
+ addEventListener<K extends string>(type: K, listener: (ev: CustomEvent<{
10
+ value: InferEventDetail<this, any>;
11
+ }>) => void, options?: boolean | AddEventListenerOptions): void;
12
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
13
+ accessKey: string;
14
+ readonly accessKeyLabel: string;
15
+ autocapitalize: string;
16
+ autocorrect: boolean;
17
+ dir: string;
18
+ draggable: boolean;
19
+ hidden: boolean;
20
+ inert: boolean;
21
+ innerText: string;
22
+ lang: string;
23
+ readonly offsetHeight: number;
24
+ readonly offsetLeft: number;
25
+ readonly offsetParent: Element | null;
26
+ readonly offsetTop: number;
27
+ readonly offsetWidth: number;
28
+ outerText: string;
29
+ popover: string | null;
30
+ spellcheck: boolean;
31
+ title: string;
32
+ translate: boolean;
33
+ writingSuggestions: string;
34
+ attachInternals(): ElementInternals;
35
+ click(): void;
36
+ hidePopover(): void;
37
+ showPopover(): void;
38
+ togglePopover(options?: boolean): boolean;
39
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
40
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
41
+ readonly attributes: NamedNodeMap;
42
+ get classList(): DOMTokenList;
43
+ set classList(value: string);
44
+ className: string;
45
+ readonly clientHeight: number;
46
+ readonly clientLeft: number;
47
+ readonly clientTop: number;
48
+ readonly clientWidth: number;
49
+ readonly currentCSSZoom: number;
50
+ id: string;
51
+ innerHTML: string;
52
+ readonly localName: string;
53
+ readonly namespaceURI: string | null;
54
+ onfullscreenchange: ((this: Element, ev: Event) => any) | null;
55
+ onfullscreenerror: ((this: Element, ev: Event) => any) | null;
56
+ outerHTML: string;
57
+ readonly ownerDocument: Document;
58
+ get part(): DOMTokenList;
59
+ set part(value: string);
60
+ readonly prefix: string | null;
61
+ readonly scrollHeight: number;
62
+ scrollLeft: number;
63
+ scrollTop: number;
64
+ readonly scrollWidth: number;
65
+ readonly shadowRoot: ShadowRoot | null;
66
+ slot: string;
67
+ readonly tagName: string;
68
+ attachShadow(init: ShadowRootInit): ShadowRoot;
69
+ checkVisibility(options?: CheckVisibilityOptions): boolean;
70
+ closest<K extends keyof HTMLElementTagNameMap>(selector: K): HTMLElementTagNameMap[K] | null;
71
+ closest<K extends keyof SVGElementTagNameMap>(selector: K): SVGElementTagNameMap[K] | null;
72
+ closest<K extends keyof MathMLElementTagNameMap>(selector: K): MathMLElementTagNameMap[K] | null;
73
+ closest<E extends Element = Element>(selectors: string): E | null;
74
+ computedStyleMap(): StylePropertyMapReadOnly;
75
+ getAttribute(qualifiedName: string): string | null;
76
+ getAttributeNS(namespace: string | null, localName: string): string | null;
77
+ getAttributeNames(): string[];
78
+ getAttributeNode(qualifiedName: string): Attr | null;
79
+ getAttributeNodeNS(namespace: string | null, localName: string): Attr | null;
80
+ getBoundingClientRect(): DOMRect;
81
+ getClientRects(): DOMRectList;
82
+ getElementsByClassName(classNames: string): HTMLCollectionOf<Element>;
83
+ getElementsByTagName<K extends keyof HTMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>;
84
+ getElementsByTagName<K extends keyof SVGElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>;
85
+ getElementsByTagName<K extends keyof MathMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<MathMLElementTagNameMap[K]>;
86
+ getElementsByTagName<K extends keyof HTMLElementDeprecatedTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementDeprecatedTagNameMap[K]>;
87
+ getElementsByTagName(qualifiedName: string): HTMLCollectionOf<Element>;
88
+ getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf<HTMLElement>;
89
+ getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>;
90
+ getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1998/Math/MathML", localName: string): HTMLCollectionOf<MathMLElement>;
91
+ getElementsByTagNameNS(namespace: string | null, localName: string): HTMLCollectionOf<Element>;
92
+ getHTML(options?: GetHTMLOptions): string;
93
+ hasAttribute(qualifiedName: string): boolean;
94
+ hasAttributeNS(namespace: string | null, localName: string): boolean;
95
+ hasAttributes(): boolean;
96
+ hasPointerCapture(pointerId: number): boolean;
97
+ insertAdjacentElement(where: InsertPosition, element: Element): Element | null;
98
+ insertAdjacentHTML(position: InsertPosition, string: string): void;
99
+ insertAdjacentText(where: InsertPosition, data: string): void;
100
+ matches(selectors: string): boolean;
101
+ releasePointerCapture(pointerId: number): void;
102
+ removeAttribute(qualifiedName: string): void;
103
+ removeAttributeNS(namespace: string | null, localName: string): void;
104
+ removeAttributeNode(attr: Attr): Attr;
105
+ requestFullscreen(options?: FullscreenOptions): Promise<void>;
106
+ requestPointerLock(options?: PointerLockOptions): Promise<void>;
107
+ scroll(options?: ScrollToOptions): void;
108
+ scroll(x: number, y: number): void;
109
+ scrollBy(options?: ScrollToOptions): void;
110
+ scrollBy(x: number, y: number): void;
111
+ scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void;
112
+ scrollTo(options?: ScrollToOptions): void;
113
+ scrollTo(x: number, y: number): void;
114
+ setAttribute(qualifiedName: string, value: string): void;
115
+ setAttributeNS(namespace: string | null, qualifiedName: string, value: string): void;
116
+ setAttributeNode(attr: Attr): Attr | null;
117
+ setAttributeNodeNS(attr: Attr): Attr | null;
118
+ setHTMLUnsafe(html: string): void;
119
+ setPointerCapture(pointerId: number): void;
120
+ toggleAttribute(qualifiedName: string, force?: boolean): boolean;
121
+ webkitMatchesSelector(selectors: string): boolean;
122
+ get textContent(): string;
123
+ set textContent(value: string | null);
124
+ readonly baseURI: string;
125
+ readonly childNodes: NodeListOf<ChildNode>;
126
+ readonly firstChild: ChildNode | null;
127
+ readonly isConnected: boolean;
128
+ readonly lastChild: ChildNode | null;
129
+ readonly nextSibling: ChildNode | null;
130
+ readonly nodeName: string;
131
+ readonly nodeType: number;
132
+ nodeValue: string | null;
133
+ readonly parentElement: HTMLElement | null;
134
+ readonly parentNode: ParentNode | null;
135
+ readonly previousSibling: ChildNode | null;
136
+ appendChild<T extends Node>(node: T): T;
137
+ cloneNode(subtree?: boolean): Node;
138
+ compareDocumentPosition(other: Node): number;
139
+ contains(other: Node | null): boolean;
140
+ getRootNode(options?: GetRootNodeOptions): Node;
141
+ hasChildNodes(): boolean;
142
+ insertBefore<T extends Node>(node: T, child: Node | null): T;
143
+ isDefaultNamespace(namespace: string | null): boolean;
144
+ isEqualNode(otherNode: Node | null): boolean;
145
+ isSameNode(otherNode: Node | null): boolean;
146
+ lookupNamespaceURI(prefix: string | null): string | null;
147
+ lookupPrefix(namespace: string | null): string | null;
148
+ normalize(): void;
149
+ removeChild<T extends Node>(child: T): T;
150
+ replaceChild<T extends Node>(node: Node, child: T): T;
151
+ readonly ELEMENT_NODE: 1;
152
+ readonly ATTRIBUTE_NODE: 2;
153
+ readonly TEXT_NODE: 3;
154
+ readonly CDATA_SECTION_NODE: 4;
155
+ readonly ENTITY_REFERENCE_NODE: 5;
156
+ readonly ENTITY_NODE: 6;
157
+ readonly PROCESSING_INSTRUCTION_NODE: 7;
158
+ readonly COMMENT_NODE: 8;
159
+ readonly DOCUMENT_NODE: 9;
160
+ readonly DOCUMENT_TYPE_NODE: 10;
161
+ readonly DOCUMENT_FRAGMENT_NODE: 11;
162
+ readonly NOTATION_NODE: 12;
163
+ readonly DOCUMENT_POSITION_DISCONNECTED: 1;
164
+ readonly DOCUMENT_POSITION_PRECEDING: 2;
165
+ readonly DOCUMENT_POSITION_FOLLOWING: 4;
166
+ readonly DOCUMENT_POSITION_CONTAINS: 8;
167
+ readonly DOCUMENT_POSITION_CONTAINED_BY: 16;
168
+ readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32;
169
+ dispatchEvent(event: Event): boolean;
170
+ ariaActiveDescendantElement: Element | null;
171
+ ariaAtomic: string | null;
172
+ ariaAutoComplete: string | null;
173
+ ariaBrailleLabel: string | null;
174
+ ariaBrailleRoleDescription: string | null;
175
+ ariaBusy: string | null;
176
+ ariaChecked: string | null;
177
+ ariaColCount: string | null;
178
+ ariaColIndex: string | null;
179
+ ariaColIndexText: string | null;
180
+ ariaColSpan: string | null;
181
+ ariaControlsElements: ReadonlyArray<Element> | null;
182
+ ariaCurrent: string | null;
183
+ ariaDescribedByElements: ReadonlyArray<Element> | null;
184
+ ariaDescription: string | null;
185
+ ariaDetailsElements: ReadonlyArray<Element> | null;
186
+ ariaDisabled: string | null;
187
+ ariaErrorMessageElements: ReadonlyArray<Element> | null;
188
+ ariaExpanded: string | null;
189
+ ariaFlowToElements: ReadonlyArray<Element> | null;
190
+ ariaHasPopup: string | null;
191
+ ariaHidden: string | null;
192
+ ariaInvalid: string | null;
193
+ ariaKeyShortcuts: string | null;
194
+ ariaLabel: string | null;
195
+ ariaLabelledByElements: ReadonlyArray<Element> | null;
196
+ ariaLevel: string | null;
197
+ ariaLive: string | null;
198
+ ariaModal: string | null;
199
+ ariaMultiLine: string | null;
200
+ ariaMultiSelectable: string | null;
201
+ ariaOrientation: string | null;
202
+ ariaOwnsElements: ReadonlyArray<Element> | null;
203
+ ariaPlaceholder: string | null;
204
+ ariaPosInSet: string | null;
205
+ ariaPressed: string | null;
206
+ ariaReadOnly: string | null;
207
+ ariaRelevant: string | null;
208
+ ariaRequired: string | null;
209
+ ariaRoleDescription: string | null;
210
+ ariaRowCount: string | null;
211
+ ariaRowIndex: string | null;
212
+ ariaRowIndexText: string | null;
213
+ ariaRowSpan: string | null;
214
+ ariaSelected: string | null;
215
+ ariaSetSize: string | null;
216
+ ariaSort: string | null;
217
+ ariaValueMax: string | null;
218
+ ariaValueMin: string | null;
219
+ ariaValueNow: string | null;
220
+ ariaValueText: string | null;
221
+ role: string | null;
222
+ animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions): Animation;
223
+ getAnimations(options?: GetAnimationsOptions): Animation[];
224
+ after(...nodes: (Node | string)[]): void;
225
+ before(...nodes: (Node | string)[]): void;
226
+ remove(): void;
227
+ replaceWith(...nodes: (Node | string)[]): void;
228
+ readonly nextElementSibling: Element | null;
229
+ readonly previousElementSibling: Element | null;
230
+ readonly childElementCount: number;
231
+ readonly children: HTMLCollection;
232
+ readonly firstElementChild: Element | null;
233
+ readonly lastElementChild: Element | null;
234
+ append(...nodes: (Node | string)[]): void;
235
+ prepend(...nodes: (Node | string)[]): void;
236
+ querySelector<K extends keyof HTMLElementTagNameMap>(selectors: K): HTMLElementTagNameMap[K] | null;
237
+ querySelector<K extends keyof SVGElementTagNameMap>(selectors: K): SVGElementTagNameMap[K] | null;
238
+ querySelector<K extends keyof MathMLElementTagNameMap>(selectors: K): MathMLElementTagNameMap[K] | null;
239
+ querySelector<K extends keyof HTMLElementDeprecatedTagNameMap>(selectors: K): HTMLElementDeprecatedTagNameMap[K] | null;
240
+ querySelector<E extends Element = Element>(selectors: string): E | null;
241
+ querySelectorAll<K extends keyof HTMLElementTagNameMap>(selectors: K): NodeListOf<HTMLElementTagNameMap[K]>;
242
+ querySelectorAll<K extends keyof SVGElementTagNameMap>(selectors: K): NodeListOf<SVGElementTagNameMap[K]>;
243
+ querySelectorAll<K extends keyof MathMLElementTagNameMap>(selectors: K): NodeListOf<MathMLElementTagNameMap[K]>;
244
+ querySelectorAll<K extends keyof HTMLElementDeprecatedTagNameMap>(selectors: K): NodeListOf<HTMLElementDeprecatedTagNameMap[K]>;
245
+ querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
246
+ replaceChildren(...nodes: (Node | string)[]): void;
247
+ readonly assignedSlot: HTMLSlotElement | null;
248
+ readonly attributeStyleMap: StylePropertyMap;
249
+ get style(): CSSStyleDeclaration;
250
+ set style(cssText: string);
251
+ contentEditable: string;
252
+ enterKeyHint: string;
253
+ inputMode: string;
254
+ readonly isContentEditable: boolean;
255
+ onabort: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
256
+ onanimationcancel: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
257
+ onanimationend: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
258
+ onanimationiteration: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
259
+ onanimationstart: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
260
+ onauxclick: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
261
+ onbeforeinput: ((this: GlobalEventHandlers, ev: InputEvent) => any) | null;
262
+ onbeforematch: ((this: GlobalEventHandlers, ev: Event) => any) | null;
263
+ onbeforetoggle: ((this: GlobalEventHandlers, ev: ToggleEvent) => any) | null;
264
+ onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
265
+ oncancel: ((this: GlobalEventHandlers, ev: Event) => any) | null;
266
+ oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
267
+ oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null;
268
+ onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
269
+ onclick: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
270
+ onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null;
271
+ oncontextlost: ((this: GlobalEventHandlers, ev: Event) => any) | null;
272
+ oncontextmenu: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
273
+ oncontextrestored: ((this: GlobalEventHandlers, ev: Event) => any) | null;
274
+ oncopy: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
275
+ oncuechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
276
+ oncut: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
277
+ ondblclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
278
+ ondrag: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
279
+ ondragend: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
280
+ ondragenter: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
281
+ ondragleave: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
282
+ ondragover: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
283
+ ondragstart: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
284
+ ondrop: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
285
+ ondurationchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
286
+ onemptied: ((this: GlobalEventHandlers, ev: Event) => any) | null;
287
+ onended: ((this: GlobalEventHandlers, ev: Event) => any) | null;
288
+ onerror: OnErrorEventHandler;
289
+ onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
290
+ onformdata: ((this: GlobalEventHandlers, ev: FormDataEvent) => any) | null;
291
+ ongotpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
292
+ oninput: ((this: GlobalEventHandlers, ev: Event) => any) | null;
293
+ oninvalid: ((this: GlobalEventHandlers, ev: Event) => any) | null;
294
+ onkeydown: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
295
+ onkeypress: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
296
+ onkeyup: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
297
+ onload: ((this: GlobalEventHandlers, ev: Event) => any) | null;
298
+ onloadeddata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
299
+ onloadedmetadata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
300
+ onloadstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
301
+ onlostpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
302
+ onmousedown: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
303
+ onmouseenter: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
304
+ onmouseleave: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
305
+ onmousemove: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
306
+ onmouseout: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
307
+ onmouseover: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
308
+ onmouseup: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
309
+ onpaste: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
310
+ onpause: ((this: GlobalEventHandlers, ev: Event) => any) | null;
311
+ onplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
312
+ onplaying: ((this: GlobalEventHandlers, ev: Event) => any) | null;
313
+ onpointercancel: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
314
+ onpointerdown: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
315
+ onpointerenter: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
316
+ onpointerleave: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
317
+ onpointermove: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
318
+ onpointerout: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
319
+ onpointerover: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
320
+ onpointerrawupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
321
+ onpointerup: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
322
+ onprogress: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null;
323
+ onratechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
324
+ onreset: ((this: GlobalEventHandlers, ev: Event) => any) | null;
325
+ onresize: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
326
+ onscroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
327
+ onscrollend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
328
+ onsecuritypolicyviolation: ((this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any) | null;
329
+ onseeked: ((this: GlobalEventHandlers, ev: Event) => any) | null;
330
+ onseeking: ((this: GlobalEventHandlers, ev: Event) => any) | null;
331
+ onselect: ((this: GlobalEventHandlers, ev: Event) => any) | null;
332
+ onselectionchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
333
+ onselectstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
334
+ onslotchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
335
+ onstalled: ((this: GlobalEventHandlers, ev: Event) => any) | null;
336
+ onsubmit: ((this: GlobalEventHandlers, ev: SubmitEvent) => any) | null;
337
+ onsuspend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
338
+ ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
339
+ ontoggle: ((this: GlobalEventHandlers, ev: ToggleEvent) => any) | null;
340
+ ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
341
+ ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
342
+ ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
343
+ ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
344
+ ontransitioncancel: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
345
+ ontransitionend: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
346
+ ontransitionrun: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
347
+ ontransitionstart: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
348
+ onvolumechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
349
+ onwaiting: ((this: GlobalEventHandlers, ev: Event) => any) | null;
350
+ onwebkitanimationend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
351
+ onwebkitanimationiteration: ((this: GlobalEventHandlers, ev: Event) => any) | null;
352
+ onwebkitanimationstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
353
+ onwebkittransitionend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
354
+ onwheel: ((this: GlobalEventHandlers, ev: WheelEvent) => any) | null;
355
+ autofocus: boolean;
356
+ readonly dataset: DOMStringMap;
357
+ nonce?: string;
358
+ tabIndex: number;
359
+ blur(): void;
360
+ focus(options?: FocusOptions): void;
361
+ };
362
+ } & TBase;
package/dist/index.js CHANGED
@@ -1,3 +1,8 @@
1
1
  export { delay, toKebabCase } from './utilities.js';
2
2
  export { defineElement, event, property, ref } from './decorators.js';
3
3
  export { createElement } from './dom.js';
4
+ export { EventEmitter } from './types.js';
5
+
6
+ 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){return /*#__PURE__*/function(Base){_inherits(_class,Base);function _class(){_class_call_check(this,_class);return _call_super(this,_class,arguments)}_create_class(_class,[{key:"addEventListener",value:function addEventListener(type,listener,options){_get(_get_prototype_of(_class.prototype),"addEventListener",this).call(this,type,listener,options);}}]);return _class}(Base)}
7
+
8
+ export { Zui };
package/dist/types.cjs ADDED
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ 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 _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}));}ownKeys.forEach(function(key){_define_property(target,key,source[key]);});}return target}var EventEmitter=/*#__PURE__*/function(){function EventEmitter(target,eventName){_class_call_check(this,EventEmitter);_define_property(this,"target",void 0);_define_property(this,"eventName",void 0);this.target=target;this.eventName=eventName;}_create_class(EventEmitter,[{key:"emit",value:function emit(value,options){this.target.dispatchEvent(new CustomEvent(this.eventName,_object_spread({detail:{value:value},bubbles:true,composed:true},options)));}}]);return EventEmitter}();
6
+
7
+ exports.EventEmitter = EventEmitter;
@@ -0,0 +1,12 @@
1
+ export interface ZuiComponent extends HTMLElement {
2
+ connected?(): void;
3
+ disconnected?(): void;
4
+ attributeChanged(attributeName: string, oldValue: string, newValue: string): void;
5
+ [key: string]: any;
6
+ }
7
+ export declare class EventEmitter<T> {
8
+ private target;
9
+ private eventName;
10
+ constructor(target: HTMLElement, eventName: string);
11
+ emit(value: T, options?: Omit<CustomEventInit, 'detail'>): void;
12
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ 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 _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}));}ownKeys.forEach(function(key){_define_property(target,key,source[key]);});}return target}var EventEmitter=/*#__PURE__*/function(){function EventEmitter(target,eventName){_class_call_check(this,EventEmitter);_define_property(this,"target",void 0);_define_property(this,"eventName",void 0);this.target=target;this.eventName=eventName;}_create_class(EventEmitter,[{key:"emit",value:function emit(value,options){this.target.dispatchEvent(new CustomEvent(this.eventName,_object_spread({detail:{value:value},bubbles:true,composed:true},options)));}}]);return EventEmitter}();
2
+
3
+ export { EventEmitter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o.z/zui",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Next-generation Web Component framework leveraging TypeScript Stage 3 standard decorators.",
5
5
  "homepage": "https://github.com/z-npm/zui#readme",
6
6
  "docs": "https://github.com/z-npm/zui#readme",
@@ -74,6 +74,11 @@
74
74
  "import": "./dist/utilities.js",
75
75
  "require": "./dist/utilities.cjs"
76
76
  },
77
+ "./types": {
78
+ "types": "./dist/types.d.ts",
79
+ "import": "./dist/types.js",
80
+ "require": "./dist/types.cjs"
81
+ },
77
82
  ".": {
78
83
  "types": "./dist/index.d.ts",
79
84
  "import": "./dist/index.js",