@seahax/elemental 0.5.18 → 0.5.19
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.
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createStyleSheet as e } from "./internal/createStyleSheet.js";
|
|
2
|
+
import { defineComponent as t } from "./defineComponent.js";
|
|
2
3
|
//#region src/extendComponentDefinition.ts
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
function n({ styles: n, preInit: r, postInit: i, preRender: a, postRender: o }) {
|
|
5
|
+
let s = n.map((t) => typeof t == "string" ? e(t) : t);
|
|
6
|
+
return (e, n) => t((t, n) => {
|
|
7
|
+
a?.(t), e(t, n), o?.(t);
|
|
6
8
|
}, {
|
|
7
|
-
...
|
|
8
|
-
styles: [...
|
|
9
|
+
...n,
|
|
10
|
+
styles: [...s, ...n?.styles ?? []],
|
|
9
11
|
init: (e) => {
|
|
10
|
-
|
|
12
|
+
r?.(e), n?.init?.(e), i?.(e);
|
|
11
13
|
}
|
|
12
14
|
});
|
|
13
15
|
}
|
|
14
16
|
//#endregion
|
|
15
|
-
export {
|
|
17
|
+
export { n as extendComponentDefinition };
|
|
16
18
|
|
|
17
19
|
//# sourceMappingURL=extendComponentDefinition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extendComponentDefinition.js","names":[],"sources":["../src/extendComponentDefinition.ts"],"sourcesContent":["import { type ComponentShadowRoot, defineComponent } from './defineComponent.js';\n\nexport interface ExtendComponentDefinitionOptions {\n styles: readonly (string | CSSStyleSheet)[];\n /** Called before the component `init` option is called. */\n preInit?: (shadow: ComponentShadowRoot<{}>) => void;\n /** Called after the component `init` option is called. */\n postInit?: (shadow: ComponentShadowRoot<{}>) => void;\n /** Called before the component render function. */\n preRender?: (shadow: ComponentShadowRoot<{}>) => void;\n /** Called after the component render function. */\n postRender?: (shadow: ComponentShadowRoot<{}>) => void;\n}\n\n/**\n * Create a new component factory function (ie. `defineComponent`) with\n * modified default options or render hooks.\n *\n * NOTE: Does not support `tagName` or `props` option defaults.\n */\nexport function extendComponentDefinition({\n styles,\n preInit,\n postInit,\n preRender,\n postRender,\n}: ExtendComponentDefinitionOptions): typeof defineComponent {\n return (render, options) => {\n return defineComponent(\n (shadow, propRefs) => {\n preRender?.(shadow);\n render(shadow, propRefs);\n postRender?.(shadow);\n },\n {\n ...options,\n styles: [...
|
|
1
|
+
{"version":3,"file":"extendComponentDefinition.js","names":[],"sources":["../src/extendComponentDefinition.ts"],"sourcesContent":["import { type ComponentShadowRoot, defineComponent } from './defineComponent.js';\nimport { createStyleSheet } from './internal/createStyleSheet.js';\n\nexport interface ExtendComponentDefinitionOptions {\n styles: readonly (string | CSSStyleSheet)[];\n /** Called before the component `init` option is called. */\n preInit?: (shadow: ComponentShadowRoot<{}>) => void;\n /** Called after the component `init` option is called. */\n postInit?: (shadow: ComponentShadowRoot<{}>) => void;\n /** Called before the component render function. */\n preRender?: (shadow: ComponentShadowRoot<{}>) => void;\n /** Called after the component render function. */\n postRender?: (shadow: ComponentShadowRoot<{}>) => void;\n}\n\n/**\n * Create a new component factory function (ie. `defineComponent`) with\n * modified default options or render hooks.\n *\n * NOTE: Does not support `tagName` or `props` option defaults.\n */\nexport function extendComponentDefinition({\n styles,\n preInit,\n postInit,\n preRender,\n postRender,\n}: ExtendComponentDefinitionOptions): typeof defineComponent {\n const styleSheets = styles.map((style) => (typeof style === 'string' ? createStyleSheet(style) : style));\n\n return (render, options) => {\n return defineComponent(\n (shadow, propRefs) => {\n preRender?.(shadow);\n render(shadow, propRefs);\n postRender?.(shadow);\n },\n {\n ...options,\n styles: [...styleSheets, ...(options?.styles ?? [])],\n init: (shadow) => {\n preInit?.(shadow);\n options?.init?.(shadow);\n postInit?.(shadow);\n },\n },\n );\n };\n}\n"],"mappings":";;;AAqBA,SAAgB,EAA0B,EACxC,WACA,YACA,aACA,cACA,iBAC2D;CAC3D,IAAM,IAAc,EAAO,KAAK,MAAW,OAAO,KAAU,WAAW,EAAiB,EAAM,GAAG,EAAO;AAExG,SAAQ,GAAQ,MACP,GACJ,GAAQ,MAAa;AAGpB,EAFA,IAAY,EAAO,EACnB,EAAO,GAAQ,EAAS,EACxB,IAAa,EAAO;IAEtB;EACE,GAAG;EACH,QAAQ,CAAC,GAAG,GAAa,GAAI,GAAS,UAAU,EAAE,CAAE;EACpD,OAAO,MAAW;AAGhB,GAFA,IAAU,EAAO,EACjB,GAAS,OAAO,EAAO,EACvB,IAAW,EAAO;;EAErB,CACF"}
|
package/package.json
CHANGED