@vielzeug/ore 1.2.3 → 2.0.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 +11 -8
- package/dist/_component-class.cjs +2 -0
- package/dist/_component-class.cjs.map +1 -0
- package/dist/_component-class.d.ts +2 -0
- package/dist/_component-class.d.ts.map +1 -0
- package/dist/_component-class.js +2 -0
- package/dist/_component-class.js.map +1 -0
- package/dist/_dev.cjs +1 -1
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js +1 -1
- package/dist/_dev.js.map +1 -1
- package/dist/base-element.cjs +1 -1
- package/dist/base-element.cjs.map +1 -1
- package/dist/base-element.d.ts +9 -15
- package/dist/base-element.d.ts.map +1 -1
- package/dist/base-element.js +1 -1
- package/dist/base-element.js.map +1 -1
- package/dist/component-types.d.ts +3 -14
- package/dist/component-types.d.ts.map +1 -1
- package/dist/context.cjs +1 -1
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.ts +13 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/context.js.map +1 -1
- package/dist/define.cjs +1 -1
- package/dist/define.cjs.map +1 -1
- package/dist/define.d.ts +6 -5
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +1 -1
- package/dist/define.js.map +1 -1
- package/dist/directives/classMap.cjs +1 -1
- package/dist/directives/classMap.cjs.map +1 -1
- package/dist/directives/classMap.d.ts.map +1 -1
- package/dist/directives/classMap.js +1 -1
- package/dist/directives/classMap.js.map +1 -1
- package/dist/directives/each.cjs +1 -1
- package/dist/directives/each.cjs.map +1 -1
- package/dist/directives/each.d.ts +9 -2
- package/dist/directives/each.d.ts.map +1 -1
- package/dist/directives/each.js +1 -1
- package/dist/directives/each.js.map +1 -1
- package/dist/directives/live.cjs +1 -1
- package/dist/directives/live.cjs.map +1 -1
- package/dist/directives/live.d.ts +10 -12
- package/dist/directives/live.d.ts.map +1 -1
- package/dist/directives/live.js +1 -1
- package/dist/directives/live.js.map +1 -1
- package/dist/directives/styleMap.cjs +1 -1
- package/dist/directives/styleMap.cjs.map +1 -1
- package/dist/directives/styleMap.d.ts +1 -1
- package/dist/directives/styleMap.d.ts.map +1 -1
- package/dist/directives/styleMap.js +1 -1
- package/dist/directives/styleMap.js.map +1 -1
- package/dist/directives/unsafe-html.cjs +2 -0
- package/dist/directives/unsafe-html.cjs.map +1 -0
- package/dist/directives/unsafe-html.d.ts +14 -0
- package/dist/directives/unsafe-html.d.ts.map +1 -0
- package/dist/directives/unsafe-html.js +2 -0
- package/dist/directives/unsafe-html.js.map +1 -0
- package/dist/directives/when.cjs +1 -1
- package/dist/directives/when.cjs.map +1 -1
- package/dist/directives/when.d.ts +1 -1
- package/dist/directives/when.d.ts.map +1 -1
- package/dist/directives/when.js +1 -1
- package/dist/directives/when.js.map +1 -1
- package/dist/errors.cjs +2 -2
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +21 -6
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -2
- package/dist/errors.js.map +1 -1
- package/dist/forms/field.cjs +1 -1
- package/dist/forms/field.cjs.map +1 -1
- package/dist/forms/field.d.ts +5 -1
- package/dist/forms/field.d.ts.map +1 -1
- package/dist/forms/field.js +1 -1
- package/dist/forms/field.js.map +1 -1
- package/dist/host-bind.cjs +1 -1
- package/dist/host-bind.cjs.map +1 -1
- package/dist/host-bind.d.ts +6 -0
- package/dist/host-bind.d.ts.map +1 -1
- package/dist/host-bind.js +1 -1
- package/dist/host-bind.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/observers/intersection-observe.cjs +1 -1
- package/dist/observers/intersection-observe.cjs.map +1 -1
- package/dist/observers/intersection-observe.d.ts.map +1 -1
- package/dist/observers/intersection-observe.js +1 -1
- package/dist/observers/intersection-observe.js.map +1 -1
- package/dist/observers/media-observe.cjs +1 -1
- package/dist/observers/media-observe.cjs.map +1 -1
- package/dist/observers/media-observe.d.ts.map +1 -1
- package/dist/observers/media-observe.js +1 -1
- package/dist/observers/media-observe.js.map +1 -1
- package/dist/observers/mutation-observe.cjs +1 -1
- package/dist/observers/mutation-observe.cjs.map +1 -1
- package/dist/observers/mutation-observe.d.ts.map +1 -1
- package/dist/observers/mutation-observe.js +1 -1
- package/dist/observers/mutation-observe.js.map +1 -1
- package/dist/observers/resize-observe.cjs +1 -1
- package/dist/observers/resize-observe.cjs.map +1 -1
- package/dist/observers/resize-observe.d.ts.map +1 -1
- package/dist/observers/resize-observe.js +1 -1
- package/dist/observers/resize-observe.js.map +1 -1
- package/dist/ore.cjs +2 -2
- package/dist/ore.cjs.map +1 -1
- package/dist/ore.iife.js +2 -2
- package/dist/ore.iife.js.map +1 -1
- package/dist/ore.js +2 -2
- package/dist/ore.js.map +1 -1
- package/dist/props.cjs +1 -1
- package/dist/props.cjs.map +1 -1
- package/dist/props.d.ts +1 -6
- package/dist/props.d.ts.map +1 -1
- package/dist/props.js +1 -1
- package/dist/props.js.map +1 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.ts +7 -10
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/slots.cjs +1 -1
- package/dist/slots.cjs.map +1 -1
- package/dist/slots.d.ts.map +1 -1
- package/dist/slots.js +1 -1
- package/dist/slots.js.map +1 -1
- package/dist/template/binding-types.cjs +1 -0
- package/dist/template/binding-types.d.ts +59 -0
- package/dist/template/binding-types.d.ts.map +1 -0
- package/dist/template/binding-types.js +1 -0
- package/dist/template/bindings.cjs +1 -1
- package/dist/template/bindings.cjs.map +1 -1
- package/dist/template/bindings.d.ts +18 -3
- package/dist/template/bindings.d.ts.map +1 -1
- package/dist/template/bindings.js +1 -1
- package/dist/template/bindings.js.map +1 -1
- package/dist/template/compiler.cjs +1 -1
- package/dist/template/compiler.cjs.map +1 -1
- package/dist/template/compiler.d.ts +0 -4
- package/dist/template/compiler.d.ts.map +1 -1
- package/dist/template/compiler.js +1 -1
- package/dist/template/compiler.js.map +1 -1
- package/dist/template/instantiator.cjs +1 -1
- package/dist/template/instantiator.cjs.map +1 -1
- package/dist/template/instantiator.d.ts +6 -1
- package/dist/template/instantiator.d.ts.map +1 -1
- package/dist/template/instantiator.js +1 -1
- package/dist/template/instantiator.js.map +1 -1
- package/dist/template/result.cjs +2 -0
- package/dist/template/result.cjs.map +1 -0
- package/dist/template/result.d.ts +42 -0
- package/dist/template/result.d.ts.map +1 -0
- package/dist/template/result.js +2 -0
- package/dist/template/result.js.map +1 -0
- package/dist/testing/flush.cjs +1 -1
- package/dist/testing/flush.cjs.map +1 -1
- package/dist/testing/flush.d.ts +30 -26
- package/dist/testing/flush.d.ts.map +1 -1
- package/dist/testing/flush.js +1 -1
- package/dist/testing/flush.js.map +1 -1
- package/dist/testing/form-internals-polyfill.cjs +1 -1
- package/dist/testing/form-internals-polyfill.cjs.map +1 -1
- package/dist/testing/form-internals-polyfill.d.ts +9 -7
- package/dist/testing/form-internals-polyfill.d.ts.map +1 -1
- package/dist/testing/form-internals-polyfill.js +1 -1
- package/dist/testing/form-internals-polyfill.js.map +1 -1
- package/dist/testing/index.d.ts +35 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/mount.cjs +1 -1
- package/dist/testing/mount.cjs.map +1 -1
- package/dist/testing/mount.d.ts +10 -19
- package/dist/testing/mount.d.ts.map +1 -1
- package/dist/testing/mount.js +1 -1
- package/dist/testing/mount.js.map +1 -1
- package/dist/testing/render-hook.cjs +1 -1
- package/dist/testing/render-hook.cjs.map +1 -1
- package/dist/testing/render-hook.js +1 -1
- package/dist/testing/render-hook.js.map +1 -1
- package/dist/testing/reset.cjs +2 -0
- package/dist/testing/reset.cjs.map +1 -0
- package/dist/testing/reset.d.ts +12 -0
- package/dist/testing/reset.d.ts.map +1 -0
- package/dist/testing/reset.js +2 -0
- package/dist/testing/reset.js.map +1 -0
- package/dist/testing.cjs +2 -1
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.js +2 -1
- package/dist/testing.js.map +1 -0
- package/dist/utils/aria.cjs.map +1 -1
- package/dist/utils/aria.d.ts +1 -1
- package/dist/utils/aria.js.map +1 -1
- package/dist/utils/brand.cjs +2 -0
- package/dist/utils/brand.cjs.map +1 -0
- package/dist/utils/brand.d.ts +16 -0
- package/dist/utils/brand.d.ts.map +1 -0
- package/dist/utils/brand.js +2 -0
- package/dist/utils/brand.js.map +1 -0
- package/dist/utils/css.cjs +1 -1
- package/dist/utils/css.cjs.map +1 -1
- package/dist/utils/css.d.ts.map +1 -1
- package/dist/utils/css.js +1 -1
- package/dist/utils/css.js.map +1 -1
- package/dist/utils/dom.cjs +1 -1
- package/dist/utils/dom.cjs.map +1 -1
- package/dist/utils/dom.d.ts +34 -0
- package/dist/utils/dom.d.ts.map +1 -1
- package/dist/utils/dom.js +1 -1
- package/dist/utils/dom.js.map +1 -1
- package/dist/utils/emit.cjs.map +1 -1
- package/dist/utils/emit.d.ts +10 -3
- package/dist/utils/emit.d.ts.map +1 -1
- package/dist/utils/emit.js.map +1 -1
- package/dist/utils/id.cjs +1 -1
- package/dist/utils/id.cjs.map +1 -1
- package/dist/utils/id.d.ts +11 -2
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +1 -1
- package/dist/utils/id.js.map +1 -1
- package/package.json +15 -30
- package/dist/aria.cjs +0 -2
- package/dist/aria.cjs.map +0 -1
- package/dist/aria.d.ts +0 -20
- package/dist/aria.d.ts.map +0 -1
- package/dist/aria.js +0 -2
- package/dist/aria.js.map +0 -1
- package/dist/devtools.cjs +0 -2
- package/dist/devtools.cjs.map +0 -1
- package/dist/devtools.d.ts +0 -32
- package/dist/devtools.d.ts.map +0 -1
- package/dist/devtools.js +0 -2
- package/dist/devtools.js.map +0 -1
- package/dist/directives/index.d.ts +0 -8
- package/dist/directives/index.d.ts.map +0 -1
- package/dist/directives/model.cjs +0 -2
- package/dist/directives/model.cjs.map +0 -1
- package/dist/directives/model.d.ts +0 -28
- package/dist/directives/model.d.ts.map +0 -1
- package/dist/directives/model.js +0 -2
- package/dist/directives/model.js.map +0 -1
- package/dist/directives/raw.cjs +0 -2
- package/dist/directives/raw.cjs.map +0 -1
- package/dist/directives/raw.d.ts +0 -16
- package/dist/directives/raw.d.ts.map +0 -1
- package/dist/directives/raw.js +0 -2
- package/dist/directives/raw.js.map +0 -1
- package/dist/directives.cjs +0 -1
- package/dist/directives.js +0 -1
- package/dist/forms/context.cjs +0 -2
- package/dist/forms/context.cjs.map +0 -1
- package/dist/forms/context.d.ts +0 -56
- package/dist/forms/context.d.ts.map +0 -1
- package/dist/forms/context.js +0 -2
- package/dist/forms/context.js.map +0 -1
- package/dist/forms/index.d.ts +0 -11
- package/dist/forms/index.d.ts.map +0 -1
- package/dist/forms.cjs +0 -1
- package/dist/forms.js +0 -1
- package/dist/observers/index.d.ts +0 -5
- package/dist/observers/index.d.ts.map +0 -1
- package/dist/observers.cjs +0 -1
- package/dist/observers.js +0 -1
- package/dist/template.cjs +0 -1
- package/dist/template.d.ts +0 -4
- package/dist/template.d.ts.map +0 -1
- package/dist/template.js +0 -1
- package/dist/testing/events.cjs +0 -2
- package/dist/testing/events.cjs.map +0 -1
- package/dist/testing/events.d.ts +0 -37
- package/dist/testing/events.d.ts.map +0 -1
- package/dist/testing/events.js +0 -2
- package/dist/testing/events.js.map +0 -1
- package/dist/testing/interactions.cjs +0 -2
- package/dist/testing/interactions.cjs.map +0 -1
- package/dist/testing/interactions.d.ts +0 -27
- package/dist/testing/interactions.d.ts.map +0 -1
- package/dist/testing/interactions.js +0 -2
- package/dist/testing/interactions.js.map +0 -1
- package/dist/testing/query.cjs +0 -2
- package/dist/testing/query.cjs.map +0 -1
- package/dist/testing/query.d.ts +0 -24
- package/dist/testing/query.d.ts.map +0 -1
- package/dist/testing/query.js +0 -2
- package/dist/testing/query.js.map +0 -1
- package/dist/testing/testing.cjs +0 -2
- package/dist/testing/testing.cjs.map +0 -1
- package/dist/testing/testing.d.ts +0 -32
- package/dist/testing/testing.d.ts.map +0 -1
- package/dist/testing/testing.js +0 -2
- package/dist/testing/testing.js.map +0 -1
- package/dist/testing/wait.cjs +0 -2
- package/dist/testing/wait.cjs.map +0 -1
- package/dist/testing/wait.d.ts +0 -35
- package/dist/testing/wait.d.ts.map +0 -1
- package/dist/testing/wait.js +0 -2
- package/dist/testing/wait.js.map +0 -1
- package/dist/types/bindings.cjs +0 -2
- package/dist/types/bindings.cjs.map +0 -1
- package/dist/types/bindings.d.ts +0 -125
- package/dist/types/bindings.d.ts.map +0 -1
- package/dist/types/bindings.js +0 -2
- package/dist/types/bindings.js.map +0 -1
- package/dist/types.cjs +0 -2
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.ts +0 -19
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/event-modifiers.cjs +0 -2
- package/dist/utils/event-modifiers.cjs.map +0 -1
- package/dist/utils/event-modifiers.d.ts +0 -11
- package/dist/utils/event-modifiers.d.ts.map +0 -1
- package/dist/utils/event-modifiers.js +0 -2
- package/dist/utils/event-modifiers.js.map +0 -1
package/dist/directives.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./directives/classMap.cjs"),t=require("./directives/each.cjs"),n=require("./directives/live.cjs"),r=require("./directives/model.cjs"),i=require("./directives/raw.cjs"),a=require("./directives/styleMap.cjs"),o=require("./directives/when.cjs");exports.classMap=e.classMap,exports.each=t.each,exports.live=n.live,exports.model=r.model,exports.raw=i.raw,exports.setRawSanitizer=i.setRawSanitizer,exports.styleMap=a.styleMap,exports.when=o.when;
|
package/dist/directives.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{classMap as e}from"./directives/classMap.js";import{each as t}from"./directives/each.js";import{live as n}from"./directives/live.js";import{model as r}from"./directives/model.js";import{raw as i,setRawSanitizer as a}from"./directives/raw.js";import{styleMap as o}from"./directives/styleMap.js";import{when as s}from"./directives/when.js";export{e as classMap,t as each,n as live,r as model,i as raw,a as setRawSanitizer,o as styleMap,s as when};
|
package/dist/forms/context.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("../context.cjs");let t=require("@vielzeug/ripple");var n=e.createContext(`ore:form-context`);function r(e={}){let n=(0,t.signal)([]),r=(0,t.signal)(!1),i=(0,t.signal)(!1),a=(0,t.signal)(null);return{clearStatus:()=>{i.value=!1,a.value=null,e.onReset?.()},dirty:i,error:a,markDirty:()=>{i.value=!0},registerField:e=>(n.value=[...n.value,e],()=>{n.value=n.value.filter(t=>t!==e)}),submit:async t=>{if(t?.preventDefault(),!r.value){r.value=!0,a.value=null;try{await e.onSubmit?.(t),i.value=!1}catch(e){a.value=e}finally{r.value=!1}}},submitting:r,valid:(0,t.computed)(()=>n.value.every(e=>e.value))}}exports.FORM_CONTEXT_KEY=n,exports.createFormContext=r;
|
|
2
|
-
//# sourceMappingURL=context.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.cjs","names":[],"sources":["../../src/forms/context.ts"],"sourcesContent":["import { computed, type Readable, signal } from '@vielzeug/ripple';\n\nimport { createContext } from '../context';\n\n/**\n * Context shape injected by child field components.\n * Contains only what a field needs — not submit/error/status APIs.\n */\nexport type FormFieldContext = {\n /** Whether any field has been touched (interacted with). Set via markDirty(). */\n readonly dirty: Readable<boolean>;\n markDirty(): void;\n /**\n * Register a field's validity signal with the form context.\n * Returns a cleanup function.\n */\n registerField(validity: Readable<boolean>): () => void;\n};\n\n/**\n * Full form controller returned by `createFormContext`.\n * Extends `FormFieldContext` with submission and status APIs.\n */\nexport type FormController = FormFieldContext & {\n /**\n * Clear `dirty` and `error` status signals and invoke `onReset` if provided.\n * Note: this does not reset individual field values — pass an `onReset` callback\n * to handle value restoration.\n */\n clearStatus(): void;\n /** The last submit error, or null if the last submit succeeded. */\n readonly error: Readable<unknown>;\n /** Submit the form programmatically. */\n submit(e?: Event): Promise<void>;\n /** Whether the form is currently submitting. */\n readonly submitting: Readable<boolean>;\n /** Whether all fields in the form are valid. */\n readonly valid: Readable<boolean>;\n};\n\nexport const FORM_CONTEXT_KEY = createContext<FormFieldContext>('ore:form-context');\n\n/**\n * Create a `FormController` for coordinating form state across child field components.\n * Call `provide(FORM_CONTEXT_KEY, form)` to make it available to descendants.\n *\n * @example\n * ```ts\n * define('my-form', {\n * setup(_props) {\n * const form = createFormContext({ onSubmit: async (e) => { ... } });\n * provide(FORM_CONTEXT_KEY, form);\n * return html`<form @submit=${form.submit}><slot></slot></form>`;\n * }\n * });\n * ```\n */\nexport function createFormContext(\n options: {\n onReset?: () => void;\n onSubmit?: (e?: Event) => void | Promise<void>;\n } = {},\n): FormController {\n const fieldValiditySignals = signal<Array<Readable<boolean>>>([]);\n const submitting = signal(false);\n const dirty = signal(false);\n const error = signal<unknown>(null);\n\n // Note: [].every() is vacuously true, so valid is true when no fields are registered.\n // This is intentional — a form with no fields is considered valid (nothing to invalidate it).\n const valid = computed(() => fieldValiditySignals.value.every((s) => s.value));\n\n const submit = async (e?: Event): Promise<void> => {\n e?.preventDefault();\n\n if (submitting.value) return;\n\n submitting.value = true;\n error.value = null;\n\n try {\n await options.onSubmit?.(e);\n dirty.value = false;\n } catch (err) {\n error.value = err;\n } finally {\n submitting.value = false;\n }\n };\n\n const clearStatus = (): void => {\n dirty.value = false;\n error.value = null;\n options.onReset?.();\n };\n\n const markDirty = (): void => {\n dirty.value = true;\n };\n\n const registerField = (validity: Readable<boolean>): (() => void) => {\n fieldValiditySignals.value = [...fieldValiditySignals.value, validity];\n\n return () => {\n fieldValiditySignals.value = fieldValiditySignals.value.filter((s) => s !== validity);\n };\n };\n\n return { clearStatus, dirty, error, markDirty, registerField, submit, submitting, valid };\n}\n"],"mappings":"oEAwCA,IAAa,EAAmB,EAAA,cAAgC,kBAAkB,EAiBlF,SAAgB,EACd,EAGI,CAAC,EACW,CAChB,IAAM,GAAA,EAAA,EAAA,OAAA,CAAwD,CAAC,CAAC,EAC1D,GAAA,EAAA,EAAA,OAAA,CAAoB,EAAK,EACzB,GAAA,EAAA,EAAA,OAAA,CAAe,EAAK,EACpB,GAAA,EAAA,EAAA,OAAA,CAAwB,IAAI,EA0ClC,MAAO,CAAE,gBAlBuB,CAC9B,EAAM,MAAQ,GACd,EAAM,MAAQ,KACd,EAAQ,UAAU,CACpB,EAcsB,QAAO,QAAO,cAZN,CAC5B,EAAM,MAAQ,EAChB,EAU+C,cARxB,IACrB,EAAqB,MAAQ,CAAC,GAAG,EAAqB,MAAO,CAAQ,MAExD,CACX,EAAqB,MAAQ,EAAqB,MAAM,OAAQ,GAAM,IAAM,CAAQ,CACtF,GAG4D,YApCxC,IAA6B,CACjD,MAAG,eAAe,EAEd,GAAW,MAGf,CADA,EAAW,MAAQ,GACnB,EAAM,MAAQ,KAEd,GAAI,CACF,MAAM,EAAQ,WAAW,CAAC,EAC1B,EAAM,MAAQ,EAChB,OAAS,EAAK,CACZ,EAAM,MAAQ,CAChB,QAAU,CACR,EAAW,MAAQ,EACrB,CATc,CAUhB,EAoBsE,aAAY,OAtC5E,EAAA,EAAA,SAAA,KAAuB,EAAqB,MAAM,MAAO,GAAM,EAAE,KAAK,CAsCM,CAAM,CAC1F"}
|
package/dist/forms/context.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { type Readable } from '@vielzeug/ripple';
|
|
2
|
-
/**
|
|
3
|
-
* Context shape injected by child field components.
|
|
4
|
-
* Contains only what a field needs — not submit/error/status APIs.
|
|
5
|
-
*/
|
|
6
|
-
export type FormFieldContext = {
|
|
7
|
-
/** Whether any field has been touched (interacted with). Set via markDirty(). */
|
|
8
|
-
readonly dirty: Readable<boolean>;
|
|
9
|
-
markDirty(): void;
|
|
10
|
-
/**
|
|
11
|
-
* Register a field's validity signal with the form context.
|
|
12
|
-
* Returns a cleanup function.
|
|
13
|
-
*/
|
|
14
|
-
registerField(validity: Readable<boolean>): () => void;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Full form controller returned by `createFormContext`.
|
|
18
|
-
* Extends `FormFieldContext` with submission and status APIs.
|
|
19
|
-
*/
|
|
20
|
-
export type FormController = FormFieldContext & {
|
|
21
|
-
/**
|
|
22
|
-
* Clear `dirty` and `error` status signals and invoke `onReset` if provided.
|
|
23
|
-
* Note: this does not reset individual field values — pass an `onReset` callback
|
|
24
|
-
* to handle value restoration.
|
|
25
|
-
*/
|
|
26
|
-
clearStatus(): void;
|
|
27
|
-
/** The last submit error, or null if the last submit succeeded. */
|
|
28
|
-
readonly error: Readable<unknown>;
|
|
29
|
-
/** Submit the form programmatically. */
|
|
30
|
-
submit(e?: Event): Promise<void>;
|
|
31
|
-
/** Whether the form is currently submitting. */
|
|
32
|
-
readonly submitting: Readable<boolean>;
|
|
33
|
-
/** Whether all fields in the form are valid. */
|
|
34
|
-
readonly valid: Readable<boolean>;
|
|
35
|
-
};
|
|
36
|
-
export declare const FORM_CONTEXT_KEY: import("..").InjectionKey<FormFieldContext>;
|
|
37
|
-
/**
|
|
38
|
-
* Create a `FormController` for coordinating form state across child field components.
|
|
39
|
-
* Call `provide(FORM_CONTEXT_KEY, form)` to make it available to descendants.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* define('my-form', {
|
|
44
|
-
* setup(_props) {
|
|
45
|
-
* const form = createFormContext({ onSubmit: async (e) => { ... } });
|
|
46
|
-
* provide(FORM_CONTEXT_KEY, form);
|
|
47
|
-
* return html`<form @submit=${form.submit}><slot></slot></form>`;
|
|
48
|
-
* }
|
|
49
|
-
* });
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare function createFormContext(options?: {
|
|
53
|
-
onReset?: () => void;
|
|
54
|
-
onSubmit?: (e?: Event) => void | Promise<void>;
|
|
55
|
-
}): FormController;
|
|
56
|
-
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/forms/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,QAAQ,EAAU,MAAM,kBAAkB,CAAC;AAInE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClC,SAAS,IAAI,IAAI,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,CAAC;CACxD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG;IAC9C;;;;OAIG;IACH,WAAW,IAAI,IAAI,CAAC;IACpB,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClC,wCAAwC;IACxC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACvC,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,gBAAgB,6CAAsD,CAAC;AAEpF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C,GACL,cAAc,CA+ChB"}
|
package/dist/forms/context.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createContext as e}from"../context.js";import{computed as t,signal as n}from"@vielzeug/ripple";var r=e(`ore:form-context`);function i(e={}){let r=n([]),i=n(!1),a=n(!1),o=n(null);return{clearStatus:()=>{a.value=!1,o.value=null,e.onReset?.()},dirty:a,error:o,markDirty:()=>{a.value=!0},registerField:e=>(r.value=[...r.value,e],()=>{r.value=r.value.filter(t=>t!==e)}),submit:async t=>{if(t?.preventDefault(),!i.value){i.value=!0,o.value=null;try{await e.onSubmit?.(t),a.value=!1}catch(e){o.value=e}finally{i.value=!1}}},submitting:i,valid:t(()=>r.value.every(e=>e.value))}}export{r as FORM_CONTEXT_KEY,i as createFormContext};
|
|
2
|
-
//# sourceMappingURL=context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../../src/forms/context.ts"],"sourcesContent":["import { computed, type Readable, signal } from '@vielzeug/ripple';\n\nimport { createContext } from '../context';\n\n/**\n * Context shape injected by child field components.\n * Contains only what a field needs — not submit/error/status APIs.\n */\nexport type FormFieldContext = {\n /** Whether any field has been touched (interacted with). Set via markDirty(). */\n readonly dirty: Readable<boolean>;\n markDirty(): void;\n /**\n * Register a field's validity signal with the form context.\n * Returns a cleanup function.\n */\n registerField(validity: Readable<boolean>): () => void;\n};\n\n/**\n * Full form controller returned by `createFormContext`.\n * Extends `FormFieldContext` with submission and status APIs.\n */\nexport type FormController = FormFieldContext & {\n /**\n * Clear `dirty` and `error` status signals and invoke `onReset` if provided.\n * Note: this does not reset individual field values — pass an `onReset` callback\n * to handle value restoration.\n */\n clearStatus(): void;\n /** The last submit error, or null if the last submit succeeded. */\n readonly error: Readable<unknown>;\n /** Submit the form programmatically. */\n submit(e?: Event): Promise<void>;\n /** Whether the form is currently submitting. */\n readonly submitting: Readable<boolean>;\n /** Whether all fields in the form are valid. */\n readonly valid: Readable<boolean>;\n};\n\nexport const FORM_CONTEXT_KEY = createContext<FormFieldContext>('ore:form-context');\n\n/**\n * Create a `FormController` for coordinating form state across child field components.\n * Call `provide(FORM_CONTEXT_KEY, form)` to make it available to descendants.\n *\n * @example\n * ```ts\n * define('my-form', {\n * setup(_props) {\n * const form = createFormContext({ onSubmit: async (e) => { ... } });\n * provide(FORM_CONTEXT_KEY, form);\n * return html`<form @submit=${form.submit}><slot></slot></form>`;\n * }\n * });\n * ```\n */\nexport function createFormContext(\n options: {\n onReset?: () => void;\n onSubmit?: (e?: Event) => void | Promise<void>;\n } = {},\n): FormController {\n const fieldValiditySignals = signal<Array<Readable<boolean>>>([]);\n const submitting = signal(false);\n const dirty = signal(false);\n const error = signal<unknown>(null);\n\n // Note: [].every() is vacuously true, so valid is true when no fields are registered.\n // This is intentional — a form with no fields is considered valid (nothing to invalidate it).\n const valid = computed(() => fieldValiditySignals.value.every((s) => s.value));\n\n const submit = async (e?: Event): Promise<void> => {\n e?.preventDefault();\n\n if (submitting.value) return;\n\n submitting.value = true;\n error.value = null;\n\n try {\n await options.onSubmit?.(e);\n dirty.value = false;\n } catch (err) {\n error.value = err;\n } finally {\n submitting.value = false;\n }\n };\n\n const clearStatus = (): void => {\n dirty.value = false;\n error.value = null;\n options.onReset?.();\n };\n\n const markDirty = (): void => {\n dirty.value = true;\n };\n\n const registerField = (validity: Readable<boolean>): (() => void) => {\n fieldValiditySignals.value = [...fieldValiditySignals.value, validity];\n\n return () => {\n fieldValiditySignals.value = fieldValiditySignals.value.filter((s) => s !== validity);\n };\n };\n\n return { clearStatus, dirty, error, markDirty, registerField, submit, submitting, valid };\n}\n"],"mappings":"sGAwCA,IAAa,EAAmB,EAAgC,kBAAkB,EAiBlF,SAAgB,EACd,EAGI,CAAC,EACW,CAChB,IAAM,EAAuB,EAAiC,CAAC,CAAC,EAC1D,EAAa,EAAO,EAAK,EACzB,EAAQ,EAAO,EAAK,EACpB,EAAQ,EAAgB,IAAI,EA0ClC,MAAO,CAAE,gBAlBuB,CAC9B,EAAM,MAAQ,GACd,EAAM,MAAQ,KACd,EAAQ,UAAU,CACpB,EAcsB,QAAO,QAAO,cAZN,CAC5B,EAAM,MAAQ,EAChB,EAU+C,cARxB,IACrB,EAAqB,MAAQ,CAAC,GAAG,EAAqB,MAAO,CAAQ,MAExD,CACX,EAAqB,MAAQ,EAAqB,MAAM,OAAQ,GAAM,IAAM,CAAQ,CACtF,GAG4D,YApCxC,IAA6B,CACjD,MAAG,eAAe,EAEd,GAAW,MAGf,CADA,EAAW,MAAQ,GACnB,EAAM,MAAQ,KAEd,GAAI,CACF,MAAM,EAAQ,WAAW,CAAC,EAC1B,EAAM,MAAQ,EAChB,OAAS,EAAK,CACZ,EAAM,MAAQ,CAChB,QAAU,CACR,EAAW,MAAQ,EACrB,CATc,CAUhB,EAoBsE,aAAY,MAtCpE,MAAe,EAAqB,MAAM,MAAO,GAAM,EAAE,KAAK,CAsCM,CAAM,CAC1F"}
|
package/dist/forms/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Form-association helpers built on `ElementInternals`.
|
|
3
|
-
*
|
|
4
|
-
* Split from the package root into its own sub-path: not every component
|
|
5
|
-
* needs `formAssociated`/`ElementInternals` wiring, and keeping it out of the
|
|
6
|
-
* core surface keeps `@vielzeug/ore`'s main entry point scoped to universal
|
|
7
|
-
* authoring primitives (define/html/prop/context/aria).
|
|
8
|
-
*/
|
|
9
|
-
export { useField, type FormFieldHandle, type FormFieldOptions } from './field';
|
|
10
|
-
export { createFormContext, FORM_CONTEXT_KEY, type FormController, type FormFieldContext } from './context';
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/forms/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/forms.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./forms/field.cjs"),t=require("./forms/context.cjs");exports.FORM_CONTEXT_KEY=t.FORM_CONTEXT_KEY,exports.createFormContext=t.createFormContext,exports.useField=e.useField;
|
package/dist/forms.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useField as e}from"./forms/field.js";import{FORM_CONTEXT_KEY as t,createFormContext as n}from"./forms/context.js";export{t as FORM_CONTEXT_KEY,n as createFormContext,e as useField};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/observers.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./observers/intersection-observe.cjs"),t=require("./observers/media-observe.cjs"),n=require("./observers/mutation-observe.cjs"),r=require("./observers/resize-observe.cjs");exports.intersectionObserver=e.intersectionObserver,exports.mediaObserver=t.mediaObserver,exports.mutationObserver=n.mutationObserver,exports.resizeObserver=r.resizeObserver;
|
package/dist/observers.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{intersectionObserver as e}from"./observers/intersection-observe.js";import{mediaObserver as t}from"./observers/media-observe.js";import{mutationObserver as n}from"./observers/mutation-observe.js";import{resizeObserver as r}from"./observers/resize-observe.js";export{e as intersectionObserver,t as mediaObserver,n as mutationObserver,r as resizeObserver};
|
package/dist/template.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require("./template/bindings.cjs");const e=require("./template/instantiator.cjs");exports.html=e.html;
|
package/dist/template.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { applyAttrBinding, applyBinding, applyHtmlBinding, type RegisterCleanup } from './template/bindings';
|
|
2
|
-
export { type CompiledStaticTemplate, type NodePath, type SlotMeta } from './template/compiler';
|
|
3
|
-
export { compileTemplate, html } from './template/instantiator';
|
|
4
|
-
//# sourceMappingURL=template.d.ts.map
|
package/dist/template.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC7G,OAAO,EAAE,KAAK,sBAAsB,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/template.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./template/bindings.js";import{html as e}from"./template/instantiator.js";export{e as html};
|
package/dist/testing/events.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e=(e,t={})=>typeof PointerEvent<`u`?new PointerEvent(e,t):new MouseEvent(e,t),t={blur:(e,t)=>e.dispatchEvent(new FocusEvent(`blur`,{bubbles:!0,...t})),change:(e,t)=>e.dispatchEvent(new Event(`change`,{bubbles:!0,...t})),click:(e,t)=>e.dispatchEvent(new MouseEvent(`click`,{bubbles:!0,cancelable:!0,...t})),custom(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!1,...n}))},event(e,t){e.dispatchEvent(t)},focus:(e,t,n)=>e.dispatchEvent(new FocusEvent(`focus`,{bubbles:!0,...n})),input:(e,t)=>e.dispatchEvent(new Event(`input`,{bubbles:!0,...t})),keyboard:(e,t,n)=>e.dispatchEvent(new KeyboardEvent(t,{bubbles:!0,cancelable:!0,...n})),keyDown:(e,t)=>e.dispatchEvent(new KeyboardEvent(`keydown`,{bubbles:!0,cancelable:!0,...t})),keyUp:(e,t)=>e.dispatchEvent(new KeyboardEvent(`keyup`,{bubbles:!0,cancelable:!0,...t})),mouse:(e,t,n)=>e.dispatchEvent(new MouseEvent(t,{bubbles:!0,cancelable:!0,...n})),pointerDown:(t,n)=>t.dispatchEvent(e(`pointerdown`,{bubbles:!0,cancelable:!0,...n})),pointerEnter:(t,n)=>t.dispatchEvent(e(`pointerenter`,{bubbles:!1,...n})),pointerLeave:(t,n)=>t.dispatchEvent(e(`pointerleave`,{bubbles:!1,...n})),pointerUp:(t,n)=>t.dispatchEvent(e(`pointerup`,{bubbles:!0,cancelable:!0,...n})),submit:(e,t)=>e.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0,...t})),touch(e,t,n){typeof TouchEvent<`u`?e.dispatchEvent(new TouchEvent(t,{bubbles:!0,cancelable:!0,...n})):e.dispatchEvent(new CustomEvent(t,{bubbles:!0,cancelable:!0,...n}))}};exports.createPointerEvent=e,exports.fire=t;
|
|
2
|
-
//# sourceMappingURL=events.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.cjs","names":[],"sources":["../../src/testing/events.ts"],"sourcesContent":["/**\n * Synchronous DOM event dispatchers for test environments.\n */\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nexport const createPointerEvent = (type: string, init: PointerEventInit = {}): Event => {\n if (typeof PointerEvent !== 'undefined') {\n return new PointerEvent(type, init);\n }\n\n return new MouseEvent(type, init);\n};\n\n// ─── API ─────────────────────────────────────────────────────────────────────\n\n/**\n * Fire low-level DOM events synchronously.\n *\n * @example\n * fire.click(button);\n * fire.keyDown(input, { key: 'Enter' });\n * fire.custom(el, 'value-change', { detail: 42 });\n */\nexport const fire = {\n blur: (el: Element, opts?: FocusEventInit) => el.dispatchEvent(new FocusEvent('blur', { bubbles: true, ...opts })),\n change: (el: Element, opts?: EventInit) => el.dispatchEvent(new Event('change', { bubbles: true, ...opts })),\n click: (el: Element, opts?: PointerEventInit) =>\n el.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, ...opts })),\n /** Fire a CustomEvent. Pass `{ detail: ... }` for event detail. */\n custom(el: Element, name: string, opts?: CustomEventInit): void {\n el.dispatchEvent(new CustomEvent(name, { bubbles: true, cancelable: true, composed: false, ...opts }));\n },\n /** Dispatch any pre-built Event instance directly. */\n event(el: Element, event: Event): void {\n el.dispatchEvent(event);\n },\n focus: (el: Element, _name?: string, opts?: FocusEventInit) =>\n el.dispatchEvent(new FocusEvent('focus', { bubbles: true, ...opts })),\n input: (el: Element, opts?: EventInit) => el.dispatchEvent(new Event('input', { bubbles: true, ...opts })),\n /** Fire a KeyboardEvent with a given type (keydown, keyup, keypress). */\n keyboard: (el: Element, type: string, opts?: KeyboardEventInit) =>\n el.dispatchEvent(new KeyboardEvent(type, { bubbles: true, cancelable: true, ...opts })),\n keyDown: (el: Element, opts?: KeyboardEventInit) =>\n el.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, cancelable: true, ...opts })),\n keyUp: (el: Element, opts?: KeyboardEventInit) =>\n el.dispatchEvent(new KeyboardEvent('keyup', { bubbles: true, cancelable: true, ...opts })),\n /** Fire a MouseEvent with a given type (click, mousedown, etc.). */\n mouse: (el: Element, type: string, opts?: MouseEventInit) =>\n el.dispatchEvent(new MouseEvent(type, { bubbles: true, cancelable: true, ...opts })),\n pointerDown: (el: Element, opts?: PointerEventInit) =>\n el.dispatchEvent(createPointerEvent('pointerdown', { bubbles: true, cancelable: true, ...opts })),\n pointerEnter: (el: Element, opts?: PointerEventInit) =>\n el.dispatchEvent(createPointerEvent('pointerenter', { bubbles: false, ...opts })),\n pointerLeave: (el: Element, opts?: PointerEventInit) =>\n el.dispatchEvent(createPointerEvent('pointerleave', { bubbles: false, ...opts })),\n pointerUp: (el: Element, opts?: PointerEventInit) =>\n el.dispatchEvent(createPointerEvent('pointerup', { bubbles: true, cancelable: true, ...opts })),\n submit: (el: Element, opts?: EventInit) =>\n el.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true, ...opts })),\n /** Fire a touch event; falls back to CustomEvent in environments without TouchEvent. */\n touch(el: Element, type: string, opts?: EventInit): void {\n if (typeof TouchEvent !== 'undefined') {\n el.dispatchEvent(new TouchEvent(type, { bubbles: true, cancelable: true, ...opts }));\n } else {\n el.dispatchEvent(new CustomEvent(type, { bubbles: true, cancelable: true, ...opts }));\n }\n },\n} as const;\n"],"mappings":"AAMA,IAAa,GAAsB,EAAc,EAAyB,CAAC,IACrE,OAAO,aAAiB,IACnB,IAAI,aAAa,EAAM,CAAI,EAG7B,IAAI,WAAW,EAAM,CAAI,EAarB,EAAO,CAClB,MAAO,EAAa,IAA0B,EAAG,cAAc,IAAI,WAAW,OAAQ,CAAE,QAAS,GAAM,GAAG,CAAK,CAAC,CAAC,EACjH,QAAS,EAAa,IAAqB,EAAG,cAAc,IAAI,MAAM,SAAU,CAAE,QAAS,GAAM,GAAG,CAAK,CAAC,CAAC,EAC3G,OAAQ,EAAa,IACnB,EAAG,cAAc,IAAI,WAAW,QAAS,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAExF,OAAO,EAAa,EAAc,EAA8B,CAC9D,EAAG,cAAc,IAAI,YAAY,EAAM,CAAE,QAAS,GAAM,WAAY,GAAM,SAAU,GAAO,GAAG,CAAK,CAAC,CAAC,CACvG,EAEA,MAAM,EAAa,EAAoB,CACrC,EAAG,cAAc,CAAK,CACxB,EACA,OAAQ,EAAa,EAAgB,IACnC,EAAG,cAAc,IAAI,WAAW,QAAS,CAAE,QAAS,GAAM,GAAG,CAAK,CAAC,CAAC,EACtE,OAAQ,EAAa,IAAqB,EAAG,cAAc,IAAI,MAAM,QAAS,CAAE,QAAS,GAAM,GAAG,CAAK,CAAC,CAAC,EAEzG,UAAW,EAAa,EAAc,IACpC,EAAG,cAAc,IAAI,cAAc,EAAM,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EACxF,SAAU,EAAa,IACrB,EAAG,cAAc,IAAI,cAAc,UAAW,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAC7F,OAAQ,EAAa,IACnB,EAAG,cAAc,IAAI,cAAc,QAAS,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAE3F,OAAQ,EAAa,EAAc,IACjC,EAAG,cAAc,IAAI,WAAW,EAAM,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EACrF,aAAc,EAAa,IACzB,EAAG,cAAc,EAAmB,cAAe,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAClG,cAAe,EAAa,IAC1B,EAAG,cAAc,EAAmB,eAAgB,CAAE,QAAS,GAAO,GAAG,CAAK,CAAC,CAAC,EAClF,cAAe,EAAa,IAC1B,EAAG,cAAc,EAAmB,eAAgB,CAAE,QAAS,GAAO,GAAG,CAAK,CAAC,CAAC,EAClF,WAAY,EAAa,IACvB,EAAG,cAAc,EAAmB,YAAa,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAChG,QAAS,EAAa,IACpB,EAAG,cAAc,IAAI,MAAM,SAAU,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAEpF,MAAM,EAAa,EAAc,EAAwB,CACnD,OAAO,WAAe,IACxB,EAAG,cAAc,IAAI,WAAW,EAAM,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAEnF,EAAG,cAAc,IAAI,YAAY,EAAM,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,CAExF,CACF"}
|
package/dist/testing/events.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Synchronous DOM event dispatchers for test environments.
|
|
3
|
-
*/
|
|
4
|
-
export declare const createPointerEvent: (type: string, init?: PointerEventInit) => Event;
|
|
5
|
-
/**
|
|
6
|
-
* Fire low-level DOM events synchronously.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* fire.click(button);
|
|
10
|
-
* fire.keyDown(input, { key: 'Enter' });
|
|
11
|
-
* fire.custom(el, 'value-change', { detail: 42 });
|
|
12
|
-
*/
|
|
13
|
-
export declare const fire: {
|
|
14
|
-
readonly blur: (el: Element, opts?: FocusEventInit) => boolean;
|
|
15
|
-
readonly change: (el: Element, opts?: EventInit) => boolean;
|
|
16
|
-
readonly click: (el: Element, opts?: PointerEventInit) => boolean;
|
|
17
|
-
/** Fire a CustomEvent. Pass `{ detail: ... }` for event detail. */
|
|
18
|
-
readonly custom: (el: Element, name: string, opts?: CustomEventInit) => void;
|
|
19
|
-
/** Dispatch any pre-built Event instance directly. */
|
|
20
|
-
readonly event: (el: Element, event: Event) => void;
|
|
21
|
-
readonly focus: (el: Element, _name?: string, opts?: FocusEventInit) => boolean;
|
|
22
|
-
readonly input: (el: Element, opts?: EventInit) => boolean;
|
|
23
|
-
/** Fire a KeyboardEvent with a given type (keydown, keyup, keypress). */
|
|
24
|
-
readonly keyboard: (el: Element, type: string, opts?: KeyboardEventInit) => boolean;
|
|
25
|
-
readonly keyDown: (el: Element, opts?: KeyboardEventInit) => boolean;
|
|
26
|
-
readonly keyUp: (el: Element, opts?: KeyboardEventInit) => boolean;
|
|
27
|
-
/** Fire a MouseEvent with a given type (click, mousedown, etc.). */
|
|
28
|
-
readonly mouse: (el: Element, type: string, opts?: MouseEventInit) => boolean;
|
|
29
|
-
readonly pointerDown: (el: Element, opts?: PointerEventInit) => boolean;
|
|
30
|
-
readonly pointerEnter: (el: Element, opts?: PointerEventInit) => boolean;
|
|
31
|
-
readonly pointerLeave: (el: Element, opts?: PointerEventInit) => boolean;
|
|
32
|
-
readonly pointerUp: (el: Element, opts?: PointerEventInit) => boolean;
|
|
33
|
-
readonly submit: (el: Element, opts?: EventInit) => boolean;
|
|
34
|
-
/** Fire a touch event; falls back to CustomEvent in environments without TouchEvent. */
|
|
35
|
-
readonly touch: (el: Element, type: string, opts?: EventInit) => void;
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/testing/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,OAAM,gBAAqB,KAAG,KAM9E,CAAC;AAIF;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI;wBACJ,OAAO,SAAS,cAAc;0BAC5B,OAAO,SAAS,SAAS;yBAC1B,OAAO,SAAS,gBAAgB;IAE5C,mEAAmE;0BACxD,OAAO,QAAQ,MAAM,SAAS,eAAe,KAAG,IAAI;IAG/D,sDAAsD;yBAC5C,OAAO,SAAS,KAAK,KAAG,IAAI;yBAG1B,OAAO,UAAU,MAAM,SAAS,cAAc;yBAE9C,OAAO,SAAS,SAAS;IACrC,yEAAyE;4BAC1D,OAAO,QAAQ,MAAM,SAAS,iBAAiB;2BAEhD,OAAO,SAAS,iBAAiB;yBAEnC,OAAO,SAAS,iBAAiB;IAE7C,oEAAoE;yBACxD,OAAO,QAAQ,MAAM,SAAS,cAAc;+BAEtC,OAAO,SAAS,gBAAgB;gCAE/B,OAAO,SAAS,gBAAgB;gCAEhC,OAAO,SAAS,gBAAgB;6BAEnC,OAAO,SAAS,gBAAgB;0BAEnC,OAAO,SAAS,SAAS;IAEtC,wFAAwF;yBAC9E,OAAO,QAAQ,MAAM,SAAS,SAAS,KAAG,IAAI;CAOhD,CAAC"}
|
package/dist/testing/events.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e=(e,t={})=>typeof PointerEvent<`u`?new PointerEvent(e,t):new MouseEvent(e,t),t={blur:(e,t)=>e.dispatchEvent(new FocusEvent(`blur`,{bubbles:!0,...t})),change:(e,t)=>e.dispatchEvent(new Event(`change`,{bubbles:!0,...t})),click:(e,t)=>e.dispatchEvent(new MouseEvent(`click`,{bubbles:!0,cancelable:!0,...t})),custom(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!1,...n}))},event(e,t){e.dispatchEvent(t)},focus:(e,t,n)=>e.dispatchEvent(new FocusEvent(`focus`,{bubbles:!0,...n})),input:(e,t)=>e.dispatchEvent(new Event(`input`,{bubbles:!0,...t})),keyboard:(e,t,n)=>e.dispatchEvent(new KeyboardEvent(t,{bubbles:!0,cancelable:!0,...n})),keyDown:(e,t)=>e.dispatchEvent(new KeyboardEvent(`keydown`,{bubbles:!0,cancelable:!0,...t})),keyUp:(e,t)=>e.dispatchEvent(new KeyboardEvent(`keyup`,{bubbles:!0,cancelable:!0,...t})),mouse:(e,t,n)=>e.dispatchEvent(new MouseEvent(t,{bubbles:!0,cancelable:!0,...n})),pointerDown:(t,n)=>t.dispatchEvent(e(`pointerdown`,{bubbles:!0,cancelable:!0,...n})),pointerEnter:(t,n)=>t.dispatchEvent(e(`pointerenter`,{bubbles:!1,...n})),pointerLeave:(t,n)=>t.dispatchEvent(e(`pointerleave`,{bubbles:!1,...n})),pointerUp:(t,n)=>t.dispatchEvent(e(`pointerup`,{bubbles:!0,cancelable:!0,...n})),submit:(e,t)=>e.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0,...t})),touch(e,t,n){typeof TouchEvent<`u`?e.dispatchEvent(new TouchEvent(t,{bubbles:!0,cancelable:!0,...n})):e.dispatchEvent(new CustomEvent(t,{bubbles:!0,cancelable:!0,...n}))}};export{e as createPointerEvent,t as fire};
|
|
2
|
-
//# sourceMappingURL=events.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","names":[],"sources":["../../src/testing/events.ts"],"sourcesContent":["/**\n * Synchronous DOM event dispatchers for test environments.\n */\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nexport const createPointerEvent = (type: string, init: PointerEventInit = {}): Event => {\n if (typeof PointerEvent !== 'undefined') {\n return new PointerEvent(type, init);\n }\n\n return new MouseEvent(type, init);\n};\n\n// ─── API ─────────────────────────────────────────────────────────────────────\n\n/**\n * Fire low-level DOM events synchronously.\n *\n * @example\n * fire.click(button);\n * fire.keyDown(input, { key: 'Enter' });\n * fire.custom(el, 'value-change', { detail: 42 });\n */\nexport const fire = {\n blur: (el: Element, opts?: FocusEventInit) => el.dispatchEvent(new FocusEvent('blur', { bubbles: true, ...opts })),\n change: (el: Element, opts?: EventInit) => el.dispatchEvent(new Event('change', { bubbles: true, ...opts })),\n click: (el: Element, opts?: PointerEventInit) =>\n el.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, ...opts })),\n /** Fire a CustomEvent. Pass `{ detail: ... }` for event detail. */\n custom(el: Element, name: string, opts?: CustomEventInit): void {\n el.dispatchEvent(new CustomEvent(name, { bubbles: true, cancelable: true, composed: false, ...opts }));\n },\n /** Dispatch any pre-built Event instance directly. */\n event(el: Element, event: Event): void {\n el.dispatchEvent(event);\n },\n focus: (el: Element, _name?: string, opts?: FocusEventInit) =>\n el.dispatchEvent(new FocusEvent('focus', { bubbles: true, ...opts })),\n input: (el: Element, opts?: EventInit) => el.dispatchEvent(new Event('input', { bubbles: true, ...opts })),\n /** Fire a KeyboardEvent with a given type (keydown, keyup, keypress). */\n keyboard: (el: Element, type: string, opts?: KeyboardEventInit) =>\n el.dispatchEvent(new KeyboardEvent(type, { bubbles: true, cancelable: true, ...opts })),\n keyDown: (el: Element, opts?: KeyboardEventInit) =>\n el.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, cancelable: true, ...opts })),\n keyUp: (el: Element, opts?: KeyboardEventInit) =>\n el.dispatchEvent(new KeyboardEvent('keyup', { bubbles: true, cancelable: true, ...opts })),\n /** Fire a MouseEvent with a given type (click, mousedown, etc.). */\n mouse: (el: Element, type: string, opts?: MouseEventInit) =>\n el.dispatchEvent(new MouseEvent(type, { bubbles: true, cancelable: true, ...opts })),\n pointerDown: (el: Element, opts?: PointerEventInit) =>\n el.dispatchEvent(createPointerEvent('pointerdown', { bubbles: true, cancelable: true, ...opts })),\n pointerEnter: (el: Element, opts?: PointerEventInit) =>\n el.dispatchEvent(createPointerEvent('pointerenter', { bubbles: false, ...opts })),\n pointerLeave: (el: Element, opts?: PointerEventInit) =>\n el.dispatchEvent(createPointerEvent('pointerleave', { bubbles: false, ...opts })),\n pointerUp: (el: Element, opts?: PointerEventInit) =>\n el.dispatchEvent(createPointerEvent('pointerup', { bubbles: true, cancelable: true, ...opts })),\n submit: (el: Element, opts?: EventInit) =>\n el.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true, ...opts })),\n /** Fire a touch event; falls back to CustomEvent in environments without TouchEvent. */\n touch(el: Element, type: string, opts?: EventInit): void {\n if (typeof TouchEvent !== 'undefined') {\n el.dispatchEvent(new TouchEvent(type, { bubbles: true, cancelable: true, ...opts }));\n } else {\n el.dispatchEvent(new CustomEvent(type, { bubbles: true, cancelable: true, ...opts }));\n }\n },\n} as const;\n"],"mappings":"AAMA,IAAa,GAAsB,EAAc,EAAyB,CAAC,IACrE,OAAO,aAAiB,IACnB,IAAI,aAAa,EAAM,CAAI,EAG7B,IAAI,WAAW,EAAM,CAAI,EAarB,EAAO,CAClB,MAAO,EAAa,IAA0B,EAAG,cAAc,IAAI,WAAW,OAAQ,CAAE,QAAS,GAAM,GAAG,CAAK,CAAC,CAAC,EACjH,QAAS,EAAa,IAAqB,EAAG,cAAc,IAAI,MAAM,SAAU,CAAE,QAAS,GAAM,GAAG,CAAK,CAAC,CAAC,EAC3G,OAAQ,EAAa,IACnB,EAAG,cAAc,IAAI,WAAW,QAAS,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAExF,OAAO,EAAa,EAAc,EAA8B,CAC9D,EAAG,cAAc,IAAI,YAAY,EAAM,CAAE,QAAS,GAAM,WAAY,GAAM,SAAU,GAAO,GAAG,CAAK,CAAC,CAAC,CACvG,EAEA,MAAM,EAAa,EAAoB,CACrC,EAAG,cAAc,CAAK,CACxB,EACA,OAAQ,EAAa,EAAgB,IACnC,EAAG,cAAc,IAAI,WAAW,QAAS,CAAE,QAAS,GAAM,GAAG,CAAK,CAAC,CAAC,EACtE,OAAQ,EAAa,IAAqB,EAAG,cAAc,IAAI,MAAM,QAAS,CAAE,QAAS,GAAM,GAAG,CAAK,CAAC,CAAC,EAEzG,UAAW,EAAa,EAAc,IACpC,EAAG,cAAc,IAAI,cAAc,EAAM,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EACxF,SAAU,EAAa,IACrB,EAAG,cAAc,IAAI,cAAc,UAAW,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAC7F,OAAQ,EAAa,IACnB,EAAG,cAAc,IAAI,cAAc,QAAS,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAE3F,OAAQ,EAAa,EAAc,IACjC,EAAG,cAAc,IAAI,WAAW,EAAM,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EACrF,aAAc,EAAa,IACzB,EAAG,cAAc,EAAmB,cAAe,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAClG,cAAe,EAAa,IAC1B,EAAG,cAAc,EAAmB,eAAgB,CAAE,QAAS,GAAO,GAAG,CAAK,CAAC,CAAC,EAClF,cAAe,EAAa,IAC1B,EAAG,cAAc,EAAmB,eAAgB,CAAE,QAAS,GAAO,GAAG,CAAK,CAAC,CAAC,EAClF,WAAY,EAAa,IACvB,EAAG,cAAc,EAAmB,YAAa,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAChG,QAAS,EAAa,IACpB,EAAG,cAAc,IAAI,MAAM,SAAU,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAEpF,MAAM,EAAa,EAAc,EAAwB,CACnD,OAAO,WAAe,IACxB,EAAG,cAAc,IAAI,WAAW,EAAM,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,EAEnF,EAAG,cAAc,IAAI,YAAY,EAAM,CAAE,QAAS,GAAM,WAAY,GAAM,GAAG,CAAK,CAAC,CAAC,CAExF,CACF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("./flush.cjs"),t=require("./events.cjs");var n=()=>e.flush(),r={async clear(e){e.focus(),e.value=``,t.fire.input(e),t.fire.change(e),await n()},async click(e,r){t.fire.pointerEnter(e,r),t.fire.click(e,r),await n()},async dblClick(e){for(let n=0;n<2;n++)t.fire.pointerDown(e),t.fire.pointerUp(e),t.fire.click(e);e.dispatchEvent(new MouseEvent(`dblclick`,{bubbles:!0,cancelable:!0})),await n()},async fill(e,r){e.focus(),e.value=``;for(let i of r)e.value+=i,t.fire.input(e),t.fire.keyDown(e,{key:i}),t.fire.keyUp(e,{key:i}),await n();t.fire.change(e)},async hover(e){t.fire.pointerEnter(e),await n()},async press(e,r,i){t.fire.keyDown(e,{key:r,...i}),t.fire.keyUp(e,{key:r,...i}),await n()},async select(e,r){let i=Array.isArray(r)?r:[r];for(let t of e.options)t.selected=i.includes(t.value);t.fire.change(e),await n()},async type(e,r){e.focus();for(let i of r)e.value+=i,t.fire.input(e),t.fire.keyDown(e,{key:i}),t.fire.keyUp(e,{key:i}),await n();t.fire.change(e)},async unhover(e){t.fire.pointerLeave(e),await n()}};exports.user=r;
|
|
2
|
-
//# sourceMappingURL=interactions.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interactions.cjs","names":[],"sources":["../../src/testing/interactions.ts"],"sourcesContent":["/**\n * Higher-level async user interaction helpers for test environments.\n */\n\nimport { fire } from './events';\nimport { flush } from './flush';\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nconst tick = (): Promise<void> => flush();\n\n// ─── API ─────────────────────────────────────────────────────────────────────\n\n/**\n * Higher-level async user interactions that mirror real browser behavior.\n *\n * @example\n * await user.type(input, 'hello');\n * await user.fill(input, 'replacement'); // clear then type\n * await user.click(button);\n * await user.press(input, 'Enter');\n */\nexport const user = {\n async clear(el: HTMLInputElement | HTMLTextAreaElement): Promise<void> {\n el.focus();\n el.value = '';\n fire.input(el);\n fire.change(el);\n await tick();\n },\n\n async click(el: Element, opts?: PointerEventInit): Promise<void> {\n fire.pointerEnter(el, opts);\n fire.click(el, opts);\n await tick();\n },\n\n async dblClick(el: Element): Promise<void> {\n for (let i = 0; i < 2; i++) {\n fire.pointerDown(el);\n fire.pointerUp(el);\n fire.click(el);\n }\n el.dispatchEvent(new MouseEvent('dblclick', { bubbles: true, cancelable: true }));\n await tick();\n },\n\n /** Clear existing value and type new text (select-all-and-replace semantics) */\n async fill(el: HTMLInputElement | HTMLTextAreaElement, text: string): Promise<void> {\n el.focus();\n el.value = '';\n for (const char of text) {\n el.value += char;\n fire.input(el);\n fire.keyDown(el, { key: char });\n fire.keyUp(el, { key: char });\n await tick();\n }\n fire.change(el);\n },\n\n async hover(el: Element): Promise<void> {\n fire.pointerEnter(el);\n await tick();\n },\n\n /** Dispatch keydown + keyup for a single key */\n async press(el: Element, key: string, opts?: KeyboardEventInit): Promise<void> {\n fire.keyDown(el, { key, ...opts });\n fire.keyUp(el, { key, ...opts });\n await tick();\n },\n\n async select(el: HTMLSelectElement, value: string | string[]): Promise<void> {\n const values = Array.isArray(value) ? value : [value];\n\n for (const opt of el.options) opt.selected = values.includes(opt.value);\n fire.change(el);\n await tick();\n },\n\n /** Type text character-by-character, appending to any existing value */\n async type(el: HTMLInputElement | HTMLTextAreaElement, text: string): Promise<void> {\n el.focus();\n for (const char of text) {\n el.value += char;\n fire.input(el);\n fire.keyDown(el, { key: char });\n fire.keyUp(el, { key: char });\n await tick();\n }\n fire.change(el);\n },\n\n async unhover(el: Element): Promise<void> {\n fire.pointerLeave(el);\n await tick();\n },\n} as const;\n"],"mappings":"yDASA,IAAM,MAA4B,EAAA,MAAM,EAa3B,EAAO,CAClB,MAAM,MAAM,EAA2D,CACrE,EAAG,MAAM,EACT,EAAG,MAAQ,GACX,EAAA,KAAK,MAAM,CAAE,EACb,EAAA,KAAK,OAAO,CAAE,EACd,MAAM,EAAK,CACb,EAEA,MAAM,MAAM,EAAa,EAAwC,CAC/D,EAAA,KAAK,aAAa,EAAI,CAAI,EAC1B,EAAA,KAAK,MAAM,EAAI,CAAI,EACnB,MAAM,EAAK,CACb,EAEA,MAAM,SAAS,EAA4B,CACzC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAG,IACrB,EAAA,KAAK,YAAY,CAAE,EACnB,EAAA,KAAK,UAAU,CAAE,EACjB,EAAA,KAAK,MAAM,CAAE,EAEf,EAAG,cAAc,IAAI,WAAW,WAAY,CAAE,QAAS,GAAM,WAAY,EAAK,CAAC,CAAC,EAChF,MAAM,EAAK,CACb,EAGA,MAAM,KAAK,EAA4C,EAA6B,CAClF,EAAG,MAAM,EACT,EAAG,MAAQ,GACX,IAAK,IAAM,KAAQ,EACjB,EAAG,OAAS,EACZ,EAAA,KAAK,MAAM,CAAE,EACb,EAAA,KAAK,QAAQ,EAAI,CAAE,IAAK,CAAK,CAAC,EAC9B,EAAA,KAAK,MAAM,EAAI,CAAE,IAAK,CAAK,CAAC,EAC5B,MAAM,EAAK,EAEb,EAAA,KAAK,OAAO,CAAE,CAChB,EAEA,MAAM,MAAM,EAA4B,CACtC,EAAA,KAAK,aAAa,CAAE,EACpB,MAAM,EAAK,CACb,EAGA,MAAM,MAAM,EAAa,EAAa,EAAyC,CAC7E,EAAA,KAAK,QAAQ,EAAI,CAAE,MAAK,GAAG,CAAK,CAAC,EACjC,EAAA,KAAK,MAAM,EAAI,CAAE,MAAK,GAAG,CAAK,CAAC,EAC/B,MAAM,EAAK,CACb,EAEA,MAAM,OAAO,EAAuB,EAAyC,CAC3E,IAAM,EAAS,MAAM,QAAQ,CAAK,EAAI,EAAQ,CAAC,CAAK,EAEpD,IAAK,IAAM,KAAO,EAAG,QAAS,EAAI,SAAW,EAAO,SAAS,EAAI,KAAK,EACtE,EAAA,KAAK,OAAO,CAAE,EACd,MAAM,EAAK,CACb,EAGA,MAAM,KAAK,EAA4C,EAA6B,CAClF,EAAG,MAAM,EACT,IAAK,IAAM,KAAQ,EACjB,EAAG,OAAS,EACZ,EAAA,KAAK,MAAM,CAAE,EACb,EAAA,KAAK,QAAQ,EAAI,CAAE,IAAK,CAAK,CAAC,EAC9B,EAAA,KAAK,MAAM,EAAI,CAAE,IAAK,CAAK,CAAC,EAC5B,MAAM,EAAK,EAEb,EAAA,KAAK,OAAO,CAAE,CAChB,EAEA,MAAM,QAAQ,EAA4B,CACxC,EAAA,KAAK,aAAa,CAAE,EACpB,MAAM,EAAK,CACb,CACF"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Higher-level async user interaction helpers for test environments.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Higher-level async user interactions that mirror real browser behavior.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* await user.type(input, 'hello');
|
|
9
|
-
* await user.fill(input, 'replacement'); // clear then type
|
|
10
|
-
* await user.click(button);
|
|
11
|
-
* await user.press(input, 'Enter');
|
|
12
|
-
*/
|
|
13
|
-
export declare const user: {
|
|
14
|
-
readonly clear: (el: HTMLInputElement | HTMLTextAreaElement) => Promise<void>;
|
|
15
|
-
readonly click: (el: Element, opts?: PointerEventInit) => Promise<void>;
|
|
16
|
-
readonly dblClick: (el: Element) => Promise<void>;
|
|
17
|
-
/** Clear existing value and type new text (select-all-and-replace semantics) */
|
|
18
|
-
readonly fill: (el: HTMLInputElement | HTMLTextAreaElement, text: string) => Promise<void>;
|
|
19
|
-
readonly hover: (el: Element) => Promise<void>;
|
|
20
|
-
/** Dispatch keydown + keyup for a single key */
|
|
21
|
-
readonly press: (el: Element, key: string, opts?: KeyboardEventInit) => Promise<void>;
|
|
22
|
-
readonly select: (el: HTMLSelectElement, value: string | string[]) => Promise<void>;
|
|
23
|
-
/** Type text character-by-character, appending to any existing value */
|
|
24
|
-
readonly type: (el: HTMLInputElement | HTMLTextAreaElement, text: string) => Promise<void>;
|
|
25
|
-
readonly unhover: (el: Element) => Promise<void>;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=interactions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../src/testing/interactions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI;yBACC,gBAAgB,GAAG,mBAAmB,KAAG,OAAO,CAAC,IAAI,CAAC;yBAQtD,OAAO,SAAS,gBAAgB,KAAG,OAAO,CAAC,IAAI,CAAC;4BAM7C,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC;IAU1C,gFAAgF;wBACjE,gBAAgB,GAAG,mBAAmB,QAAQ,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;yBAanE,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC;IAKvC,gDAAgD;yBAChC,OAAO,OAAO,MAAM,SAAS,iBAAiB,KAAG,OAAO,CAAC,IAAI,CAAC;0BAM7D,iBAAiB,SAAS,MAAM,GAAG,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAAC;IAQ5E,wEAAwE;wBACzD,gBAAgB,GAAG,mBAAmB,QAAQ,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;2BAYjE,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC;CAIjC,CAAC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{flush as e}from"./flush.js";import{fire as t}from"./events.js";var n=()=>e(),r={async clear(e){e.focus(),e.value=``,t.input(e),t.change(e),await n()},async click(e,r){t.pointerEnter(e,r),t.click(e,r),await n()},async dblClick(e){for(let n=0;n<2;n++)t.pointerDown(e),t.pointerUp(e),t.click(e);e.dispatchEvent(new MouseEvent(`dblclick`,{bubbles:!0,cancelable:!0})),await n()},async fill(e,r){e.focus(),e.value=``;for(let i of r)e.value+=i,t.input(e),t.keyDown(e,{key:i}),t.keyUp(e,{key:i}),await n();t.change(e)},async hover(e){t.pointerEnter(e),await n()},async press(e,r,i){t.keyDown(e,{key:r,...i}),t.keyUp(e,{key:r,...i}),await n()},async select(e,r){let i=Array.isArray(r)?r:[r];for(let t of e.options)t.selected=i.includes(t.value);t.change(e),await n()},async type(e,r){e.focus();for(let i of r)e.value+=i,t.input(e),t.keyDown(e,{key:i}),t.keyUp(e,{key:i}),await n();t.change(e)},async unhover(e){t.pointerLeave(e),await n()}};export{r as user};
|
|
2
|
-
//# sourceMappingURL=interactions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interactions.js","names":[],"sources":["../../src/testing/interactions.ts"],"sourcesContent":["/**\n * Higher-level async user interaction helpers for test environments.\n */\n\nimport { fire } from './events';\nimport { flush } from './flush';\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nconst tick = (): Promise<void> => flush();\n\n// ─── API ─────────────────────────────────────────────────────────────────────\n\n/**\n * Higher-level async user interactions that mirror real browser behavior.\n *\n * @example\n * await user.type(input, 'hello');\n * await user.fill(input, 'replacement'); // clear then type\n * await user.click(button);\n * await user.press(input, 'Enter');\n */\nexport const user = {\n async clear(el: HTMLInputElement | HTMLTextAreaElement): Promise<void> {\n el.focus();\n el.value = '';\n fire.input(el);\n fire.change(el);\n await tick();\n },\n\n async click(el: Element, opts?: PointerEventInit): Promise<void> {\n fire.pointerEnter(el, opts);\n fire.click(el, opts);\n await tick();\n },\n\n async dblClick(el: Element): Promise<void> {\n for (let i = 0; i < 2; i++) {\n fire.pointerDown(el);\n fire.pointerUp(el);\n fire.click(el);\n }\n el.dispatchEvent(new MouseEvent('dblclick', { bubbles: true, cancelable: true }));\n await tick();\n },\n\n /** Clear existing value and type new text (select-all-and-replace semantics) */\n async fill(el: HTMLInputElement | HTMLTextAreaElement, text: string): Promise<void> {\n el.focus();\n el.value = '';\n for (const char of text) {\n el.value += char;\n fire.input(el);\n fire.keyDown(el, { key: char });\n fire.keyUp(el, { key: char });\n await tick();\n }\n fire.change(el);\n },\n\n async hover(el: Element): Promise<void> {\n fire.pointerEnter(el);\n await tick();\n },\n\n /** Dispatch keydown + keyup for a single key */\n async press(el: Element, key: string, opts?: KeyboardEventInit): Promise<void> {\n fire.keyDown(el, { key, ...opts });\n fire.keyUp(el, { key, ...opts });\n await tick();\n },\n\n async select(el: HTMLSelectElement, value: string | string[]): Promise<void> {\n const values = Array.isArray(value) ? value : [value];\n\n for (const opt of el.options) opt.selected = values.includes(opt.value);\n fire.change(el);\n await tick();\n },\n\n /** Type text character-by-character, appending to any existing value */\n async type(el: HTMLInputElement | HTMLTextAreaElement, text: string): Promise<void> {\n el.focus();\n for (const char of text) {\n el.value += char;\n fire.input(el);\n fire.keyDown(el, { key: char });\n fire.keyUp(el, { key: char });\n await tick();\n }\n fire.change(el);\n },\n\n async unhover(el: Element): Promise<void> {\n fire.pointerLeave(el);\n await tick();\n },\n} as const;\n"],"mappings":"sEASA,IAAM,MAA4B,EAAM,EAa3B,EAAO,CAClB,MAAM,MAAM,EAA2D,CACrE,EAAG,MAAM,EACT,EAAG,MAAQ,GACX,EAAK,MAAM,CAAE,EACb,EAAK,OAAO,CAAE,EACd,MAAM,EAAK,CACb,EAEA,MAAM,MAAM,EAAa,EAAwC,CAC/D,EAAK,aAAa,EAAI,CAAI,EAC1B,EAAK,MAAM,EAAI,CAAI,EACnB,MAAM,EAAK,CACb,EAEA,MAAM,SAAS,EAA4B,CACzC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAG,IACrB,EAAK,YAAY,CAAE,EACnB,EAAK,UAAU,CAAE,EACjB,EAAK,MAAM,CAAE,EAEf,EAAG,cAAc,IAAI,WAAW,WAAY,CAAE,QAAS,GAAM,WAAY,EAAK,CAAC,CAAC,EAChF,MAAM,EAAK,CACb,EAGA,MAAM,KAAK,EAA4C,EAA6B,CAClF,EAAG,MAAM,EACT,EAAG,MAAQ,GACX,IAAK,IAAM,KAAQ,EACjB,EAAG,OAAS,EACZ,EAAK,MAAM,CAAE,EACb,EAAK,QAAQ,EAAI,CAAE,IAAK,CAAK,CAAC,EAC9B,EAAK,MAAM,EAAI,CAAE,IAAK,CAAK,CAAC,EAC5B,MAAM,EAAK,EAEb,EAAK,OAAO,CAAE,CAChB,EAEA,MAAM,MAAM,EAA4B,CACtC,EAAK,aAAa,CAAE,EACpB,MAAM,EAAK,CACb,EAGA,MAAM,MAAM,EAAa,EAAa,EAAyC,CAC7E,EAAK,QAAQ,EAAI,CAAE,MAAK,GAAG,CAAK,CAAC,EACjC,EAAK,MAAM,EAAI,CAAE,MAAK,GAAG,CAAK,CAAC,EAC/B,MAAM,EAAK,CACb,EAEA,MAAM,OAAO,EAAuB,EAAyC,CAC3E,IAAM,EAAS,MAAM,QAAQ,CAAK,EAAI,EAAQ,CAAC,CAAK,EAEpD,IAAK,IAAM,KAAO,EAAG,QAAS,EAAI,SAAW,EAAO,SAAS,EAAI,KAAK,EACtE,EAAK,OAAO,CAAE,EACd,MAAM,EAAK,CACb,EAGA,MAAM,KAAK,EAA4C,EAA6B,CAClF,EAAG,MAAM,EACT,IAAK,IAAM,KAAQ,EACjB,EAAG,OAAS,EACZ,EAAK,MAAM,CAAE,EACb,EAAK,QAAQ,EAAI,CAAE,IAAK,CAAK,CAAC,EAC9B,EAAK,MAAM,EAAI,CAAE,IAAK,CAAK,CAAC,EAC5B,MAAM,EAAK,EAEb,EAAK,OAAO,CAAE,CAChB,EAEA,MAAM,QAAQ,EAA4B,CACxC,EAAK,aAAa,CAAE,EACpB,MAAM,EAAK,CACb,CACF"}
|
package/dist/testing/query.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function e(e,t,n){for(let r of e.querySelectorAll(n))if(r.textContent?.trim()===t)return r;return null}function t(e,t,n){return Array.from(e.querySelectorAll(n)).filter(e=>e.textContent?.trim()===t)}function n(n){return{query:e=>n.querySelector(e),queryAll:e=>Array.from(n.querySelectorAll(e)),queryAllByTestId:e=>Array.from(n.querySelectorAll(`[data-testid="${e}"]`)),queryAllByText:(e,r=`*`)=>t(n,e,r),queryByTestId:e=>n.querySelector(`[data-testid="${e}"]`),queryByText:(t,r=`*`)=>e(n,t,r)}}exports.queryAllByText=t,exports.queryByText=e,exports.within=n;
|
|
2
|
-
//# sourceMappingURL=query.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.cjs","names":[],"sources":["../../src/testing/query.ts"],"sourcesContent":["/**\n * DOM query helpers for test environments.\n */\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\n/** Scoped query helpers for any DOM element — see {@link within} */\nexport interface QueryScope {\n query<E extends Element = Element>(selector: string): E | null;\n queryAll<E extends Element = Element>(selector: string): E[];\n queryByText<E extends Element = Element>(text: string, selector?: string): E | null;\n queryAllByText<E extends Element = Element>(text: string, selector?: string): E[];\n queryByTestId<E extends Element = Element>(testId: string): E | null;\n queryAllByTestId<E extends Element = Element>(testId: string): E[];\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nexport function queryByText<E extends Element = Element>(\n root: Element | ShadowRoot,\n text: string,\n selector: string,\n): E | null {\n for (const el of root.querySelectorAll<E>(selector)) {\n if (el.textContent?.trim() === text) return el;\n }\n\n return null;\n}\n\nexport function queryAllByText<E extends Element = Element>(\n root: Element | ShadowRoot,\n text: string,\n selector: string,\n): E[] {\n return Array.from(root.querySelectorAll<E>(selector)).filter((el) => el.textContent?.trim() === text);\n}\n\n// ─── API ─────────────────────────────────────────────────────────────────────\n\n/**\n * Create query helpers scoped to any element — useful for slotted/light DOM content.\n *\n * @example\n * const panel = fixture.query('.panel')!;\n * const { query } = within(panel);\n * expect(query('.title')?.textContent).toBe('Hello');\n */\nexport function within(element: Element): QueryScope {\n return {\n query: <E extends Element = Element>(selector: string) => element.querySelector<E>(selector),\n queryAll: <E extends Element = Element>(selector: string) => Array.from(element.querySelectorAll<E>(selector)),\n queryAllByTestId: <E extends Element = Element>(testId: string) =>\n Array.from(element.querySelectorAll<E>(`[data-testid=\"${testId}\"]`)),\n queryAllByText: <E extends Element = Element>(text: string, selector = '*') =>\n queryAllByText<E>(element, text, selector),\n queryByTestId: <E extends Element = Element>(testId: string) =>\n element.querySelector<E>(`[data-testid=\"${testId}\"]`),\n queryByText: <E extends Element = Element>(text: string, selector = '*') => queryByText<E>(element, text, selector),\n };\n}\n"],"mappings":"AAkBA,SAAgB,EACd,EACA,EACA,EACU,CACV,IAAK,IAAM,KAAM,EAAK,iBAAoB,CAAQ,EAChD,GAAI,EAAG,aAAa,KAAK,IAAM,EAAM,OAAO,EAG9C,OAAO,IACT,CAEA,SAAgB,EACd,EACA,EACA,EACK,CACL,OAAO,MAAM,KAAK,EAAK,iBAAoB,CAAQ,CAAC,CAAC,CAAC,OAAQ,GAAO,EAAG,aAAa,KAAK,IAAM,CAAI,CACtG,CAYA,SAAgB,EAAO,EAA8B,CACnD,MAAO,CACL,MAAqC,GAAqB,EAAQ,cAAiB,CAAQ,EAC3F,SAAwC,GAAqB,MAAM,KAAK,EAAQ,iBAAoB,CAAQ,CAAC,EAC7G,iBAAgD,GAC9C,MAAM,KAAK,EAAQ,iBAAoB,iBAAiB,EAAO,GAAG,CAAC,EACrE,gBAA8C,EAAc,EAAW,MACrE,EAAkB,EAAS,EAAM,CAAQ,EAC3C,cAA6C,GAC3C,EAAQ,cAAiB,iBAAiB,EAAO,GAAG,EACtD,aAA2C,EAAc,EAAW,MAAQ,EAAe,EAAS,EAAM,CAAQ,CACpH,CACF"}
|
package/dist/testing/query.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOM query helpers for test environments.
|
|
3
|
-
*/
|
|
4
|
-
/** Scoped query helpers for any DOM element — see {@link within} */
|
|
5
|
-
export interface QueryScope {
|
|
6
|
-
query<E extends Element = Element>(selector: string): E | null;
|
|
7
|
-
queryAll<E extends Element = Element>(selector: string): E[];
|
|
8
|
-
queryByText<E extends Element = Element>(text: string, selector?: string): E | null;
|
|
9
|
-
queryAllByText<E extends Element = Element>(text: string, selector?: string): E[];
|
|
10
|
-
queryByTestId<E extends Element = Element>(testId: string): E | null;
|
|
11
|
-
queryAllByTestId<E extends Element = Element>(testId: string): E[];
|
|
12
|
-
}
|
|
13
|
-
export declare function queryByText<E extends Element = Element>(root: Element | ShadowRoot, text: string, selector: string): E | null;
|
|
14
|
-
export declare function queryAllByText<E extends Element = Element>(root: Element | ShadowRoot, text: string, selector: string): E[];
|
|
15
|
-
/**
|
|
16
|
-
* Create query helpers scoped to any element — useful for slotted/light DOM content.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* const panel = fixture.query('.panel')!;
|
|
20
|
-
* const { query } = within(panel);
|
|
21
|
-
* expect(query('.title')?.textContent).toBe('Hello');
|
|
22
|
-
*/
|
|
23
|
-
export declare function within(element: Element): QueryScope;
|
|
24
|
-
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/testing/query.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,oEAAoE;AACpE,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC;IAC/D,QAAQ,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;IAC7D,WAAW,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC;IACpF,cAAc,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;IAClF,aAAa,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC;IACrE,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;CACpE;AAID,wBAAgB,WAAW,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EACrD,IAAI,EAAE,OAAO,GAAG,UAAU,EAC1B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,CAAC,GAAG,IAAI,CAMV;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EACxD,IAAI,EAAE,OAAO,GAAG,UAAU,EAC1B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,CAAC,EAAE,CAEL;AAID;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAYnD"}
|
package/dist/testing/query.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function e(e,t,n){for(let r of e.querySelectorAll(n))if(r.textContent?.trim()===t)return r;return null}function t(e,t,n){return Array.from(e.querySelectorAll(n)).filter(e=>e.textContent?.trim()===t)}function n(n){return{query:e=>n.querySelector(e),queryAll:e=>Array.from(n.querySelectorAll(e)),queryAllByTestId:e=>Array.from(n.querySelectorAll(`[data-testid="${e}"]`)),queryAllByText:(e,r=`*`)=>t(n,e,r),queryByTestId:e=>n.querySelector(`[data-testid="${e}"]`),queryByText:(t,r=`*`)=>e(n,t,r)}}export{t as queryAllByText,e as queryByText,n as within};
|
|
2
|
-
//# sourceMappingURL=query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","names":[],"sources":["../../src/testing/query.ts"],"sourcesContent":["/**\n * DOM query helpers for test environments.\n */\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\n/** Scoped query helpers for any DOM element — see {@link within} */\nexport interface QueryScope {\n query<E extends Element = Element>(selector: string): E | null;\n queryAll<E extends Element = Element>(selector: string): E[];\n queryByText<E extends Element = Element>(text: string, selector?: string): E | null;\n queryAllByText<E extends Element = Element>(text: string, selector?: string): E[];\n queryByTestId<E extends Element = Element>(testId: string): E | null;\n queryAllByTestId<E extends Element = Element>(testId: string): E[];\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nexport function queryByText<E extends Element = Element>(\n root: Element | ShadowRoot,\n text: string,\n selector: string,\n): E | null {\n for (const el of root.querySelectorAll<E>(selector)) {\n if (el.textContent?.trim() === text) return el;\n }\n\n return null;\n}\n\nexport function queryAllByText<E extends Element = Element>(\n root: Element | ShadowRoot,\n text: string,\n selector: string,\n): E[] {\n return Array.from(root.querySelectorAll<E>(selector)).filter((el) => el.textContent?.trim() === text);\n}\n\n// ─── API ─────────────────────────────────────────────────────────────────────\n\n/**\n * Create query helpers scoped to any element — useful for slotted/light DOM content.\n *\n * @example\n * const panel = fixture.query('.panel')!;\n * const { query } = within(panel);\n * expect(query('.title')?.textContent).toBe('Hello');\n */\nexport function within(element: Element): QueryScope {\n return {\n query: <E extends Element = Element>(selector: string) => element.querySelector<E>(selector),\n queryAll: <E extends Element = Element>(selector: string) => Array.from(element.querySelectorAll<E>(selector)),\n queryAllByTestId: <E extends Element = Element>(testId: string) =>\n Array.from(element.querySelectorAll<E>(`[data-testid=\"${testId}\"]`)),\n queryAllByText: <E extends Element = Element>(text: string, selector = '*') =>\n queryAllByText<E>(element, text, selector),\n queryByTestId: <E extends Element = Element>(testId: string) =>\n element.querySelector<E>(`[data-testid=\"${testId}\"]`),\n queryByText: <E extends Element = Element>(text: string, selector = '*') => queryByText<E>(element, text, selector),\n };\n}\n"],"mappings":"AAkBA,SAAgB,EACd,EACA,EACA,EACU,CACV,IAAK,IAAM,KAAM,EAAK,iBAAoB,CAAQ,EAChD,GAAI,EAAG,aAAa,KAAK,IAAM,EAAM,OAAO,EAG9C,OAAO,IACT,CAEA,SAAgB,EACd,EACA,EACA,EACK,CACL,OAAO,MAAM,KAAK,EAAK,iBAAoB,CAAQ,CAAC,CAAC,CAAC,OAAQ,GAAO,EAAG,aAAa,KAAK,IAAM,CAAI,CACtG,CAYA,SAAgB,EAAO,EAA8B,CACnD,MAAO,CACL,MAAqC,GAAqB,EAAQ,cAAiB,CAAQ,EAC3F,SAAwC,GAAqB,MAAM,KAAK,EAAQ,iBAAoB,CAAQ,CAAC,EAC7G,iBAAgD,GAC9C,MAAM,KAAK,EAAQ,iBAAoB,iBAAiB,EAAO,GAAG,CAAC,EACrE,gBAA8C,EAAc,EAAW,MACrE,EAAkB,EAAS,EAAM,CAAQ,EAC3C,cAA6C,GAC3C,EAAQ,cAAiB,iBAAiB,EAAO,GAAG,EACtD,aAA2C,EAAc,EAAW,MAAQ,EAAe,EAAS,EAAM,CAAQ,CACpH,CACF"}
|
package/dist/testing/testing.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("./flush.cjs"),t=require("./dom.cjs"),n=require("./form-internals-polyfill.cjs"),r=require("./query.cjs"),i=require("./mount.cjs"),a=require("./events.cjs"),o=require("./interactions.cjs"),s=require("./wait.cjs"),c=require("./render-hook.cjs");function l(e){e(i.cleanup),n.installFormInternalsPolyfill()}exports.FLUSH_DEEP=e.FLUSH_DEEP,exports.cleanup=i.cleanup,exports.createPointerEvent=a.createPointerEvent,exports.fire=a.fire,exports.flush=e.flush,exports.install=l,exports.installFormInternalsPolyfill=n.installFormInternalsPolyfill,exports.mock=i.mock,exports.mount=i.mount,exports.mountComponent=i.mountComponent,exports.renderHook=c.renderHook,exports.user=o.user,exports.waitFor=s.waitFor,exports.waitForEvent=s.waitForEvent,exports.walkFlatTree=t.walkFlatTree,exports.within=r.within;
|
|
2
|
-
//# sourceMappingURL=testing.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testing.cjs","names":[],"sources":["../../src/testing/testing.ts"],"sourcesContent":["/**\n * Testing utilities for Ore components\n *\n * ⚠️ Requires DOM environment (browser / jsdom / happy-dom)\n *\n * This barrel re-exports the full testing API for convenience.\n * For tree-shaking, import directly from the focused sub-modules.\n */\n\nimport { installFormInternalsPolyfill } from './form-internals-polyfill';\nimport { cleanup } from './mount';\n\nexport { fire, createPointerEvent } from './events';\nexport { FLUSH_DEEP, flush, type FlushOptions } from './flush';\nexport { walkFlatTree } from './dom';\nexport { installFormInternalsPolyfill } from './form-internals-polyfill';\nexport { user } from './interactions';\nexport { cleanup, mock, mount, mountComponent, type Fixture, type MountOptions, type MountSetup } from './mount';\nexport { within, type QueryScope } from './query';\nexport { waitFor, waitForEvent, type WaitOptions } from './wait';\nexport { renderHook, type HookFixture } from './render-hook';\n\n/**\n * Register auto-cleanup after each test, and polyfill the jsdom/happy-dom gaps in\n * `ElementInternals`/`FormData`/`<form>.reset()` that `useField()` needs (see\n * `installFormInternalsPolyfill` — safe to call even in a suite with no form-associated\n * components; every patch it installs is a guarded no-op when its target is missing).\n * Call once in your test setup file.\n *\n * @example\n * // vitest.setup.ts\n * import { afterEach } from 'vitest';\n * import { install } from '@vielzeug/ore/testing';\n * install(afterEach);\n */\nexport function install(afterEachHook: (fn: () => void) => void): void {\n afterEachHook(cleanup);\n installFormInternalsPolyfill();\n}\n"],"mappings":"oQAmCA,SAAgB,EAAQ,EAA+C,CACrE,EAAc,EAAA,OAAO,EACrB,EAAA,6BAA6B,CAC/B"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Testing utilities for Ore components
|
|
3
|
-
*
|
|
4
|
-
* ⚠️ Requires DOM environment (browser / jsdom / happy-dom)
|
|
5
|
-
*
|
|
6
|
-
* This barrel re-exports the full testing API for convenience.
|
|
7
|
-
* For tree-shaking, import directly from the focused sub-modules.
|
|
8
|
-
*/
|
|
9
|
-
export { fire, createPointerEvent } from './events';
|
|
10
|
-
export { FLUSH_DEEP, flush, type FlushOptions } from './flush';
|
|
11
|
-
export { walkFlatTree } from './dom';
|
|
12
|
-
export { installFormInternalsPolyfill } from './form-internals-polyfill';
|
|
13
|
-
export { user } from './interactions';
|
|
14
|
-
export { cleanup, mock, mount, mountComponent, type Fixture, type MountOptions, type MountSetup } from './mount';
|
|
15
|
-
export { within, type QueryScope } from './query';
|
|
16
|
-
export { waitFor, waitForEvent, type WaitOptions } from './wait';
|
|
17
|
-
export { renderHook, type HookFixture } from './render-hook';
|
|
18
|
-
/**
|
|
19
|
-
* Register auto-cleanup after each test, and polyfill the jsdom/happy-dom gaps in
|
|
20
|
-
* `ElementInternals`/`FormData`/`<form>.reset()` that `useField()` needs (see
|
|
21
|
-
* `installFormInternalsPolyfill` — safe to call even in a suite with no form-associated
|
|
22
|
-
* components; every patch it installs is a guarded no-op when its target is missing).
|
|
23
|
-
* Call once in your test setup file.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* // vitest.setup.ts
|
|
27
|
-
* import { afterEach } from 'vitest';
|
|
28
|
-
* import { install } from '@vielzeug/ore/testing';
|
|
29
|
-
* install(afterEach);
|
|
30
|
-
*/
|
|
31
|
-
export declare function install(afterEachHook: (fn: () => void) => void): void;
|
|
32
|
-
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/testing/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AACjH,OAAO,EAAE,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,GAAG,IAAI,CAGrE"}
|
package/dist/testing/testing.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{FLUSH_DEEP as e,flush as t}from"./flush.js";import{walkFlatTree as n}from"./dom.js";import{installFormInternalsPolyfill as r}from"./form-internals-polyfill.js";import{within as i}from"./query.js";import{cleanup as a,mock as o,mount as s,mountComponent as c}from"./mount.js";import{createPointerEvent as l,fire as u}from"./events.js";import{user as d}from"./interactions.js";import{waitFor as f,waitForEvent as p}from"./wait.js";import{renderHook as m}from"./render-hook.js";function h(e){e(a),r()}export{e as FLUSH_DEEP,a as cleanup,l as createPointerEvent,u as fire,t as flush,h as install,r as installFormInternalsPolyfill,o as mock,s as mount,c as mountComponent,m as renderHook,d as user,f as waitFor,p as waitForEvent,n as walkFlatTree,i as within};
|
|
2
|
-
//# sourceMappingURL=testing.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","names":[],"sources":["../../src/testing/testing.ts"],"sourcesContent":["/**\n * Testing utilities for Ore components\n *\n * ⚠️ Requires DOM environment (browser / jsdom / happy-dom)\n *\n * This barrel re-exports the full testing API for convenience.\n * For tree-shaking, import directly from the focused sub-modules.\n */\n\nimport { installFormInternalsPolyfill } from './form-internals-polyfill';\nimport { cleanup } from './mount';\n\nexport { fire, createPointerEvent } from './events';\nexport { FLUSH_DEEP, flush, type FlushOptions } from './flush';\nexport { walkFlatTree } from './dom';\nexport { installFormInternalsPolyfill } from './form-internals-polyfill';\nexport { user } from './interactions';\nexport { cleanup, mock, mount, mountComponent, type Fixture, type MountOptions, type MountSetup } from './mount';\nexport { within, type QueryScope } from './query';\nexport { waitFor, waitForEvent, type WaitOptions } from './wait';\nexport { renderHook, type HookFixture } from './render-hook';\n\n/**\n * Register auto-cleanup after each test, and polyfill the jsdom/happy-dom gaps in\n * `ElementInternals`/`FormData`/`<form>.reset()` that `useField()` needs (see\n * `installFormInternalsPolyfill` — safe to call even in a suite with no form-associated\n * components; every patch it installs is a guarded no-op when its target is missing).\n * Call once in your test setup file.\n *\n * @example\n * // vitest.setup.ts\n * import { afterEach } from 'vitest';\n * import { install } from '@vielzeug/ore/testing';\n * install(afterEach);\n */\nexport function install(afterEachHook: (fn: () => void) => void): void {\n afterEachHook(cleanup);\n installFormInternalsPolyfill();\n}\n"],"mappings":"ieAmCA,SAAgB,EAAQ,EAA+C,CACrE,EAAc,CAAO,EACrB,EAA6B,CAC/B"}
|
package/dist/testing/wait.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("../errors.cjs");async function t(t,{interval:n=50,message:r,timeout:i=1e3}={}){let a=Date.now()+i,o,s=async()=>{try{let e=await t();return e===void 0||!!e}catch(e){return o=e,!1}};for(;Date.now()<a;){if(await s())return;await new Promise(e=>setTimeout(e,n))}if(await s())return;let c=r??`waitFor timed out after ${i}ms`;throw o instanceof Error?(o.message=`${c}\n${o.message}`,o):new e.OreTimeoutError(o==null?c:`${c}\nCause: ${o}`)}function n(t,n,r=1e3){return new Promise((i,a)=>{let o=e=>{clearTimeout(s),i(e)},s=setTimeout(()=>{t.removeEventListener(n,o),a(new e.OreTimeoutError(`waitForEvent: "${n}" timed out after ${r}ms`))},r);t.addEventListener(n,o,{once:!0})})}exports.waitFor=t,exports.waitForEvent=n;
|
|
2
|
-
//# sourceMappingURL=wait.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wait.cjs","names":[],"sources":["../../src/testing/wait.ts"],"sourcesContent":["/**\n * Async waiting utilities for test environments.\n */\n\nimport { OreTimeoutError } from '../errors';\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport interface WaitOptions {\n /** Maximum wait time in ms (default: 1000) */\n timeout?: number;\n /** Polling interval in ms (default: 50) */\n interval?: number;\n /** Message included in timeout error */\n message?: string;\n}\n\n// ─── API ─────────────────────────────────────────────────────────────────────\n\n/**\n * Poll until a callback returns truthy (or void) without throwing.\n * Supports both boolean conditions and `expect()` assertions.\n *\n * - Returns truthy → success\n * - Returns `undefined` (e.g. bare `expect()` call) → success\n * - Returns falsy value → retry\n * - Throws → retry, re-throw original error on timeout\n *\n * @example\n * await waitFor(() => query('.status')?.textContent === 'loaded');\n * await waitFor(() => expect(count).toBe(3));\n */\nexport async function waitFor(\n fn: () => unknown,\n { interval = 50, message, timeout = 1000 }: WaitOptions = {},\n): Promise<void> {\n const deadline = Date.now() + timeout;\n let lastError: unknown;\n\n const attempt = async (): Promise<boolean> => {\n try {\n const result = await fn();\n\n return result === undefined || !!result;\n } catch (e) {\n lastError = e;\n\n return false;\n }\n };\n\n while (Date.now() < deadline) {\n if (await attempt()) return;\n\n await new Promise((r) => setTimeout(r, interval));\n }\n\n if (await attempt()) return;\n\n const base = message ?? `waitFor timed out after ${timeout}ms`;\n\n if (lastError instanceof Error) {\n lastError.message = `${base}\\n${lastError.message}`;\n throw lastError;\n }\n\n throw new OreTimeoutError(lastError != null ? `${base}\\nCause: ${lastError}` : base);\n}\n\n/**\n * Resolve when the target element emits the given event.\n *\n * @example\n * const promise = waitForEvent(el, 'change');\n * fire.click(trigger);\n * const event = await promise;\n */\nexport function waitForEvent<T extends Event = Event>(element: Element, name: string, timeout = 1000): Promise<T> {\n return new Promise((resolve, reject) => {\n const onEvent = (e: Event): void => {\n clearTimeout(timer);\n resolve(e as T);\n };\n const timer = setTimeout(() => {\n element.removeEventListener(name, onEvent);\n reject(new OreTimeoutError(`waitForEvent: \"${name}\" timed out after ${timeout}ms`));\n }, timeout);\n\n element.addEventListener(name, onEvent, { once: true });\n });\n}\n"],"mappings":"iCAgCA,eAAsB,EACpB,EACA,CAAE,WAAW,GAAI,UAAS,UAAU,KAAsB,CAAC,EAC5C,CACf,IAAM,EAAW,KAAK,IAAI,EAAI,EAC1B,EAEE,EAAU,SAA8B,CAC5C,GAAI,CACF,IAAM,EAAS,MAAM,EAAG,EAExB,OAAO,IAAW,IAAA,IAAa,CAAC,CAAC,CACnC,OAAS,EAAG,CAGV,MAFA,GAAY,EAEL,EACT,CACF,EAEA,KAAO,KAAK,IAAI,EAAI,GAAU,CAC5B,GAAI,MAAM,EAAQ,EAAG,OAErB,MAAM,IAAI,QAAS,GAAM,WAAW,EAAG,CAAQ,CAAC,CAClD,CAEA,GAAI,MAAM,EAAQ,EAAG,OAErB,IAAM,EAAO,GAAW,2BAA2B,EAAQ,IAO3D,MALI,aAAqB,OACvB,EAAU,QAAU,GAAG,EAAK,IAAI,EAAU,UACpC,GAGF,IAAI,EAAA,gBAAgB,GAAa,KAAwC,EAAjC,GAAG,EAAK,WAAW,GAAkB,CACrF,CAUA,SAAgB,EAAsC,EAAkB,EAAc,EAAU,IAAkB,CAChH,OAAO,IAAI,SAAS,EAAS,IAAW,CACtC,IAAM,EAAW,GAAmB,CAClC,aAAa,CAAK,EAClB,EAAQ,CAAM,CAChB,EACM,EAAQ,eAAiB,CAC7B,EAAQ,oBAAoB,EAAM,CAAO,EACzC,EAAO,IAAI,EAAA,gBAAgB,kBAAkB,EAAK,oBAAoB,EAAQ,GAAG,CAAC,CACpF,EAAG,CAAO,EAEV,EAAQ,iBAAiB,EAAM,EAAS,CAAE,KAAM,EAAK,CAAC,CACxD,CAAC,CACH"}
|
package/dist/testing/wait.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Async waiting utilities for test environments.
|
|
3
|
-
*/
|
|
4
|
-
export interface WaitOptions {
|
|
5
|
-
/** Maximum wait time in ms (default: 1000) */
|
|
6
|
-
timeout?: number;
|
|
7
|
-
/** Polling interval in ms (default: 50) */
|
|
8
|
-
interval?: number;
|
|
9
|
-
/** Message included in timeout error */
|
|
10
|
-
message?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Poll until a callback returns truthy (or void) without throwing.
|
|
14
|
-
* Supports both boolean conditions and `expect()` assertions.
|
|
15
|
-
*
|
|
16
|
-
* - Returns truthy → success
|
|
17
|
-
* - Returns `undefined` (e.g. bare `expect()` call) → success
|
|
18
|
-
* - Returns falsy value → retry
|
|
19
|
-
* - Throws → retry, re-throw original error on timeout
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* await waitFor(() => query('.status')?.textContent === 'loaded');
|
|
23
|
-
* await waitFor(() => expect(count).toBe(3));
|
|
24
|
-
*/
|
|
25
|
-
export declare function waitFor(fn: () => unknown, { interval, message, timeout }?: WaitOptions): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Resolve when the target element emits the given event.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* const promise = waitForEvent(el, 'change');
|
|
31
|
-
* fire.click(trigger);
|
|
32
|
-
* const event = await promise;
|
|
33
|
-
*/
|
|
34
|
-
export declare function waitForEvent<T extends Event = Event>(element: Element, name: string, timeout?: number): Promise<T>;
|
|
35
|
-
//# sourceMappingURL=wait.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wait.d.ts","sourceRoot":"","sources":["../../src/testing/wait.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,WAAW,WAAW;IAC1B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAID;;;;;;;;;;;;GAYG;AACH,wBAAsB,OAAO,CAC3B,EAAE,EAAE,MAAM,OAAO,EACjB,EAAE,QAAa,EAAE,OAAO,EAAE,OAAc,EAAE,GAAE,WAAgB,GAC3D,OAAO,CAAC,IAAI,CAAC,CAgCf;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,SAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAahH"}
|
package/dist/testing/wait.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{OreTimeoutError as e}from"../errors.js";async function t(t,{interval:n=50,message:r,timeout:i=1e3}={}){let a=Date.now()+i,o,s=async()=>{try{let e=await t();return e===void 0||!!e}catch(e){return o=e,!1}};for(;Date.now()<a;){if(await s())return;await new Promise(e=>setTimeout(e,n))}if(await s())return;let c=r??`waitFor timed out after ${i}ms`;throw o instanceof Error?(o.message=`${c}\n${o.message}`,o):new e(o==null?c:`${c}\nCause: ${o}`)}function n(t,n,r=1e3){return new Promise((i,a)=>{let o=e=>{clearTimeout(s),i(e)},s=setTimeout(()=>{t.removeEventListener(n,o),a(new e(`waitForEvent: "${n}" timed out after ${r}ms`))},r);t.addEventListener(n,o,{once:!0})})}export{t as waitFor,n as waitForEvent};
|
|
2
|
-
//# sourceMappingURL=wait.js.map
|
package/dist/testing/wait.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wait.js","names":[],"sources":["../../src/testing/wait.ts"],"sourcesContent":["/**\n * Async waiting utilities for test environments.\n */\n\nimport { OreTimeoutError } from '../errors';\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport interface WaitOptions {\n /** Maximum wait time in ms (default: 1000) */\n timeout?: number;\n /** Polling interval in ms (default: 50) */\n interval?: number;\n /** Message included in timeout error */\n message?: string;\n}\n\n// ─── API ─────────────────────────────────────────────────────────────────────\n\n/**\n * Poll until a callback returns truthy (or void) without throwing.\n * Supports both boolean conditions and `expect()` assertions.\n *\n * - Returns truthy → success\n * - Returns `undefined` (e.g. bare `expect()` call) → success\n * - Returns falsy value → retry\n * - Throws → retry, re-throw original error on timeout\n *\n * @example\n * await waitFor(() => query('.status')?.textContent === 'loaded');\n * await waitFor(() => expect(count).toBe(3));\n */\nexport async function waitFor(\n fn: () => unknown,\n { interval = 50, message, timeout = 1000 }: WaitOptions = {},\n): Promise<void> {\n const deadline = Date.now() + timeout;\n let lastError: unknown;\n\n const attempt = async (): Promise<boolean> => {\n try {\n const result = await fn();\n\n return result === undefined || !!result;\n } catch (e) {\n lastError = e;\n\n return false;\n }\n };\n\n while (Date.now() < deadline) {\n if (await attempt()) return;\n\n await new Promise((r) => setTimeout(r, interval));\n }\n\n if (await attempt()) return;\n\n const base = message ?? `waitFor timed out after ${timeout}ms`;\n\n if (lastError instanceof Error) {\n lastError.message = `${base}\\n${lastError.message}`;\n throw lastError;\n }\n\n throw new OreTimeoutError(lastError != null ? `${base}\\nCause: ${lastError}` : base);\n}\n\n/**\n * Resolve when the target element emits the given event.\n *\n * @example\n * const promise = waitForEvent(el, 'change');\n * fire.click(trigger);\n * const event = await promise;\n */\nexport function waitForEvent<T extends Event = Event>(element: Element, name: string, timeout = 1000): Promise<T> {\n return new Promise((resolve, reject) => {\n const onEvent = (e: Event): void => {\n clearTimeout(timer);\n resolve(e as T);\n };\n const timer = setTimeout(() => {\n element.removeEventListener(name, onEvent);\n reject(new OreTimeoutError(`waitForEvent: \"${name}\" timed out after ${timeout}ms`));\n }, timeout);\n\n element.addEventListener(name, onEvent, { once: true });\n });\n}\n"],"mappings":"+CAgCA,eAAsB,EACpB,EACA,CAAE,WAAW,GAAI,UAAS,UAAU,KAAsB,CAAC,EAC5C,CACf,IAAM,EAAW,KAAK,IAAI,EAAI,EAC1B,EAEE,EAAU,SAA8B,CAC5C,GAAI,CACF,IAAM,EAAS,MAAM,EAAG,EAExB,OAAO,IAAW,IAAA,IAAa,CAAC,CAAC,CACnC,OAAS,EAAG,CAGV,MAFA,GAAY,EAEL,EACT,CACF,EAEA,KAAO,KAAK,IAAI,EAAI,GAAU,CAC5B,GAAI,MAAM,EAAQ,EAAG,OAErB,MAAM,IAAI,QAAS,GAAM,WAAW,EAAG,CAAQ,CAAC,CAClD,CAEA,GAAI,MAAM,EAAQ,EAAG,OAErB,IAAM,EAAO,GAAW,2BAA2B,EAAQ,IAO3D,MALI,aAAqB,OACvB,EAAU,QAAU,GAAG,EAAK,IAAI,EAAU,UACpC,GAGF,IAAI,EAAgB,GAAa,KAAwC,EAAjC,GAAG,EAAK,WAAW,GAAkB,CACrF,CAUA,SAAgB,EAAsC,EAAkB,EAAc,EAAU,IAAkB,CAChH,OAAO,IAAI,SAAS,EAAS,IAAW,CACtC,IAAM,EAAW,GAAmB,CAClC,aAAa,CAAK,EAClB,EAAQ,CAAM,CAChB,EACM,EAAQ,eAAiB,CAC7B,EAAQ,oBAAoB,EAAM,CAAO,EACzC,EAAO,IAAI,EAAgB,kBAAkB,EAAK,oBAAoB,EAAQ,GAAG,CAAC,CACpF,EAAG,CAAO,EAEV,EAAQ,iBAAiB,EAAM,EAAS,CAAE,KAAM,EAAK,CAAC,CACxD,CAAC,CACH"}
|
package/dist/types/bindings.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
let e=require("@vielzeug/ripple");function t(){return(0,e.signal)(null)}var n=e=>{let t=Symbol.for(e);return{is:e=>typeof e==`object`&&!!e&&t in e,stamp:e=>Object.assign(e,{[t]:!0})}},r=n(`ore:directive`),i=e=>r.stamp({mount:e}),a=r.is,o=n(`ore:spread`),s=e=>o.stamp({apply:e}),c=o.is,l=n(`ore:html-result`),u=l.is;function d(e,t){return l.stamp({apply:t,fragment:e,mount:(n,r,i)=>{let a=Array.from(e.childNodes);return n.insertBefore(e,r),t(i),a}})}exports.createDirectiveResult=i,exports.createHtmlResult=d,exports.createSpreadObject=s,exports.isDirectiveResult=a,exports.isHtmlResult=u,exports.isSpreadObject=c,exports.ref=t;
|
|
2
|
-
//# sourceMappingURL=bindings.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.cjs","names":[],"sources":["../../src/types/bindings.ts"],"sourcesContent":["/**\n * Core type definitions for the template binding and rendering system.\n *\n * All bindings reference actual DOM nodes directly (no UID-based lookup).\n * This eliminates the TreeWalker indexing pass and the string-based ID remapping\n * that the previous design required.\n */\n\nimport { type Readable, signal, type Signal } from '@vielzeug/ripple';\n\n// ─── REF TYPES ───────────────────────────────────────────────────────────────\n\nexport type Ref<T extends Element> = Signal<T | null>;\n\nexport function ref<T extends Element>(): Ref<T> {\n return signal<T | null>(null);\n}\n\nexport type RefCallback<T extends Element> = (el: T | null) => void;\n\n// ─── BINDING VARIANTS ────────────────────────────────────────────────────────\n// All bindings hold direct references to the DOM node they manage.\n\nexport type TextBinding = {\n node: Text;\n signal: Readable<unknown>;\n type: 'text';\n};\n\n/**\n * Minimal prop metadata needed by the attr binding layer.\n * Populated at binding creation time from propRegistry, so template-bindings.ts\n * has no direct dependency on props.ts.\n */\nexport type AttrPropMeta = {\n parse: (v: string | null) => unknown;\n reflect: boolean;\n signal: { value: unknown };\n};\n\ntype AttrBaseFields = {\n el: HTMLElement;\n /**\n * When true the binding uses live-write semantics: stale app-state writes are\n * skipped if the DOM value has diverged from the last programmatic write.\n */\n live?: true;\n mode: 'attr' | 'bool';\n name: string;\n /** Pre-resolved prop metadata (if the target element is an ore component). */\n propMeta?: AttrPropMeta;\n type: 'attr';\n};\n\n/** Attribute binding with a static value (no signal). */\nexport type AttrStaticBinding = AttrBaseFields & { value: unknown };\n\n/** Attribute binding driven by a reactive signal. */\nexport type AttrReactiveBinding = AttrBaseFields & { signal: Readable<unknown> };\n\nexport type AttrBinding = AttrStaticBinding | AttrReactiveBinding;\n\nexport type EventBinding = {\n el: HTMLElement;\n handler: (e: Event) => void;\n name: string;\n options?: AddEventListenerOptions;\n type: 'event';\n};\n\nexport type RefBinding = {\n el: HTMLElement;\n ref: Ref<Element> | RefCallback<Element>;\n type: 'ref';\n};\n\n/** Value types a reactive HTML slot can produce. */\nexport type HtmlBindingValue = HTMLResult | string | number | boolean | null | undefined;\n\nexport type HtmlBinding = {\n anchor: Comment;\n signal: Readable<HtmlBindingValue[]>;\n type: 'html';\n};\n\nexport type DirectiveBinding = {\n anchor: Comment;\n directive: DirectiveResult;\n type: 'directive';\n};\n\n/** Element-spread binding applied by model() and similar helpers. */\nexport type SpreadBinding = {\n el: HTMLElement;\n spread: SpreadObject;\n type: 'spread';\n};\n\nexport type Binding =\n TextBinding | AttrBinding | EventBinding | RefBinding | HtmlBinding | DirectiveBinding | SpreadBinding;\n\n// ─── BRAND UTILITY ───────────────────────────────────────────────────────────\n// Cross-realm–safe brand for branded types. Avoids repeating the symbol+guard boilerplate.\n\nconst makeBrand = <T extends object>(key: string) => {\n const BRAND = Symbol.for(key);\n const stamp = (obj: T): T => Object.assign(obj, { [BRAND]: true });\n const is = (value: unknown): value is T => typeof value === 'object' && value !== null && BRAND in (value as object);\n\n return { is, stamp };\n};\n\n// ─── DIRECTIVE RESULT ────────────────────────────────────────────────────────\n\nexport type DirectiveResult = {\n mount: (anchor: Comment, registerCleanup: (fn: () => void) => void) => void;\n};\n\nconst directiveBrand = makeBrand<DirectiveResult>('ore:directive');\n\n/**\n * Creates a registered DirectiveResult. All directive factories must use this\n * function — only objects created here pass `isDirectiveResult()`.\n */\nexport const createDirectiveResult = (mount: DirectiveResult['mount']): DirectiveResult =>\n directiveBrand.stamp({ mount });\n\nexport const isDirectiveResult = directiveBrand.is;\n\n// ─── SPREAD OBJECT ───────────────────────────────────────────────────────────\n// Returned by model() and similar helpers that apply multiple bindings to one element.\n\nexport type SpreadObject = {\n apply(el: HTMLElement, registerCleanup: (fn: () => void) => void): void;\n};\n\nconst spreadBrand = makeBrand<SpreadObject>('ore:spread');\n\n/**\n * Creates a registered SpreadObject. Used by model() to attach multiple bindings\n * (value sync + input event) to an element via a single template expression.\n */\nexport const createSpreadObject = (apply: SpreadObject['apply']): SpreadObject => spreadBrand.stamp({ apply });\n\nexport const isSpreadObject = spreadBrand.is;\n\n// ─── HTML RESULT ─────────────────────────────────────────────────────────────\n\n/**\n * The output of an `html` tagged template call.\n *\n * Each `html` call produces an independent fragment — there is no shared mutable\n * state between instances, so the same template can be safely rendered multiple\n * times (e.g. inside `each()`).\n */\nexport interface HTMLResult {\n /** The DOM fragment ready to insert into the document. Consumed on insertion. */\n readonly fragment: DocumentFragment;\n /** Wire up reactive effects to the fragment's nodes. Call after insertion. */\n apply(registerCleanup: (fn: () => void) => void): void;\n /**\n * Insert the fragment before `anchor` (or append to `parent` when no anchor)\n * and immediately wire up all reactive effects.\n *\n * This is the preferred single-step API — it is impossible to forget calling\n * `apply` separately. Use the lower-level `fragment` + `apply` only when you\n * need precise control over insertion (e.g. inside directive implementations).\n */\n mount(parent: ParentNode, anchor: Node | null, registerCleanup: (fn: () => void) => void): Node[];\n}\n\nconst htmlResultBrand = makeBrand<HTMLResult>('ore:html-result');\n\nexport const isHtmlResult = htmlResultBrand.is;\n\nexport function createHtmlResult(\n fragment: DocumentFragment,\n applyFn: (registerCleanup: (fn: () => void) => void) => void,\n): HTMLResult {\n const mount = (parent: ParentNode, anchor: Node | null, registerCleanup: (fn: () => void) => void): Node[] => {\n const nodes = Array.from(fragment.childNodes);\n\n parent.insertBefore(fragment, anchor);\n applyFn(registerCleanup);\n\n return nodes;\n };\n\n return htmlResultBrand.stamp({ apply: applyFn, fragment, mount });\n}\n"],"mappings":"kCAcA,SAAgB,GAAiC,CAC/C,OAAA,EAAA,EAAA,OAAA,CAAwB,IAAI,CAC9B,CAwFA,IAAM,EAA+B,GAAgB,CACnD,IAAM,EAAQ,OAAO,IAAI,CAAG,EAI5B,MAAO,CAAE,GAFG,GAA+B,OAAO,GAAU,YAAY,GAAkB,KAAU,EAEvF,MAHE,GAAc,OAAO,OAAO,EAAK,EAAG,GAAQ,EAAK,CAAC,CAG9C,CACrB,EAQM,EAAiB,EAA2B,eAAe,EAMpD,EAAyB,GACpC,EAAe,MAAM,CAAE,OAAM,CAAC,EAEnB,EAAoB,EAAe,GAS1C,EAAc,EAAwB,YAAY,EAM3C,EAAsB,GAA+C,EAAY,MAAM,CAAE,OAAM,CAAC,EAEhG,EAAiB,EAAY,GA2BpC,EAAkB,EAAsB,iBAAiB,EAElD,EAAe,EAAgB,GAE5C,SAAgB,EACd,EACA,EACY,CAUZ,OAAO,EAAgB,MAAM,CAAE,MAAO,EAAS,WAAU,OAT1C,EAAoB,EAAqB,IAAsD,CAC5G,IAAM,EAAQ,MAAM,KAAK,EAAS,UAAU,EAK5C,OAHA,EAAO,aAAa,EAAU,CAAM,EACpC,EAAQ,CAAe,EAEhB,CACT,CAE+D,CAAC,CAClE"}
|