@iris-ui-kit/vue 0.2.18 → 0.2.19
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/{chunk-VM2CXEUA.js → chunk-RLVG5JQH.js} +4 -4
- package/dist/chunk-RLVG5JQH.js.map +1 -0
- package/dist/index.cjs +23 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/dist/undo.cjs +2 -2
- package/dist/undo.cjs.map +1 -1
- package/dist/undo.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-VM2CXEUA.js.map +0 -1
|
@@ -26,12 +26,12 @@ function useUndoStack(options) {
|
|
|
26
26
|
};
|
|
27
27
|
const undo = () => {
|
|
28
28
|
const result = stack.undo();
|
|
29
|
-
|
|
29
|
+
sync();
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
32
|
const redo = () => {
|
|
33
33
|
const result = stack.redo();
|
|
34
|
-
|
|
34
|
+
sync();
|
|
35
35
|
return result;
|
|
36
36
|
};
|
|
37
37
|
const clear = () => {
|
|
@@ -42,5 +42,5 @@ function useUndoStack(options) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export { useUndoStack };
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-RLVG5JQH.js.map
|
|
46
|
+
//# sourceMappingURL=chunk-RLVG5JQH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/undo/useUndoStack.ts"],"names":[],"mappings":";;;;;AAgCO,SAAS,aAAgB,OAAA,EAa9B;AACA,EAAA,MAAM,KAAA,GAAQ,gBAAmB,OAAO,CAAA;AAExC,EAAA,MAAM,QAAQ,UAAA,CAAmC;AAAA,IAC/C,OAAA,EAAS,MAAM,OAAA,EAAQ;AAAA,IACvB,OAAA,EAAS,MAAM,OAAA,EAAQ;AAAA,IACvB,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,OAAO,KAAA,CAAM;AAAA,GACd,CAAA;AAED,EAAA,MAAM,OAAO,MAAM;AACjB,IAAA,KAAA,CAAM,KAAA,GAAQ;AAAA,MACZ,OAAA,EAAS,MAAM,OAAA,EAAQ;AAAA,MACvB,OAAA,EAAS,MAAM,OAAA,EAAQ;AAAA,MACvB,OAAO,KAAA,CAAM,KAAA;AAAA,MACb,OAAO,KAAA,CAAM;AAAA,KACf;AAAA,EACF,CAAA;AAEA,EAAA,MAAM,IAAA,GAAO,CAAC,QAAA,KAAmB;AAC/B,IAAA,MAAM,MAAA,GAAS,KAAA,CAAM,IAAA,CAAK,QAAQ,CAAA;AAClC,IAAA,IAAA,EAAK;AACL,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AAEA,EAAA,MAAM,OAAO,MAAqB;AAChC,IAAA,MAAM,MAAA,GAAS,MAAM,IAAA,EAAK;AAK1B,IAAA,IAAA,EAAK;AACL,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AAEA,EAAA,MAAM,OAAO,MAAqB;AAChC,IAAA,MAAM,MAAA,GAAS,MAAM,IAAA,EAAK;AAC1B,IAAA,IAAA,EAAK;AACL,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AAEA,EAAA,MAAM,QAAQ,MAAM;AAClB,IAAA,KAAA,CAAM,KAAA,EAAM;AACZ,IAAA,IAAA,EAAK;AAAA,EACP,CAAA;AAEA,EAAA,OAAO,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,KAAA,EAAO,OAAO,KAAA,EAAM;AACjD","file":"chunk-RLVG5JQH.js","sourcesContent":["import { shallowRef, type ShallowRef } from 'vue'\nimport { createUndoStack, type UndoStack, type UndoStackOptions } from '@iris-ui-kit/core/undo'\n\n/**\n * Reactive snapshot metadata for the UndoStack: convenience booleans that\n * update on every push/undo/redo/clear for use in UI bindings (enable/disable\n * undo/redo buttons).\n */\nexport interface UndoStackReactiveState {\n canUndo: boolean\n canRedo: boolean\n depth: number\n index: number\n}\n\n/**\n * Vue bridge over the framework-agnostic {@link createUndoStack}.\n * Creates the stack once in `setup()` and returns a stable controller\n * plus a reactive `state` that tracks `canUndo`/`canRedo`/`depth`/`index` for\n * easy UI binding.\n *\n * The returned `push`/`undo`/`redo`/`clear` automatically update the reactive\n * state — no manual `.value = ...` needed.\n *\n * @example\n * const { push, undo, redo, state } = useUndoStack({ initial: formValues })\n * // After mutation:\n * push(currentValues)\n * // In template:\n * <button :disabled=\"!state.canUndo\" @click=\"undo\">Undo</button>\n * <button :disabled=\"!state.canRedo\" @click=\"redo\">Redo</button>\n */\nexport function useUndoStack<T>(options?: UndoStackOptions<T>): {\n /** Push a new snapshot onto the stack. Returns the stored value. */\n push: (snapshot: T) => T\n /** Undo: returns the previous snapshot, or undefined if nothing to undo. */\n undo: () => T | undefined\n /** Redo: returns the next snapshot, or undefined if nothing to redo. */\n redo: () => T | undefined\n /** Clear all history. */\n clear: () => void\n /** The raw undo stack (stable reference, same across renders). */\n stack: UndoStack<T>\n /** Reactive metadata: canUndo, canRedo, depth, index. */\n state: ShallowRef<UndoStackReactiveState>\n} {\n const stack = createUndoStack<T>(options)\n\n const state = shallowRef<UndoStackReactiveState>({\n canUndo: stack.canUndo(),\n canRedo: stack.canRedo(),\n depth: stack.depth,\n index: stack.index,\n })\n\n const sync = () => {\n state.value = {\n canUndo: stack.canUndo(),\n canRedo: stack.canRedo(),\n depth: stack.depth,\n index: stack.index,\n }\n }\n\n const push = (snapshot: T): T => {\n const result = stack.push(snapshot)\n sync()\n return result\n }\n\n const undo = (): T | undefined => {\n const result = stack.undo()\n // Always sync: `undefined` is a legal snapshot value for a generic T, so\n // the return value cannot distinguish \"no-op\" from \"moved onto an\n // undefined snapshot\". A true no-op writes identical values, which is\n // harmless (same as push/clear).\n sync()\n return result\n }\n\n const redo = (): T | undefined => {\n const result = stack.redo()\n sync()\n return result\n }\n\n const clear = () => {\n stack.clear()\n sync()\n }\n\n return { push, undo, redo, clear, stack, state }\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -3004,12 +3004,12 @@ function useUndoStack(options) {
|
|
|
3004
3004
|
};
|
|
3005
3005
|
const undo$1 = () => {
|
|
3006
3006
|
const result = stack.undo();
|
|
3007
|
-
|
|
3007
|
+
sync();
|
|
3008
3008
|
return result;
|
|
3009
3009
|
};
|
|
3010
3010
|
const redo = () => {
|
|
3011
3011
|
const result = stack.redo();
|
|
3012
|
-
|
|
3012
|
+
sync();
|
|
3013
3013
|
return result;
|
|
3014
3014
|
};
|
|
3015
3015
|
const clear = () => {
|
|
@@ -5388,13 +5388,19 @@ var IrisCombobox = vue.defineComponent({
|
|
|
5388
5388
|
size: { type: String, default: "md" },
|
|
5389
5389
|
/** Text shown when no option matches the query. Defaults to the i18n value. */
|
|
5390
5390
|
emptyText: { type: String, default: void 0 },
|
|
5391
|
+
/** Allow committing free text that matches no option: Enter/blur emits
|
|
5392
|
+
* `commit` with the trimmed query (antd AutoComplete parity). Default
|
|
5393
|
+
* false keeps the option-only contract. */
|
|
5394
|
+
allowCommit: { type: Boolean, default: false },
|
|
5391
5395
|
/** id forwarded to the input. Set by IrisFormField. */
|
|
5392
5396
|
id: { type: String, default: void 0 },
|
|
5393
5397
|
/** Forwarded as `aria-describedby` on the input. Set by IrisFormField. */
|
|
5394
5398
|
ariaDescribedby: { type: String, default: void 0 }
|
|
5395
5399
|
},
|
|
5396
5400
|
emits: {
|
|
5397
|
-
"update:modelValue": (_value) => true
|
|
5401
|
+
"update:modelValue": (_value) => true,
|
|
5402
|
+
/** Free-text commit when `allowCommit` is on and no option is selected. */
|
|
5403
|
+
commit: (_text) => true
|
|
5398
5404
|
},
|
|
5399
5405
|
setup(props, { attrs, emit }) {
|
|
5400
5406
|
const { t } = useI18n();
|
|
@@ -5423,6 +5429,13 @@ var IrisCombobox = vue.defineComponent({
|
|
|
5423
5429
|
query.value = "";
|
|
5424
5430
|
close();
|
|
5425
5431
|
};
|
|
5432
|
+
const commitQuery = () => {
|
|
5433
|
+
const text = query.value.trim();
|
|
5434
|
+
if (!text) return;
|
|
5435
|
+
emit("commit", text);
|
|
5436
|
+
query.value = "";
|
|
5437
|
+
close();
|
|
5438
|
+
};
|
|
5426
5439
|
const onInput = (event) => {
|
|
5427
5440
|
query.value = event.target.value;
|
|
5428
5441
|
filtering.value = true;
|
|
@@ -5448,6 +5461,9 @@ var IrisCombobox = vue.defineComponent({
|
|
|
5448
5461
|
if (open.value && activeIndex.value >= 0 && list[activeIndex.value]) {
|
|
5449
5462
|
event.preventDefault();
|
|
5450
5463
|
selectOption(list[activeIndex.value]);
|
|
5464
|
+
} else if (props.allowCommit) {
|
|
5465
|
+
event.preventDefault();
|
|
5466
|
+
commitQuery();
|
|
5451
5467
|
}
|
|
5452
5468
|
} else if (event.key === "Escape") {
|
|
5453
5469
|
if (open.value) {
|
|
@@ -5519,6 +5535,10 @@ var IrisCombobox = vue.defineComponent({
|
|
|
5519
5535
|
},
|
|
5520
5536
|
onBlur: () => {
|
|
5521
5537
|
focused.value = false;
|
|
5538
|
+
if (props.allowCommit && query.value.trim()) {
|
|
5539
|
+
commitQuery();
|
|
5540
|
+
return;
|
|
5541
|
+
}
|
|
5522
5542
|
close();
|
|
5523
5543
|
},
|
|
5524
5544
|
style: {
|