@stubber/form-fields 1.7.6 → 1.7.8

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.
@@ -43,10 +43,10 @@ export let fieldStore;
43
43
  function onInput(e) {
44
44
  const new_value = e.target.value;
45
45
  let parsedValue = parseFloat(new_value);
46
- if (!isNaN(parsedValue)) {
46
+ if (!isNaN(parsedValue) && parsedValue.toString() === new_value) {
47
47
  $fieldStore.value = parsedValue;
48
48
  } else {
49
- $fieldStore.value = void 0;
49
+ $fieldStore.value = new_value;
50
50
  }
51
51
  }
52
52
  function onBlur() {
@@ -68,10 +68,10 @@ function onBlur() {
68
68
 
69
69
  <FieldLabel {fieldStore} />
70
70
  <Input
71
+ id={$fieldStore.id}
71
72
  value={$fieldStore.value}
72
73
  on:input={onInput}
73
74
  on:blur={onBlur}
74
- type="number"
75
75
  aria-invalid={$fieldStore.validation_result?.type == "error" ? true : undefined}
76
76
  />
77
77
  <FieldMessage {fieldStore} />
@@ -4,11 +4,19 @@ export const smart_text_field_param_spec = {
4
4
  fields: {
5
5
  parse_string: {
6
6
  fieldtype: "checkbox",
7
- without_value_details: true
7
+ without_value_details: true,
8
+ initvalue: {
9
+ has_default: true,
10
+ default: true
11
+ }
8
12
  },
9
13
  code_language: {
10
14
  fieldtype: "select",
11
15
  without_value_details: true,
16
+ initvalue: {
17
+ has_default: true,
18
+ default: "handlebars"
19
+ },
12
20
  params: {
13
21
  options: [
14
22
  { label: "Handlebars", value: "handlebars" },
@@ -77,7 +85,7 @@ $: type = validation_result?.type;
77
85
  $: isValid = type !== "error";
78
86
  $: is_object = typeof $fieldStore.value === "object";
79
87
  const smart_text_fields_ctx_store = getContext("smart_text_fields_ctx");
80
- $: parse_string = $fieldStore.params?.parse_string;
88
+ $: parse_string = $fieldStore.params?.parse_string ?? true;
81
89
  $: code_language = $fieldStore.params?.code_language || "handlebars";
82
90
  const setup_editor = (element) => {
83
91
  const extensions = [
@@ -94,9 +102,10 @@ const setup_editor = (element) => {
94
102
  if (code_language === "handlebars") {
95
103
  extensions.push(fake_handlebars_lang());
96
104
  }
105
+ const str_value = $fieldStore?.value?.toString() ?? "";
97
106
  editor_view = new EditorView({
98
107
  state: EditorState.create({
99
- doc: $fieldStore.value,
108
+ doc: str_value,
100
109
  extensions
101
110
  }),
102
111
  parent: element
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stubber/form-fields",
3
- "version": "1.7.6",
3
+ "version": "1.7.8",
4
4
  "description": "An automatic form builder based on field specifications",
5
5
  "keywords": [
6
6
  "components",