matcha-components 20.84.0 → 20.88.0

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.
@@ -2291,7 +2291,7 @@ class MatchaLabelComponent {
2291
2291
  if (formField) {
2292
2292
  // Busca por elementos nativos e componentes customizados com required
2293
2293
  const inputElement = formField.querySelector('input[required], textarea[required], select[required], ' +
2294
- 'matcha-select[required], matcha-autocomplete[required]');
2294
+ 'matcha-select[required], matcha-autocomplete[required], matcha-date[required]');
2295
2295
  this.isRequired = !!inputElement;
2296
2296
  }
2297
2297
  }
@@ -3122,6 +3122,67 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
3122
3122
  args: ['keydown', ['$event']]
3123
3123
  }] } });
3124
3124
 
3125
+ class MatchaDateComponent {
3126
+ constructor() {
3127
+ this.placeholder = 'Selecione uma data';
3128
+ this.min = '';
3129
+ this.max = '';
3130
+ this.disabled = false;
3131
+ this.value = '';
3132
+ this.isDisabled = false;
3133
+ // ControlValueAccessor methods
3134
+ this.onChange = (value) => { };
3135
+ this.onTouched = () => { };
3136
+ }
3137
+ writeValue(value) {
3138
+ this.value = value || '';
3139
+ }
3140
+ registerOnChange(fn) {
3141
+ this.onChange = fn;
3142
+ }
3143
+ registerOnTouched(fn) {
3144
+ this.onTouched = fn;
3145
+ }
3146
+ setDisabledState(isDisabled) {
3147
+ this.isDisabled = isDisabled;
3148
+ this.disabled = isDisabled;
3149
+ }
3150
+ onInputChange(event) {
3151
+ const input = event.target;
3152
+ this.value = input.value;
3153
+ this.onChange(this.value);
3154
+ }
3155
+ onBlur() {
3156
+ this.onTouched();
3157
+ }
3158
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
3159
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: MatchaDateComponent, isStandalone: false, selector: "matcha-date", inputs: { placeholder: "placeholder", min: "min", max: "max", disabled: "disabled" }, providers: [
3160
+ {
3161
+ provide: NG_VALUE_ACCESSOR,
3162
+ useExisting: forwardRef(() => MatchaDateComponent),
3163
+ multi: true
3164
+ }
3165
+ ], ngImport: i0, template: "<input\n type=\"date\"\n class=\"matcha-date-input\"\n [value]=\"value\"\n [placeholder]=\"placeholder\"\n [min]=\"min\"\n [max]=\"max\"\n [disabled]=\"disabled || isDisabled\"\n (input)=\"onInputChange($event)\"\n (blur)=\"onBlur()\"\n/>\n\n", styles: [""], encapsulation: i0.ViewEncapsulation.None }); }
3166
+ }
3167
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateComponent, decorators: [{
3168
+ type: Component,
3169
+ args: [{ selector: 'matcha-date', encapsulation: ViewEncapsulation.None, standalone: false, providers: [
3170
+ {
3171
+ provide: NG_VALUE_ACCESSOR,
3172
+ useExisting: forwardRef(() => MatchaDateComponent),
3173
+ multi: true
3174
+ }
3175
+ ], template: "<input\n type=\"date\"\n class=\"matcha-date-input\"\n [value]=\"value\"\n [placeholder]=\"placeholder\"\n [min]=\"min\"\n [max]=\"max\"\n [disabled]=\"disabled || isDisabled\"\n (input)=\"onInputChange($event)\"\n (blur)=\"onBlur()\"\n/>\n\n" }]
3176
+ }], propDecorators: { placeholder: [{
3177
+ type: Input
3178
+ }], min: [{
3179
+ type: Input
3180
+ }], max: [{
3181
+ type: Input
3182
+ }], disabled: [{
3183
+ type: Input
3184
+ }] } });
3185
+
3125
3186
  class MatchaDateRangeComponent {
3126
3187
  constructor() {
3127
3188
  this.startDateControl = null;
@@ -3150,42 +3211,83 @@ class MatchaDateRangeComponent {
3150
3211
  validateDateRange() {
3151
3212
  if (!this.startDateControl || !this.endDateControl)
3152
3213
  return;
3153
- if (!this.startDateControl.value || !this.endDateControl.value)
3214
+ const startValue = this.startDateControl.value;
3215
+ const endValue = this.endDateControl.value;
3216
+ // Se ambos os campos estão vazios, não valida
3217
+ if (!startValue && !endValue) {
3218
+ this.clearDateRangeErrors();
3154
3219
  return;
3220
+ }
3221
+ // Se apenas um campo está preenchido, limpa erros de intervalo
3222
+ if (!startValue || !endValue) {
3223
+ this.clearDateRangeErrors();
3224
+ return;
3225
+ }
3155
3226
  // Validação de formato de data (YYYY-MM-DD)
3156
3227
  const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
3157
- if (!dateRegex.test(this.startDateControl.value)) {
3158
- this.startDateControl.setErrors({ ['invalidDateFormat']: true });
3228
+ if (!dateRegex.test(startValue)) {
3229
+ this.startDateControl.setErrors({
3230
+ ...this.startDateControl.errors,
3231
+ ['invalidDateFormat']: true
3232
+ });
3159
3233
  return;
3160
3234
  }
3161
- if (!dateRegex.test(this.endDateControl.value)) {
3162
- this.endDateControl.setErrors({ ['invalidDateFormat']: true });
3235
+ if (!dateRegex.test(endValue)) {
3236
+ this.endDateControl.setErrors({
3237
+ ...this.endDateControl.errors,
3238
+ ['invalidDateFormat']: true
3239
+ });
3163
3240
  return;
3164
3241
  }
3165
- const startDate = new Date(this.startDateControl.value);
3166
- const endDate = new Date(this.endDateControl.value);
3242
+ const startDate = new Date(startValue);
3243
+ const endDate = new Date(endValue);
3167
3244
  // Verifica se as datas são válidas
3168
3245
  if (isNaN(startDate.getTime())) {
3169
- this.startDateControl.setErrors({ ['invalidDate']: true });
3246
+ this.startDateControl.setErrors({
3247
+ ...this.startDateControl.errors,
3248
+ ['invalidDate']: true
3249
+ });
3170
3250
  return;
3171
3251
  }
3172
3252
  if (isNaN(endDate.getTime())) {
3173
- this.endDateControl.setErrors({ ['invalidDate']: true });
3253
+ this.endDateControl.setErrors({
3254
+ ...this.endDateControl.errors,
3255
+ ['invalidDate']: true
3256
+ });
3174
3257
  return;
3175
3258
  }
3259
+ // Validação principal: data inicial não pode ser posterior à data final
3176
3260
  if (startDate > endDate) {
3177
3261
  // Adiciona erros quando a data inicial é posterior à final
3178
- this.startDateControl.setErrors({ ['startAfterEnd']: true });
3179
- this.endDateControl.setErrors({ ['endBeforeStart']: true });
3262
+ this.startDateControl.setErrors({
3263
+ ...this.startDateControl.errors,
3264
+ ['dateRangeInvalid']: true
3265
+ });
3266
+ this.endDateControl.setErrors({
3267
+ ...this.endDateControl.errors,
3268
+ ['dateRangeInvalid']: true
3269
+ });
3180
3270
  }
3181
3271
  else {
3182
- // Remove apenas nossos erros específicos
3183
- this.removeSpecificError(this.startDateControl, 'startAfterEnd');
3184
- this.removeSpecificError(this.endDateControl, 'endBeforeStart');
3272
+ // Remove apenas nossos erros específicos se o intervalo está correto
3273
+ this.clearDateRangeErrors();
3274
+ }
3275
+ }
3276
+ /**
3277
+ * Limpa apenas os erros relacionados ao intervalo de datas
3278
+ */
3279
+ clearDateRangeErrors() {
3280
+ if (this.startDateControl) {
3281
+ this.removeSpecificError(this.startDateControl, 'dateRangeInvalid');
3185
3282
  this.removeSpecificError(this.startDateControl, 'invalidDateFormat');
3186
- this.removeSpecificError(this.endDateControl, 'invalidDateFormat');
3187
3283
  this.removeSpecificError(this.startDateControl, 'invalidDate');
3284
+ this.removeSpecificError(this.startDateControl, 'startAfterEnd');
3285
+ }
3286
+ if (this.endDateControl) {
3287
+ this.removeSpecificError(this.endDateControl, 'dateRangeInvalid');
3288
+ this.removeSpecificError(this.endDateControl, 'invalidDateFormat');
3188
3289
  this.removeSpecificError(this.endDateControl, 'invalidDate');
3290
+ this.removeSpecificError(this.endDateControl, 'endBeforeStart');
3189
3291
  }
3190
3292
  }
3191
3293
  /**
@@ -3199,11 +3301,11 @@ class MatchaDateRangeComponent {
3199
3301
  }
3200
3302
  }
3201
3303
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateRangeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
3202
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: MatchaDateRangeComponent, isStandalone: false, selector: "matcha-date-range", queries: [{ propertyName: "controls", predicate: NgControl, descendants: true }], ngImport: i0, template: "<div class=\"d-flex gap-16\">\n <ng-content></ng-content>\n</div>\n", styles: [""] }); }
3304
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: MatchaDateRangeComponent, isStandalone: false, selector: "matcha-date-range", queries: [{ propertyName: "controls", predicate: NgControl, descendants: true }], ngImport: i0, template: "<div class=\"matcha-date-range-container\">\n <ng-content></ng-content>\n</div>\n", styles: [""] }); }
3203
3305
  }
3204
3306
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateRangeComponent, decorators: [{
3205
3307
  type: Component,
3206
- args: [{ selector: 'matcha-date-range', standalone: false, template: "<div class=\"d-flex gap-16\">\n <ng-content></ng-content>\n</div>\n" }]
3308
+ args: [{ selector: 'matcha-date-range', standalone: false, template: "<div class=\"matcha-date-range-container\">\n <ng-content></ng-content>\n</div>\n" }]
3207
3309
  }], propDecorators: { controls: [{
3208
3310
  type: ContentChildren,
3209
3311
  args: [NgControl, { descendants: true }]
@@ -8001,8 +8103,17 @@ class MatchaAutocompleteComponent {
8001
8103
  this.placement = 'auto';
8002
8104
  this.maxHeight = 280;
8003
8105
  this.minWidth = 160;
8106
+ // Funcionalidades avançadas
8107
+ this.autoSelectOnBlur = false;
8108
+ this.displayWith = null;
8109
+ this.displayProperty = 'name';
8110
+ this.showClearButton = false;
8111
+ this.clearButtonIcon = 'action_close';
8112
+ this.clearButtonAriaLabel = 'Limpar seleção';
8004
8113
  this.opened = new EventEmitter();
8005
8114
  this.closed = new EventEmitter();
8115
+ this.cleared = new EventEmitter();
8116
+ this.autoSelected = new EventEmitter();
8006
8117
  this.open = false;
8007
8118
  this.activeIndex = -1;
8008
8119
  }
@@ -8048,14 +8159,14 @@ class MatchaAutocompleteComponent {
8048
8159
  }
8049
8160
  });
8050
8161
  }
8051
- notifyDirectiveOfSelection(value) {
8162
+ notifyDirectiveOfSelection(data) {
8052
8163
  // Disparar evento customizado para notificar a diretiva sobre a seleção
8053
8164
  const selectionEvent = new CustomEvent('matcha-autocomplete-selection', {
8054
- detail: { value },
8165
+ detail: data,
8055
8166
  bubbles: true
8056
8167
  });
8057
8168
  this.elRef.nativeElement.dispatchEvent(selectionEvent);
8058
- console.log('MatchaAutocomplete: Evento de seleção disparado', { value });
8169
+ console.log('MatchaAutocomplete: Evento de seleção disparado', data);
8059
8170
  }
8060
8171
  openPanel() {
8061
8172
  if (!this.triggerElement) {
@@ -8157,7 +8268,12 @@ class MatchaAutocompleteComponent {
8157
8268
  allOptions: this.options.toArray().map(o => ({ value: o.value, selected: o.selected }))
8158
8269
  });
8159
8270
  // Notificar a diretiva sobre a seleção antes de fechar o painel
8160
- this.notifyDirectiveOfSelection(option.value);
8271
+ // Passar tanto o valor quanto o texto de exibição
8272
+ const displayText = this.getDisplayValue(option.value);
8273
+ this.notifyDirectiveOfSelection({
8274
+ value: option.value,
8275
+ displayText: displayText
8276
+ });
8161
8277
  // Fechamos painel automaticamente
8162
8278
  console.log('MatchaAutocomplete: Fechando painel após seleção');
8163
8279
  this.closePanel();
@@ -8175,8 +8291,59 @@ class MatchaAutocompleteComponent {
8175
8291
  });
8176
8292
  return value;
8177
8293
  }
8294
+ hasSelection() {
8295
+ return this.selectedValue !== undefined && this.selectedValue !== null;
8296
+ }
8297
+ clearSelection() {
8298
+ this.selectedValue = undefined;
8299
+ // Limpar seleção visual das opções
8300
+ this.options.forEach(opt => {
8301
+ opt.selected = false;
8302
+ });
8303
+ // Notificar diretiva para limpar input
8304
+ const clearEvent = new CustomEvent('matcha-autocomplete-clear', {
8305
+ bubbles: true
8306
+ });
8307
+ this.elRef.nativeElement.dispatchEvent(clearEvent);
8308
+ // Emitir evento de limpeza
8309
+ this.cleared.emit();
8310
+ }
8311
+ /**
8312
+ * Obtém o texto de exibição de um valor
8313
+ * Usa displayWith se fornecido, senão displayProperty, senão retorna o valor como string
8314
+ */
8315
+ getDisplayValue(value) {
8316
+ if (value == null)
8317
+ return '';
8318
+ if (this.displayWith) {
8319
+ return this.displayWith(value) || '';
8320
+ }
8321
+ if (typeof value === 'object' && this.displayProperty) {
8322
+ return value[this.displayProperty] || '';
8323
+ }
8324
+ return String(value);
8325
+ }
8326
+ /**
8327
+ * Busca uma opção que corresponda ao texto digitado
8328
+ * Compara usando displayWith ou displayProperty
8329
+ */
8330
+ findOptionByText(text) {
8331
+ if (!text || text.trim() === '')
8332
+ return null;
8333
+ const searchText = text.toLowerCase().trim();
8334
+ const options = this.options.toArray();
8335
+ for (const option of options) {
8336
+ if (option.disabled)
8337
+ continue;
8338
+ const displayText = this.getDisplayValue(option.value).toLowerCase().trim();
8339
+ if (displayText === searchText) {
8340
+ return option;
8341
+ }
8342
+ }
8343
+ return null;
8344
+ }
8178
8345
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaAutocompleteComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
8179
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: MatchaAutocompleteComponent, isStandalone: false, selector: "matcha-autocomplete", inputs: { placement: "placement", maxHeight: "maxHeight", minWidth: "minWidth" }, outputs: { opened: "opened", closed: "closed" }, queries: [{ propertyName: "options", predicate: MatchaOptionComponent, descendants: true }], viewQueries: [{ propertyName: "panel", first: true, predicate: MatchaPanelComponent, descendants: true }], ngImport: i0, template: "<matcha-panel\n #panel\n [open]=\"open\"\n [placement]=\"placement\"\n [maxHeight]=\"maxHeight\"\n [minWidth]=\"minWidth\"\n [triggerElement]=\"triggerElement\"\n (opened)=\"opened.emit()\"\n (closed)=\"closed.emit()\">\n <div class=\"matcha-panel-content flex-column\">\n <ng-content></ng-content>\n </div>\n</matcha-panel>\n", dependencies: [{ kind: "component", type: MatchaPanelComponent, selector: "matcha-panel", inputs: ["placement", "maxHeight", "minWidth", "offset", "triggerElement", "open"], outputs: ["opened", "closed"] }], encapsulation: i0.ViewEncapsulation.None }); }
8346
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: MatchaAutocompleteComponent, isStandalone: false, selector: "matcha-autocomplete", inputs: { placement: "placement", maxHeight: "maxHeight", minWidth: "minWidth", autoSelectOnBlur: "autoSelectOnBlur", displayWith: "displayWith", displayProperty: "displayProperty", showClearButton: "showClearButton", clearButtonIcon: "clearButtonIcon", clearButtonAriaLabel: "clearButtonAriaLabel" }, outputs: { opened: "opened", closed: "closed", cleared: "cleared", autoSelected: "autoSelected" }, queries: [{ propertyName: "options", predicate: MatchaOptionComponent, descendants: true }], viewQueries: [{ propertyName: "panel", first: true, predicate: MatchaPanelComponent, descendants: true }], ngImport: i0, template: "<matcha-panel\n #panel\n [open]=\"open\"\n [placement]=\"placement\"\n [maxHeight]=\"maxHeight\"\n [minWidth]=\"minWidth\"\n [triggerElement]=\"triggerElement\"\n (opened)=\"opened.emit()\"\n (closed)=\"closed.emit()\">\n <div class=\"matcha-panel-content flex-column\">\n <ng-content></ng-content>\n </div>\n</matcha-panel>\n", dependencies: [{ kind: "component", type: MatchaPanelComponent, selector: "matcha-panel", inputs: ["placement", "maxHeight", "minWidth", "offset", "triggerElement", "open"], outputs: ["opened", "closed"] }], encapsulation: i0.ViewEncapsulation.None }); }
8180
8347
  }
