@o.z/zui 0.4.0 → 0.4.2

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.
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ var OBSERVED_ATTRS_KEY=Symbol("observedAttributes");var REFS_KEY=Symbol("refs");
4
+
5
+ exports.OBSERVED_ATTRS_KEY = OBSERVED_ATTRS_KEY;
6
+ exports.REFS_KEY = REFS_KEY;
@@ -0,0 +1,3 @@
1
+ var OBSERVED_ATTRS_KEY=Symbol("observedAttributes");var REFS_KEY=Symbol("refs");
2
+
3
+ export { OBSERVED_ATTRS_KEY as O, REFS_KEY as R };
@@ -0,0 +1,3 @@
1
+ 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===null||value===undefined?0:Number(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"'}};
2
+
3
+ export { callFun as c, getConvertor as g };
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ 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===null||value===undefined?0:Number(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"'}};
4
+
5
+ exports.callFun = callFun;
6
+ exports.getConvertor = getConvertor;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
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');
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}};
11
+
12
+ exports.defineElement = defineElement;
@@ -0,0 +1,12 @@
1
+ import { SafeHTML } from '../html';
2
+ export interface DefineElementOptions {
3
+ tagName: string;
4
+ html: string | SafeHTML;
5
+ css?: string;
6
+ options?: ElementDefinitionOptions;
7
+ }
8
+ export declare const defineElement: ({ tagName, html, css, options }: DefineElementOptions) => <T extends CustomElementConstructor>(originalClass: T, context: ClassDecoratorContext<T>) => T & {
9
+ prototype: {
10
+ zcolor: string;
11
+ };
12
+ };
@@ -0,0 +1,8 @@
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';
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}};
7
+
8
+ export { defineElement };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const utilities = require('../utilities.cjs');
6
+ const decorators_types = require('./types.cjs');
7
+
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
+
10
+ exports.event = event;
@@ -0,0 +1,5 @@
1
+ import { EventEmitter } from './types';
2
+ export interface EventOptions {
3
+ name?: string;
4
+ }
5
+ export declare const event: (options?: EventOptions) => <T extends HTMLElement, V>(_target: undefined, context: ClassFieldDecoratorContext<T, EventEmitter<V>>) => void;
@@ -0,0 +1,6 @@
1
+ import { toKebabCase } from '../utilities.js';
2
+ import { EventEmitter } from './types.js';
3
+
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
+
6
+ export { event };
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const decorators_defineElement = require('./defineElement.cjs');
6
+ const decorators_event = require('./event.cjs');
7
+ const decorators_property = require('./property.cjs');
8
+ const decorators_refs = require('./refs.cjs');
9
+ const decorators_state = require('./state.cjs');
10
+ const decorators_types = require('./types.cjs');
11
+
12
+
13
+
14
+ exports.defineElement = decorators_defineElement.defineElement;
15
+ exports.event = decorators_event.event;
16
+ exports.property = decorators_property.property;
17
+ exports.ref = decorators_refs.ref;
18
+ exports.state = decorators_state.state;
19
+ exports.EventEmitter = decorators_types.EventEmitter;
@@ -0,0 +1,6 @@
1
+ export * from './defineElement.ts';
2
+ export * from './event.ts';
3
+ export * from './property.ts';
4
+ export * from './refs.ts';
5
+ export * from './state.ts';
6
+ export * from './types.ts';
@@ -0,0 +1,6 @@
1
+ export { defineElement } from './defineElement.js';
2
+ export { event } from './event.js';
3
+ export { property } from './property.js';
4
+ export { ref } from './refs.js';
5
+ export { state } from './state.js';
6
+ export { EventEmitter } from './types.js';
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const utilities = require('../utilities.cjs');
6
+ const _helper = require('../_helper-YcE1MU2f.cjs');
7
+ const _constants = require('../_constants-D8uytuQc.cjs');
8
+
9
+ function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}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=_constants.OBSERVED_ATTRS_KEY])!==null&&_!==void 0?_:_context_metadata[_OBSERVED_ATTRS_KEY]=[];var attributes=context.metadata[_constants.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(){_helper.callFun(attribute,initialValue,initialValue,zuiThis);});return initialValue},get:function get(){var zuiThis=this;return _helper.getConvertor(attribute,zuiThis)},set:function set(value){var _this=this;queueMicrotask(function(){var zuiThis=_this;var oldValue=_helper.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)_helper.callFun(attribute,oldValue,value,zuiThis);});}}}};
10
+
11
+ exports.property = property;
@@ -0,0 +1,15 @@
1
+ export type PropertyType = "string" | "number" | "boolean";
2
+ export type PropertyCallback = "Update" | "Changed";
3
+ export interface PropertyOptions {
4
+ type?: PropertyType;
5
+ name?: string;
6
+ callbackName?: `${string}${PropertyCallback}`;
7
+ }
8
+ export declare const property: ({ type, name, callbackName }?: PropertyOptions) => <T extends HTMLElement, V extends number | string | boolean>(_accessor: {
9
+ get: (this: T) => V;
10
+ set: (this: T, value: V) => void;
11
+ }, context: ClassAccessorDecoratorContext<T, V>) => {
12
+ init(this: T, initialValue: V): V;
13
+ get: (this: T) => V;
14
+ set: (this: T, value: V) => void;
15
+ };
@@ -0,0 +1,7 @@
1
+ import { toKebabCase } from '../utilities.js';
2
+ import { g as getConvertor, c as callFun } from '../_helper-B0T4FTYh.js';
3
+ import { O as OBSERVED_ATTRS_KEY } from '../_constants-DLywjTCf.js';
4
+
5
+ function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}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);});}}}};
6
+
7
+ export { property };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const _constants = require('../_constants-D8uytuQc.cjs');
6
+
7
+ var ref=function(selector){return function(_target,context){var _context_metadata,_REFS_KEY,_;(_=(_context_metadata=context.metadata)[_REFS_KEY=_constants.REFS_KEY])!==null&&_!==void 0?_:_context_metadata[_REFS_KEY]=[];var refs=context.metadata[_constants.REFS_KEY];refs.push(selector);context.addInitializer(function(){var _this=this;queueMicrotask(function(){var zuiThis=_this;zuiThis[context.name.toString()]=zuiThis.shadowRoot.querySelector(selector);});});}};
8
+
9
+ exports.ref = ref;
@@ -0,0 +1 @@
1
+ export declare const ref: (selector: string) => <T extends HTMLElement, V extends HTMLElement>(_target: undefined, context: ClassFieldDecoratorContext<T, V>) => void;
@@ -0,0 +1,5 @@
1
+ import { R as REFS_KEY } from '../_constants-DLywjTCf.js';
2
+
3
+ var ref=function(selector){return function(_target,context){var _context_metadata,_REFS_KEY,_;(_=(_context_metadata=context.metadata)[_REFS_KEY=REFS_KEY])!==null&&_!==void 0?_:_context_metadata[_REFS_KEY]=[];var refs=context.metadata[REFS_KEY];refs.push(selector);context.addInitializer(function(){var _this=this;queueMicrotask(function(){var zuiThis=_this;zuiThis[context.name.toString()]=zuiThis.shadowRoot.querySelector(selector);});});}};
4
+
5
+ export { ref };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const utilities = require('../utilities.cjs');
6
+
7
+ function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}var state=function(){var callbackName=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).callbackName;return function(accessor,context){var propName=context.name.toString();var updateMethodName=callbackName!==null&&callbackName!==void 0?callbackName:"".concat(propName,"Update");return {init:function init(initialValue){var zuiThis=this;var triggerUpdate=function(){queueMicrotask(function(){if(typeof zuiThis[updateMethodName]==="function"){zuiThis[updateMethodName](initialValue,initialValue);}});};var finalValue=initialValue;if(initialValue&&(typeof initialValue==="undefined"?"undefined":_type_of(initialValue))==="object"){finalValue=utilities.makeReactive(initialValue,triggerUpdate);}triggerUpdate();return finalValue},get:function get(){return accessor.get.call(this)},set:function set(newValue){var zuiThis=this;var triggerUpdate=function(){queueMicrotask(function(){if(typeof zuiThis[updateMethodName]==="function"){zuiThis[updateMethodName](newValue,newValue);}});};var finalValue=newValue;if(newValue&&(typeof newValue==="undefined"?"undefined":_type_of(newValue))==="object"){finalValue=utilities.makeReactive(newValue,triggerUpdate);}accessor.set.call(this,finalValue);triggerUpdate();}}}};
8
+
9
+ exports.state = state;
@@ -0,0 +1,16 @@
1
+ export interface StateOptions {
2
+ callbackName?: string;
3
+ }
4
+ /**
5
+ * Decorator for internal reactive state.
6
+ * Triggers component updates but does NOT reflect to DOM attributes.
7
+ * Useful for Objects, Arrays, or private data.
8
+ */
9
+ export declare const state: ({ callbackName }?: StateOptions) => <T extends HTMLElement, V>(accessor: {
10
+ get: (this: T) => V;
11
+ set: (this: T, value: V) => void;
12
+ }, context: ClassAccessorDecoratorContext<T, V>) => {
13
+ init(this: T, initialValue: V): V;
14
+ get(this: T): V;
15
+ set(this: T, newValue: V): void;
16
+ };
@@ -0,0 +1,5 @@
1
+ import { makeReactive } from '../utilities.js';
2
+
3
+ function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}var state=function(){var callbackName=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).callbackName;return function(accessor,context){var propName=context.name.toString();var updateMethodName=callbackName!==null&&callbackName!==void 0?callbackName:"".concat(propName,"Update");return {init:function init(initialValue){var zuiThis=this;var triggerUpdate=function(){queueMicrotask(function(){if(typeof zuiThis[updateMethodName]==="function"){zuiThis[updateMethodName](initialValue,initialValue);}});};var finalValue=initialValue;if(initialValue&&(typeof initialValue==="undefined"?"undefined":_type_of(initialValue))==="object"){finalValue=makeReactive(initialValue,triggerUpdate);}triggerUpdate();return finalValue},get:function get(){return accessor.get.call(this)},set:function set(newValue){var zuiThis=this;var triggerUpdate=function(){queueMicrotask(function(){if(typeof zuiThis[updateMethodName]==="function"){zuiThis[updateMethodName](newValue,newValue);}});};var finalValue=newValue;if(newValue&&(typeof newValue==="undefined"?"undefined":_type_of(newValue))==="object"){finalValue=makeReactive(newValue,triggerUpdate);}accessor.set.call(this,finalValue);triggerUpdate();}}}};
4
+
5
+ export { state };
@@ -1,12 +1,16 @@
1
1
  export interface ZuiComponent extends HTMLElement {
2
2
  connected?(): void;
3
3
  disconnected?(): void;
4
- attributeChanged(attributeName: string, oldValue: string, newValue: string): void;
4
+ attributeChanged?(attributeName: string, oldValue: string, newValue: string): void;
5
5
  [key: string]: any;
6
6
  }
