eco-vue-js 0.11.34 → 0.11.36

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.
@@ -1 +1 @@
1
- {"version":3,"file":"WInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Input/WInput.vue"],"names":[],"mappings":"AA2PA;AA2iBA,OAAO,KAAK,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,SAAS,CAAA;AAatD,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,gBAAgB,CAAA;yBAE9B,IAAI,SAAS,SAAS,GAAG,MAAM,EAC/C,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,eAAe,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EACjE;WAqyBO,mBAAmB,CAAC,oCAAkE,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB;qBA3mB7B,IAAI;oBAOL,IAAI;+BAkCS,aAAa;0BA1KlB,MAAM,QAAQ,MAAM,KAAG,IAAI;wBAN/B,WAAW;;;oBAyBf,IAAI;oBAgBJ,IAAI;MAysBgD,GAAG,IAAI;WACpE,GAAG;;uBAhEgB,GAAG;0BACA,GAAG;wBACJ,GAAG;;;YAGH,GAAG;;;YAFH,GAAG;;;YAGH,GAAG;;mCAzgBF,aAAa;YAugBb,GAAG;uBAGL,GAAG;;;;YACF,GAAG;uBACJ,GAAG;uBACH,GAAG;wBACF,GAAG;;;YAxtB1B,oBAAoB,SAAS,4CAAa,SAAS,GAAG,IAAI;YAC1D,gBAAgB,SAAS,aAAa,GAAG,IAAI;YAC7C,aAAa,SAAS,aAAa,GAAG,IAAI;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,KAAK,EAAE,gBAAgB;qBA7nB7B,IAAI;oBAOL,IAAI;+BAyDS,aAAa;0BA7MlB,MAAM,QAAQ,MAAM,KAAG,IAAI;wBAN/B,WAAW;;;oBAqCf,IAAI;oBAgBJ,IAAI;MA2tBgD,GAAG,IAAI;WACpE,GAAG;;uBAjEgB,GAAG;0BACA,GAAG;wBACJ,GAAG;;;YAGH,GAAG;;;YAFH,GAAG;;;YAGH,GAAG;;mCAngBF,aAAa;YAigBb,GAAG;uBAGL,GAAG;;;;YACF,GAAG;uBACJ,GAAG;uBACH,GAAG;wBACF,GAAG;;;YArvB1B,oBAAoB,SAAS,4CAAa,SAAS,GAAG,IAAI;YAC1D,gBAAgB,SAAS,aAAa,GAAG,IAAI;YAC7C,aAAa,SAAS,aAAa,GAAG,IAAI;YAC1C,eAAe,SAAS,aAAa,GAAG,IAAI;YAC5C,iBAAiB,SAAS,aAAa,GAAG,IAAI;YAC9C,oBAAoB,SAAS,aAAa,GAAG,IAAI;YACjD,aAAa,GAAG,IAAI;YACpB,OAAO,SAAS,UAAU,GAAG,SAAS,GAAG,IAAI;YAC7C,MAAM,SAAS,UAAU,GAAG,IAAI;YAChC,OAAO,SAAS,UAAU,GAAG,IAAI;YACjC,WAAW,SAAS,UAAU,GAAG,IAAI;YACrC,cAAc,SAAS,KAAK,GAAG,IAAI;YACnC,OAAO,GAAG,IAAI;;EAmyBhB,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AA90BzE,wBA80B4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -85,9 +85,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
85
85
  const setCaret = (start, end) => {
86
86
  if (!inputRef.value) return;
87
87
  if ("setCaret" in inputRef.value) inputRef.value.setCaret(start, end);
88
- else inputRef.value.setSelectionRange(start, end ?? null);
88
+ else inputRef.value.setSelectionRange(start, end ?? start);
89
89
  };
