ads-nuxt 0.6.1 → 0.6.3
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.
|
@@ -147,7 +147,7 @@ const props = withDefaults(
|
|
|
147
147
|
panelWidthClass?: string;
|
|
148
148
|
/**
|
|
149
149
|
* Ação de cadastrar no rodapé da lista, com ícone de adicionar. `{query}` vira a busca atual,
|
|
150
|
-
* ex.: "Cadastrar {query}". Sem valor, a ação não aparece.
|
|
150
|
+
* ex.: "Cadastrar {query}". Sem valor, com busca vazia ou com texto igual a uma opção, a ação não aparece.
|
|
151
151
|
*/
|
|
152
152
|
addLabel?: string;
|
|
153
153
|
}>(),
|
|
@@ -108,7 +108,12 @@ const dividerClass =
|
|
|
108
108
|
|
|
109
109
|
const surfaceClass = computed(() => {
|
|
110
110
|
if (props.disabled) return "cursor-not-allowed bg-[var(--ads-surface-card)]";
|
|
111
|
-
if (props.mode === "radio" && props.selected)
|
|
111
|
+
if (props.mode === "radio" && props.selected) {
|
|
112
|
+
/** Figma pinta o item de sugestão com innovation/100 a 30%. O sólido equivalente é surface/ai. */
|
|
113
|
+
return props.badge?.tone === "ai"
|
|
114
|
+
? "bg-[var(--ads-surface-ai)]"
|
|
115
|
+
: "bg-[var(--ads-select-item-selected)]";
|
|
116
|
+
}
|
|
112
117
|
return "bg-[var(--ads-surface-card)] hover:bg-[var(--ads-select-item-hover)] focus-visible:bg-[var(--ads-select-item-hover)]";
|
|
113
118
|
});
|
|
114
119
|
|
|
@@ -125,7 +125,7 @@ const props = withDefaults(
|
|
|
125
125
|
widthClass?: string;
|
|
126
126
|
/**
|
|
127
127
|
* Ação de cadastrar no rodapé, com ícone de adicionar. `{query}` vira a busca atual.
|
|
128
|
-
* Sem valor, a ação não aparece.
|
|
128
|
+
* Sem valor, com busca vazia ou com texto igual a uma opção, a ação não aparece.
|
|
129
129
|
*/
|
|
130
130
|
addLabel?: string;
|
|
131
131
|
}>(),
|
|
@@ -148,11 +148,22 @@ const emit = defineEmits<{
|
|
|
148
148
|
add: [query: string];
|
|
149
149
|
}>();
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
const queryMatchesOption = (typed: string): boolean => {
|
|
152
|
+
const key = typed.toLocaleLowerCase("pt-BR");
|
|
153
|
+
return props.options.some((option) => {
|
|
154
|
+
const label = option.label.trim().toLocaleLowerCase("pt-BR");
|
|
155
|
+
const value = String(option.value).trim().toLocaleLowerCase("pt-BR");
|
|
156
|
+
return label === key || value === key;
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/** A ação só aparece com texto na busca e se esse texto ainda não é uma opção. */
|
|
152
161
|
const addText = computed(() => {
|
|
153
162
|
if (!props.addLabel) return "";
|
|
154
|
-
const
|
|
155
|
-
|
|
163
|
+
const typed = query.value.trim();
|
|
164
|
+
if (props.addLabel.includes("{query}") && !typed) return "";
|
|
165
|
+
if (typed && queryMatchesOption(typed)) return "";
|
|
166
|
+
return props.addLabel.replaceAll("{query}", typed).replace(/\s+/g, " ").trim();
|
|
156
167
|
});
|
|
157
168
|
|
|
158
169
|
const groups = computed(() => groupFilterOptions(props.options, query.value));
|