@stubber/form-fields 1.4.5 → 1.5.0

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.
Files changed (97) hide show
  1. package/README.md +61 -295
  2. package/dist/fields/components/Signature.svelte +9 -5
  3. package/dist/fields2/FieldLabel.svelte +8 -0
  4. package/dist/fields2/FieldLabel.svelte.d.ts +20 -0
  5. package/dist/fields2/FieldMessage.svelte +16 -0
  6. package/dist/fields2/FieldMessage.svelte.d.ts +20 -0
  7. package/dist/fields2/Form.svelte +29 -0
  8. package/dist/fields2/Form.svelte.d.ts +23 -0
  9. package/dist/fields2/fileserver.d.ts +15 -0
  10. package/dist/fields2/fileserver.js +52 -0
  11. package/dist/fields2/form-field.svelte +10 -0
  12. package/dist/fields2/form-field.svelte.d.ts +20 -0
  13. package/dist/fields2/interfaces.d.ts +207 -0
  14. package/dist/fields2/interfaces.js +82 -0
  15. package/dist/fields2/sub/array-builder-field.svelte +110 -0
  16. package/dist/fields2/sub/array-builder-field.svelte.d.ts +27 -0
  17. package/dist/fields2/sub/checkbox-autocomplete.svelte +56 -0
  18. package/dist/fields2/sub/checkbox-autocomplete.svelte.d.ts +27 -0
  19. package/dist/fields2/sub/checkbox-field.svelte +41 -0
  20. package/dist/fields2/sub/checkbox-field.svelte.d.ts +28 -0
  21. package/dist/fields2/sub/code-field.svelte +146 -0
  22. package/dist/fields2/sub/code-field.svelte.d.ts +27 -0
  23. package/dist/fields2/sub/contact-selector-field.svelte +84 -0
  24. package/dist/fields2/sub/contact-selector-field.svelte.d.ts +30 -0
  25. package/dist/fields2/sub/currency-field.svelte +197 -0
  26. package/dist/fields2/sub/currency-field.svelte.d.ts +29 -0
  27. package/dist/fields2/sub/data-indication-field.svelte +19 -0
  28. package/dist/fields2/sub/data-indication-field.svelte.d.ts +23 -0
  29. package/dist/fields2/sub/date-field.svelte +31 -0
  30. package/dist/fields2/sub/date-field.svelte.d.ts +23 -0
  31. package/dist/fields2/sub/date-time-field.svelte +31 -0
  32. package/dist/fields2/sub/date-time-field.svelte.d.ts +23 -0
  33. package/dist/fields2/sub/email-field.svelte +40 -0
  34. package/dist/fields2/sub/email-field.svelte.d.ts +23 -0
  35. package/dist/fields2/sub/field-builder-field.svelte +525 -0
  36. package/dist/fields2/sub/field-builder-field.svelte.d.ts +23 -0
  37. package/dist/fields2/sub/file-field.svelte +150 -0
  38. package/dist/fields2/sub/file-field.svelte.d.ts +27 -0
  39. package/dist/fields2/sub/grid-field.svelte +54 -0
  40. package/dist/fields2/sub/grid-field.svelte.d.ts +30 -0
  41. package/dist/fields2/sub/heading-field.svelte +28 -0
  42. package/dist/fields2/sub/heading-field.svelte.d.ts +28 -0
  43. package/dist/fields2/sub/hidden-field.svelte +142 -0
  44. package/dist/fields2/sub/hidden-field.svelte.d.ts +37 -0
  45. package/dist/fields2/sub/hidden-location-field.svelte +23 -0
  46. package/dist/fields2/sub/hidden-location-field.svelte.d.ts +23 -0
  47. package/dist/fields2/sub/html-field.svelte +22 -0
  48. package/dist/fields2/sub/html-field.svelte.d.ts +27 -0
  49. package/dist/fields2/sub/json-editor-bound.svelte +17 -0
  50. package/dist/fields2/sub/json-editor-bound.svelte.d.ts +65 -0
  51. package/dist/fields2/sub/jsoneditor-field.svelte +23 -0
  52. package/dist/fields2/sub/jsoneditor-field.svelte.d.ts +27 -0
  53. package/dist/fields2/sub/map-field.svelte +144 -0
  54. package/dist/fields2/sub/map-field.svelte.d.ts +28 -0
  55. package/dist/fields2/sub/multi-checkbox-field.svelte +83 -0
  56. package/dist/fields2/sub/multi-checkbox-field.svelte.d.ts +34 -0
  57. package/dist/fields2/sub/multistep-field.svelte +70 -0
  58. package/dist/fields2/sub/multistep-field.svelte.d.ts +24 -0
  59. package/dist/fields2/sub/note-field.svelte +18 -0
  60. package/dist/fields2/sub/note-field.svelte.d.ts +23 -0
  61. package/dist/fields2/sub/number-field.svelte +77 -0
  62. package/dist/fields2/sub/number-field.svelte.d.ts +29 -0
  63. package/dist/fields2/sub/object-builder-field.svelte +123 -0
  64. package/dist/fields2/sub/object-builder-field.svelte.d.ts +28 -0
  65. package/dist/fields2/sub/qr-code-scanner-field.svelte +86 -0
  66. package/dist/fields2/sub/qr-code-scanner-field.svelte.d.ts +23 -0
  67. package/dist/fields2/sub/radio-field.svelte +69 -0
  68. package/dist/fields2/sub/radio-field.svelte.d.ts +30 -0
  69. package/dist/fields2/sub/screenrecorder-field.svelte +182 -0
  70. package/dist/fields2/sub/screenrecorder-field.svelte.d.ts +27 -0
  71. package/dist/fields2/sub/screenshot-field.svelte +165 -0
  72. package/dist/fields2/sub/screenshot-field.svelte.d.ts +26 -0
  73. package/dist/fields2/sub/scroll-and-read-display-field.svelte +92 -0
  74. package/dist/fields2/sub/scroll-and-read-display-field.svelte.d.ts +29 -0
  75. package/dist/fields2/sub/section-field.svelte +27 -0
  76. package/dist/fields2/sub/section-field.svelte.d.ts +26 -0
  77. package/dist/fields2/sub/select-field.svelte +138 -0
  78. package/dist/fields2/sub/select-field.svelte.d.ts +34 -0
  79. package/dist/fields2/sub/selectresource-field.svelte +69 -0
  80. package/dist/fields2/sub/selectresource-field.svelte.d.ts +29 -0
  81. package/dist/fields2/sub/signature-field.svelte +84 -0
  82. package/dist/fields2/sub/signature-field.svelte.d.ts +23 -0
  83. package/dist/fields2/sub/slider-field.svelte +28 -0
  84. package/dist/fields2/sub/slider-field.svelte.d.ts +28 -0
  85. package/dist/fields2/sub/smart-text-field.svelte +245 -0
  86. package/dist/fields2/sub/smart-text-field.svelte.d.ts +36 -0
  87. package/dist/fields2/sub/telephone-field.svelte +68 -0
  88. package/dist/fields2/sub/telephone-field.svelte.d.ts +26 -0
  89. package/dist/fields2/sub/text-field.svelte +46 -0
  90. package/dist/fields2/sub/text-field.svelte.d.ts +27 -0
  91. package/dist/fields2/sub/voicenote-field.svelte +161 -0
  92. package/dist/fields2/sub/voicenote-field.svelte.d.ts +26 -0
  93. package/dist/fields2/utils.d.ts +9 -0
  94. package/dist/fields2/utils.js +116 -0
  95. package/dist/fields2/validations/validate_field.d.ts +11 -0
  96. package/dist/fields2/validations/validate_field.js +121 -0
  97. package/package.json +6 -9