90
- const addToHistory = debounce((value) => {
90
+ const addToHistory = (value, noDebounce) => {
91
+ if (history.value.length === 0) {
92
+ history.value.push({ value: props.modelValue, caret: getCaret() });
93
+ historyPosition.value = 0;
94
+ }
95
+ if (noDebounce) nextTick(() => addToHistoryFn(value));
96
+ else addToHistoryDebounced(value);
97
+ };
98
+ const addToHistoryFn = (value) => {
91
99
  const entry = { value, caret: getCaret() };
92
100
  if (historyPosition.value < history.value.length - 1) history.value = history.value.slice(0, historyPosition.value + 1);
93
101
  history.value.push(entry);
@@ -96,7 +104,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
96
104
  history.value.shift();
97
105
  historyPosition.value--;
98
106
  }
99
- }, 500);
107
+ };
108
+ const addToHistoryDebounced = debounce(addToHistoryFn, 500);
100
109
  const undo = () => {
101
110
  if (props.loading || isDisabled.value || isReadonly.value || props.unclickable || props.textSecure) return;
102
111
  if (historyPosition.value <= 0) {
@@ -133,12 +142,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
133
142
  if (event.shiftKey) redo();
134
143
  else undo();
135
144
  };
136
- const updateModelValue = (value) => {
145
+ const updateModelValue = (value, noDebounce = false) => {
137
146
  if (props.loading || isDisabled.value || isReadonly.value || props.unclickable) return;
138
147
  let newValue;
139
148
  if (props.type === "number") newValue = typeof value === "string" && value.length ? Number.parseFloat(value) : void 0;
140
149
  else newValue = value;
141
- if (!props.textSecure) addToHistory(newValue);
150
+ if (!props.textSecure) addToHistory(newValue, noDebounce);
142
151
  emit("update:model-value", newValue);
143
152
  };
144
153
  const handleBackspace = (event) => {
@@ -176,8 +185,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
176
185
  };
177
186
  const clearValue = () => {
178
187
  if (isDisabled.value || isReadonly.value || props.unclickable) return;
179
- if (typeof props.modelValue === "string") updateModelValue("");
180
- else updateModelValue(void 0);
188
+ if (typeof props.modelValue === "string") updateModelValue("", true);
189
+ else updateModelValue(void 0, true);
181
190
  inputRef.value?.focus();
182
191
  emit("click:clear");
183
192
  };
@@ -187,14 +196,30 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
187
196
  else inputRef.value?.focus();
188
197
  };
189
198
  const blur = () => inputRef.value?.blur();
199
+ const onPaste = async (e) => {
200
+ if (props.loading || isDisabled.value || isReadonly.value || props.unclickable) return;
201
+ navigator.clipboard.readText();
202
+ const text = (e.clipboardData?.getData("text/plain") || await navigator.clipboard.readText()).replace(/\r\n?/g, "\n");
203
+ if (!text) {
204
+ fieldWrapperRef.value?.showMessage("Nothing to paste");
205
+ return;
206
+ }
207
+ const caret = getCaret();
208
+ const value = props.modelValue?.toString() ?? "";
209
+ const newValue = value.slice(0, caret.start) + text + value.slice(caret.end);
210
+ updateModelValue(newValue, true);
211
+ await nextTick();
212
+ setCaret(Math.min(caret.start + text.length, props.modelValue?.toString().length ?? 0));
213
+ };
190
214
  const paste = async () => {
215
+ if (props.loading || isDisabled.value || isReadonly.value || props.unclickable) return;
191
216
  try {
192
217
  await checkPermissionPaste();
193
218
  await navigator.clipboard.readText().then((value) => {
194
219
  if (!value) {
195
220
  Notify.warn({ title: "Nothing to paste" });
196
221
  } else if (!props.maxLength || props.maxLength <= value.length) {
197
- updateModelValue(value);
222
+ updateModelValue(value, true);
198
223
  Notify.success({ title: "Pasted" });
199
224
  nextTick().then(() => emit("paste"));
200
225
  } else Notify.error({
@@ -232,17 +257,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
232
257
  if (value === false || value === void 0) return;
233
258
  nextTick(autofocusDebounced);
234
259
  });
235
- const handle = watch(() => props.modelValue, (value) => {
236
- if (history.value.length === 0) {
237
- if (value) {
238
- addToHistory(value);
239
- handle.stop();
240
- }
241
- } else handle.stop();
242
- });
243
260
  onMounted(() => {
244
261
  if (props.autofocus !== false && props.autofocus !== void 0) autofocusDebounced();
245
- if (props.modelValue) addToHistory(props.modelValue);
246
262
  });
247
263
  onBeforeUnmount(() => {
248
264
  if (timeout) {
@@ -429,7 +445,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
429
445
  onClick: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("click", $event)),
430
446
  onMousedown: _cache[5] || (_cache[5] = withModifiers(($event) => _ctx.$emit("mousedown", $event), ["stop"])),
431
447
  onSelect: _cache[6] || (_cache[6] = withModifiers(($event) => _ctx.$emit("select:input", $event), ["stop"])),
432
- "onUpdate:modelValue": updateModelValue
448
+ "onUpdate:modelValue": updateModelValue,
449
+ onPaste: withModifiers(onPaste, ["prevent"])
433
450
  }, null, 40, ["id", "class", "value", "placeholder", "type", "name", "disabled", "readonly", "autocomplete", "size", "step", "min", "max", "spellcheck", "max-length", "text-parts", "onFocus", "onBlur"])),
434
451
  renderSlot(_ctx.$slots, "after")
435
452
  ])
@@ -20,12 +20,12 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
20
20
  blur: (value: FocusEvent) => any;
21
21
  focus: (value: FocusEvent) => any;
22
22
  keydown: (value: KeyboardEvent) => any;
23
- "update:model-value": (value: string) => any;
23
+ "update:model-value": (value: string, noDebounce?: boolean | undefined) => any;
24
24
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
25
25
  onBlur?: ((value: FocusEvent) => any) | undefined;
26
26
  onFocus?: ((value: FocusEvent) => any) | undefined;
27
27
  onKeydown?: ((value: KeyboardEvent) => any) | undefined;
28
- "onUpdate:model-value"?: ((value: string) => any) | undefined;
28
+ "onUpdate:model-value"?: ((value: string, noDebounce?: boolean | undefined) => any) | undefined;
29
29
  }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
30
30
  element: HTMLDivElement;
31
31
  }, HTMLDivElement>;
