{"version":3,"file":"rockField.obs.js","sources":["../../../Framework/Controls/rockField.obs"],"sourcesContent":["<!-- Copyright by the Spark Development Network; Licensed under the Rock Community License -->\r\n<template>\r\n    <div v-if=\"!isEditMode\">\r\n        <template v-if=\"showLabel\">\r\n            <div v-if=\"showValue\" class=\"form-group static-control\">\r\n                <label class=\"control-label\">\r\n                    {{ label }}\r\n                </label>\r\n                <div class=\"control-wrapper\">\r\n                    <div class=\"form-control-static\">\r\n                        <component :is=\"valueComponent\" :modelValue=\"value\" :configurationValues=\"configurationValues\" :isEscaped=\"isEscaped\" v-bind=\"$attrs\" />\r\n                    </div>\r\n                </div>\r\n            </div>\r\n        </template>\r\n        <component v-else :is=\"valueComponent\" :modelValue=\"value\" :configurationValues=\"configurationValues\" :isEscaped=\"isEscaped\" v-bind=\"$attrs\" />\r\n    </div>\r\n    <div v-else>\r\n        <component :is=\"editComponent\"\r\n                   v-model=\"value\"\r\n                   :label=\"label\"\r\n                   :help=\"helpText\"\r\n                   :configurationValues=\"configurationValues\"\r\n                   :rules=\"rules\"\r\n                   :dataEntryMode=\"dataEntryMode\"\r\n                   v-bind=\"$attrs\" />\r\n    </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\n    import { DataEntryMode, getFieldType } from \"@Obsidian/Utility/fieldTypes\";\r\n    import { computed, PropType, provide } from \"vue\";\r\n    import { PublicAttributeBag } from \"@Obsidian/ViewModels/Utility/publicAttributeBag\";\r\n    import { FieldType } from \"@Obsidian/SystemGuids/fieldType\";\r\n    import { emptyGuid, toGuidOrNull } from \"@Obsidian/Utility/guid\";\r\n\r\n    const textField = getFieldType(FieldType.Text);\r\n\r\n    const props = defineProps({\r\n        modelValue: {\r\n            type: String as PropType<string>,\r\n            required: false\r\n        },\r\n        attribute: {\r\n            type: Object as PropType<PublicAttributeBag>,\r\n            required: true\r\n        },\r\n        showEmptyValue: {\r\n            type: Boolean as PropType<boolean>,\r\n            default: false\r\n        },\r\n        isEditMode: {\r\n            type: Boolean as PropType<boolean>,\r\n            default: false\r\n        },\r\n        showLabel: {\r\n            type: Boolean as PropType<boolean>,\r\n            default: true\r\n        },\r\n        isCondensed: {\r\n            type: Boolean as PropType<boolean>,\r\n            default: false\r\n        },\r\n        dataEntryMode: {\r\n            type: String as PropType<DataEntryMode>,\r\n            default: undefined\r\n        },\r\n        isEscaped: {\r\n            type: Boolean as PropType<boolean>,\r\n            default: false\r\n        }\r\n    });\r\n\r\n    const emit = defineEmits<{\r\n        (e: \"update:modelValue\", value: string): void;\r\n    }>();\r\n\r\n    const field = computed(() => {\r\n        const fieldType = getFieldType(toGuidOrNull(props.attribute.fieldTypeGuid) ?? emptyGuid);\r\n\r\n        return fieldType ?? textField;\r\n    });\r\n\r\n    /** True if the read-only value should be displayed. */\r\n    const showValue = computed(() => props.showEmptyValue || field.value?.getTextValue(props.modelValue ?? \"\", props.attribute.configurationValues ?? {}) !== \"\");\r\n\r\n    /** True if this field is required and must be filled in. */\r\n    const isRequired = computed(() => props.attribute.isRequired);\r\n\r\n    /** Indicates to the editor component if this field is required or not. */\r\n    const rules = computed(() => isRequired.value ? \"required\" : \"\");\r\n\r\n    /** True if we are currently in edit mode. */\r\n    const isEditMode = computed(() => props.isEditMode);\r\n\r\n    /** The label to display above the value or editor. */\r\n    const label = computed(() => props.attribute.name);\r\n\r\n    /** The help text to display in the help bubble when in edit mode. */\r\n    const helpText = computed(() => props.attribute.description);\r\n\r\n    /** The read-only component to use to display the value. */\r\n    const valueComponent = computed(() => {\r\n        // This is here to cause the component to update reactively if\r\n        // the value changes.\r\n        // Commented out on 3/14/2022 by DSH. If no issues show up it can be removed\r\n        // at a later point in time (maybe 6 months later). I do not believe this\r\n        // is needed anymore after the refactoring that was performed.\r\n        //const _ignored = props.attributeValue.value;\r\n\r\n        return props.isCondensed\r\n            ? field.value?.getCondensedFormattedComponent(configurationValues.value)\r\n            : field.value?.getFormattedComponent(configurationValues.value);\r\n    });\r\n\r\n    /** The edit component to use to display the value. */\r\n    const editComponent = computed(() => field.value?.getEditComponent(configurationValues.value));\r\n\r\n    /** The value to display or edit. */\r\n    const value = computed({\r\n        get: () => props.modelValue || \"\",\r\n        set(newValue) {\r\n            emit(\"update:modelValue\", newValue);\r\n        }\r\n    });\r\n\r\n    /** The configuration values for the editor component. */\r\n    const configurationValues = computed(() => {\r\n        return props.attribute.configurationValues ?? {};\r\n    });\r\n\r\n    provide(\"isRequired\", isRequired);\r\n</script>\r\n"],"names":["textField","getFieldType","FieldType","Text","field","computed","_toGuidOrNull","fieldType","toGuidOrNull","props","attribute","fieldTypeGuid","emptyGuid","showValue","_field$value","_props$modelValue","_props$attribute$conf","showEmptyValue","value","getTextValue","modelValue","configurationValues","isRequired","rules","isEditMode","label","name","helpText","description","valueComponent","_field$value2","_field$value3","isCondensed","getCondensedFormattedComponent","getFormattedComponent","editComponent","_field$value4","getEditComponent","get","set","newValue","emit","_props$attribute$conf2","provide"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAoCI,IAAA,IAAMA,SAAS,GAAGC,YAAY,CAACC,SAAS,CAACC,IAAI,CAAC,CAAA;MAyC9C,IAAA,IAAMC,KAAK,GAAGC,QAAQ,CAAC,MAAM;MAAA,MAAA,IAAAC,aAAA,CAAA;YACzB,IAAMC,SAAS,GAAGN,YAAY,CAAA,CAAAK,aAAA,GAACE,YAAY,CAACC,KAAK,CAACC,SAAS,CAACC,aAAa,CAAC,MAAAL,IAAAA,IAAAA,aAAA,cAAAA,aAAA,GAAIM,SAAS,CAAC,CAAA;MAExF,MAAA,OAAOL,SAAS,KAATA,IAAAA,IAAAA,SAAS,KAATA,KAAAA,CAAAA,GAAAA,SAAS,GAAIP,SAAS,CAAA;MACjC,KAAC,CAAC,CAAA;UAGF,IAAMa,SAAS,GAAGR,QAAQ,CAAC,MAAA;MAAA,MAAA,IAAAS,YAAA,EAAAC,iBAAA,EAAAC,qB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