quasar-ui-danx 0.3.29 → 0.3.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.3.29",
3
+ "version": "0.3.31",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -69,74 +69,74 @@ import { ContentDrawer } from "../../../Utility";
69
69
 
70
70
  const emit = defineEmits(["update:modelValue"]);
71
71
  const props = defineProps({
72
- modelValue: {
73
- type: [Object, String, Array, null],
74
- required: true
75
- },
76
- options: {
77
- type: Array,
78
- default: () => []
79
- },
80
- multiple: Boolean,
81
- label: {
82
- type: String,
83
- default: "Select"
84
- },
85
- placeholder: {
86
- type: String,
87
- default: "All"
88
- }
72
+ modelValue: {
73
+ type: [Object, String, Array, null],
74
+ required: true
75
+ },
76
+ options: {
77
+ type: Array,
78
+ default: () => []
79
+ },
80
+ multiple: Boolean,
81
+ label: {
82
+ type: String,
83
+ default: "Select"
84
+ },
85
+ placeholder: {
86
+ type: String,
87
+ default: "All"
88
+ }
89
89
  });
90
90
 
91
91
  const showDrawer = ref(false);
92
92
  const formattedOptions = computed(() =>
93
- props.options.map((opt) =>
94
- typeof opt === "string"
95
- ? {
96
- label: opt,
97
- value: opt
98
- }
99
- : opt
100
- )
93
+ props.options.map((opt) =>
94
+ typeof opt === "string"
95
+ ? {
96
+ label: opt,
97
+ value: opt
98
+ }
99
+ : opt
100
+ )
101
101
  );
102
102
 
103
103
  function getOptionValue(option) {
104
- return option.value === undefined ? option : option.value;
104
+ return option.value === undefined ? option : option.value;
105
105
  }
106
106
 
107
107
  function getOptionLabel(value) {
108
- return formattedOptions.value.find((opt) => opt.value === value).label;
108
+ return formattedOptions.value.find((opt) => opt.value === value)?.label;
109
109
  }
110
110
 
111
111
  function isSelected(option) {
112
- const optionValue = getOptionValue(option);
112
+ const optionValue = getOptionValue(option);
113
113
 
114
- if (props.multiple) {
115
- return props.modelValue.includes(optionValue);
116
- } else {
117
- return props.modelValue === optionValue;
118
- }
114
+ if (props.multiple) {
115
+ return props.modelValue.includes(optionValue);
116
+ } else {
117
+ return props.modelValue === optionValue;
118
+ }
119
119
  }
120
120
 
121
121
  function toggleSelect(option) {
122
- let optionValue = getOptionValue(option);
122
+ let optionValue = getOptionValue(option);
123
123
 
124
- let selection = optionValue;
124
+ let selection = optionValue;
125
125
 
126
- if (props.multiple) {
127
- selection = [...props.modelValue];
128
- if (isSelected(optionValue)) {
129
- selection = selection.filter((opt) => opt !== optionValue);
130
- } else {
131
- selection.push(optionValue);
132
- }
133
- } else {
134
- // Allow deselection on single select
135
- if (selection === props.modelValue) {
136
- selection = null;
137
- }
138
- }
126
+ if (props.multiple) {
127
+ selection = [...props.modelValue];
128
+ if (isSelected(optionValue)) {
129
+ selection = selection.filter((opt) => opt !== optionValue);
130
+ } else {
131
+ selection.push(optionValue);
132
+ }
133
+ } else {
134
+ // Allow deselection on single select
135
+ if (selection === props.modelValue) {
136
+ selection = null;
137
+ }
138
+ }
139
139
 
140
- emit("update:modelValue", selection);
140
+ emit("update:modelValue", selection);
141
141
  }
142
142
  </script>