@mintjamsinc/ichigojs 0.1.61 → 0.1.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/dist/ichigo.cjs +49 -5
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +49 -5
- package/dist/ichigo.esm.js.map +1 -1
- package/dist/ichigo.esm.min.js +1 -1
- package/dist/ichigo.min.cjs +1 -1
- package/dist/ichigo.umd.js +49 -5
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/dist/types/ichigo/directives/VOnDirective.d.ts +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -277,7 +277,27 @@ Event handling with modifiers:
|
|
|
277
277
|
<div @click.stop="handleClick">Stop propagation</div>
|
|
278
278
|
```
|
|
279
279
|
|
|
280
|
-
|
|
280
|
+
Event modifiers: `.stop`, `.prevent`, `.capture`, `.self`, `.once`
|
|
281
|
+
|
|
282
|
+
Key modifiers (KeyboardEvent): `.enter`, `.tab`, `.delete` (matches Delete/Backspace), `.esc` / `.escape`, `.space`, `.up`, `.down`, `.left`, `.right`
|
|
283
|
+
|
|
284
|
+
Mouse button modifiers (MouseEvent): `.left`, `.middle`, `.right`
|
|
285
|
+
|
|
286
|
+
System modifier keys (KeyboardEvent and MouseEvent): `.shift`, `.ctrl`, `.alt`, `.meta`. Add `.exact` to require that no other system modifiers are held.
|
|
287
|
+
|
|
288
|
+
```html
|
|
289
|
+
<!-- Shift + Click -->
|
|
290
|
+
<button @click.shift="onShiftClick">Shift+Click</button>
|
|
291
|
+
|
|
292
|
+
<!-- Right-click without bringing up the browser menu -->
|
|
293
|
+
<div @contextmenu.prevent="onMenu">Right-click me</div>
|
|
294
|
+
|
|
295
|
+
<!-- Middle-click -->
|
|
296
|
+
<a @mousedown.middle="onMiddleClick">Middle-click</a>
|
|
297
|
+
|
|
298
|
+
<!-- Ctrl+Click only (no other modifiers held) -->
|
|
299
|
+
<button @click.ctrl.exact="onCtrlClickOnly">Ctrl+Click only</button>
|
|
300
|
+
```
|
|
281
301
|
|
|
282
302
|
**Event Handlers with Context:**
|
|
283
303
|
|
package/dist/ichigo.cjs
CHANGED
|
@@ -11322,6 +11322,10 @@
|
|
|
11322
11322
|
* The `v-on` directive supports event modifiers such as `.stop`, `.prevent`, `.capture`, `.self`, and `.once` to modify the behavior of the event listener.
|
|
11323
11323
|
* For example, `v-on:click.stop="handleClick"` will stop the event from propagating up the DOM tree.
|
|
11324
11324
|
*
|
|
11325
|
+
* Key modifiers (KeyboardEvent): `.enter`, `.tab`, `.delete` (Delete/Backspace), `.esc` / `.escape`, `.space`, `.up`, `.down`, `.left`, `.right`.
|
|
11326
|
+
* Mouse button modifiers (MouseEvent): `.left`, `.middle`, `.right`.
|
|
11327
|
+
* System modifiers (KeyboardEvent and MouseEvent): `.shift`, `.ctrl`, `.alt`, `.meta`, plus `.exact` to require that no other system modifiers are held.
|
|
11328
|
+
*
|
|
11325
11329
|
* Additionally, this directive supports lifecycle hooks:
|
|
11326
11330
|
* @mount="onMount" - Called before the VNode is mounted to the DOM element
|
|
11327
11331
|
* @mounted="onMounted" - Called after the VNode is mounted to the DOM element
|
|
@@ -11514,14 +11518,14 @@
|
|
|
11514
11518
|
const eventName = this.#eventName;
|
|
11515
11519
|
const useCapture = this.#modifiers.has('capture');
|
|
11516
11520
|
const isOnce = this.#modifiers.has('once');
|
|
11521
|
+
// System modifier keys (held during the event) shared by KeyboardEvent and MouseEvent.
|
|
11522
|
+
const systemModifiers = ['shift', 'ctrl', 'alt', 'meta'];
|
|
11517
11523
|
// Create the event listener function
|
|
11518
11524
|
this.#listener = (event) => {
|
|
11519
|
-
// Check key modifiers for keyboard events
|
|
11525
|
+
// Check key modifiers for keyboard events.
|
|
11526
|
+
// The `.left` / `.right` aliases here mean ArrowLeft / ArrowRight; the same tokens
|
|
11527
|
+
// map to mouse buttons further below, dispatched by event type to avoid ambiguity.
|
|
11520
11528
|
if (event instanceof KeyboardEvent) {
|
|
11521
|
-
// Map of modifier alias -> KeyboardEvent.key values it matches.
|
|
11522
|
-
// Multiple values allow a single modifier to match several physical keys
|
|
11523
|
-
// (e.g. `.delete` matches both Delete and Backspace, matching Vue's behavior).
|
|
11524
|
-
// Multiple aliases pointing to the same key are allowed (e.g. `.esc` / `.escape`).
|
|
11525
11529
|
const keyMap = {
|
|
11526
11530
|
'enter': ['Enter'],
|
|
11527
11531
|
'tab': ['Tab'],
|
|
@@ -11549,6 +11553,46 @@
|
|
|
11549
11553
|
}
|
|
11550
11554
|
}
|
|
11551
11555
|
}
|
|
11556
|
+
// Check mouse button modifiers for mouse events.
|
|
11557
|
+
// `.left` / `.middle` / `.right` map to MouseEvent.button values 0 / 1 / 2.
|
|
11558
|
+
if (event instanceof MouseEvent) {
|
|
11559
|
+
const buttonMap = {
|
|
11560
|
+
'left': 0,
|
|
11561
|
+
'middle': 1,
|
|
11562
|
+
'right': 2
|
|
11563
|
+
};
|
|
11564
|
+
const hasButtonModifier = Object.keys(buttonMap).some(b => this.#modifiers.has(b));
|
|
11565
|
+
if (hasButtonModifier) {
|
|
11566
|
+
let buttonMatched = false;
|
|
11567
|
+
for (const [modifier, buttonValue] of Object.entries(buttonMap)) {
|
|
11568
|
+
if (this.#modifiers.has(modifier) && event.button === buttonValue) {
|
|
11569
|
+
buttonMatched = true;
|
|
11570
|
+
break;
|
|
11571
|
+
}
|
|
11572
|
+
}
|
|
11573
|
+
if (!buttonMatched) {
|
|
11574
|
+
return;
|
|
11575
|
+
}
|
|
11576
|
+
}
|
|
11577
|
+
}
|
|
11578
|
+
// Check system modifier keys (shift / ctrl / alt / meta) and `.exact`.
|
|
11579
|
+
// These properties exist on both KeyboardEvent and MouseEvent.
|
|
11580
|
+
if (event instanceof KeyboardEvent || event instanceof MouseEvent) {
|
|
11581
|
+
// Required system modifiers must be held.
|
|
11582
|
+
for (const mod of systemModifiers) {
|
|
11583
|
+
if (this.#modifiers.has(mod) && !event[`${mod}Key`]) {
|
|
11584
|
+
return;
|
|
11585
|
+
}
|
|
11586
|
+
}
|
|
11587
|
+
// `.exact` rejects events with extra system modifiers held that weren't listed.
|
|
11588
|
+
if (this.#modifiers.has('exact')) {
|
|
11589
|
+
for (const mod of systemModifiers) {
|
|
11590
|
+
if (event[`${mod}Key`] && !this.#modifiers.has(mod)) {
|
|
11591
|
+
return;
|
|
11592
|
+
}
|
|
11593
|
+
}
|
|
11594
|
+
}
|
|
11595
|
+
}
|
|
11552
11596
|
// Apply event modifiers
|
|
11553
11597
|
if (this.#modifiers.has('stop')) {
|
|
11554
11598
|
event.stopPropagation();
|