@props([ // name of the input field for use in forms 'name' => 'input-'.uniqid(), // what type of input box are you displaying // available options are text, password, email, search, tel 'type' => 'text', // label to display on the input box 'label' => '', // should the input accept numbers only. Default is false 'numeric' => false, // minimum number a user can enter when numeric=true 'min' => null, // maximum number a user can enter when numeric=true 'max' => null, // is this a required field. Default is false 'required' => false, // adds margin after the input box 'add_clearing' => config('bladewind.input.add_clearing', true), 'addClearing' => config('bladewind.input.add_clearing', true), // placeholder text 'placeholder' => '', // value to set when in edit mode or if you want to load the input with default text 'selected_value' => '', 'selectedValue' => '', // should the placeholder always be visible even if a label is set // by default the label overwrites the placeholder // useful if you dont want this overwriting 'show_placeholder_always' => config('bladewind.input.show_placeholder_always', false), 'showPlaceholderAlways' => config('bladewind.input.show_placeholder_always', false), // message to display when validation fails for this field // this is just attached to the input field as a data attribute 'error_message' => '', 'errorMessage' => '', // this is an easy way to pass a translatable heading to the notification component // since it is triggered from Javascript, it is hard to translate any text from within js 'error_heading' => 'Error', 'errorHeading' => 'Error', // how should error messages be displayed for this input // by default error messages are displayed in the Bladewind notification component // the component should exist on the page 'show_error_inline' => config('bladewind.input.show_error_inline', false), 'showErrorInline' => config('bladewind.input.show_error_inline', false), // for numeric input only: should the numbers include dots 'with_dots' => true, 'withDots' => true, // determines if the input field has a label 'has_label' => false, 'hasLabel' => false, 'is_datepicker' => false, 'isDatepicker' => false, // set the prefix for the input field 'prefix' => '', // set the suffix for the input field 'suffix' => '', // define if prefix background is transparent 'transparent_prefix' => config('bladewind.input.transparent_prefix', true), 'transparentPrefix' => config('bladewind.input.transparent_prefix', true), // define if suffix background is transparent 'transparent_suffix' => config('bladewind.input.transparent_suffix', true), 'transparentSuffix' => config('bladewind.input.transparent_suffix', true), // force (or not) prefix to be an icon 'prefix_is_icon' => false, 'prefixIsIcon' => false, // force (or not) suffix to be an icon 'suffix_is_icon' => false, 'suffixIsIcon' => false, // define if icon prefix is outline or solid 'prefix_icon_type' => 'outline', 'prefixIconType' => 'outline', // force (or not) suffix to be an icon 'suffix_icon_type' => 'outline', 'suffixIconType' => 'outline', // should password be viewable 'viewable' => false, // should field be clearable 'clearable' => config('bladewind.input.clearable', false), // additional css for prefix 'prefix_icon_css' => '', 'prefixIconCss' => '', // additional css for suffix 'suffix_icon_css' => '', 'suffixIconCss' => '', // additional css for div containing the prefix 'prefix_icon_div_css' => '', // additional css for div containing the suffix 'suffix_icon_div_css' => 'rtl:!right-[unset] rtl:!left-0', // javascript to execute when suffix icon is clicked 'action' => null, 'size' => config('bladewind.input.size', 'medium'), ]) @php // reset variables for Laravel 8 support $add_clearing = filter_var($add_clearing, FILTER_VALIDATE_BOOLEAN); $addClearing = filter_var($addClearing, FILTER_VALIDATE_BOOLEAN); $show_placeholder_always = filter_var($show_placeholder_always, FILTER_VALIDATE_BOOLEAN); $showPlaceholderAlways = filter_var($showPlaceholderAlways, FILTER_VALIDATE_BOOLEAN); $show_error_inline = filter_var($show_error_inline, FILTER_VALIDATE_BOOLEAN); $showErrorInline = filter_var($showErrorInline, FILTER_VALIDATE_BOOLEAN); $with_dots = filter_var($with_dots, FILTER_VALIDATE_BOOLEAN); $withDots = filter_var($withDots, FILTER_VALIDATE_BOOLEAN); $has_label = filter_var($has_label, FILTER_VALIDATE_BOOLEAN); $hasLabel = filter_var($hasLabel, FILTER_VALIDATE_BOOLEAN); $is_datepicker = filter_var($is_datepicker, FILTER_VALIDATE_BOOLEAN); $isDatepicker = filter_var($isDatepicker, FILTER_VALIDATE_BOOLEAN); $transparent_prefix = filter_var($transparent_prefix, FILTER_VALIDATE_BOOLEAN); $transparentPrefix = filter_var($transparentPrefix, FILTER_VALIDATE_BOOLEAN); $transparent_suffix = filter_var($transparent_suffix, FILTER_VALIDATE_BOOLEAN); $transparentSuffix = filter_var($transparentSuffix, FILTER_VALIDATE_BOOLEAN); $prefix_is_icon = filter_var($prefix_is_icon, FILTER_VALIDATE_BOOLEAN); $prefixIsIcon = filter_var($prefixIsIcon, FILTER_VALIDATE_BOOLEAN); $suffix_is_icon = filter_var($suffix_is_icon, FILTER_VALIDATE_BOOLEAN); $suffixIsIcon = filter_var($suffixIsIcon, FILTER_VALIDATE_BOOLEAN); $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); $numeric = filter_var($numeric, FILTER_VALIDATE_BOOLEAN); $viewable = filter_var($viewable, FILTER_VALIDATE_BOOLEAN); $clearable = filter_var($clearable, FILTER_VALIDATE_BOOLEAN); if (!$addClearing) $add_clearing = $addClearing; if ($showPlaceholderAlways) $show_placeholder_always = $showPlaceholderAlways; if ($showErrorInline) $show_error_inline = $showErrorInline; if (!$withDots) $with_dots = $withDots; if ($isDatepicker) $is_datepicker = $isDatepicker; if (!$transparentPrefix) $transparent_prefix = $transparentPrefix; if (!$transparentSuffix) $transparent_suffix = $transparentSuffix; if (!$prefixIsIcon) $prefix_is_icon = $prefixIsIcon; if (!$suffixIsIcon) $suffix_is_icon = $suffixIsIcon; if ($selectedValue !== $selected_value) $selected_value = $selectedValue; if ($errorMessage !== $error_message) $error_message = $errorMessage; if ($errorHeading !== $error_heading) $error_heading = $errorHeading; if ($prefixIconType !== $prefix_icon_type) $prefix_icon_type = $prefixIconType; if ($suffixIconType !== $suffix_icon_type) $suffix_icon_type = $suffixIconType; if ($prefixIconCss !== $prefix_icon_css) $prefix_icon_css = $prefixIconCss; if ($suffixIconCss !== $suffix_icon_css) $suffix_icon_css = $suffixIconCss; //-------------------------------------------------------------------- $name = preg_replace('/[\s-]/', '_', $name); $required_symbol = ($label == '' && $required) ? ' *' : ''; $is_required = ($required) ? 'required' : ''; $placeholder_color = ($show_placeholder_always || $label == '') ? '' : 'placeholder-transparent dark:placeholder-transparent'; $placeholder_label = ($show_placeholder_always) ? $placeholder : (($label !== '') ? $label : $placeholder); $with_dots = ($with_dots) ? 1 : 0; if($type == "password" && $viewable) { $suffix = 'eye'; $suffix_icon_css = 'show-pwd'; $action = 'togglePassword(\''.$name.'\', \'show\')'; $suffix_is_icon = true; } if($clearable) { $suffix = 'x-mark'; $suffix_is_icon = true; $suffix_icon_css = 'hidden cursor-pointer dark:!bg-dark-900/60 dark:hover:!bg-dark-900 !p-0.5 !rounded-full bg-gray-400 !stroke-2 hover:bg-gray-600 text-white'; } @endphp