@zeus-js/zeus 0.1.0-beta.2 → 0.1.0-beta.4
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/dist/advanced.cjs.js +1 -1
- package/dist/advanced.cjs.prod.js +1 -1
- package/dist/advanced.js +1 -1
- package/dist/advanced.prod.js +1 -1
- package/dist/capabilities.cjs.js +2 -2
- package/dist/capabilities.cjs.prod.js +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/capabilities.prod.js +1 -1
- package/dist/zeus.cjs.js +3 -1
- package/dist/zeus.cjs.prod.js +3 -1
- package/dist/zeus.d.mts +1 -1
- package/dist/zeus.d.ts +1 -1
- package/dist/zeus.esm-browser.js +189 -112
- package/dist/zeus.esm-browser.prod.js +1 -1
- package/dist/zeus.esm-bundler.js +3 -3
- package/dist/zeus.global.js +190 -111
- package/dist/zeus.global.prod.js +1 -1
- package/jsx-runtime.js +13 -1
- package/package.json +13 -13
package/dist/advanced.cjs.js
CHANGED
package/dist/advanced.js
CHANGED
package/dist/advanced.prod.js
CHANGED
package/dist/capabilities.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* zeus v0.1.0-beta.
|
|
2
|
+
* zeus v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -9,7 +9,7 @@ Object.defineProperties(exports, {
|
|
|
9
9
|
});
|
|
10
10
|
const ZEUS_CAPABILITIES = {
|
|
11
11
|
packageName: "@zeus-js/zeus",
|
|
12
|
-
version: "0.1.0-beta.
|
|
12
|
+
version: "0.1.0-beta.4",
|
|
13
13
|
publicApi: {
|
|
14
14
|
state: true,
|
|
15
15
|
computed: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* zeus v0.1.0-beta.
|
|
2
|
+
* zeus v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -9,7 +9,7 @@ Object.defineProperties(exports, {
|
|
|
9
9
|
});
|
|
10
10
|
const ZEUS_CAPABILITIES = {
|
|
11
11
|
packageName: "@zeus-js/zeus",
|
|
12
|
-
version: "0.1.0-beta.
|
|
12
|
+
version: "0.1.0-beta.4",
|
|
13
13
|
publicApi: {
|
|
14
14
|
state: true,
|
|
15
15
|
computed: true,
|
package/dist/capabilities.js
CHANGED
package/dist/zeus.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* zeus v0.1.0-beta.
|
|
2
|
+
* zeus v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -68,12 +68,14 @@ exports.computed = _zeus_js_signal.computed;
|
|
|
68
68
|
exports.createContext = _zeus_js_runtime_dom.createContext;
|
|
69
69
|
exports.defineElement = _zeus_js_runtime_dom.defineElement;
|
|
70
70
|
exports.effect = _zeus_js_signal.effect;
|
|
71
|
+
exports.event = _zeus_js_runtime_dom.event;
|
|
71
72
|
exports.inject = _zeus_js_runtime_dom.inject;
|
|
72
73
|
exports.jsx = jsx;
|
|
73
74
|
exports.jsxDEV = jsxDEV;
|
|
74
75
|
exports.jsxs = jsxs;
|
|
75
76
|
exports.nextTick = _zeus_js_signal.nextTick;
|
|
76
77
|
exports.onCleanup = _zeus_js_signal.onCleanup;
|
|
78
|
+
exports.prop = _zeus_js_runtime_dom.prop;
|
|
77
79
|
exports.provide = _zeus_js_runtime_dom.provide;
|
|
78
80
|
exports.render = _zeus_js_runtime_dom.render;
|
|
79
81
|
exports.scope = _zeus_js_signal.scope;
|
package/dist/zeus.cjs.prod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* zeus v0.1.0-beta.
|
|
2
|
+
* zeus v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -68,12 +68,14 @@ exports.computed = _zeus_js_signal.computed;
|
|
|
68
68
|
exports.createContext = _zeus_js_runtime_dom.createContext;
|
|
69
69
|
exports.defineElement = _zeus_js_runtime_dom.defineElement;
|
|
70
70
|
exports.effect = _zeus_js_signal.effect;
|
|
71
|
+
exports.event = _zeus_js_runtime_dom.event;
|
|
71
72
|
exports.inject = _zeus_js_runtime_dom.inject;
|
|
72
73
|
exports.jsx = jsx;
|
|
73
74
|
exports.jsxDEV = jsxDEV;
|
|
74
75
|
exports.jsxs = jsxs;
|
|
75
76
|
exports.nextTick = _zeus_js_signal.nextTick;
|
|
76
77
|
exports.onCleanup = _zeus_js_signal.onCleanup;
|
|
78
|
+
exports.prop = _zeus_js_runtime_dom.prop;
|
|
77
79
|
exports.provide = _zeus_js_runtime_dom.provide;
|
|
78
80
|
exports.render = _zeus_js_runtime_dom.render;
|
|
79
81
|
exports.scope = _zeus_js_signal.scope;
|
package/dist/zeus.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ComputedRef, Scope, State, ValueState, WatchHandle, WatchOptions, batch, computed, effect, nextTick, onCleanup, scope, state, untrack, watch } from '@zeus-js/signal';
|
|
2
2
|
import { JSXValue } from '@zeus-js/runtime-dom';
|
|
3
|
-
export { Component, Context, ContextBridgeProps, ContextProviderProps, DefineElementContext, DefineElementMeta, DefineElementOptions, DefineElementSetup, For, ForProps, Host, HostProps, JSXValue, Show, ShowProps, Slot, SlotProps, createContext, defineElement, inject, provide, render, useContext } from '@zeus-js/runtime-dom';
|
|
3
|
+
export { Component, Context, ContextBridgeProps, ContextProviderProps, DefineElementContext, DefineElementMeta, DefineElementOptions, DefineElementSetup, ElementModelDefinition, EmitApi, EmitsOptions, EventDefinition, EventOptions, For, ForProps, FormAssociatedOptions, FormAssociatedValue, FormStateRestoreMode, Host, HostProps, JSXValue, PropDefinition, PropDefinitionOptions, PropDeserializer, PropSerializer, Show, ShowProps, Slot, SlotProps, ValuePropDefinition, createContext, defineElement, event, inject, prop, provide, render, useContext } from '@zeus-js/runtime-dom';
|
|
4
4
|
|
|
5
5
|
export declare const Fragment: unique symbol;
|
|
6
6
|
|
package/dist/zeus.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ComputedRef, Scope, State, ValueState, WatchHandle, WatchOptions, batch, computed, effect, nextTick, onCleanup, scope, state, untrack, watch } from '@zeus-js/signal';
|
|
2
2
|
import { JSXValue } from '@zeus-js/runtime-dom';
|
|
3
|
-
export { Component, Context, ContextBridgeProps, ContextProviderProps, DefineElementContext, DefineElementMeta, DefineElementOptions, DefineElementSetup, For, ForProps, Host, HostProps, JSXValue, Show, ShowProps, Slot, SlotProps, createContext, defineElement, inject, provide, render, useContext } from '@zeus-js/runtime-dom';
|
|
3
|
+
export { Component, Context, ContextBridgeProps, ContextProviderProps, DefineElementContext, DefineElementMeta, DefineElementOptions, DefineElementSetup, ElementModelDefinition, EmitApi, EmitsOptions, EventDefinition, EventOptions, For, ForProps, FormAssociatedOptions, FormAssociatedValue, FormStateRestoreMode, Host, HostProps, JSXValue, PropDefinition, PropDefinitionOptions, PropDeserializer, PropSerializer, Show, ShowProps, Slot, SlotProps, ValuePropDefinition, createContext, defineElement, event, inject, prop, provide, render, useContext } from '@zeus-js/runtime-dom';
|
|
4
4
|
|
|
5
5
|
export declare const Fragment: unique symbol;
|
|
6
6
|
|
package/dist/zeus.esm-browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* zeus v0.1.0-beta.
|
|
2
|
+
* zeus v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -365,7 +365,6 @@ function cleanupDeps(sub) {
|
|
|
365
365
|
}
|
|
366
366
|
function isDirty(sub) {
|
|
367
367
|
for (let link = sub.deps; link; link = link.nextDep) if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) return true;
|
|
368
|
-
if (sub._dirty) return true;
|
|
369
368
|
return false;
|
|
370
369
|
}
|
|
371
370
|
/**
|
|
@@ -1422,7 +1421,6 @@ var ComputedRefImpl = class {
|
|
|
1422
1421
|
this.flags = 16;
|
|
1423
1422
|
this.globalVersion = globalVersion - 1;
|
|
1424
1423
|
this.next = void 0;
|
|
1425
|
-
this.effect = this;
|
|
1426
1424
|
this["__v_isReadonly"] = !setter;
|
|
1427
1425
|
this.isSSR = isSSR;
|
|
1428
1426
|
}
|
|
@@ -1742,7 +1740,7 @@ function useContext(context, fallback) {
|
|
|
1742
1740
|
const ZEUS_CONTEXT_REQUEST = "zeus:context-request";
|
|
1743
1741
|
/**
|
|
1744
1742
|
* Creates a transparent DOM element that acts as a context boundary.
|
|
1745
|
-
* Native custom elements inside it can use `
|
|
1743
|
+
* Native custom elements inside it can use `resolveDOMContext` to receive
|
|
1746
1744
|
* context values via the DOM event protocol.
|
|
1747
1745
|
*/
|
|
1748
1746
|
function createDOMContextBoundary(context, value, children) {
|
|
@@ -1754,7 +1752,7 @@ function createDOMContextBoundary(context, value, children) {
|
|
|
1754
1752
|
}
|
|
1755
1753
|
/**
|
|
1756
1754
|
* Registers a context value on a DOM target so that any descendant custom
|
|
1757
|
-
* element can pick it up via `
|
|
1755
|
+
* element can pick it up via `resolveDOMContext`.
|
|
1758
1756
|
*/
|
|
1759
1757
|
function provideDOMContext(target, context, value) {
|
|
1760
1758
|
const handler = (event) => {
|
|
@@ -1772,7 +1770,7 @@ function provideDOMContext(target, context, value) {
|
|
|
1772
1770
|
/**
|
|
1773
1771
|
* Internal precise DOM context resolver.
|
|
1774
1772
|
*
|
|
1775
|
-
*
|
|
1773
|
+
* The result distinguishes:
|
|
1776
1774
|
* - found: false, value: undefined
|
|
1777
1775
|
* - found: true, value: undefined
|
|
1778
1776
|
*/
|
|
@@ -1956,30 +1954,6 @@ function toKebabCase$1(value) {
|
|
|
1956
1954
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
1957
1955
|
}
|
|
1958
1956
|
//#endregion
|
|
1959
|
-
//#region packages/core/runtime-dom/src/refs.ts
|
|
1960
|
-
function setRef(target, value) {
|
|
1961
|
-
if (target == null) return;
|
|
1962
|
-
if (typeof target === "function") {
|
|
1963
|
-
target(value);
|
|
1964
|
-
return;
|
|
1965
|
-
}
|
|
1966
|
-
if ("value" in target) {
|
|
1967
|
-
target.value = value;
|
|
1968
|
-
return;
|
|
1969
|
-
}
|
|
1970
|
-
if ("current" in target) {
|
|
1971
|
-
target.current = value;
|
|
1972
|
-
return;
|
|
1973
|
-
}
|
|
1974
|
-
console.warn("[Zeus runtime] Invalid ref target:", target);
|
|
1975
|
-
}
|
|
1976
|
-
function bindRef(el, target) {
|
|
1977
|
-
setRef(target, el);
|
|
1978
|
-
if (getCurrentScope()) onScopeDispose(() => {
|
|
1979
|
-
setRef(target, null);
|
|
1980
|
-
}, true);
|
|
1981
|
-
}
|
|
1982
|
-
//#endregion
|
|
1983
1957
|
//#region packages/core/runtime-dom/src/component.ts
|
|
1984
1958
|
function createComponent(component, props) {
|
|
1985
1959
|
return runWithOwner(createOwner(), () => component(props));
|
|
@@ -1998,68 +1972,42 @@ function For(props) {
|
|
|
1998
1972
|
return (_props$each$map = (_props$each = props.each) === null || _props$each === void 0 ? void 0 : _props$each.map((item, index) => props.children(item, index))) !== null && _props$each$map !== void 0 ? _props$each$map : null;
|
|
1999
1973
|
}
|
|
2000
1974
|
//#endregion
|
|
2001
|
-
//#region
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
2024
|
-
function toPropertyKey(t) {
|
|
2025
|
-
var i = toPrimitive(t, "string");
|
|
2026
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
2027
|
-
}
|
|
2028
|
-
//#endregion
|
|
2029
|
-
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
2030
|
-
function _defineProperty(e, r, t) {
|
|
2031
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
2032
|
-
value: t,
|
|
2033
|
-
enumerable: !0,
|
|
2034
|
-
configurable: !0,
|
|
2035
|
-
writable: !0
|
|
2036
|
-
}) : e[r] = t, e;
|
|
1975
|
+
//#region packages/core/runtime-dom/src/defineElement.ts
|
|
1976
|
+
const ZEUS_ELEMENT_DEFINITION = Symbol.for("zeus.element.definition");
|
|
1977
|
+
function prop(input, options = {}) {
|
|
1978
|
+
var _options$reflect, _options$default;
|
|
1979
|
+
if (Array.isArray(input)) return {
|
|
1980
|
+
type: String,
|
|
1981
|
+
values: input,
|
|
1982
|
+
attr: options.attr,
|
|
1983
|
+
reflect: options.reflect,
|
|
1984
|
+
default: options.default,
|
|
1985
|
+
serialize: options.serialize,
|
|
1986
|
+
deserialize: options.deserialize
|
|
1987
|
+
};
|
|
1988
|
+
const type = input;
|
|
1989
|
+
return {
|
|
1990
|
+
type,
|
|
1991
|
+
attr: options.attr,
|
|
1992
|
+
reflect: type === Boolean ? (_options$reflect = options.reflect) !== null && _options$reflect !== void 0 ? _options$reflect : true : options.reflect,
|
|
1993
|
+
default: type === Boolean ? (_options$default = options.default) !== null && _options$default !== void 0 ? _options$default : false : options.default,
|
|
1994
|
+
serialize: options.serialize,
|
|
1995
|
+
deserialize: options.deserialize
|
|
1996
|
+
};
|
|
2037
1997
|
}
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
}
|
|
2050
|
-
function _objectSpread2(e) {
|
|
2051
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
2052
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
2053
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
2054
|
-
_defineProperty(e, r, t[r]);
|
|
2055
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
2056
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
2057
|
-
});
|
|
2058
|
-
}
|
|
2059
|
-
return e;
|
|
1998
|
+
function event(input) {
|
|
1999
|
+
if (typeof input === "string") return {
|
|
2000
|
+
__zeusEvent: true,
|
|
2001
|
+
name: input
|
|
2002
|
+
};
|
|
2003
|
+
return {
|
|
2004
|
+
__zeusEvent: true,
|
|
2005
|
+
name: input === null || input === void 0 ? void 0 : input.name,
|
|
2006
|
+
bubbles: input === null || input === void 0 ? void 0 : input.bubbles,
|
|
2007
|
+
composed: input === null || input === void 0 ? void 0 : input.composed,
|
|
2008
|
+
cancelable: input === null || input === void 0 ? void 0 : input.cancelable
|
|
2009
|
+
};
|
|
2060
2010
|
}
|
|
2061
|
-
//#endregion
|
|
2062
|
-
//#region packages/core/runtime-dom/src/defineElement.ts
|
|
2063
2011
|
function createPropStore(defs) {
|
|
2064
2012
|
const slots = /* @__PURE__ */ new Map();
|
|
2065
2013
|
const props = {};
|
|
@@ -2099,6 +2047,12 @@ function createPropStore(defs) {
|
|
|
2099
2047
|
function defineElement(tagName, options, setup) {
|
|
2100
2048
|
var _options$props;
|
|
2101
2049
|
const propDefs = normalizePropDefinitions((_options$props = options.props) !== null && _options$props !== void 0 ? _options$props : {});
|
|
2050
|
+
const definition = {
|
|
2051
|
+
tagName,
|
|
2052
|
+
options,
|
|
2053
|
+
setup,
|
|
2054
|
+
propDefs
|
|
2055
|
+
};
|
|
2102
2056
|
const observedAttributes = propDefs.filter((def) => def.attr !== false).map((def) => def.attr);
|
|
2103
2057
|
class ZeusElement extends HTMLElement {
|
|
2104
2058
|
static get observedAttributes() {
|
|
@@ -2113,6 +2067,13 @@ function defineElement(tagName, options, setup) {
|
|
|
2113
2067
|
this.props = this.propStore.props;
|
|
2114
2068
|
applyPropDefaults(this.propStore, propDefs);
|
|
2115
2069
|
definePropAccessors(this, this.propStore, propDefs);
|
|
2070
|
+
if (options.formAssociated) this.internals = attachElementInternals(this);
|
|
2071
|
+
this.setupContext = {
|
|
2072
|
+
host: this,
|
|
2073
|
+
internals: this.internals,
|
|
2074
|
+
emit: createEmitApi(this, options.emits),
|
|
2075
|
+
expose: createExpose(this)
|
|
2076
|
+
};
|
|
2116
2077
|
}
|
|
2117
2078
|
connectedCallback() {
|
|
2118
2079
|
var _options$shadow, _options$consumes;
|
|
@@ -2136,17 +2097,10 @@ function defineElement(tagName, options, setup) {
|
|
|
2136
2097
|
mode,
|
|
2137
2098
|
lightChildren: this.lightChildren
|
|
2138
2099
|
};
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
bubbles: true,
|
|
2144
|
-
composed: true,
|
|
2145
|
-
cancelable: true
|
|
2146
|
-
}, eventOptions), {}, { detail })));
|
|
2147
|
-
}
|
|
2148
|
-
};
|
|
2149
|
-
this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => setup(this.props, setupContext))), target, { owner });
|
|
2100
|
+
this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => {
|
|
2101
|
+
syncFormValue(this.props, this.setupContext, options.form);
|
|
2102
|
+
return setup(this.props, this.setupContext);
|
|
2103
|
+
})), target, { owner });
|
|
2150
2104
|
mountStyles(target, options.styles);
|
|
2151
2105
|
}
|
|
2152
2106
|
disconnectedCallback() {
|
|
@@ -2154,6 +2108,22 @@ function defineElement(tagName, options, setup) {
|
|
|
2154
2108
|
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
2155
2109
|
this.dispose = void 0;
|
|
2156
2110
|
}
|
|
2111
|
+
formAssociatedCallback(form) {
|
|
2112
|
+
var _options$form, _options$form$associa;
|
|
2113
|
+
(_options$form = options.form) === null || _options$form === void 0 || (_options$form$associa = _options$form.associated) === null || _options$form$associa === void 0 || _options$form$associa.call(_options$form, form, this.props, this.setupContext);
|
|
2114
|
+
}
|
|
2115
|
+
formDisabledCallback(disabled) {
|
|
2116
|
+
var _options$form2, _options$form2$disabl;
|
|
2117
|
+
(_options$form2 = options.form) === null || _options$form2 === void 0 || (_options$form2$disabl = _options$form2.disabled) === null || _options$form2$disabl === void 0 || _options$form2$disabl.call(_options$form2, disabled, this.props, this.setupContext);
|
|
2118
|
+
}
|
|
2119
|
+
formResetCallback() {
|
|
2120
|
+
var _options$form3, _options$form3$reset;
|
|
2121
|
+
(_options$form3 = options.form) === null || _options$form3 === void 0 || (_options$form3$reset = _options$form3.reset) === null || _options$form3$reset === void 0 || _options$form3$reset.call(_options$form3, this.props, this.setupContext);
|
|
2122
|
+
}
|
|
2123
|
+
formStateRestoreCallback(state, mode) {
|
|
2124
|
+
var _options$form4, _options$form4$stateR;
|
|
2125
|
+
(_options$form4 = options.form) === null || _options$form4 === void 0 || (_options$form4$stateR = _options$form4.stateRestore) === null || _options$form4$stateR === void 0 || _options$form4$stateR.call(_options$form4, state, mode, this.props, this.setupContext);
|
|
2126
|
+
}
|
|
2157
2127
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2158
2128
|
if (oldValue === newValue || this.reflecting) return;
|
|
2159
2129
|
const def = propDefs.find((item) => item.attr === name);
|
|
@@ -2189,24 +2159,37 @@ function defineElement(tagName, options, setup) {
|
|
|
2189
2159
|
}
|
|
2190
2160
|
}
|
|
2191
2161
|
}
|
|
2162
|
+
ZeusElement.formAssociated = Boolean(options.formAssociated);
|
|
2192
2163
|
if (!customElements.get(tagName)) customElements.define(tagName, ZeusElement);
|
|
2164
|
+
Object.defineProperty(ZeusElement, ZEUS_ELEMENT_DEFINITION, {
|
|
2165
|
+
value: definition,
|
|
2166
|
+
configurable: false
|
|
2167
|
+
});
|
|
2193
2168
|
return ZeusElement;
|
|
2194
2169
|
}
|
|
2195
2170
|
function normalizePropDefinitions(props) {
|
|
2196
2171
|
return Object.keys(props).map((key) => {
|
|
2172
|
+
const propKey = String(key);
|
|
2197
2173
|
const input = props[key];
|
|
2198
|
-
if (typeof input === "function")
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2174
|
+
if (typeof input === "function") {
|
|
2175
|
+
const type = input;
|
|
2176
|
+
return {
|
|
2177
|
+
key: propKey,
|
|
2178
|
+
attr: isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false,
|
|
2179
|
+
type,
|
|
2180
|
+
reflect: false
|
|
2181
|
+
};
|
|
2182
|
+
}
|
|
2183
|
+
const type = input === null || input === void 0 ? void 0 : input.type;
|
|
2184
|
+
const defaultAttr = isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false;
|
|
2204
2185
|
return {
|
|
2205
|
-
key,
|
|
2206
|
-
attr: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ?
|
|
2207
|
-
type
|
|
2186
|
+
key: propKey,
|
|
2187
|
+
attr: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ? defaultAttr : input.attr,
|
|
2188
|
+
type,
|
|
2208
2189
|
reflect: Boolean(input === null || input === void 0 ? void 0 : input.reflect),
|
|
2209
|
-
default: input === null || input === void 0 ? void 0 : input.default
|
|
2190
|
+
default: input === null || input === void 0 ? void 0 : input.default,
|
|
2191
|
+
serialize: input === null || input === void 0 ? void 0 : input.serialize,
|
|
2192
|
+
deserialize: input === null || input === void 0 ? void 0 : input.deserialize
|
|
2210
2193
|
};
|
|
2211
2194
|
});
|
|
2212
2195
|
}
|
|
@@ -2242,6 +2225,7 @@ function definePropAccessors(element, store, defs) {
|
|
|
2242
2225
|
}
|
|
2243
2226
|
}
|
|
2244
2227
|
function castAttributeValue(value, def) {
|
|
2228
|
+
if (def.deserialize) return def.deserialize(value);
|
|
2245
2229
|
if (def.type === Boolean) return value !== null;
|
|
2246
2230
|
if (value === null) return;
|
|
2247
2231
|
if (def.type === Number) return Number(value);
|
|
@@ -2251,10 +2235,17 @@ function castAttributeValue(value, def) {
|
|
|
2251
2235
|
console.warn(`[Zeus custom-element] Failed to parse JSON attribute "${def.attr}".`);
|
|
2252
2236
|
return def.type === Array ? [] : {};
|
|
2253
2237
|
}
|
|
2238
|
+
if (def.type === Function) return;
|
|
2254
2239
|
return value;
|
|
2255
2240
|
}
|
|
2256
2241
|
function reflectPropToAttribute(element, def, value) {
|
|
2257
2242
|
if (def.attr === false) return;
|
|
2243
|
+
if (def.serialize) {
|
|
2244
|
+
const serialized = def.serialize(value);
|
|
2245
|
+
if (serialized == null) element.removeAttribute(def.attr);
|
|
2246
|
+
else element.setAttribute(def.attr, serialized);
|
|
2247
|
+
return;
|
|
2248
|
+
}
|
|
2258
2249
|
if (def.type === Boolean) {
|
|
2259
2250
|
if (value) element.setAttribute(def.attr, "");
|
|
2260
2251
|
else element.removeAttribute(def.attr);
|
|
@@ -2268,8 +2259,70 @@ function reflectPropToAttribute(element, def, value) {
|
|
|
2268
2259
|
element.setAttribute(def.attr, JSON.stringify(value));
|
|
2269
2260
|
return;
|
|
2270
2261
|
}
|
|
2262
|
+
if (def.type === Function) return;
|
|
2271
2263
|
element.setAttribute(def.attr, String(value));
|
|
2272
2264
|
}
|
|
2265
|
+
function syncFormValue(props, context, form) {
|
|
2266
|
+
const valueResolver = form === null || form === void 0 ? void 0 : form.value;
|
|
2267
|
+
const stateResolver = form === null || form === void 0 ? void 0 : form.state;
|
|
2268
|
+
if (!context.internals || valueResolver === void 0) return;
|
|
2269
|
+
effect(() => {
|
|
2270
|
+
const value = resolveFormValue(props, valueResolver);
|
|
2271
|
+
const state = stateResolver === void 0 ? void 0 : resolveFormValue(props, stateResolver);
|
|
2272
|
+
context.internals.setFormValue(value, state);
|
|
2273
|
+
});
|
|
2274
|
+
}
|
|
2275
|
+
function resolveFormValue(props, resolver) {
|
|
2276
|
+
if (typeof resolver === "function") {
|
|
2277
|
+
var _resolver;
|
|
2278
|
+
return (_resolver = resolver(props)) !== null && _resolver !== void 0 ? _resolver : null;
|
|
2279
|
+
}
|
|
2280
|
+
const value = props[resolver];
|
|
2281
|
+
return value == null ? null : value;
|
|
2282
|
+
}
|
|
2283
|
+
function attachElementInternals(host) {
|
|
2284
|
+
const attachInternals = host.attachInternals;
|
|
2285
|
+
if (typeof attachInternals !== "function") return;
|
|
2286
|
+
try {
|
|
2287
|
+
return attachInternals.call(host);
|
|
2288
|
+
} catch (error) {
|
|
2289
|
+
console.warn("[Zeus custom-element] Failed to attach ElementInternals.", error);
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
function createEmitApi(host, emits) {
|
|
2294
|
+
const emit = {};
|
|
2295
|
+
const dispatch = (name, detail, options) => {
|
|
2296
|
+
var _definition$name, _ref, _options$bubbles, _ref2, _options$composed, _ref3, _options$cancelable;
|
|
2297
|
+
const definition = emits === null || emits === void 0 ? void 0 : emits[name];
|
|
2298
|
+
return host.dispatchEvent(new CustomEvent((_definition$name = definition === null || definition === void 0 ? void 0 : definition.name) !== null && _definition$name !== void 0 ? _definition$name : toKebabCase(name), {
|
|
2299
|
+
bubbles: (_ref = (_options$bubbles = options === null || options === void 0 ? void 0 : options.bubbles) !== null && _options$bubbles !== void 0 ? _options$bubbles : definition === null || definition === void 0 ? void 0 : definition.bubbles) !== null && _ref !== void 0 ? _ref : true,
|
|
2300
|
+
composed: (_ref2 = (_options$composed = options === null || options === void 0 ? void 0 : options.composed) !== null && _options$composed !== void 0 ? _options$composed : definition === null || definition === void 0 ? void 0 : definition.composed) !== null && _ref2 !== void 0 ? _ref2 : true,
|
|
2301
|
+
cancelable: (_ref3 = (_options$cancelable = options === null || options === void 0 ? void 0 : options.cancelable) !== null && _options$cancelable !== void 0 ? _options$cancelable : definition === null || definition === void 0 ? void 0 : definition.cancelable) !== null && _ref3 !== void 0 ? _ref3 : false,
|
|
2302
|
+
detail
|
|
2303
|
+
}));
|
|
2304
|
+
};
|
|
2305
|
+
if (emits) for (const key of Object.keys(emits)) Object.defineProperty(emit, key, {
|
|
2306
|
+
configurable: true,
|
|
2307
|
+
enumerable: true,
|
|
2308
|
+
value(detail, options) {
|
|
2309
|
+
return dispatch(key, detail, options);
|
|
2310
|
+
}
|
|
2311
|
+
});
|
|
2312
|
+
return emit;
|
|
2313
|
+
}
|
|
2314
|
+
function createExpose(host) {
|
|
2315
|
+
return (methods) => {
|
|
2316
|
+
for (const key of Object.keys(methods)) Object.defineProperty(host, key, {
|
|
2317
|
+
configurable: true,
|
|
2318
|
+
enumerable: false,
|
|
2319
|
+
value: methods[key]
|
|
2320
|
+
});
|
|
2321
|
+
};
|
|
2322
|
+
}
|
|
2323
|
+
function isAttributeBackedConstructor(type) {
|
|
2324
|
+
return type === String || type === Number || type === Boolean;
|
|
2325
|
+
}
|
|
2273
2326
|
function mountStyles(target, styles) {
|
|
2274
2327
|
if (!styles) return;
|
|
2275
2328
|
const list = Array.isArray(styles) ? styles : [styles];
|
|
@@ -2283,6 +2336,30 @@ function toKebabCase(value) {
|
|
|
2283
2336
|
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
2284
2337
|
}
|
|
2285
2338
|
//#endregion
|
|
2339
|
+
//#region packages/core/runtime-dom/src/refs.ts
|
|
2340
|
+
function setRef(target, value) {
|
|
2341
|
+
if (target == null) return;
|
|
2342
|
+
if (typeof target === "function") {
|
|
2343
|
+
target(value);
|
|
2344
|
+
return;
|
|
2345
|
+
}
|
|
2346
|
+
if ("value" in target) {
|
|
2347
|
+
target.value = value;
|
|
2348
|
+
return;
|
|
2349
|
+
}
|
|
2350
|
+
if ("current" in target) {
|
|
2351
|
+
target.current = value;
|
|
2352
|
+
return;
|
|
2353
|
+
}
|
|
2354
|
+
console.warn("[Zeus runtime] Invalid ref target:", target);
|
|
2355
|
+
}
|
|
2356
|
+
function bindRef(el, target) {
|
|
2357
|
+
setRef(target, el);
|
|
2358
|
+
if (getCurrentScope()) onScopeDispose(() => {
|
|
2359
|
+
setRef(target, null);
|
|
2360
|
+
}, true);
|
|
2361
|
+
}
|
|
2362
|
+
//#endregion
|
|
2286
2363
|
//#region packages/core/runtime-dom/src/slot.ts
|
|
2287
2364
|
function createSlot(name, fallback) {
|
|
2288
2365
|
const context = getCurrentHostContext();
|
|
@@ -2455,4 +2532,4 @@ function setFallbackRef(target, el) {
|
|
|
2455
2532
|
}
|
|
2456
2533
|
}
|
|
2457
2534
|
//#endregion
|
|
2458
|
-
export { For, Fragment, Host, Show, Slot, batch, computed, createContext, defineElement, effect, inject, jsx, jsxDEV, jsxs, nextTick, onCleanup, provide, render, effectScope as scope, state, untrack, useContext, watch };
|
|
2535
|
+
export { For, Fragment, Host, Show, Slot, batch, computed, createContext, defineElement, effect, event, inject, jsx, jsxDEV, jsxs, nextTick, onCleanup, prop, provide, render, effectScope as scope, state, untrack, useContext, watch };
|