{"version":3,"file":"textBox.js","sources":["../../../Framework/Controls/textBox.ts"],"sourcesContent":["// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\nimport { computed } from \"vue\";\r\nimport { defineComponent, PropType } from \"vue\";\r\nimport { useVModelPassthrough } from \"@Obsidian/Utility/component\";\r\nimport RockFormField from \"./rockFormField\";\r\n\r\nexport default defineComponent({\r\n name: \"TextBox\",\r\n components: {\r\n RockFormField\r\n },\r\n props: {\r\n modelValue: {\r\n type: String as PropType,\r\n required: true\r\n },\r\n type: {\r\n type: String as PropType,\r\n default: \"text\"\r\n },\r\n maxLength: {\r\n type: Number as PropType,\r\n default: 524288\r\n },\r\n showCountDown: {\r\n type: Boolean as PropType,\r\n default: false\r\n },\r\n placeholder: {\r\n type: String as PropType,\r\n default: \"\"\r\n },\r\n inputClasses: {\r\n type: String as PropType,\r\n default: \"\"\r\n },\r\n formGroupClasses: {\r\n type: String as PropType,\r\n default: \"\"\r\n },\r\n rows: {\r\n type: Number as PropType,\r\n default: 3\r\n },\r\n textMode: {\r\n type: String as PropType,\r\n default: \"\"\r\n }\r\n },\r\n emits: [\r\n \"update:modelValue\"\r\n ],\r\n setup(props, ctx) {\r\n const internalValue = useVModelPassthrough(props, \"modelValue\", ctx.emit);\r\n\r\n const isTextarea = computed((): boolean => {\r\n return props.textMode?.toLowerCase() === \"multiline\";\r\n });\r\n\r\n const charsRemaining = computed((): number => {\r\n return props.maxLength - internalValue.value.length;\r\n });\r\n\r\n const countdownClass = computed((): string => {\r\n if (charsRemaining.value >= 10) {\r\n return \"badge-default\";\r\n }\r\n\r\n if (charsRemaining.value >= 0) {\r\n return \"badge-warning\";\r\n }\r\n\r\n return \"badge-danger\";\r\n });\r\n\r\n const isInputGroup = computed((): boolean => {\r\n return !!ctx.slots.inputGroupPrepend || !!ctx.slots.inputGroupAppend;\r\n });\r\n\r\n const controlContainerClass = computed((): string => {\r\n return isInputGroup.value ? \"input-group\" : \"\";\r\n });\r\n\r\n return {\r\n controlContainerClass,\r\n internalValue,\r\n isTextarea,\r\n charsRemaining,\r\n countdownClass\r\n };\r\n },\r\n template: `\r\n\r\n \r\n \r\n {{charsRemaining}}\r\n \r\n \r\n \r\n