@energysage/es-ds-components 3.6.2 → 3.7.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.7.1](https://github.com/EnergySage/es-ds/compare/es-ds-components-v3.7.0...es-ds-components-v3.7.1) (2025-09-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * account for object array in isSelected ([#1663](https://github.com/EnergySage/es-ds/issues/1663)) ([d34ce8a](https://github.com/EnergySage/es-ds/commit/d34ce8a0b2935cfe9621a54b85cac88f95a5a314))
9
+
10
+ ## [3.7.0](https://github.com/EnergySage/es-ds/compare/es-ds-components-v3.6.2...es-ds-components-v3.7.0) (2025-09-04)
11
+
12
+
13
+ ### Features
14
+
15
+ * dropdown tweaks ([#1660](https://github.com/EnergySage/es-ds/issues/1660)) ([42ffeac](https://github.com/EnergySage/es-ds/commit/42ffeac51b89969cd55b936d744be598e769e1a5))
16
+
3
17
  ## [3.6.2](https://github.com/EnergySage/es-ds/compare/es-ds-components-v3.6.1...es-ds-components-v3.6.2) (2025-08-25)
4
18
 
5
19
 
@@ -5,6 +5,7 @@ interface Props {
5
5
  disabled?: boolean;
6
6
  label?: string;
7
7
  modelValue?: any;
8
+ noOptionsText?: string;
8
9
  options?: string[] | { label: string; value: string }[];
9
10
  placeholder?: string;
10
11
  required?: boolean;
@@ -13,6 +14,7 @@ interface Props {
13
14
  const props = withDefaults(defineProps<Props>(), {
14
15
  disabled: false,
15
16
  modelValue: undefined,
17
+ noOptionsText: 'No available options',
16
18
  options: () => [],
17
19
  placeholder: '',
18
20
  label: '',
@@ -29,8 +31,12 @@ const isOpen = ref(false);
29
31
  const isFocused = ref(false);
30
32
  const isInputClicked = ref(false);
31
33
  const isLabelClicked = ref(false);
34
+ const isDisabled = computed(() => props.disabled || props.options.length === 0);
32
35
 
33
- const isSelected = (option: any) => option === props.modelValue;
36
+ const isSelected = (option: any) => {
37
+ const compareOption = typeof option === 'object' ? option.value : option;
38
+ return compareOption === props.modelValue;
39
+ };
34
40
 
35
41
  const id = useId();
36
42
  const labelId = useId();
@@ -72,29 +78,30 @@ const hide = () => {
72
78
  <dropdown
73
79
  :input-id="id"
74
80
  :class="[
75
- 'es-dropdown es-form-input form-control d-flex align-items-center justify-content-between',
81
+ 'es-dropdown es-form-input form-control align-items-center d-flex justify-content-between position-relative',
76
82
  {
77
- disabled: disabled,
83
+ disabled: isDisabled,
78
84
  focused: isFocused && !isInputClicked && !isOpen && !isLabelClicked,
79
85
  'focused-on-click': isOpen || isLabelClicked || isInputClicked,
80
86
  'is-invalid': state === false,
81
87
  },
82
88
  ]"
89
+ append-to="self"
83
90
  :aria-labelledby="labelId"
84
- :disabled="disabled"
91
+ :disabled="isDisabled"
85
92
  :focus-on-hover="false"
86
93
  :model-value="modelValue"
87
94
  :option-label="options.length > 0 && typeof options[0] === 'object' ? 'label' : undefined"
88
95
  :option-value="options.length > 0 && typeof options[0] === 'object' ? 'value' : undefined"
89
96
  :options="options"
90
- :placeholder="placeholder"
97
+ :placeholder="options.length === 0 ? props.noOptionsText : placeholder"
91
98
  :pt="{
92
- panel: { class: 'es-dropdown-panel bg-white rounded-xs' },
99
+ panel: { class: 'es-dropdown-panel bg-white rounded-xs w-100' },
93
100
  wrapper: { class: 'es-dropdown-wrapper' },
94
- list: { class: 'p-0 m-0 list-unstyled' },
101
+ list: { class: 'list-unstyled m-0 p-0' },
95
102
  input: {
96
103
  class: [
97
- 'es-dropdown-input',
104
+ 'es-dropdown-input h-100 text-truncate',
98
105
  {
99
106
  'es-dropdown-input--placeholder': modelValue === undefined && state !== false,
100
107
  },
@@ -102,12 +109,13 @@ const hide = () => {
102
109
  },
103
110
  item: {
104
111
  class: [
105
- 'es-dropdown-item d-flex justify-content-between p-100 pl-200',
112
+ 'es-dropdown-item align-items-center d-flex justify-content-between p-100 pl-200 position-relative',
106
113
  {
107
114
  'input-focused position-relative': isFocused && !isInputClicked && !isLabelClicked,
108
115
  },
109
116
  ],
110
117
  },
118
+ trigger: { class: 'h-100' },
111
119
  }"
112
120
  scroll-height="15.75rem"
113
121
  v-bind="$attrs"
@@ -123,17 +131,19 @@ const hide = () => {
123
131
  height="1.125rem"
124
132
  :class="[
125
133
  {
126
- 'text-gray-500': disabled,
127
- 'text-gray-900': !disabled && state !== false,
134
+ 'text-gray-500': isDisabled,
135
+ 'text-gray-900': !isDisabled && state !== false,
128
136
  },
129
137
  ]" />
130
138
  </template>
131
139
  <template #option="slotProps">
132
- <span>{{ slotProps.option.label ? slotProps.option.label : slotProps.option }}</span>
140
+ <span class="option-label pr-200">{{
141
+ slotProps.option.label ? slotProps.option.label : slotProps.option
142
+ }}</span>
133
143
  <icon-check
134
144
  v-if="isSelected(slotProps.option)"
135
145
  height="1.5rem"
136
- class="text-gray-700" />
146
+ class="icon-check position-absolute text-gray-700" />
137
147
  </template>
138
148
  </dropdown>
139
149
  <small
@@ -220,6 +230,14 @@ const hide = () => {
220
230
  cursor: pointer;
221
231
  transition: background-color 0.15s ease-in-out;
222
232
 
233
+ .icon-check {
234
+ right: 1rem;
235
+ }
236
+
237
+ .option-label {
238
+ overflow-wrap: anywhere;
239
+ }
240
+
223
241
  &:hover,
224
242
  &:not(.input-focused)[data-p-focused='true'] {
225
243
  background-color: variables.$blue-50;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@energysage/es-ds-components",
3
- "version": "3.6.2",
3
+ "version": "3.7.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "An EnergySage Vue component library",