@stubber/form-fields 1.4.4 → 1.4.6

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,4 +1,10 @@
1
- <script>import { acceptCompletion, CompletionContext } from "@codemirror/autocomplete";
1
+ <script>import {
2
+ acceptCompletion,
3
+ autocompletion,
4
+ CompletionContext,
5
+ completionKeymap,
6
+ startCompletion
7
+ } from "@codemirror/autocomplete";
2
8
  import { javascript, javascriptLanguage } from "@codemirror/lang-javascript";
3
9
  import { EditorState } from "@codemirror/state";
4
10
  import { EditorView, keymap } from "@codemirror/view";
@@ -12,10 +18,21 @@ $: label = $field.spec?.title;
12
18
  $: hide_label = $field.spec?.hide_label;
13
19
  $: isValid = !$field.state?.validation || $field.state?.validation?.valid;
14
20
  $: validationMessage = $field.state?.validation?.message;
15
- const tab_accept_completion = keymap.of([
21
+ const custom_completion_keymap = completionKeymap.filter((binding) => binding.key != "Enter").concat([
22
+ {
23
+ key: "Enter",
24
+ run: () => {
25
+ return false;
26
+ }
27
+ },
16
28
  {
17
29
  key: "Tab",
18
30
  run: acceptCompletion
31
+ },
32
+ {
33
+ key: "Ctrl-Space",
34
+ run: startCompletion,
35
+ stopPropagation: true
19
36
  }
20
37
  ]);
21
38
  function keysFor(obj) {
@@ -61,7 +78,8 @@ function bind_codemirror(el) {
61
78
  basicSetup,
62
79
  javascript(),
63
80
  stubber_completions,
64
- tab_accept_completion,
81
+ autocompletion({ defaultKeymap: false }),
82
+ keymap.of(custom_completion_keymap),
65
83
  min_height_editor,
66
84
  update_listener
67
85
  ]
@@ -49,7 +49,7 @@
49
49
  signaturePad = new SignaturePad(pad);
50
50
  signaturePad.addEventListener("endStroke", handleStroke);
51
51
  setTimeout(() => {
52
- let d = _.isArray($field.data?.base) ? $field.data?.base : [];
52
+ let d = _.isArray($field.data?.base?.data) ? $field.data?.base?.data : [];
53
53
  signaturePad.fromData(d);
54
54
  }, 0);
55
55
 
@@ -91,10 +91,12 @@
91
91
  let upload_res = await form.uploadFiles(null, filesForm);
92
92
  let { uploaded_files } = upload_res;
93
93
  if (uploaded_files?.length) {
94
+ if ($internal.value.file && $internal.value.file.fileuuid) {
95
+ form.removeAttachment($internal.value.file);
96
+ }
97
+
94
98
  $internal.value.file = uploaded_files[0];
95
- uploaded_files.forEach((a) => {
96
- form.appendAttachment(a);
97
- });
99
+ form.appendAttachment(uploaded_files[0]);
98
100
  } else {
99
101
  console.warn("Failed to upload file");
100
102
  }
@@ -102,6 +104,8 @@
102
104
  return true;
103
105
  }
104
106
 
107
+ const debounced_upload = _.debounce(uploadFile, 1000);
108
+
105
109
  function clear() {
106
110
  signaturePad.clear();
107
111
  $field.data.base = {
@@ -117,7 +121,7 @@
117
121
 
118
122
  if (!deepEqual(comparison, $internal)) {
119
123
  $internal = comparison;
120
- uploadFile();
124
+ debounced_upload();
121
125
  }
122
126
  }
123
127
 
@@ -1,27 +1,26 @@
1
1
  <script>
2
2
  import { syncStoreToStore } from "../../utils/syncing";
3
- import { deepEqual } from "fast-equals";
4
- import _ from "lodash-es";
5
- import { onMount, onDestroy } from "svelte";
6
- import { writable } from "svelte/store";
7
- import {
8
- EditorView,
9
- placeholder,
10
- MatchDecorator,
11
- Decoration,
12
- ViewPlugin,
13
- keymap,
14
- } from "@codemirror/view";
15
- import { EditorState, StateField } from "@codemirror/state";
16
- import { history, defaultKeymap, historyKeymap } from "@codemirror/commands";
17
3
  import {
18
4
  acceptCompletion,
19
5
  autocompletion,
20
6
  completionKeymap,
21
7
  startCompletion,
22
8
  } from "@codemirror/autocomplete";
9
+ import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
10
+ import { EditorState, StateField } from "@codemirror/state";
11
+ import {
12
+ Decoration,
13
+ EditorView,
14
+ MatchDecorator,
15
+ ViewPlugin,
16
+ keymap,
17
+ placeholder,
18
+ } from "@codemirror/view";
19
+ import { deepEqual } from "fast-equals";
20
+ import _ from "lodash-es";
21
+ import { onDestroy, onMount } from "svelte";
22
+ import { writable } from "svelte/store";
23
23
 
24
- import { Input } from "@stubber/ui/input";
25
24
  import { Label } from "@stubber/ui/label";
26
25
 
27
26
  export let field;
@@ -232,9 +231,7 @@
232
231
  },
233
232
  {
234
233
  key: "Ctrl-Space",
235
- run: (view) => {
236
- startCompletion(view);
237
- },
234
+ run: startCompletion,
238
235
  stopPropagation: true,
239
236
  },
240
237
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stubber/form-fields",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "An automatic form builder based on field specifications",
5
5
  "keywords": [
6
6
  "components",