8181
8348
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaAutocompleteComponent, decorators: [{
8182
8349
  type: Component,
@@ -8193,10 +8360,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
8193
8360
  type: Input
8194
8361
  }], minWidth: [{
8195
8362
  type: Input
8363
+ }], autoSelectOnBlur: [{
8364
+ type: Input
8365
+ }], displayWith: [{
8366
+ type: Input
8367
+ }], displayProperty: [{
8368
+ type: Input
8369
+ }], showClearButton: [{
8370
+ type: Input
8371
+ }], clearButtonIcon: [{
8372
+ type: Input
8373
+ }], clearButtonAriaLabel: [{
8374
+ type: Input
8196
8375
  }], opened: [{
8197
8376
  type: Output
8198
8377
  }], closed: [{
8199
8378
  type: Output
8379
+ }], cleared: [{
8380
+ type: Output
8381
+ }], autoSelected: [{
8382
+ type: Output
8200
8383
  }] } });
8201
8384
 
8202
8385
  class MatchaSelectComponent {
@@ -10957,8 +11140,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
10957
11140
  }] });
10958
11141
 
10959
11142
  class MatchaAutocompleteTriggerDirective {
10960
- constructor(el) {
11143
+ constructor(el, renderer, cdr, ngControl) {
10961
11144
  this.el = el;
11145
+ this.renderer = renderer;
11146
+ this.cdr = cdr;
11147
+ this.ngControl = ngControl;
10962
11148
  this.subs = new Subscription();
10963
11149
  }
10964
11150
  ngAfterViewInit() {
@@ -10989,31 +11175,107 @@ class MatchaAutocompleteTriggerDirective {
10989
11175
  // Escutar evento de seleção do autocomplete
10990
11176
  const selectionSub = fromEvent(this.panel.elRef.nativeElement, 'matcha-autocomplete-selection').subscribe((event) => {
10991
11177
  console.log('MatchaAutocomplete: Evento de seleção recebido na diretiva', event.detail);
10992
- const { value } = event.detail;
11178
+ const { value, displayText } = event.detail;
10993
11179
  if (value !== undefined) {
10994
- this.writeValueToInput(value);
11180
+ // Usar displayText se fornecido, senão usar o valor diretamente
11181
+ const textToWrite = displayText !== undefined ? displayText : value;
11182
+ this.writeValueToInput(textToWrite, value);
10995
11183
  }
10996
11184
  });
10997
11185
  this.subs.add(selectionSub);
11186
+ // Escutar evento de limpeza
11187
+ const clearSub = fromEvent(this.panel.elRef.nativeElement, 'matcha-autocomplete-clear').subscribe(() => {
11188
+ console.log('MatchaAutocomplete: Evento de limpeza recebido na diretiva');
11189
+ this.clearInput();
11190
+ });
11191
+ this.subs.add(clearSub);
11192
+ // Criar botão de limpar se necessário
11193
+ if (this.panel.showClearButton) {
11194
+ this.createClearButton();
11195
+ // Observar mudanças no estado disabled do input
11196
+ const input = this.el.nativeElement;
11197
+ const observer = new MutationObserver(() => {
11198
+ this.updateClearButtonVisibility();
11199
+ });
11200
+ observer.observe(input, {
11201
+ attributes: true,
11202
+ attributeFilter: ['disabled']
11203
+ });
11204
+ // Armazenar observer para cleanup
11205
+ this._disabledObserver = observer;
11206
+ }
11207
+ // Observar mudanças na seleção para mostrar/esconder botão
11208
+ const selectionChangeSub = fromEvent(this.panel.elRef.nativeElement, 'matcha-autocomplete-selection').subscribe(() => {
11209
+ this.updateClearButtonVisibility();
11210
+ });
11211
+ const clearChangeSub = fromEvent(this.panel.elRef.nativeElement, 'matcha-autocomplete-clear').subscribe(() => {
11212
+ this.updateClearButtonVisibility();
11213
+ });
11214
+ this.subs.add(selectionChangeSub);
11215
+ this.subs.add(clearChangeSub);
11216
+ // Observar mudanças no FormControl para sincronizar o input com displayWith
11217
+ if (this.ngControl && this.ngControl.control) {
11218
+ const controlValueSub = this.ngControl.control.valueChanges.subscribe((value) => {
11219
+ console.log('MatchaAutocomplete: FormControl valor mudou', value);
11220
+ // Se o valor é um objeto, usar displayWith para exibir no input
11221
+ if (value && typeof value === 'object') {
11222
+ const displayText = this.panel.getDisplayValue(value);
11223
+ console.log('MatchaAutocomplete: Atualizando input com displayWith', { value, displayText });
11224
+ // Atualizar apenas o input visual, sem disparar eventos do FormControl
11225
+ const input = this.el.nativeElement;
11226
+ if (input.value !== displayText) {
11227
+ input.value = displayText;
11228
+ }
11229
+ // Atualizar visibilidade do botão de limpar
11230
+ this.updateClearButtonVisibility();
11231
+ }
11232
+ });
11233
+ this.subs.add(controlValueSub);
11234
+ }
10998
11235
  }
10999
11236
  ngOnDestroy() {
11000
11237
  this.subs.unsubscribe();
11238
+ // Limpar observer se existir
11239
+ if (this._disabledObserver) {
11240
+ this._disabledObserver.disconnect();
11241
+ }
11242
+ // Remover botão de limpar se existir
11243
+ if (this.clearButton && this.clearButton.parentNode) {
11244
+ this.renderer.removeChild(this.clearButton.parentNode, this.clearButton);
11245
+ }
11001
11246
  }
11002
- writeValueToInput(value) {
11247
+ writeValueToInput(displayText, actualValue) {
11003
11248
  console.log('MatchaAutocomplete: writeValueToInput chamado', {
11004
- value,
11249
+ displayText,
11250
+ actualValue,
11005
11251
  input: this.el.nativeElement
11006
11252
  });
11007
11253
  const input = this.el.nativeElement;
11008
- input.value = value == null ? '' : value;
11254
+ input.value = displayText == null ? '' : String(displayText);
11009
11255
  // Dispatch múltiplos eventos para garantir compatibilidade com Angular Forms
11010
11256
  const inputEvent = new Event('input', { bubbles: true });
11011
11257
  const changeEvent = new Event('change', { bubbles: true });
11258
+ input.dispatchEvent(inputEvent);
11259
+ input.dispatchEvent(changeEvent);
11260
+ // Atualizar visibilidade do botão após escrever valor
11261
+ setTimeout(() => {
11262
+ this.updateClearButtonVisibility();
11263
+ }, 0);
11264
+ console.log('MatchaAutocomplete: Valor escrito no input', input.value);
11265
+ }
11266
+ clearInput() {
11267
+ const input = this.el.nativeElement;
11268
+ input.value = '';
11269
+ // Dispatch eventos para garantir compatibilidade com Angular Forms
11270
+ const inputEvent = new Event('input', { bubbles: true });
11271
+ const changeEvent = new Event('change', { bubbles: true });
11012
11272
  const blurEvent = new Event('blur', { bubbles: true });
11013
11273
  input.dispatchEvent(inputEvent);
11014
11274
  input.dispatchEvent(changeEvent);
11015
11275
  input.dispatchEvent(blurEvent);
11016
- console.log('MatchaAutocomplete: Valor escrito no input', input.value);
11276
+ // Atualizar visibilidade do botão
11277
+ this.updateClearButtonVisibility();
11278
+ console.log('MatchaAutocomplete: Input limpo');
11017
11279
  }
11018
11280
  onClick() {
11019
11281
  // Abrir painel quando clicar no input
@@ -11028,6 +11290,50 @@ class MatchaAutocompleteTriggerDirective {
11028
11290
  if (!this.panel.open)
11029
11291
  this.panel.openPanel();
11030
11292
  }
11293
+ onBlur() {
11294
+ // Implementar auto-seleção no blur se configurado
11295
+ if (!this.panel.autoSelectOnBlur) {
11296
+ return;
11297
+ }
11298
+ const input = this.el.nativeElement;
11299
+ const currentValue = input.value;
11300
+ // Se já há uma seleção válida (objeto), verificar se o texto ainda corresponde
11301
+ const selectedValue = this.panel.getSelectedValue();
11302
+ if (selectedValue !== undefined && selectedValue !== null) {
11303
+ // Verificar se o texto do input corresponde ao valor selecionado
11304
+ const displayText = this.panel.getDisplayValue(selectedValue);
11305
+ if (displayText.toLowerCase().trim() === currentValue.toLowerCase().trim()) {
11306
+ // Texto corresponde à seleção, não fazer nada
11307
+ return;
11308
+ }
11309
+ }
11310
+ // Se o valor é uma string (texto digitado mas não selecionado)
11311
+ if (typeof currentValue === 'string' && currentValue.trim() !== '') {
11312
+ // Procurar match exato (case-insensitive) nas opções disponíveis
11313
+ const exactMatch = this.panel.findOptionByText(currentValue);
11314
+ if (exactMatch) {
11315
+ // Match exato encontrado - selecionar automaticamente
11316
+ console.log('MatchaAutocomplete: Match exato encontrado no blur, selecionando automaticamente');
11317
+ this.panel.selectOption(exactMatch);
11318
+ // Emitir evento de auto-seleção
11319
+ this.panel.autoSelected.emit(exactMatch.value);
11320
+ // Atualizar visibilidade do botão de limpar após auto-seleção
11321
+ this.updateClearButtonVisibility();
11322
+ }
11323
+ else {
11324
+ // Nenhum match exato - limpar o campo
11325
+ console.log('MatchaAutocomplete: Nenhum match exato encontrado no blur, limpando campo');
11326
+ this.panel.clearSelection();
11327
+ }
11328
+ }
11329
+ else if (currentValue === '' || !currentValue) {
11330
+ // Campo vazio - limpar seleção se houver
11331
+ if (this.panel.hasSelection()) {
11332
+ console.log('MatchaAutocomplete: Campo vazio no blur, limpando seleção');
11333
+ this.panel.clearSelection();
11334
+ }
11335
+ }
11336
+ }
11031
11337
  onKeydown(ev) {
11032
11338
  if (!this.panel)
11033
11339
  return;
@@ -11046,8 +11352,10 @@ class MatchaAutocompleteTriggerDirective {
11046
11352
  // pega o value escolhido e escreve no input
11047
11353
  setTimeout(() => {
11048
11354
  const val = this.panel.getSelectedValue();
11049
- if (val !== undefined)
11050
- this.writeValueToInput(val);
11355
+ if (val !== undefined) {
11356
+ const displayText = this.panel.getDisplayValue(val);
11357
+ this.writeValueToInput(displayText, val);
11358
+ }
11051
11359
  });
11052
11360
  break;
11053
11361
  case 'Escape':
@@ -11070,14 +11378,79 @@ class MatchaAutocompleteTriggerDirective {
11070
11378
  setTimeout(() => {
11071
11379
  if (this.panel && typeof this.panel.getSelectedValue === 'function') {
11072
11380
  const val = this.panel.getSelectedValue();
11073
- if (val !== undefined)
11074
- this.writeValueToInput(val);
11381
+ if (val !== undefined) {
11382
+ const displayText = this.panel.getDisplayValue(val);
11383
+ this.writeValueToInput(displayText, val);
11384
+ }
11075
11385
  }
11076
11386
  }, 10);
11077
11387
  }
11078
11388
  }
11079
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaAutocompleteTriggerDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
11080
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: MatchaAutocompleteTriggerDirective, isStandalone: false, selector: "[matchaAutocomplete]", inputs: { panel: ["matchaAutocomplete", "panel"] }, host: { listeners: { "click": "onClick()", "focus": "onFocus()", "input": "onInput($event)", "keydown": "onKeydown($event)", "document:click": "onDocClick($event)" } }, ngImport: i0 }); }
11389
+ createClearButton() {
11390
+ if (this.clearButton)
11391
+ return;
11392
+ const input = this.el.nativeElement;
11393
+ const formField = input.closest('matcha-form-field');
11394
+ if (!formField) {
11395
+ console.warn('MatchaAutocomplete: matcha-form-field não encontrado para adicionar botão de limpar');
11396
+ return;
11397
+ }
11398
+ // Criar botão
11399
+ this.clearButton = this.renderer.createElement('span');
11400
+ // Adicionar classe do ícone (formato: i-matcha-{iconName})
11401
+ const iconClass = this.panel.clearButtonIcon.startsWith('i-matcha-')
11402
+ ? this.panel.clearButtonIcon
11403
+ : 'i-matcha-' + this.panel.clearButtonIcon;
11404
+ this.renderer.addClass(this.clearButton, iconClass);
11405
+ this.renderer.addClass(this.clearButton, 'i-size-sm');
11406
+ this.renderer.addClass(this.clearButton, 'matcha-autocomplete-clear-button');
11407
+ this.renderer.setStyle(this.clearButton, 'cursor', 'pointer');
11408
+ this.renderer.setStyle(this.clearButton, 'position', 'absolute');
11409
+ this.renderer.setStyle(this.clearButton, 'right', '12px');
11410
+ this.renderer.setStyle(this.clearButton, 'z-index', '10');
11411
+ this.renderer.setAttribute(this.clearButton, 'aria-label', this.panel.clearButtonAriaLabel);
11412
+ this.renderer.setAttribute(this.clearButton, 'role', 'button');
11413
+ this.renderer.setAttribute(this.clearButton, 'tabindex', '0');
11414
+ // Adicionar evento de clique
11415
+ this.renderer.listen(this.clearButton, 'click', (event) => {
11416
+ event.preventDefault();
11417
+ event.stopPropagation();
11418
+ this.panel.clearSelection();
11419
+ });
11420
+ // Adicionar evento de teclado (Enter e Space)
11421
+ this.renderer.listen(this.clearButton, 'keydown', (event) => {
11422
+ if (event.key === 'Enter' || event.key === ' ') {
11423
+ event.preventDefault();
11424
+ event.stopPropagation();
11425
+ this.panel.clearSelection();
11426
+ }
11427
+ });
11428
+ // Inserir botão no form-field (após o input)
11429
+ const inputContainer = input.parentElement;
11430
+ if (inputContainer) {
11431
+ this.renderer.setStyle(inputContainer, 'position', 'relative');
11432
+ this.renderer.appendChild(inputContainer, this.clearButton);
11433
+ }
11434
+ else {
11435
+ this.renderer.appendChild(formField, this.clearButton);
11436
+ }
11437
+ // Atualizar visibilidade inicial
11438
+ this.updateClearButtonVisibility();
11439
+ }
11440
+ updateClearButtonVisibility() {
11441
+ if (!this.clearButton)
11442
+ return;
11443
+ const hasSelection = this.panel.hasSelection();
11444
+ const isDisabled = this.el.nativeElement.disabled;
11445
+ if (hasSelection && !isDisabled && this.panel.showClearButton) {
11446
+ this.renderer.setStyle(this.clearButton, 'display', 'block');
11447
+ }
11448
+ else {
11449
+ this.renderer.setStyle(this.clearButton, 'display', 'none');
11450
+ }
11451
+ }
11452
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaAutocompleteTriggerDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i2.NgControl, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
11453
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: MatchaAutocompleteTriggerDirective, isStandalone: false, selector: "[matchaAutocomplete]", inputs: { panel: ["matchaAutocomplete", "panel"] }, host: { listeners: { "click": "onClick()", "focus": "onFocus()", "input": "onInput($event)", "blur": "onBlur()", "keydown": "onKeydown($event)", "document:click": "onDocClick($event)" } }, ngImport: i0 }); }
11081
11454
  }
