@stubber/form-fields 1.7.8 → 1.8.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.
- package/dist/{fields2 → form-fields}/sub/currency-field.svelte +2 -3
- package/dist/{fields2 → form-fields}/sub/file-field.svelte +17 -25
- package/dist/{fields2 → form-fields}/sub/select-field.svelte +6 -3
- package/dist/{fields2 → form-fields}/utils.d.ts +1 -0
- package/dist/{fields2 → form-fields}/utils.js +9 -1
- package/dist/utils/input_regex_mask.d.ts +3 -0
- package/dist/utils/input_regex_mask.js +25 -0
- package/package.json +4 -8
- package/dist/Field.svelte +0 -36
- package/dist/Field.svelte.d.ts +0 -33
- package/dist/Form.svelte +0 -34
- package/dist/Form.svelte.d.ts +0 -31
- package/dist/NullFieldWrapper.svelte +0 -6
- package/dist/NullFieldWrapper.svelte.d.ts +0 -27
- package/dist/fields/component_parts/arraybuilder/FieldWrapper.svelte +0 -74
- package/dist/fields/component_parts/arraybuilder/FieldWrapper.svelte.d.ts +0 -31
- package/dist/fields/component_parts/fieldbuilder/FieldWrapper.svelte +0 -8
- package/dist/fields/component_parts/fieldbuilder/FieldWrapper.svelte.d.ts +0 -27
- package/dist/fields/components/AgGrid.svelte +0 -46
- package/dist/fields/components/AgGrid.svelte.d.ts +0 -20
- package/dist/fields/components/Arraybuilder.svelte +0 -98
- package/dist/fields/components/Arraybuilder.svelte.d.ts +0 -27
- package/dist/fields/components/Checkbox.svelte +0 -89
- package/dist/fields/components/Checkbox.svelte.d.ts +0 -25
- package/dist/fields/components/CheckboxAutocomplete.svelte +0 -95
- package/dist/fields/components/CheckboxAutocomplete.svelte.d.ts +0 -25
- package/dist/fields/components/Code.svelte +0 -133
- package/dist/fields/components/Code.svelte.d.ts +0 -18
- package/dist/fields/components/Contactselector.svelte +0 -71
- package/dist/fields/components/Contactselector.svelte.d.ts +0 -27
- package/dist/fields/components/Currency.svelte +0 -264
- package/dist/fields/components/Currency.svelte.d.ts +0 -25
- package/dist/fields/components/Dataindication.svelte +0 -31
- package/dist/fields/components/Dataindication.svelte.d.ts +0 -25
- package/dist/fields/components/Date.svelte +0 -97
- package/dist/fields/components/Date.svelte.d.ts +0 -25
- package/dist/fields/components/Datetime.svelte +0 -97
- package/dist/fields/components/Datetime.svelte.d.ts +0 -25
- package/dist/fields/components/Email.svelte +0 -125
- package/dist/fields/components/Email.svelte.d.ts +0 -25
- package/dist/fields/components/Fieldbuilder.svelte +0 -343
- package/dist/fields/components/Fieldbuilder.svelte.d.ts +0 -27
- package/dist/fields/components/Fieldsbuilder.svelte +0 -122
- package/dist/fields/components/Fieldsbuilder.svelte.d.ts +0 -27
- package/dist/fields/components/File.svelte +0 -231
- package/dist/fields/components/File.svelte.d.ts +0 -27
- package/dist/fields/components/Heading.svelte +0 -17
- package/dist/fields/components/Heading.svelte.d.ts +0 -25
- package/dist/fields/components/Hidden.svelte +0 -7
- package/dist/fields/components/Hidden.svelte.d.ts +0 -25
- package/dist/fields/components/Hiddenlocation.svelte +0 -28
- package/dist/fields/components/Hiddenlocation.svelte.d.ts +0 -25
- package/dist/fields/components/Html.svelte +0 -13
- package/dist/fields/components/Html.svelte.d.ts +0 -25
- package/dist/fields/components/Jsoneditor.svelte +0 -133
- package/dist/fields/components/Jsoneditor.svelte.d.ts +0 -25
- package/dist/fields/components/Map.svelte +0 -192
- package/dist/fields/components/Map.svelte.d.ts +0 -27
- package/dist/fields/components/Multicheckbox.svelte +0 -77
- package/dist/fields/components/Multicheckbox.svelte.d.ts +0 -25
- package/dist/fields/components/Multistep.svelte +0 -86
- package/dist/fields/components/Multistep.svelte.d.ts +0 -27
- package/dist/fields/components/Note.svelte +0 -92
- package/dist/fields/components/Note.svelte.d.ts +0 -25
- package/dist/fields/components/Number.svelte +0 -119
- package/dist/fields/components/Number.svelte.d.ts +0 -25
- package/dist/fields/components/Objectbuilder.svelte +0 -154
- package/dist/fields/components/Objectbuilder.svelte.d.ts +0 -27
- package/dist/fields/components/Qrcodescanner.svelte +0 -196
- package/dist/fields/components/Qrcodescanner.svelte.d.ts +0 -25
- package/dist/fields/components/Radio.svelte +0 -117
- package/dist/fields/components/Radio.svelte.d.ts +0 -25
- package/dist/fields/components/Renderfield.svelte +0 -58
- package/dist/fields/components/Renderfield.svelte.d.ts +0 -27
- package/dist/fields/components/Screenrecorder.svelte +0 -276
- package/dist/fields/components/Screenrecorder.svelte.d.ts +0 -27
- package/dist/fields/components/Screenshot.svelte +0 -269
- package/dist/fields/components/Screenshot.svelte.d.ts +0 -27
- package/dist/fields/components/Scrollandreaddisplay.svelte +0 -122
- package/dist/fields/components/Scrollandreaddisplay.svelte.d.ts +0 -25
- package/dist/fields/components/Section.svelte +0 -87
- package/dist/fields/components/Section.svelte.d.ts +0 -27
- package/dist/fields/components/Select.svelte +0 -161
- package/dist/fields/components/Select.svelte.d.ts +0 -31
- package/dist/fields/components/Selectresource.svelte +0 -57
- package/dist/fields/components/Selectresource.svelte.d.ts +0 -27
- package/dist/fields/components/Signature.svelte +0 -152
- package/dist/fields/components/Signature.svelte.d.ts +0 -27
- package/dist/fields/components/Slider.svelte +0 -101
- package/dist/fields/components/Slider.svelte.d.ts +0 -25
- package/dist/fields/components/SmartText.svelte +0 -351
- package/dist/fields/components/SmartText.svelte.d.ts +0 -25
- package/dist/fields/components/Telephone.svelte +0 -156
- package/dist/fields/components/Telephone.svelte.d.ts +0 -25
- package/dist/fields/components/Text.svelte +0 -107
- package/dist/fields/components/Text.svelte.d.ts +0 -25
- package/dist/fields/components/Voicenote.svelte +0 -267
- package/dist/fields/components/Voicenote.svelte.d.ts +0 -27
- package/dist/fields/components/index.d.ts +0 -84
- package/dist/fields/components/index.js +0 -85
- package/dist/fields/definitions/all.json +0 -38
- package/dist/fields/definitions/arraybuilder.json +0 -39
- package/dist/fields/definitions/checkbox.json +0 -44
- package/dist/fields/definitions/code.json +0 -15
- package/dist/fields/definitions/contactselector.json +0 -15
- package/dist/fields/definitions/currency.json +0 -42
- package/dist/fields/definitions/dataindication.json +0 -16
- package/dist/fields/definitions/date.json +0 -16
- package/dist/fields/definitions/datetime.json +0 -15
- package/dist/fields/definitions/email.json +0 -16
- package/dist/fields/definitions/fieldbuilder.json +0 -64
- package/dist/fields/definitions/fieldsbuilder.json +0 -38
- package/dist/fields/definitions/file.json +0 -42
- package/dist/fields/definitions/grid.json +0 -47
- package/dist/fields/definitions/heading.json +0 -38
- package/dist/fields/definitions/hidden.json +0 -89
- package/dist/fields/definitions/hiddenlocation.json +0 -15
- package/dist/fields/definitions/html.json +0 -34
- package/dist/fields/definitions/index.d.ts +0 -90
- package/dist/fields/definitions/index.js +0 -99
- package/dist/fields/definitions/jsoneditor.json +0 -33
- package/dist/fields/definitions/map.json +0 -36
- package/dist/fields/definitions/multicheckbox.json +0 -47
- package/dist/fields/definitions/multistep.json +0 -35
- package/dist/fields/definitions/note.json +0 -16
- package/dist/fields/definitions/number.json +0 -42
- package/dist/fields/definitions/objectbuilder.json +0 -39
- package/dist/fields/definitions/placeholder.json +0 -15
- package/dist/fields/definitions/qrcodescanner.json +0 -16
- package/dist/fields/definitions/radio.json +0 -47
- package/dist/fields/definitions/renderfield.json +0 -36
- package/dist/fields/definitions/richtext.json +0 -16
- package/dist/fields/definitions/screenrecorder.json +0 -42
- package/dist/fields/definitions/screenshot.json +0 -42
- package/dist/fields/definitions/scrollandreaddisplay.json +0 -49
- package/dist/fields/definitions/section.json +0 -50
- package/dist/fields/definitions/select.json +0 -47
- package/dist/fields/definitions/selectresource.json +0 -48
- package/dist/fields/definitions/signature.json +0 -16
- package/dist/fields/definitions/slider.json +0 -78
- package/dist/fields/definitions/smarttext.json +0 -101
- package/dist/fields/definitions/telephone.json +0 -16
- package/dist/fields/definitions/text.json +0 -35
- package/dist/fields/definitions/validfieldtype.json +0 -220
- package/dist/fields/definitions/voicenote.json +0 -43
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -3
- package/dist/thirdparty/mapbox/GeoCoder.svelte +0 -10
- package/dist/thirdparty/mapbox/GeoCoder.svelte.d.ts +0 -27
- package/dist/thirdparty/mapbox/Map.svelte +0 -30
- package/dist/thirdparty/mapbox/Map.svelte.d.ts +0 -22
- package/dist/thirdparty/mapbox/MapMarker.svelte +0 -13
- package/dist/thirdparty/mapbox/MapMarker.svelte.d.ts +0 -33
- package/dist/utils/createField.d.ts +0 -6
- package/dist/utils/createField.js +0 -33
- package/dist/utils/createForm.d.ts +0 -1
- package/dist/utils/createForm.js +0 -501
- package/dist/utils/index.d.ts +0 -18
- package/dist/utils/index.js +0 -126
- package/dist/utils/syncing.d.ts +0 -11
- package/dist/utils/syncing.js +0 -134
- /package/dist/{fields2 → form-fields}/FieldExprToggle.svelte +0 -0
- /package/dist/{fields2 → form-fields}/FieldExprToggle.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/FieldLabel.svelte +0 -0
- /package/dist/{fields2 → form-fields}/FieldLabel.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/FieldMessage.svelte +0 -0
- /package/dist/{fields2 → form-fields}/FieldMessage.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/Form.svelte +0 -0
- /package/dist/{fields2 → form-fields}/Form.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/fileserver.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/fileserver.js +0 -0
- /package/dist/{fields2 → form-fields}/form-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/form-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/index.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/index.js +0 -0
- /package/dist/{fields2 → form-fields}/interfaces.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/interfaces.js +0 -0
- /package/dist/{fields2 → form-fields}/sub/array-builder-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/array-builder-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/checkbox-autocomplete.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/checkbox-autocomplete.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/checkbox-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/checkbox-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/code-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/code-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/contact-selector-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/contact-selector-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/currency-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/data-indication-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/data-indication-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/date-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/date-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/date-time-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/date-time-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/email-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/email-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/field-builder-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/field-builder-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/file-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/grid-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/grid-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/heading-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/heading-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/hidden-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/hidden-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/hidden-location-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/hidden-location-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/html-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/html-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/json-editor-bound.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/json-editor-bound.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/jsoneditor-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/jsoneditor-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/map-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/map-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/multi-checkbox-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/multi-checkbox-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/multistep-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/multistep-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/note-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/note-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/number-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/number-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/object-builder-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/object-builder-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/qr-code-scanner-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/qr-code-scanner-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/radio-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/radio-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/screenrecorder-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/screenrecorder-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/screenshot-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/screenshot-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/scroll-and-read-display-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/scroll-and-read-display-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/section-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/section-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/select-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/selectresource-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/selectresource-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/signature-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/signature-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/slider-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/slider-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/smart-text-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/smart-text-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/telephone-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/telephone-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/text-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/text-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/sub/voicenote-field.svelte +0 -0
- /package/dist/{fields2 → form-fields}/sub/voicenote-field.svelte.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/validations/validate_field.d.ts +0 -0
- /package/dist/{fields2 → form-fields}/validations/validate_field.js +0 -0
|
@@ -44,8 +44,7 @@ export const currency_field_param_spec = {
|
|
|
44
44
|
};
|
|
45
45
|
</script>
|
|
46
46
|
|
|
47
|
-
<script>import
|
|
48
|
-
import { Button } from "@stubber/ui/button";
|
|
47
|
+
<script>import { Button } from "@stubber/ui/button";
|
|
49
48
|
import * as Command from "@stubber/ui/command";
|
|
50
49
|
import * as Popover from "@stubber/ui/popover";
|
|
51
50
|
import getSymbolFromCurrency from "currency-symbol-map";
|
|
@@ -55,6 +54,7 @@ import { get as get_store_value } from "svelte/store";
|
|
|
55
54
|
import FieldLabel from "../FieldLabel.svelte";
|
|
56
55
|
import FieldMessage from "../FieldMessage.svelte";
|
|
57
56
|
import { set_value_details } from "../utils";
|
|
57
|
+
import { inputRegexMask } from "../../utils/input_regex_mask";
|
|
58
58
|
export let fieldStore;
|
|
59
59
|
let field = $fieldStore;
|
|
60
60
|
let params = field.params;
|
|
@@ -62,7 +62,6 @@ const currencyRegex = /^([0-9]+(\.?[0-9]?[0-9]?)?)$/;
|
|
|
62
62
|
const currencyName = new Intl.DisplayNames("en-US", {
|
|
63
63
|
type: "currency"
|
|
64
64
|
});
|
|
65
|
-
let { inputRegexMask } = utils;
|
|
66
65
|
let initial_ui_value = $fieldStore.value || "";
|
|
67
66
|
let currency_list = [];
|
|
68
67
|
const build_currency_list_from_codes = (codes) => {
|
|
@@ -19,14 +19,6 @@ import { append_attachment, remove_attachment, uploadFiles } from "../fileserver
|
|
|
19
19
|
export let fieldStore;
|
|
20
20
|
$: validation_result = $fieldStore.validation_result;
|
|
21
21
|
$: validation_type = validation_result?.type;
|
|
22
|
-
function parse_string_value(value) {
|
|
23
|
-
if (value === "true") return true;
|
|
24
|
-
if (value === "false") return false;
|
|
25
|
-
if (value !== "" && !isNaN(Number(value))) {
|
|
26
|
-
return Number(value);
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
22
|
async function handle_files_select(e) {
|
|
31
23
|
const { acceptedFiles, fileRejections } = e.detail;
|
|
32
24
|
if (limit_remaining < acceptedFiles.length) {
|
|
@@ -65,7 +57,7 @@ async function handle_files_select(e) {
|
|
|
65
57
|
];
|
|
66
58
|
selected_files = [];
|
|
67
59
|
}
|
|
68
|
-
let uploaded_files = [];
|
|
60
|
+
let uploaded_files = Array.isArray($fieldStore.value) ? $fieldStore.value : [];
|
|
69
61
|
let failed_files = [];
|
|
70
62
|
let selected_files = [];
|
|
71
63
|
$: update_fieldStore(uploaded_files);
|
|
@@ -91,46 +83,44 @@ function remove_file(item) {
|
|
|
91
83
|
</script>
|
|
92
84
|
|
|
93
85
|
<FieldLabel {fieldStore} />
|
|
94
|
-
<div class="w-full flex
|
|
86
|
+
<div class="flex w-full flex-col {validation_type == 'error' ? 'border-b border-warning-500' : ''}">
|
|
95
87
|
<Dropzone on:drop={handle_files_select} disabled={limit_remaining <= 0}>
|
|
96
|
-
<div class="flex
|
|
88
|
+
<div class="flex h-full flex-col justify-center rounded-sm text-center">
|
|
97
89
|
<div>
|
|
98
90
|
<p class=" text-surface-800">Drop files to upload</p>
|
|
99
91
|
<p class=" text-surface-800">
|
|
100
92
|
Or click <span
|
|
101
|
-
class="text-primary-500 hover:text-primary-400 hover:underline
|
|
93
|
+
class="cursor-pointer text-primary-500 hover:text-primary-400 hover:underline"
|
|
102
94
|
>here</span
|
|
103
95
|
>
|
|
104
96
|
to browse
|
|
105
97
|
</p>
|
|
106
98
|
{#if limit_remaining <= 0}
|
|
107
|
-
<p class="text-field text-danger-600
|
|
99
|
+
<p class="text-field text-sm italic text-danger-600">
|
|
108
100
|
You have reached the maximum number of files allowed
|
|
109
101
|
</p>
|
|
110
102
|
{/if}
|
|
111
103
|
</div>
|
|
112
104
|
</div>
|
|
113
105
|
</Dropzone>
|
|
114
|
-
<div class="w-full
|
|
106
|
+
<div class="mt-2 flex w-full flex-col gap-2">
|
|
115
107
|
{#each all_files as item}
|
|
116
|
-
<div class="w-full flex
|
|
108
|
+
<div class="flex w-full flex-row items-center gap-2">
|
|
117
109
|
{#if item.is_uploaded}
|
|
118
|
-
<div class="
|
|
119
|
-
<i class="fa fa-check
|
|
110
|
+
<div class="flex h-6 w-6 items-center justify-center text-success-500">
|
|
111
|
+
<i class="fa fa-check" />
|
|
120
112
|
</div>
|
|
121
113
|
{:else if item.is_failed}
|
|
122
|
-
<div class="
|
|
114
|
+
<div class="flex h-6 w-6 items-center justify-center text-danger-400">
|
|
123
115
|
<i class="fa-regular fa-triangle-exclamation" />
|
|
124
|
-
<p class="hidden md:block text-fluid-md">Failed</p>
|
|
125
116
|
</div>
|
|
126
117
|
{:else}
|
|
127
|
-
<div class="
|
|
128
|
-
<p class="hidden md:block text-fluid-md" />
|
|
118
|
+
<div class="flex h-6 w-6 items-center justify-center text-surface-500">
|
|
129
119
|
<i class="fa fa-pulse fa-spinner" />
|
|
130
120
|
</div>
|
|
131
121
|
{/if}
|
|
132
|
-
<div class="
|
|
133
|
-
<p class="text-surface-800
|
|
122
|
+
<div class="flex-1 truncate rounded-sm border border-surface-200 py-1 pl-2">
|
|
123
|
+
<p class="text-surface-800">
|
|
134
124
|
{item?.filename}
|
|
135
125
|
</p>
|
|
136
126
|
</div>
|
|
@@ -138,11 +128,13 @@ function remove_file(item) {
|
|
|
138
128
|
type="button"
|
|
139
129
|
variant="destructive"
|
|
140
130
|
size="icon"
|
|
141
|
-
class="
|
|
131
|
+
class="h-8 w-8 shrink-0"
|
|
142
132
|
on:click={() => {
|
|
143
133
|
remove_file(item);
|
|
144
134
|
}}
|
|
145
|
-
|
|
135
|
+
>
|
|
136
|
+
<i class="fa-solid fa-x text-xs" />
|
|
137
|
+
</Button>
|
|
146
138
|
</div>
|
|
147
139
|
{/each}
|
|
148
140
|
</div>
|
|
@@ -31,17 +31,20 @@ import { debounce, isEqual } from "lodash-es";
|
|
|
31
31
|
import { tick } from "svelte";
|
|
32
32
|
import FieldLabel from "../FieldLabel.svelte";
|
|
33
33
|
import FieldMessage from "../FieldMessage.svelte";
|
|
34
|
-
import { set_value_details } from "../utils";
|
|
34
|
+
import { clear_value_details, set_value_details } from "../utils";
|
|
35
35
|
export let fieldStore;
|
|
36
36
|
export let load_options = void 0;
|
|
37
37
|
let open = false;
|
|
38
38
|
let loading = false;
|
|
39
39
|
let items = [];
|
|
40
40
|
const state = createState();
|
|
41
|
-
$: dropdownLabel = items.find((i) => isEqual(i.value, $fieldStore.value))?.label ?? $fieldStore.value?._default_label ??
|
|
41
|
+
$: dropdownLabel = items.find((i) => isEqual(i.value, $fieldStore.value))?.label ?? $fieldStore.value?._default_label ?? "Select...";
|
|
42
42
|
$: update_value_details_label(dropdownLabel);
|
|
43
43
|
const update_value_details_label = (label) => {
|
|
44
|
-
if (!label || label === "Select...")
|
|
44
|
+
if (!label || label === "Select...") {
|
|
45
|
+
clear_value_details($fieldStore, "label");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
45
48
|
set_value_details($fieldStore, "label", label);
|
|
46
49
|
};
|
|
47
50
|
const map_field_options = (options) => {
|
|
@@ -7,3 +7,4 @@ export declare const generate_field_data_path: (key: string, field: IField, base
|
|
|
7
7
|
export declare const get_field_label: (key: string, field: IField) => string;
|
|
8
8
|
export declare const get_field_help_message: (field: IBuiltField) => IValidationResult | undefined;
|
|
9
9
|
export declare const set_value_details: (field: IBuiltField, key: "label" | "details", details: any) => void;
|
|
10
|
+
export declare const clear_value_details: (field: IBuiltField, key: "label" | "details") => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get, isEqual, set, startCase } from "lodash-es";
|
|
1
|
+
import { get, isEqual, set, startCase, unset } from "lodash-es";
|
|
2
2
|
import { get as getStoreValue, writable } from "svelte/store";
|
|
3
3
|
export const build_fields = (formStore, attachmentsStore, formDependencies, input_fields, base_path = null) => {
|
|
4
4
|
return Object.entries(input_fields).map(([key, field]) => {
|
|
@@ -117,3 +117,11 @@ export const set_value_details = (field, key, details) => {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
};
|
|
120
|
+
export const clear_value_details = (field, key) => {
|
|
121
|
+
const formStore = field.formStore;
|
|
122
|
+
const value_details_path = field.data_path + `_${key}`;
|
|
123
|
+
formStore.update((f) => {
|
|
124
|
+
unset(f, value_details_path);
|
|
125
|
+
return f;
|
|
126
|
+
});
|
|
127
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function inputRegexMask(input, regex) {
|
|
2
|
+
let lastValidValue;
|
|
3
|
+
function handleBeforeInput(event) {
|
|
4
|
+
lastValidValue = event.target.value;
|
|
5
|
+
}
|
|
6
|
+
function handleInput(event) {
|
|
7
|
+
const input_element = event.target;
|
|
8
|
+
let { value, selectionStart } = input_element;
|
|
9
|
+
if (!regex.test(value) && value && selectionStart) {
|
|
10
|
+
input_element.value = lastValidValue;
|
|
11
|
+
const cursorPlace = selectionStart - (value.length - value.length);
|
|
12
|
+
requestAnimationFrame(() => input_element.setSelectionRange(cursorPlace, cursorPlace));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
lastValidValue = value;
|
|
16
|
+
}
|
|
17
|
+
input.addEventListener("beforeinput", handleBeforeInput);
|
|
18
|
+
input.addEventListener("input", handleInput);
|
|
19
|
+
return {
|
|
20
|
+
destroy() {
|
|
21
|
+
input.removeEventListener("beforeinput", handleBeforeInput);
|
|
22
|
+
input.removeEventListener("input", handleInput);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stubber/form-fields",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "An automatic form builder based on field specifications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -17,12 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
|
-
"svelte": "./dist/index.js"
|
|
22
|
-
},
|
|
23
|
-
"./fields2": {
|
|
24
|
-
"types": "./dist/fields2/index.d.ts",
|
|
25
|
-
"svelte": "./dist/fields2/index.js"
|
|
20
|
+
"types": "./dist/form-fields/index.d.ts",
|
|
21
|
+
"svelte": "./dist/form-fields/index.js"
|
|
26
22
|
}
|
|
27
23
|
},
|
|
28
24
|
"scripts": {
|
|
@@ -66,7 +62,7 @@
|
|
|
66
62
|
"@codemirror/lang-javascript": "^6.2.4",
|
|
67
63
|
"@codemirror/state": "^6.5.2",
|
|
68
64
|
"@codemirror/view": "^6.38.4",
|
|
69
|
-
"@stubber/ui": "^1.13.
|
|
65
|
+
"@stubber/ui": "^1.13.7",
|
|
70
66
|
"ag-grid-community": "^31.0.2",
|
|
71
67
|
"ag-grid-enterprise": "^31.0.2",
|
|
72
68
|
"codemirror": "^6.0.2",
|
package/dist/Field.svelte
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { getContext, onDestroy, onMount } from "svelte";
|
|
3
|
-
import * as utils from "./utils/index.js";
|
|
4
|
-
import _ from "lodash-es";
|
|
5
|
-
|
|
6
|
-
export let form;
|
|
7
|
-
export let initial_field_spec = null;
|
|
8
|
-
export let parent_field = null;
|
|
9
|
-
export let field_wrapper = null;
|
|
10
|
-
export let field = null;
|
|
11
|
-
|
|
12
|
-
const default_field_wrapper = getContext("stubber-form-fields-default-wrapper");
|
|
13
|
-
|
|
14
|
-
let removeField;
|
|
15
|
-
onMount(() => {
|
|
16
|
-
let addResult = form.addField(initial_field_spec, $parent_field?.state?.state_key);
|
|
17
|
-
if (addResult?.state_key) field = utils.createField(addResult?.state_key, form);
|
|
18
|
-
if (addResult?.removeField) removeField = addResult?.removeField;
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
onDestroy(() => {
|
|
22
|
-
if (removeField) removeField();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// derive the field wrapper
|
|
26
|
-
$: FieldWrapper = field_wrapper || default_field_wrapper;
|
|
27
|
-
|
|
28
|
-
// get the right svelte component
|
|
29
|
-
$: fieldcomponent = utils.mapFieldToComponent($field?.spec);
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
{#if $field?.state?.conditions_passed}
|
|
33
|
-
<div class={$field?.state?.invisible ? "invisible absolute" : ""}>
|
|
34
|
-
<svelte:component this={FieldWrapper} {form} {field} {fieldcomponent} {parent_field} />
|
|
35
|
-
</div>
|
|
36
|
-
{/if}
|
package/dist/Field.svelte.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} FieldProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} FieldEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} FieldSlots */
|
|
4
|
-
export default class Field extends SvelteComponent<{
|
|
5
|
-
form: any;
|
|
6
|
-
field?: null | undefined;
|
|
7
|
-
parent_field?: null | undefined;
|
|
8
|
-
initial_field_spec?: null | undefined;
|
|
9
|
-
field_wrapper?: null | undefined;
|
|
10
|
-
}, {
|
|
11
|
-
[evt: string]: CustomEvent<any>;
|
|
12
|
-
}, {}> {
|
|
13
|
-
}
|
|
14
|
-
export type FieldProps = typeof __propDef.props;
|
|
15
|
-
export type FieldEvents = typeof __propDef.events;
|
|
16
|
-
export type FieldSlots = typeof __propDef.slots;
|
|
17
|
-
import { SvelteComponent } from "svelte";
|
|
18
|
-
declare const __propDef: {
|
|
19
|
-
props: {
|
|
20
|
-
form: any;
|
|
21
|
-
field?: null | undefined;
|
|
22
|
-
parent_field?: null | undefined;
|
|
23
|
-
initial_field_spec?: null | undefined;
|
|
24
|
-
field_wrapper?: null | undefined;
|
|
25
|
-
};
|
|
26
|
-
events: {
|
|
27
|
-
[evt: string]: CustomEvent<any>;
|
|
28
|
-
};
|
|
29
|
-
slots: {};
|
|
30
|
-
exports?: undefined;
|
|
31
|
-
bindings?: undefined;
|
|
32
|
-
};
|
|
33
|
-
export {};
|
package/dist/Form.svelte
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { setContext } from "svelte";
|
|
3
|
-
import * as utils from "./utils/index.js";
|
|
4
|
-
import _ from "lodash-es";
|
|
5
|
-
import Field from "./Field.svelte";
|
|
6
|
-
import NullFieldWrapper from "./NullFieldWrapper.svelte";
|
|
7
|
-
import { deepEqual } from "fast-equals";
|
|
8
|
-
|
|
9
|
-
export let initial_form = {};
|
|
10
|
-
export let form = null;
|
|
11
|
-
export let field_wrapper = null;
|
|
12
|
-
export let dependencies = null;
|
|
13
|
-
|
|
14
|
-
form = utils.createForm({ dependencies, form });
|
|
15
|
-
setContext("stubber-form-fields-default-wrapper", field_wrapper || NullFieldWrapper);
|
|
16
|
-
|
|
17
|
-
let debounceRenderForm = utils.debounce(renderForm, 50);
|
|
18
|
-
$: debounceRenderForm(initial_form);
|
|
19
|
-
function renderForm(v) {
|
|
20
|
-
if (!deepEqual($form?.initial_form, v)) form.initialize(v);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
$: fields = utils.getFieldsToRender($form?.root_spec?.fields);
|
|
24
|
-
</script>
|
|
25
|
-
|
|
26
|
-
{#if $form?.render_index}
|
|
27
|
-
{#key $form?.render_index}
|
|
28
|
-
{#if fields}
|
|
29
|
-
{#each fields as initial_field_spec (initial_field_spec.__key)}
|
|
30
|
-
<Field {form} {initial_field_spec} />
|
|
31
|
-
{/each}
|
|
32
|
-
{/if}
|
|
33
|
-
{/key}
|
|
34
|
-
{/if}
|
package/dist/Form.svelte.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} FormProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} FormEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} FormSlots */
|
|
4
|
-
export default class Form extends SvelteComponent<{
|
|
5
|
-
form?: any;
|
|
6
|
-
field_wrapper?: null | undefined;
|
|
7
|
-
initial_form?: {} | undefined;
|
|
8
|
-
dependencies?: null | undefined;
|
|
9
|
-
}, {
|
|
10
|
-
[evt: string]: CustomEvent<any>;
|
|
11
|
-
}, {}> {
|
|
12
|
-
}
|
|
13
|
-
export type FormProps = typeof __propDef.props;
|
|
14
|
-
export type FormEvents = typeof __propDef.events;
|
|
15
|
-
export type FormSlots = typeof __propDef.slots;
|
|
16
|
-
import { SvelteComponent } from "svelte";
|
|
17
|
-
declare const __propDef: {
|
|
18
|
-
props: {
|
|
19
|
-
form?: any;
|
|
20
|
-
field_wrapper?: null | undefined;
|
|
21
|
-
initial_form?: {} | undefined;
|
|
22
|
-
dependencies?: null | undefined;
|
|
23
|
-
};
|
|
24
|
-
events: {
|
|
25
|
-
[evt: string]: CustomEvent<any>;
|
|
26
|
-
};
|
|
27
|
-
slots: {};
|
|
28
|
-
exports?: undefined;
|
|
29
|
-
bindings?: undefined;
|
|
30
|
-
};
|
|
31
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} NullFieldWrapperProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} NullFieldWrapperEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} NullFieldWrapperSlots */
|
|
4
|
-
export default class NullFieldWrapper extends SvelteComponent<{
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
fieldcomponent: any;
|
|
7
|
-
}, {
|
|
8
|
-
[evt: string]: CustomEvent<any>;
|
|
9
|
-
}, {}> {
|
|
10
|
-
}
|
|
11
|
-
export type NullFieldWrapperProps = typeof __propDef.props;
|
|
12
|
-
export type NullFieldWrapperEvents = typeof __propDef.events;
|
|
13
|
-
export type NullFieldWrapperSlots = typeof __propDef.slots;
|
|
14
|
-
import { SvelteComponent } from "svelte";
|
|
15
|
-
declare const __propDef: {
|
|
16
|
-
props: {
|
|
17
|
-
[x: string]: any;
|
|
18
|
-
fieldcomponent: any;
|
|
19
|
-
};
|
|
20
|
-
events: {
|
|
21
|
-
[evt: string]: CustomEvent<any>;
|
|
22
|
-
};
|
|
23
|
-
slots: {};
|
|
24
|
-
exports?: undefined;
|
|
25
|
-
bindings?: undefined;
|
|
26
|
-
};
|
|
27
|
-
export {};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import _ from "lodash-es";
|
|
3
|
-
|
|
4
|
-
import { Button } from "@stubber/ui/button";
|
|
5
|
-
|
|
6
|
-
// fieldWrapper
|
|
7
|
-
export let field;
|
|
8
|
-
export let fieldcomponent;
|
|
9
|
-
export let parent_field;
|
|
10
|
-
|
|
11
|
-
function removeEntry() {
|
|
12
|
-
let field_index = parseInt($field.spec?.__key);
|
|
13
|
-
// update the parent field
|
|
14
|
-
let parent_data = _.cloneDeep($parent_field?.data?.base);
|
|
15
|
-
if (_.isArray(parent_data)) {
|
|
16
|
-
parent_data = parent_data.slice(0, field_index).concat(parent_data.slice(field_index + 1));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
parent_field.update((p) => {
|
|
20
|
-
let cp = _.cloneDeep(p);
|
|
21
|
-
_.set(cp, "data.base", parent_data);
|
|
22
|
-
return cp;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function reorder(is_move_higher) {
|
|
27
|
-
let field_index = parseInt($field.spec?.__key);
|
|
28
|
-
let sibling_index = field_index + (is_move_higher ? 1 : -1);
|
|
29
|
-
|
|
30
|
-
if (sibling_index < 0 || sibling_index >= $parent_field?.data?.base?.length) return;
|
|
31
|
-
|
|
32
|
-
// update the parent field
|
|
33
|
-
let parent_data = _.cloneDeep($parent_field?.data?.base);
|
|
34
|
-
if (_.isArray(parent_data)) {
|
|
35
|
-
let temp = _.cloneDeep(parent_data[field_index]);
|
|
36
|
-
parent_data[field_index] = _.cloneDeep(parent_data[sibling_index]);
|
|
37
|
-
parent_data[sibling_index] = temp;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
$parent_field.data.base = parent_data;
|
|
41
|
-
}
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
<div class="flex items-center pb-1">
|
|
45
|
-
<div class="relative flex-grow-0 mr-2">
|
|
46
|
-
<Button
|
|
47
|
-
on:click={() => reorder(false)}
|
|
48
|
-
variant="ghost"
|
|
49
|
-
size="icon"
|
|
50
|
-
class="flex items-center justify-center w-5 h-5 "
|
|
51
|
-
>
|
|
52
|
-
<i class="fa-sharp fa-regular fa-angle-up text-base" />
|
|
53
|
-
</Button>
|
|
54
|
-
<Button
|
|
55
|
-
on:click={() => reorder(true)}
|
|
56
|
-
variant="ghost"
|
|
57
|
-
size="icon"
|
|
58
|
-
class="flex items-center justify-center w-5 h-5"
|
|
59
|
-
>
|
|
60
|
-
<i class="fa-sharp fa-regular fa-angle-down text-base" />
|
|
61
|
-
</Button>
|
|
62
|
-
</div>
|
|
63
|
-
<div class="flex-grow">
|
|
64
|
-
<svelte:component this={fieldcomponent} {...$$props} field_wrapper={null} />
|
|
65
|
-
</div>
|
|
66
|
-
<Button
|
|
67
|
-
on:click={removeEntry}
|
|
68
|
-
variant="destructive"
|
|
69
|
-
size="icon"
|
|
70
|
-
class="flex-grow-0 flex items-center justify-center w-6 h-6 ml-2 "
|
|
71
|
-
>
|
|
72
|
-
<i class="fa-regular fa-trash-alt text-xs" />
|
|
73
|
-
</Button>
|
|
74
|
-
</div>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} FieldWrapperProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} FieldWrapperEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} FieldWrapperSlots */
|
|
4
|
-
export default class FieldWrapper extends SvelteComponent<{
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
field: any;
|
|
7
|
-
fieldcomponent: any;
|
|
8
|
-
parent_field: any;
|
|
9
|
-
}, {
|
|
10
|
-
[evt: string]: CustomEvent<any>;
|
|
11
|
-
}, {}> {
|
|
12
|
-
}
|
|
13
|
-
export type FieldWrapperProps = typeof __propDef.props;
|
|
14
|
-
export type FieldWrapperEvents = typeof __propDef.events;
|
|
15
|
-
export type FieldWrapperSlots = typeof __propDef.slots;
|
|
16
|
-
import { SvelteComponent } from "svelte";
|
|
17
|
-
declare const __propDef: {
|
|
18
|
-
props: {
|
|
19
|
-
[x: string]: any;
|
|
20
|
-
field: any;
|
|
21
|
-
fieldcomponent: any;
|
|
22
|
-
parent_field: any;
|
|
23
|
-
};
|
|
24
|
-
events: {
|
|
25
|
-
[evt: string]: CustomEvent<any>;
|
|
26
|
-
};
|
|
27
|
-
slots: {};
|
|
28
|
-
exports?: undefined;
|
|
29
|
-
bindings?: undefined;
|
|
30
|
-
};
|
|
31
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} FieldWrapperProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} FieldWrapperEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} FieldWrapperSlots */
|
|
4
|
-
export default class FieldWrapper extends SvelteComponent<{
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
fieldcomponent: any;
|
|
7
|
-
}, {
|
|
8
|
-
[evt: string]: CustomEvent<any>;
|
|
9
|
-
}, {}> {
|
|
10
|
-
}
|
|
11
|
-
export type FieldWrapperProps = typeof __propDef.props;
|
|
12
|
-
export type FieldWrapperEvents = typeof __propDef.events;
|
|
13
|
-
export type FieldWrapperSlots = typeof __propDef.slots;
|
|
14
|
-
import { SvelteComponent } from "svelte";
|
|
15
|
-
declare const __propDef: {
|
|
16
|
-
props: {
|
|
17
|
-
[x: string]: any;
|
|
18
|
-
fieldcomponent: any;
|
|
19
|
-
};
|
|
20
|
-
events: {
|
|
21
|
-
[evt: string]: CustomEvent<any>;
|
|
22
|
-
};
|
|
23
|
-
slots: {};
|
|
24
|
-
exports?: undefined;
|
|
25
|
-
bindings?: undefined;
|
|
26
|
-
};
|
|
27
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<script>import { syncStoreToStore } from "../../utils/syncing";
|
|
2
|
-
import { deepEqual } from "fast-equals";
|
|
3
|
-
import _ from "lodash-es";
|
|
4
|
-
import { onMount } from "svelte";
|
|
5
|
-
import { createGrid, GridApi } from "ag-grid-community";
|
|
6
|
-
import "ag-grid-community/styles/ag-grid.css";
|
|
7
|
-
import "ag-grid-community/styles/ag-theme-material.css";
|
|
8
|
-
export let field;
|
|
9
|
-
$: state_key = $field.state?.state_key;
|
|
10
|
-
$: label = $field.spec?.title;
|
|
11
|
-
$: hide_label = $field.spec?.hide_label;
|
|
12
|
-
$: isValid = !$field.state?.validation || $field.state?.validation?.valid;
|
|
13
|
-
$: validationMessage = $field.state?.validation?.message;
|
|
14
|
-
let gridDiv;
|
|
15
|
-
let gridApi;
|
|
16
|
-
const gridOptions = {
|
|
17
|
-
autoSizeStrategy: {
|
|
18
|
-
type: "fitGridWidth",
|
|
19
|
-
defaultMinWidth: 100
|
|
20
|
-
},
|
|
21
|
-
defaultColDef: {
|
|
22
|
-
suppressMovable: true
|
|
23
|
-
},
|
|
24
|
-
onGridReady: (params) => {
|
|
25
|
-
gridApi = params.api;
|
|
26
|
-
},
|
|
27
|
-
onCellValueChanged: () => {
|
|
28
|
-
let rowData = [];
|
|
29
|
-
gridApi.forEachNode((node) => rowData.push(node.data));
|
|
30
|
-
$field.data.base = rowData;
|
|
31
|
-
},
|
|
32
|
-
// Row Data: The data to be displayed.
|
|
33
|
-
rowData: [],
|
|
34
|
-
// Column Definitions: Defines & controls grid columns.
|
|
35
|
-
columnDefs: []
|
|
36
|
-
};
|
|
37
|
-
onMount(() => {
|
|
38
|
-
let columnDefs = $field.spec?.params?.columnDefs;
|
|
39
|
-
if (columnDefs) gridOptions.columnDefs = columnDefs;
|
|
40
|
-
let rowData = $field.data?.base;
|
|
41
|
-
if (Array.isArray(rowData)) gridOptions.rowData = rowData;
|
|
42
|
-
createGrid(gridDiv, gridOptions);
|
|
43
|
-
});
|
|
44
|
-
</script>
|
|
45
|
-
|
|
46
|
-
<div bind:this={gridDiv} class="ag-theme-material w-full h-96" />
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import "ag-grid-community/styles/ag-grid.css";
|
|
3
|
-
import "ag-grid-community/styles/ag-theme-material.css";
|
|
4
|
-
declare const __propDef: {
|
|
5
|
-
props: {
|
|
6
|
-
field: any;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type AgGridProps = typeof __propDef.props;
|
|
16
|
-
export type AgGridEvents = typeof __propDef.events;
|
|
17
|
-
export type AgGridSlots = typeof __propDef.slots;
|
|
18
|
-
export default class AgGrid extends SvelteComponent<AgGridProps, AgGridEvents, AgGridSlots> {
|
|
19
|
-
}
|
|
20
|
-
export {};
|