Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ariaieboy/filament-currency
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.8.3
Choose a base ref
...
head repository: ariaieboy/filament-currency
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Aug 12, 2024

  1. Update CHANGELOG

    ariaieboy authored and github-actions[bot] committed Aug 12, 2024
    Copy the full SHA
    0ba7e0e View commit details
  2. Copy the full SHA
    0d9b13f View commit details
  3. Update CHANGELOG

    ariaieboy authored and github-actions[bot] committed Aug 12, 2024
    Copy the full SHA
    cfaa188 View commit details

Commits on Sep 22, 2024

  1. Copy the full SHA
    4680814 View commit details
  2. Copy the full SHA
    133db5e View commit details
  3. Merge pull request #42 from ariaieboy/41-add-textinputcolumn-currency…

    …mask-support
    
    41 add textinputcolumn currencymask support
    ariaieboy authored Sep 22, 2024
    Copy the full SHA
    9f6ae72 View commit details
  4. Fix styling

    ariaieboy authored and github-actions[bot] committed Sep 22, 2024
    Copy the full SHA
    96b7d2d View commit details
  5. Update README.md

    ariaieboy authored Sep 22, 2024
    Copy the full SHA
    b1bbd97 View commit details
  6. Update CHANGELOG

    ariaieboy authored and github-actions[bot] committed Sep 22, 2024
    Copy the full SHA
    64bec62 View commit details

Commits on Sep 24, 2024

  1. Copy the full SHA
    568f316 View commit details
  2. Merge pull request #44 from ariaieboy/fix_safari

    fix safari error on required inputs
    ariaieboy authored Sep 24, 2024
    Copy the full SHA
    b6e2c71 View commit details
  3. Update CHANGELOG

    ariaieboy authored and github-actions[bot] committed Sep 24, 2024
    Copy the full SHA
    5eec534 View commit details

Commits on Sep 29, 2024

  1. add php 8.4 support

    ariaieboy committed Sep 29, 2024
    Copy the full SHA
    c8a681b View commit details
  2. Update CHANGELOG

    ariaieboy authored and github-actions[bot] committed Sep 29, 2024
    Copy the full SHA
    d1caa6f View commit details

Commits on Nov 3, 2024

  1. Copy the full SHA
    4e64365 View commit details
  2. Fix styling

    ariaieboy authored and github-actions[bot] committed Nov 3, 2024
    Copy the full SHA
    0c00226 View commit details
  3. Update CHANGELOG

    ariaieboy authored and github-actions[bot] committed Nov 3, 2024
    Copy the full SHA
    1ead18d View commit details

Commits on Jan 9, 2025

  1. Update FilamentCurrencyServiceProvider.php

    Add Support for custom summerizers
    eele94 authored Jan 9, 2025
    Copy the full SHA
    7c111a6 View commit details
  2. Update ide-helper.stubs.php

    eele94 authored Jan 9, 2025
    Copy the full SHA
    c807d57 View commit details
  3. Update README.md

    eele94 authored Jan 9, 2025
    Copy the full SHA
    9621419 View commit details

Commits on Jan 11, 2025

  1. Merge pull request #46 from eele94/main

    Include Support for Summarizer
    ariaieboy authored Jan 11, 2025
    Copy the full SHA
    32d0afb View commit details
  2. Fix styling

    ariaieboy authored and github-actions[bot] committed Jan 11, 2025
    Copy the full SHA
    6fa9c45 View commit details
  3. Update CHANGELOG

    ariaieboy authored and github-actions[bot] committed Jan 11, 2025
    Copy the full SHA
    23ae4d0 View commit details

Commits on Feb 8, 2025

  1. Update composer.json

    ariaieboy authored Feb 8, 2025
    Copy the full SHA
    9fb338b View commit details
  2. Update CHANGELOG

    ariaieboy authored and github-actions[bot] committed Feb 8, 2025
    Copy the full SHA
    48d996b View commit details

Commits on Feb 15, 2025

  1. Copy the full SHA
    dfeaeb3 View commit details

Commits on Feb 27, 2025

  1. Merge pull request #47 from laravel-shift/l12-compatibility

    Laravel 12.x Compatibility
    ariaieboy authored Feb 27, 2025
    Copy the full SHA
    8fa87b3 View commit details
  2. Update CHANGELOG

    ariaieboy authored and github-actions[bot] committed Feb 27, 2025
    Copy the full SHA
    caaa6ef View commit details
