////
/// @group form
////

@import '~@react-md/theme/dist/helpers';
@import './variables';

/// This function is used to quickly get one of the form's theme values. This is
/// really just for the `rmd-form-theme` mixin to provide some validation that a
/// correct style key is used, but might be useful in other cases.
///
/// @param {String} theme-style - One of the `$rmd-form-theme-values` map keys
/// to get a value for.
/// @return {Color|String|Number} one of the form's theme values.
@function rmd-form-theme($theme-style) {
  @return rmd-theme-get-var-value($theme-style, $rmd-form-theme-values, form);
}

/// This function is used to get one of the form's theme variables as a CSS
/// Variable to be applied as a style attribute. By default, the CSS Variable
/// will have a fallback of the current `$rmd-form-theme-values`
///
/// This function is used to create a CSS Variable declaration with an optional
/// fallback value if the CSS Variable has not been declared somehow.
///
/// @param {String} theme-style - One of the `$rmd-form-theme-values` map keys
/// to set a value for.
/// @param {Color|String|Number} fallback [null] - An optional fallback color to
/// apply. This is set to `null` by default and not used since the link's theme
/// variables should always exist.
/// @return {Color|String|Number} one of the form's theme values.
@function rmd-form-theme-var($theme-style, $fallback: null) {
  @return rmd-theme-get-var(
    $theme-style,
    $rmd-form-theme-values,
    form,
    $fallback
  );
}

/// Creates the styles for one of the form's theme values. This is mostly going
/// to be an internal helper mixin util.
///
/// @param {String} property - The property to set a `rmd-form-theme-values`
/// value to.
/// @param {String} theme-style - One of the keys of `rmd-form-theme-values` to
/// extract a value from.
/// @param {Color|String|Number} fallback [null] - A fallback value to use if
/// the css variable isn't set somehow. This will default to automatically
/// retrieving the default value from the `rmd-form-theme-values` map when
/// `null`.
@mixin rmd-form-theme($property, $theme-style: $property, $fallback: null) {
  @include rmd-theme-apply-rmd-var(
    $property,
    $theme-style,
    $rmd-form-theme-values,
    form
  );
}

/// Updates one of the form's theme variables with the new value for the section
/// of your app.
///
/// @param {String} theme-style - The form theme style type to update. This
/// should be one of the `$rmd-form-theme-values` keys.
/// @param {Color|String|Number} value - The new value to use.
@mixin rmd-form-theme-update-var($theme-style, $value) {
  @include rmd-theme-update-rmd-var(
    $value,
    $theme-style,
    $rmd-form-theme-values,
    form
  );
}
