@bquery/bquery 1.1.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +501 -323
- package/dist/batch-4LAvfLE7.js +13 -0
- package/dist/batch-4LAvfLE7.js.map +1 -0
- package/dist/component/component.d.ts +69 -0
- package/dist/component/component.d.ts.map +1 -0
- package/dist/component/html.d.ts +35 -0
- package/dist/component/html.d.ts.map +1 -0
- package/dist/component/index.d.ts +3 -126
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/props.d.ts +18 -0
- package/dist/component/props.d.ts.map +1 -0
- package/dist/component/types.d.ts +77 -0
- package/dist/component/types.d.ts.map +1 -0
- package/dist/component.es.mjs +90 -59
- package/dist/component.es.mjs.map +1 -1
- package/dist/core/collection.d.ts +36 -0
- package/dist/core/collection.d.ts.map +1 -1
- package/dist/core/dom.d.ts +6 -0
- package/dist/core/dom.d.ts.map +1 -0
- package/dist/core/element.d.ts +8 -0
- package/dist/core/element.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/utils/array.d.ts +74 -0
- package/dist/core/utils/array.d.ts.map +1 -0
- package/dist/core/utils/function.d.ts +70 -0
- package/dist/core/utils/function.d.ts.map +1 -0
- package/dist/core/utils/index.d.ts +70 -0
- package/dist/core/utils/index.d.ts.map +1 -0
- package/dist/core/utils/misc.d.ts +63 -0
- package/dist/core/utils/misc.d.ts.map +1 -0
- package/dist/core/utils/number.d.ts +65 -0
- package/dist/core/utils/number.d.ts.map +1 -0
- package/dist/core/utils/object.d.ts +133 -0
- package/dist/core/utils/object.d.ts.map +1 -0
- package/dist/core/utils/string.d.ts +80 -0
- package/dist/core/utils/string.d.ts.map +1 -0
- package/dist/core/utils/type-guards.d.ts +79 -0
- package/dist/core/utils/type-guards.d.ts.map +1 -0
- package/dist/core-COenAZjD.js +145 -0
- package/dist/core-COenAZjD.js.map +1 -0
- package/dist/core.es.mjs +411 -448
- package/dist/core.es.mjs.map +1 -1
- package/dist/full.d.ts +8 -2
- package/dist/full.d.ts.map +1 -1
- package/dist/full.es.mjs +86 -40
- package/dist/full.es.mjs.map +1 -1
- package/dist/full.iife.js +6 -1
- package/dist/full.iife.js.map +1 -1
- package/dist/full.umd.js +6 -1
- package/dist/full.umd.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.mjs +137 -44
- package/dist/index.es.mjs.map +1 -1
- package/dist/motion/animate.d.ts +25 -0
- package/dist/motion/animate.d.ts.map +1 -0
- package/dist/motion/easing.d.ts +30 -0
- package/dist/motion/easing.d.ts.map +1 -0
- package/dist/motion/flip.d.ts +55 -0
- package/dist/motion/flip.d.ts.map +1 -0
- package/dist/motion/index.d.ts +11 -138
- package/dist/motion/index.d.ts.map +1 -1
- package/dist/motion/keyframes.d.ts +21 -0
- package/dist/motion/keyframes.d.ts.map +1 -0
- package/dist/motion/reduced-motion.d.ts +12 -0
- package/dist/motion/reduced-motion.d.ts.map +1 -0
- package/dist/motion/scroll.d.ts +15 -0
- package/dist/motion/scroll.d.ts.map +1 -0
- package/dist/motion/spring.d.ts +42 -0
- package/dist/motion/spring.d.ts.map +1 -0
- package/dist/motion/stagger.d.ts +22 -0
- package/dist/motion/stagger.d.ts.map +1 -0
- package/dist/motion/timeline.d.ts +21 -0
- package/dist/motion/timeline.d.ts.map +1 -0
- package/dist/motion/transition.d.ts +22 -0
- package/dist/motion/transition.d.ts.map +1 -0
- package/dist/motion/types.d.ts +182 -0
- package/dist/motion/types.d.ts.map +1 -0
- package/dist/motion.es.mjs +320 -61
- package/dist/motion.es.mjs.map +1 -1
- package/dist/persisted-Dz_ryNuC.js +278 -0
- package/dist/persisted-Dz_ryNuC.js.map +1 -0
- package/dist/reactive/batch.d.ts +13 -0
- package/dist/reactive/batch.d.ts.map +1 -0
- package/dist/reactive/computed.d.ts +50 -0
- package/dist/reactive/computed.d.ts.map +1 -0
- package/dist/reactive/core.d.ts +60 -0
- package/dist/reactive/core.d.ts.map +1 -0
- package/dist/reactive/effect.d.ts +15 -0
- package/dist/reactive/effect.d.ts.map +1 -0
- package/dist/reactive/index.d.ts +2 -2
- package/dist/reactive/index.d.ts.map +1 -1
- package/dist/reactive/internals.d.ts +36 -0
- package/dist/reactive/internals.d.ts.map +1 -0
- package/dist/reactive/linked.d.ts +36 -0
- package/dist/reactive/linked.d.ts.map +1 -0
- package/dist/reactive/persisted.d.ts +14 -0
- package/dist/reactive/persisted.d.ts.map +1 -0
- package/dist/reactive/readonly.d.ts +26 -0
- package/dist/reactive/readonly.d.ts.map +1 -0
- package/dist/reactive/signal.d.ts +13 -305
- package/dist/reactive/signal.d.ts.map +1 -1
- package/dist/reactive/type-guards.d.ts +20 -0
- package/dist/reactive/type-guards.d.ts.map +1 -0
- package/dist/reactive/untrack.d.ts +29 -0
- package/dist/reactive/untrack.d.ts.map +1 -0
- package/dist/reactive/watch.d.ts +42 -0
- package/dist/reactive/watch.d.ts.map +1 -0
- package/dist/reactive.es.mjs +30 -154
- package/dist/reactive.es.mjs.map +1 -1
- package/dist/router/index.d.ts +41 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/links.d.ts +44 -0
- package/dist/router/links.d.ts.map +1 -0
- package/dist/router/match.d.ts +20 -0
- package/dist/router/match.d.ts.map +1 -0
- package/dist/router/navigation.d.ts +45 -0
- package/dist/router/navigation.d.ts.map +1 -0
- package/dist/router/query.d.ts +16 -0
- package/dist/router/query.d.ts.map +1 -0
- package/dist/router/router.d.ts +34 -0
- package/dist/router/router.d.ts.map +1 -0
- package/dist/router/state.d.ts +27 -0
- package/dist/router/state.d.ts.map +1 -0
- package/dist/router/types.d.ts +88 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/utils.d.ts +65 -0
- package/dist/router/utils.d.ts.map +1 -0
- package/dist/router.es.mjs +202 -0
- package/dist/router.es.mjs.map +1 -0
- package/dist/sanitize-1FBEPAFH.js +272 -0
- package/dist/sanitize-1FBEPAFH.js.map +1 -0
- package/dist/security/constants.d.ts +42 -0
- package/dist/security/constants.d.ts.map +1 -0
- package/dist/security/csp.d.ts +24 -0
- package/dist/security/csp.d.ts.map +1 -0
- package/dist/security/index.d.ts +4 -2
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/sanitize-core.d.ts +13 -0
- package/dist/security/sanitize-core.d.ts.map +1 -0
- package/dist/security/sanitize.d.ts +5 -57
- package/dist/security/sanitize.d.ts.map +1 -1
- package/dist/security/trusted-types.d.ts +25 -0
- package/dist/security/trusted-types.d.ts.map +1 -0
- package/dist/security/types.d.ts +36 -0
- package/dist/security/types.d.ts.map +1 -0
- package/dist/security.es.mjs +50 -277
- package/dist/security.es.mjs.map +1 -1
- package/dist/store/create-store.d.ts +15 -0
- package/dist/store/create-store.d.ts.map +1 -0
- package/dist/store/define-store.d.ts +28 -0
- package/dist/store/define-store.d.ts.map +1 -0
- package/dist/store/devtools.d.ts +22 -0
- package/dist/store/devtools.d.ts.map +1 -0
- package/dist/store/index.d.ts +12 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/mapping.d.ts +28 -0
- package/dist/store/mapping.d.ts.map +1 -0
- package/dist/store/persisted.d.ts +13 -0
- package/dist/store/persisted.d.ts.map +1 -0
- package/dist/store/plugins.d.ts +13 -0
- package/dist/store/plugins.d.ts.map +1 -0
- package/dist/store/registry.d.ts +28 -0
- package/dist/store/registry.d.ts.map +1 -0
- package/dist/store/types.d.ts +71 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/utils.d.ts +28 -0
- package/dist/store/utils.d.ts.map +1 -0
- package/dist/store/watch.d.ts +23 -0
- package/dist/store/watch.d.ts.map +1 -0
- package/dist/store.es.mjs +27 -0
- package/dist/store.es.mjs.map +1 -0
- package/dist/type-guards-DRma3-Kc.js +16 -0
- package/dist/type-guards-DRma3-Kc.js.map +1 -0
- package/dist/untrack-BuEQKH7_.js +6 -0
- package/dist/untrack-BuEQKH7_.js.map +1 -0
- package/dist/view/directives/bind.d.ts +7 -0
- package/dist/view/directives/bind.d.ts.map +1 -0
- package/dist/view/directives/class.d.ts +8 -0
- package/dist/view/directives/class.d.ts.map +1 -0
- package/dist/view/directives/for.d.ts +23 -0
- package/dist/view/directives/for.d.ts.map +1 -0
- package/dist/view/directives/html.d.ts +7 -0
- package/dist/view/directives/html.d.ts.map +1 -0
- package/dist/view/directives/if.d.ts +7 -0
- package/dist/view/directives/if.d.ts.map +1 -0
- package/dist/view/directives/index.d.ts +12 -0
- package/dist/view/directives/index.d.ts.map +1 -0
- package/dist/view/directives/model.d.ts +7 -0
- package/dist/view/directives/model.d.ts.map +1 -0
- package/dist/view/directives/on.d.ts +7 -0
- package/dist/view/directives/on.d.ts.map +1 -0
- package/dist/view/directives/ref.d.ts +7 -0
- package/dist/view/directives/ref.d.ts.map +1 -0
- package/dist/view/directives/show.d.ts +7 -0
- package/dist/view/directives/show.d.ts.map +1 -0
- package/dist/view/directives/style.d.ts +7 -0
- package/dist/view/directives/style.d.ts.map +1 -0
- package/dist/view/directives/text.d.ts +7 -0
- package/dist/view/directives/text.d.ts.map +1 -0
- package/dist/view/evaluate.d.ts +43 -0
- package/dist/view/evaluate.d.ts.map +1 -0
- package/dist/view/index.d.ts +111 -0
- package/dist/view/index.d.ts.map +1 -0
- package/dist/view/mount.d.ts +69 -0
- package/dist/view/mount.d.ts.map +1 -0
- package/dist/view/process.d.ts +26 -0
- package/dist/view/process.d.ts.map +1 -0
- package/dist/view/types.d.ts +36 -0
- package/dist/view/types.d.ts.map +1 -0
- package/dist/view.es.mjs +426 -0
- package/dist/view.es.mjs.map +1 -0
- package/dist/watch-CXyaBC_9.js +58 -0
- package/dist/watch-CXyaBC_9.js.map +1 -0
- package/package.json +26 -14
- package/src/component/component.ts +289 -0
- package/src/component/html.ts +53 -0
- package/src/component/index.ts +40 -414
- package/src/component/props.ts +116 -0
- package/src/component/types.ts +85 -0
- package/src/core/collection.ts +588 -454
- package/src/core/dom.ts +38 -0
- package/src/core/element.ts +746 -740
- package/src/core/index.ts +43 -0
- package/src/core/utils/array.ts +102 -0
- package/src/core/utils/function.ts +110 -0
- package/src/core/utils/index.ts +83 -0
- package/src/core/utils/misc.ts +82 -0
- package/src/core/utils/number.ts +78 -0
- package/src/core/utils/object.ts +206 -0
- package/src/core/utils/string.ts +112 -0
- package/src/core/utils/type-guards.ts +112 -0
- package/src/full.ts +187 -106
- package/src/index.ts +36 -27
- package/src/motion/animate.ts +113 -0
- package/src/motion/easing.ts +40 -0
- package/src/motion/flip.ts +176 -0
- package/src/motion/index.ts +41 -358
- package/src/motion/keyframes.ts +46 -0
- package/src/motion/reduced-motion.ts +17 -0
- package/src/motion/scroll.ts +57 -0
- package/src/motion/spring.ts +150 -0
- package/src/motion/stagger.ts +43 -0
- package/src/motion/timeline.ts +246 -0
- package/src/motion/transition.ts +51 -0
- package/src/motion/types.ts +198 -0
- package/src/reactive/batch.ts +22 -0
- package/src/reactive/computed.ts +92 -0
- package/src/reactive/core.ts +93 -0
- package/src/reactive/effect.ts +43 -0
- package/src/reactive/index.ts +23 -22
- package/src/reactive/internals.ts +105 -0
- package/src/reactive/linked.ts +56 -0
- package/src/reactive/persisted.ts +74 -0
- package/src/reactive/readonly.ts +35 -0
- package/src/reactive/signal.ts +20 -506
- package/src/reactive/type-guards.ts +22 -0
- package/src/reactive/untrack.ts +31 -0
- package/src/reactive/watch.ts +73 -0
- package/src/router/index.ts +41 -0
- package/src/router/links.ts +130 -0
- package/src/router/match.ts +106 -0
- package/src/router/navigation.ts +71 -0
- package/src/router/query.ts +35 -0
- package/src/router/router.ts +211 -0
- package/src/router/state.ts +46 -0
- package/src/router/types.ts +93 -0
- package/src/router/utils.ts +116 -0
- package/src/security/constants.ts +209 -0
- package/src/security/csp.ts +77 -0
- package/src/security/index.ts +4 -12
- package/src/security/sanitize-core.ts +343 -0
- package/src/security/sanitize.ts +66 -625
- package/src/security/trusted-types.ts +69 -0
- package/src/security/types.ts +40 -0
- package/src/store/create-store.ts +329 -0
- package/src/store/define-store.ts +48 -0
- package/src/store/devtools.ts +45 -0
- package/src/store/index.ts +22 -0
- package/src/store/mapping.ts +73 -0
- package/src/store/persisted.ts +61 -0
- package/src/store/plugins.ts +32 -0
- package/src/store/registry.ts +51 -0
- package/src/store/types.ts +94 -0
- package/src/store/utils.ts +141 -0
- package/src/store/watch.ts +52 -0
- package/src/view/directives/bind.ts +23 -0
- package/src/view/directives/class.ts +70 -0
- package/src/view/directives/for.ts +275 -0
- package/src/view/directives/html.ts +19 -0
- package/src/view/directives/if.ts +30 -0
- package/src/view/directives/index.ts +11 -0
- package/src/view/directives/model.ts +56 -0
- package/src/view/directives/on.ts +41 -0
- package/src/view/directives/ref.ts +41 -0
- package/src/view/directives/show.ts +26 -0
- package/src/view/directives/style.ts +47 -0
- package/src/view/directives/text.ts +15 -0
- package/src/view/evaluate.ts +274 -0
- package/src/view/index.ts +112 -0
- package/src/view/mount.ts +200 -0
- package/src/view/process.ts +92 -0
- package/src/view/types.ts +44 -0
- package/dist/core/utils.d.ts +0 -313
- package/dist/core/utils.d.ts.map +0 -1
- package/src/core/utils.ts +0 -444
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-4LAvfLE7.js","sources":["../src/reactive/batch.ts"],"sourcesContent":["/**\n * Batched reactive updates.\n */\n\nimport { beginBatch, endBatch } from './internals';\n\n/**\n * Batches multiple signal updates into a single notification cycle.\n *\n * Updates made inside the batch function are deferred until the batch\n * completes, preventing intermediate re-renders and improving performance.\n *\n * @param fn - Function containing multiple signal updates\n */\nexport const batch = (fn: () => void): void => {\n beginBatch();\n try {\n fn();\n } finally {\n endBatch();\n }\n};\n"],"names":["batch","fn","beginBatch","endBatch"],"mappings":";AAcO,MAAMA,IAAQ,CAACC,MAAyB;AAC7C,EAAAC,EAAA;AACA,MAAI;AACF,IAAAD,EAAA;AAAA,EACF,UAAA;AACE,IAAAE,EAAA;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Component factory and registry.
|
|
3
|
+
*
|
|
4
|
+
* @module bquery/component
|
|
5
|
+
*/
|
|
6
|
+
import type { ComponentDefinition } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a custom element class for a component definition.
|
|
9
|
+
*
|
|
10
|
+
* This is useful when you want to extend or register the class manually
|
|
11
|
+
* (e.g. with different tag names in tests or custom registries).
|
|
12
|
+
*
|
|
13
|
+
* @template TProps - Type of the component's props
|
|
14
|
+
* @param tagName - The custom element tag name (used for diagnostics)
|
|
15
|
+
* @param definition - The component configuration
|
|
16
|
+
*/
|
|
17
|
+
export declare const defineComponent: <TProps extends Record<string, unknown>>(tagName: string, definition: ComponentDefinition<TProps>) => typeof HTMLElement;
|
|
18
|
+
/**
|
|
19
|
+
* Defines and registers a custom Web Component.
|
|
20
|
+
*
|
|
21
|
+
* This function creates a new custom element with the given tag name
|
|
22
|
+
* and configuration. The component uses Shadow DOM for encapsulation
|
|
23
|
+
* and automatically re-renders when observed attributes change.
|
|
24
|
+
*
|
|
25
|
+
* @template TProps - Type of the component's props
|
|
26
|
+
* @param tagName - The custom element tag name (must contain a hyphen)
|
|
27
|
+
* @param definition - The component configuration
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* component('counter-button', {
|
|
32
|
+
* props: {
|
|
33
|
+
* start: { type: Number, default: 0 },
|
|
34
|
+
* },
|
|
35
|
+
* state: { count: 0 },
|
|
36
|
+
* styles: `
|
|
37
|
+
* button { padding: 0.5rem 1rem; }
|
|
38
|
+
* `,
|
|
39
|
+
* connected() {
|
|
40
|
+
* // Use event delegation on shadow root so handler survives re-renders
|
|
41
|
+
* const handleClick = (event: Event) => {
|
|
42
|
+
* const target = event.target as HTMLElement | null;
|
|
43
|
+
* if (target?.matches('button')) {
|
|
44
|
+
* this.setState('count', (this.getState('count') as number) + 1);
|
|
45
|
+
* }
|
|
46
|
+
* };
|
|
47
|
+
* this.shadowRoot?.addEventListener('click', handleClick);
|
|
48
|
+
* // Store handler for cleanup
|
|
49
|
+
* (this as any)._handleClick = handleClick;
|
|
50
|
+
* },
|
|
51
|
+
* disconnected() {
|
|
52
|
+
* // Clean up event listener to prevent memory leaks
|
|
53
|
+
* const handleClick = (this as any)._handleClick;
|
|
54
|
+
* if (handleClick) {
|
|
55
|
+
* this.shadowRoot?.removeEventListener('click', handleClick);
|
|
56
|
+
* }
|
|
57
|
+
* },
|
|
58
|
+
* render({ props, state }) {
|
|
59
|
+
* return html`
|
|
60
|
+
* <button>
|
|
61
|
+
* Count: ${state.count}
|
|
62
|
+
* </button>
|
|
63
|
+
* `;
|
|
64
|
+
* },
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare const component: <TProps extends Record<string, unknown>>(tagName: string, definition: ComponentDefinition<TProps>) => void;
|
|
69
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/component/component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,SAAS,CAAC;AAEnE;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpE,SAAS,MAAM,EACf,YAAY,mBAAmB,CAAC,MAAM,CAAC,KACtC,OAAO,WA4MT,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9D,SAAS,MAAM,EACf,YAAY,mBAAmB,CAAC,MAAM,CAAC,KACtC,IAMF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tagged template literal for creating HTML strings.
|
|
3
|
+
*
|
|
4
|
+
* This function handles interpolation of values into HTML templates,
|
|
5
|
+
* converting null/undefined to empty strings.
|
|
6
|
+
*
|
|
7
|
+
* @param strings - Template literal string parts
|
|
8
|
+
* @param values - Interpolated values
|
|
9
|
+
* @returns Combined HTML string
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const name = 'World';
|
|
14
|
+
* const greeting = html`<h1>Hello, ${name}!</h1>`;
|
|
15
|
+
* // Result: '<h1>Hello, World!</h1>'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => string;
|
|
19
|
+
/**
|
|
20
|
+
* Escapes HTML entities in interpolated values for XSS prevention.
|
|
21
|
+
* Use this when you need to safely embed user content in templates.
|
|
22
|
+
*
|
|
23
|
+
* @param strings - Template literal string parts
|
|
24
|
+
* @param values - Interpolated values to escape
|
|
25
|
+
* @returns Combined HTML string with escaped values
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const userInput = '<script>alert("xss")</script>';
|
|
30
|
+
* const safe = safeHtml`<div>${userInput}</div>`;
|
|
31
|
+
* // Result: '<div><script>alert("xss")</script></div>'
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const safeHtml: (strings: TemplateStringsArray, ...values: unknown[]) => string;
|
|
35
|
+
//# sourceMappingURL=html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/component/html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,IAAI,GAAI,SAAS,oBAAoB,EAAE,GAAG,QAAQ,OAAO,EAAE,KAAG,MAE1E,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ,GAAI,SAAS,oBAAoB,EAAE,GAAG,QAAQ,OAAO,EAAE,KAAG,MAgB9E,CAAC"}
|
|
@@ -34,130 +34,7 @@
|
|
|
34
34
|
* });
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* @template T - The TypeScript type of the prop value
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```ts
|
|
44
|
-
* const myProp: PropDefinition<number> = {
|
|
45
|
-
* type: Number,
|
|
46
|
-
* required: false,
|
|
47
|
-
* default: 0,
|
|
48
|
-
* };
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export type PropDefinition<T = unknown> = {
|
|
52
|
-
/** Constructor or converter function for the prop type */
|
|
53
|
-
type: StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor | {
|
|
54
|
-
new (value: unknown): T;
|
|
55
|
-
} | ((value: unknown) => T);
|
|
56
|
-
/** Whether the prop must be provided */
|
|
57
|
-
required?: boolean;
|
|
58
|
-
/** Default value when prop is not provided */
|
|
59
|
-
default?: T;
|
|
60
|
-
/** Optional validator function to validate prop values */
|
|
61
|
-
validator?: (value: T) => boolean;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Complete component definition including props, state, styles, and lifecycle.
|
|
65
|
-
*
|
|
66
|
-
* @template TProps - Type of the component's props
|
|
67
|
-
*/
|
|
68
|
-
export type ComponentDefinition<TProps extends Record<string, unknown> = Record<string, unknown>> = {
|
|
69
|
-
/** Prop definitions with types and defaults */
|
|
70
|
-
props?: Record<keyof TProps, PropDefinition>;
|
|
71
|
-
/** Initial internal state */
|
|
72
|
-
state?: Record<string, unknown>;
|
|
73
|
-
/** CSS styles scoped to the component's shadow DOM */
|
|
74
|
-
styles?: string;
|
|
75
|
-
/** Lifecycle hook called before the component mounts (before first render) */
|
|
76
|
-
beforeMount?: () => void;
|
|
77
|
-
/** Lifecycle hook called when component is added to DOM */
|
|
78
|
-
connected?: () => void;
|
|
79
|
-
/** Lifecycle hook called when component is removed from DOM */
|
|
80
|
-
disconnected?: () => void;
|
|
81
|
-
/** Lifecycle hook called before an update render; return false to prevent */
|
|
82
|
-
beforeUpdate?: (props: TProps) => boolean | void;
|
|
83
|
-
/** Lifecycle hook called after reactive updates trigger a render */
|
|
84
|
-
updated?: () => void;
|
|
85
|
-
/** Error handler for errors during rendering or lifecycle */
|
|
86
|
-
onError?: (error: Error) => void;
|
|
87
|
-
/** Render function returning HTML string */
|
|
88
|
-
render: (context: {
|
|
89
|
-
props: TProps;
|
|
90
|
-
state: Record<string, unknown>;
|
|
91
|
-
emit: (event: string, detail?: unknown) => void;
|
|
92
|
-
}) => string;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Tagged template literal for creating HTML strings.
|
|
96
|
-
*
|
|
97
|
-
* This function handles interpolation of values into HTML templates,
|
|
98
|
-
* converting null/undefined to empty strings.
|
|
99
|
-
*
|
|
100
|
-
* @param strings - Template literal string parts
|
|
101
|
-
* @param values - Interpolated values
|
|
102
|
-
* @returns Combined HTML string
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```ts
|
|
106
|
-
* const name = 'World';
|
|
107
|
-
* const greeting = html`<h1>Hello, ${name}!</h1>`;
|
|
108
|
-
* // Result: '<h1>Hello, World!</h1>'
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
export declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => string;
|
|
112
|
-
/**
|
|
113
|
-
* Escapes HTML entities in interpolated values for XSS prevention.
|
|
114
|
-
* Use this when you need to safely embed user content in templates.
|
|
115
|
-
*
|
|
116
|
-
* @param strings - Template literal string parts
|
|
117
|
-
* @param values - Interpolated values to escape
|
|
118
|
-
* @returns Combined HTML string with escaped values
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```ts
|
|
122
|
-
* const userInput = '<script>alert("xss")</script>';
|
|
123
|
-
* const safe = safeHtml`<div>${userInput}</div>`;
|
|
124
|
-
* // Result: '<div><script>alert("xss")</script></div>'
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
export declare const safeHtml: (strings: TemplateStringsArray, ...values: unknown[]) => string;
|
|
128
|
-
/**
|
|
129
|
-
* Defines and registers a custom Web Component.
|
|
130
|
-
*
|
|
131
|
-
* This function creates a new custom element with the given tag name
|
|
132
|
-
* and configuration. The component uses Shadow DOM for encapsulation
|
|
133
|
-
* and automatically re-renders when observed attributes change.
|
|
134
|
-
*
|
|
135
|
-
* @template TProps - Type of the component's props
|
|
136
|
-
* @param tagName - The custom element tag name (must contain a hyphen)
|
|
137
|
-
* @param definition - The component configuration
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```ts
|
|
141
|
-
* component('counter-button', {
|
|
142
|
-
* props: {
|
|
143
|
-
* start: { type: Number, default: 0 },
|
|
144
|
-
* },
|
|
145
|
-
* state: { count: 0 },
|
|
146
|
-
* styles: `
|
|
147
|
-
* button { padding: 0.5rem 1rem; }
|
|
148
|
-
* `,
|
|
149
|
-
* connected() {
|
|
150
|
-
* console.log('Counter mounted');
|
|
151
|
-
* },
|
|
152
|
-
* render({ props, state, emit }) {
|
|
153
|
-
* return html`
|
|
154
|
-
* <button onclick="this.getRootNode().host.increment()">
|
|
155
|
-
* Count: ${state.count}
|
|
156
|
-
* </button>
|
|
157
|
-
* `;
|
|
158
|
-
* },
|
|
159
|
-
* });
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
export declare const component: <TProps extends Record<string, unknown>>(tagName: string, definition: ComponentDefinition<TProps>) => void;
|
|
37
|
+
export { component, defineComponent } from './component';
|
|
38
|
+
export { html, safeHtml } from './html';
|
|
39
|
+
export type { ComponentDefinition, ComponentRenderContext, PropDefinition } from './types';
|
|
163
40
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/component/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/component/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop coercion utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module bquery/component
|
|
5
|
+
*/
|
|
6
|
+
import type { PropDefinition } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Coerces a string attribute value into a typed prop value.
|
|
9
|
+
* Supports String, Number, Boolean, Object, Array, and custom converters.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
* @template T - The target type
|
|
13
|
+
* @param rawValue - The raw string value from the attribute
|
|
14
|
+
* @param config - The prop definition with type information
|
|
15
|
+
* @returns The coerced value of type T
|
|
16
|
+
*/
|
|
17
|
+
export declare const coercePropValue: <T>(rawValue: string, config: PropDefinition<T>) => T;
|
|
18
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/component/props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,UAAU,MAAM,EAAE,QAAQ,cAAc,CAAC,CAAC,CAAC,KAAG,CAiGhF,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component types and render context definitions.
|
|
3
|
+
*
|
|
4
|
+
* @module bquery/component
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Defines a single prop's type and configuration.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The TypeScript type of the prop value
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const myProp: PropDefinition<number> = {
|
|
14
|
+
* type: Number,
|
|
15
|
+
* required: false,
|
|
16
|
+
* default: 0,
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export type PropDefinition<T = unknown> = {
|
|
21
|
+
/** Constructor or converter function for the prop type */
|
|
22
|
+
type: StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor | {
|
|
23
|
+
new (value: unknown): T;
|
|
24
|
+
} | ((value: unknown) => T);
|
|
25
|
+
/** Whether the prop must be provided */
|
|
26
|
+
required?: boolean;
|
|
27
|
+
/** Default value when prop is not provided */
|
|
28
|
+
default?: T;
|
|
29
|
+
/** Optional validator function to validate prop values */
|
|
30
|
+
validator?: (value: T) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Explicitly control whether to invoke `type` with `new` (constructor) or as a plain function.
|
|
33
|
+
* - `true`: Always use `new type(value)` (for class constructors, Date, etc.)
|
|
34
|
+
* - `false`: Always call `type(value)` (for converter functions)
|
|
35
|
+
* - `undefined` (default): Auto-detect based on heuristics with fallback
|
|
36
|
+
*/
|
|
37
|
+
construct?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Render context passed into a component render function.
|
|
41
|
+
*/
|
|
42
|
+
export type ComponentRenderContext<TProps extends Record<string, unknown>> = {
|
|
43
|
+
/** Typed props object populated from attributes */
|
|
44
|
+
props: TProps;
|
|
45
|
+
/** Internal mutable state object */
|
|
46
|
+
state: Record<string, unknown>;
|
|
47
|
+
/** Emit a custom event from the component */
|
|
48
|
+
emit: (event: string, detail?: unknown) => void;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Complete component definition including props, state, styles, and lifecycle.
|
|
52
|
+
*
|
|
53
|
+
* @template TProps - Type of the component's props
|
|
54
|
+
*/
|
|
55
|
+
export type ComponentDefinition<TProps extends Record<string, unknown> = Record<string, unknown>> = {
|
|
56
|
+
/** Prop definitions with types and defaults */
|
|
57
|
+
props?: Record<keyof TProps, PropDefinition>;
|
|
58
|
+
/** Initial internal state */
|
|
59
|
+
state?: Record<string, unknown>;
|
|
60
|
+
/** CSS styles scoped to the component's shadow DOM */
|
|
61
|
+
styles?: string;
|
|
62
|
+
/** Lifecycle hook called before the component mounts (before first render) */
|
|
63
|
+
beforeMount?: () => void;
|
|
64
|
+
/** Lifecycle hook called when component is added to DOM */
|
|
65
|
+
connected?: () => void;
|
|
66
|
+
/** Lifecycle hook called when component is removed from DOM */
|
|
67
|
+
disconnected?: () => void;
|
|
68
|
+
/** Lifecycle hook called before an update render; return false to prevent */
|
|
69
|
+
beforeUpdate?: (props: TProps) => boolean | void;
|
|
70
|
+
/** Lifecycle hook called after reactive updates trigger a render */
|
|
71
|
+
updated?: () => void;
|
|
72
|
+
/** Error handler for errors during rendering or lifecycle */
|
|
73
|
+
onError?: (error: Error) => void;
|
|
74
|
+
/** Render function returning HTML string */
|
|
75
|
+
render: (context: ComponentRenderContext<TProps>) => string;
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/component/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,0DAA0D;IAC1D,IAAI,EACA,iBAAiB,GACjB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,gBAAgB,GAChB;QAAE,KAAK,KAAK,EAAE,OAAO,GAAG,CAAC,CAAA;KAAE,GAC3B,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC;IAC5B,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,0DAA0D;IAC1D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IAClC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IAC3E,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,6CAA6C;IAC7C,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC9F;IACE,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,6EAA6E;IAC7E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;IACjD,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,4CAA4C;IAC5C,MAAM,EAAE,CAAC,OAAO,EAAE,sBAAsB,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC;CAC7D,CAAC"}
|
package/dist/component.es.mjs
CHANGED
|
@@ -1,43 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (
|
|
5
|
-
|
|
6
|
-
return Number
|
|
1
|
+
import { s as h } from "./sanitize-1FBEPAFH.js";
|
|
2
|
+
const p = (e, r) => {
|
|
3
|
+
const { type: s } = r;
|
|
4
|
+
if (s === String) return e;
|
|
5
|
+
if (s === Number)
|
|
6
|
+
return Number(e);
|
|
7
|
+
if (s === Boolean) {
|
|
8
|
+
const c = e.trim().toLowerCase();
|
|
9
|
+
return c === "" || c === "true" || c === "1" ? !0 : c === "false" || c === "0" ? !1 : !!e;
|
|
7
10
|
}
|
|
8
|
-
if (
|
|
9
|
-
const s = e.trim().toLowerCase();
|
|
10
|
-
return s === "" || s === "true" || s === "1" ? !0 : s === "false" || s === "0" ? !1 : !!e;
|
|
11
|
-
}
|
|
12
|
-
if (o === Object || o === Array)
|
|
11
|
+
if (s === Object || s === Array)
|
|
13
12
|
try {
|
|
14
13
|
return JSON.parse(e);
|
|
15
14
|
} catch {
|
|
16
15
|
return e;
|
|
17
16
|
}
|
|
18
|
-
if (typeof
|
|
19
|
-
const
|
|
17
|
+
if (typeof s == "function") {
|
|
18
|
+
const c = s, t = s;
|
|
19
|
+
if (r.construct === !0)
|
|
20
|
+
return Reflect.construct(t, [e]);
|
|
21
|
+
if (r.construct === !1)
|
|
22
|
+
return c(e);
|
|
23
|
+
const o = s.prototype !== void 0 && s.prototype !== null, u = (o ? Object.getOwnPropertyNames(s.prototype) : []).length > 1, n = o && s.prototype.constructor !== s, l = /^class\s/.test(Function.prototype.toString.call(s));
|
|
24
|
+
if (u || n || l)
|
|
25
|
+
try {
|
|
26
|
+
return Reflect.construct(t, [e]);
|
|
27
|
+
} catch {
|
|
28
|
+
return c(e);
|
|
29
|
+
}
|
|
20
30
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
const a = c(e);
|
|
32
|
+
if (a === void 0 && o)
|
|
33
|
+
try {
|
|
34
|
+
return Reflect.construct(t, [e]);
|
|
35
|
+
} catch {
|
|
36
|
+
return a;
|
|
37
|
+
}
|
|
38
|
+
return a;
|
|
39
|
+
} catch (a) {
|
|
40
|
+
if (a instanceof TypeError && /cannot be invoked without 'new'|is not a function/i.test(a.message))
|
|
41
|
+
return Reflect.construct(t, [e]);
|
|
42
|
+
throw a;
|
|
24
43
|
}
|
|
25
44
|
}
|
|
26
45
|
return e;
|
|
27
|
-
}, p = (e, ...r) => e.reduce((o, s, t) => `${o}${s}${r[t] ?? ""}`, ""), i = (e, ...r) => {
|
|
28
|
-
const o = {
|
|
29
|
-
"&": "&",
|
|
30
|
-
"<": "<",
|
|
31
|
-
">": ">",
|
|
32
|
-
'"': """,
|
|
33
|
-
"'": "'",
|
|
34
|
-
"`": "`"
|
|
35
|
-
}, s = (t) => String(t ?? "").replace(/[&<>"'`]/g, (n) => o[n]);
|
|
36
|
-
return e.reduce((t, c, n) => `${t}${c}${s(r[n])}`, "");
|
|
37
46
|
}, d = (e, r) => {
|
|
38
|
-
class
|
|
47
|
+
class s extends HTMLElement {
|
|
39
48
|
constructor() {
|
|
40
|
-
super(), this.state = { ...r.state ?? {} }, this.props = {}, this.attachShadow({ mode: "open" }), this.syncProps();
|
|
49
|
+
super(), this.state = { ...r.state ?? {} }, this.props = {}, this.missingRequiredProps = /* @__PURE__ */ new Set(), this.hasMounted = !1, this.attachShadow({ mode: "open" }), this.syncProps();
|
|
41
50
|
}
|
|
42
51
|
/**
|
|
43
52
|
* Returns the list of attributes to observe for changes.
|
|
@@ -50,11 +59,21 @@ const u = (e, r) => {
|
|
|
50
59
|
*/
|
|
51
60
|
connectedCallback() {
|
|
52
61
|
try {
|
|
53
|
-
|
|
62
|
+
if (this.missingRequiredProps.size > 0)
|
|
63
|
+
return;
|
|
64
|
+
this.mount();
|
|
54
65
|
} catch (t) {
|
|
55
66
|
this.handleError(t);
|
|
56
67
|
}
|
|
57
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Performs the initial mount of the component.
|
|
71
|
+
* Called when the element is connected and all required props are present.
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
mount() {
|
|
75
|
+
this.hasMounted || (r.beforeMount?.call(this), r.connected?.call(this), this.render(), this.hasMounted = !0);
|
|
76
|
+
}
|
|
58
77
|
/**
|
|
59
78
|
* Called when the element is removed from the DOM.
|
|
60
79
|
*/
|
|
@@ -68,11 +87,11 @@ const u = (e, r) => {
|
|
|
68
87
|
/**
|
|
69
88
|
* Called when an observed attribute changes.
|
|
70
89
|
*/
|
|
71
|
-
attributeChangedCallback() {
|
|
90
|
+
attributeChangedCallback(t, o, i) {
|
|
72
91
|
try {
|
|
73
|
-
this.syncProps(), this.render(!0);
|
|
74
|
-
} catch (
|
|
75
|
-
this.handleError(
|
|
92
|
+
this.syncProps(), this.hasMounted ? this.render(!0) : this.isConnected && this.missingRequiredProps.size === 0 && this.mount();
|
|
93
|
+
} catch (u) {
|
|
94
|
+
this.handleError(u);
|
|
76
95
|
}
|
|
77
96
|
}
|
|
78
97
|
/**
|
|
@@ -88,8 +107,8 @@ const u = (e, r) => {
|
|
|
88
107
|
* @param key - The state property key
|
|
89
108
|
* @param value - The new value
|
|
90
109
|
*/
|
|
91
|
-
setState(t,
|
|
92
|
-
this.state[t] =
|
|
110
|
+
setState(t, o) {
|
|
111
|
+
this.state[t] = o, this.render(!0);
|
|
93
112
|
}
|
|
94
113
|
/**
|
|
95
114
|
* Gets a state property value.
|
|
@@ -106,20 +125,14 @@ const u = (e, r) => {
|
|
|
106
125
|
*/
|
|
107
126
|
syncProps() {
|
|
108
127
|
const t = r.props ?? {};
|
|
109
|
-
for (const [
|
|
110
|
-
const
|
|
111
|
-
let
|
|
112
|
-
if (
|
|
113
|
-
if (n.required && n.default === void 0)
|
|
114
|
-
throw new Error(`bQuery component: missing required prop "${c}"`);
|
|
115
|
-
a = n.default ?? void 0;
|
|
116
|
-
} else
|
|
117
|
-
a = u(l, n);
|
|
118
|
-
if (n.validator && a !== void 0 && !n.validator(a))
|
|
128
|
+
for (const [o, i] of Object.entries(t)) {
|
|
129
|
+
const u = this.getAttribute(o);
|
|
130
|
+
let n;
|
|
131
|
+
if (u == null ? i.required && i.default === void 0 ? (this.missingRequiredProps.add(o), n = void 0) : n = i.default ?? void 0 : (this.missingRequiredProps.has(o) && this.missingRequiredProps.delete(o), n = p(u, i)), i.validator && n !== void 0 && !i.validator(n))
|
|
119
132
|
throw new Error(
|
|
120
|
-
`bQuery component: validation failed for prop "${
|
|
133
|
+
`bQuery component: validation failed for prop "${o}" with value ${JSON.stringify(n)}`
|
|
121
134
|
);
|
|
122
|
-
this.props[
|
|
135
|
+
this.props[o] = n;
|
|
123
136
|
}
|
|
124
137
|
}
|
|
125
138
|
/**
|
|
@@ -130,26 +143,44 @@ const u = (e, r) => {
|
|
|
130
143
|
try {
|
|
131
144
|
if (t && r.beforeUpdate && r.beforeUpdate.call(this, this.props) === !1)
|
|
132
145
|
return;
|
|
133
|
-
const
|
|
134
|
-
this.dispatchEvent(new CustomEvent(
|
|
146
|
+
const o = (n, l) => {
|
|
147
|
+
this.dispatchEvent(new CustomEvent(n, { detail: l, bubbles: !0, composed: !0 }));
|
|
135
148
|
};
|
|
136
149
|
if (!this.shadowRoot) return;
|
|
137
|
-
const
|
|
150
|
+
const i = r.render({
|
|
138
151
|
props: this.props,
|
|
139
152
|
state: this.state,
|
|
140
|
-
emit:
|
|
141
|
-
}),
|
|
142
|
-
this.shadowRoot.innerHTML =
|
|
143
|
-
|
|
144
|
-
|
|
153
|
+
emit: o
|
|
154
|
+
}), u = h(i);
|
|
155
|
+
if (this.shadowRoot.innerHTML = u, r.styles) {
|
|
156
|
+
const n = document.createElement("style");
|
|
157
|
+
n.textContent = r.styles, this.shadowRoot.prepend(n);
|
|
158
|
+
}
|
|
159
|
+
t && r.updated?.call(this);
|
|
160
|
+
} catch (o) {
|
|
161
|
+
this.handleError(o);
|
|
145
162
|
}
|
|
146
163
|
}
|
|
147
164
|
}
|
|
148
|
-
|
|
165
|
+
return s;
|
|
166
|
+
}, b = (e, r) => {
|
|
167
|
+
const s = d(e, r);
|
|
168
|
+
customElements.get(e) || customElements.define(e, s);
|
|
169
|
+
}, E = (e, ...r) => e.reduce((s, c, t) => `${s}${c}${r[t] ?? ""}`, ""), g = (e, ...r) => {
|
|
170
|
+
const s = {
|
|
171
|
+
"&": "&",
|
|
172
|
+
"<": "<",
|
|
173
|
+
">": ">",
|
|
174
|
+
'"': """,
|
|
175
|
+
"'": "'",
|
|
176
|
+
"`": "`"
|
|
177
|
+
}, c = (t) => String(t ?? "").replace(/[&<>"'`]/g, (i) => s[i]);
|
|
178
|
+
return e.reduce((t, o, i) => `${t}${o}${c(r[i])}`, "");
|
|
149
179
|
};
|
|
150
180
|
export {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
181
|
+
b as component,
|
|
182
|
+
d as defineComponent,
|
|
183
|
+
E as html,
|
|
184
|
+
g as safeHtml
|
|
154
185
|
};
|
|
155
186
|
//# sourceMappingURL=component.es.mjs.map
|