Showing with 302 additions and 29 deletions.
  1. +70 −0 CHANGELOG.md
  2. +5 −1 README.md
  3. +9 −9 composer.json
  4. +1 −0 config/filament-currency.php
  5. +15 −0 ide-helper.stubs.php
  6. +21 −11 resources/views/currency-mask.blade.php
  7. +147 −0 resources/views/text-input-column.blade.php
  8. +34 −8 src/FilamentCurrencyServiceProvider.php
70 changes: 70 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,76 @@

All notable changes to `filament-currency` will be documented in this file.

## 1.13.0 - 2025-02-27

### What's Changed

* Laravel 12.x Compatibility by @laravel-shift in https://github.com/ariaieboy/filament-currency/pull/47

### New Contributors

* @laravel-shift made their first contribution in https://github.com/ariaieboy/filament-currency/pull/47

**Full Changelog**: https://github.com/ariaieboy/filament-currency/compare/1.12.0...1.13.0

## 1.12.0 - 2025-02-08

- add support for laravel-money version 6

> if you use PHP 8.4 you should upgrade to laravel-money version 6
**Full Changelog**: https://github.com/ariaieboy/filament-currency/compare/1.11.0...1.12.0

## 1.11.0 - 2025-01-11

### What's Changed

* Include Support for Summarizer by @eele94 in https://github.com/ariaieboy/filament-currency/pull/46

### New Contributors

* @eele94 made their first contribution in https://github.com/ariaieboy/filament-currency/pull/46

**Full Changelog**: https://github.com/ariaieboy/filament-currency/compare/1.10.0...1.11.0

## 1.10.0 - 2024-11-03

- add support for `MONEY_DEFAULTS_CONVERT` env variable

**Full Changelog**: https://github.com/ariaieboy/filament-currency/compare/1.9.2...1.10.0

## 1.9.2 - 2024-09-29

- add php 8.4 to composer.json

**Full Changelog**: https://github.com/ariaieboy/filament-currency/compare/1.9.1...1.9.2

## 1.9.1 - 2024-09-24

### What's Changed

* fix safari error on required inputs by @ariaieboy in https://github.com/ariaieboy/filament-currency/pull/44

**Full Changelog**: https://github.com/ariaieboy/filament-currency/compare/1.9.0...1.9.1

## 1.9.0 - 2024-09-22

### What's Changed

* 41 add textinputcolumn currencymask support by @ariaieboy in https://github.com/ariaieboy/filament-currency/pull/42

**Full Changelog**: https://github.com/ariaieboy/filament-currency/compare/1.8.4...1.9.0

## 1.8.4 - 2024-08-12

**Full Changelog**: https://github.com/ariaieboy/filament-currency/compare/1.8.3...1.8.4

## 1.8.3 - 2024-08-12

* fix issue https://github.com/ariaieboy/filament-currency/issues/39#issuecomment-2284272710

**Full Changelog**: https://github.com/ariaieboy/filament-currency/compare/1.8.2...1.8.3

## 1.8.2 - 2024-08-12

### What's Changed
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ A new `currency(string | Closure $currency = null, bool $shouldConvert = false)`

### Summary (Table Builder)

The summarizer classes `Sum` and `Average` contains the method `currency(string | Closure $currency = null, bool $shouldConvert = false)` to display the value in the configured currency format.
The summarizer classes `Summarizer`, `Sum` and `Average` contains the method `currency(string | Closure $currency = null, bool $shouldConvert = false)` to display the value in the configured currency format.

### Text Entry (InfoLists)

@@ -22,6 +22,10 @@ A new `currency(string | Closure $currency = null, bool $shouldConvert = false)`

We also have a `currencyMask()` method for `TextInput` that lets you mask your numbers in front-end and return the plain number to back-end.

### Text Input Column (Table Builder)

We also have a `currencyMask()` method for `TextInputColumn` that lets you mask your numbers in front-end and return the plain number to back-end.

