import { boot } from "quasar/wrappers";
import { QDialog, QInput, QSelect, QScrollArea, QCard } from "quasar";

/**
 * Set some default properties on a component
 */
const SetComponentDefaults = (component, defaults) => {
  Object.keys(defaults).forEach((prop) => {
    component.props[prop] =
      Array.isArray(component.props[prop]) === true ||
      typeof component.props[prop] === "function"
        ? { type: component.props[prop], default: defaults[prop] }
        : { ...component.props[prop], default: defaults[prop] };
  });
};

export default boot(() => {
  SetComponentDefaults(QDialog, {
    transitionShow: "slide-up",
    transitionHide: "slide-down",
  });
  SetComponentDefaults(QInput, {
    outlined: true,
    labelColor: "primary",
    dense: true,
    bgColor: "surface",
    class: "text-bold",
  });
  SetComponentDefaults(QSelect, {
    outlined: true,
    labelColor: "primary",
    dense: true,
    bgColor: "surface",
  });
  SetComponentDefaults(QCard, {
    flat: true,
  });
  SetComponentDefaults(QScrollArea, {
    thumbStyle: {
      borderRadius: "4px",
      background: "#A6A6A6",
      width: "6px",
      opacity: 0.6,
    },
    verticalOffset: [4, 2],
    horizontalOffset: [0, 2],
  });
});