@@ -1 +1 @@
1
- {"version":3,"file":"ContentEditable.vue.d.ts","sourceRoot":"","sources":["../../../../../src/components/Input/components/ContentEditable.vue"],"names":[],"mappings":"AAiBA;AA0UA,OAAO,KAAK,EAAC,QAAQ,EAAG,aAAa,EAAC,MAAM,UAAU,CAAA;AAStD,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAA;IACjC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B,CAAC;;;;2BAqK4B,aAAa,KAAG,IAAI;2BATpB,MAAM,aAAa,MAAM;;;;;;;;;;;;;;;;;;AAsNvD,wBAUG"}
1
+ {"version":3,"file":"ContentEditable.vue.d.ts","sourceRoot":"","sources":["../../../../../src/components/Input/components/ContentEditable.vue"],"names":[],"mappings":"AAiBA;AAwUA,OAAO,KAAK,EAAC,QAAQ,EAAG,aAAa,EAAC,MAAM,UAAU,CAAA;AAStD,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAA;IACjC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B,CAAC;;;;2BAmK4B,aAAa,KAAG,IAAI;2BATpB,MAAM,aAAa,MAAM;;;;;;;;;;;;;;;;;;AAsNvD,wBAUG"}
@@ -1,4 +1,4 @@
1
- import { defineComponent, useTemplateRef, ref, watch, onMounted, createElementBlock, openBlock, nextTick } from 'vue';
1
+ import { defineComponent, useTemplateRef, ref, watch, onMounted, createElementBlock, openBlock, withModifiers, nextTick } from 'vue';
2
2
  import { WrapSelectionType } from '../../../utils/utils.js';
3
3
  import { preserveIndentation } from '../models/toolbarActions.js';
4
4
  import { getCaretOffset, setCaretOffset } from '../models/utils.js';
@@ -104,7 +104,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
104
104
  }
105
105
  };
106
106
  const onPaste = async (e) => {
107
- e.preventDefault();
108
107
  navigator.clipboard.readText();
109
108
  const text = (e.clipboardData?.getData("text/plain") || await navigator.clipboard.readText()).replace(/\r\n?/g, "\n");
110
109
  insertPlain(text);
@@ -116,7 +115,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
116
115
  const currentText = getCurrentText();
117
116
  const next = (currentText ?? "").slice(0, start) + " ".repeat(trail) + text + ((currentText ?? "").slice(end) || " ");
118
117
  const caretAfter = start + text.length + trail;
119
- emit("update:model-value", props.maxLength && next.length > props.maxLength ? next.substring(0, props.maxLength) : next);
118
+ emit("update:model-value", props.maxLength && next.length > props.maxLength ? next.substring(0, props.maxLength) : next, true);
120
119
  nextTick(() => setCaret(props.maxLength ? Math.min(caretAfter, props.maxLength) : caretAfter));
121
120
  };
122
121
  const getCaret = () => getCaretOffset(elementRef.value);
@@ -212,7 +211,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
212
211
  break;
213
212
  }
214
213
  isSetCaretNext = true;
215
- emit("update:model-value", newText);
214
+ emit("update:model-value", newText, true);
216
215
  requestAnimationFrame(() => setCaret(newCursorStart, newCursorEnd));
217
216
  };
218
217
  const focus = () => {
@@ -246,7 +245,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
246
245
  class: "relative whitespace-pre",
247
246
  onInput,
248
247
  onBeforeinput: _cache[0] || (_cache[0] = ($event) => insertParagraph($event)),
249
- onPaste,
248
+ onPaste: withModifiers(onPaste, ["prevent"]),
250
249
  onKeydown: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("keydown", $event)),
251
250
  onFocus: _cache[2] || (_cache[2] = ($event) => {
252
251
  _ctx.$emit("focus", $event);
@@ -16,7 +16,7 @@ const HEADERS_FORMDATA = {
16
16
  class ApiClientInstance {
17
17
  constructor(config) {
18
18
  this.config = config;
19
- window.addEventListener("storage", this.checkAuth);
19
+ if (typeof window !== "undefined") window.addEventListener("storage", this.checkAuth);
20
20
  this.useAuth = () => {
21
21
  return this.auth;
22
22
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/rsmple/eco-vue-js.git"
6
6
  },
7
- "version": "0.11.34",
7
+ "version": "0.11.36",
8
8
  "dependencies": {
9
9
  "@stylistic/eslint-plugin": "5.2.3",
10
10
  "@tanstack/eslint-plugin-query": "5.83.1",