@@ -0,0 +1,23 @@
1
+ <script context="module">import {} from "../interfaces";
2
+ export const jsoneditor_field_param_spec = {
3
+ spec: {
4
+ fields: {
5
+ readOnly: {
6
+ fieldtype: "checkbox",
7
+ without_value_details: true
8
+ }
9
+ }
10
+ }
11
+ };
12
+ </script>
13
+
14
+ <script>import FieldLabel from "../FieldLabel.svelte";
15
+ import FieldMessage from "../FieldMessage.svelte";
16
+ import JsonEditorBound from "./json-editor-bound.svelte";
17
+ export let fieldStore;
18
+ let read_only = $fieldStore.params?.readOnly ?? false;
19
+ </script>
20
+
21
+ <FieldLabel {fieldStore} />
22
+ <JsonEditorBound bind:value={$fieldStore.value} readOnly={read_only} />
23
+ <FieldMessage {fieldStore} />
@@ -0,0 +1,27 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Writable } from "svelte/store";
3
+ import { type IBaseField, type IBuiltField, type IInitialForm } from "../interfaces";
4
+ export interface IJSONEditorFieldParams {
5
+ readOnly?: boolean;
6
+ }
7
+ export declare const jsoneditor_field_param_spec: IInitialForm;
8
+ export interface IJSONEditorField extends IBaseField<IJSONEditorFieldParams> {
9
+ fieldtype: "jsoneditor";
10
+ }
11
+ declare const __propDef: {
12
+ props: {
13
+ fieldStore: Writable<IBuiltField<IJSONEditorFieldParams>>;
14
+ };
15
+ events: {
16
+ [evt: string]: CustomEvent<any>;
17
+ };
18
+ slots: {};
19
+ exports?: {} | undefined;
20
+ bindings?: string | undefined;
21
+ };
22
+ export type JsoneditorFieldProps = typeof __propDef.props;
23
+ export type JsoneditorFieldEvents = typeof __propDef.events;
24
+ export type JsoneditorFieldSlots = typeof __propDef.slots;
25
+ export default class JsoneditorField extends SvelteComponent<JsoneditorFieldProps, JsoneditorFieldEvents, JsoneditorFieldSlots> {
26
+ }
27
+ export {};
@@ -0,0 +1,144 @@
1
+ <script context="module">import { onMount } from "svelte";
2
+ import FieldMessage from "../FieldMessage.svelte";
3
+ import {} from "../interfaces";
4
+ export const map_field_param_spec = {
5
+ spec: {
6
+ fields: {
7
+ hide_geolocate_button: {
8
+ fieldtype: "checkbox"
9
+ },
10
+ auto_set_location: {
11
+ fieldtype: "checkbox"
12
+ }
13
+ }
14
+ }
15
+ };
16
+ </script>
17
+
18
+ <script>import { controls, Geocoder, Map, Marker } from "@beyonk/svelte-mapbox";
19
+ import FieldLabel from "../FieldLabel.svelte";
20
+ const { GeolocateControl } = controls;
21
+ export let fieldStore;
22
+ const initial_value = $fieldStore.value;
23
+ let params = $fieldStore.params;
24
+ let hide_geolocate_button = params?.hide_geolocate_button || false;
25
+ let auto_set_location = params?.auto_set_location || false;
26
+ let dependencies = $fieldStore?.formDependencies;
27
+ let mapboxAccessToken = dependencies?.map?.mapboxAccessToken;
28
+ let mapboxStylesheetUrl = dependencies?.map?.mapboxStylesheetUrl;
29
+ let mapComponent;
30
+ let geocoder = void 0;
31
+ let center = [
32
+ $fieldStore.value?.lng || 18.5,
33
+ $fieldStore.value?.lat || -34
34
+ ];
35
+ let browserLocation;
36
+ onMount(() => {
37
+ if (auto_set_location) {
38
+ navigator.geolocation.getCurrentPosition(setCurrentPosition);
39
+ } else {
40
+ resetValues();
41
+ }
42
+ });
43
+ function setCurrentPosition(o) {
44
+ let { latitude, longitude } = o?.coords || {};
45
+ if (!latitude || !longitude) return;
46
+ browserLocation = {
47
+ lat: latitude,
48
+ lng: longitude
49
+ };
50
+ setValueCoords(latitude, longitude);
51
+ center = [longitude, latitude];
52
+ mapComponent?.flyTo({ center });
53
+ }
54
+ function setValueCoords(lat, lng, force = false) {
55
+ if (lat && lng || force) {
56
+ $fieldStore.value = {
57
+ lat: lat ?? null,
58
+ lng: lng ?? null,
59
+ latlng: `${lat ?? null},${lng ?? null}`
60
+ };
61
+ }
62
+ }
63
+ function resetValues() {
64
+ center = [initial_value?.lng ?? 18.5, initial_value?.lat ?? -34];
65
+ setValueCoords(initial_value?.lat, initial_value?.lng, true);
66
+ mapComponent?.flyTo({ center });
67
+ }
68
+ function handle_map_click(e) {
69
+ setValueCoords(e?.detail?.lat, e?.detail?.lng);
70
+ }
71
+ function handle_geocoder_result(r) {
72
+ const geo_center = r?.detail?.result?.center || [];
73
+ if (geo_center.length === 2) {
74
+ center = [geo_center[0], geo_center[1]];
75
+ mapComponent?.flyTo({ center });
76
+ }
77
+ }
78
+ function handle_geolocate(o) {
79
+ const coords = o?.detail?.coords || {};
80
+ setValueCoords(coords.latitude, coords.longitude);
81
+ }
82
+ </script>
83
+
84
+ <FieldLabel {fieldStore} />
85
+ {#if mapboxAccessToken}
86
+ <div class="flex flex-col w-full">
87
+ <div>
88
+ <button
89
+ type="button"
90
+ on:click={resetValues}
91
+ class="text-sm text-surface-300 hover:underline hover:text-surface-500"
92
+ >
93
+ <i class="fa-regular fa-undo" /> Reset
94
+ </button>
95
+ </div>
96
+ <div class="relative mt-2 rounded-md">
97
+ <div class="w-full h-72">
98
+ <Map
99
+ bind:center
100
+ zoom={14}
101
+ accessToken={mapboxAccessToken}
102
+ style={mapboxStylesheetUrl}
103
+ bind:this={mapComponent}
104
+ on:click={handle_map_click}
105
+ >
106
+ <div class="absolute left-2 top-2">
107
+ <Geocoder
108
+ on:result={handle_geocoder_result}
109
+ accessToken={mapboxAccessToken}
110
+ {geocoder}
111
+ />
112
+ </div>
113
+ {#if !hide_geolocate_button}
114
+ <GeolocateControl position="top-right" on:geolocate={handle_geolocate} />
115
+ {/if}
116
+ {#if browserLocation}
117
+ <Marker lat={browserLocation.lat} lng={browserLocation.lng}>
118
+ <div class="relative w-0">
119
+ <div
120
+ class="bg-surface-0 p-4 rounded-xl rounded-bl-none shadow-2xl border absolute bottom-0 whitespace-nowrap"
121
+ >
122
+ <i class="fa-solid fa-user text-4xl" />
123
+ </div>
124
+ </div>
125
+ </Marker>
126
+ {/if}
127
+ {#if $fieldStore.value?.lat && $fieldStore.value?.lng}
128
+ <Marker lat={$fieldStore.value.lat} lng={$fieldStore.value.lng} popup={false}>
129
+ <div class="relative w-0">
130
+ <div
131
+ class="bg-surface-0 p-4 rounded-xl rounded-bl-none shadow-2xl border absolute bottom-0 whitespace-nowrap"
132
+ >
133
+ lat: {$fieldStore.value.lat?.toString()?.substring(0, 6)} <br />
134
+ lng: {$fieldStore.value.lng?.toString()?.substring(0, 6)}
135
+ </div>
136
+ </div>
137
+ </Marker>
138
+ {/if}
139
+ </Map>
140
+ </div>
141
+ </div>
142
+ </div>
143
+ {/if}
144
+ <FieldMessage {fieldStore} />
@@ -0,0 +1,28 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Writable } from "svelte/store";
3
+ import { type IBaseField, type IBuiltField, type IInitialForm } from "../interfaces";
4
+ export interface IMapFieldParams {
5
+ hide_geolocate_button?: boolean;
6
+ auto_set_location?: boolean;
7
+ }
8
+ export interface IMapField extends IBaseField<IMapFieldParams> {
9
+ fieldtype: "map";
10
+ }
11
+ export declare const map_field_param_spec: IInitialForm;
12
+ declare const __propDef: {
13
+ props: {
14
+ fieldStore: Writable<IBuiltField<IMapFieldParams>>;
15
+ };
16
+ events: {
17
+ [evt: string]: CustomEvent<any>;
18
+ };
19
+ slots: {};
20
+ exports?: {} | undefined;
21
+ bindings?: string | undefined;
22
+ };
23
+ export type MapFieldProps = typeof __propDef.props;
24
+ export type MapFieldEvents = typeof __propDef.events;
25
+ export type MapFieldSlots = typeof __propDef.slots;
26
+ export default class MapField extends SvelteComponent<MapFieldProps, MapFieldEvents, MapFieldSlots> {
27
+ }
28
+ export {};
@@ -0,0 +1,83 @@
1
+ <script context="module">import {} from "../interfaces";
2
+ export const multi_checkbox_field_param_spec = {
3
+ spec: {
4
+ fields: {
5
+ options: {
6
+ fieldtype: "objectbuilder",
7
+ params: {
8
+ value_field_spec: {
9
+ fieldtype: "section",
10
+ fields: {
11
+ label: {
12
+ fieldtype: "text",
13
+ help: "Optional label for this option (if different from the key)"
14
+ },
15
+ value: {
16
+ fieldtype: "jsoneditor",
17
+ help: "Optional additional data point to store with this option"
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+ }
24
+ }
25
+ };
26
+ </script>
27
+
28
+ <script>import { Checkbox } from "@stubber/ui/checkbox";
29
+ import { Label } from "@stubber/ui/label";
30
+ import { cloneDeep, startCase } from "lodash-es";
31
+ import FieldLabel from "../FieldLabel.svelte";
32
+ import FieldMessage from "../FieldMessage.svelte";
33
+ export let fieldStore;
34
+ let options = $fieldStore.params?.options || {};
35
+ if ($fieldStore.value) {
36
+ const newValue = {};
37
+ for (const key of Object.keys(options)) {
38
+ if ($fieldStore.value[key]) {
39
+ newValue[key] = $fieldStore.value[key];
40
+ }
41
+ }
42
+ $fieldStore.value = newValue;
43
+ }
44
+ for (const [key, item] of Object.entries(options)) {
45
+ if (!$fieldStore.value?.[key]) {
46
+ if (!$fieldStore.value) {
47
+ $fieldStore.value = {};
48
+ }
49
+ $fieldStore.value[key] = {
50
+ ...item,
51
+ checked: item.checked || false
52
+ };
53
+ }
54
+ }
55
+ const handle_check_change = (key, item, checked) => {
56
+ if (!$fieldStore.value) {
57
+ $fieldStore.value = {};
58
+ }
59
+ $fieldStore.value[key] = {
60
+ ...item,
61
+ checked
62
+ };
63
+ $fieldStore.value = cloneDeep({ ...$fieldStore.value });
64
+ };
65
+ </script>
66
+
67
+ <FieldLabel {fieldStore} />
68
+ {#each Object.entries(options) as [key, item] (key)}
69
+ {@const checked = $fieldStore.value?.[key]?.checked ?? false}
70
+ <div class="flex space-x-3 relative mt-2">
71
+ <Checkbox
72
+ id="{$fieldStore.id}_{key}"
73
+ name={key}
74
+ {checked}
75
+ onCheckedChange={(checked) => handle_check_change(key, item, checked)}
76
+ />
77
+
78
+ <Label for="{$fieldStore.id}_{key}">
79
+ {item.label || startCase(key)}
80
+ </Label>
81
+ </div>
82
+ {/each}
83
+ <FieldMessage {fieldStore} />
@@ -0,0 +1,34 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Writable } from "svelte/store";
3
+ import { type IBaseField, type IBuiltField, type IInitialForm } from "../interfaces";
4
+ interface IOption {
5
+ label: string;
6
+ value?: any;
7
+ checked?: boolean;
8
+ }
9
+ interface IMultiCheckboxFieldParams {
10
+ options: {
11
+ [key: string]: IOption;
12
+ };
13
+ }
14
+ export declare const multi_checkbox_field_param_spec: IInitialForm;
15
+ export interface IMultiCheckboxField extends IBaseField<IMultiCheckboxFieldParams> {
16
+ fieldtype: "multicheckbox";
17
+ }
18
+ declare const __propDef: {
19
+ props: {
20
+ fieldStore: Writable<IBuiltField<IMultiCheckboxFieldParams>>;
21
+ };
22
+ events: {
23
+ [evt: string]: CustomEvent<any>;
24
+ };
25
+ slots: {};
26
+ exports?: {} | undefined;
27
+ bindings?: string | undefined;
28
+ };
29
+ export type MultiCheckboxFieldProps = typeof __propDef.props;
30
+ export type MultiCheckboxFieldEvents = typeof __propDef.events;
31
+ export type MultiCheckboxFieldSlots = typeof __propDef.slots;
32
+ export default class MultiCheckboxField extends SvelteComponent<MultiCheckboxFieldProps, MultiCheckboxFieldEvents, MultiCheckboxFieldSlots> {
33
+ }
34
+ export {};
@@ -0,0 +1,70 @@
1
+ <script context="module">import { get } from "svelte/store";
2
+ import {} from "../interfaces";
3
+ </script>
4
+
5
+ <script>import { Button } from "@stubber/ui/button";
6
+ import FieldLabel from "../FieldLabel.svelte";
7
+ import FieldMessage from "../FieldMessage.svelte";
8
+ import FormField from "../form-field.svelte";
9
+ export let fieldStore;
10
+ $: fields = $fieldStore.sub_fields || [];
11
+ let allChildrenConditionsChecked = true;
12
+ let current_page_index = 0;
13
+ </script>
14
+
15
+ <FieldLabel {fieldStore} />
16
+
17
+ {#if fields?.length}
18
+ <div class={!allChildrenConditionsChecked ? "invisible absolute" : ""}>
19
+ <div class="border border-surface-200">
20
+ <div class="p-2 py-3 overflow-x-auto whitespace-nowrap">
21
+ <div class="flex items-center">
22
+ {#each fields as p, i}
23
+ <button
24
+ type="button"
25
+ on:click={() => (current_page_index = i)}
26
+ class="flex items-center mr-4 {current_page_index === i
27
+ ? 'text-surface-900'
28
+ : 'text-surface-500'}"
29
+ >
30
+ <span
31
+ class="mr-1 flex items-center justify-center w-6 h-6 rounded-full {current_page_index ===
32
+ i
33
+ ? 'bg-primary-500 text-surface-0'
34
+ : 'bg-surface-100 text-surface-700'}"
35
+ >
36
+ {i + 1}
37
+ </span>
38
+ </button>
39
+ {/each}
40
+ </div>
41
+ </div>
42
+ {#each $fieldStore.sub_fields || [] as sub_field, index (get(sub_field).id)}
43
+ <div
44
+ class="p-6 border-y border-surface-200 {current_page_index !== index
45
+ ? 'invisible absolute'
46
+ : ''}"
47
+ >
48
+ <FormField fieldStore={sub_field} />
49
+ </div>
50
+ {/each}
51
+ <div class="flex items-center justify-between text-sm p-2">
52
+ {#if current_page_index > 0}
53
+ <Button variant="outline" on:click={() => (current_page_index = current_page_index - 1)}>
54
+ Back
55
+ </Button>
56
+ {/if}
57
+ {#if current_page_index < fields.length - 1}
58
+ <Button
59
+ class="ml-auto"
60
+ variant="outline"
61
+ on:click={() => (current_page_index = current_page_index + 1)}
62
+ >
63
+ Next
64
+ </Button>
65
+ {/if}
66
+ </div>
67
+ </div>
68
+ <FieldMessage {fieldStore} />
69
+ </div>
70
+ {/if}
@@ -0,0 +1,24 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type Writable } from "svelte/store";
3
+ import { type IBaseField, type IBuiltField, type IField } from "../interfaces";
4
+ export interface IMultistepField extends IBaseField<{}> {
5
+ fieldtype: "multistep";
6
+ fields: Record<string, IField>;
7
+ }
8
+ declare const __propDef: {
9
+ props: {
10
+ fieldStore: Writable<IBuiltField>;
11
+ };
12
+ events: {
13
+ [evt: string]: CustomEvent<any>;
14
+ };
15
+ slots: {};
16
+ exports?: {} | undefined;
17
+ bindings?: string | undefined;
18
+ };
19
+ export type MultistepFieldProps = typeof __propDef.props;
20
+ export type MultistepFieldEvents = typeof __propDef.events;
21
+ export type MultistepFieldSlots = typeof __propDef.slots;
22
+ export default class MultistepField extends SvelteComponent<MultistepFieldProps, MultistepFieldEvents, MultistepFieldSlots> {
23
+ }
24
+ export {};
@@ -0,0 +1,18 @@
1
+ <script context="module">import {} from "../interfaces";
2
+ </script>
3
+
4
+ <script>import { Textarea } from "@stubber/ui/textarea";
5
+ import FieldLabel from "../FieldLabel.svelte";
6
+ import FieldMessage from "../FieldMessage.svelte";
7
+ export let fieldStore;
8
+ </script>
9
+
10
+ <FieldLabel {fieldStore} />
11
+ <Textarea
12
+ id={$fieldStore.id}
13
+ bind:value={$fieldStore.value}
14
+ placeholder={$fieldStore.label}
15
+ aria-invalid={$fieldStore.validation_result?.type == "error" ? true : undefined}
16
+ aria-describedby="message-{$fieldStore.id}"
17
+ />
18
+ <FieldMessage {fieldStore} />
@@ -0,0 +1,23 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Writable } from "svelte/store";
3
+ import { type IBaseField, type IBuiltField } from "../interfaces";
4
+ export interface INoteField extends IBaseField<{}> {
5
+ fieldtype: "note";
6
+ }
7
+ declare const __propDef: {
8
+ props: {
9
+ fieldStore: Writable<IBuiltField>;
10
+ };
11
+ events: {
12
+ [evt: string]: CustomEvent<any>;
13
+ };
14
+ slots: {};
15
+ exports?: {} | undefined;
16
+ bindings?: string | undefined;
17
+ };
18
+ export type NoteFieldProps = typeof __propDef.props;
19
+ export type NoteFieldEvents = typeof __propDef.events;
20
+ export type NoteFieldSlots = typeof __propDef.slots;
21
+ export default class NoteField extends SvelteComponent<NoteFieldProps, NoteFieldEvents, NoteFieldSlots> {
22
+ }
23
+ export {};
@@ -0,0 +1,77 @@
1
+ <script context="module">export const number_field_param_spec = {
2
+ spec: {
3
+ fields: {
4
+ min: {
5
+ fieldtype: "number",
6
+ help: "Minimum value allowed",
7
+ validations: [
8
+ {
9
+ validationtype: "jsonata",
10
+ invalid_message: "Minimum value cannot be greater than maximum value",
11
+ params: {
12
+ jsonata: "$not($exists(field.data) and $exists(form.data.max)) or form.data.max >= field.data"
13
+ }
14
+ }
15
+ ]
16
+ },
17
+ max: {
18
+ fieldtype: "number",
19
+ help: "Maximum value allowed",
20
+ validations: [
21
+ {
22
+ validationtype: "jsonata",
23
+ invalid_message: "Maximum value cannot be less than minimum value",
24
+ params: {
25
+ jsonata: "$not($exists(field.data) and $exists(form.data.min)) or form.data.min <= field.data"
26
+ }
27
+ }
28
+ ]
29
+ },
30
+ step: {
31
+ fieldtype: "number",
32
+ help: "Increment step for the number input"
33
+ }
34
+ }
35
+ }
36
+ };
37
+ </script>
38
+
39
+ <script>import { Input } from "@stubber/ui/input";
40
+ import FieldLabel from "../FieldLabel.svelte";
41
+ import FieldMessage from "../FieldMessage.svelte";
42
+ export let fieldStore;
43
+ function onInput(e) {
44
+ const new_value = e.target.value;
45
+ let parsedValue = parseFloat(new_value);
46
+ if (!isNaN(parsedValue)) {
47
+ $fieldStore.value = parsedValue;
48
+ } else {
49
+ $fieldStore.value = void 0;
50
+ }
51
+ }
52
+ function onBlur() {
53
+ let parsedValue = parseFloat($fieldStore.value);
54
+ if (!isNaN(parsedValue)) {
55
+ if ($fieldStore.min !== void 0 && parsedValue < $fieldStore.min) {
56
+ parsedValue = $fieldStore.min;
57
+ }
58
+ if ($fieldStore.max !== void 0 && parsedValue > $fieldStore.max) {
59
+ parsedValue = $fieldStore.max;
60
+ }
61
+ if ($fieldStore.step !== void 0) {
62
+ parsedValue = Math.round(parsedValue / $fieldStore.step) * $fieldStore.step;
63
+ }
64
+ $fieldStore.value = parsedValue;
65
+ }
66
+ }
67
+ </script>
68
+
69
+ <FieldLabel {fieldStore} />
70
+ <Input
71
+ value={$fieldStore.value}
72
+ on:input={onInput}
73
+ on:blur={onBlur}
74
+ type="number"
75
+ aria-invalid={$fieldStore.validation_result?.type == "error" ? true : undefined}
76
+ />
77
+ <FieldMessage {fieldStore} />
@@ -0,0 +1,29 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Writable } from "svelte/store";
3
+ import type { IBaseField, IBuiltField, IInitialForm } from "../interfaces";
4
+ interface INumberParams {
5
+ min?: number;
6
+ max?: number;
7
+ step?: number;
8
+ }
9
+ export declare const number_field_param_spec: IInitialForm;
10
+ export interface INumberField extends IBaseField<INumberParams> {
11
+ fieldtype: "number";
12
+ }
13
+ declare const __propDef: {
14
+ props: {
15
+ fieldStore: Writable<IBuiltField>;
16
+ };
17
+ events: {
18
+ [evt: string]: CustomEvent<any>;
19
+ };
20
+ slots: {};
21
+ exports?: {} | undefined;
22
+ bindings?: string | undefined;
23
+ };
24
+ export type NumberFieldProps = typeof __propDef.props;
25
+ export type NumberFieldEvents = typeof __propDef.events;
26
+ export type NumberFieldSlots = typeof __propDef.slots;
27
+ export default class NumberField extends SvelteComponent<NumberFieldProps, NumberFieldEvents, NumberFieldSlots> {
28
+ }
29
+ export {};