11082
11455
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaAutocompleteTriggerDirective, decorators: [{
11083
11456
  type: Directive,
@@ -11085,7 +11458,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
11085
11458
  selector: '[matchaAutocomplete]',
11086
11459
  standalone: false,
11087
11460
  }]
11088
- }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { panel: [{
11461
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i2.NgControl, decorators: [{
11462
+ type: Optional
11463
+ }] }], propDecorators: { panel: [{
11089
11464
  type: Input,
11090
11465
  args: ['matchaAutocomplete']
11091
11466
  }], onClick: [{
@@ -11097,6 +11472,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
11097
11472
  }], onInput: [{
11098
11473
  type: HostListener,
11099
11474
  args: ['input', ['$event']]
11475
+ }], onBlur: [{
11476
+ type: HostListener,
11477
+ args: ['blur']
11100
11478
  }], onKeydown: [{
11101
11479
  type: HostListener,
11102
11480
  args: ['keydown', ['$event']]
@@ -11556,12 +11934,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
11556
11934
  }]
11557
11935
  }] });
11558
11936
 
11937
+ class MatchaDateModule {
11938
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
11939
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateModule, declarations: [MatchaDateComponent], imports: [CommonModule,
11940
+ FormsModule], exports: [MatchaDateComponent] }); }
11941
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateModule, imports: [CommonModule,
11942
+ FormsModule] }); }
11943
+ }
11944
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateModule, decorators: [{
11945
+ type: NgModule,
11946
+ args: [{
11947
+ declarations: [
11948
+ MatchaDateComponent
11949
+ ],
11950
+ imports: [
11951
+ CommonModule,
11952
+ FormsModule
11953
+ ],
11954
+ exports: [
11955
+ MatchaDateComponent
11956
+ ]
11957
+ }]
11958
+ }] });
11959
+
11559
11960
  class MatchaDateRangeModule {
11560
11961
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateRangeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
11561
11962
  static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateRangeModule, declarations: [MatchaDateRangeComponent], imports: [CommonModule,
11562
- ReactiveFormsModule], exports: [MatchaDateRangeComponent] }); }
11963
+ ReactiveFormsModule,
11964
+ MatchaDateModule], exports: [MatchaDateRangeComponent,
11965
+ MatchaDateModule] }); }
11563
11966
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateRangeModule, imports: [CommonModule,
11564
- ReactiveFormsModule] }); }
11967
+ ReactiveFormsModule,
11968
+ MatchaDateModule, MatchaDateModule] }); }
11565
11969
  }