By using this package you can configure the formatter using [laravel-money config](https://github.com/akaunting/laravel-money/blob/master/config/money.php).

For example, you can customize the `symbol`, `symbol_first`, `decimal_mark`, and `thousands_separator` for each currency. Or if you want you can add your custom currency to the config and use it in the `currency()` method instead of standard money.
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -20,23 +20,23 @@
}
],
"require": {
"php": "~8.1|~8.2|~8.3",
"akaunting/laravel-money": "^1.2|^2.0|^3.0|^4.0|^5.2",
"php": "~8.1|~8.2|~8.3|~8.4",
"akaunting/laravel-money": "^1.2|^2.0|^3.0|^4.0|^5.2|^6",
"filament/tables": "^3.0",
"illuminate/contracts": "^10.0|^11",
"illuminate/contracts": "^10.0|^11|^12.0",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9",
"larastan/larastan": "^2.7.0",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"orchestra/testbench": "^8.0|^10.0",
"pestphp/pest": "^2.0|^3.7",
"pestphp/pest-plugin-arch": "^2.0|^3.0",
"pestphp/pest-plugin-laravel": "^2.0|^3.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0"
"phpstan/phpstan-deprecation-rules": "^1.0|^2.0",
"phpstan/phpstan-phpunit": "^1.0|^2.0"
},
"autoload": {
"psr-4": {
1 change: 1 addition & 0 deletions config/filament-currency.php
Original file line number Diff line number Diff line change
@@ -7,4 +7,5 @@
* we use it in the fallback to support the laravel-money version 5.
*/
'default_currency' => env('CURRENCY_DEFAULT', env('MONEY_DEFAULTS_CURRENCY', config('money.defaults.currency', 'USD'))),
'default_convert' => env('MONEY_DEFAULTS_CONVERT', false),
];
15 changes: 15 additions & 0 deletions ide-helper.stubs.php
Original file line number Diff line number Diff line change
@@ -11,6 +11,13 @@ public function currency(string | Closure | null $currency = null, bool $shouldC
return $this;
}
}
class TextInputColumn
{
public function currencyMask($thousandSeparator = ',', $decimalSeparator = '.', $precision = 2): self
{
return $this;
}
}
}