7
+ export interface CustomEventDetail<T> {
8
+ value: T;
9
+ }
7
10
  export declare class EventEmitter<T> {
8
11
  private target;
9
12
  private eventName;
10
13
  constructor(target: HTMLElement, eventName: string);
11
14
  emit(value: T, options?: Omit<CustomEventInit, 'detail'>): void;
12
15
  }
16
+ export type EventDetail<T> = T extends EventEmitter<infer U> ? U : never;
package/dist/index.cjs CHANGED
@@ -3,24 +3,28 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const utilities = require('./utilities.cjs');
6
- const decorators = require('./decorators.cjs');
6
+ const decorators_defineElement = require('./decorators/defineElement.cjs');
7
+ const decorators_event = require('./decorators/event.cjs');
8
+ const decorators_property = require('./decorators/property.cjs');
9
+ const decorators_refs = require('./decorators/refs.cjs');
10
+ const decorators_state = require('./decorators/state.cjs');
11
+ const decorators_types = require('./decorators/types.cjs');
7
12
  const dom = require('./dom.cjs');
8
- const types = require('./types.cjs');
9
13
  const html = require('./html.cjs');
10
14
 
11
- 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)}
15
+ 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(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)}
12
16
 
13
17
  exports.delay = utilities.delay;
14
18
  exports.isBrowser = utilities.isBrowser;
