{"version":3,"file":"checkBoxList.js","sources":["../../../Framework/Controls/checkBoxList.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 { Guid } from \"@Obsidian/Types\";\r\nimport { computed, defineComponent, PropType, ref, watch } from \"vue\";\r\nimport { updateRefValue } from \"@Obsidian/Utility/component\";\r\nimport { ListItemBag } from \"@Obsidian/ViewModels/Utility/listItemBag\";\r\nimport RockFormField from \"./rockFormField\";\r\nimport { defaultControlCompareValue } from \"@Obsidian/Utility/stringUtils\";\r\n\r\nexport default defineComponent({\r\n name: \"CheckBoxList\",\r\n\r\n components: {\r\n RockFormField\r\n },\r\n\r\n props: {\r\n modelValue: {\r\n type: Array as PropType,\r\n default: []\r\n },\r\n\r\n disabled: {\r\n type: Boolean as PropType,\r\n required: false,\r\n default: false\r\n },\r\n\r\n items: {\r\n type: Array as PropType>,\r\n required: true\r\n },\r\n\r\n repeatColumns: {\r\n type: Number as PropType,\r\n default: 0\r\n },\r\n\r\n horizontal: {\r\n type: Boolean as PropType,\r\n default: false\r\n },\r\n\r\n compareValue: {\r\n type: Function as PropType<((value: string, itemValue: string) => boolean)>,\r\n default: defaultControlCompareValue\r\n }\r\n },\r\n\r\n emits: {\r\n \"update:modelValue\": (_value: string[]) => true\r\n },\r\n\r\n setup(props, { emit }) {\r\n const internalValue = ref([...props.modelValue]);\r\n\r\n const valueForItem = (item: ListItemBag): string => item.value ?? \"\";\r\n const textForItem = (item: ListItemBag): string => item.text ?? \"\";\r\n\r\n const uniqueIdForItem = (uniqueId: Guid, item: ListItemBag): string => `${uniqueId}-${(item.value ?? \"\").replace(\" \", \"-\")}`;\r\n\r\n const containerClasses = computed(() => {\r\n const classes: string[] = [];\r\n\r\n if (props.horizontal) {\r\n classes.push(\"rockcheckboxlist-horizontal\");\r\n\r\n if (props.repeatColumns > 0) {\r\n classes.push(`in-columns in-columns-${props.repeatColumns}`);\r\n }\r\n }\r\n else {\r\n classes.push(\"rockcheckboxlist-vertical input-group\");\r\n }\r\n\r\n return classes.join(\" \");\r\n });\r\n\r\n const syncInternalValue = (): void => {\r\n let value = [...props.modelValue];\r\n\r\n // Ensure they are all valid values and make sure they are the\r\n // correct matching value from the item rather than what was\r\n // originally provided.\r\n value = props.items\r\n .filter(o => value.some(v => props.compareValue(v, o.value ?? \"\")))\r\n .map(o => o.value ?? \"\");\r\n\r\n updateRefValue(internalValue, value);\r\n };\r\n\r\n watch([() => props.modelValue, () => props.items], () => {\r\n syncInternalValue();\r\n });\r\n\r\n watch(internalValue, () => {\r\n emit(\"update:modelValue\", internalValue.value);\r\n });\r\n\r\n syncInternalValue();\r\n\r\n return {\r\n containerClasses,\r\n internalValue,\r\n textForItem,\r\n uniqueIdForItem,\r\n valueForItem\r\n };\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","Array","default","disabled","Boolean","required","items","repeatColumns","Number","horizontal","compareValue","Function","defaultControlCompareValue","emits","_value","setup","_ref","emit","internalValue","ref","valueForItem","item","_item$value","value","textForItem","_item$text","text","uniqueIdForItem","uniqueId","_item$value2","concat","replace","containerClasses","computed","classes","push","join","syncInternalValue","filter","o","some","v","_o$value","map","_o$value2","updateRefValue","watch","template"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,kDAAeA,eAAe,CAAC;YAC3BC,EAAAA,IAAI,EAAE,cAAc;YAEpBC,EAAAA,UAAU,EAAE;YACRC,IAAAA,aAAAA;eACH;YAEDC,EAAAA,KAAK,EAAE;YACHC,IAA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