{"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`\r\n});\r\n"],"names":["defineComponent","name","components","RockFormField","props","modelValue","type","String","required","default","maxLength","Number","showCountDown","Boolean","placeholder","inputClasses","formGroupClasses","rows","textMode","emits","setup","ctx","internalValue","useVModelPassthrough","emit","isTextarea","computed","_props$textMode","toLowerCase","charsRemaining","value","length","countdownClass","isInputGroup","slots","inputGroupPrepend","inputGroupAppend","controlContainerClass","template"],"mappings":";;;;;;;;;;;;;;AAqBA,6CAAeA,eAAe,CAAC;YAC3BC,EAAAA,IAAI,EAAE,SAAS;YACfC,EAAAA,UAAU,EAAE;YACRC,IAAAA,aAAAA;eACH;YACDC,EAAAA,KAAK,EAAE;YACHC,IAAAA,UAAU,EAAE;YACRC,MAAAA,IAAI,EAAEC,MAA0B;YAChCC,MAAAA,QAAQ,EAAE,IAAA;iBACb;YACDF,IAAAA,IAAI,EAAE;YACFA,MAAAA,IAAI,EAAEC,MAA0B;YAChCE,MAAAA,OAAO,EAAE,MAAA;iBACZ;YACDC,IAAAA,SAAS,EAAE;YACPJ,MAAAA,IAAI,EAAEK,MAA0B;YAChCF,MAAAA,OAAO,EAAE,MAAA;iBACZ;YACDG,IAAAA,aAAa,EAAE;YACXN,MAAAA,IAAI,EAAEO,OAA4B;YAClCJ,MAAAA,OAAO,EAAE,KAAA;iBACZ;YACDK,IAAAA,WAAW,EAAE;YACTR,MAAAA,IAAI,EAAEC,MAA0B;YAChCE,MAAAA,OAAO,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