@stubber/form-fields 2.0.2 → 2.0.4

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,7 +1,6 @@
1
1
  <script>import { getContext } from "svelte";
2
2
  export let fieldStore;
3
3
  const field_component_store = getContext("field_component");
4
- const show_toggle = getContext("show_field_expr_toggle") ?? false;
5
4
  $: selected_fieldtype = $field_component_store.fieldtype;
6
5
  $: is_true_field = $fieldStore.fieldtype === selected_fieldtype;
7
6
  const handle_fieldtype_click = (ft) => {
@@ -9,7 +8,7 @@ const handle_fieldtype_click = (ft) => {
9
8
  };
10
9
  </script>
11
10
 
12
- {#if show_toggle || !is_true_field}
11
+ {#if !is_true_field}
13
12
  <div
14
13
  class="ml-auto flex h-fit w-fit flex-row items-center gap-0.5 rounded bg-gray-300 p-0.5 text-xs"
15
14
  >
@@ -8,8 +8,8 @@ export let form;
8
8
  export let attachments = writable([]);
9
9
  export let dependencies = void 0;
10
10
  export let form_valid = false;
11
- export let show_field_expr_toggle = false;
12
- setContext("show_field_expr_toggle", show_field_expr_toggle);
11
+ export let dynamic_field_type = false;
12
+ setContext("dynamic_field_type", dynamic_field_type);
13
13
  if (initial_form.data) {
14
14
  form.update((data) => {
15
15
  return { ...data, ...initial_form.data };
@@ -9,7 +9,7 @@ declare const __propDef: {
9
9
  attachments?: Writable<UploadedFile[]>;
10
10
  dependencies?: IFormDependencies | undefined;
11
11
  form_valid?: boolean;
12
- show_field_expr_toggle?: boolean;
12
+ dynamic_field_type?: boolean;
13
13
  };
14
14
  events: {
15
15
  [evt: string]: CustomEvent<any>;
@@ -1,9 +1,10 @@
1
1
  <script>import { get, set } from "lodash-es";
2
- import { setContext } from "svelte";
2
+ import { getContext, setContext } from "svelte";
3
3
  import { writable } from "svelte/store";
4
4
  import { component_for, final_field_type } from "./interfaces";
5
5
  export let fieldStore;
6
- let fieldtype = final_field_type($fieldStore, true);
6
+ const dynamic_field_type = getContext("dynamic_field_type") ?? false;
7
+ let fieldtype = final_field_type($fieldStore, dynamic_field_type);
7
8
  let component = component_for(fieldtype);
8
9
  const field_component_store = writable({ fieldtype });
9
10
  setContext("field_component", field_component_store);
@@ -76,7 +76,16 @@ export const fields = {
76
76
  screenrecorder: ScreenrecorderField,
77
77
  code: CodeField,
78
78
  };
79
- const string_fields = ["text", "email", "telephone", "smart_text", "note", "code"];
79
+ const string_fields = [
80
+ "text",
81
+ "email",
82
+ "telephone",
83
+ "smart_text",
84
+ "note",
85
+ "code",
86
+ "date",
87
+ "datetime",
88
+ ];
80
89
  export const final_field_type = (f, allow_dynamic_switching) => {
81
90
  if (!allow_dynamic_switching) {
82
91
  return f.fieldtype;
@@ -44,11 +44,9 @@ const load_options = async (search_term) => {
44
44
  if (details.params.limit === void 0) {
45
45
  details.params.limit = 50;
46
46
  }
47
- console.log("Loading contacts with details:", details);
48
47
  return new Promise((resolve, reject) => {
49
48
  socket.emit("request", { type: "resource", details }, (res) => {
50
49
  if (res.success) {
51
- console.log("Contacts loaded:", res);
52
50
  const contacts = res.payload?.contacts || [];
53
51
  const result = contacts.map((contact) => {
54
52
  let label = contact._default_label;
@@ -74,7 +72,7 @@ const load_options = async (search_term) => {
74
72
  <Button
75
73
  on:click={show_create_contact_modal}
76
74
  variant="ghost"
77
- class="ml-auto text-surface-500 text-sm hover:text-surface-700"
75
+ class="ml-auto text-sm text-surface-500 hover:text-surface-700"
78
76
  >
79
77
  <i class="fa-regular fa-plus" />
80
78
  Create new contact
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stubber/form-fields",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "An automatic form builder based on field specifications",
5
5
  "keywords": [
6
6
  "components",