{"version":3,"file":"textBox.obs.js","sources":["../../../Framework/Controls/textBox.obs","../../../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["<!-- Copyright by the Spark Development Network; Licensed under the Rock Community License -->\n<template>\n <RockFormField v-model=\"internalValue\"\n name=\"textbox\"\n v-bind=\"fieldProps\"\n :rules=\"augmentedRules\"\n :formGroupClasses=\"'rock-text-box ' + formGroupClasses\">\n <template #pre>\n <em v-if=\"showCountDown\" class=\"pull-right badge\" :class=\"countdownClass\">\n {{ charsRemaining }}\n </em>\n </template>\n <template #default=\"{ uniqueId, field }\">\n <div class=\"control-wrapper\">\n <slot name=\"prepend\" :isInputGroupSupported=\"true\" />\n <div :class=\"controlContainerClass\">\n <template v-if=\"isTextarea\">\n <slot name=\"inputGroupPrepend\" :isInputGroupSupported=\"true\" />\n <textarea :value=\"internalValue\"\n :rows=\"rows\"\n cols=\"20\"\n :maxlength=\"!canExceedMaxLength ? maxLength : undefined\"\n :placeholder=\"placeholder\"\n :id=\"uniqueId\"\n class=\"form-control\"\n v-bind=\"field\"\n @input=\"onInput\"\n @change=\"onChange\"></textarea>\n <slot name=\"inputGroupAppend\" :isInputGroupSupported=\"true\" />\n </template>\n <template v-else-if=\"isClearable\">\n <template v-if=\"$slots.inputGroupPrepend || $slots.inputGroupAppend\">\n <slot name=\"inputGroupPrepend\" :isInputGroupSupported=\"true\" />\n <input :value=\"internalValue\"\n :id=\"uniqueId\"\n :type=\"type\"\n class=\"form-control\"\n :class=\"formControlClass\"\n style=\"display: table-cell;\"\n v-bind=\"field\"\n :maxlength=\"!canExceedMaxLength ? maxLength : undefined\"\n :placeholder=\"placeholder\"\n @input=\"onInput\"\n @change=\"onChange\" />\n <i v-if=\"internalValue\"\n class=\"fa fa-times text-muted clear-icon clear-position-with-slots\"\n @click=\"onClear\"></i>\n <slot name=\"inputGroupAppend\" :isInputGroupSupported=\"true\" />\n </template>\n <template v-else>\n <div class=\"input-container\">\n <input :value=\"internalValue\"\n :id=\"uniqueId\"\n :type=\"type\"\n :class=\"formControlClass\"\n v-bind=\"field\"\n :maxlength=\"!canExceedMaxLength ? maxLength : undefined\"\n :placeholder=\"placeholder\"\n @input=\"onInput\"\n @change=\"onChange\" />\n <i v-if=\"internalValue\"\n class=\"fa fa-times text-muted clear-icon\"\n @click=\"onClear\"></i>\n </div>\n </template>\n </template>\n <template v-else>\n <slot name=\"inputGroupPrepend\" :isInputGroupSupported=\"true\" />\n <input :value=\"internalValue\"\n :id=\"uniqueId\"\n :type=\"type\"\n :class=\"formControlClass\"\n v-bind=\"field\"\n :maxlength=\"!canExceedMaxLength ? maxLength : undefined\"\n :placeholder=\"placeholder\"\n @input=\"onInput\"\n @change=\"onChange\" />\n <slot name=\"inputGroupAppend\" :isInputGroupSupported=\"true\" />\n </template>\n </div>\n <slot name=\"append\" :isInputGroupSupported=\"true\" />\n </div>\n </template>\n </RockFormField>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, ref, useSlots, watch } from \"vue\";\n import { PropType } from \"vue\";\n import RockFormField from \"./rockFormField.obs\";\n import { standardRockFormFieldProps, useStandardRockFormFieldProps } from \"@Obsidian/Utility/component\";\n import type { ValidationRule } from \"@Obsidian/Types/validationRules\";\n import { normalizeRules } from \"@Obsidian/ValidationRules\";\n\n const props = defineProps({\n modelValue: {\n type: String as PropType<string>,\n required: true\n },\n /** Internal use to track what modifier flags were applied to modelValue. */\n modelModifiers: {\n type: Object as PropType<Record<string, boolean>>,\n default: () => ({})\n },\n type: {\n type: String as PropType<string>,\n default: \"text\"\n },\n maxLength: {\n type: Number as PropType<number>,\n default: 524288\n },\n showCountDown: {\n type: Boolean as PropType<boolean>,\n default: false\n },\n disableAutocomplete: {\n type: Boolean as PropType<boolean>,\n default: false\n },\n placeholder: {\n type: String as PropType<string>,\n default: null\n },\n inputClasses: {\n type: String as PropType<string>,\n default: \"\"\n },\n inputGroupClasses: {\n type: String as PropType<string>,\n default: \"\"\n },\n rows: {\n type: Number as PropType<number>,\n default: 3\n },\n textMode: {\n type: String as PropType<string>,\n default: \"\"\n },\n size: {\n type: String as PropType<\"small\" | \"medium\" | \"large\">,\n default: \"medium\"\n },\n allowHtml: {\n type: Boolean as PropType<boolean>,\n default: false\n },\n isClearable: {\n type: Boolean as PropType<boolean>,\n default: false,\n },\n /**\n * If `true`, then the max length can be exceeded; i.e., the max length is not enforced.\n *\n * This was added so showCountDown can display the remaining characters without limiting the\n * the textbox to a max number of characters.\n */\n canExceedMaxLength: {\n type: Boolean as PropType<boolean>,\n default: false\n },\n ...standardRockFormFieldProps\n });\n\n const emit = defineEmits<{\n (e: \"update:modelValue\", value: string): void;\n }>();\n\n const slots = useSlots();\n\n const internalValue = ref(props.modelValue);\n const fieldProps = useStandardRockFormFieldProps(props);\n\n const isTextarea = computed((): boolean => {\n return props.textMode?.toLowerCase() === \"multiline\";\n });\n\n const charsRemaining = computed((): number => {\n return props.maxLength - internalValue.value.length;\n });\n\n const countdownClass = computed((): string => {\n if (charsRemaining.value >= 10) {\n return \"badge-default\";\n }\n\n if (charsRemaining.value >= 0) {\n return \"badge-warning\";\n }\n\n return \"badge-danger\";\n });\n\n const isInputGroup = computed((): boolean => {\n return !!slots.inputGroupPrepend || !!slots.inputGroupAppend;\n });\n\n const controlContainerClass = computed((): Record<string, boolean> => {\n return {\n \"input-group col-xs-12\": isInputGroup.value,\n [props.inputGroupClasses]: isInputGroup.value,\n \"input-group-sm\": isInputGroup.value && props.size == \"small\",\n \"input-group-lg\": isInputGroup.value && props.size == \"large\"\n };\n });\n\n const formControlClass = computed((): Record<string, boolean> => {\n return {\n \"form-control\": true,\n [props.inputClasses]: true,\n \"input-sm\": props.size == \"small\",\n \"input-lg\": props.size == \"large\"\n };\n });\n\n const augmentedRules = computed((): ValidationRule[] => {\n const rules = normalizeRules(props.rules);\n\n if (!props.allowHtml) {\n rules.push(\"nohtml\");\n }\n\n return rules;\n });\n\n /**\n * Event handler for the input field having any modification to the value\n * happen. This is basically called on every key press.\n *\n * @param e The object that describes the event.\n */\n function onInput(e: Event): void {\n if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {\n internalValue.value = e.target.value;\n }\n\n // Lazy models do not get every single key press.\n if (!props.modelModifiers.lazy) {\n emit(\"update:modelValue\", internalValue.value);\n }\n }\n\n /**\n * Event handler for the input field when the changed value is \"committed\".\n * This is basically called when the focus leaves the input field.\n *\n * @param e The object that describes the event.\n */\n function onChange(e: Event): void {\n if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {\n internalValue.value = e.target.value;\n }\n\n // Only send the update if we didn't send it in the onInput handler.\n if (props.modelModifiers.lazy) {\n emit(\"update:modelValue\", internalValue.value);\n }\n }\n\n function onClear(): void {\n internalValue.value = \"\";\n emit(\"update:modelValue\", internalValue.value);\n }\n\n watch(() => props.modelValue, () => {\n internalValue.value = props.modelValue;\n });\n</script>\n\n<style scoped>\n.input-container {\n display: flex;\n align-items: center;\n}\n\n.clear-icon {\n margin-left: -34px;\n cursor: pointer;\n padding: 10px;\n}\n\n.clear-position-with-slots {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n z-index: 3;\n}\n</style>","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":["props","__props","emit","__emit","slots","useSlots","internalValue","ref","modelValue","fieldProps","useStandardRockFormFieldProps","isTextarea","computed","_props$textMode","textMode","toLowerCase","charsRemaining","maxLength","value","length","countdownClass","isInputGroup","inputGroupPrepend","inputGroupAppend","controlContainerClass","inputGroupClasses","size","formControlClass","inputClasses","augmentedRules","rules","normalizeRules","allowHtml","push","onInput","e","target","HTMLInputElement","HTMLTextAreaElement","modelModifiers","lazy","onChange","onClear","watch","styleInject","css","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8FI,IAAMA,KAAK,GAAGC,OAqEZ,CAAA;UAEF,IAAMC,IAAI,GAAGC,MAET,CAAA;MAEJ,IAAA,IAAMC,KAAK,GAAGC,QAAQ,EAAE,CAAA;MAExB,IAAA,IAAMC,aAAa,GAAGC,GAAG,CAACP,KAAK,CAACQ,UAAU,CAAC,CAAA;MAC3C,IAAA,IAAMC,UAAU,GAAGC,6BAA6B,CAACV,KAAK,CAAC,CAAA;MAEvD,IAAA,IAAMW,UAAU,GAAGC,QAAQ,CAAC,MAAe;MAAA,MAAA,IAAAC,eAAA,CAAA;MACvC,MAAA,OAAO,CAAAA,CAAAA,eAAA,GAAAb,KAAK,CAACc,QAAQ,MAAA,IAAA,IAAAD,eAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAdA,eAAA,CAAgBE,WAAW,EAAE,MAAK,WAAW,CAAA;MACxD,KAAC,CAAC,CAAA;MAEF,IAAA,IAAMC,cAAc,GAAGJ,QAAQ,CAAC,MAAc;YAC1C,OAAOZ,KAAK,CAACiB,SAAS,GAAGX,aAAa,CAACY,KAAK,CAACC,MAAM,CAAA;MACvD,KAAC,CAAC,CAAA;MAEF,IAAA,IAAMC,cAAc,GAAGR,QAAQ,CAAC,MAAc;MAC1C,MAAA,IAAII,cAAc,CAACE,KAAK,IAAI,EAAE,EAAE;MAC5B,QAAA,OAAO,eAAe,CAAA;MA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