@hyperfixi/behaviors 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/dist/all.browser.global.js +116 -0
- package/dist/all.browser.global.js.map +1 -0
- package/dist/behaviors/draggable.cjs +109 -0
- package/dist/behaviors/draggable.cjs.map +1 -0
- package/dist/behaviors/draggable.d.cts +15 -0
- package/dist/behaviors/draggable.d.ts +15 -0
- package/dist/behaviors/draggable.js +14 -0
- package/dist/behaviors/draggable.js.map +1 -0
- package/dist/behaviors/removable.cjs +120 -0
- package/dist/behaviors/removable.cjs.map +1 -0
- package/dist/behaviors/removable.d.cts +15 -0
- package/dist/behaviors/removable.d.ts +15 -0
- package/dist/behaviors/removable.js +14 -0
- package/dist/behaviors/removable.js.map +1 -0
- package/dist/behaviors/resizable.cjs +146 -0
- package/dist/behaviors/resizable.cjs.map +1 -0
- package/dist/behaviors/resizable.d.cts +15 -0
- package/dist/behaviors/resizable.d.ts +15 -0
- package/dist/behaviors/resizable.js +14 -0
- package/dist/behaviors/resizable.js.map +1 -0
- package/dist/behaviors/sortable.cjs +119 -0
- package/dist/behaviors/sortable.cjs.map +1 -0
- package/dist/behaviors/sortable.d.cts +15 -0
- package/dist/behaviors/sortable.d.ts +15 -0
- package/dist/behaviors/sortable.js +14 -0
- package/dist/behaviors/sortable.js.map +1 -0
- package/dist/behaviors/toggleable.cjs +105 -0
- package/dist/behaviors/toggleable.cjs.map +1 -0
- package/dist/behaviors/toggleable.d.cts +15 -0
- package/dist/behaviors/toggleable.d.ts +15 -0
- package/dist/behaviors/toggleable.js +14 -0
- package/dist/behaviors/toggleable.js.map +1 -0
- package/dist/chunk-272NKUJ3.js +63 -0
- package/dist/chunk-272NKUJ3.js.map +1 -0
- package/dist/chunk-2NQHIHD5.js +37 -0
- package/dist/chunk-2NQHIHD5.js.map +1 -0
- package/dist/chunk-3DVDS7CT.js +170 -0
- package/dist/chunk-3DVDS7CT.js.map +1 -0
- package/dist/chunk-3Q652JQB.js +37 -0
- package/dist/chunk-3Q652JQB.js.map +1 -0
- package/dist/chunk-BWZ6EGII.js +62 -0
- package/dist/chunk-BWZ6EGII.js.map +1 -0
- package/dist/chunk-G6WR2AYR.js +52 -0
- package/dist/chunk-G6WR2AYR.js.map +1 -0
- package/dist/chunk-HMRPQWQU.js +37 -0
- package/dist/chunk-HMRPQWQU.js.map +1 -0
- package/dist/chunk-MEP6B7XW.js +37 -0
- package/dist/chunk-MEP6B7XW.js.map +1 -0
- package/dist/chunk-URBOGGW6.js +32 -0
- package/dist/chunk-URBOGGW6.js.map +1 -0
- package/dist/chunk-V5IWDPDP.js +89 -0
- package/dist/chunk-V5IWDPDP.js.map +1 -0
- package/dist/chunk-WU37DFAL.js +37 -0
- package/dist/chunk-WU37DFAL.js.map +1 -0
- package/dist/chunk-WUHHMDAA.js +48 -0
- package/dist/chunk-WUHHMDAA.js.map +1 -0
- package/dist/core.browser.global.js +39 -0
- package/dist/core.browser.global.js.map +1 -0
- package/dist/draggable.browser.global.js +25 -0
- package/dist/draggable.browser.global.js.map +1 -0
- package/dist/index.cjs +907 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +134 -0
- package/dist/index.d.ts +134 -0
- package/dist/index.js +193 -0
- package/dist/index.js.map +1 -0
- package/dist/loaders.cjs +562 -0
- package/dist/loaders.cjs.map +1 -0
- package/dist/loaders.d.cts +2 -0
- package/dist/loaders.d.ts +2 -0
- package/dist/loaders.js +8 -0
- package/dist/loaders.js.map +1 -0
- package/dist/registry.cjs +214 -0
- package/dist/registry.cjs.map +1 -0
- package/dist/registry.d.cts +116 -0
- package/dist/registry.d.ts +116 -0
- package/dist/registry.js +47 -0
- package/dist/registry.js.map +1 -0
- package/dist/removable.browser.global.js +23 -0
- package/dist/removable.browser.global.js.map +1 -0
- package/dist/resizable.browser.global.js +35 -0
- package/dist/resizable.browser.global.js.map +1 -0
- package/dist/schemas/index.cjs +353 -0
- package/dist/schemas/index.cjs.map +1 -0
- package/dist/schemas/index.d.cts +75 -0
- package/dist/schemas/index.d.ts +75 -0
- package/dist/schemas/index.js +41 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/sortable.browser.global.js +25 -0
- package/dist/sortable.browser.global.js.map +1 -0
- package/dist/toggleable.browser.global.js +16 -0
- package/dist/toggleable.browser.global.js.map +1 -0
- package/dist/types-CCc_2wAb.d.cts +100 -0
- package/dist/types-CCc_2wAb.d.ts +100 -0
- package/package.json +109 -0
- package/src/behaviors/draggable.ts +60 -0
- package/src/behaviors/index.ts +40 -0
- package/src/behaviors/integration.test.ts +80 -0
- package/src/behaviors/removable.ts +55 -0
- package/src/behaviors/resizable.ts +55 -0
- package/src/behaviors/sortable.ts +56 -0
- package/src/behaviors/toggleable.ts +55 -0
- package/src/core-bundle.ts +35 -0
- package/src/generated/index.ts +9 -0
- package/src/generated/metadata.ts +78 -0
- package/src/generated/types.ts +51 -0
- package/src/index.test.ts +180 -0
- package/src/index.ts +222 -0
- package/src/loaders.ts +39 -0
- package/src/registry.test.ts +207 -0
- package/src/registry.ts +304 -0
- package/src/schemas/draggable.schema.ts +54 -0
- package/src/schemas/index.ts +60 -0
- package/src/schemas/removable.schema.ts +69 -0
- package/src/schemas/resizable.schema.ts +91 -0
- package/src/schemas/sortable.schema.ts +68 -0
- package/src/schemas/toggleable.schema.ts +50 -0
- package/src/schemas/types.ts +107 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/schemas/index.ts
|
|
21
|
+
var schemas_exports = {};
|
|
22
|
+
__export(schemas_exports, {
|
|
23
|
+
ALL_SCHEMAS: () => ALL_SCHEMAS,
|
|
24
|
+
draggableSchema: () => draggableSchema,
|
|
25
|
+
findSchema: () => findSchema,
|
|
26
|
+
getSchemaNames: () => getSchemaNames,
|
|
27
|
+
removableSchema: () => removableSchema,
|
|
28
|
+
resizableSchema: () => resizableSchema,
|
|
29
|
+
sortableSchema: () => sortableSchema,
|
|
30
|
+
toggleableSchema: () => toggleableSchema
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(schemas_exports);
|
|
33
|
+
|
|
34
|
+
// src/schemas/draggable.schema.ts
|
|
35
|
+
var draggableSchema = {
|
|
36
|
+
name: "Draggable",
|
|
37
|
+
category: "ui",
|
|
38
|
+
tier: "core",
|
|
39
|
+
version: "1.0.0",
|
|
40
|
+
description: "Makes elements draggable with pointer events",
|
|
41
|
+
parameters: [
|
|
42
|
+
{
|
|
43
|
+
name: "dragHandle",
|
|
44
|
+
type: "selector",
|
|
45
|
+
optional: true,
|
|
46
|
+
default: "me",
|
|
47
|
+
description: "CSS selector for the drag handle element"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
events: [
|
|
51
|
+
{ name: "draggable:start", description: "Fired when drag begins" },
|
|
52
|
+
{ name: "draggable:move", description: "Fired during each movement" },
|
|
53
|
+
{ name: "draggable:end", description: "Fired when drag completes" }
|
|
54
|
+
],
|
|
55
|
+
requirements: ["position: absolute or position: fixed on the element"],
|
|
56
|
+
source: `
|
|
57
|
+
behavior Draggable(dragHandle)
|
|
58
|
+
init
|
|
59
|
+
if no dragHandle set dragHandle to me
|
|
60
|
+
end
|
|
61
|
+
on pointerdown(clientX, clientY) from dragHandle
|
|
62
|
+
halt the event
|
|
63
|
+
trigger draggable:start
|
|
64
|
+
measure x
|
|
65
|
+
set startX to it
|
|
66
|
+
measure y
|
|
67
|
+
set startY to it
|
|
68
|
+
set xoff to clientX - startX
|
|
69
|
+
set yoff to clientY - startY
|
|
70
|
+
repeat until event pointerup from document
|
|
71
|
+
wait for pointermove(clientX, clientY) or
|
|
72
|
+
pointerup(clientX, clientY) from document
|
|
73
|
+
add { left: \${clientX - xoff}px; top: \${clientY - yoff}px; }
|
|
74
|
+
trigger draggable:move
|
|
75
|
+
end
|
|
76
|
+
trigger draggable:end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
`.trim()
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// src/schemas/sortable.schema.ts
|
|
83
|
+
var sortableSchema = {
|
|
84
|
+
name: "Sortable",
|
|
85
|
+
category: "ui",
|
|
86
|
+
tier: "common",
|
|
87
|
+
version: "1.0.0",
|
|
88
|
+
description: "Makes child elements reorderable via drag-and-drop",
|
|
89
|
+
parameters: [
|
|
90
|
+
{
|
|
91
|
+
name: "handle",
|
|
92
|
+
type: "selector",
|
|
93
|
+
optional: true,
|
|
94
|
+
default: "none",
|
|
95
|
+
description: "CSS selector for drag handles within items"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "dragClass",
|
|
99
|
+
type: "string",
|
|
100
|
+
optional: true,
|
|
101
|
+
default: "sorting",
|
|
102
|
+
description: "CSS class added to item during drag"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
events: [
|
|
106
|
+
{ name: "sortable:start", description: "Fired when drag begins" },
|
|
107
|
+
{
|
|
108
|
+
name: "sortable:move",
|
|
109
|
+
description: "Fired during drag \u2014 handle this event to reorder DOM elements"
|
|
110
|
+
},
|
|
111
|
+
{ name: "sortable:end", description: "Fired when drag completes" }
|
|
112
|
+
],
|
|
113
|
+
requirements: ["Users must handle DOM reordering in sortable:move event handlers"],
|
|
114
|
+
source: `
|
|
115
|
+
behavior Sortable(handle, dragClass)
|
|
116
|
+
init
|
|
117
|
+
if no dragClass set dragClass to "sorting"
|
|
118
|
+
end
|
|
119
|
+
on pointerdown(target, clientY) from me
|
|
120
|
+
set item to closest <li/> in target
|
|
121
|
+
if no item exit
|
|
122
|
+
if handle
|
|
123
|
+
set handleEl to target.closest(handle)
|
|
124
|
+
if no handleEl exit
|
|
125
|
+
end
|
|
126
|
+
halt the event
|
|
127
|
+
add dragClass to item
|
|
128
|
+
trigger sortable:start on me
|
|
129
|
+
repeat until event pointerup from document
|
|
130
|
+
wait for pointermove(clientY) from document
|
|
131
|
+
trigger sortable:move on me
|
|
132
|
+
end
|
|
133
|
+
remove dragClass from item
|
|
134
|
+
trigger sortable:end on me
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
`.trim()
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// src/schemas/resizable.schema.ts
|
|
141
|
+
var resizableSchema = {
|
|
142
|
+
name: "Resizable",
|
|
143
|
+
category: "ui",
|
|
144
|
+
tier: "optional",
|
|
145
|
+
version: "1.0.0",
|
|
146
|
+
description: "Makes elements resizable by dragging",
|
|
147
|
+
parameters: [
|
|
148
|
+
{
|
|
149
|
+
name: "handle",
|
|
150
|
+
type: "selector",
|
|
151
|
+
optional: true,
|
|
152
|
+
default: "me",
|
|
153
|
+
description: "CSS selector for the resize handle (defaults to the element itself)"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "minWidth",
|
|
157
|
+
type: "number",
|
|
158
|
+
optional: true,
|
|
159
|
+
default: 50,
|
|
160
|
+
description: "Minimum width in pixels"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "minHeight",
|
|
164
|
+
type: "number",
|
|
165
|
+
optional: true,
|
|
166
|
+
default: 50,
|
|
167
|
+
description: "Minimum height in pixels"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "maxWidth",
|
|
171
|
+
type: "number",
|
|
172
|
+
optional: true,
|
|
173
|
+
default: 9999,
|
|
174
|
+
description: "Maximum width in pixels"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "maxHeight",
|
|
178
|
+
type: "number",
|
|
179
|
+
optional: true,
|
|
180
|
+
default: 9999,
|
|
181
|
+
description: "Maximum height in pixels"
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
events: [
|
|
185
|
+
{ name: "resizable:start", description: "Fired when resize begins" },
|
|
186
|
+
{ name: "resizable:resize", description: "Fired during resize" },
|
|
187
|
+
{ name: "resizable:end", description: "Fired when resize completes" }
|
|
188
|
+
],
|
|
189
|
+
source: `
|
|
190
|
+
behavior Resizable(handle, minWidth, minHeight, maxWidth, maxHeight)
|
|
191
|
+
init
|
|
192
|
+
if no handle set handle to me
|
|
193
|
+
if no minWidth set minWidth to 50
|
|
194
|
+
if no minHeight set minHeight to 50
|
|
195
|
+
if no maxWidth set maxWidth to 9999
|
|
196
|
+
if no maxHeight set maxHeight to 9999
|
|
197
|
+
end
|
|
198
|
+
on pointerdown(clientX, clientY) from handle
|
|
199
|
+
halt the event
|
|
200
|
+
trigger resizable:start
|
|
201
|
+
measure width
|
|
202
|
+
set startWidth to it
|
|
203
|
+
measure height
|
|
204
|
+
set startHeight to it
|
|
205
|
+
set startX to clientX
|
|
206
|
+
set startY to clientY
|
|
207
|
+
repeat until event pointerup from document
|
|
208
|
+
wait for pointermove(clientX, clientY) or
|
|
209
|
+
pointerup from document
|
|
210
|
+
set newWidth to startWidth + (clientX - startX)
|
|
211
|
+
set newHeight to startHeight + (clientY - startY)
|
|
212
|
+
if newWidth < minWidth set newWidth to minWidth
|
|
213
|
+
if newWidth > maxWidth set newWidth to maxWidth
|
|
214
|
+
if newHeight < minHeight set newHeight to minHeight
|
|
215
|
+
if newHeight > maxHeight set newHeight to maxHeight
|
|
216
|
+
add { width: \${newWidth}px; height: \${newHeight}px; }
|
|
217
|
+
trigger resizable:resize
|
|
218
|
+
end
|
|
219
|
+
trigger resizable:end
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
`.trim()
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// src/schemas/removable.schema.ts
|
|
226
|
+
var removableSchema = {
|
|
227
|
+
name: "Removable",
|
|
228
|
+
category: "data",
|
|
229
|
+
tier: "common",
|
|
230
|
+
version: "1.2.0",
|
|
231
|
+
description: "Makes elements removable on click",
|
|
232
|
+
parameters: [
|
|
233
|
+
{
|
|
234
|
+
name: "triggerEl",
|
|
235
|
+
type: "selector",
|
|
236
|
+
optional: true,
|
|
237
|
+
default: "me",
|
|
238
|
+
description: "Element that triggers removal (e.g., a close button)"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "confirm",
|
|
242
|
+
type: "boolean",
|
|
243
|
+
optional: true,
|
|
244
|
+
default: false,
|
|
245
|
+
description: "Show confirmation dialog before removal"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: "effect",
|
|
249
|
+
type: "string",
|
|
250
|
+
optional: true,
|
|
251
|
+
default: "none",
|
|
252
|
+
enum: ["fade", "none"],
|
|
253
|
+
description: 'Transition effect: "fade" or "none"'
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
events: [
|
|
257
|
+
{ name: "removable:before", description: "Fired before removal (cancelable)" },
|
|
258
|
+
{ name: "removable:removed", description: "Fired after removal" }
|
|
259
|
+
],
|
|
260
|
+
source: `
|
|
261
|
+
behavior Removable(triggerEl, confirm, effect)
|
|
262
|
+
init
|
|
263
|
+
if triggerEl is undefined
|
|
264
|
+
set triggerEl to me
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
on click from triggerEl
|
|
268
|
+
if confirm
|
|
269
|
+
if not window.confirm("Are you sure?")
|
|
270
|
+
halt
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
trigger removable:before
|
|
274
|
+
if effect is "fade"
|
|
275
|
+
transition opacity to 0 over 300ms
|
|
276
|
+
end
|
|
277
|
+
trigger removable:removed
|
|
278
|
+
remove me
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
`.trim()
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// src/schemas/toggleable.schema.ts
|
|
285
|
+
var toggleableSchema = {
|
|
286
|
+
name: "Toggleable",
|
|
287
|
+
category: "form",
|
|
288
|
+
tier: "core",
|
|
289
|
+
version: "1.0.0",
|
|
290
|
+
description: "Toggles a CSS class on click",
|
|
291
|
+
parameters: [
|
|
292
|
+
{
|
|
293
|
+
name: "cls",
|
|
294
|
+
type: "string",
|
|
295
|
+
optional: true,
|
|
296
|
+
default: "active",
|
|
297
|
+
description: "CSS class to toggle"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: "target",
|
|
301
|
+
type: "selector",
|
|
302
|
+
optional: true,
|
|
303
|
+
default: "me",
|
|
304
|
+
description: "Element to toggle the class on"
|
|
305
|
+
}
|
|
306
|
+
],
|
|
307
|
+
events: [
|
|
308
|
+
{ name: "toggleable:on", description: "Fired when class is added" },
|
|
309
|
+
{ name: "toggleable:off", description: "Fired when class is removed" }
|
|
310
|
+
],
|
|
311
|
+
source: `
|
|
312
|
+
behavior Toggleable(cls, target)
|
|
313
|
+
init
|
|
314
|
+
if cls is undefined
|
|
315
|
+
set cls to "active"
|
|
316
|
+
end
|
|
317
|
+
if target is undefined
|
|
318
|
+
set target to me
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
on click
|
|
322
|
+
toggle .{cls} on target
|
|
323
|
+
end
|
|
324
|
+
end
|
|
325
|
+
`.trim()
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// src/schemas/index.ts
|
|
329
|
+
var ALL_SCHEMAS = {
|
|
330
|
+
Draggable: draggableSchema,
|
|
331
|
+
Sortable: sortableSchema,
|
|
332
|
+
Resizable: resizableSchema,
|
|
333
|
+
Removable: removableSchema,
|
|
334
|
+
Toggleable: toggleableSchema
|
|
335
|
+
};
|
|
336
|
+
function getSchemaNames() {
|
|
337
|
+
return Object.keys(ALL_SCHEMAS);
|
|
338
|
+
}
|
|
339
|
+
function findSchema(name) {
|
|
340
|
+
return ALL_SCHEMAS[name];
|
|
341
|
+
}
|
|
342
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
343
|
+
0 && (module.exports = {
|
|
344
|
+
ALL_SCHEMAS,
|
|
345
|
+
draggableSchema,
|
|
346
|
+
findSchema,
|
|
347
|
+
getSchemaNames,
|
|
348
|
+
removableSchema,
|
|
349
|
+
resizableSchema,
|
|
350
|
+
sortableSchema,
|
|
351
|
+
toggleableSchema
|
|
352
|
+
});
|
|
353
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schemas/index.ts","../../src/schemas/draggable.schema.ts","../../src/schemas/sortable.schema.ts","../../src/schemas/resizable.schema.ts","../../src/schemas/removable.schema.ts","../../src/schemas/toggleable.schema.ts"],"sourcesContent":["/**\n * Behavior Schemas\n *\n * Central export point for all behavior schemas.\n * Used by the registry and code generation.\n */\n\n// Types\nexport type {\n BehaviorSchema,\n BehaviorCategory,\n BehaviorTier,\n ParameterSchema,\n EventSchema,\n BehaviorModule,\n LokaScriptInstance,\n} from './types';\n\n// Individual schemas\nexport { draggableSchema } from './draggable.schema';\nexport { sortableSchema } from './sortable.schema';\nexport { resizableSchema } from './resizable.schema';\nexport { removableSchema } from './removable.schema';\nexport { toggleableSchema } from './toggleable.schema';\n\n// All schemas as a collection\nimport { draggableSchema } from './draggable.schema';\nimport { sortableSchema } from './sortable.schema';\nimport { resizableSchema } from './resizable.schema';\nimport { removableSchema } from './removable.schema';\nimport { toggleableSchema } from './toggleable.schema';\nimport type { BehaviorSchema } from './types';\n\n/**\n * All behavior schemas indexed by name.\n */\nexport const ALL_SCHEMAS: Record<string, BehaviorSchema> = {\n Draggable: draggableSchema,\n Sortable: sortableSchema,\n Resizable: resizableSchema,\n Removable: removableSchema,\n Toggleable: toggleableSchema,\n};\n\n/**\n * Get all schema names.\n */\nexport function getSchemaNames(): string[] {\n return Object.keys(ALL_SCHEMAS);\n}\n\n/**\n * Find a schema by name. Returns undefined if not found.\n *\n * Note: For the throwing version, use `getSchema()` from the registry\n * (exported from '@hyperfixi/behaviors').\n */\nexport function findSchema(name: string): BehaviorSchema | undefined {\n return ALL_SCHEMAS[name];\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: 'Makes elements draggable with pointer events',\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 init\n if no dragHandle set dragHandle to me\n end\n on pointerdown(clientX, clientY) from dragHandle\n halt the event\n trigger draggable:start\n measure x\n set startX to it\n measure y\n set startY to it\n set xoff to clientX - startX\n set yoff to clientY - startY\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\n`.trim(),\n};\n","import type { BehaviorSchema } from './types';\n\n/**\n * Sortable Behavior Schema\n *\n * Drag-and-drop reordering of list items.\n * Apply to a container element; children become sortable.\n *\n * Note: This behavior fires lifecycle events but does NOT automatically\n * reorder DOM elements. Users must handle actual reordering in their\n * `sortable:move` event handlers.\n */\nexport const sortableSchema: BehaviorSchema = {\n name: 'Sortable',\n category: 'ui',\n tier: 'common',\n version: '1.0.0',\n description: 'Makes child elements reorderable via drag-and-drop',\n parameters: [\n {\n name: 'handle',\n type: 'selector',\n optional: true,\n default: 'none',\n description: 'CSS selector for drag handles within items',\n },\n {\n name: 'dragClass',\n type: 'string',\n optional: true,\n default: 'sorting',\n description: 'CSS class added to item during drag',\n },\n ],\n events: [\n { name: 'sortable:start', description: 'Fired when drag begins' },\n {\n name: 'sortable:move',\n description: 'Fired during drag — handle this event to reorder DOM elements',\n },\n { name: 'sortable:end', description: 'Fired when drag completes' },\n ],\n requirements: ['Users must handle DOM reordering in sortable:move event handlers'],\n source: `\nbehavior Sortable(handle, dragClass)\n init\n if no dragClass set dragClass to \"sorting\"\n end\n on pointerdown(target, clientY) from me\n set item to closest <li/> in target\n if no item exit\n if handle\n set handleEl to target.closest(handle)\n if no handleEl exit\n end\n halt the event\n add dragClass to item\n trigger sortable:start on me\n repeat until event pointerup from document\n wait for pointermove(clientY) from document\n trigger sortable:move on me\n end\n remove dragClass from item\n trigger sortable:end on me\n end\nend\n`.trim(),\n};\n","import type { BehaviorSchema } from './types';\n\n/**\n * Resizable Behavior Schema\n *\n * Makes elements resizable by dragging edges or corners.\n * Supports minimum/maximum dimensions and resize handles.\n */\nexport const resizableSchema: BehaviorSchema = {\n name: 'Resizable',\n category: 'ui',\n tier: 'optional',\n version: '1.0.0',\n description: 'Makes elements resizable by dragging',\n parameters: [\n {\n name: 'handle',\n type: 'selector',\n optional: true,\n default: 'me',\n description: 'CSS selector for the resize handle (defaults to the element itself)',\n },\n {\n name: 'minWidth',\n type: 'number',\n optional: true,\n default: 50,\n description: 'Minimum width in pixels',\n },\n {\n name: 'minHeight',\n type: 'number',\n optional: true,\n default: 50,\n description: 'Minimum height in pixels',\n },\n {\n name: 'maxWidth',\n type: 'number',\n optional: true,\n default: 9999,\n description: 'Maximum width in pixels',\n },\n {\n name: 'maxHeight',\n type: 'number',\n optional: true,\n default: 9999,\n description: 'Maximum height in pixels',\n },\n ],\n events: [\n { name: 'resizable:start', description: 'Fired when resize begins' },\n { name: 'resizable:resize', description: 'Fired during resize' },\n { name: 'resizable:end', description: 'Fired when resize completes' },\n ],\n source: `\nbehavior Resizable(handle, minWidth, minHeight, maxWidth, maxHeight)\n init\n if no handle set handle to me\n if no minWidth set minWidth to 50\n if no minHeight set minHeight to 50\n if no maxWidth set maxWidth to 9999\n if no maxHeight set maxHeight to 9999\n end\n on pointerdown(clientX, clientY) from handle\n halt the event\n trigger resizable:start\n measure width\n set startWidth to it\n measure height\n set startHeight to it\n set startX to clientX\n set startY to clientY\n repeat until event pointerup from document\n wait for pointermove(clientX, clientY) or\n pointerup from document\n set newWidth to startWidth + (clientX - startX)\n set newHeight to startHeight + (clientY - startY)\n if newWidth < minWidth set newWidth to minWidth\n if newWidth > maxWidth set newWidth to maxWidth\n if newHeight < minHeight set newHeight to minHeight\n if newHeight > maxHeight set newHeight to maxHeight\n add { width: \\${newWidth}px; height: \\${newHeight}px; }\n trigger resizable:resize\n end\n trigger resizable:end\n end\nend\n`.trim(),\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: 'confirm',\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, confirm, effect)\n init\n if triggerEl is undefined\n set triggerEl to me\n end\n end\n on click from triggerEl\n if confirm\n if not window.confirm(\"Are you sure?\")\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\n`.trim(),\n};\n","import type { BehaviorSchema } from './types';\n\n/**\n * Toggleable Behavior Schema\n *\n * Toggles a CSS class on click.\n * Useful for accordions, dropdowns, and toggle buttons.\n */\nexport const toggleableSchema: BehaviorSchema = {\n name: 'Toggleable',\n category: 'form',\n tier: 'core',\n version: '1.0.0',\n description: 'Toggles a CSS class on click',\n parameters: [\n {\n name: 'cls',\n type: 'string',\n optional: true,\n default: 'active',\n description: 'CSS class to toggle',\n },\n {\n name: 'target',\n type: 'selector',\n optional: true,\n default: 'me',\n description: 'Element to toggle the class on',\n },\n ],\n events: [\n { name: 'toggleable:on', description: 'Fired when class is added' },\n { name: 'toggleable:off', description: 'Fired when class is removed' },\n ],\n source: `\nbehavior Toggleable(cls, target)\n init\n if cls is undefined\n set cls to \"active\"\n end\n if target is undefined\n set target to me\n end\n end\n on click\n toggle .{cls} on target\n end\nend\n`.trim(),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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;A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AAY;AACd;AAKO,SAAS,iBAA2B;AACzC,SAAO,OAAO,KAAK,WAAW;AAChC;AAQO,SAAS,WAAW,MAA0C;AACnE,SAAO,YAAY,IAAI;AACzB;","names":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { a as BehaviorSchema } from '../types-CCc_2wAb.cjs';
|
|
2
|
+
export { b as BehaviorCategory, B as BehaviorModule, c as BehaviorTier, E as EventSchema, L as LokaScriptInstance, P as ParameterSchema } from '../types-CCc_2wAb.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Draggable Behavior Schema
|
|
6
|
+
*
|
|
7
|
+
* Makes elements draggable with pointer events.
|
|
8
|
+
* Supports custom drag handles and lifecycle events.
|
|
9
|
+
*/
|
|
10
|
+
declare const draggableSchema: BehaviorSchema;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Sortable Behavior Schema
|
|
14
|
+
*
|
|
15
|
+
* Drag-and-drop reordering of list items.
|
|
16
|
+
* Apply to a container element; children become sortable.
|
|
17
|
+
*
|
|
18
|
+
* Note: This behavior fires lifecycle events but does NOT automatically
|
|
19
|
+
* reorder DOM elements. Users must handle actual reordering in their
|
|
20
|
+
* `sortable:move` event handlers.
|
|
21
|
+
*/
|
|
22
|
+
declare const sortableSchema: BehaviorSchema;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Resizable Behavior Schema
|
|
26
|
+
*
|
|
27
|
+
* Makes elements resizable by dragging edges or corners.
|
|
28
|
+
* Supports minimum/maximum dimensions and resize handles.
|
|
29
|
+
*/
|
|
30
|
+
declare const resizableSchema: BehaviorSchema;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Removable Behavior Schema
|
|
34
|
+
*
|
|
35
|
+
* Removes an element when a trigger is clicked.
|
|
36
|
+
* Supports optional confirmation and transition effects.
|
|
37
|
+
*
|
|
38
|
+
* @since 1.2.0 — `trigger` parameter renamed to `triggerEl` to avoid
|
|
39
|
+
* shadowing the hyperscript `trigger` command keyword. Users migrating
|
|
40
|
+
* from v1.x should update: `install Removable(triggerEl: .close-btn)`.
|
|
41
|
+
*/
|
|
42
|
+
declare const removableSchema: BehaviorSchema;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Toggleable Behavior Schema
|
|
46
|
+
*
|
|
47
|
+
* Toggles a CSS class on click.
|
|
48
|
+
* Useful for accordions, dropdowns, and toggle buttons.
|
|
49
|
+
*/
|
|
50
|
+
declare const toggleableSchema: BehaviorSchema;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Behavior Schemas
|
|
54
|
+
*
|
|
55
|
+
* Central export point for all behavior schemas.
|
|
56
|
+
* Used by the registry and code generation.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* All behavior schemas indexed by name.
|
|
61
|
+
*/
|
|
62
|
+
declare const ALL_SCHEMAS: Record<string, BehaviorSchema>;
|
|
63
|
+
/**
|
|
64
|
+
* Get all schema names.
|
|
65
|
+
*/
|
|
66
|
+
declare function getSchemaNames(): string[];
|
|
67
|
+
/**
|
|
68
|
+
* Find a schema by name. Returns undefined if not found.
|
|
69
|
+
*
|
|
70
|
+
* Note: For the throwing version, use `getSchema()` from the registry
|
|
71
|
+
* (exported from '@hyperfixi/behaviors').
|
|
72
|
+
*/
|
|
73
|
+
declare function findSchema(name: string): BehaviorSchema | undefined;
|
|
74
|
+
|
|
75
|
+
export { ALL_SCHEMAS, BehaviorSchema, draggableSchema, findSchema, getSchemaNames, removableSchema, resizableSchema, sortableSchema, toggleableSchema };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { a as BehaviorSchema } from '../types-CCc_2wAb.js';
|
|
2
|
+
export { b as BehaviorCategory, B as BehaviorModule, c as BehaviorTier, E as EventSchema, L as LokaScriptInstance, P as ParameterSchema } from '../types-CCc_2wAb.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Draggable Behavior Schema
|
|
6
|
+
*
|
|
7
|
+
* Makes elements draggable with pointer events.
|
|
8
|
+
* Supports custom drag handles and lifecycle events.
|
|
9
|
+
*/
|
|
10
|
+
declare const draggableSchema: BehaviorSchema;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Sortable Behavior Schema
|
|
14
|
+
*
|
|
15
|
+
* Drag-and-drop reordering of list items.
|
|
16
|
+
* Apply to a container element; children become sortable.
|
|
17
|
+
*
|
|
18
|
+
* Note: This behavior fires lifecycle events but does NOT automatically
|
|
19
|
+
* reorder DOM elements. Users must handle actual reordering in their
|
|
20
|
+
* `sortable:move` event handlers.
|
|
21
|
+
*/
|
|
22
|
+
declare const sortableSchema: BehaviorSchema;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Resizable Behavior Schema
|
|
26
|
+
*
|
|
27
|
+
* Makes elements resizable by dragging edges or corners.
|
|
28
|
+
* Supports minimum/maximum dimensions and resize handles.
|
|
29
|
+
*/
|
|
30
|
+
declare const resizableSchema: BehaviorSchema;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Removable Behavior Schema
|
|
34
|
+
*
|
|
35
|
+
* Removes an element when a trigger is clicked.
|
|
36
|
+
* Supports optional confirmation and transition effects.
|
|
37
|
+
*
|
|
38
|
+
* @since 1.2.0 — `trigger` parameter renamed to `triggerEl` to avoid
|
|
39
|
+
* shadowing the hyperscript `trigger` command keyword. Users migrating
|
|
40
|
+
* from v1.x should update: `install Removable(triggerEl: .close-btn)`.
|
|
41
|
+
*/
|
|
42
|
+
declare const removableSchema: BehaviorSchema;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Toggleable Behavior Schema
|
|
46
|
+
*
|
|
47
|
+
* Toggles a CSS class on click.
|
|
48
|
+
* Useful for accordions, dropdowns, and toggle buttons.
|
|
49
|
+
*/
|
|
50
|
+
declare const toggleableSchema: BehaviorSchema;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Behavior Schemas
|
|
54
|
+
*
|
|
55
|
+
* Central export point for all behavior schemas.
|
|
56
|
+
* Used by the registry and code generation.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* All behavior schemas indexed by name.
|
|
61
|
+
*/
|
|
62
|
+
declare const ALL_SCHEMAS: Record<string, BehaviorSchema>;
|
|
63
|
+
/**
|
|
64
|
+
* Get all schema names.
|
|
65
|
+
*/
|
|
66
|
+
declare function getSchemaNames(): string[];
|
|
67
|
+
/**
|
|
68
|
+
* Find a schema by name. Returns undefined if not found.
|
|
69
|
+
*
|
|
70
|
+
* Note: For the throwing version, use `getSchema()` from the registry
|
|
71
|
+
* (exported from '@hyperfixi/behaviors').
|
|
72
|
+
*/
|
|
73
|
+
declare function findSchema(name: string): BehaviorSchema | undefined;
|
|
74
|
+
|
|
75
|
+
export { ALL_SCHEMAS, BehaviorSchema, draggableSchema, findSchema, getSchemaNames, removableSchema, resizableSchema, sortableSchema, toggleableSchema };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
draggableSchema
|
|
3
|
+
} from "../chunk-G6WR2AYR.js";
|
|
4
|
+
import {
|
|
5
|
+
removableSchema
|
|
6
|
+
} from "../chunk-272NKUJ3.js";
|
|
7
|
+
import {
|
|
8
|
+
resizableSchema
|
|
9
|
+
} from "../chunk-V5IWDPDP.js";
|
|
10
|
+
import {
|
|
11
|
+
sortableSchema
|
|
12
|
+
} from "../chunk-BWZ6EGII.js";
|
|
13
|
+
import {
|
|
14
|
+
toggleableSchema
|
|
15
|
+
} from "../chunk-WUHHMDAA.js";
|
|
16
|
+
|
|
17
|
+
// src/schemas/index.ts
|
|
18
|
+
var ALL_SCHEMAS = {
|
|
19
|
+
Draggable: draggableSchema,
|
|
20
|
+
Sortable: sortableSchema,
|
|
21
|
+
Resizable: resizableSchema,
|
|
22
|
+
Removable: removableSchema,
|
|
23
|
+
Toggleable: toggleableSchema
|
|
24
|
+
};
|
|
25
|
+
function getSchemaNames() {
|
|
26
|
+
return Object.keys(ALL_SCHEMAS);
|
|
27
|
+
}
|
|
28
|
+
function findSchema(name) {
|
|
29
|
+
return ALL_SCHEMAS[name];
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
ALL_SCHEMAS,
|
|
33
|
+
draggableSchema,
|
|
34
|
+
findSchema,
|
|
35
|
+
getSchemaNames,
|
|
36
|
+
removableSchema,
|
|
37
|
+
resizableSchema,
|
|
38
|
+
sortableSchema,
|
|
39
|
+
toggleableSchema
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schemas/index.ts"],"sourcesContent":["/**\n * Behavior Schemas\n *\n * Central export point for all behavior schemas.\n * Used by the registry and code generation.\n */\n\n// Types\nexport type {\n BehaviorSchema,\n BehaviorCategory,\n BehaviorTier,\n ParameterSchema,\n EventSchema,\n BehaviorModule,\n LokaScriptInstance,\n} from './types';\n\n// Individual schemas\nexport { draggableSchema } from './draggable.schema';\nexport { sortableSchema } from './sortable.schema';\nexport { resizableSchema } from './resizable.schema';\nexport { removableSchema } from './removable.schema';\nexport { toggleableSchema } from './toggleable.schema';\n\n// All schemas as a collection\nimport { draggableSchema } from './draggable.schema';\nimport { sortableSchema } from './sortable.schema';\nimport { resizableSchema } from './resizable.schema';\nimport { removableSchema } from './removable.schema';\nimport { toggleableSchema } from './toggleable.schema';\nimport type { BehaviorSchema } from './types';\n\n/**\n * All behavior schemas indexed by name.\n */\nexport const ALL_SCHEMAS: Record<string, BehaviorSchema> = {\n Draggable: draggableSchema,\n Sortable: sortableSchema,\n Resizable: resizableSchema,\n Removable: removableSchema,\n Toggleable: toggleableSchema,\n};\n\n/**\n * Get all schema names.\n */\nexport function getSchemaNames(): string[] {\n return Object.keys(ALL_SCHEMAS);\n}\n\n/**\n * Find a schema by name. Returns undefined if not found.\n *\n * Note: For the throwing version, use `getSchema()` from the registry\n * (exported from '@hyperfixi/behaviors').\n */\nexport function findSchema(name: string): BehaviorSchema | undefined {\n return ALL_SCHEMAS[name];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCO,IAAM,cAA8C;AAAA,EACzD,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AACd;AAKO,SAAS,iBAA2B;AACzC,SAAO,OAAO,KAAK,WAAW;AAChC;AAQO,SAAS,WAAW,MAA0C;AACnE,SAAO,YAAY,IAAI;AACzB;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";var HyperFixiBehaviors=(()=>{var i=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var r in e)i(t,r,{get:e[r],enumerable:!0})},p=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of l(e))!c.call(t,a)&&a!==r&&i(t,a,{get:()=>e[a],enumerable:!(n=d(e,a))||n.enumerable});return t};var g=t=>p(i({},"__esModule",{value:!0}),t);var w={};m(w,{default:()=>f,registerSortable:()=>s,sortableMetadata:()=>u,sortableSource:()=>h});var o={name:"Sortable",category:"ui",tier:"common",version:"1.0.0",description:"Makes child elements reorderable via drag-and-drop",parameters:[{name:"handle",type:"selector",optional:!0,default:"none",description:"CSS selector for drag handles within items"},{name:"dragClass",type:"string",optional:!0,default:"sorting",description:"CSS class added to item during drag"}],events:[{name:"sortable:start",description:"Fired when drag begins"},{name:"sortable:move",description:"Fired during drag \u2014 handle this event to reorder DOM elements"},{name:"sortable:end",description:"Fired when drag completes"}],requirements:["Users must handle DOM reordering in sortable:move event handlers"],source:`
|
|
2
|
+
behavior Sortable(handle, dragClass)
|
|
3
|
+
init
|
|
4
|
+
if no dragClass set dragClass to "sorting"
|
|
5
|
+
end
|
|
6
|
+
on pointerdown(target, clientY) from me
|
|
7
|
+
set item to closest <li/> in target
|
|
8
|
+
if no item exit
|
|
9
|
+
if handle
|
|
10
|
+
set handleEl to target.closest(handle)
|
|
11
|
+
if no handleEl exit
|
|
12
|
+
end
|
|
13
|
+
halt the event
|
|
14
|
+
add dragClass to item
|
|
15
|
+
trigger sortable:start on me
|
|
16
|
+
repeat until event pointerup from document
|
|
17
|
+
wait for pointermove(clientY) from document
|
|
18
|
+
trigger sortable:move on me
|
|
19
|
+
end
|
|
20
|
+
remove dragClass from item
|
|
21
|
+
trigger sortable:end on me
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
`.trim()};var h=o.source,u=o;async function s(t){let e=t||(typeof window<"u"?window.lokascript:null);if(!e)throw new Error("LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors.");let r=e.compileSync(o.source,{traditional:!0});if(!r.ok)throw new Error(`Failed to compile Sortable behavior: ${JSON.stringify(r.errors)}`);let n=e.createContext?e.createContext():{locals:new Map,globals:new Map};await e.execute(r.ast,n)}typeof window<"u"&&window.lokascript&&s().catch(console.error);var f={source:o.source,metadata:o,register:s};return g(w);})();
|
|
25
|
+
//# sourceMappingURL=sortable.browser.global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/behaviors/sortable.ts","../src/schemas/sortable.schema.ts"],"sourcesContent":["/**\n * Sortable Behavior\n *\n * A behavior for drag-and-drop reordering of list items.\n * Apply to a container element; children become sortable.\n *\n * @example\n * ```html\n * <ul _=\"install Sortable\">\n * <li>Item 1</li>\n * <li>Item 2</li>\n * </ul>\n * ```\n */\n\nimport { sortableSchema } from '../schemas/sortable.schema';\nimport type { LokaScriptInstance, LokaScriptWindow } from '../schemas/types';\n\n// Re-export schema-derived values for backwards compatibility\nexport const sortableSource = sortableSchema.source;\nexport const sortableMetadata = sortableSchema;\n\n/**\n * Register the Sortable behavior with LokaScript.\n */\nexport async function registerSortable(hyperfixi?: LokaScriptInstance): Promise<void> {\n const hf =\n hyperfixi ||\n (typeof window !== 'undefined' ? (window as unknown as LokaScriptWindow).lokascript : null);\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(sortableSchema.source, { traditional: true });\n\n if (!result.ok) {\n throw new Error(`Failed to compile Sortable 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 (typeof window !== 'undefined' && (window as unknown as LokaScriptWindow).lokascript) {\n registerSortable().catch(console.error);\n}\n\nexport default {\n source: sortableSchema.source,\n metadata: sortableSchema,\n register: registerSortable,\n};\n","import type { BehaviorSchema } from './types';\n\n/**\n * Sortable Behavior Schema\n *\n * Drag-and-drop reordering of list items.\n * Apply to a container element; children become sortable.\n *\n * Note: This behavior fires lifecycle events but does NOT automatically\n * reorder DOM elements. Users must handle actual reordering in their\n * `sortable:move` event handlers.\n */\nexport const sortableSchema: BehaviorSchema = {\n name: 'Sortable',\n category: 'ui',\n tier: 'common',\n version: '1.0.0',\n description: 'Makes child elements reorderable via drag-and-drop',\n parameters: [\n {\n name: 'handle',\n type: 'selector',\n optional: true,\n default: 'none',\n description: 'CSS selector for drag handles within items',\n },\n {\n name: 'dragClass',\n type: 'string',\n optional: true,\n default: 'sorting',\n description: 'CSS class added to item during drag',\n },\n ],\n events: [\n { name: 'sortable:start', description: 'Fired when drag begins' },\n {\n name: 'sortable:move',\n description: 'Fired during drag — handle this event to reorder DOM elements',\n },\n { name: 'sortable:end', description: 'Fired when drag completes' },\n ],\n requirements: ['Users must handle DOM reordering in sortable:move event handlers'],\n source: `\nbehavior Sortable(handle, dragClass)\n init\n if no dragClass set dragClass to \"sorting\"\n end\n on pointerdown(target, clientY) from me\n set item to closest <li/> in target\n if no item exit\n if handle\n set handleEl to target.closest(handle)\n if no handleEl exit\n end\n halt the event\n add dragClass to item\n trigger sortable:start on me\n repeat until event pointerup from document\n wait for pointermove(clientY) from document\n trigger sortable:move on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3EJ,EAAiB,EAAE,MAAM,QAAQ,KAAK,EAGxC,IAAOK,EAAQ,CACb,OAAQP,EAAe,OACvB,SAAUA,EACV,SAAUE,CACZ","names":["sortable_exports","__export","sortable_default","registerSortable","sortableMetadata","sortableSource","sortableSchema","sortableSource","sortableSchema","sortableMetadata","registerSortable","hyperfixi","hf","result","ctx","sortable_default"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";var HyperFixiBehaviors=(()=>{var n=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var g=(o,e)=>{for(var t in e)n(o,t,{get:e[t],enumerable:!0})},p=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of l(e))!d.call(o,a)&&a!==t&&n(o,a,{get:()=>e[a],enumerable:!(i=c(e,a))||i.enumerable});return o};var m=o=>p(n({},"__esModule",{value:!0}),o);var h={};g(h,{default:()=>w,registerToggleable:()=>s,toggleableMetadata:()=>u,toggleableSource:()=>f});var r={name:"Toggleable",category:"form",tier:"core",version:"1.0.0",description:"Toggles a CSS class on click",parameters:[{name:"cls",type:"string",optional:!0,default:"active",description:"CSS class to toggle"},{name:"target",type:"selector",optional:!0,default:"me",description:"Element to toggle the class on"}],events:[{name:"toggleable:on",description:"Fired when class is added"},{name:"toggleable:off",description:"Fired when class is removed"}],source:`
|
|
2
|
+
behavior Toggleable(cls, target)
|
|
3
|
+
init
|
|
4
|
+
if cls is undefined
|
|
5
|
+
set cls to "active"
|
|
6
|
+
end
|
|
7
|
+
if target is undefined
|
|
8
|
+
set target to me
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
on click
|
|
12
|
+
toggle .{cls} on target
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
`.trim()};var f=r.source,u=r;async function s(o){let e=o||(typeof window<"u"?window.lokascript:null);if(!e)throw new Error("LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors.");let t=e.compileSync(r.source,{traditional:!0});if(!t.ok)throw new Error(`Failed to compile Toggleable behavior: ${JSON.stringify(t.errors)}`);let i=e.createContext?e.createContext():{locals:new Map,globals:new Map};await e.execute(t.ast,i)}typeof window<"u"&&window.lokascript&&s().catch(console.error);var w={source:r.source,metadata:r,register:s};return m(h);})();
|
|
16
|
+
//# sourceMappingURL=toggleable.browser.global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/behaviors/toggleable.ts","../src/schemas/toggleable.schema.ts"],"sourcesContent":["/**\n * Toggleable Behavior\n *\n * A behavior that toggles a CSS class on click.\n * Useful for accordions, dropdowns, and toggle buttons.\n *\n * @example\n * ```html\n * <button _=\"install Toggleable\">Toggle</button>\n *\n * <button _=\"install Toggleable(cls: expanded, target: #menu)\">Menu</button>\n * ```\n */\n\nimport { toggleableSchema } from '../schemas/toggleable.schema';\nimport type { LokaScriptInstance, LokaScriptWindow } from '../schemas/types';\n\n// Re-export schema-derived values for backwards compatibility\nexport const toggleableSource = toggleableSchema.source;\nexport const toggleableMetadata = toggleableSchema;\n\n/**\n * Register the Toggleable behavior with LokaScript.\n */\nexport async function registerToggleable(hyperfixi?: LokaScriptInstance): Promise<void> {\n const hf =\n hyperfixi ||\n (typeof window !== 'undefined' ? (window as unknown as LokaScriptWindow).lokascript : null);\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(toggleableSchema.source, { traditional: true });\n\n if (!result.ok) {\n throw new Error(`Failed to compile Toggleable 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 (typeof window !== 'undefined' && (window as unknown as LokaScriptWindow).lokascript) {\n registerToggleable().catch(console.error);\n}\n\nexport default {\n source: toggleableSchema.source,\n metadata: toggleableSchema,\n register: registerToggleable,\n};\n","import type { BehaviorSchema } from './types';\n\n/**\n * Toggleable Behavior Schema\n *\n * Toggles a CSS class on click.\n * Useful for accordions, dropdowns, and toggle buttons.\n */\nexport const toggleableSchema: BehaviorSchema = {\n name: 'Toggleable',\n category: 'form',\n tier: 'core',\n version: '1.0.0',\n description: 'Toggles a CSS class on click',\n parameters: [\n {\n name: 'cls',\n type: 'string',\n optional: true,\n default: 'active',\n description: 'CSS class to toggle',\n },\n {\n name: 'target',\n type: 'selector',\n optional: true,\n default: 'me',\n description: 'Element to toggle the class on',\n },\n ],\n events: [\n { name: 'toggleable:on', description: 'Fired when class is added' },\n { name: 'toggleable:off', description: 'Fired when class is removed' },\n ],\n source: `\nbehavior Toggleable(cls, target)\n init\n if cls is undefined\n set cls to \"active\"\n end\n if target is undefined\n set target to me\n end\n end\n on click\n toggle .{cls} on target\n end\nend\n`.trim(),\n};\n"],"mappings":"scAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,uBAAAC,EAAA,uBAAAC,EAAA,qBAAAC,ICQO,IAAMC,EAAmC,CAC9C,KAAM,aACN,SAAU,OACV,KAAM,OACN,QAAS,QACT,YAAa,+BACb,WAAY,CACV,CACE,KAAM,MACN,KAAM,SACN,SAAU,GACV,QAAS,SACT,YAAa,qBACf,EACA,CACE,KAAM,SACN,KAAM,WACN,SAAU,GACV,QAAS,KACT,YAAa,gCACf,CACF,EACA,OAAQ,CACN,CAAE,KAAM,gBAAiB,YAAa,2BAA4B,EAClE,CAAE,KAAM,iBAAkB,YAAa,6BAA8B,CACvE,EACA,OAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcR,KAAK,CACP,ED/BO,IAAMC,EAAmBC,EAAiB,OACpCC,EAAqBD,EAKlC,eAAsBE,EAAmBC,EAA+C,CACtF,IAAMC,EACJD,IACC,OAAO,OAAW,IAAe,OAAuC,WAAa,MAExF,GAAI,CAACC,EACH,MAAM,IAAI,MACR,yFACF,EAGF,IAAMC,EAASD,EAAG,YAAYJ,EAAiB,OAAQ,CAAE,YAAa,EAAK,CAAC,EAE5E,GAAI,CAACK,EAAO,GACV,MAAM,IAAI,MAAM,0CAA0C,KAAK,UAAUA,EAAO,MAAM,CAAC,EAAE,EAG3F,IAAMC,EAAMF,EAAG,cAAgBA,EAAG,cAAc,EAAI,CAAE,OAAQ,IAAI,IAAO,QAAS,IAAI,GAAM,EAC5F,MAAMA,EAAG,QAAQC,EAAO,IAAKC,CAAG,CAClC,CAGI,OAAO,OAAW,KAAgB,OAAuC,YAC3EJ,EAAmB,EAAE,MAAM,QAAQ,KAAK,EAG1C,IAAOK,EAAQ,CACb,OAAQP,EAAiB,OACzB,SAAUA,EACV,SAAUE,CACZ","names":["toggleable_exports","__export","toggleable_default","registerToggleable","toggleableMetadata","toggleableSource","toggleableSchema","toggleableSource","toggleableSchema","toggleableMetadata","registerToggleable","hyperfixi","hf","result","ctx","toggleable_default"]}
|