15
19
  exports.makeReactive = utilities.makeReactive;
16
20
  exports.toKebabCase = utilities.toKebabCase;
17
- exports.defineElement = decorators.defineElement;
18
- exports.event = decorators.event;
19
- exports.property = decorators.property;
20
- exports.ref = decorators.ref;
21
- exports.state = decorators.state;
21
+ exports.defineElement = decorators_defineElement.defineElement;
22
+ exports.event = decorators_event.event;
23
+ exports.property = decorators_property.property;
24
+ exports.ref = decorators_refs.ref;
25
+ exports.state = decorators_state.state;
26
+ exports.EventEmitter = decorators_types.EventEmitter;
22
27
  exports.createElement = dom.createElement;
23
- exports.EventEmitter = types.EventEmitter;
24
28
  exports.SafeHTML = html.SafeHTML;
25
29
  exports.html = html.html;
26
30
  exports.unsafeHTML = html.unsafeHTML;
package/dist/index.d.ts CHANGED
@@ -1,16 +1,18 @@
1
- import { EventEmitter } from './types.ts';
1
+ import { EventEmitter, CustomEventDetail } from './decorators';
2
2
  export * from './utilities';
3
3
  export * from './decorators';
4
4
  export * from './dom';
5
- export * from './types.ts';
6
- export * from './html.ts';
7
- type InferEventDetail<T, K extends keyof T> = T[K] extends EventEmitter<infer P> ? P : never;
5
+ export * from './html';
6
+ type KebabCase<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${KebabCase<U>}` : `${Uncapitalize<T>}-${KebabCase<U>}` : S;
7
+ export type InferEventDetail<T> = T extends EventEmitter<infer U> ? CustomEventDetail<U> : never;
8
+ type ZuiEventMap<T> = {
9
+ [K in keyof T as T[K] extends EventEmitter<any> ? KebabCase<string & K> : never]: InferEventDetail<T[K]>;
10
+ };
8
11
  export declare function Zui<TBase extends new (...args: any[]) => HTMLElement>(Base: TBase): {
9
12
  new (...args: any[]): {
10
- addEventListener<K extends string>(type: K, listener: (ev: CustomEvent<{
11
- value: InferEventDetail<this, any>;
12
- }>) => void, options?: boolean | AddEventListenerOptions): void;
13
+ addEventListener<K extends never>(type: K, listener: (ev: CustomEvent<ZuiEventMap</*elided*/ any>[K]>) => void, options?: boolean | AddEventListenerOptions): void;
13
14
  addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
15
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
14
16
  accessKey: string;
15
17
  readonly accessKeyLabel: string;
16
18
  autocapitalize: string;
package/dist/index.js CHANGED
@@ -1,9 +1,13 @@
1
1
  export { delay, isBrowser, makeReactive, toKebabCase } from './utilities.js';
2
- export { defineElement, event, property, ref, state } from './decorators.js';
2
+ export { defineElement } from './decorators/defineElement.js';
3
+ export { event } from './decorators/event.js';
4
+ export { property } from './decorators/property.js';
5
+ export { ref } from './decorators/refs.js';
6
+ export { state } from './decorators/state.js';
7
+ export { EventEmitter } from './decorators/types.js';
3
8
  export { createElement } from './dom.js';
4
- export { EventEmitter } from './types.js';
5
9
  export { SafeHTML, html, unsafeHTML } from './html.js';
6
10
 
7
- 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)}
11
+ 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(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)}
8
12
 
9
13
  export { Zui };
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- var delay=function(ms){return new Promise(function(resolve){return setTimeout(resolve,ms)})};var toKebabCase=function(str){return str.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()};var isBrowser=typeof window!=="undefined";var makeReactive=function(target,onChange){var handler={set:function set(target,prop,value,receiver){var result=Reflect.set(target,prop,value,receiver);onChange();return result},deleteProperty:function deleteProperty(target,prop){var result=Reflect.deleteProperty(target,prop);onChange();return result}};return new Proxy(target,handler)};
5
+ function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}var delay=function(ms){return new Promise(function(resolve){return setTimeout(resolve,ms)})};var toKebabCase=function(str){return str.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()};var isBrowser=typeof window!=="undefined";var makeReactive=function(target,onChange){var proxyCache=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new WeakMap;if(proxyCache.has(target))return proxyCache.get(target);var handler={get:function get(target,prop,receiver){var value=Reflect.get(target,prop,receiver);if((typeof value==="undefined"?"undefined":_type_of(value))==="object"&&value!==null){return makeReactive(value,onChange,proxyCache)}return value},set:function set(target,prop,value,receiver){var oldValue=Reflect.get(target,prop,receiver);if(oldValue===value)return true;var result=Reflect.set(target,prop,value,receiver);onChange();return result},deleteProperty:function deleteProperty(target,prop){var result=Reflect.deleteProperty(target,prop);onChange();return result}};var proxy=new Proxy(target,handler);proxyCache.set(target,proxy);return proxy};
6
6
 
7
7
  exports.delay = delay;
8
8
  exports.isBrowser = isBrowser;
@@ -1,4 +1,4 @@
1
1
  export declare const delay: (ms: number) => Promise<unknown>;
2
2
  export declare const toKebabCase: (str: string) => string;
3
3
  export declare const isBrowser: boolean;
4
- export declare const makeReactive: <T extends object>(target: T, onChange: () => void) => T;
4
+ export declare const makeReactive: <T extends object>(target: T, onChange: () => void, proxyCache?: WeakMap<object, any>) => T;
package/dist/utilities.js CHANGED
@@ -1,3 +1,3 @@
1
- var delay=function(ms){return new Promise(function(resolve){return setTimeout(resolve,ms)})};var toKebabCase=function(str){return str.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()};var isBrowser=typeof window!=="undefined";var makeReactive=function(target,onChange){var handler={set:function set(target,prop,value,receiver){var result=Reflect.set(target,prop,value,receiver);onChange();return result},deleteProperty:function deleteProperty(target,prop){var result=Reflect.deleteProperty(target,prop);onChange();return result}};return new Proxy(target,handler)};
1
+ function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}var delay=function(ms){return new Promise(function(resolve){return setTimeout(resolve,ms)})};var toKebabCase=function(str){return str.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()};var isBrowser=typeof window!=="undefined";var makeReactive=function(target,onChange){var proxyCache=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new WeakMap;if(proxyCache.has(target))return proxyCache.get(target);var handler={get:function get(target,prop,receiver){var value=Reflect.get(target,prop,receiver);if((typeof value==="undefined"?"undefined":_type_of(value))==="object"&&value!==null){return makeReactive(value,onChange,proxyCache)}return value},set:function set(target,prop,value,receiver){var oldValue=Reflect.get(target,prop,receiver);if(oldValue===value)return true;var result=Reflect.set(target,prop,value,receiver);onChange();return result},deleteProperty:function deleteProperty(target,prop){var result=Reflect.deleteProperty(target,prop);onChange();return result}};var proxy=new Proxy(target,handler);proxyCache.set(target,proxy);return proxy};
2
2
 
3
3
  export { delay, isBrowser, makeReactive, toKebabCase };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o.z/zui",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
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",
@@ -56,29 +56,21 @@
56
56
  "build": "tsc && vite build",
57
57
  "test": "vitest",
58
58
  "test:ui": "vitest --ui",
59
- "test:coverage": "vitest run --coverage",
60
- "lint": "eslint .",
61
- "lint:fix": "eslint . --fix"
59
+ "test:coverage": "vitest run --coverage"
62
60
  },
63
61
  "devDependencies": {
64
- "@eslint/js": "^9.39.2",
65
62
  "@testing-library/dom": "^10.4.1",
66
63
  "@testing-library/user-event": "^14.6.1",
67
64
  "@types/jsdom": "^27.0.0",
68
- "@types/node": "^25.0.10",
65
+ "@types/node": "^25.1.0",
69
66
  "@vitest/coverage-v8": "^4.0.18",
67
+ "@vitest/ui": "^4.0.18",
70
68
  "@z-code/vite-plugin-swc": "^0.5.5",
71
- "eslint": "^9.39.2",
72
- "eslint-config-prettier": "^10.1.8",
73
- "eslint-plugin-prettier": "^5.5.5",
74
69
  "glob": "^13.0.0",
75
70
  "globals": "^17.2.0",
76
- "husky": "^9.1.7",
77
71
  "jsdom": "^27.4.0",
78
- "lint-staged": "^16.2.7",
79
72
  "sass": "^1.97.3",
80
73
  "typescript": "^5.9.3",
81
- "typescript-eslint": "^8.54.0",
82
74
  "vite": "^7.3.1",
83
75
  "vite-plugin-dts": "^4.5.4",
84
76
  "vite-plugin-lib-inject-css": "^2.2.2",
@@ -93,11 +85,6 @@
93
85
  "import": "./dist/utilities.js",
94
86
  "require": "./dist/utilities.cjs"
95
87
  },
96
- "./types": {
97
- "types": "./dist/types.d.ts",
98
- "import": "./dist/types.js",
99
- "require": "./dist/types.cjs"
100
- },
101
88
  ".": {
102
89
  "types": "./dist/index.d.ts",
103
90
  "import": "./dist/index.js",
@@ -113,10 +100,40 @@
113
100
  "import": "./dist/dom.js",
114
101
  "require": "./dist/dom.cjs"
115
102
  },
103
+ "./decorators/types": {
104
+ "types": "./dist/decorators/types.d.ts",
105
+ "import": "./dist/decorators/types.js",
106
+ "require": "./dist/decorators/types.cjs"
107
+ },
108
+ "./decorators/state": {
109
+ "types": "./dist/decorators/state.d.ts",
110
+ "import": "./dist/decorators/state.js",
111
+ "require": "./dist/decorators/state.cjs"
112
+ },
113
+ "./decorators/refs": {
114
+ "types": "./dist/decorators/refs.d.ts",
115
+ "import": "./dist/decorators/refs.js",
116
+ "require": "./dist/decorators/refs.cjs"
117
+ },
118
+ "./decorators/property": {
119
+ "types": "./dist/decorators/property.d.ts",
120
+ "import": "./dist/decorators/property.js",
121
+ "require": "./dist/decorators/property.cjs"
122
+ },
116
123
  "./decorators": {
117
- "types": "./dist/decorators.d.ts",
118
- "import": "./dist/decorators.js",
119
- "require": "./dist/decorators.cjs"
124
+ "types": "./dist/decorators/index.d.ts",
125
+ "import": "./dist/decorators/index.js",
126
+ "require": "./dist/decorators/index.cjs"
127
+ },
128
+ "./decorators/event": {
129
+ "types": "./dist/decorators/event.d.ts",
130
+ "import": "./dist/decorators/event.js",
131
+ "require": "./dist/decorators/event.cjs"
132
+ },
133
+ "./decorators/defineElement": {
134
+ "types": "./dist/decorators/defineElement.d.ts",
135
+ "import": "./dist/decorators/defineElement.js",
136
+ "require": "./dist/decorators/defineElement.cjs"
120
137
  }
121
138
  },
122
139
  "dependencies": {
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const html = require('./html.cjs');
6
- const types = require('./types.cjs');
7
- const utilities = require('./utilities.cjs');
8
-
9
- 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 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$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[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("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(utilities.isBrowser&&!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 state=function(){var callbackName=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).callbackName;return function(accessor,context){var propName=context.name.toString();var updateMethodName=callbackName!==null&&callbackName!==void 0?callbackName:"".concat(propName,"Update");return {init:function init(initialValue){var zuiThis=this;var triggerUpdate=function(){queueMicrotask(function(){if(typeof zuiThis[updateMethodName]==="function"){zuiThis[updateMethodName](initialValue,initialValue);}});};var finalValue=initialValue;if(initialValue&&(typeof initialValue==="undefined"?"undefined":_type_of(initialValue))==="object"){finalValue=utilities.makeReactive(initialValue,triggerUpdate);}triggerUpdate();return finalValue},get:function get(){return accessor.get.call(this)},set:function set(newValue){var zuiThis=this;var triggerUpdate=function(){queueMicrotask(function(){if(typeof zuiThis[updateMethodName]==="function"){zuiThis[updateMethodName](newValue,newValue);}});};var finalValue=newValue;if(newValue&&(typeof newValue==="undefined"?"undefined":_type_of(newValue))==="object"){finalValue=utilities.makeReactive(newValue,triggerUpdate);}accessor.set.call(this,finalValue);triggerUpdate();}}}};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);});});}};
10
-
11
- exports.defineElement = defineElement;
12
- exports.event = event;
13
- exports.property = property;
14
- exports.ref = ref;
15
- exports.state = state;
@@ -1,48 +0,0 @@
1
- import { SafeHTML } from './html';
2
- import { EventEmitter } from './types';
3
- export interface DefineElementProp {
4
- tagName: string;
5
- html: string | SafeHTML;
6
- css?: string;
7
- options?: ElementDefinitionOptions;
8
- }
9
- export declare const defineElement: ({ tagName, html, css, options }: DefineElementProp) => <T extends CustomElementConstructor>(originalClass: T, context: ClassDecoratorContext<T>) => T & {
10
- prototype: {
11
- zcolor: string;
12
- };
13
- };
14
- export interface PropertyProp {
15
- type?: "string" | "number" | "boolean";
16
- name?: string;
17
- callbackName?: string;
18
- }
19
- export declare const property: ({ type, name, callbackName }?: PropertyProp) => <T extends HTMLElement, V extends number | string | boolean>(_accessor: {
20
- get: (this: T) => V;
21
- set: (this: T, value: V) => void;
22
- }, context: ClassAccessorDecoratorContext<T, V>) => {
23
- init(this: T, initialValue: V): V;
24
- get: (this: T) => V;
25
- set: (this: T, value: V) => void;
26
- };
27
- export interface StateOptions {
28
- callbackName?: string;
29
- }
30
- /**
31
- * Decorator for internal reactive state.
32
- * Triggers component updates but does NOT reflect to DOM attributes.
33
- * Useful for Objects, Arrays, or private data.
34
- */
35
- export declare const state: ({ callbackName }?: StateOptions) => <T extends HTMLElement, V>(accessor: {
36
- get: (this: T) => V;
37
- set: (this: T, value: V) => void;
38
- }, context: ClassAccessorDecoratorContext<T, V>) => {
39
- init(this: T, initialValue: V): V;
40
- get(this: T): V;
41
- set(this: T, newValue: V): void;
42
- };
43
- export declare const ref: (selector: string) => <T extends HTMLElement, V extends HTMLElement>(_target: undefined, context: ClassFieldDecoratorContext<T, V>) => void;
44
- interface EventProp {
45
- name?: string;
46
- }
47
- export declare const event: (options?: EventProp) => <T extends HTMLElement, V>(_target: undefined, context: ClassFieldDecoratorContext<T, EventEmitter<V>>) => void;
48
- export {};
@@ -1,7 +0,0 @@
1
- import { SafeHTML } from './html.js';
2
- import { EventEmitter } from './types.js';
3
- import { isBrowser, toKebabCase, makeReactive } from './utilities.js';
4
-
5
- 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 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];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("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}};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 state=function(){var callbackName=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).callbackName;return function(accessor,context){var propName=context.name.toString();var updateMethodName=callbackName!==null&&callbackName!==void 0?callbackName:"".concat(propName,"Update");return {init:function init(initialValue){var zuiThis=this;var triggerUpdate=function(){queueMicrotask(function(){if(typeof zuiThis[updateMethodName]==="function"){zuiThis[updateMethodName](initialValue,initialValue);}});};var finalValue=initialValue;if(initialValue&&(typeof initialValue==="undefined"?"undefined":_type_of(initialValue))==="object"){finalValue=makeReactive(initialValue,triggerUpdate);}triggerUpdate();return finalValue},get:function get(){return accessor.get.call(this)},set:function set(newValue){var zuiThis=this;var triggerUpdate=function(){queueMicrotask(function(){if(typeof zuiThis[updateMethodName]==="function"){zuiThis[updateMethodName](newValue,newValue);}});};var finalValue=newValue;if(newValue&&(typeof newValue==="undefined"?"undefined":_type_of(newValue))==="object"){finalValue=makeReactive(newValue,triggerUpdate);}accessor.set.call(this,finalValue);triggerUpdate();}}}};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);});});}};
6
-
7
- export { defineElement, event, property, ref, state };
File without changes
File without changes