@mintjamsinc/ichigojs 0.1.56 → 0.1.58
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 +31 -0
- package/dist/ichigo.cjs +27 -15
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +27 -15
- 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 +27 -15
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,6 +219,37 @@ List rendering:
|
|
|
219
219
|
</ul>
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
+
##### Using `<template>` as a fragment
|
|
223
|
+
|
|
224
|
+
`v-for` and `v-if` can be placed on a `<template>` element to render
|
|
225
|
+
multiple nodes per iteration without introducing a wrapper element:
|
|
226
|
+
|
|
227
|
+
```html
|
|
228
|
+
<dl>
|
|
229
|
+
<template v-for="item in items" :key="item.id">
|
|
230
|
+
<dt>{{ item.term }}</dt>
|
|
231
|
+
<dd>{{ item.description }}</dd>
|
|
232
|
+
</template>
|
|
233
|
+
</dl>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
`<template>` supports **either** `v-for` **or** `v-if` per element, but
|
|
237
|
+
**not both on the same `<template>`**. If you need both, either:
|
|
238
|
+
|
|
239
|
+
1. Nest them on separate `<template>` / element levels:
|
|
240
|
+
```html
|
|
241
|
+
<template v-for="item in items" :key="item.id">
|
|
242
|
+
<div v-if="item.visible">{{ item.name }}</div>
|
|
243
|
+
</template>
|
|
244
|
+
```
|
|
245
|
+
2. Use a regular element instead of `<template>`:
|
|
246
|
+
```html
|
|
247
|
+
<div v-for="item in items" v-if="item.visible" :key="item.id">...</div>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Combining `v-for` and `v-if` on the same element works for all
|
|
251
|
+
non-`<template>` tags (v-for is evaluated first, v-if per iteration).
|
|
252
|
+
|
|
222
253
|
#### v-show
|
|
223
254
|
|
|
224
255
|
Toggle visibility:
|
package/dist/ichigo.cjs
CHANGED
|
@@ -8653,6 +8653,14 @@
|
|
|
8653
8653
|
// Other directives (@click, :class, etc.) will be processed on the cloned/rendered elements.
|
|
8654
8654
|
const attributes = [];
|
|
8655
8655
|
if (element.hasAttribute(StandardDirectiveName.V_FOR)) {
|
|
8656
|
+
// <template v-for v-if> is not supported: v-for clones .content (a
|
|
8657
|
+
// DocumentFragment), so the v-if attribute on the <template> itself
|
|
8658
|
+
// is lost. Warn the developer so silent failure is avoided.
|
|
8659
|
+
if (element instanceof HTMLTemplateElement && element.hasAttribute(StandardDirectiveName.V_IF)) {
|
|
8660
|
+
console.warn('[ichigo.js] <template> cannot combine v-for and v-if. ' +
|
|
8661
|
+
'The v-if will be ignored. Move v-if to an inner element, ' +
|
|
8662
|
+
'or replace <template> with a regular element.', element);
|
|
8663
|
+
}
|
|
8656
8664
|
// For v-for template element: only process v-for and :key
|
|
8657
8665
|
// Other attributes will be processed when child VNodes are created for cloned elements
|
|
8658
8666
|
attributes.push(element.getAttributeNode(StandardDirectiveName.V_FOR));
|
|
@@ -11399,23 +11407,27 @@
|
|
|
11399
11407
|
this.#listener = (event) => {
|
|
11400
11408
|
// Check key modifiers for keyboard events
|
|
11401
11409
|
if (event instanceof KeyboardEvent) {
|
|
11402
|
-
|
|
11403
|
-
|
|
11410
|
+
// Map of modifier alias -> KeyboardEvent.key values it matches.
|
|
11411
|
+
// Multiple values allow a single modifier to match several physical keys
|
|
11412
|
+
// (e.g. `.delete` matches both Delete and Backspace, matching Vue's behavior).
|
|
11413
|
+
// Multiple aliases pointing to the same key are allowed (e.g. `.esc` / `.escape`).
|
|
11414
|
+
const keyMap = {
|
|
11415
|
+
'enter': ['Enter'],
|
|
11416
|
+
'tab': ['Tab'],
|
|
11417
|
+
'delete': ['Delete', 'Backspace'],
|
|
11418
|
+
'esc': ['Escape'],
|
|
11419
|
+
'escape': ['Escape'],
|
|
11420
|
+
'space': [' '],
|
|
11421
|
+
'up': ['ArrowUp'],
|
|
11422
|
+
'down': ['ArrowDown'],
|
|
11423
|
+
'left': ['ArrowLeft'],
|
|
11424
|
+
'right': ['ArrowRight']
|
|
11425
|
+
};
|
|
11426
|
+
const hasKeyModifier = Object.keys(keyMap).some(key => this.#modifiers.has(key));
|
|
11404
11427
|
if (hasKeyModifier) {
|
|
11405
|
-
const keyMap = {
|
|
11406
|
-
'enter': 'Enter',
|
|
11407
|
-
'tab': 'Tab',
|
|
11408
|
-
'delete': 'Delete',
|
|
11409
|
-
'esc': 'Escape',
|
|
11410
|
-
'space': ' ',
|
|
11411
|
-
'up': 'ArrowUp',
|
|
11412
|
-
'down': 'ArrowDown',
|
|
11413
|
-
'left': 'ArrowLeft',
|
|
11414
|
-
'right': 'ArrowRight'
|
|
11415
|
-
};
|
|
11416
11428
|
let keyMatched = false;
|
|
11417
|
-
for (const [modifier,
|
|
11418
|
-
if (this.#modifiers.has(modifier) && event.key
|
|
11429
|
+
for (const [modifier, keyValues] of Object.entries(keyMap)) {
|
|
11430
|
+
if (this.#modifiers.has(modifier) && keyValues.includes(event.key)) {
|
|
11419
11431
|
keyMatched = true;
|
|
11420
11432
|
break;
|
|
11421
11433
|
}
|