11566
11970
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaDateRangeModule, decorators: [{
11567
11971
  type: NgModule,
@@ -11569,9 +11973,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
11569
11973
  declarations: [MatchaDateRangeComponent],
11570
11974
  imports: [
11571
11975
  CommonModule,
11572
- ReactiveFormsModule
11976
+ ReactiveFormsModule,
11977
+ MatchaDateModule
11573
11978
  ],
11574
- exports: [MatchaDateRangeComponent]
11979
+ exports: [
11980
+ MatchaDateRangeComponent,
11981
+ MatchaDateModule
11982
+ ]
11575
11983
  }]
11576
11984
  }] });
11577
11985
 
@@ -12529,5 +12937,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
12529
12937
  * Generated bundle index. Do not edit.
12530
12938
  */
12531
12939
 
12532
- export { CopyButtonComponent, INITIAL_CONFIG, MATCHA_MASK_CONFIG, MATCHA_OPTION_PARENT, MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaAutocompleteComponent, MatchaAutocompleteModule, MatchaAutocompleteTriggerDirective, MatchaAvatarComponent, MatchaAvatarModule, MatchaBreakpointObservableModule, MatchaBreakpointObserver, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaChipComponent, MatchaChipListComponent, MatchaChipModule, MatchaComponentsModule, MatchaDateRangeComponent, MatchaDateRangeModule, MatchaDividerComponent, MatchaDividerModule, MatchaDragDirective, MatchaDragHandleDirective, MatchaDrawerComponent, MatchaDrawerContainerComponent, MatchaDrawerContentComponent, MatchaDrawerModule, MatchaDropListComponent, MatchaDropListModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHighlightComponent, MatchaHighlightModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputPhoneComponent, MatchaInputPhoneModule, MatchaLabelComponent, MatchaLazyloadComponent, MatchaLazyloadDataComponent, MatchaLazyloadModule, MatchaMaskApplierService, MatchaMaskCompatibleDirective, MatchaMaskModule, MatchaMaskPipe, MatchaMaskService, MatchaMasonryComponent, MatchaMasonryModule, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaOptionComponent, MatchaOptionModule, MatchaOverlayService, MatchaPageLayoutComponent, MatchaPageLayoutModule, MatchaPaginatorComponent, MatchaPaginatorIntl, MatchaPaginatorModule, MatchaPanelComponent, MatchaPanelModule, MatchaRadioComponent, MatchaRadioModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectComponent, MatchaSelectModule, MatchaSelectTriggerDirective, MatchaSkeletonComponent, MatchaSkeletonModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderComponent, MatchaSliderModule, MatchaSpinComponent, MatchaSpinModule, MatchaSpinnerComponent, MatchaSpinnerModule, MatchaStepperComponent, MatchaStepperContentComponent, MatchaStepperControllerComponent, MatchaStepperModule, MatchaStepperStateService, MatchaTabItemComponent, MatchaTabsComponent, MatchaTabsModule, MatchaTimeComponent, MatchaTimeModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, NEW_CONFIG, NextStepDirective, PrevStepDirective, StepComponent, StepContentDirective, compatibleOptions, initialConfig, timeMasks, withoutValidation };
12940
+ export { CopyButtonComponent, INITIAL_CONFIG, MATCHA_MASK_CONFIG, MATCHA_OPTION_PARENT, MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaAutocompleteComponent, MatchaAutocompleteModule, MatchaAutocompleteTriggerDirective, MatchaAvatarComponent, MatchaAvatarModule, MatchaBreakpointObservableModule, MatchaBreakpointObserver, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaChipComponent, MatchaChipListComponent, MatchaChipModule, MatchaComponentsModule, MatchaDateComponent, MatchaDateModule, MatchaDateRangeComponent, MatchaDateRangeModule, MatchaDividerComponent, MatchaDividerModule, MatchaDragDirective, MatchaDragHandleDirective, MatchaDrawerComponent, MatchaDrawerContainerComponent, MatchaDrawerContentComponent, MatchaDrawerModule, MatchaDropListComponent, MatchaDropListModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHighlightComponent, MatchaHighlightModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputPhoneComponent, MatchaInputPhoneModule, MatchaLabelComponent, MatchaLazyloadComponent, MatchaLazyloadDataComponent, MatchaLazyloadModule, MatchaMaskApplierService, MatchaMaskCompatibleDirective, MatchaMaskModule, MatchaMaskPipe, MatchaMaskService, MatchaMasonryComponent, MatchaMasonryModule, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaOptionComponent, MatchaOptionModule, MatchaOverlayService, MatchaPageLayoutComponent, MatchaPageLayoutModule, MatchaPaginatorComponent, MatchaPaginatorIntl, MatchaPaginatorModule, MatchaPanelComponent, MatchaPanelModule, MatchaRadioComponent, MatchaRadioModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectComponent, MatchaSelectModule, MatchaSelectTriggerDirective, MatchaSkeletonComponent, MatchaSkeletonModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderComponent, MatchaSliderModule, MatchaSpinComponent, MatchaSpinModule, MatchaSpinnerComponent, MatchaSpinnerModule, MatchaStepperComponent, MatchaStepperContentComponent, MatchaStepperControllerComponent, MatchaStepperModule, MatchaStepperStateService, MatchaTabItemComponent, MatchaTabsComponent, MatchaTabsModule, MatchaTimeComponent, MatchaTimeModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, NEW_CONFIG, NextStepDirective, PrevStepDirective, StepComponent, StepContentDirective, compatibleOptions, initialConfig, timeMasks, withoutValidation };
12533
12941
  //# sourceMappingURL=matcha-components.mjs.map