-
Notifications
You must be signed in to change notification settings - Fork 46
fix(panel-app): DatePicker não-nativo para data de nascimento #457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.x
Are you sure you want to change the base?
Changes from 4 commits
b0ff9fd
11ae8a2
0d60ea6
3288f3e
b54872d
69b1e81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| use Filament\Schemas\Components\Utilities\Set; | ||
| use Filament\Schemas\Schema; | ||
| use Filament\Support\Enums\Width; | ||
| use Filament\Support\Icons\Heroicon; | ||
| use He4rt\Gamification\Character\Models\Character; | ||
| use He4rt\Identity\User\Models\User; | ||
| use He4rt\Profile\Actions\SyncProfileSkills; | ||
|
|
@@ -97,6 +98,26 @@ public function form(Schema $schema): Schema | |
| return $schema | ||
| ->components([ | ||
| Form::make([ | ||
| Section::make(__('panel-app::profile.sections.personal')) | ||
| ->schema([ | ||
| DatePicker::make('birthdate') | ||
| ->label(__('panel-app::profile.fields.birthdate')) | ||
| ->native(condition: false) | ||
| ->displayFormat('d/m/Y') | ||
| ->format('Y-m-d') | ||
| ->minDate(now()->subYears(120)) | ||
| ->maxDate(now()) | ||
| ->suffixIcon(Heroicon::Calendar, isInline: true) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== locate files =="
git ls-files | rg 'ProfilePage\.php|\.php$' | sed -n '1,120p'
echo "== target file outline/size =="
wc -l app-modules/panel-app/src/Pages/ProfilePage.php
ast-grep outline app-modules/panel-app/src/Pages/ProfilePage.php --view expanded || true
echo "== relevant target sections =="
cat -n app-modules/panel-app/src/Pages/ProfilePage.php | sed -n '1,180p'
echo "== search save/formData/birthdate usages =="
rg -n "save|formData|data->|data\[|birthdate|Profile" app-modules/panel-app/src/Pages/ProfilePage.php app-modules/panel-app/src app-modules -g '*.php' | sed -n '1,240p'Repository: he4rt/heartdevs.com Length of output: 46770 🌐 Web query:
💡 Result: In Filament, the Citations:
🌐 Web query:
💡 Result: In the Filament PHP framework, the file located at packages/forms/resources/js/components/date-time-picker.js is a core JavaScript component that manages the custom date and time picker functionality [1]. Key details regarding this file and its context within Filament v5.6.0: 1. Functionality: This file defines the Alpine.js component (typically registered as dateTimePickerFormComponent) that powers the date-time-picker form field when it is not using the native browser input mode [1]. It relies on the Day.js library to handle date formatting, localization, and manipulation [2][1]. 2. Evolution in v5.6.0: Filament v5.6.0 was released on April 21, 2026 [3][4]. Throughout the v5.x lifecycle, this file has undergone structural improvements, including refactoring to better align with project standards [5]. For instance, recent updates have focused on moving Alpine.js x-data logic out of Blade views and directly into this JavaScript file, as well as updating event listeners (e.g., switching to x-on:invalid and x-on:blur) [5]. 3. Architecture: The component is built to be modular. While older versions of Filament (v2.x) relied on CommonJS require statements within this file to load Day.js locales—which caused compatibility issues with modern bundlers like Vite—later versions have moved toward cleaner import patterns and optimized bundling processes [6]. 4. Usage: It is internal to the framework's package structure. Developers generally do not interact with this raw file directly; instead, they use the PHP DateTimePicker component in their Laravel/Filament forms, which automatically handles the registration and loading of the necessary JavaScript assets [1]. Citations:
🌐 Web query:
💡 Result: In Filament v5.6.0, the DateTimePicker component uses 'Y-m-d H:i:s' as its default internal format when the non-native (JavaScript) date picker is enabled [1]. When using the component, you can control the storage format—the format used when the data is saved to your database—by using the Citations:
Persist the dehydrated birthdate state.
🤖 Prompt for AI Agents |
||
| ->extraAttributes([ | ||
| // Suffix icon sits outside the trigger button; open the panel on icon click. | ||
| 'x-on:click' => <<<'JS' | ||
| if (! $event.target.closest('.fi-input-wrp-suffix')) return; | ||
| if ($event.target.closest('.fi-input-wrp-actions')) return; | ||
| $el.querySelector('button.fi-fo-date-time-picker-trigger')?.click(); | ||
| JS, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== locate files =="
fd -a 'ProfilePage\.php|date-time-picker\.blade\.php' . | sed 's#^\./##' | head -200
echo "== ProfilePage relevant lines =="
file="$(fd 'ProfilePage\.php' . | head -1)"
if [ -n "${file:-}" ]; then
wc -l "$file"
sed -n '80,140p' "$file" | cat -n
fi
echo "== search suffix icon / click handling in repo =="
rg -n "suffixIcon|fi-input-wrp-suffix|fi-input-wrp-actions|fi-fo-date-time-picker-trigger|x-on:click|ke[ey]|enter|keydown|keypress" -S .Repository: he4rt/heartdevs.com Length of output: 50376 🏁 Script executed: #!/bin/bash
set -euo pipefail
profile="$(fd -a 'ProfilePage\.php' . | head -1)"
echo "PROFILE=$profile"
if [ -n "$profile" ]; then
wc -l "$profile"
sed -n '1,180p' "$profile" | cat -n
fi
echo "== focused search for relevant symbols =="
rg -n "Date\.dateTimes\(|suffixIcon\(|fi-input-wrp-suffix|fi-fo-date-time-picker-trigger|tabindex|key|click\\(|date-time-picker|Calendar\.Heroicon|Heroicon::Calendar" -S app-modules/panel-app/src/Pages/ProfilePage.php || trueRepository: he4rt/heartdevs.com Length of output: 10445 🌐 Web query:
💡 Result: In Filament PHP, the DateTimePicker component handles suffix icons and trigger buttons as part of its core input wrapper [1][2]. Regarding tab index and focus behavior, historical issues involving redundant tab stops in the DateTimePicker were addressed by ensuring appropriate tabindex settings [3]. 1. Suffix Icon and Action Implementation: You can add a suffix icon to a DateTimePicker using the ->suffixIcon method [1][4]. If you need a clickable interaction (such as opening the picker or a custom action), Filament uses suffix actions [5][6]. These are implemented via the ->suffixAction or ->suffixActions methods, which wrap the action in an icon-button view by default [5][7]. 2. Tab Index and Trigger Behavior: Filament specifically manages the tab index of the DateTimePicker's trigger button to ensure seamless keyboard navigation [3]. - Historical Fix: To prevent the input and the trigger button from both stealing focus (which would cause the user to tab twice to exit the component), the trigger button is often configured with tabindex="-1" [3]. This ensures that the primary focus remains on the input field while still allowing the component to be triggered via keyboard interactions (such as the Enter key or specific focus events) [3]. - Accessibility: This design choice aims to provide a consistent focus outline and predictable tab flow across browsers like Chrome and Firefox [3]. If you are encountering unexpected tab index behavior in custom implementations or specific modals, verify if there are conflicting attributes in your custom Blade views or extra attributes [8]. The core component manages these attributes via the InputAttributeBag and internal logic to maintain standardized accessible behavior [9][10]. If you need to customize this, you can use the ->extraTriggerAttributes method on the DateTimePicker to manually override or adjust attributes on the trigger element [2][11]. Citations:
🌐 Web query:
💡 Result: In FilamentPHP v5.6.0, the Citations:
🌐 Web query:
💡 Result: The file packages/forms/resources/views/components/date-time-picker.blade.php in the Filament PHP framework corresponds to the Blade component template for the DateTimePicker form field [1][2]. In version v5.6.0, released on April 21, 2026 [3][4], this component handles rendering the date and time picker input, including logic for configuration such as min/max dates, read-only states, and integration with Alpine.js [1][2]. As of July 27, 2026, version v5.6.0 is an older release in the 5.x series, which has since seen multiple subsequent updates (e.g., v5.6.8, v5.7.0, and v5.7.1) [5][6]. Changes to this specific file in the repository have included bug fixes for SPA mode compatibility and typo corrections (e.g., fixing variable naming such as $isReadonly to $isReadOnly) [7][8][9]. You can view the source code for this component directly on the official Filament GitHub repository for specific versions or the current branch [1][2][6]. Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== temp raw source =="
tmp="$(mktemp -d)"
curl -LfsS https://raw.githubusercontent.com/filamentphp/filament/v5.6.0/packages/forms/resources/views/components/date-time-picker.blade.php -o "$tmp/date-time-picker.blade.php"
curl -LfsS https://raw.githubusercontent.com/filamentphp/filament/v5.6.0/packages/forms/src/Concerns/HasAffixes.php -o "$tmp/HasAffixes.php"
curl -LfsS https://raw.githubusercontent.com/filamentphp/filament/v5.6.0/packages/forms/resources/views/components/input.blade.php -o "$tmp/input.blade.php" 2>/dev/null || true
echo "== date-time picker relevant snippets =="
grep -nE "suffix|trigger|tabindex|button|input-wrp-suffix|fi-fo-date-time-picker-trigger" "$tmp/date-time-picker.blade.php" "$tmp/HasAffixes.php" || true
sed -n '1,240p' "$tmp/date-time-picker.blade.php" | cat -nRepository: he4rt/heartdevs.com Length of output: 230 🌐 Web query:
💡 Result: In Filament, the DateTimePicker component supports interactive buttons via "affix actions" [1]. These are distinct from static suffix icons (added via Citations:
🌐 Web query:
💡 Result: The requested components and methods, such as suffixIcon and isInline, are part of the Filament PHP framework's form builder package, specifically within the DateTimePicker component [1]. In Filament, the DateTimePicker component allows for extensive customization of its appearance and functionality. To utilize the suffixIcon method, you can chain it onto the DateTimePicker component definition to display an icon inside the input field's suffix area. Regarding isInline, this is typically used in form components to control whether the component's label or field structure aligns horizontally rather than the default stacked layout. The file path packages/forms/resources/views/components referenced in your query corresponds to the internal directory structure of the Filament Forms package where the Blade templates for these components reside [1]. Please note that developers generally should not modify these core view files directly, but rather use the fluent API provided by the DateTimePicker class to configure these attributes. You can find the relevant methods defined in the official Filament documentation under the Forms component section for Date Time Picker. Citations: 🌐 Web query:
💡 Result: In Filament PHP, the Citations:
Make the custom calendar icon keyboard-accessible.
🤖 Prompt for AI Agents |
||
| ]), | ||
| ]), | ||
|
|
||
| Section::make(__('panel-app::profile.sections.professional')) | ||
| ->schema([ | ||
| Grid::make(3)->schema([ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: he4rt/heartdevs.com
Length of output: 304
🌐 Web query:
Filament v5 dateTimePicker client submits date as UTC midnight minDate maxDate server validation full timestamp💡 Result:
In Filament v5, the DateTimePicker component handles date and time values by respecting the configured timezone. By default, Filament uses the application's configured timezone (defined in your app config) [1][2]. When a timezone is specified using the
timezone()method, the component automatically converts the input to that timezone for display and converts it back to the application's default timezone (usually UTC) upon saving [1][2]. Regarding your specific concerns: Client Submission and UTC: When the form is submitted, Filament handles the data transformation based on the component'stimezone()configuration. If a timezone is set (e.g., 'America/New_York'), the picker manages the conversion so that the value saved to the database remains in the application's default timezone (typically UTC) [1][2]. To ensure consistency and avoid "shifting" issues, it is essential to use appropriate Eloquent model casts (e.g.,datetime,immutable_datetime) on your model attributes [3]. Without proper casting, or if accessors/mutators conflict, the date values may shift incorrectly during load and save cycles [3]. Midnight and Date-Only Fields: Filament treatsDatePicker(date-only) differently thanDateTimePicker. For date-only fields, thetimezone()method is generally not intended to be used, as this can lead to unexpected date shifts (e.g., saving the day before due to timezone offsets from midnight) [1][2][4]. If you are using aDatePicker, avoid applying a timezone to prevent these issues [1][4]. Server Validation (minDate/maxDate): TheminDate()andmaxDate()methods perform server-side validation using Laravel's validation rules (after_or_equalandbefore_or_equal) [5][6]. - These methods acceptDateTimeinstances (such as Carbon) or strings [6][7]. - Filament internally evaluates these values to generate the required validation rules [5]. - When performing validation, ensure that the comparison values passed tominDate()andmaxDate()are normalized to the same timezone as your application's stored format (typically UTC) to ensure the validation logic is accurate against the timestamp being saved [6][7]. To troubleshoot unexpected shifts: 1. Ensure your model attributes are properly cast todatetimeorimmutable_datetime[3]. 2. If usingDatePicker(date-only), remove anytimezone()calls [1][4]. 3. ForDateTimePicker, verify that thetimezone()matches the expected user or application context and that you are not performing manual mutations that conflict with Filament's internal handling [1][2][3].Citations:
🏁 Script executed:
Repository: he4rt/heartdevs.com
Length of output: 4743
🌐 Web query:
Filament DateTimePicker minDate maxDate server validation code after_or_equal before_or_equal💡 Result:
In Filament, you should use the built-in minDate and maxDate methods on the DateTimePicker component to handle both frontend constraints and server-side validation [1][2][3]. When you use these methods, Filament automatically applies the corresponding Laravel validation rules (after_or_equal and before_or_equal) to your form component [4]. Implementation: use Filament\Forms\Components\DateTimePicker; DateTimePicker::make('start_date') ->minDate(now) ->maxDate(now->addDays(7)) How it works: 1. Native Validation: The minDate and maxDate methods internally call the ->rule method on the component [4]. 2. Server Validation: Specifically, minDate adds the after_or_equal rule, and maxDate adds the before_or_equal rule [4]. 3. Dynamic Values: You can pass static dates (like Carbon instances or strings) or closures to these methods to calculate the limits dynamically at runtime [1][3]. If a closure returns null, the validation rule is not applied [1][3]. If you need to perform additional validation against other fields in your form, you should use the dedicated validation methods provided by Filament rather than writing raw strings in a rule method [5][6][7]. For example, to ensure an end_date is after or equal to a start_date, you can use: DateTimePicker::make('end_date') ->afterOrEqual('start_date')
Citations:
🏁 Script executed:
Repository: he4rt/heartdevs.com
Length of output: 1950
🏁 Script executed:
Repository: he4rt/heartdevs.com
Length of output: 1379
🌐 Web query:
GitHub raw.githubusercontent.com filamentphp filament v5.6.0 packages forms src Components DatePicker.php minDate💡 Result:
In Filament v5.6.0, the DatePicker component does not define a
minDateproperty directly within its own class file. Instead, it extends theDateTimePickercomponent, which handles theminDatelogic [1][2]. TheDatePickerclass primarily serves to restrict the picker to date-only selection by overriding thehasTime()method [1]: public function hasTime: bool { return false; } TheminDatefunctionality is inherited from theDateTimePickercomponent, which includes aminDate()method to set the minimum allowed date (acceptingCarboninstances, strings, or closures) and agetMinDate()method to retrieve the evaluated value [3][2]. Users have noted that when aminDateis set, the picker may default its focused date to theminDaterather than the current date [4][5]. While this has been discussed as intended behavior when the current date falls outside the allowed range, enhancements have been made to the underlying logic in various updates to improve focused date behavior [4][5].Citations:
Align DatePicker bounds with date-only values.
DatePicker::minDate()/maxDate()are inherited fromDateTimePickerand pass these values into timestamp-based validation rules (after_or_equal/before_or_equal). Since this field submits only a date, usetoday()->subYears(120)andtoday()so values on the selected day don’t fail before/after comparisons.🤖 Prompt for AI Agents