@hyperfixi/behaviors 3.3.0 → 4.0.1
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/CHANGELOG.md +199 -1
- package/README.md +29 -9
- package/dist/all.browser.global.js +45 -100
- package/dist/all.browser.global.js.map +1 -1
- package/dist/autodismiss.browser.global.js +5 -11
- package/dist/autodismiss.browser.global.js.map +1 -1
- package/dist/behaviors/autodismiss.cjs +19 -22
- package/dist/behaviors/autodismiss.cjs.map +1 -1
- package/dist/behaviors/autodismiss.d.cts +4 -4
- package/dist/behaviors/autodismiss.d.ts +4 -4
- package/dist/behaviors/autodismiss.js +3 -3
- package/dist/behaviors/clickoutside.cjs +19 -18
- package/dist/behaviors/clickoutside.cjs.map +1 -1
- package/dist/behaviors/clickoutside.d.cts +4 -4
- package/dist/behaviors/clickoutside.d.ts +4 -4
- package/dist/behaviors/clickoutside.js +3 -3
- package/dist/behaviors/clipboard.cjs +18 -19
- package/dist/behaviors/clipboard.cjs.map +1 -1
- package/dist/behaviors/clipboard.d.cts +4 -4
- package/dist/behaviors/clipboard.d.ts +4 -4
- package/dist/behaviors/clipboard.js +3 -3
- package/dist/behaviors/draggable.cjs +20 -25
- package/dist/behaviors/draggable.cjs.map +1 -1
- package/dist/behaviors/draggable.d.cts +4 -4
- package/dist/behaviors/draggable.d.ts +4 -4
- package/dist/behaviors/draggable.js +3 -3
- package/dist/behaviors/focustrap.cjs +18 -19
- package/dist/behaviors/focustrap.cjs.map +1 -1
- package/dist/behaviors/focustrap.d.cts +4 -4
- package/dist/behaviors/focustrap.d.ts +4 -4
- package/dist/behaviors/focustrap.js +3 -3
- package/dist/behaviors/removable.cjs +18 -21
- package/dist/behaviors/removable.cjs.map +1 -1
- package/dist/behaviors/removable.d.cts +4 -3
- package/dist/behaviors/removable.d.ts +4 -3
- package/dist/behaviors/removable.js +3 -3
- package/dist/behaviors/resizable.cjs +19 -19
- package/dist/behaviors/resizable.cjs.map +1 -1
- package/dist/behaviors/resizable.d.cts +4 -4
- package/dist/behaviors/resizable.d.ts +4 -4
- package/dist/behaviors/resizable.js +3 -3
- package/dist/behaviors/scrollreveal.cjs +19 -22
- package/dist/behaviors/scrollreveal.cjs.map +1 -1
- package/dist/behaviors/scrollreveal.d.cts +4 -4
- package/dist/behaviors/scrollreveal.d.ts +4 -4
- package/dist/behaviors/scrollreveal.js +3 -3
- package/dist/behaviors/sortable.cjs +19 -20
- package/dist/behaviors/sortable.cjs.map +1 -1
- package/dist/behaviors/sortable.d.cts +4 -4
- package/dist/behaviors/sortable.d.ts +4 -4
- package/dist/behaviors/sortable.js +3 -3
- package/dist/behaviors/tabs.cjs +20 -25
- package/dist/behaviors/tabs.cjs.map +1 -1
- package/dist/behaviors/tabs.d.cts +4 -4
- package/dist/behaviors/tabs.d.ts +4 -4
- package/dist/behaviors/tabs.js +3 -3
- package/dist/behaviors/toggleable.cjs +25 -26
- package/dist/behaviors/toggleable.cjs.map +1 -1
- package/dist/behaviors/toggleable.d.cts +4 -4
- package/dist/behaviors/toggleable.d.ts +4 -4
- package/dist/behaviors/toggleable.js +3 -3
- package/dist/chunk-2GIS4DCY.js +30 -0
- package/dist/chunk-2GIS4DCY.js.map +1 -0
- package/dist/chunk-3BCBZR6R.js +30 -0
- package/dist/chunk-3BCBZR6R.js.map +1 -0
- package/dist/chunk-4YUIDZAO.js +30 -0
- package/dist/chunk-4YUIDZAO.js.map +1 -0
- package/dist/{chunk-XYZ7FOXJ.js → chunk-AQCOK5J5.js} +10 -14
- package/dist/chunk-AQCOK5J5.js.map +1 -0
- package/dist/chunk-ATGHQQC7.js +30 -0
- package/dist/chunk-ATGHQQC7.js.map +1 -0
- package/dist/{chunk-HQDYH45I.js → chunk-CWLAXLWR.js} +5 -13
- package/dist/chunk-CWLAXLWR.js.map +1 -0
- package/dist/chunk-DMWN52SV.js +30 -0
- package/dist/chunk-DMWN52SV.js.map +1 -0
- package/dist/{chunk-PDMOOWFW.js → chunk-EIVPVTUI.js} +4 -8
- package/dist/{chunk-PDMOOWFW.js.map → chunk-EIVPVTUI.js.map} +1 -1
- package/dist/chunk-HHTEMPIT.js +30 -0
- package/dist/chunk-HHTEMPIT.js.map +1 -0
- package/dist/{chunk-26IX7QU7.js → chunk-HJESSMKB.js} +4 -6
- package/dist/{chunk-26IX7QU7.js.map → chunk-HJESSMKB.js.map} +1 -1
- package/dist/{chunk-5S7WN3ZQ.js → chunk-IFAH652L.js} +4 -7
- package/dist/chunk-IFAH652L.js.map +1 -0
- package/dist/chunk-IUGJG4RA.js +30 -0
- package/dist/chunk-IUGJG4RA.js.map +1 -0
- package/dist/{chunk-ZR66E3T6.js → chunk-JNLVXPHR.js} +13 -13
- package/dist/chunk-KEZEGPEX.js +30 -0
- package/dist/chunk-KEZEGPEX.js.map +1 -0
- package/dist/{chunk-66U2RSYJ.js → chunk-KP4GNXYS.js} +4 -10
- package/dist/chunk-KP4GNXYS.js.map +1 -0
- package/dist/chunk-KXQMCN4O.js +30 -0
- package/dist/chunk-KXQMCN4O.js.map +1 -0
- package/dist/{chunk-YXS27XM6.js → chunk-KYBOZ7C4.js} +3 -7
- package/dist/chunk-KYBOZ7C4.js.map +1 -0
- package/dist/chunk-LBWM6TTU.js +30 -0
- package/dist/chunk-LBWM6TTU.js.map +1 -0
- package/dist/{chunk-3DVDS7CT.js → chunk-LCDONZBX.js} +5 -5
- package/dist/chunk-LCDONZBX.js.map +1 -0
- package/dist/{chunk-OJ3YWO3W.js → chunk-NE76IBV2.js} +3 -7
- package/dist/chunk-NE76IBV2.js.map +1 -0
- package/dist/{chunk-HMU342XE.js → chunk-PVO6TZCZ.js} +3 -9
- package/dist/{chunk-HMU342XE.js.map → chunk-PVO6TZCZ.js.map} +1 -1
- package/dist/{chunk-URZGNPTQ.js → chunk-RILYRQ72.js} +4 -10
- package/dist/chunk-RILYRQ72.js.map +1 -0
- package/dist/{chunk-FBQ3X3UY.js → chunk-U4QMFVAM.js} +5 -13
- package/dist/chunk-U4QMFVAM.js.map +1 -0
- package/dist/chunk-VWDTOSE3.js +26 -0
- package/dist/chunk-VWDTOSE3.js.map +1 -0
- package/dist/chunk-YRQBU2OW.js +30 -0
- package/dist/chunk-YRQBU2OW.js.map +1 -0
- package/dist/clickoutside.browser.global.js +5 -7
- package/dist/clickoutside.browser.global.js.map +1 -1
- package/dist/clipboard.browser.global.js +4 -8
- package/dist/clipboard.browser.global.js.map +1 -1
- package/dist/core.browser.global.js +13 -25
- package/dist/core.browser.global.js.map +1 -1
- package/dist/draggable.browser.global.js +5 -13
- package/dist/draggable.browser.global.js.map +1 -1
- package/dist/focustrap.browser.global.js +4 -8
- package/dist/focustrap.browser.global.js.map +1 -1
- package/dist/index.cjs +96 -271
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +42 -55
- package/dist/index.js.map +1 -1
- package/dist/loaders.cjs +75 -237
- package/dist/loaders.cjs.map +1 -1
- package/dist/loaders.js +13 -13
- package/dist/registry.cjs +4 -4
- package/dist/registry.cjs.map +1 -1
- package/dist/registry.d.cts +5 -6
- package/dist/registry.d.ts +5 -6
- package/dist/registry.js +1 -1
- package/dist/removable.browser.global.js +3 -9
- package/dist/removable.browser.global.js.map +1 -1
- package/dist/resizable.browser.global.js +4 -7
- package/dist/resizable.browser.global.js.map +1 -1
- package/dist/resolver.browser.global.js +45 -100
- package/dist/resolver.browser.global.js.map +1 -1
- package/dist/schemas/index.cjs +38 -93
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +2 -2
- package/dist/schemas/index.d.ts +2 -2
- package/dist/schemas/index.js +11 -11
- package/dist/schemas/index.js.map +1 -1
- package/dist/scrollreveal.browser.global.js +5 -11
- package/dist/scrollreveal.browser.global.js.map +1 -1
- package/dist/sortable.browser.global.js +5 -9
- package/dist/sortable.browser.global.js.map +1 -1
- package/dist/tabs.browser.global.js +6 -14
- package/dist/tabs.browser.global.js.map +1 -1
- package/dist/toggleable.browser.global.js +9 -13
- package/dist/toggleable.browser.global.js.map +1 -1
- package/dist/{types-DCCtVQS5.d.cts → types-CbA4L8XJ.d.cts} +16 -23
- package/dist/{types-DCCtVQS5.d.ts → types-CbA4L8XJ.d.ts} +16 -23
- package/package.json +5 -5
- package/src/behavior-resolver.ts +24 -56
- package/src/behaviors/autodismiss.test.ts +12 -20
- package/src/behaviors/autodismiss.ts +8 -23
- package/src/behaviors/clickoutside.test.ts +13 -21
- package/src/behaviors/clickoutside.ts +8 -23
- package/src/behaviors/clipboard.test.ts +12 -34
- package/src/behaviors/clipboard.ts +8 -23
- package/src/behaviors/curated-runtime.test.ts +22 -24
- package/src/behaviors/draggable.ts +10 -24
- package/src/behaviors/experimental-runtime.test.ts +19 -18
- package/src/behaviors/focustrap.test.ts +12 -20
- package/src/behaviors/focustrap.ts +8 -23
- package/src/behaviors/integration.test.ts +19 -54
- package/src/behaviors/optional-runtime.test.ts +17 -22
- package/src/behaviors/removable.ts +6 -20
- package/src/behaviors/resizable.ts +9 -24
- package/src/behaviors/scrollreveal.test.ts +13 -21
- package/src/behaviors/scrollreveal.ts +8 -23
- package/src/behaviors/sortable.ts +7 -22
- package/src/behaviors/tabs.test.ts +12 -34
- package/src/behaviors/tabs.ts +8 -23
- package/src/behaviors/toggleable.ts +10 -26
- package/src/browser-resolver-bundle.ts +20 -30
- package/src/core-bundle.ts +11 -11
- package/src/index.test.ts +2 -2
- package/src/index.ts +30 -47
- package/src/registry.test.ts +9 -34
- package/src/registry.ts +7 -11
- package/src/schemas/autodismiss.schema.ts +3 -9
- package/src/schemas/clickoutside.schema.ts +3 -5
- package/src/schemas/clipboard.schema.ts +2 -6
- package/src/schemas/draggable.schema.ts +4 -12
- package/src/schemas/focustrap.schema.ts +2 -6
- package/src/schemas/index.ts +2 -1
- package/src/schemas/removable.schema.ts +2 -8
- package/src/schemas/resizable.schema.ts +3 -6
- package/src/schemas/scrollreveal.schema.ts +3 -9
- package/src/schemas/sortable.schema.ts +3 -7
- package/src/schemas/tabs.schema.ts +4 -12
- package/src/schemas/toggleable.schema.ts +10 -13
- package/src/schemas/types.ts +37 -30
- package/dist/chunk-2HUF6RMI.js +0 -40
- package/dist/chunk-2HUF6RMI.js.map +0 -1
- package/dist/chunk-3DVDS7CT.js.map +0 -1
- package/dist/chunk-5S7WN3ZQ.js.map +0 -1
- package/dist/chunk-66U2RSYJ.js.map +0 -1
- package/dist/chunk-6TJXDCAQ.js +0 -11
- package/dist/chunk-6TJXDCAQ.js.map +0 -1
- package/dist/chunk-7TPDLB7W.js +0 -40
- package/dist/chunk-7TPDLB7W.js.map +0 -1
- package/dist/chunk-CR3J7VV6.js +0 -40
- package/dist/chunk-CR3J7VV6.js.map +0 -1
- package/dist/chunk-EDBG2F57.js +0 -40
- package/dist/chunk-EDBG2F57.js.map +0 -1
- package/dist/chunk-FBQ3X3UY.js.map +0 -1
- package/dist/chunk-HQDYH45I.js.map +0 -1
- package/dist/chunk-HX663BJ4.js +0 -40
- package/dist/chunk-HX663BJ4.js.map +0 -1
- package/dist/chunk-KROW43CG.js +0 -40
- package/dist/chunk-KROW43CG.js.map +0 -1
- package/dist/chunk-L52AGCMP.js +0 -40
- package/dist/chunk-L52AGCMP.js.map +0 -1
- package/dist/chunk-MTI5PSRH.js +0 -40
- package/dist/chunk-MTI5PSRH.js.map +0 -1
- package/dist/chunk-OJ3YWO3W.js.map +0 -1
- package/dist/chunk-ORBJ7MRW.js +0 -40
- package/dist/chunk-ORBJ7MRW.js.map +0 -1
- package/dist/chunk-SLSCZV4A.js +0 -40
- package/dist/chunk-SLSCZV4A.js.map +0 -1
- package/dist/chunk-URZGNPTQ.js.map +0 -1
- package/dist/chunk-WKBRZGGL.js +0 -40
- package/dist/chunk-WKBRZGGL.js.map +0 -1
- package/dist/chunk-XYZ7FOXJ.js.map +0 -1
- package/dist/chunk-YXS27XM6.js.map +0 -1
- /package/dist/{chunk-ZR66E3T6.js.map → chunk-JNLVXPHR.js.map} +0 -0
|
@@ -51,18 +51,11 @@ var draggableSchema = {
|
|
|
51
51
|
requirements: ["position: absolute or position: fixed on the element"],
|
|
52
52
|
source: `
|
|
53
53
|
behavior Draggable(dragHandle)
|
|
54
|
-
|
|
55
|
-
if no dragHandle set dragHandle to me
|
|
56
|
-
end
|
|
57
|
-
on pointerdown(clientX, clientY) from dragHandle
|
|
54
|
+
on pointerdown(clientX, clientY) from (dragHandle or me)
|
|
58
55
|
halt the event
|
|
59
56
|
trigger draggable:start
|
|
60
|
-
|
|
61
|
-
set
|
|
62
|
-
measure y
|
|
63
|
-
set startY to it
|
|
64
|
-
set xoff to clientX - startX
|
|
65
|
-
set yoff to clientY - startY
|
|
57
|
+
set xoff to clientX - my offsetLeft
|
|
58
|
+
set yoff to clientY - my offsetTop
|
|
66
59
|
repeat until event pointerup from document
|
|
67
60
|
wait for pointermove(clientX, clientY) or
|
|
68
61
|
pointerup(clientX, clientY) from document
|
|
@@ -71,33 +64,35 @@ behavior Draggable(dragHandle)
|
|
|
71
64
|
end
|
|
72
65
|
trigger draggable:end
|
|
73
66
|
end
|
|
74
|
-
end
|
|
75
|
-
`.trim()
|
|
67
|
+
end`.trim()
|
|
76
68
|
};
|
|
77
69
|
|
|
78
70
|
// src/schemas/types.ts
|
|
79
71
|
function resolveRuntime() {
|
|
80
72
|
if (typeof window === "undefined") return null;
|
|
81
73
|
const win = window;
|
|
82
|
-
|
|
74
|
+
const host = win.hyperfixi ?? win._hyperscript;
|
|
75
|
+
return host && typeof host.evaluate === "function" ? host : null;
|
|
83
76
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var draggableSource = draggableSchema.source;
|
|
87
|
-
var draggableMetadata = draggableSchema;
|
|
88
|
-
async function registerDraggable(hyperfixi) {
|
|
89
|
-
const hf = hyperfixi || resolveRuntime();
|
|
77
|
+
function defineBehavior(schema, host) {
|
|
78
|
+
const hf = host ?? resolveRuntime();
|
|
90
79
|
if (!hf) {
|
|
91
80
|
throw new Error(
|
|
92
|
-
|
|
81
|
+
`No hyperscript host found: load @hyperfixi/engine (hyperfixi-hs.js) before defining ${schema.name}.`
|
|
93
82
|
);
|
|
94
83
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
try {
|
|
85
|
+
hf.evaluate(schema.source);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
throw new Error(`Failed to define ${schema.name} behavior: ${e.message}`);
|
|
98
88
|
}
|
|
99
|
-
|
|
100
|
-
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/behaviors/draggable.ts
|
|
92
|
+
var draggableSource = draggableSchema.source;
|
|
93
|
+
var draggableMetadata = draggableSchema;
|
|
94
|
+
async function registerDraggable(host) {
|
|
95
|
+
defineBehavior(draggableSchema, host);
|
|
101
96
|
}
|
|
102
97
|
if (resolveRuntime()) {
|
|
103
98
|
registerDraggable().catch(console.error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/behaviors/draggable.ts","../../src/schemas/draggable.schema.ts","../../src/schemas/types.ts"],"sourcesContent":["/**\n * Draggable Behavior\n *\n * Makes elements draggable with pointer events.
|
|
1
|
+
{"version":3,"sources":["../../src/behaviors/draggable.ts","../../src/schemas/draggable.schema.ts","../../src/schemas/types.ts"],"sourcesContent":["/**\n * Draggable Behavior\n *\n * Makes elements draggable with pointer events. Defined from its hyperscript\n * `source` (the single source of truth shared with the browser bundle and\n * patterns-reference) — no imperative installer. The source uses\n * `repeat until event pointerup` + `wait for pointermove or pointerup` to run the\n * drag loop, `my offsetLeft` / `my offsetTop` for the start offset, and\n * `add { left: ${…}px }` to move.\n *\n * @example\n * ```html\n * <!-- Basic usage -->\n * <div _=\"install Draggable\">Drag me!</div>\n *\n * <!-- With custom drag handle -->\n * <div _=\"install Draggable(dragHandle: .titlebar)\">\n * <div class=\"titlebar\">Drag here</div>\n * <div class=\"content\">Content</div>\n * </div>\n * ```\n */\n\nimport { draggableSchema } from '../schemas/draggable.schema';\nimport { defineBehavior, resolveRuntime } from '../schemas/types';\nimport type { HyperscriptHost } from '../schemas/types';\n\n// Re-export schema-derived values for backwards compatibility\nexport const draggableSource = draggableSchema.source;\nexport const draggableMetadata = draggableSchema;\n\n/**\n * Define the Draggable behavior on a hyperscript host (`window.hyperfixi` when none is given)\n * from its source, as a `<script type=\"text/hyperscript\">` would.\n */\nexport async function registerDraggable(host?: HyperscriptHost): Promise<void> {\n defineBehavior(draggableSchema, host);\n}\n\n// Auto-register when loaded as a script tag\nif (resolveRuntime()) {\n registerDraggable().catch(console.error);\n}\n\nexport default {\n source: draggableSchema.source,\n metadata: draggableSchema,\n register: registerDraggable,\n};\n","import type { BehaviorSchema } from './types';\n\n/**\n * Draggable Behavior Schema\n *\n * Makes elements draggable with pointer events.\n * Supports custom drag handles and lifecycle events.\n */\nexport const draggableSchema: BehaviorSchema = {\n name: 'Draggable',\n category: 'ui',\n tier: 'core',\n version: '1.0.0',\n description:\n 'Makes elements draggable with pointer events (EXPERIMENTAL — stateful async component, beyond the inline-scripting boundary; not part of the curated set)',\n parameters: [\n {\n name: 'dragHandle',\n type: 'selector',\n optional: true,\n default: 'me',\n description: 'CSS selector for the drag handle element',\n },\n ],\n events: [\n { name: 'draggable:start', description: 'Fired when drag begins' },\n { name: 'draggable:move', description: 'Fired during each movement' },\n { name: 'draggable:end', description: 'Fired when drag completes' },\n ],\n requirements: ['position: absolute or position: fixed on the element'],\n source: `\nbehavior Draggable(dragHandle)\n on pointerdown(clientX, clientY) from (dragHandle or me)\n halt the event\n trigger draggable:start\n set xoff to clientX - my offsetLeft\n set yoff to clientY - my offsetTop\n repeat until event pointerup from document\n wait for pointermove(clientX, clientY) or\n pointerup(clientX, clientY) from document\n add { left: \\${clientX - xoff}px; top: \\${clientY - yoff}px; }\n trigger draggable:move\n end\n trigger draggable:end\n end\nend`.trim(),\n};\n","/**\n * Behavior Schema Types\n *\n * Defines the structure for behavior metadata used for:\n * - Code generation (TypeScript types, documentation)\n * - Runtime categorization and lazy loading\n * - Tooling and IDE integration\n */\n\n/**\n * Behavior categories for organization.\n * - ui: Visual interaction behaviors (drag, resize, sort)\n * - data: Data manipulation behaviors (remove, transform)\n * - animation: Animation and transition behaviors\n * - form: Form-related behaviors (validation, toggle states)\n * - layout: Layout behaviors (sticky, scrollspy)\n */\nexport type BehaviorCategory = 'ui' | 'data' | 'animation' | 'form' | 'layout';\n\n/**\n * Loading tiers for lazy loading optimization.\n * - core: Always loaded (essential behaviors)\n * - common: High usage (loaded for typical apps)\n * - optional: Low usage (loaded on demand)\n */\nexport type BehaviorTier = 'core' | 'common' | 'optional';\n\n/**\n * Schema for a behavior parameter.\n */\nexport interface ParameterSchema {\n name: string;\n type: 'string' | 'number' | 'boolean' | 'selector' | 'element';\n optional?: boolean;\n default?: string | number | boolean;\n /** Allowed values for constrained parameters */\n enum?: string[];\n description: string;\n}\n\n/**\n * Schema for a behavior event.\n */\nexport interface EventSchema {\n name: string;\n description: string;\n}\n\n/**\n * Complete schema for a behavior.\n * This is the source of truth for all behavior metadata.\n */\nexport interface BehaviorSchema {\n /** Behavior name (PascalCase) */\n name: string;\n /** Category for organization */\n category: BehaviorCategory;\n /** Loading tier for lazy loading */\n tier: BehaviorTier;\n /** Semantic version */\n version: string;\n /** Human-readable description */\n description: string;\n /** Parameter definitions */\n parameters: ParameterSchema[];\n /** Event definitions */\n events: EventSchema[];\n /** The hyperscript behavior source code */\n source: string;\n /** Optional requirements or notes */\n requirements?: string[];\n}\n\n/**\n * Runtime behavior module interface: a behavior's source, its schema, and the function that\n * defines it on a hyperscript host.\n */\nexport interface BehaviorModule {\n source: string;\n metadata: BehaviorSchema;\n register: (host?: HyperscriptHost) => Promise<void>;\n}\n\n/**\n * A hyperscript host, in upstream `_hyperscript`'s shape: `@hyperfixi/engine` (the\n * `hyperfixi-hs.js` bundle, `window.hyperfixi` / `window._hyperscript`) or upstream itself.\n * `evaluate(source)` of a `behavior … end` program defines the behavior; `processNode`\n * initialises the scripted elements under a node.\n */\nexport interface HyperscriptHost {\n evaluate: (source: string) => unknown;\n processNode?: (node: Node) => void;\n}\n\n/** The window globals a host installs itself as. */\nexport interface HyperscriptWindow {\n hyperfixi?: HyperscriptHost;\n _hyperscript?: HyperscriptHost;\n}\n\n/** The host on `window`: `hyperfixi` (the engine's bundle) or `_hyperscript` (upstream's name). */\nexport function resolveRuntime(): HyperscriptHost | null {\n if (typeof window === 'undefined') return null;\n const win = window as unknown as HyperscriptWindow;\n const host = win.hyperfixi ?? win._hyperscript;\n return host && typeof host.evaluate === 'function' ? host : null;\n}\n\n/**\n * Define a behavior on a host from its schema's source, as a page's\n * `<script type=\"text/hyperscript\">` would. Throws when there is no host or the source\n * does not parse.\n */\nexport function defineBehavior(schema: BehaviorSchema, host?: HyperscriptHost): void {\n const hf = host ?? resolveRuntime();\n if (!hf) {\n throw new Error(\n `No hyperscript host found: load @hyperfixi/engine (hyperfixi-hs.js) before defining ${schema.name}.`\n );\n }\n try {\n hf.evaluate(schema.source);\n } catch (e) {\n throw new Error(`Failed to define ${schema.name} behavior: ${(e as Error).message}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,IAAM,kBAAkC;AAAA,EAC7C,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aACE;AAAA,EACF,YAAY;AAAA,IACV;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,EAAE,MAAM,mBAAmB,aAAa,yBAAyB;AAAA,IACjE,EAAE,MAAM,kBAAkB,aAAa,6BAA6B;AAAA,IACpE,EAAE,MAAM,iBAAiB,aAAa,4BAA4B;AAAA,EACpE;AAAA,EACA,cAAc,CAAC,sDAAsD;AAAA,EACrE,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAeL,KAAK;AACV;;;ACuDO,SAAS,iBAAyC;AACvD,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,QAAM,MAAM;AACZ,QAAM,OAAO,IAAI,aAAa,IAAI;AAClC,SAAO,QAAQ,OAAO,KAAK,aAAa,aAAa,OAAO;AAC9D;AAOO,SAAS,eAAe,QAAwB,MAA8B;AACnF,QAAM,KAAK,QAAQ,eAAe;AAClC,MAAI,CAAC,IAAI;AACP,UAAM,IAAI;AAAA,MACR,uFAAuF,OAAO,IAAI;AAAA,IACpG;AAAA,EACF;AACA,MAAI;AACF,OAAG,SAAS,OAAO,MAAM;AAAA,EAC3B,SAAS,GAAG;AACV,UAAM,IAAI,MAAM,oBAAoB,OAAO,IAAI,cAAe,EAAY,OAAO,EAAE;AAAA,EACrF;AACF;;;AFjGO,IAAM,kBAAkB,gBAAgB;AACxC,IAAM,oBAAoB;AAMjC,eAAsB,kBAAkB,MAAuC;AAC7E,iBAAe,iBAAiB,IAAI;AACtC;AAGA,IAAI,eAAe,GAAG;AACpB,oBAAkB,EAAE,MAAM,QAAQ,KAAK;AACzC;AAEA,IAAO,oBAAQ;AAAA,EACb,QAAQ,gBAAgB;AAAA,EACxB,UAAU;AAAA,EACV,UAAU;AACZ;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { B as BehaviorSchema,
|
|
1
|
+
import { B as BehaviorSchema, H as HyperscriptHost } from '../types-CbA4L8XJ.cjs';
|
|
2
2
|
|
|
3
3
|
declare const draggableSource: string;
|
|
4
4
|
declare const draggableMetadata: BehaviorSchema;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* source
|
|
6
|
+
* Define the Draggable behavior on a hyperscript host (`window.hyperfixi` when none is given)
|
|
7
|
+
* from its source, as a `<script type="text/hyperscript">` would.
|
|
8
8
|
*/
|
|
9
|
-
declare function registerDraggable(
|
|
9
|
+
declare function registerDraggable(host?: HyperscriptHost): Promise<void>;
|
|
10
10
|
declare const _default: {
|
|
11
11
|
source: string;
|
|
12
12
|
metadata: BehaviorSchema;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { B as BehaviorSchema,
|
|
1
|
+
import { B as BehaviorSchema, H as HyperscriptHost } from '../types-CbA4L8XJ.js';
|
|
2
2
|
|
|
3
3
|
declare const draggableSource: string;
|
|
4
4
|
declare const draggableMetadata: BehaviorSchema;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* source
|
|
6
|
+
* Define the Draggable behavior on a hyperscript host (`window.hyperfixi` when none is given)
|
|
7
|
+
* from its source, as a `<script type="text/hyperscript">` would.
|
|
8
8
|
*/
|
|
9
|
-
declare function registerDraggable(
|
|
9
|
+
declare function registerDraggable(host?: HyperscriptHost): Promise<void>;
|
|
10
10
|
declare const _default: {
|
|
11
11
|
source: string;
|
|
12
12
|
metadata: BehaviorSchema;
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
draggableSource,
|
|
4
4
|
draggable_default,
|
|
5
5
|
registerDraggable
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-LBWM6TTU.js";
|
|
7
|
+
import "../chunk-U4QMFVAM.js";
|
|
8
|
+
import "../chunk-VWDTOSE3.js";
|
|
9
9
|
export {
|
|
10
10
|
draggable_default as default,
|
|
11
11
|
draggableMetadata,
|
|
@@ -67,12 +67,8 @@ var focusTrapSchema = {
|
|
|
67
67
|
source: `
|
|
68
68
|
behavior FocusTrap(active, initialFocus, returnFocus)
|
|
69
69
|
init
|
|
70
|
-
if active is undefined
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
if returnFocus is undefined
|
|
74
|
-
set returnFocus to true
|
|
75
|
-
end
|
|
70
|
+
if active is undefined set element's active to true end
|
|
71
|
+
if returnFocus is undefined set element's returnFocus to true end
|
|
76
72
|
js(me, active, initialFocus, returnFocus)
|
|
77
73
|
var FOCUSABLE = 'a[href],button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex="-1"])';
|
|
78
74
|
var isActive = false;
|
|
@@ -119,25 +115,28 @@ end`.trim()
|
|
|
119
115
|
function resolveRuntime() {
|
|
120
116
|
if (typeof window === "undefined") return null;
|
|
121
117
|
const win = window;
|
|
122
|
-
|
|
118
|
+
const host = win.hyperfixi ?? win._hyperscript;
|
|
119
|
+
return host && typeof host.evaluate === "function" ? host : null;
|
|
123
120
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
var focusTrapSource = focusTrapSchema.source;
|
|
127
|
-
var focusTrapMetadata = focusTrapSchema;
|
|
128
|
-
async function registerFocusTrap(hyperfixi) {
|
|
129
|
-
const hf = hyperfixi || resolveRuntime();
|
|
121
|
+
function defineBehavior(schema, host) {
|
|
122
|
+
const hf = host ?? resolveRuntime();
|
|
130
123
|
if (!hf) {
|
|
131
124
|
throw new Error(
|
|
132
|
-
|
|
125
|
+
`No hyperscript host found: load @hyperfixi/engine (hyperfixi-hs.js) before defining ${schema.name}.`
|
|
133
126
|
);
|
|
134
127
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
128
|
+
try {
|
|
129
|
+
hf.evaluate(schema.source);
|
|
130
|
+
} catch (e) {
|
|
131
|
+
throw new Error(`Failed to define ${schema.name} behavior: ${e.message}`);
|
|
138
132
|
}
|
|
139
|
-
|
|
140
|
-
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/behaviors/focustrap.ts
|
|
136
|
+
var focusTrapSource = focusTrapSchema.source;
|
|
137
|
+
var focusTrapMetadata = focusTrapSchema;
|
|
138
|
+
async function registerFocusTrap(host) {
|
|
139
|
+
defineBehavior(focusTrapSchema, host);
|
|
141
140
|
}
|
|
142
141
|
if (resolveRuntime()) {
|
|
143
142
|
registerFocusTrap().catch(console.error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/behaviors/focustrap.ts","../../src/schemas/focustrap.schema.ts","../../src/schemas/types.ts"],"sourcesContent":["/**\n * FocusTrap Behavior\n *\n * Confines Tab navigation inside an element, manages aria-modal,\n * and restores focus on deactivation. The Tab-trapping / focus-model logic\n * lives in the schema's hyperscript `source` (an `init`-block `js()` body).\n *\n * Compiled from its hyperscript `source` — the single source of truth shared with\n * the CDN resolver bundle and patterns-reference. This collapses FocusTrap onto\n * the one runtime path (no more imperative-installer fork between CDN and npm);\n * see docs-internal/BEHAVIORS_CONSOLIDATION_PLAN.md §3d.\n */\n\nimport { focusTrapSchema } from '../schemas/focustrap.schema';\nimport type { LokaScriptInstance } from '../schemas/types';\nimport { resolveRuntime } from '../schemas/types';\n\n// Re-export schema-derived values\nexport const focusTrapSource = focusTrapSchema.source;\nexport const focusTrapMetadata = focusTrapSchema;\n\n/**\n * Register the FocusTrap behavior with LokaScript by compiling its\n * hyperscript source and executing the resulting behavior definition.\n */\nexport async function registerFocusTrap(hyperfixi?: LokaScriptInstance): Promise<void> {\n const hf = hyperfixi || resolveRuntime();\n\n if (!hf) {\n throw new Error(\n 'LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors.'\n );\n }\n\n const result = hf.compileSync(focusTrapSchema.source, { traditional: true });\n\n if (!result.ok) {\n throw new Error(`Failed to compile FocusTrap behavior: ${JSON.stringify(result.errors)}`);\n }\n\n const ctx = hf.createContext ? hf.createContext() : { locals: new Map(), globals: new Map() };\n await hf.execute(result.ast, ctx);\n}\n\n// Auto-register when loaded as a script tag\nif (resolveRuntime()) {\n registerFocusTrap().catch(console.error);\n}\n\nexport default {\n source: focusTrapSchema.source,\n metadata: focusTrapSchema,\n register: registerFocusTrap,\n};\n","import type { BehaviorSchema } from './types';\n\n/**\n * FocusTrap Behavior Schema\n *\n * Confines Tab navigation inside an element and restores focus on release.\n * Manages aria-modal for accessibility compliance.\n */\nexport const focusTrapSchema: BehaviorSchema = {\n name: 'FocusTrap',\n category: 'ui',\n tier: 'core',\n version: '1.0.0',\n description: 'Confines Tab navigation inside an element with ARIA support',\n parameters: [\n {\n name: 'active',\n type: 'boolean',\n optional: true,\n default: true,\n description: 'Whether the trap is active on install',\n },\n {\n name: 'initialFocus',\n type: 'selector',\n optional: true,\n description: 'Element to focus when the trap activates',\n },\n {\n name: 'returnFocus',\n type: 'boolean',\n optional: true,\n default: true,\n description: 'Restore focus to the previously focused element on deactivation',\n },\n ],\n events: [\n { name: 'focustrap:activated', description: 'Fired when the trap is activated' },\n { name: 'focustrap:deactivated', description: 'Fired when the trap is deactivated' },\n ],\n requirements: [\n 'Sets aria-modal=\"true\" on the element when active',\n 'Listens for focustrap:activate and focustrap:deactivate custom events for programmatic control',\n ],\n source: `\nbehavior FocusTrap(active, initialFocus, returnFocus)\n init\n if active is undefined\n set active to true\n end\n if returnFocus is undefined\n set returnFocus to true\n end\n js(me, active, initialFocus, returnFocus)\n var FOCUSABLE = 'a[href],button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex=\"-1\"])';\n var isActive = false;\n var previouslyFocused = null;\n function getFocusable() { return Array.from(me.querySelectorAll(FOCUSABLE)); }\n function activate() {\n if (isActive) return;\n isActive = true;\n previouslyFocused = document.activeElement;\n me.setAttribute('aria-modal', 'true');\n var initEl = initialFocus ? (typeof initialFocus === 'string' ? me.querySelector(initialFocus) : initialFocus) : null;\n if (initEl) { initEl.focus(); } else { var f = getFocusable(); if (f.length) f[0].focus(); }\n me.dispatchEvent(new CustomEvent('focustrap:activated', { bubbles: true }));\n }\n function deactivate() {\n if (!isActive) return;\n isActive = false;\n me.removeAttribute('aria-modal');\n if (returnFocus && previouslyFocused instanceof HTMLElement) previouslyFocused.focus();\n previouslyFocused = null;\n me.dispatchEvent(new CustomEvent('focustrap:deactivated', { bubbles: true }));\n }\n me.addEventListener('keydown', function(e) {\n if (!isActive || e.key !== 'Tab') return;\n var focusable = getFocusable();\n if (focusable.length === 0) { e.preventDefault(); return; }\n e.preventDefault();\n var idx = focusable.indexOf(document.activeElement);\n if (e.shiftKey) {\n focusable[idx <= 0 ? focusable.length - 1 : idx - 1].focus();\n } else {\n focusable[idx >= focusable.length - 1 ? 0 : idx + 1].focus();\n }\n });\n me.addEventListener('focustrap:activate', function() { activate(); });\n me.addEventListener('focustrap:deactivate', function() { deactivate(); });\n if (active) activate();\n end\n end\nend`.trim(),\n};\n","/**\n * Behavior Schema Types\n *\n * Defines the structure for behavior metadata used for:\n * - Code generation (TypeScript types, documentation)\n * - Runtime categorization and lazy loading\n * - Tooling and IDE integration\n */\n\n/**\n * Behavior categories for organization.\n * - ui: Visual interaction behaviors (drag, resize, sort)\n * - data: Data manipulation behaviors (remove, transform)\n * - animation: Animation and transition behaviors\n * - form: Form-related behaviors (validation, toggle states)\n * - layout: Layout behaviors (sticky, scrollspy)\n */\nexport type BehaviorCategory = 'ui' | 'data' | 'animation' | 'form' | 'layout';\n\n/**\n * Loading tiers for lazy loading optimization.\n * - core: Always loaded (essential behaviors)\n * - common: High usage (loaded for typical apps)\n * - optional: Low usage (loaded on demand)\n */\nexport type BehaviorTier = 'core' | 'common' | 'optional';\n\n/**\n * Schema for a behavior parameter.\n */\nexport interface ParameterSchema {\n name: string;\n type: 'string' | 'number' | 'boolean' | 'selector' | 'element';\n optional?: boolean;\n default?: string | number | boolean;\n /** Allowed values for constrained parameters */\n enum?: string[];\n description: string;\n}\n\n/**\n * Schema for a behavior event.\n */\nexport interface EventSchema {\n name: string;\n description: string;\n}\n\n/**\n * Complete schema for a behavior.\n * This is the source of truth for all behavior metadata.\n */\nexport interface BehaviorSchema {\n /** Behavior name (PascalCase) */\n name: string;\n /** Category for organization */\n category: BehaviorCategory;\n /** Loading tier for lazy loading */\n tier: BehaviorTier;\n /** Semantic version */\n version: string;\n /** Human-readable description */\n description: string;\n /** Parameter definitions */\n parameters: ParameterSchema[];\n /** Event definitions */\n events: EventSchema[];\n /** The hyperscript behavior source code */\n source: string;\n /** Optional requirements or notes */\n requirements?: string[];\n}\n\n/**\n * Runtime behavior module interface.\n * This is what gets registered with the hyperfixi runtime.\n */\nexport interface BehaviorModule {\n source: string;\n metadata: BehaviorSchema;\n register: (hyperfixi?: LokaScriptInstance) => Promise<void>;\n}\n\n/**\n * Minimal LokaScript instance interface for behavior registration.\n */\nexport interface LokaScriptInstance {\n compileSync: (\n code: string,\n options?: { traditional?: boolean; language?: string }\n ) => {\n ok: boolean;\n ast?: unknown;\n errors?: Array<{ message: string; line?: number; column?: number }>;\n };\n execute: (ast: unknown, ctx: unknown) => Promise<unknown>;\n createContext?: () => { locals: Map<string, unknown>; globals: Map<string, unknown> };\n}\n\n/**\n * Typed window interface for behavior auto-registration.\n * Avoids `(window as any)` casts throughout the codebase.\n * Checks both `window.lokascript` and `window.hyperfixi` for the runtime instance.\n */\nexport interface LokaScriptWindow {\n lokascript?: LokaScriptInstance;\n hyperfixi?: LokaScriptInstance;\n __hyperfixi_behaviors_ready?: Promise<void> | undefined;\n}\n\n/**\n * Resolve the LokaScript runtime from window globals.\n * Checks both `window.lokascript` and `window.hyperfixi`.\n */\nexport function resolveRuntime(): LokaScriptInstance | null {\n if (typeof window === 'undefined') return null;\n const win = window as unknown as LokaScriptWindow;\n return win.lokascript || win.hyperfixi || null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,IAAM,kBAAkC;AAAA,EAC7C,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,YAAY;AAAA,IACV;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,EAAE,MAAM,uBAAuB,aAAa,mCAAmC;AAAA,IAC/E,EAAE,MAAM,yBAAyB,aAAa,qCAAqC;AAAA,EACrF;AAAA,EACA,cAAc;AAAA,IACZ;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAgDL,KAAK;AACV;;;ACqBO,SAAS,iBAA4C;AAC1D,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,QAAM,MAAM;AACZ,SAAO,IAAI,cAAc,IAAI,aAAa;AAC5C;;;AFpGO,IAAM,kBAAkB,gBAAgB;AACxC,IAAM,oBAAoB;AAMjC,eAAsB,kBAAkB,WAA+C;AACrF,QAAM,KAAK,aAAa,eAAe;AAEvC,MAAI,CAAC,IAAI;AACP,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,GAAG,YAAY,gBAAgB,QAAQ,EAAE,aAAa,KAAK,CAAC;AAE3E,MAAI,CAAC,OAAO,IAAI;AACd,UAAM,IAAI,MAAM,yCAAyC,KAAK,UAAU,OAAO,MAAM,CAAC,EAAE;AAAA,EAC1F;AAEA,QAAM,MAAM,GAAG,gBAAgB,GAAG,cAAc,IAAI,EAAE,QAAQ,oBAAI,IAAI,GAAG,SAAS,oBAAI,IAAI,EAAE;AAC5F,QAAM,GAAG,QAAQ,OAAO,KAAK,GAAG;AAClC;AAGA,IAAI,eAAe,GAAG;AACpB,oBAAkB,EAAE,MAAM,QAAQ,KAAK;AACzC;AAEA,IAAO,oBAAQ;AAAA,EACb,QAAQ,gBAAgB;AAAA,EACxB,UAAU;AAAA,EACV,UAAU;AACZ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/behaviors/focustrap.ts","../../src/schemas/focustrap.schema.ts","../../src/schemas/types.ts"],"sourcesContent":["/**\n * FocusTrap Behavior\n *\n * Confines Tab navigation inside an element, manages aria-modal,\n * and restores focus on deactivation. The Tab-trapping / focus-model logic\n * lives in the schema's hyperscript `source` (an `init`-block `js()` body).\n *\n * Defined from its hyperscript `source` — the single source of truth shared with\n * the browser bundle and patterns-reference. This collapses FocusTrap onto\n * the one runtime path (no more imperative-installer fork between CDN and npm);\n * see docs-internal/BEHAVIORS_CONSOLIDATION_PLAN.md §3d.\n */\n\nimport { focusTrapSchema } from '../schemas/focustrap.schema';\nimport { defineBehavior, resolveRuntime } from '../schemas/types';\nimport type { HyperscriptHost } from '../schemas/types';\n\n// Re-export schema-derived values\nexport const focusTrapSource = focusTrapSchema.source;\nexport const focusTrapMetadata = focusTrapSchema;\n\n/**\n * Define the FocusTrap behavior on a hyperscript host (`window.hyperfixi` when none is given)\n * from its source, as a `<script type=\"text/hyperscript\">` would.\n */\nexport async function registerFocusTrap(host?: HyperscriptHost): Promise<void> {\n defineBehavior(focusTrapSchema, host);\n}\n\n// Auto-register when loaded as a script tag\nif (resolveRuntime()) {\n registerFocusTrap().catch(console.error);\n}\n\nexport default {\n source: focusTrapSchema.source,\n metadata: focusTrapSchema,\n register: registerFocusTrap,\n};\n","import type { BehaviorSchema } from './types';\n\n/**\n * FocusTrap Behavior Schema\n *\n * Confines Tab navigation inside an element and restores focus on release.\n * Manages aria-modal for accessibility compliance.\n */\nexport const focusTrapSchema: BehaviorSchema = {\n name: 'FocusTrap',\n category: 'ui',\n tier: 'core',\n version: '1.0.0',\n description: 'Confines Tab navigation inside an element with ARIA support',\n parameters: [\n {\n name: 'active',\n type: 'boolean',\n optional: true,\n default: true,\n description: 'Whether the trap is active on install',\n },\n {\n name: 'initialFocus',\n type: 'selector',\n optional: true,\n description: 'Element to focus when the trap activates',\n },\n {\n name: 'returnFocus',\n type: 'boolean',\n optional: true,\n default: true,\n description: 'Restore focus to the previously focused element on deactivation',\n },\n ],\n events: [\n { name: 'focustrap:activated', description: 'Fired when the trap is activated' },\n { name: 'focustrap:deactivated', description: 'Fired when the trap is deactivated' },\n ],\n requirements: [\n 'Sets aria-modal=\"true\" on the element when active',\n 'Listens for focustrap:activate and focustrap:deactivate custom events for programmatic control',\n ],\n source: `\nbehavior FocusTrap(active, initialFocus, returnFocus)\n init\n if active is undefined set element's active to true end\n if returnFocus is undefined set element's returnFocus to true end\n js(me, active, initialFocus, returnFocus)\n var FOCUSABLE = 'a[href],button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex=\"-1\"])';\n var isActive = false;\n var previouslyFocused = null;\n function getFocusable() { return Array.from(me.querySelectorAll(FOCUSABLE)); }\n function activate() {\n if (isActive) return;\n isActive = true;\n previouslyFocused = document.activeElement;\n me.setAttribute('aria-modal', 'true');\n var initEl = initialFocus ? (typeof initialFocus === 'string' ? me.querySelector(initialFocus) : initialFocus) : null;\n if (initEl) { initEl.focus(); } else { var f = getFocusable(); if (f.length) f[0].focus(); }\n me.dispatchEvent(new CustomEvent('focustrap:activated', { bubbles: true }));\n }\n function deactivate() {\n if (!isActive) return;\n isActive = false;\n me.removeAttribute('aria-modal');\n if (returnFocus && previouslyFocused instanceof HTMLElement) previouslyFocused.focus();\n previouslyFocused = null;\n me.dispatchEvent(new CustomEvent('focustrap:deactivated', { bubbles: true }));\n }\n me.addEventListener('keydown', function(e) {\n if (!isActive || e.key !== 'Tab') return;\n var focusable = getFocusable();\n if (focusable.length === 0) { e.preventDefault(); return; }\n e.preventDefault();\n var idx = focusable.indexOf(document.activeElement);\n if (e.shiftKey) {\n focusable[idx <= 0 ? focusable.length - 1 : idx - 1].focus();\n } else {\n focusable[idx >= focusable.length - 1 ? 0 : idx + 1].focus();\n }\n });\n me.addEventListener('focustrap:activate', function() { activate(); });\n me.addEventListener('focustrap:deactivate', function() { deactivate(); });\n if (active) activate();\n end\n end\nend`.trim(),\n};\n","/**\n * Behavior Schema Types\n *\n * Defines the structure for behavior metadata used for:\n * - Code generation (TypeScript types, documentation)\n * - Runtime categorization and lazy loading\n * - Tooling and IDE integration\n */\n\n/**\n * Behavior categories for organization.\n * - ui: Visual interaction behaviors (drag, resize, sort)\n * - data: Data manipulation behaviors (remove, transform)\n * - animation: Animation and transition behaviors\n * - form: Form-related behaviors (validation, toggle states)\n * - layout: Layout behaviors (sticky, scrollspy)\n */\nexport type BehaviorCategory = 'ui' | 'data' | 'animation' | 'form' | 'layout';\n\n/**\n * Loading tiers for lazy loading optimization.\n * - core: Always loaded (essential behaviors)\n * - common: High usage (loaded for typical apps)\n * - optional: Low usage (loaded on demand)\n */\nexport type BehaviorTier = 'core' | 'common' | 'optional';\n\n/**\n * Schema for a behavior parameter.\n */\nexport interface ParameterSchema {\n name: string;\n type: 'string' | 'number' | 'boolean' | 'selector' | 'element';\n optional?: boolean;\n default?: string | number | boolean;\n /** Allowed values for constrained parameters */\n enum?: string[];\n description: string;\n}\n\n/**\n * Schema for a behavior event.\n */\nexport interface EventSchema {\n name: string;\n description: string;\n}\n\n/**\n * Complete schema for a behavior.\n * This is the source of truth for all behavior metadata.\n */\nexport interface BehaviorSchema {\n /** Behavior name (PascalCase) */\n name: string;\n /** Category for organization */\n category: BehaviorCategory;\n /** Loading tier for lazy loading */\n tier: BehaviorTier;\n /** Semantic version */\n version: string;\n /** Human-readable description */\n description: string;\n /** Parameter definitions */\n parameters: ParameterSchema[];\n /** Event definitions */\n events: EventSchema[];\n /** The hyperscript behavior source code */\n source: string;\n /** Optional requirements or notes */\n requirements?: string[];\n}\n\n/**\n * Runtime behavior module interface: a behavior's source, its schema, and the function that\n * defines it on a hyperscript host.\n */\nexport interface BehaviorModule {\n source: string;\n metadata: BehaviorSchema;\n register: (host?: HyperscriptHost) => Promise<void>;\n}\n\n/**\n * A hyperscript host, in upstream `_hyperscript`'s shape: `@hyperfixi/engine` (the\n * `hyperfixi-hs.js` bundle, `window.hyperfixi` / `window._hyperscript`) or upstream itself.\n * `evaluate(source)` of a `behavior … end` program defines the behavior; `processNode`\n * initialises the scripted elements under a node.\n */\nexport interface HyperscriptHost {\n evaluate: (source: string) => unknown;\n processNode?: (node: Node) => void;\n}\n\n/** The window globals a host installs itself as. */\nexport interface HyperscriptWindow {\n hyperfixi?: HyperscriptHost;\n _hyperscript?: HyperscriptHost;\n}\n\n/** The host on `window`: `hyperfixi` (the engine's bundle) or `_hyperscript` (upstream's name). */\nexport function resolveRuntime(): HyperscriptHost | null {\n if (typeof window === 'undefined') return null;\n const win = window as unknown as HyperscriptWindow;\n const host = win.hyperfixi ?? win._hyperscript;\n return host && typeof host.evaluate === 'function' ? host : null;\n}\n\n/**\n * Define a behavior on a host from its schema's source, as a page's\n * `<script type=\"text/hyperscript\">` would. Throws when there is no host or the source\n * does not parse.\n */\nexport function defineBehavior(schema: BehaviorSchema, host?: HyperscriptHost): void {\n const hf = host ?? resolveRuntime();\n if (!hf) {\n throw new Error(\n `No hyperscript host found: load @hyperfixi/engine (hyperfixi-hs.js) before defining ${schema.name}.`\n );\n }\n try {\n hf.evaluate(schema.source);\n } catch (e) {\n throw new Error(`Failed to define ${schema.name} behavior: ${(e as Error).message}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,IAAM,kBAAkC;AAAA,EAC7C,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,YAAY;AAAA,IACV;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,EAAE,MAAM,uBAAuB,aAAa,mCAAmC;AAAA,IAC/E,EAAE,MAAM,yBAAyB,aAAa,qCAAqC;AAAA,EACrF;AAAA,EACA,cAAc;AAAA,IACZ;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KA4CL,KAAK;AACV;;;ACYO,SAAS,iBAAyC;AACvD,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,QAAM,MAAM;AACZ,QAAM,OAAO,IAAI,aAAa,IAAI;AAClC,SAAO,QAAQ,OAAO,KAAK,aAAa,aAAa,OAAO;AAC9D;AAOO,SAAS,eAAe,QAAwB,MAA8B;AACnF,QAAM,KAAK,QAAQ,eAAe;AAClC,MAAI,CAAC,IAAI;AACP,UAAM,IAAI;AAAA,MACR,uFAAuF,OAAO,IAAI;AAAA,IACpG;AAAA,EACF;AACA,MAAI;AACF,OAAG,SAAS,OAAO,MAAM;AAAA,EAC3B,SAAS,GAAG;AACV,UAAM,IAAI,MAAM,oBAAoB,OAAO,IAAI,cAAe,EAAY,OAAO,EAAE;AAAA,EACrF;AACF;;;AF3GO,IAAM,kBAAkB,gBAAgB;AACxC,IAAM,oBAAoB;AAMjC,eAAsB,kBAAkB,MAAuC;AAC7E,iBAAe,iBAAiB,IAAI;AACtC;AAGA,IAAI,eAAe,GAAG;AACpB,oBAAkB,EAAE,MAAM,QAAQ,KAAK;AACzC;AAEA,IAAO,oBAAQ;AAAA,EACb,QAAQ,gBAAgB;AAAA,EACxB,UAAU;AAAA,EACV,UAAU;AACZ;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { B as BehaviorSchema,
|
|
1
|
+
import { B as BehaviorSchema, H as HyperscriptHost } from '../types-CbA4L8XJ.cjs';
|
|
2
2
|
|
|
3
3
|
declare const focusTrapSource: string;
|
|
4
4
|
declare const focusTrapMetadata: BehaviorSchema;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Define the FocusTrap behavior on a hyperscript host (`window.hyperfixi` when none is given)
|
|
7
|
+
* from its source, as a `<script type="text/hyperscript">` would.
|
|
8
8
|
*/
|
|
9
|
-
declare function registerFocusTrap(
|
|
9
|
+
declare function registerFocusTrap(host?: HyperscriptHost): Promise<void>;
|
|
10
10
|
declare const _default: {
|
|
11
11
|
source: string;
|
|
12
12
|
metadata: BehaviorSchema;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { B as BehaviorSchema,
|
|
1
|
+
import { B as BehaviorSchema, H as HyperscriptHost } from '../types-CbA4L8XJ.js';
|
|
2
2
|
|
|
3
3
|
declare const focusTrapSource: string;
|
|
4
4
|
declare const focusTrapMetadata: BehaviorSchema;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Define the FocusTrap behavior on a hyperscript host (`window.hyperfixi` when none is given)
|
|
7
|
+
* from its source, as a `<script type="text/hyperscript">` would.
|
|
8
8
|
*/
|
|
9
|
-
declare function registerFocusTrap(
|
|
9
|
+
declare function registerFocusTrap(host?: HyperscriptHost): Promise<void>;
|
|
10
10
|
declare const _default: {
|
|
11
11
|
source: string;
|
|
12
12
|
metadata: BehaviorSchema;
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
focusTrapSource,
|
|
4
4
|
focustrap_default,
|
|
5
5
|
registerFocusTrap
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-YRQBU2OW.js";
|
|
7
|
+
import "../chunk-NE76IBV2.js";
|
|
8
|
+
import "../chunk-VWDTOSE3.js";
|
|
9
9
|
export {
|
|
10
10
|
focustrap_default as default,
|
|
11
11
|
focusTrapMetadata,
|
|
@@ -64,12 +64,7 @@ var removableSchema = {
|
|
|
64
64
|
],
|
|
65
65
|
source: `
|
|
66
66
|
behavior Removable(triggerEl, confirmRemoval, effect)
|
|
67
|
-
|
|
68
|
-
if triggerEl is undefined
|
|
69
|
-
set triggerEl to me
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
on click from triggerEl
|
|
67
|
+
on click from (triggerEl or me)
|
|
73
68
|
if confirmRemoval
|
|
74
69
|
js(me)
|
|
75
70
|
if (!window.confirm("Are you sure?")) return "cancel";
|
|
@@ -85,33 +80,35 @@ behavior Removable(triggerEl, confirmRemoval, effect)
|
|
|
85
80
|
trigger removable:removed
|
|
86
81
|
remove me
|
|
87
82
|
end
|
|
88
|
-
end
|
|
89
|
-
`.trim()
|
|
83
|
+
end`.trim()
|
|
90
84
|
};
|
|
91
85
|
|
|
92
86
|
// src/schemas/types.ts
|
|
93
87
|
function resolveRuntime() {
|
|
94
88
|
if (typeof window === "undefined") return null;
|
|
95
89
|
const win = window;
|
|
96
|
-
|
|
90
|
+
const host = win.hyperfixi ?? win._hyperscript;
|
|
91
|
+
return host && typeof host.evaluate === "function" ? host : null;
|
|
97
92
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var removableSource = removableSchema.source;
|
|
101
|
-
var removableMetadata = removableSchema;
|
|
102
|
-
async function registerRemovable(hyperfixi) {
|
|
103
|
-
const hf = hyperfixi || resolveRuntime();
|
|
93
|
+
function defineBehavior(schema, host) {
|
|
94
|
+
const hf = host ?? resolveRuntime();
|
|
104
95
|
if (!hf) {
|
|
105
96
|
throw new Error(
|
|
106
|
-
|
|
97
|
+
`No hyperscript host found: load @hyperfixi/engine (hyperfixi-hs.js) before defining ${schema.name}.`
|
|
107
98
|
);
|
|
108
99
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
try {
|
|
101
|
+
hf.evaluate(schema.source);
|
|
102
|
+
} catch (e) {
|
|
103
|
+
throw new Error(`Failed to define ${schema.name} behavior: ${e.message}`);
|
|
112
104
|
}
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/behaviors/removable.ts
|
|
108
|
+
var removableSource = removableSchema.source;
|
|
109
|
+
var removableMetadata = removableSchema;
|
|
110
|
+
async function registerRemovable(host) {
|
|
111
|
+
defineBehavior(removableSchema, host);
|
|
115
112
|
}
|
|
116
113
|
if (resolveRuntime()) {
|
|
117
114
|
registerRemovable().catch(console.error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/behaviors/removable.ts","../../src/schemas/removable.schema.ts","../../src/schemas/types.ts"],"sourcesContent":["/**\n * Removable Behavior\n *\n * A behavior that removes an element when a trigger is clicked.\n * Supports optional confirmation and transition effects.\n *\n * @example\n * ```html\n * <div _=\"install Removable\">Click to remove</div>\n *\n * <div _=\"install Removable(confirm: true)\">With confirmation</div>\n * ```\n */\n\nimport { removableSchema } from '../schemas/removable.schema';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/behaviors/removable.ts","../../src/schemas/removable.schema.ts","../../src/schemas/types.ts"],"sourcesContent":["/**\n * Removable Behavior\n *\n * A behavior that removes an element when a trigger is clicked.\n * Supports optional confirmation and transition effects.\n *\n * @example\n * ```html\n * <div _=\"install Removable\">Click to remove</div>\n *\n * <div _=\"install Removable(confirm: true)\">With confirmation</div>\n * ```\n */\n\nimport { removableSchema } from '../schemas/removable.schema';\nimport { defineBehavior, resolveRuntime } from '../schemas/types';\nimport type { HyperscriptHost } from '../schemas/types';\n\n// Re-export schema-derived values for backwards compatibility\nexport const removableSource = removableSchema.source;\nexport const removableMetadata = removableSchema;\n\n/**\n * Define the Removable behavior on a hyperscript host (`window.hyperfixi` when none is given)\n * from its source, as a `<script type=\"text/hyperscript\">` would.\n */\nexport async function registerRemovable(host?: HyperscriptHost): Promise<void> {\n defineBehavior(removableSchema, host);\n}\n\n// Auto-register when loaded as a script tag\nif (resolveRuntime()) {\n registerRemovable().catch(console.error);\n}\n\nexport default {\n source: removableSchema.source,\n metadata: removableSchema,\n register: registerRemovable,\n};\n","import type { BehaviorSchema } from './types';\n\n/**\n * Removable Behavior Schema\n *\n * Removes an element when a trigger is clicked.\n * Supports optional confirmation and transition effects.\n *\n * @since 1.2.0 — `trigger` parameter renamed to `triggerEl` to avoid\n * shadowing the hyperscript `trigger` command keyword. Users migrating\n * from v1.x should update: `install Removable(triggerEl: .close-btn)`.\n */\nexport const removableSchema: BehaviorSchema = {\n name: 'Removable',\n category: 'data',\n tier: 'common',\n version: '1.2.0',\n description: 'Makes elements removable on click',\n parameters: [\n {\n name: 'triggerEl',\n type: 'selector',\n optional: true,\n default: 'me',\n description: 'Element that triggers removal (e.g., a close button)',\n },\n {\n name: 'confirmRemoval',\n type: 'boolean',\n optional: true,\n default: false,\n description: 'Show confirmation dialog before removal',\n },\n {\n name: 'effect',\n type: 'string',\n optional: true,\n default: 'none',\n enum: ['fade', 'none'],\n description: 'Transition effect: \"fade\" or \"none\"',\n },\n ],\n events: [\n { name: 'removable:before', description: 'Fired before removal (cancelable)' },\n { name: 'removable:removed', description: 'Fired after removal' },\n ],\n source: `\nbehavior Removable(triggerEl, confirmRemoval, effect)\n on click from (triggerEl or me)\n if confirmRemoval\n js(me)\n if (!window.confirm(\"Are you sure?\")) return \"cancel\";\n end\n if it is \"cancel\"\n halt\n end\n end\n trigger removable:before\n if effect is \"fade\"\n transition opacity to 0 over 300ms\n end\n trigger removable:removed\n remove me\n end\nend`.trim(),\n};\n","/**\n * Behavior Schema Types\n *\n * Defines the structure for behavior metadata used for:\n * - Code generation (TypeScript types, documentation)\n * - Runtime categorization and lazy loading\n * - Tooling and IDE integration\n */\n\n/**\n * Behavior categories for organization.\n * - ui: Visual interaction behaviors (drag, resize, sort)\n * - data: Data manipulation behaviors (remove, transform)\n * - animation: Animation and transition behaviors\n * - form: Form-related behaviors (validation, toggle states)\n * - layout: Layout behaviors (sticky, scrollspy)\n */\nexport type BehaviorCategory = 'ui' | 'data' | 'animation' | 'form' | 'layout';\n\n/**\n * Loading tiers for lazy loading optimization.\n * - core: Always loaded (essential behaviors)\n * - common: High usage (loaded for typical apps)\n * - optional: Low usage (loaded on demand)\n */\nexport type BehaviorTier = 'core' | 'common' | 'optional';\n\n/**\n * Schema for a behavior parameter.\n */\nexport interface ParameterSchema {\n name: string;\n type: 'string' | 'number' | 'boolean' | 'selector' | 'element';\n optional?: boolean;\n default?: string | number | boolean;\n /** Allowed values for constrained parameters */\n enum?: string[];\n description: string;\n}\n\n/**\n * Schema for a behavior event.\n */\nexport interface EventSchema {\n name: string;\n description: string;\n}\n\n/**\n * Complete schema for a behavior.\n * This is the source of truth for all behavior metadata.\n */\nexport interface BehaviorSchema {\n /** Behavior name (PascalCase) */\n name: string;\n /** Category for organization */\n category: BehaviorCategory;\n /** Loading tier for lazy loading */\n tier: BehaviorTier;\n /** Semantic version */\n version: string;\n /** Human-readable description */\n description: string;\n /** Parameter definitions */\n parameters: ParameterSchema[];\n /** Event definitions */\n events: EventSchema[];\n /** The hyperscript behavior source code */\n source: string;\n /** Optional requirements or notes */\n requirements?: string[];\n}\n\n/**\n * Runtime behavior module interface: a behavior's source, its schema, and the function that\n * defines it on a hyperscript host.\n */\nexport interface BehaviorModule {\n source: string;\n metadata: BehaviorSchema;\n register: (host?: HyperscriptHost) => Promise<void>;\n}\n\n/**\n * A hyperscript host, in upstream `_hyperscript`'s shape: `@hyperfixi/engine` (the\n * `hyperfixi-hs.js` bundle, `window.hyperfixi` / `window._hyperscript`) or upstream itself.\n * `evaluate(source)` of a `behavior … end` program defines the behavior; `processNode`\n * initialises the scripted elements under a node.\n */\nexport interface HyperscriptHost {\n evaluate: (source: string) => unknown;\n processNode?: (node: Node) => void;\n}\n\n/** The window globals a host installs itself as. */\nexport interface HyperscriptWindow {\n hyperfixi?: HyperscriptHost;\n _hyperscript?: HyperscriptHost;\n}\n\n/** The host on `window`: `hyperfixi` (the engine's bundle) or `_hyperscript` (upstream's name). */\nexport function resolveRuntime(): HyperscriptHost | null {\n if (typeof window === 'undefined') return null;\n const win = window as unknown as HyperscriptWindow;\n const host = win.hyperfixi ?? win._hyperscript;\n return host && typeof host.evaluate === 'function' ? host : null;\n}\n\n/**\n * Define a behavior on a host from its schema's source, as a page's\n * `<script type=\"text/hyperscript\">` would. Throws when there is no host or the source\n * does not parse.\n */\nexport function defineBehavior(schema: BehaviorSchema, host?: HyperscriptHost): void {\n const hf = host ?? resolveRuntime();\n if (!hf) {\n throw new Error(\n `No hyperscript host found: load @hyperfixi/engine (hyperfixi-hs.js) before defining ${schema.name}.`\n );\n }\n try {\n hf.evaluate(schema.source);\n } catch (e) {\n throw new Error(`Failed to define ${schema.name} behavior: ${(e as Error).message}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,kBAAkC;AAAA,EAC7C,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,YAAY;AAAA,IACV;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,MACT,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,EAAE,MAAM,oBAAoB,aAAa,oCAAoC;AAAA,IAC7E,EAAE,MAAM,qBAAqB,aAAa,sBAAsB;AAAA,EAClE;AAAA,EACA,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAkBL,KAAK;AACV;;;ACoCO,SAAS,iBAAyC;AACvD,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,QAAM,MAAM;AACZ,QAAM,OAAO,IAAI,aAAa,IAAI;AAClC,SAAO,QAAQ,OAAO,KAAK,aAAa,aAAa,OAAO;AAC9D;AAOO,SAAS,eAAe,QAAwB,MAA8B;AACnF,QAAM,KAAK,QAAQ,eAAe;AAClC,MAAI,CAAC,IAAI;AACP,UAAM,IAAI;AAAA,MACR,uFAAuF,OAAO,IAAI;AAAA,IACpG;AAAA,EACF;AACA,MAAI;AACF,OAAG,SAAS,OAAO,MAAM;AAAA,EAC3B,SAAS,GAAG;AACV,UAAM,IAAI,MAAM,oBAAoB,OAAO,IAAI,cAAe,EAAY,OAAO,EAAE;AAAA,EACrF;AACF;;;AF1GO,IAAM,kBAAkB,gBAAgB;AACxC,IAAM,oBAAoB;AAMjC,eAAsB,kBAAkB,MAAuC;AAC7E,iBAAe,iBAAiB,IAAI;AACtC;AAGA,IAAI,eAAe,GAAG;AACpB,oBAAkB,EAAE,MAAM,QAAQ,KAAK;AACzC;AAEA,IAAO,oBAAQ;AAAA,EACb,QAAQ,gBAAgB;AAAA,EACxB,UAAU;AAAA,EACV,UAAU;AACZ;","names":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { B as BehaviorSchema,
|
|
1
|
+
import { B as BehaviorSchema, H as HyperscriptHost } from '../types-CbA4L8XJ.cjs';
|
|
2
2
|
|
|
3
3
|
declare const removableSource: string;
|
|
4
4
|
declare const removableMetadata: BehaviorSchema;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Define the Removable behavior on a hyperscript host (`window.hyperfixi` when none is given)
|
|
7
|
+
* from its source, as a `<script type="text/hyperscript">` would.
|
|
7
8
|
*/
|
|
8
|
-
declare function registerRemovable(
|
|
9
|
+
declare function registerRemovable(host?: HyperscriptHost): Promise<void>;
|
|
9
10
|
declare const _default: {
|
|
10
11
|
source: string;
|
|
11
12
|
metadata: BehaviorSchema;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { B as BehaviorSchema,
|
|
1
|
+
import { B as BehaviorSchema, H as HyperscriptHost } from '../types-CbA4L8XJ.js';
|
|
2
2
|
|
|
3
3
|
declare const removableSource: string;
|
|
4
4
|
declare const removableMetadata: BehaviorSchema;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Define the Removable behavior on a hyperscript host (`window.hyperfixi` when none is given)
|
|
7
|
+
* from its source, as a `<script type="text/hyperscript">` would.
|
|
7
8
|
*/
|
|
8
|
-
declare function registerRemovable(
|
|
9
|
+
declare function registerRemovable(host?: HyperscriptHost): Promise<void>;
|
|
9
10
|
declare const _default: {
|
|
10
11
|
source: string;
|
|
11
12
|
metadata: BehaviorSchema;
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
removableMetadata,
|
|
4
4
|
removableSource,
|
|
5
5
|
removable_default
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-2GIS4DCY.js";
|
|
7
|
+
import "../chunk-PVO6TZCZ.js";
|
|
8
|
+
import "../chunk-VWDTOSE3.js";
|
|
9
9
|
export {
|
|
10
10
|
removable_default as default,
|
|
11
11
|
registerRemovable,
|
|
@@ -74,10 +74,8 @@ behavior Resizable(minWidth, minHeight, maxWidth, maxHeight)
|
|
|
74
74
|
on pointerdown(clientX, clientY) from me
|
|
75
75
|
halt the event
|
|
76
76
|
trigger resizable:start
|
|
77
|
-
|
|
78
|
-
set
|
|
79
|
-
measure height
|
|
80
|
-
set startHeight to it
|
|
77
|
+
set startWidth to my offsetWidth
|
|
78
|
+
set startHeight to my offsetHeight
|
|
81
79
|
set startX to clientX
|
|
82
80
|
set startY to clientY
|
|
83
81
|
repeat until event pointerup from document
|
|
@@ -94,33 +92,35 @@ behavior Resizable(minWidth, minHeight, maxWidth, maxHeight)
|
|
|
94
92
|
end
|
|
95
93
|
trigger resizable:end
|
|
96
94
|
end
|
|
97
|
-
end
|
|
98
|
-
`.trim()
|
|
95
|
+
end`.trim()
|
|
99
96
|
};
|
|
100
97
|
|
|
101
98
|
// src/schemas/types.ts
|
|
102
99
|
function resolveRuntime() {
|
|
103
100
|
if (typeof window === "undefined") return null;
|
|
104
101
|
const win = window;
|
|
105
|
-
|
|
102
|
+
const host = win.hyperfixi ?? win._hyperscript;
|
|
103
|
+
return host && typeof host.evaluate === "function" ? host : null;
|
|
106
104
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
var resizableSource = resizableSchema.source;
|
|
110
|
-
var resizableMetadata = resizableSchema;
|
|
111
|
-
async function registerResizable(hyperfixi) {
|
|
112
|
-
const hf = hyperfixi || resolveRuntime();
|
|
105
|
+
function defineBehavior(schema, host) {
|
|
106
|
+
const hf = host ?? resolveRuntime();
|
|
113
107
|
if (!hf) {
|
|
114
108
|
throw new Error(
|
|
115
|
-
|
|
109
|
+
`No hyperscript host found: load @hyperfixi/engine (hyperfixi-hs.js) before defining ${schema.name}.`
|
|
116
110
|
);
|
|
117
111
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
try {
|
|
113
|
+
hf.evaluate(schema.source);
|
|
114
|
+
} catch (e) {
|
|
115
|
+
throw new Error(`Failed to define ${schema.name} behavior: ${e.message}`);
|
|
121
116
|
}
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/behaviors/resizable.ts
|
|
120
|
+
var resizableSource = resizableSchema.source;
|
|
121
|
+
var resizableMetadata = resizableSchema;
|
|
122
|
+
async function registerResizable(host) {
|
|
123
|
+
defineBehavior(resizableSchema, host);
|
|
124
124
|
}
|
|
125
125
|
if (resolveRuntime()) {
|
|
126
126
|
registerResizable().catch(console.error);
|