Commit awal: prototipe UI SIAKAD Untan
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
{{-- Baris tombol di dasar formulir, sejajar kanan (simpan/batal). Satu tombol primer saja. --}}
|
||||
<div {{ $attributes->class('form-actions') }}>
|
||||
{{ $slot }}
|
||||
</div>
|
||||
@@ -0,0 +1,19 @@
|
||||
@props(['name', 'label', 'value' => '1', 'checked' => false, 'id' => null])
|
||||
|
||||
@php
|
||||
$id ??= 'check-'.\Illuminate\Support\Str::slug($name);
|
||||
// Setelah validasi gagal, nilai lama menang atas nilai bawaan (kotak yang tidak dicentang tidak dikirim browser)
|
||||
$isChecked = request()->hasSession() && session()->hasOldInput() ? (bool) old($name) : (bool) $checked;
|
||||
@endphp
|
||||
|
||||
<label class="check" for="{{ $id }}">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="{{ $id }}"
|
||||
name="{{ $name }}"
|
||||
value="{{ $value }}"
|
||||
@checked($isChecked)
|
||||
{{ $attributes->class('check__input') }}
|
||||
>
|
||||
<span>{{ $label }}</span>
|
||||
</label>
|
||||
@@ -0,0 +1,76 @@
|
||||
{{--
|
||||
Label + input + bantuan/galat. Type "password" otomatis mendapat tombol tampil/sembunyikan (hanya jika JS aktif).
|
||||
Atribut lain (required, autofocus, autocomplete, inputmode, maxlength...) diteruskan ke <input>.
|
||||
--}}
|
||||
@props([
|
||||
'name',
|
||||
'label',
|
||||
'type' => 'text',
|
||||
'value' => null,
|
||||
'hint' => null,
|
||||
'error' => null,
|
||||
'optional' => false,
|
||||
'id' => null,
|
||||
'prefix' => null,
|
||||
'suffix' => null,
|
||||
])
|
||||
|
||||
@php
|
||||
$id ??= 'field-'.\Illuminate\Support\Str::slug($name);
|
||||
$isPassword = $type === 'password';
|
||||
$message = $error ?? (isset($errors) ? $errors->first($name) : null);
|
||||
$current = $isPassword ? null : old($name, $value);
|
||||
$helpId = $id.'-help';
|
||||
// Lebar prefiks/sufiks diperkirakan dengan satuan ch agar teks input tidak menimpa satuan
|
||||
$pads = collect(['--pad-start' => $prefix, '--pad-end' => $suffix])
|
||||
->filter(fn ($text) => filled($text))
|
||||
->map(fn ($text, $var) => $var.': calc('.mb_strlen($text).'ch + 1.75rem)')
|
||||
->implode('; ');
|
||||
@endphp
|
||||
|
||||
<div class="field" @if ($isPassword) x-data="passwordField" @endif>
|
||||
<label class="field__label" for="{{ $id }}">
|
||||
{{ $label }}
|
||||
@if ($optional) <span class="field__optional">(opsional)</span> @endif
|
||||
</label>
|
||||
|
||||
<div class="field__control">
|
||||
@if (filled($prefix)) <span class="field__affix field__affix--start">{{ $prefix }}</span> @endif
|
||||
<input
|
||||
id="{{ $id }}"
|
||||
name="{{ $name }}"
|
||||
type="{{ $type }}"
|
||||
@if ($current !== null) value="{{ $current }}" @endif
|
||||
@if ($message) aria-invalid="true" @endif
|
||||
@if ($attributes->get('required')) aria-required="true" @endif
|
||||
aria-describedby="{{ $helpId }}"
|
||||
@if ($pads) style="{{ $pads }}" @endif
|
||||
@if ($isPassword) x-bind:type="show ? 'text' : 'password'" @endif
|
||||
{{ $attributes->class(['field__input', 'field__input--password' => $isPassword]) }}
|
||||
>
|
||||
@if (filled($suffix)) <span class="field__affix field__affix--end">{{ $suffix }}</span> @endif
|
||||
|
||||
@if ($isPassword)
|
||||
<button
|
||||
type="button"
|
||||
class="field__toggle"
|
||||
aria-label="Tampilkan kata sandi"
|
||||
aria-pressed="false"
|
||||
x-on:click="toggle()"
|
||||
x-bind:aria-pressed="show"
|
||||
>
|
||||
<x-heroicon-o-eye x-show="!show" />
|
||||
<x-heroicon-o-eye-slash x-show="show" x-cloak />
|
||||
</button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<p id="{{ $helpId }}" @class(['field__help', 'field__help--error' => $message]) aria-live="polite" @if ($message) role="alert" @endif>
|
||||
@if ($message)
|
||||
<x-heroicon-s-exclamation-circle />
|
||||
<span>{{ $message }}</span>
|
||||
@elseif ($hint)
|
||||
<span>{{ $hint }}</span>
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
@@ -0,0 +1,16 @@
|
||||
{{-- Bagian formulir: fieldset + legend + grid kolom responsif (container query). Kolom lebar penuh: beri class="col-span-full". --}}
|
||||
@props(['title', 'description' => null, 'columns' => 2])
|
||||
|
||||
@php
|
||||
$columns = in_array((int) $columns, [1, 2, 3], true) ? (int) $columns : 2;
|
||||
@endphp
|
||||
|
||||
<fieldset {{ $attributes->class('form-section') }}>
|
||||
<legend class="form-section__title">{{ $title }}</legend>
|
||||
@if ($description) <p class="form-section__desc">{{ $description }}</p> @endif
|
||||
<div class="form-section__body">
|
||||
<div class="form-section__grid form-section__grid--{{ $columns }}">
|
||||
{{ $slot }}
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,63 @@
|
||||
{{--
|
||||
Label + <select> + bantuan/galat, selaras dengan form.field. `options` = nilai => label; atau isi slot dengan <option>.
|
||||
Atribut lain (required, disabled, x-model, onchange...) diteruskan ke <select>. old() menang atas value.
|
||||
--}}
|
||||
@props([
|
||||
'name',
|
||||
'label',
|
||||
'options' => [],
|
||||
'value' => null,
|
||||
'placeholder' => null,
|
||||
'hint' => null,
|
||||
'error' => null,
|
||||
'optional' => false,
|
||||
'id' => null,
|
||||
])
|
||||
|
||||
@php
|
||||
$key = trim(str_replace(['[', ']'], ['.', ''], $name), '.');
|
||||
$id ??= 'field-'.\Illuminate\Support\Str::slug($key, '-');
|
||||
$message = $error ?? (isset($errors) ? $errors->first($key) : null);
|
||||
$current = old($key, $value);
|
||||
$helpId = $id.'-help';
|
||||
$hasSlot = trim((string) $slot) !== '';
|
||||
@endphp
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="{{ $id }}">
|
||||
{{ $label }}
|
||||
@if ($optional) <span class="field__optional">(opsional)</span> @endif
|
||||
</label>
|
||||
|
||||
<div class="field__control">
|
||||
<select
|
||||
id="{{ $id }}"
|
||||
name="{{ $name }}"
|
||||
@if ($message) aria-invalid="true" @endif
|
||||
@if ($attributes->get('required')) aria-required="true" @endif
|
||||
aria-describedby="{{ $helpId }}"
|
||||
{{ $attributes->class(['field__input', 'field__select']) }}
|
||||
>
|
||||
@if ($placeholder !== null)
|
||||
<option value="">{{ $placeholder }}</option>
|
||||
@endif
|
||||
@if ($hasSlot)
|
||||
{{ $slot }}
|
||||
@else
|
||||
@foreach ($options as $optionValue => $optionLabel)
|
||||
<option value="{{ $optionValue }}" @selected($current !== null && (string) $current === (string) $optionValue)>{{ $optionLabel }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
<span class="field__chevron" aria-hidden="true"><x-heroicon-m-chevron-down /></span>
|
||||
</div>
|
||||
|
||||
<p id="{{ $helpId }}" @class(['field__help', 'field__help--error' => $message]) aria-live="polite" @if ($message) role="alert" @endif>
|
||||
@if ($message)
|
||||
<x-heroicon-s-exclamation-circle />
|
||||
<span>{{ $message }}</span>
|
||||
@elseif ($hint)
|
||||
<span>{{ $hint }}</span>
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
@@ -0,0 +1,47 @@
|
||||
{{-- Label + <textarea> + bantuan/galat, selaras dengan form.field. Atribut lain (required, maxlength, placeholder...) ke <textarea>. --}}
|
||||
@props([
|
||||
'name',
|
||||
'label',
|
||||
'value' => null,
|
||||
'rows' => 4,
|
||||
'hint' => null,
|
||||
'error' => null,
|
||||
'optional' => false,
|
||||
'id' => null,
|
||||
])
|
||||
|
||||
@php
|
||||
$key = trim(str_replace(['[', ']'], ['.', ''], $name), '.');
|
||||
$id ??= 'field-'.\Illuminate\Support\Str::slug($key, '-');
|
||||
$message = $error ?? (isset($errors) ? $errors->first($key) : null);
|
||||
$current = old($key, $value);
|
||||
$helpId = $id.'-help';
|
||||
@endphp
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="{{ $id }}">
|
||||
{{ $label }}
|
||||
@if ($optional) <span class="field__optional">(opsional)</span> @endif
|
||||
</label>
|
||||
|
||||
<div class="field__control">
|
||||
<textarea
|
||||
id="{{ $id }}"
|
||||
name="{{ $name }}"
|
||||
rows="{{ $rows }}"
|
||||
@if ($message) aria-invalid="true" @endif
|
||||
@if ($attributes->get('required')) aria-required="true" @endif
|
||||
aria-describedby="{{ $helpId }}"
|
||||
{{ $attributes->class(['field__input', 'field__textarea']) }}
|
||||
>{{ $current }}</textarea>
|
||||
</div>
|
||||
|
||||
<p id="{{ $helpId }}" @class(['field__help', 'field__help--error' => $message]) aria-live="polite" @if ($message) role="alert" @endif>
|
||||
@if ($message)
|
||||
<x-heroicon-s-exclamation-circle />
|
||||
<span>{{ $message }}</span>
|
||||
@elseif ($hint)
|
||||
<span>{{ $hint }}</span>
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
Reference in New Issue
Block a user