namespace Filament\Forms\Components {
@@ -28,6 +35,14 @@ public function currencyMask($thousandSeparator = ',', $decimalSeparator = '.',

use Closure;

class Summarizer
{
public function currency(string | Closure | null $currency = null, bool $shouldConvert = false): self
{
return $this;
}
}

class Average
{
public function currency(string | Closure | null $currency = null, bool $shouldConvert = false): self
32 changes: 21 additions & 11 deletions resources/views/currency-mask.blade.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
@php
$datalistOptions = $getDatalistOptions();
$extraAlpineAttributes = $getExtraAlpineAttributes();
$hasInlineLabel = $hasInlineLabel();
$id = $getId();
$isConcealed = $isConcealed();
$isDisabled = $isDisabled();
$isLive = $isLive();
$isLiveOnBlur = $isLiveOnBlur();
$isLiveDebounced = $isLiveDebounced();
$liveDebounce = $getLiveDebounce();
$isPasswordRevealable = $isPasswordRevealable();
$isPrefixInline = $isPrefixInline();
$isSuffixInline = $isSuffixInline();
$mask = $getMask();
@@ -19,32 +17,43 @@
$suffixLabel = $getSuffixLabel();
$statePath = $getStatePath();
$xmask = "\$money(\$input,'$decimalSeparator','$thousandSeparator',$precision)";
$xmodel = "x-model".($isLive?($isLiveOnBlur?".lazy":($isLiveDebounced?(".debounce.".$liveDebounce."ms"):"")):"");
$xmodel = "x-model".($isLive()?($isLiveOnBlur()?".lazy":($isLiveDebounced()?(".debounce.".$getLiveDebounce()."ms"):"")):"");
$xdata = <<<JS
{
input:\$wire.{$applyStateBindingModifiers("\$entangle('{$statePath}')")},
masked:'',
init(){
\$nextTick(this.updateMasked());
\$watch('masked',(value, oldValue)=>this.updateInput(value, oldValue));
\$watch('masked',(value, oldValue)=>this.updateInput(value,oldValue));
\$watch('input', () => this.updateMasked());
},
updateMasked(){
if(this.input !== undefined && typeof Number(this.input) === 'number') {
if(this.masked?.replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.') !== this.input){
if(this.masked?.toString().replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.') !== this.input){
this.masked = this.input?.toString().replaceAll('.','$decimalSeparator');
}
}
},
updateInput(value, oldValue){
if(value !== oldValue)
this.input = this.masked?.replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.');
if(value?.toString().replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.') !== oldValue?.toString().replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.')){
this.input = this.masked?.toString().replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.');
}
}
}
JS;
@endphp
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field">
<x-slot
name="label"
@class([
'sm:pt-1.5' => $hasInlineLabel,
])
>
{{ $getLabel() }}
</x-slot>
<x-filament::input.wrapper
:disabled="$isDisabled"
:inline-prefix="$isPrefixInline"
@@ -55,11 +64,12 @@
:suffix="$suffixLabel"
:suffix-actions="$suffixActions"
:suffix-icon="$suffixIcon"
:suffix-icon-color="$getSuffixIconColor()"
:valid="! $errors->has($statePath)"
class="fi-fo-text-input"
:attributes="
\Filament\Support\prepare_inherited_attributes($getExtraAttributeBag())
->class(['overflow-hidden'])
->class(['fi-fo-text-input overflow-hidden'])
"
>
<x-filament::input
147 changes: 147 additions & 0 deletions resources/views/text-input-column.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
@php
use Filament\Support\Enums\Alignment;
$isDisabled = $isDisabled();
$state = $getState();
$mask = $getMask();
$alignment = $getAlignment() ?? Alignment::Start;
if (! $alignment instanceof Alignment) {
$alignment = filled($alignment) ? (Alignment::tryFrom($alignment) ?? $alignment) : null;
}
if (filled($mask)) {
$type = 'text';
} else {
$type = $getType();
}
$xmask = "\$money(\$input,'$decimalSeparator','$thousandSeparator',$precision)";
$xchange = <<<JS
isLoading = true
const response = await \$wire.updateTableColumnState(
name,
recordKey,
\$event.target.value.toString()?.replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.'),
)
error = response?.error ?? undefined
if (! error) {
if(state?.toString().replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.') !== response.toString()){
state = response
}
}
isLoading = false
JS;
@endphp
<div
x-data="{
error: undefined,
isEditing: false,
isLoading: false,
name: @js($getName()),
recordKey: @js($recordKey),
state: @js($state),
}"
x-init="
() => {
Livewire.hook('commit', ({ component, commit, succeed, fail, respond }) => {
succeed(({ snapshot, effect }) => {
$nextTick(() => {
if (component.id !== @js($this->getId())) {
return
}
if (isEditing) {
return
}
if (! $refs.newState) {
return
}
let newState = $refs.newState.value?.toString().replaceAll('{{$thousandSeparator}}','').replaceAll('{{$decimalSeparator}}','.')
if (state?.toString().replaceAll('{{$thousandSeparator}}','').replaceAll('{{$decimalSeparator}}','.') === newState) {
return
}
state = newState
})
})
})
}
"
{{
$attributes
->merge($getExtraAttributes(), escape: false)
->class([
'fi-ta-text-input',
'px-3 py-4' => ! $isInline(),
])
}}
>
<input
type="hidden"
value="{{ str($state)->replace('"', '\\"')->replace(',','') }}"
x-ref="newState"
/>
<x-filament::input.wrapper
:alpine-disabled="'isLoading || ' . \Illuminate\Support\Js::from($isDisabled)"
alpine-valid="error === undefined"
x-tooltip="
error === undefined
? false
: {
content: error,
theme: $store.theme,
}
"
x-on:click.stop=""
>
{{-- format-ignore-start --}}
<x-filament::input
:disabled="$isDisabled"
:input-mode="$getInputMode()"
:placeholder="$getPlaceholder()"
:step="$getStep()"
:type="$type"
:x-bind:disabled="$isDisabled ? null : 'isLoading'"
x-model="state"
x-on:blur="isEditing = false"
x-on:focus="isEditing = true"
:attributes="
\Filament\Support\prepare_inherited_attributes(
$getExtraInputAttributeBag()
->merge([
'x-on:change' . ($type === 'number' ? '.debounce.1s' : null) => $xchange,
'x-mask:dynamic'=> $xmask,
])
->class([
match ($alignment) {
Alignment::Start => 'text-start',
Alignment::Center => 'text-center',
Alignment::End => 'text-end',
Alignment::Left => 'text-left',
Alignment::Right => 'text-right',
Alignment::Justify, Alignment::Between => 'text-justify',
default => $alignment,
},
])
)
"
/>
{{-- format-ignore-end --}}
</x-filament::input.wrapper>
</div>
Loading