@charset "UTF-8";

// @description
// * u-select mixin.
// * Apply user-select property with cross-browser support.

// @access public

// @version 1.4.0

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @reference: https://developer.mozilla.org/en-US/docs/Web/CSS/user-select

// @namespace general

// @module general/u-select

// @dependencies:
// * - meta.type-of (SASS function).
// * - LibFunc.is-in-list (function).
// * - Error.throw (function).

// @param {String} $val
// * The value for the user-select property.
// *  - `none`: No text selection is allowed.
// *  - `auto`: Standard selection behavior.
// *  - `text`: Only text selection is allowed.
// *  - `contain`: Text selection is allowed, but not outside of
// *    the element's boundaries.
// *  - `all`: Text, image, and other selection is allowed.
// *  - `inherit`, `initial`, `revert`, `revert-layer`,
// *    `unset`: CSS standard values.

// @example
// * .example {
// *   @include u-select(none);
// * }

// @output
// * .example {
// *   -webkit-user-select: none;
// *   -moz-user-select: none;
// *   -ms-user-select: none;
// *   user-select: none;
// * }

// stylelint-disable scss/dollar-variable-empty-line-before

@use "sass:meta";
@use "sass:list";
@use "../../functions/global/is-in-list" as LibFunc;
@use "../../development-utils/toggle-error-message" as Error;

@mixin u-select($value: auto) {
    $user-select-props: (-webkit-user-select, -moz-user-select, -ms-user-select, user-select) !default;

    $user-select-values: (none, auto, text, contain, all, inherit, initial, revert, revert-layer, unset) !default;

    @if meta.type-of($value) == string {
        @if LibFunc.is-in-list($user-select-values, $value) {
            @each $prop in $user-select-props {
                #{$prop}: $value;
            }
        } @else {
            content: Error.throw("The parameter of u-select mixin must be one of: (#{$user-select-values}).");
        }
    } @else {
        content: Error.throw("The parameter of u-select mixin must be in a string type.");
    }
}
