@stubber/form-fields 1.7.10 → 2.0.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/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 +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
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
<script>
|
|
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
|
-
|
|
8
|
-
import { Checkbox } from "@stubber/ui/checkbox";
|
|
9
|
-
import { Label } from "@stubber/ui/label";
|
|
10
|
-
|
|
11
|
-
export let field;
|
|
12
|
-
|
|
13
|
-
const internal = writable();
|
|
14
|
-
|
|
15
|
-
$: state_key = $field.state?.state_key;
|
|
16
|
-
$: label = $field.spec?.title;
|
|
17
|
-
$: hide_label = $field.spec?.hide_label;
|
|
18
|
-
$: checkedvalue =
|
|
19
|
-
$field.spec?.params?.checkedvalue !== undefined ? $field.spec?.params?.checkedvalue : true;
|
|
20
|
-
$: uncheckedvalue =
|
|
21
|
-
$field.spec?.params?.uncheckedvalue !== undefined ? $field.spec?.params?.uncheckedvalue : false;
|
|
22
|
-
$: isValid = !$field.state?.validation || $field.state?.validation?.valid;
|
|
23
|
-
$: validationMessage = $field.state?.validation?.message;
|
|
24
|
-
|
|
25
|
-
let store_sync_sub;
|
|
26
|
-
|
|
27
|
-
onMount(() => {
|
|
28
|
-
// set field values that aren't set yet
|
|
29
|
-
let f = _.cloneDeep($field);
|
|
30
|
-
let checked = deepEqual(f?.data?.base, checkedvalue);
|
|
31
|
-
let initial_data = {
|
|
32
|
-
...f?.data,
|
|
33
|
-
base: checked ? checkedvalue : uncheckedvalue,
|
|
34
|
-
};
|
|
35
|
-
if (!f?.spec?.without_value_details) initial_data.base_label = label;
|
|
36
|
-
let initial_state_internal = {
|
|
37
|
-
...f?.state?.internal,
|
|
38
|
-
checked,
|
|
39
|
-
};
|
|
40
|
-
_.set(f, "data", initial_data);
|
|
41
|
-
_.set(f, "state.internal", initial_state_internal);
|
|
42
|
-
if (!deepEqual(f, $field)) $field = f;
|
|
43
|
-
|
|
44
|
-
store_sync_sub = syncStoreToStore(
|
|
45
|
-
field,
|
|
46
|
-
internal,
|
|
47
|
-
(a, b) => {
|
|
48
|
-
let _clone = _.cloneDeep(a?.state?.internal) || {};
|
|
49
|
-
|
|
50
|
-
// get parts from data
|
|
51
|
-
_clone.checked = deepEqual(a?.data?.base, checkedvalue);
|
|
52
|
-
|
|
53
|
-
// set field state if changed
|
|
54
|
-
if (!deepEqual(a?.state?.internal, _clone)) {
|
|
55
|
-
$field.state.internal = _clone;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return _clone;
|
|
59
|
-
},
|
|
60
|
-
(a, b) => {
|
|
61
|
-
let _clone = _.cloneDeep(a) || {};
|
|
62
|
-
// update the state
|
|
63
|
-
_.set(_clone, "state.internal", _.cloneDeep(b));
|
|
64
|
-
// update the data
|
|
65
|
-
_.set(_clone, "data.base", b?.checked ? checkedvalue : uncheckedvalue);
|
|
66
|
-
|
|
67
|
-
return _clone;
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
onDestroy(() => {
|
|
73
|
-
store_sync_sub?.destroy();
|
|
74
|
-
});
|
|
75
|
-
</script>
|
|
76
|
-
|
|
77
|
-
{#if $internal}
|
|
78
|
-
<div class="flex flex-col w-full {!isValid ? `text-danger-500` : `text-surface-900`}">
|
|
79
|
-
<div class="flex space-x-3 relative my-1 items-center">
|
|
80
|
-
<Checkbox id="input_{state_key}" name={state_key} bind:checked={$internal.checked} />
|
|
81
|
-
<Label for="input_{state_key}" class="block {hide_label ? 'hidden' : ''}">
|
|
82
|
-
{label}
|
|
83
|
-
</Label>
|
|
84
|
-
</div>
|
|
85
|
-
{#if validationMessage}
|
|
86
|
-
<Label class={!isValid ? `text-danger-500` : `text-success-500`}>{validationMessage}</Label>
|
|
87
|
-
{/if}
|
|
88
|
-
</div>
|
|
89
|
-
{/if}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} CheckboxProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} CheckboxEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} CheckboxSlots */
|
|
4
|
-
export default class Checkbox extends SvelteComponent<{
|
|
5
|
-
field: any;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type CheckboxProps = typeof __propDef.props;
|
|
11
|
-
export type CheckboxEvents = typeof __propDef.events;
|
|
12
|
-
export type CheckboxSlots = typeof __propDef.slots;
|
|
13
|
-
import { SvelteComponent } from "svelte";
|
|
14
|
-
declare const __propDef: {
|
|
15
|
-
props: {
|
|
16
|
-
field: any;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {};
|
|
22
|
-
exports?: undefined;
|
|
23
|
-
bindings?: undefined;
|
|
24
|
-
};
|
|
25
|
-
export {};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import _ from "lodash-es";
|
|
3
|
-
import Checkbox from "./Checkbox.svelte";
|
|
4
|
-
import SmartText from "./SmartText.svelte";
|
|
5
|
-
import * as utils from "../../utils/index.js";
|
|
6
|
-
|
|
7
|
-
import { Label } from "@stubber/ui/label";
|
|
8
|
-
|
|
9
|
-
let clickOutside = utils.clickOutside;
|
|
10
|
-
|
|
11
|
-
export let field;
|
|
12
|
-
|
|
13
|
-
$field.spec.without_value_details = true;
|
|
14
|
-
|
|
15
|
-
$field.spec.params = $field.spec?.params || {};
|
|
16
|
-
$field.spec.params = {
|
|
17
|
-
...$field.spec.params,
|
|
18
|
-
code_language: "handlebars",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// this field picks the best field to render based on the data
|
|
22
|
-
let selected_option = typeof $field.data.base === "boolean" ? "Checkbox" : "Smart Text";
|
|
23
|
-
|
|
24
|
-
let menu_open = false;
|
|
25
|
-
|
|
26
|
-
const open_menu = () => {
|
|
27
|
-
menu_open = !menu_open;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const options = ["Checkbox", "Smart Text"];
|
|
31
|
-
|
|
32
|
-
function select_option(option) {
|
|
33
|
-
selected_option = option;
|
|
34
|
-
switch (selected_option) {
|
|
35
|
-
case "Checkbox":
|
|
36
|
-
$field.data.base = false;
|
|
37
|
-
break;
|
|
38
|
-
case "Smart Text":
|
|
39
|
-
$field.data.base = "";
|
|
40
|
-
break;
|
|
41
|
-
default:
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
menu_open = false;
|
|
46
|
-
}
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<div>
|
|
50
|
-
<div class="flex gap-1 items-center">
|
|
51
|
-
<div
|
|
52
|
-
class="relative"
|
|
53
|
-
use:clickOutside={() => {
|
|
54
|
-
if (menu_open) {
|
|
55
|
-
menu_open = false;
|
|
56
|
-
}
|
|
57
|
-
}}
|
|
58
|
-
>
|
|
59
|
-
<button
|
|
60
|
-
type="button"
|
|
61
|
-
on:click={open_menu}
|
|
62
|
-
class="flex items-center justify-center border border-dashed bg-surface-0 border-surface-300 hover:bg-surface-500 hover:text-surface-0 active:bg-surface-600 active:text-surface-0 rounded text-surface-500"
|
|
63
|
-
>
|
|
64
|
-
<i class="fa-regular fa-chevron-down" />
|
|
65
|
-
</button>
|
|
66
|
-
{#if menu_open}
|
|
67
|
-
<div
|
|
68
|
-
class="absolute z-10 left-0 top-6 w-48 bg-white shadow-lg rounded-md ring-1 ring-surface-300"
|
|
69
|
-
>
|
|
70
|
-
<div class="p-2">
|
|
71
|
-
{#each options as option}
|
|
72
|
-
<div class="flex items-center gap-1">
|
|
73
|
-
<input
|
|
74
|
-
id="fieldtype_radio_{option}"
|
|
75
|
-
type="radio"
|
|
76
|
-
name="fieldtype"
|
|
77
|
-
checked={option === selected_option}
|
|
78
|
-
on:change={() => {
|
|
79
|
-
select_option(option);
|
|
80
|
-
}}
|
|
81
|
-
/>
|
|
82
|
-
<Label for="fieldtype_radio_{option}">{option}</Label>
|
|
83
|
-
</div>
|
|
84
|
-
{/each}
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
{/if}
|
|
88
|
-
</div>
|
|
89
|
-
{#if selected_option === "Checkbox"}
|
|
90
|
-
<Checkbox {field} />
|
|
91
|
-
{:else}
|
|
92
|
-
<SmartText {field} />
|
|
93
|
-
{/if}
|
|
94
|
-
</div>
|
|
95
|
-
</div>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} CheckboxAutocompleteProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} CheckboxAutocompleteEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} CheckboxAutocompleteSlots */
|
|
4
|
-
export default class CheckboxAutocomplete extends SvelteComponent<{
|
|
5
|
-
field: any;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type CheckboxAutocompleteProps = typeof __propDef.props;
|
|
11
|
-
export type CheckboxAutocompleteEvents = typeof __propDef.events;
|
|
12
|
-
export type CheckboxAutocompleteSlots = typeof __propDef.slots;
|
|
13
|
-
import { SvelteComponent } from "svelte";
|
|
14
|
-
declare const __propDef: {
|
|
15
|
-
props: {
|
|
16
|
-
field: any;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {};
|
|
22
|
-
exports?: undefined;
|
|
23
|
-
bindings?: undefined;
|
|
24
|
-
};
|
|
25
|
-
export {};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
acceptCompletion,
|
|
3
|
-
autocompletion,
|
|
4
|
-
CompletionContext,
|
|
5
|
-
completionKeymap,
|
|
6
|
-
startCompletion
|
|
7
|
-
} from "@codemirror/autocomplete";
|
|
8
|
-
import { javascript, javascriptLanguage } from "@codemirror/lang-javascript";
|
|
9
|
-
import { EditorState } from "@codemirror/state";
|
|
10
|
-
import { EditorView, keymap } from "@codemirror/view";
|
|
11
|
-
import { Label } from "@stubber/ui/label";
|
|
12
|
-
import { basicSetup } from "codemirror";
|
|
13
|
-
export let field;
|
|
14
|
-
let value = $field.data.base || "";
|
|
15
|
-
let editor_view;
|
|
16
|
-
$: state_key = $field.state?.state_key;
|
|
17
|
-
$: label = $field.spec?.title;
|
|
18
|
-
$: hide_label = $field.spec?.hide_label;
|
|
19
|
-
$: isValid = !$field.state?.validation || $field.state?.validation?.valid;
|
|
20
|
-
$: validationMessage = $field.state?.validation?.message;
|
|
21
|
-
const custom_completion_keymap = completionKeymap.filter((binding) => binding.key != "Enter").concat([
|
|
22
|
-
{
|
|
23
|
-
key: "Enter",
|
|
24
|
-
run: () => {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
key: "Tab",
|
|
30
|
-
run: acceptCompletion
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
key: "Ctrl-Space",
|
|
34
|
-
run: startCompletion,
|
|
35
|
-
stopPropagation: true
|
|
36
|
-
}
|
|
37
|
-
]);
|
|
38
|
-
function keysFor(obj) {
|
|
39
|
-
return Object.keys(obj ?? {});
|
|
40
|
-
}
|
|
41
|
-
function globalCompletions(ctx) {
|
|
42
|
-
const m = ctx.matchBefore(/[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*\.?/);
|
|
43
|
-
if (!m && !ctx.explicit) return null;
|
|
44
|
-
const text = m?.text ?? "";
|
|
45
|
-
const trailingDot = text.endsWith(".");
|
|
46
|
-
const parts = (trailingDot ? text.slice(0, -1) : text).split(".").filter(Boolean);
|
|
47
|
-
let container = $field.spec?.params?.globals || {};
|
|
48
|
-
for (let i = 0; i < Math.max(0, parts.length - (trailingDot ? 0 : 1)); i++) {
|
|
49
|
-
container = container?.[parts[i]];
|
|
50
|
-
if (!container) break;
|
|
51
|
-
}
|
|
52
|
-
const last = trailingDot ? "" : parts[parts.length - 1] ?? "";
|
|
53
|
-
const from = ctx.pos - last.length;
|
|
54
|
-
return {
|
|
55
|
-
from,
|
|
56
|
-
options: keysFor(container).map((key) => ({
|
|
57
|
-
label: key,
|
|
58
|
-
type: "property"
|
|
59
|
-
// 👈 simplified
|
|
60
|
-
})),
|
|
61
|
-
validFor: /^\w*$/
|
|
62
|
-
// keep suggestions stable while typing
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const stubber_completions = javascriptLanguage.data.of({
|
|
66
|
-
autocomplete: globalCompletions
|
|
67
|
-
});
|
|
68
|
-
function bind_codemirror(el) {
|
|
69
|
-
const min_height_editor = EditorView.theme({
|
|
70
|
-
".cm-content, .cm-gutter": { minHeight: "200px" },
|
|
71
|
-
"&": { maxHeight: "300px" },
|
|
72
|
-
".cm-scroller": { overflow: "auto" }
|
|
73
|
-
});
|
|
74
|
-
editor_view = new EditorView({
|
|
75
|
-
state: EditorState.create({
|
|
76
|
-
doc: value,
|
|
77
|
-
extensions: [
|
|
78
|
-
basicSetup,
|
|
79
|
-
javascript(),
|
|
80
|
-
stubber_completions,
|
|
81
|
-
autocompletion({ defaultKeymap: false }),
|
|
82
|
-
keymap.of(custom_completion_keymap),
|
|
83
|
-
min_height_editor,
|
|
84
|
-
update_listener
|
|
85
|
-
]
|
|
86
|
-
}),
|
|
87
|
-
parent: el
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
const update_listener = EditorView.updateListener.of((update) => {
|
|
91
|
-
if (update.docChanged) {
|
|
92
|
-
const new_value = update.state.doc.toString();
|
|
93
|
-
if (new_value !== value) {
|
|
94
|
-
value = new_value;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
$: sync_field_to_editor(value);
|
|
99
|
-
const sync_field_to_editor = (new_value) => {
|
|
100
|
-
if (editor_view && editor_view.state.doc.toString() !== new_value) {
|
|
101
|
-
editor_view.dispatch({
|
|
102
|
-
changes: {
|
|
103
|
-
from: 0,
|
|
104
|
-
to: editor_view.state.doc.length,
|
|
105
|
-
insert: new_value
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
if ($field.data.base !== new_value) {
|
|
110
|
-
$field.data.base = new_value;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
$: sync_field_to_value($field.data.base);
|
|
114
|
-
const sync_field_to_value = (new_value) => {
|
|
115
|
-
if (new_value !== value) {
|
|
116
|
-
value = new_value;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
</script>
|
|
120
|
-
|
|
121
|
-
<div class="flex flex-col w-full my-2">
|
|
122
|
-
<Label for="input_{state_key}" class="block py-2 {hide_label ? 'hidden' : ''}">
|
|
123
|
-
{label}
|
|
124
|
-
</Label>
|
|
125
|
-
<div class="relative rounded-md">
|
|
126
|
-
<div use:bind_codemirror />
|
|
127
|
-
</div>
|
|
128
|
-
{#if validationMessage}
|
|
129
|
-
<Label class="mt-1.5 {!isValid ? `text-danger-500` : `text-success-500`}"
|
|
130
|
-
>{validationMessage}</Label
|
|
131
|
-
>
|
|
132
|
-
{/if}
|
|
133
|
-
</div>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
field: any;
|
|
5
|
-
};
|
|
6
|
-
events: {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
};
|
|
9
|
-
slots: {};
|
|
10
|
-
exports?: {} | undefined;
|
|
11
|
-
bindings?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
export type CodeProps = typeof __propDef.props;
|
|
14
|
-
export type CodeEvents = typeof __propDef.events;
|
|
15
|
-
export type CodeSlots = typeof __propDef.slots;
|
|
16
|
-
export default class Code extends SvelteComponent<CodeProps, CodeEvents, CodeSlots> {
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { onMount } from "svelte";
|
|
3
|
-
import _ from "lodash-es";
|
|
4
|
-
|
|
5
|
-
import { Button } from "@stubber/ui/button";
|
|
6
|
-
import Select from "./Select.svelte";
|
|
7
|
-
|
|
8
|
-
export let form;
|
|
9
|
-
export let field;
|
|
10
|
-
|
|
11
|
-
let dependencies = form.dependencies;
|
|
12
|
-
let clienthub = dependencies?.clienthub;
|
|
13
|
-
let createWantToModal = dependencies?.createWantToModal;
|
|
14
|
-
let stubber = dependencies?.stubber;
|
|
15
|
-
let socket = clienthub?.socket;
|
|
16
|
-
let stubref = stubber?.stubref;
|
|
17
|
-
let orguuid = stubber?.orguuid;
|
|
18
|
-
|
|
19
|
-
onMount(() => {});
|
|
20
|
-
|
|
21
|
-
const show_create_contact_modal = () => {
|
|
22
|
-
createWantToModal("_create_new_contact", stubref, orguuid);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const load_options = async (search_term) => {
|
|
26
|
-
if (!clienthub) return [];
|
|
27
|
-
|
|
28
|
-
const details = {
|
|
29
|
-
resource_name: "contacts",
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
details.params = $field.spec.params || {};
|
|
33
|
-
// add required/dynamic params (orguuid, stubref, input, and limit)
|
|
34
|
-
details.params.orguuid = orguuid;
|
|
35
|
-
details.params.stubref = stubref;
|
|
36
|
-
details.params.input = search_term;
|
|
37
|
-
if (details.params.limit === undefined) {
|
|
38
|
-
details.params.limit = 50;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return new Promise((resolve, reject) => {
|
|
42
|
-
socket.emit("request", { type: "resource", details }, (res) => {
|
|
43
|
-
if (res.success) {
|
|
44
|
-
const contacts = res.payload?.contacts || [];
|
|
45
|
-
const result = contacts.map((contact) => ({
|
|
46
|
-
value: contact,
|
|
47
|
-
label:
|
|
48
|
-
contact[$field.spec?.params?.label || $field.spec.label] ?? contact._default_label,
|
|
49
|
-
}));
|
|
50
|
-
resolve(result);
|
|
51
|
-
} else {
|
|
52
|
-
console.error("Failed to load contacts:", res);
|
|
53
|
-
resolve([]);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
</script>
|
|
59
|
-
|
|
60
|
-
<Select {field} {load_options}>
|
|
61
|
-
<div class="ml-auto pt-1">
|
|
62
|
-
<Button
|
|
63
|
-
on:click={show_create_contact_modal}
|
|
64
|
-
variant="ghost"
|
|
65
|
-
class="text-surface-500 text-sm hover:text-surface-700"
|
|
66
|
-
>
|
|
67
|
-
<i class="fa-regular fa-plus" />
|
|
68
|
-
Create new contact
|
|
69
|
-
</Button>
|
|
70
|
-
</div>
|
|
71
|
-
</Select>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} ContactselectorProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} ContactselectorEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} ContactselectorSlots */
|
|
4
|
-
export default class Contactselector extends SvelteComponent<{
|
|
5
|
-
form: any;
|
|
6
|
-
field: any;
|
|
7
|
-
}, {
|
|
8
|
-
[evt: string]: CustomEvent<any>;
|
|
9
|
-
}, {}> {
|
|
10
|
-
}
|
|
11
|
-
export type ContactselectorProps = typeof __propDef.props;
|
|
12
|
-
export type ContactselectorEvents = typeof __propDef.events;
|
|
13
|
-
export type ContactselectorSlots = typeof __propDef.slots;
|
|
14
|
-
import { SvelteComponent } from "svelte";
|
|
15
|
-
declare const __propDef: {
|
|
16
|
-
props: {
|
|
17
|
-
form: any;
|
|
18
|
-
field: any;
|
|
19
|
-
};
|
|
20
|
-
events: {
|
|
21
|
-
[evt: string]: CustomEvent<any>;
|
|
22
|
-
};
|
|
23
|
-
slots: {};
|
|
24
|
-
exports?: undefined;
|
|
25
|
-
bindings?: undefined;
|
|
26
|
-
};
|
|
27
|
-
export {};
|