libs/barista-components/filter-field/src/filter-field.scss
@use 'sass:math';
@import '../../core/src/style/variables';
@import '../../style/font-mixins';
@import '../../core/src/style/form-control';
@import '../../core/src/style/interactive-common';

$dt-filter-field-inner-height: 30px;

// from "* { Box-sizing: Border-box }
// FTW" @ https://www.paulirish.com/2012/box-sizing-border-box-ftw/
*,
*::before,
*::after {
  box-sizing: inherit;
}

:host {
  display: block;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  @include dt-form-control();

  // We need to set overflow visible to prevent the outline
  // of inner interactive elements (like buttons) to be cut off
  overflow: visible;

  .dt-focused & {
    @include dt-focus-style();
  }

  &:not(.dt-filter-field-disabled) {
    cursor: text;
  }

  &.dt-filter-field-disabled {
    background-color: $gray-100;
    color: $disabledcolor;
  }
}

.dt-filter-field-body {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  padding: 0 8px 0 0;

  // Do not set `align-items` as it breaks SVGs baseline alignment
  // align-items: baseline;
  box-sizing: border-box;
}

.dt-filter-field-label {
  white-space: nowrap;
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 0 0 8px;
  @include dt-main-font();
  line-height: $dt-filter-field-inner-height;
  color: $gray-500;

  label {
    font-size: inherit;
    color: inherit;
    line-height: inherit;
  }
}

.dt-filter-field-icon {
  display: flex;
  width: 16px;
  height: $dt-filter-field-inner-height;
  align-items: center;
  margin-right: 8px;

  ::ng-deep svg {
    width: 16px;
    height: 16px;
    fill: $gray-500;
  }
}

.dt-filter-field-infix {
  display: flex;
  flex-grow: 1;
  flex-shrink: 1;
  margin-left: 8px;
}

.dt-filter-field-infix-edit {
  max-width: 400px;
}

.dt-filter-field-category {
  display: block;
  flex-grow: 0;
  flex-shrink: 0;
  padding-right: 8px;
  @include dt-main-font();
  line-height: $dt-filter-field-inner-height;
  color: $gray-500;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dt-filter-field-input {
  display: block;
  min-width: 100px; // Minimum width of the autocomplete
  width: 100%;
  flex-grow: 1;
  flex-shrink: 1;
  position: relative;
  @include dt-main-font();
  appearance: none;
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  border: none;
  height: $dt-filter-field-inner-height;
  line-height: $dt-filter-field-inner-height;
  line-height: -moz-block-height;
  outline: none;
  background: transparent;
  z-index: 1;
}

.dt-filter-field-spinner {
  margin-top: 7px;
  margin-left: 9px;
}

dt-filter-field-tag {
  margin-top: math.div($dt-filter-field-inner-height - 24, 2);
  margin-bottom: math.div($dt-filter-field-inner-height - 24, 2);
  margin-left: 8px;
}

button.dt-filter-field-clear-all-button {
  justify-self: flex-end;
  margin-top: 3px;
  margin-left: auto;
  height: 24px;
  line-height: 22px;
}

button.dt-filter-field-clear-all-button-hidden {
  visibility: hidden;
  position: absolute;
}

// We need to double the class to get a better specificity
// than the original autocomplete panel selector
::ng-deep .dt-autocomplete-panel.dt-filter-field-panel.dt-filter-field-panel {
  margin-top: 0;
}

.dt-filter-field-subscript-wrapper {
  position: relative;
}

.dt-filter-field-error {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border: 1px solid $gray-300;
  background-color: $gray-100;
  padding: 8px 12px;
  border-bottom-left-radius: 3px;
  border-bottom-right-radius: 3px;
  transform-origin: top left;
  color: $error-color;

  // Make sure the error is not overlapped by other elements
  // This needs to be higher than the drawer in order to
  // allow the error message to be over the drawer's content
  z-index: 4;

  &::before {
    content: '';
    display: block;
    position: absolute;
    top: -2px;
    left: -1px;
    right: -1px;
    height: 2px;
    background-color: $error-color;
  }
}

.dt-filter-field-error p {
  margin: 0;
}

::ng-deep .dt-filter-field-panel .dt-filter-field-hint-partial {
  @include dt-text-ellipsis();
  @include dt-custom-font-styles(
    $custom-color: $gray-500,
    $custom-font-size: 12px
  );
  text-align: center;
  border-bottom: solid 1px $gray-200;
  padding: 0 8px;
}

::ng-deep .dt-filter-field-panel .dt-option {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

::ng-deep .dt-filter-field-panel .dt-highlight {
  display: inline;
}
