@zeus-js/runtime-dom 0.1.0-beta.3 → 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/runtime-dom.cjs.js +208 -50
- package/dist/runtime-dom.cjs.prod.js +207 -50
- package/dist/runtime-dom.d.ts +98 -23
- package/dist/runtime-dom.esm-browser.js +207 -108
- package/dist/runtime-dom.esm-browser.prod.js +1 -1
- package/dist/runtime-dom.esm-bundler.js +207 -107
- package/dist/runtime-dom.global.js +208 -108
- package/dist/runtime-dom.global.prod.js +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* runtime-dom v0.1.0-beta.
|
|
2
|
+
* runtime-dom v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -168,7 +168,7 @@ function useContext(context, fallback) {
|
|
|
168
168
|
const ZEUS_CONTEXT_REQUEST = "zeus:context-request";
|
|
169
169
|
/**
|
|
170
170
|
* Creates a transparent DOM element that acts as a context boundary.
|
|
171
|
-
* Native custom elements inside it can use `
|
|
171
|
+
* Native custom elements inside it can use `resolveDOMContext` to receive
|
|
172
172
|
* context values via the DOM event protocol.
|
|
173
173
|
*/
|
|
174
174
|
function createDOMContextBoundary(context, value, children) {
|
|
@@ -180,7 +180,7 @@ function createDOMContextBoundary(context, value, children) {
|
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
182
|
* Registers a context value on a DOM target so that any descendant custom
|
|
183
|
-
* element can pick it up via `
|
|
183
|
+
* element can pick it up via `resolveDOMContext`.
|
|
184
184
|
*/
|
|
185
185
|
function provideDOMContext(target, context, value) {
|
|
186
186
|
const handler = (event) => {
|
|
@@ -198,7 +198,7 @@ function provideDOMContext(target, context, value) {
|
|
|
198
198
|
/**
|
|
199
199
|
* Internal precise DOM context resolver.
|
|
200
200
|
*
|
|
201
|
-
*
|
|
201
|
+
* The result distinguishes:
|
|
202
202
|
* - found: false, value: undefined
|
|
203
203
|
* - found: true, value: undefined
|
|
204
204
|
*/
|
|
@@ -227,16 +227,6 @@ function resolveDOMContext(host, context) {
|
|
|
227
227
|
value
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
|
-
/**
|
|
231
|
-
* Public compatibility API.
|
|
232
|
-
*
|
|
233
|
-
* Returns the resolved value if found, otherwise undefined.
|
|
234
|
-
* If you need to distinguish "not found" from "found undefined",
|
|
235
|
-
* use resolveDOMContext().
|
|
236
|
-
*/
|
|
237
|
-
function requestDOMContext(host, context) {
|
|
238
|
-
return resolveDOMContext(host, context).value;
|
|
239
|
-
}
|
|
240
230
|
function resolveValue$3(value) {
|
|
241
231
|
return typeof value === "function" ? value() : value !== null && value !== void 0 ? value : null;
|
|
242
232
|
}
|
|
@@ -627,69 +617,42 @@ function mountFor(parent, marker, each, key, render) {
|
|
|
627
617
|
mountFor$1(parent, marker, each, key, render);
|
|
628
618
|
}
|
|
629
619
|
//#endregion
|
|
630
|
-
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/typeof.js
|
|
631
|
-
function _typeof(o) {
|
|
632
|
-
"@babel/helpers - typeof";
|
|
633
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
634
|
-
return typeof o;
|
|
635
|
-
} : function(o) {
|
|
636
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
637
|
-
}, _typeof(o);
|
|
638
|
-
}
|
|
639
|
-
//#endregion
|
|
640
|
-
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPrimitive.js
|
|
641
|
-
function toPrimitive(t, r) {
|
|
642
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
643
|
-
var e = t[Symbol.toPrimitive];
|
|
644
|
-
if (void 0 !== e) {
|
|
645
|
-
var i = e.call(t, r || "default");
|
|
646
|
-
if ("object" != _typeof(i)) return i;
|
|
647
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
648
|
-
}
|
|
649
|
-
return ("string" === r ? String : Number)(t);
|
|
650
|
-
}
|
|
651
|
-
//#endregion
|
|
652
|
-
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPropertyKey.js
|
|
653
|
-
function toPropertyKey(t) {
|
|
654
|
-
var i = toPrimitive(t, "string");
|
|
655
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
656
|
-
}
|
|
657
|
-
//#endregion
|
|
658
|
-
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/defineProperty.js
|
|
659
|
-
function _defineProperty(e, r, t) {
|
|
660
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
661
|
-
value: t,
|
|
662
|
-
enumerable: !0,
|
|
663
|
-
configurable: !0,
|
|
664
|
-
writable: !0
|
|
665
|
-
}) : e[r] = t, e;
|
|
666
|
-
}
|
|
667
|
-
//#endregion
|
|
668
|
-
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/objectSpread2.js
|
|
669
|
-
function ownKeys(e, r) {
|
|
670
|
-
var t = Object.keys(e);
|
|
671
|
-
if (Object.getOwnPropertySymbols) {
|
|
672
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
673
|
-
r && (o = o.filter(function(r) {
|
|
674
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
675
|
-
})), t.push.apply(t, o);
|
|
676
|
-
}
|
|
677
|
-
return t;
|
|
678
|
-
}
|
|
679
|
-
function _objectSpread2(e) {
|
|
680
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
681
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
682
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
683
|
-
_defineProperty(e, r, t[r]);
|
|
684
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
685
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
return e;
|
|
689
|
-
}
|
|
690
|
-
//#endregion
|
|
691
620
|
//#region packages/core/runtime-dom/src/defineElement.ts
|
|
692
621
|
const ZEUS_ELEMENT_DEFINITION = Symbol.for("zeus.element.definition");
|
|
622
|
+
function prop(input, options = {}) {
|
|
623
|
+
var _options$reflect, _options$default;
|
|
624
|
+
if (Array.isArray(input)) return {
|
|
625
|
+
type: String,
|
|
626
|
+
values: input,
|
|
627
|
+
attr: options.attr,
|
|
628
|
+
reflect: options.reflect,
|
|
629
|
+
default: options.default,
|
|
630
|
+
serialize: options.serialize,
|
|
631
|
+
deserialize: options.deserialize
|
|
632
|
+
};
|
|
633
|
+
const type = input;
|
|
634
|
+
return {
|
|
635
|
+
type,
|
|
636
|
+
attr: options.attr,
|
|
637
|
+
reflect: type === Boolean ? (_options$reflect = options.reflect) !== null && _options$reflect !== void 0 ? _options$reflect : true : options.reflect,
|
|
638
|
+
default: type === Boolean ? (_options$default = options.default) !== null && _options$default !== void 0 ? _options$default : false : options.default,
|
|
639
|
+
serialize: options.serialize,
|
|
640
|
+
deserialize: options.deserialize
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
function event(input) {
|
|
644
|
+
if (typeof input === "string") return {
|
|
645
|
+
__zeusEvent: true,
|
|
646
|
+
name: input
|
|
647
|
+
};
|
|
648
|
+
return {
|
|
649
|
+
__zeusEvent: true,
|
|
650
|
+
name: input === null || input === void 0 ? void 0 : input.name,
|
|
651
|
+
bubbles: input === null || input === void 0 ? void 0 : input.bubbles,
|
|
652
|
+
composed: input === null || input === void 0 ? void 0 : input.composed,
|
|
653
|
+
cancelable: input === null || input === void 0 ? void 0 : input.cancelable
|
|
654
|
+
};
|
|
655
|
+
}
|
|
693
656
|
function createPropStore(defs) {
|
|
694
657
|
const slots = /* @__PURE__ */ new Map();
|
|
695
658
|
const props = {};
|
|
@@ -749,6 +712,13 @@ function defineElement(tagName, options, setup) {
|
|
|
749
712
|
this.props = this.propStore.props;
|
|
750
713
|
applyPropDefaults(this.propStore, propDefs);
|
|
751
714
|
definePropAccessors(this, this.propStore, propDefs);
|
|
715
|
+
if (options.formAssociated) this.internals = attachElementInternals(this);
|
|
716
|
+
this.setupContext = {
|
|
717
|
+
host: this,
|
|
718
|
+
internals: this.internals,
|
|
719
|
+
emit: createEmitApi(this, options.emits),
|
|
720
|
+
expose: createExpose(this)
|
|
721
|
+
};
|
|
752
722
|
}
|
|
753
723
|
connectedCallback() {
|
|
754
724
|
var _options$shadow, _options$consumes;
|
|
@@ -772,17 +742,10 @@ function defineElement(tagName, options, setup) {
|
|
|
772
742
|
mode,
|
|
773
743
|
lightChildren: this.lightChildren
|
|
774
744
|
};
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
bubbles: true,
|
|
780
|
-
composed: true,
|
|
781
|
-
cancelable: true
|
|
782
|
-
}, eventOptions), {}, { detail })));
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => setup(this.props, setupContext))), target, { owner });
|
|
745
|
+
this.dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => {
|
|
746
|
+
syncFormValue(this.props, this.setupContext, options.form);
|
|
747
|
+
return setup(this.props, this.setupContext);
|
|
748
|
+
})), target, { owner });
|
|
786
749
|
mountStyles(target, options.styles);
|
|
787
750
|
}
|
|
788
751
|
disconnectedCallback() {
|
|
@@ -790,6 +753,22 @@ function defineElement(tagName, options, setup) {
|
|
|
790
753
|
(_this$dispose = this.dispose) === null || _this$dispose === void 0 || _this$dispose.call(this);
|
|
791
754
|
this.dispose = void 0;
|
|
792
755
|
}
|
|
756
|
+
formAssociatedCallback(form) {
|
|
757
|
+
var _options$form, _options$form$associa;
|
|
758
|
+
(_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);
|
|
759
|
+
}
|
|
760
|
+
formDisabledCallback(disabled) {
|
|
761
|
+
var _options$form2, _options$form2$disabl;
|
|
762
|
+
(_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);
|
|
763
|
+
}
|
|
764
|
+
formResetCallback() {
|
|
765
|
+
var _options$form3, _options$form3$reset;
|
|
766
|
+
(_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);
|
|
767
|
+
}
|
|
768
|
+
formStateRestoreCallback(state, mode) {
|
|
769
|
+
var _options$form4, _options$form4$stateR;
|
|
770
|
+
(_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);
|
|
771
|
+
}
|
|
793
772
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
794
773
|
if (oldValue === newValue || this.reflecting) return;
|
|
795
774
|
const def = propDefs.find((item) => item.attr === name);
|
|
@@ -825,6 +804,7 @@ function defineElement(tagName, options, setup) {
|
|
|
825
804
|
}
|
|
826
805
|
}
|
|
827
806
|
}
|
|
807
|
+
ZeusElement.formAssociated = Boolean(options.formAssociated);
|
|
828
808
|
if (!customElements.get(tagName)) customElements.define(tagName, ZeusElement);
|
|
829
809
|
Object.defineProperty(ZeusElement, ZEUS_ELEMENT_DEFINITION, {
|
|
830
810
|
value: definition,
|
|
@@ -838,11 +818,17 @@ function getElementDefinition(ctor) {
|
|
|
838
818
|
return definition;
|
|
839
819
|
}
|
|
840
820
|
function mountElementDefinition(ctor, host, initialValues = /* @__PURE__ */ new Map(), mountState = {}) {
|
|
841
|
-
var _options$shadow2, _mountState$lightChil, _options$consumes2, _mountState$target;
|
|
821
|
+
var _options$shadow2, _mountState$lightChil, _options$consumes2, _mountState$target, _mountState$internals;
|
|
842
822
|
const { options, setup, propDefs } = getElementDefinition(ctor);
|
|
843
823
|
const propStore = createPropStore(propDefs);
|
|
844
824
|
applyPropDefaults(propStore, propDefs);
|
|
845
825
|
for (const def of propDefs) {
|
|
826
|
+
var _mountState$attribute;
|
|
827
|
+
if (def.attr !== false && ((_mountState$attribute = mountState.attributeProps) === null || _mountState$attribute === void 0 ? void 0 : _mountState$attribute.has(def.key))) {
|
|
828
|
+
propStore.set(def.key, castAttributeValue(host.getAttribute(def.attr), def));
|
|
829
|
+
initialValues.set(def.key, propStore.get(def.key));
|
|
830
|
+
continue;
|
|
831
|
+
}
|
|
846
832
|
if (initialValues.has(def.key)) {
|
|
847
833
|
propStore.set(def.key, initialValues.get(def.key));
|
|
848
834
|
continue;
|
|
@@ -854,6 +840,10 @@ function mountElementDefinition(ctor, host, initialValues = /* @__PURE__ */ new
|
|
|
854
840
|
*/
|
|
855
841
|
initialValues.set(def.key, propStore.get(def.key));
|
|
856
842
|
}
|
|
843
|
+
for (const def of propDefs) {
|
|
844
|
+
var _mountState$attribute2;
|
|
845
|
+
if (def.reflect && def.serialize && !((_mountState$attribute2 = mountState.attributeProps) === null || _mountState$attribute2 === void 0 ? void 0 : _mountState$attribute2.has(def.key))) reflectExternalProp(host, def, propStore.get(def.key), mountState.reflectingAttrs);
|
|
846
|
+
}
|
|
857
847
|
const shadow = (_options$shadow2 = options.shadow) !== null && _options$shadow2 !== void 0 ? _options$shadow2 : false;
|
|
858
848
|
const mode = shadow ? "shadow" : "light";
|
|
859
849
|
if (mode === "light" && !mountState.capturedLightChildren) {
|
|
@@ -875,19 +865,41 @@ function mountElementDefinition(ctor, host, initialValues = /* @__PURE__ */ new
|
|
|
875
865
|
};
|
|
876
866
|
const setupContext = {
|
|
877
867
|
host,
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
composed: true,
|
|
882
|
-
cancelable: true
|
|
883
|
-
}, eventOptions), {}, { detail })));
|
|
884
|
-
}
|
|
868
|
+
internals: (_mountState$internals = mountState.internals) !== null && _mountState$internals !== void 0 ? _mountState$internals : options.formAssociated ? attachElementInternals(host) : void 0,
|
|
869
|
+
emit: createEmitApi(host, options.emits),
|
|
870
|
+
expose: createExpose(host)
|
|
885
871
|
};
|
|
886
|
-
|
|
872
|
+
mountState.internals = setupContext.internals;
|
|
873
|
+
const dispose = render(() => runWithOwner(owner, () => withHostContext(hostContext, () => {
|
|
874
|
+
syncFormValue(propStore.props, setupContext, options.form);
|
|
875
|
+
return setup(propStore.props, setupContext);
|
|
876
|
+
})), target, { owner });
|
|
887
877
|
mountStyles(target, options.styles);
|
|
888
878
|
return {
|
|
889
879
|
propertyChanged(name, _oldValue, newValue) {
|
|
890
|
-
|
|
880
|
+
var _mountState$attribute3;
|
|
881
|
+
const def = propDefs.find((item) => item.key === name);
|
|
882
|
+
const fromAttribute = Boolean((def === null || def === void 0 ? void 0 : def.attr) !== false && ((_mountState$attribute3 = mountState.attributeProps) === null || _mountState$attribute3 === void 0 ? void 0 : _mountState$attribute3.has(name)));
|
|
883
|
+
const value = fromAttribute && def ? castAttributeValue(typeof newValue === "string" ? newValue : null, def) : newValue;
|
|
884
|
+
propStore.set(name, value);
|
|
885
|
+
initialValues.set(name, value);
|
|
886
|
+
if ((def === null || def === void 0 ? void 0 : def.reflect) && !fromAttribute) reflectExternalProp(host, def, value, mountState.reflectingAttrs);
|
|
887
|
+
},
|
|
888
|
+
formAssociated(form) {
|
|
889
|
+
var _options$form5, _options$form5$associ;
|
|
890
|
+
(_options$form5 = options.form) === null || _options$form5 === void 0 || (_options$form5$associ = _options$form5.associated) === null || _options$form5$associ === void 0 || _options$form5$associ.call(_options$form5, form, propStore.props, setupContext);
|
|
891
|
+
},
|
|
892
|
+
formDisabled(disabled) {
|
|
893
|
+
var _options$form6, _options$form6$disabl;
|
|
894
|
+
(_options$form6 = options.form) === null || _options$form6 === void 0 || (_options$form6$disabl = _options$form6.disabled) === null || _options$form6$disabl === void 0 || _options$form6$disabl.call(_options$form6, disabled, propStore.props, setupContext);
|
|
895
|
+
},
|
|
896
|
+
formReset() {
|
|
897
|
+
var _options$form7, _options$form7$reset;
|
|
898
|
+
(_options$form7 = options.form) === null || _options$form7 === void 0 || (_options$form7$reset = _options$form7.reset) === null || _options$form7$reset === void 0 || _options$form7$reset.call(_options$form7, propStore.props, setupContext);
|
|
899
|
+
},
|
|
900
|
+
formStateRestore(state, mode) {
|
|
901
|
+
var _options$form8, _options$form8$stateR;
|
|
902
|
+
(_options$form8 = options.form) === null || _options$form8 === void 0 || (_options$form8$stateR = _options$form8.stateRestore) === null || _options$form8$stateR === void 0 || _options$form8$stateR.call(_options$form8, state, mode, propStore.props, setupContext);
|
|
891
903
|
},
|
|
892
904
|
dispose() {
|
|
893
905
|
dispose();
|
|
@@ -896,19 +908,27 @@ function mountElementDefinition(ctor, host, initialValues = /* @__PURE__ */ new
|
|
|
896
908
|
}
|
|
897
909
|
function normalizePropDefinitions(props) {
|
|
898
910
|
return Object.keys(props).map((key) => {
|
|
911
|
+
const propKey = String(key);
|
|
899
912
|
const input = props[key];
|
|
900
|
-
if (typeof input === "function")
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
913
|
+
if (typeof input === "function") {
|
|
914
|
+
const type = input;
|
|
915
|
+
return {
|
|
916
|
+
key: propKey,
|
|
917
|
+
attr: isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false,
|
|
918
|
+
type,
|
|
919
|
+
reflect: false
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
const type = input === null || input === void 0 ? void 0 : input.type;
|
|
923
|
+
const defaultAttr = isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false;
|
|
906
924
|
return {
|
|
907
|
-
key,
|
|
908
|
-
attr: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ?
|
|
909
|
-
type
|
|
925
|
+
key: propKey,
|
|
926
|
+
attr: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ? defaultAttr : input.attr,
|
|
927
|
+
type,
|
|
910
928
|
reflect: Boolean(input === null || input === void 0 ? void 0 : input.reflect),
|
|
911
|
-
default: input === null || input === void 0 ? void 0 : input.default
|
|
929
|
+
default: input === null || input === void 0 ? void 0 : input.default,
|
|
930
|
+
serialize: input === null || input === void 0 ? void 0 : input.serialize,
|
|
931
|
+
deserialize: input === null || input === void 0 ? void 0 : input.deserialize
|
|
912
932
|
};
|
|
913
933
|
});
|
|
914
934
|
}
|
|
@@ -944,6 +964,7 @@ function definePropAccessors(element, store, defs) {
|
|
|
944
964
|
}
|
|
945
965
|
}
|
|
946
966
|
function castAttributeValue(value, def) {
|
|
967
|
+
if (def.deserialize) return def.deserialize(value);
|
|
947
968
|
if (def.type === Boolean) return value !== null;
|
|
948
969
|
if (value === null) return;
|
|
949
970
|
if (def.type === Number) return Number(value);
|
|
@@ -953,10 +974,17 @@ function castAttributeValue(value, def) {
|
|
|
953
974
|
console.warn(`[Zeus custom-element] Failed to parse JSON attribute "${def.attr}".`);
|
|
954
975
|
return def.type === Array ? [] : {};
|
|
955
976
|
}
|
|
977
|
+
if (def.type === Function) return;
|
|
956
978
|
return value;
|
|
957
979
|
}
|
|
958
980
|
function reflectPropToAttribute(element, def, value) {
|
|
959
981
|
if (def.attr === false) return;
|
|
982
|
+
if (def.serialize) {
|
|
983
|
+
const serialized = def.serialize(value);
|
|
984
|
+
if (serialized == null) element.removeAttribute(def.attr);
|
|
985
|
+
else element.setAttribute(def.attr, serialized);
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
960
988
|
if (def.type === Boolean) {
|
|
961
989
|
if (value) element.setAttribute(def.attr, "");
|
|
962
990
|
else element.removeAttribute(def.attr);
|
|
@@ -970,8 +998,80 @@ function reflectPropToAttribute(element, def, value) {
|
|
|
970
998
|
element.setAttribute(def.attr, JSON.stringify(value));
|
|
971
999
|
return;
|
|
972
1000
|
}
|
|
1001
|
+
if (def.type === Function) return;
|
|
973
1002
|
element.setAttribute(def.attr, String(value));
|
|
974
1003
|
}
|
|
1004
|
+
function reflectExternalProp(element, def, value, reflectingAttrs) {
|
|
1005
|
+
if (def.attr === false) return;
|
|
1006
|
+
const attrName = def.attr.toLowerCase();
|
|
1007
|
+
reflectingAttrs === null || reflectingAttrs === void 0 || reflectingAttrs.add(attrName);
|
|
1008
|
+
try {
|
|
1009
|
+
reflectPropToAttribute(element, def, value);
|
|
1010
|
+
} finally {
|
|
1011
|
+
reflectingAttrs === null || reflectingAttrs === void 0 || reflectingAttrs.delete(attrName);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
function syncFormValue(props, context, form) {
|
|
1015
|
+
const valueResolver = form === null || form === void 0 ? void 0 : form.value;
|
|
1016
|
+
const stateResolver = form === null || form === void 0 ? void 0 : form.state;
|
|
1017
|
+
if (!context.internals || valueResolver === void 0) return;
|
|
1018
|
+
effect(() => {
|
|
1019
|
+
const value = resolveFormValue(props, valueResolver);
|
|
1020
|
+
const state = stateResolver === void 0 ? void 0 : resolveFormValue(props, stateResolver);
|
|
1021
|
+
context.internals.setFormValue(value, state);
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
function resolveFormValue(props, resolver) {
|
|
1025
|
+
if (typeof resolver === "function") {
|
|
1026
|
+
var _resolver;
|
|
1027
|
+
return (_resolver = resolver(props)) !== null && _resolver !== void 0 ? _resolver : null;
|
|
1028
|
+
}
|
|
1029
|
+
const value = props[resolver];
|
|
1030
|
+
return value == null ? null : value;
|
|
1031
|
+
}
|
|
1032
|
+
function attachElementInternals(host) {
|
|
1033
|
+
const attachInternals = host.attachInternals;
|
|
1034
|
+
if (typeof attachInternals !== "function") return;
|
|
1035
|
+
try {
|
|
1036
|
+
return attachInternals.call(host);
|
|
1037
|
+
} catch (error) {
|
|
1038
|
+
console.warn("[Zeus custom-element] Failed to attach ElementInternals.", error);
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
function createEmitApi(host, emits) {
|
|
1043
|
+
const emit = {};
|
|
1044
|
+
const dispatch = (name, detail, options) => {
|
|
1045
|
+
var _definition$name, _ref, _options$bubbles, _ref2, _options$composed, _ref3, _options$cancelable;
|
|
1046
|
+
const definition = emits === null || emits === void 0 ? void 0 : emits[name];
|
|
1047
|
+
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), {
|
|
1048
|
+
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,
|
|
1049
|
+
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,
|
|
1050
|
+
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,
|
|
1051
|
+
detail
|
|
1052
|
+
}));
|
|
1053
|
+
};
|
|
1054
|
+
if (emits) for (const key of Object.keys(emits)) Object.defineProperty(emit, key, {
|
|
1055
|
+
configurable: true,
|
|
1056
|
+
enumerable: true,
|
|
1057
|
+
value(detail, options) {
|
|
1058
|
+
return dispatch(key, detail, options);
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
return emit;
|
|
1062
|
+
}
|
|
1063
|
+
function createExpose(host) {
|
|
1064
|
+
return (methods) => {
|
|
1065
|
+
for (const key of Object.keys(methods)) Object.defineProperty(host, key, {
|
|
1066
|
+
configurable: true,
|
|
1067
|
+
enumerable: false,
|
|
1068
|
+
value: methods[key]
|
|
1069
|
+
});
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
function isAttributeBackedConstructor(type) {
|
|
1073
|
+
return type === String || type === Number || type === Boolean;
|
|
1074
|
+
}
|
|
975
1075
|
function resolveExternalRenderTarget(host, shadow) {
|
|
976
1076
|
var _host$shadowRoot;
|
|
977
1077
|
if (!shadow) return host;
|
|
@@ -1113,4 +1213,4 @@ function normalizeHostAttrName(name) {
|
|
|
1113
1213
|
}
|
|
1114
1214
|
}
|
|
1115
1215
|
//#endregion
|
|
1116
|
-
export { For, Host, Show, Slot, ZEUS_CONTEXT_REQUEST, ZEUS_ELEMENT_DEFINITION, bindAttr, bindClass, bindEvent, bindProp, bindRef, bindStyle, bindText, bindTextContent, captureCurrentHostContext, child, createComponent, createContext, createDOMContextBoundary, createOwner, createSlot, defineElement, delegateEvents, getCurrentHostContext, getCurrentOwner, getElementDefinition, inject, insert, insertTracked, marker, mountDynamic, mountElementDefinition, mountFor, mountShow, normalizeClass, provide, provideDOMContext, removeNodes, render,
|
|
1216
|
+
export { For, Host, Show, Slot, ZEUS_CONTEXT_REQUEST, ZEUS_ELEMENT_DEFINITION, bindAttr, bindClass, bindEvent, bindProp, bindRef, bindStyle, bindText, bindTextContent, captureCurrentHostContext, child, createComponent, createContext, createDOMContextBoundary, createOwner, createSlot, defineElement, delegateEvents, event, getCurrentHostContext, getCurrentOwner, getElementDefinition, inject, insert, insertTracked, marker, mountDynamic, mountElementDefinition, mountFor, mountShow, normalizeClass, prop, provide, provideDOMContext, removeNodes, render, resolveDOMContext, resolveValue, runWithOwner, setAttr, setRef, template, useContext, withCapturedHostContext, withHostContext };
|