{"version":3,"file":"textFieldComponents.js","sources":["../../../Framework/FieldTypes/textField.partial.ts","../../../Framework/FieldTypes/textFieldComponents.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\n\r\nimport { Component } from \"vue\";\r\nimport { defineAsyncComponent } from \"@Obsidian/Utility/component\";\r\nimport { ComparisonType } from \"@Obsidian/Enums/Reporting/comparisonType\";\r\nimport { stringComparisonTypes } from \"@Obsidian/Core/Reporting/comparisonType\";\r\nimport { FieldTypeBase } from \"./fieldType\";\r\n\r\nexport const enum ConfigurationValueKey {\r\n /** Contains \"True\" if the text field is designed for password entry. */\r\n IsPassword = \"ispassword\",\r\n\r\n /** The maximum number of characters allowed in the text entry field. */\r\n MaxCharacters = \"maxcharacters\",\r\n\r\n /** Contains \"True\" if the text field should show the character countdown. */\r\n ShowCountdown = \"showcountdown\"\r\n}\r\n\r\n// The configuration component can be quite large, so load it only as needed.\r\nconst configurationComponent = defineAsyncComponent(async () => {\r\n return (await import(\"./textFieldComponents\")).ConfigurationComponent;\r\n});\r\n\r\nexport class TextFieldType extends FieldTypeBase {\r\n public override getConfigurationComponent(): Component {\r\n return configurationComponent;\r\n }\r\n\r\n public override getSupportedComparisonTypes(): ComparisonType {\r\n return stringComparisonTypes;\r\n }\r\n}\r\n","// \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, defineComponent, ref, watch } from \"vue\";\r\nimport { getFieldConfigurationProps, getFieldEditorProps } from \"./utils\";\r\nimport TextBox from \"@Obsidian/Controls/textBox\";\r\nimport CheckBox from \"@Obsidian/Controls/checkBox\";\r\nimport NumberBox from \"@Obsidian/Controls/numberBox\";\r\nimport { asBoolean, asBooleanOrNull, asTrueFalseOrNull } from \"@Obsidian/Utility/booleanUtils\";\r\nimport { ConfigurationValueKey } from \"./textField.partial\";\r\nimport { toNumberOrNull } from \"@Obsidian/Utility/numberUtils\";\r\n\r\nexport const EditComponent = defineComponent({\r\n name: \"TextField.Edit\",\r\n\r\n components: {\r\n TextBox\r\n },\r\n\r\n props: getFieldEditorProps(),\r\n\r\n setup(props, { emit }) {\r\n // The internal value used by the text editor.\r\n const internalValue = ref(\"\");\r\n\r\n // Configuration attributes passed to the text editor.\r\n const configAttributes = computed((): Record => {\r\n const attributes: Record = {};\r\n\r\n const maxCharsConfig = props.configurationValues[ConfigurationValueKey.MaxCharacters];\r\n if (maxCharsConfig) {\r\n const maxCharsValue = Number(maxCharsConfig);\r\n\r\n if (maxCharsValue) {\r\n attributes.maxLength = maxCharsValue;\r\n }\r\n }\r\n\r\n const showCountDownConfig = props.configurationValues[ConfigurationValueKey.ShowCountdown];\r\n if (showCountDownConfig && showCountDownConfig) {\r\n const showCountDownValue = asBooleanOrNull(showCountDownConfig) || false;\r\n\r\n if (showCountDownValue) {\r\n attributes.showCountDown = showCountDownValue;\r\n }\r\n }\r\n\r\n return attributes;\r\n });\r\n\r\n // The type of text input field to use on the text editor.\r\n const textType = computed((): string => {\r\n const isPasswordConfig = props.configurationValues[ConfigurationValueKey.IsPassword];\r\n const isPassword = asBooleanOrNull(isPasswordConfig) ?? false;\r\n\r\n return isPassword ? \"password\" : \"\";\r\n\r\n });\r\n\r\n // Watch for changes from the parent component and update the text editor.\r\n watch(() => props.modelValue, () => {\r\n internalValue.value = props.modelValue;\r\n }, {\r\n immediate: true\r\n });\r\n\r\n // Watch for changes from the text editor and update the parent component.\r\n watch(internalValue, () => {\r\n emit(\"update:modelValue\", internalValue.value);\r\n });\r\n\r\n return {\r\n configAttributes,\r\n internalValue,\r\n textType\r\n };\r\n },\r\n\r\n template: `\r\n\r\n`\r\n});\r\n\r\nexport const ConfigurationComponent = defineComponent({\r\n name: \"TextField.Configuration\",\r\n\r\n components: {\r\n CheckBox,\r\n NumberBox\r\n },\r\n\r\n props: getFieldConfigurationProps(),\r\n\r\n emits: [\"update:modelValue\", \"updateConfiguration\", \"updateConfigurationValue\" ],\r\n\r\n setup(props, { emit }) {\r\n // Define the properties that will hold the current selections.\r\n const passwordField = ref(false);\r\n const maxCharacters = ref(null);\r\n const showCountdown = ref(false);\r\n\r\n /**\r\n * Update the modelValue property if any value of the dictionary has\r\n * actually changed. This helps prevent unwanted postbacks if the value\r\n * didn't really change - which can happen if multiple values get updated\r\n * at the same time.\r\n *\r\n * @returns true if a new modelValue was emitted to the parent component.\r\n */\r\n const maybeUpdateModelValue = (): boolean => {\r\n const newValue: Record = {};\r\n\r\n // Construct the new value that will be emitted if it is different\r\n // than the current value.\r\n newValue[ConfigurationValueKey.IsPassword] = asTrueFalseOrNull(passwordField.value) ?? \"False\";\r\n newValue[ConfigurationValueKey.MaxCharacters] = maxCharacters.value?.toString() ?? \"\";\r\n newValue[ConfigurationValueKey.ShowCountdown] = asTrueFalseOrNull(showCountdown.value) ?? \"False\";\r\n\r\n // Compare the new value and the old value.\r\n const anyValueChanged = newValue[ConfigurationValueKey.IsPassword] !== (props.modelValue[ConfigurationValueKey.IsPassword] ?? \"False\")\r\n || newValue[ConfigurationValueKey.MaxCharacters] !== (props.modelValue[ConfigurationValueKey.MaxCharacters] ?? \"\")\r\n || newValue[ConfigurationValueKey.ShowCountdown] !== (props.modelValue[ConfigurationValueKey.ShowCountdown] ?? \"False\");\r\n\r\n // If any value changed then emit the new model value.\r\n if (anyValueChanged) {\r\n emit(\"update:modelValue\", newValue);\r\n return true;\r\n }\r\n else {\r\n return false;\r\n }\r\n };\r\n\r\n /**\r\n * Emits the updateConfigurationValue if the value has actually changed.\r\n * \r\n * @param key The key that was possibly modified.\r\n * @param value The new value.\r\n */\r\n const maybeUpdateConfiguration = (key: string, value: string): void => {\r\n if (maybeUpdateModelValue()) {\r\n emit(\"updateConfigurationValue\", key, value);\r\n }\r\n };\r\n\r\n // Watch for changes coming in from the parent component and update our\r\n // data to match the new information.\r\n watch(() => [props.modelValue, props.configurationProperties], () => {\r\n passwordField.value = asBoolean(props.modelValue[ConfigurationValueKey.IsPassword]);\r\n maxCharacters.value = toNumberOrNull(props.modelValue[ConfigurationValueKey.MaxCharacters]);\r\n showCountdown.value = asBoolean(props.modelValue[ConfigurationValueKey.ShowCountdown]);\r\n }, {\r\n immediate: true\r\n });\r\n\r\n // Watch for changes in properties that require new configuration\r\n // properties to be retrieved from the server.\r\n // THIS IS JUST A PLACEHOLDER FOR COPYING TO NEW FIELDS THAT MIGHT NEED IT.\r\n // THIS FIELD DOES NOT NEED THIS\r\n watch([], () => {\r\n if (maybeUpdateModelValue()) {\r\n emit(\"updateConfiguration\");\r\n }\r\n });\r\n\r\n // Watch for changes in properties that only require a local UI update.\r\n watch(passwordField, () => maybeUpdateConfiguration(ConfigurationValueKey.IsPassword, asTrueFalseOrNull(passwordField.value) ?? \"False\"));\r\n watch(maxCharacters, () => maybeUpdateConfiguration(ConfigurationValueKey.MaxCharacters, maxCharacters.value?.toString() ?? \"\"));\r\n watch(showCountdown, () => maybeUpdateConfiguration(ConfigurationValueKey.ShowCountdown, asTrueFalseOrNull(showCountdown.value) ?? \"False\"));\r\n\r\n return {\r\n maxCharacters,\r\n passwordField,\r\n showCountdown\r\n };\r\n },\r\n\r\n template: `\r\n
\r\n \r\n \r\n \r\n
\r\n`\r\n});\r\n"],"names":["ConfigurationValueKey","defineAsyncComponent","_asyncToGenerator","ConfigurationComponent","EditComponent","defineComponent","name","components","TextBox","props","getFieldEditorProps","setup","_ref","emit","internalValue","ref","configAttributes","computed","attributes","maxCharsConfig","configurationValues","MaxCharacters","maxCharsValue","Number","maxLength","showCountDownConfig","ShowCountdown","showCountDownValue","asBooleanOrNull","showCountDown","textType","_asBooleanOrNull","isPasswordConfig","IsPassword","isPassword","watch","modelValue","value","immediate","template","CheckBox","NumberBox","getFieldConfigurationProps","emits","_ref2","passwordField","maxCharacters","showCountdown","maybeUpdateModelValue","_asTrueFalseOrNull","_maxCharacters$value$","_maxCharacters$value","_asTrueFalseOrNull2","_props$modelValue$Con","_props$modelValue$Con2","_props$modelValue$Con3","newValue","asTrueFalseOrNull","toString","anyValueChanged","maybeUpdateConfiguration","key","configurationProperties","asBoolean","toNumberOrNull","_asTrueFalseOrNull3","_maxCharacters$value$2","_maxCharacters$value2","_asTrueFalseOrNull4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuBkBA,IAAAA,qBAAqB,aAArBA,qBAAqB,EAAA;QAArBA,qBAAqB,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;QAArBA,qBAAqB,CAAA,eAAA,CAAA,GAAA,eAAA,CAAA;QAArBA,qBAAqB,CAAA,eAAA,CAAA,GAAA,eAAA,CAAA;MAAA,EAAA,OAArBA,qBAAqB,CAAA;MAAA,CAAA,CAAA,EAAA,CAAA,CAAA;MAYRC,oBAAoB,CAAAC,iBAAA,CAAC,aAAY;MAC5D,EAAA,OAAO,OAAO,cAAO,uBAAuB,CAAC,EAAEC,sBAAsB,CAAA;MACzE,CAAC,CAAC;;ACZWC,UAAAA,aAAa,4BAAGC,eAAe,CAAC;MACzCC,EAAAA,IAAI,EAAE,gBAAgB;MAEtBC,EAAAA,UAAU,EAAE;MACRC,IAAAA,OAAAA;SACH;QAEDC,KAAK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