@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'), 'enforceLimits' => false, ]) @php // reset variables for Laravel 8 support $add_clearing = parseBladewindVariable($add_clearing); $addClearing = parseBladewindVariable($addClearing); $show_placeholder_always = parseBladewindVariable($show_placeholder_always); $showPlaceholderAlways = parseBladewindVariable($showPlaceholderAlways); $show_error_inline = parseBladewindVariable($show_error_inline); $showErrorInline = parseBladewindVariable($showErrorInline); $with_dots = parseBladewindVariable($with_dots); $withDots = parseBladewindVariable($withDots); $has_label = parseBladewindVariable($has_label); $hasLabel = parseBladewindVariable($hasLabel); $is_datepicker = parseBladewindVariable($is_datepicker); $isDatepicker = parseBladewindVariable($isDatepicker); $transparent_prefix = parseBladewindVariable($transparent_prefix); $transparentPrefix = parseBladewindVariable($transparentPrefix); $transparent_suffix = parseBladewindVariable($transparent_suffix); $transparentSuffix = parseBladewindVariable($transparentSuffix); $prefix_is_icon = parseBladewindVariable($prefix_is_icon); $prefixIsIcon = parseBladewindVariable($prefixIsIcon); $suffix_is_icon = parseBladewindVariable($suffix_is_icon); $suffixIsIcon = parseBladewindVariable($suffixIsIcon); $required = parseBladewindVariable($required); $numeric = parseBladewindVariable($numeric); $viewable = parseBladewindVariable($viewable); $clearable = parseBladewindVariable($clearable); // $enforceLimits = parseBladewindVariable($enforceLimits); 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'; } if($attributes->has('readonly') || $attributes->has('disabled')) { if($attributes->get('readonly') == 'false') $attributes = $attributes->except('readonly'); if($attributes->get('disabled') == 'false') $attributes = $attributes->except('disabled'); } @endphp