diff --git a/CHANGELOG.md b/CHANGELOG.md index 56875d62e..2231ea6e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to `laravel-livewire-tables` will be documented in this file +## [3.0.0-beta.4] - 2023-10-17 +- Introduction of Loading Placeholder +- Docs livewire namespace fix [Here](https://github.com/rappasoft/laravel-livewire-tables/pull/1420) +- Add CollapseAlways capability for Columns + ## [3.0.0-beta.3] - 2023-10-13 - Fix for Livewire ^3.0.6 where the table loading causes an additional lifecycle - Add unminified files to .gitattributes export-ignore @@ -1000,4 +1005,4 @@ Ground Up Rebuild [0.1.4]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.3...v0.1.4 [0.1.3]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.2...v0.1.3 [0.1.2]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.1...v0.1.2 -[0.1.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.0...v0.1.1 \ No newline at end of file +[0.1.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.0...v0.1.1 diff --git a/docs/datatable/loaders.md b/docs/datatable/loaders.md new file mode 100644 index 000000000..a18c7b77e --- /dev/null +++ b/docs/datatable/loaders.md @@ -0,0 +1,80 @@ +--- +title: Loaders +weight: 4 +--- + +With the introduction of Livewire 3, there are several new methods available for use: + +## Loading Placeholder +```php +public function configure(): void +{ + $this->setLoadingPlaceholderBlade(''); +} +``` + +### setLoadingPlaceholderStatus +```php +public function configure(): void +{ + $this->setLoadingPlaceholderStatus(true); +} +``` + +### setLoadingPlaceholderEnabled +```php +public function configure(): void +{ + $this->setLoadingPlaceholderEnabled(); +} +``` + + +### setLoadingPlaceholderDisabled +```php +public function configure(): void +{ + $this->setLoadingPlaceholderDisabled(); +} +``` + +### setLoadingPlaceholderContent +```php +public function configure(): void +{ + $this->setLoadingPlaceholderContent(''); +} +``` + +### setLoadingPlaceHolderAttributes +```php +public function configure(): void +{ + $this->setLoadingPlaceHolderAttributes([]); +} +``` + +### setLoadingPlaceHolderIconAttributes +```php +public function configure(): void +{ + $this->setLoadingPlacehosetLoadingPlaceHolderIconAttributeslderBlade([]); +} +``` + +### setLoadingPlaceHolderWrapperAttributes +```php +public function configure(): void +{ + $this->setLoadingPlaceHolderWrapperAttributes([]); +} +``` + + +### setLoadingPlaceholderBlade +```php +public function configure(): void +{ + $this->setLoadingPlaceholderBlade(''); +} +``` diff --git a/docs/misc/custom-markup.md b/docs/misc/custom-markup.md index 62e1aa012..8bfb6ec86 100644 --- a/docs/misc/custom-markup.md +++ b/docs/misc/custom-markup.md @@ -1,6 +1,6 @@ --- title: Adding Custom Markup -weight: 3 +weight: 4 --- If you would like to append any custom markup right before the end of the component, you may use the `customView` method and return a view. @@ -12,4 +12,4 @@ public function customView(): string { return 'includes.custom'; } -``` \ No newline at end of file +``` diff --git a/docs/misc/debugging.md b/docs/misc/debugging.md index c1c8f3193..fb42f5a7f 100644 --- a/docs/misc/debugging.md +++ b/docs/misc/debugging.md @@ -1,6 +1,6 @@ --- title: Debugging -weight: 4 +weight: 5 --- ## Configuration diff --git a/docs/misc/loading-placeholder.md b/docs/misc/loading-placeholder.md new file mode 100644 index 000000000..20ca7f9b5 --- /dev/null +++ b/docs/misc/loading-placeholder.md @@ -0,0 +1,78 @@ +--- +title: Loading Placeholder +weight: 2 +--- + +When running complex filters or searches, or displaying larger number of records, you can make use of the built-in Loading Placeholder, this is disabled by default. + +### setLoadingPlaceholderStatus +You may pass a boolean to this, which will either enable (true) or disable (false) the loading placeholder + +```php + public function configure(): void + { + $this->setLoadingPlaceholderStatus(true); + } +``` + +### setLoadingPlaceholderEnabled + +Use this method to enable the loading placeholder: + +```php + public function configure(): void + { + $this->setLoadingPlaceholderEnabled(); + } +``` + +### setLoadingPlaceholderDisabled + +Use this method to disable the loading placeholder: + +```php + public function configure(): void + { + $this->setLoadingPlaceholderDisabled(); + } +``` + +### setLoadingPlaceholderContent + +You may use this method to set custom text for the placeholder: + +```php + public function configure(): void + { + $this->setLoadingPlaceholderContent('Text To Display'); + } +``` +### setLoadingPlaceHolderWrapperAttributes + +This method allows you to customise the attributes for the <tr> element used as a Placeholder when the table is loading. Similar to other setAttribute methods, this accepts a range of attributes, and a boolean "default", which will enable/disable the default attributes. + +```php + public function configure(): void + { + $this->setLoadingPlaceHolderWrapperAttributes([ + 'class' => 'text-bold', + 'default' => false, + ]); + } + +``` + +### setLoadingPlaceHolderIconAttributes + +This method allows you to customise the attributes for the <div> element that is used solely for the PlaceholderIcon. Similar to other setAttribute methods, this accepts a range of attributes, and a boolean "default", which will enable/disable the default attributes. + +```php + public function configure(): void + { + $this->setLoadingPlaceHolderIconAttributes([ + 'class' => 'lds-hourglass', + 'default' => false, + ]); + } + +``` diff --git a/docs/misc/multiple-tables.md b/docs/misc/multiple-tables.md index 026d8ca1b..2a6ac0dd4 100644 --- a/docs/misc/multiple-tables.md +++ b/docs/misc/multiple-tables.md @@ -1,6 +1,6 @@ --- title: Multiple Tables Same Page -weight: 2 +weight: 3 --- This feature works for mutiple tables on the same page that are **different** components. diff --git a/docs/misc/saving-state.md b/docs/misc/saving-state.md index 3ce5148ee..8d85acd26 100644 --- a/docs/misc/saving-state.md +++ b/docs/misc/saving-state.md @@ -1,6 +1,6 @@ --- title: Saving Table State -weight: 5 +weight: 6 --- There may be occasions that you'd like to save the table state, for example if you have a complex set of filters, search parameters, or simply to remember which page you were on! diff --git a/resources/css/laravel-livewire-tables.css b/resources/css/laravel-livewire-tables.css index 0073ed497..77c564573 100644 --- a/resources/css/laravel-livewire-tables.css +++ b/resources/css/laravel-livewire-tables.css @@ -362,3 +362,41 @@ label[dir=rtl] .range-slider { .superhide { display: none; } + +.lds-hourglass { + display: inline-block; + position: relative; + width: 80px; + height: 80px; + } + .lds-hourglass:after { + content: " "; + display: block; + border-radius: 50%; + width: 0; + height: 0; + margin: 8px; + box-sizing: border-box; + border: 32px solid #000; + border-color: #fff transparent #fff transparent; + animation: lds-hourglass 1.2s infinite; + } + .dark .lds-hourglass:after { + border: 32px solid #FFF; + + } + + + @keyframes lds-hourglass { + 0% { + transform: rotate(0); + animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); + } + 50% { + transform: rotate(900deg); + animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); + } + 100% { + transform: rotate(1800deg); + } + } \ No newline at end of file diff --git a/resources/css/laravel-livewire-tables.min.css b/resources/css/laravel-livewire-tables.min.css index bb9cc4680..bf77392cc 100644 --- a/resources/css/laravel-livewire-tables.min.css +++ b/resources/css/laravel-livewire-tables.min.css @@ -4,4 +4,4 @@ var(--value, 0), var(--max));--value-b:var(--value, 0);--text-value-a:var(--text-value, "");--completed-a:calc((var(--value-a) - var(--min)) / (var(--max) - var(--min)) * 100);--completed-b:calc((var(--value-b) - var(--min)) / (var(--max) - var(--min)) * 100);--ca:Min(var(--completed-a), var(--completed-b));--cb:Max(var(--completed-a), var(--completed-b));--thumbs-too-close:Clamp(-1, 1000 * (Min(1, Max(var(--cb) - var(--ca) - 5, -1)) + 0.001), 1);--thumb-close-to-min:Min(1, Max(var(--ca) - 2, - 0));--thumb-close-to-max:Min(1, Max(98 - var(--cb), 0));display:inline-block;height:max(var(--track-height),var(--thumb-size));background:linear-gradient(to right,var(--ticks-color,silver) var(--ticks-thickness),transparent 1px) repeat-x;background-size:var(--tickIntervalPerc) var(--ticks-height);background-position-x:calc(var(--thumb-size)/ 2 - var(--ticks-thickness)/ 2);background-position-y:var(--flip-y,bottom);padding-bottom:var(--flip-y,var(--ticks-gap));padding-top:calc(var(--flip-y) * var(--ticks-gap));position:relative;z-index:1}.range-slider::after,.range-slider::before{--offset:calc(var(--thumb-size) / 2);content:counter(x);display:var(--show-min-max,block);font:var(--min-max-font, 12px Arial);position:absolute;bottom:var(--flip-y,-2.5ch);top:calc(-2.5ch * var(--flip-y));opacity:clamp(0, var(--at-edge), var(--min-max-opacity));transform:translateX(calc(var(--min-max-x-offset) * var(--before,-1) * -1)) scale(var(--at-edge));pointer-events:none}.dark .range-slider::after,.dark .range-slider::before,.dark .range-slider>input+output::after,.dark .range-slider>input:first-of-type+output::after{color:#fff}.range-slider::before{--before:1;--at-edge:var(--thumb-close-to-min);counter-reset:x var(--min);left:var(--offset)}.range-slider::after{--at-edge:var(--thumb-close-to-max);counter-reset:x var(--max);right:var(--offset)}.range-slider__progress::after,.range-slider__progress::before{content:"";top:0;right:0;bottom:0;border-radius:inherit;left:0}.range-slider__values{position:relative;top:50%;line-height:0;text-align:justify;width:100%;pointer-events:none;margin:0 auto;z-index:5}.range-slider__values::after{content:"";width:100%;display:inline-block;height:0;background:red}.range-slider__progress{--start-end:calc(var(--thumb-size) / 2);--clip-end:calc(100% - (var(--cb)) * 1%);--clip-start:calc(var(--ca) * 1%);--clip:inset(-20px var(--clip-end) -20px var(--clip-start));position:absolute;left:var(--start-end);right:var(--start-end);top:calc(var(--ticks-gap) * var(--flip-y,0) + var(--thumb-size)/ 2 - var(--track-height)/ 2);height:calc(var(--track-height));background:var(--progress-background,#eee);pointer-events:none;z-index:-1;border-radius:var(--progress-radius)}.range-slider__progress::before{position:absolute;-webkit-clip-path:var(--clip);clip-path:var(--clip);background:var(--fill-color,#0366d6);box-shadow:var(--progress-flll-shadow);z-index:1}.range-slider__progress::after{position:absolute;box-shadow:var(--progress-shadow);pointer-events:none}.range-slider>input{-webkit-appearance:none;width:100%;height:var(--thumb-size);margin:0;position:absolute;left:0;top:calc(50% - Max(var(--track-height),var(--thumb-size))/ 2 + calc(var(--ticks-gap)/ 2 * var(--flip-y,-1)));cursor:-webkit-grab;cursor:grab;outline:0;background:0 0}.range-slider>input:not(:only-of-type){pointer-events:none}.range-slider>input::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;height:var(--thumb-size);width:var(--thumb-size);transform:var(--thumb-transform);border-radius:var(--thumb-radius,50%);background:var(--thumb-color,#fff);box-shadow:var(--thumb-shadow);border:none;pointer-events:auto;-webkit-transition:.1s;transition:.1s}.range-slider>input::-moz-range-thumb{-moz-appearance:none;appearance:none;height:var(--thumb-size);width:var(--thumb-size);transform:var(--thumb-transform);border-radius:var(--thumb-radius,50%);background:var(--thumb-color,#fff);box-shadow:var(--thumb-shadow);border:none;pointer-events:auto;-moz-transition:.1s;transition:.1s}.range-slider>input::-ms-thumb{appearance:none;height:var(--thumb-size);width:var(--thumb-size);transform:var(--thumb-transform);border-radius:var(--thumb-radius,50%);background:var(--thumb-color,#fff);box-shadow:var(--thumb-shadow);border:none;pointer-events:auto;-ms-transition:.1s;transition:.1s}.range-slider>input:hover{--thumb-shadow:var(--thumb-shadow-hover)}.range-slider>input:hover+output{--value-background:var(--value-background-hover, #0366d6);--y-offset:-5px;color:var(--value-active-color,#fff);box-shadow:0 0 0 3px var(--value-background)}.range-slider>input:active{--thumb-shadow:var(--thumb-shadow-active);cursor:-webkit-grabbing;cursor:grabbing;z-index:2}.range-slider>input:active+output{transition:none}.range-slider>input:first-of-type{--is-left-most:Clamp(0, (var(--value-a) - var(--value-b)) * 99999, 1)}.range-slider>input:first-of-type+output{--value:var(--value-a);--x-offset:calc(var(--completed-a) * -1%)}.range-slider>input:first-of-type+output:not(:only-of-type){--flip:calc(var(--thumbs-too-close) * -1)}.range-slider>input:first-of-type+output::after{content:var(--prefix, "") var(--text-value-a) var(--suffix, "")}.range-slider>input:nth-of-type(2){--is-left-most:Clamp(0, (var(--value-b) - var(--value-a)) * 99999, 1)}.range-slider>input:nth-of-type(2)+output{--value:var(--value-b)}.range-slider>input:only-of-type~.range-slider__progress{--clip-start:0}.range-slider>input+output{--flip:-1;--x-offset:calc(var(--completed-b) * -1%);--pos:calc(((var(--value) - var(--min)) / (var(--max) - var(--min))) * 100%);pointer-events:none;position:absolute;z-index:5;background:var(--value-background);border-radius:10px;padding:2px 4px;left:var(--pos);transform:translate(var(--x-offset),calc(150% * var(--flip) - (var(--y-offset,0px) + var(--value-offset-y)) * var(--flip)));transition:.12s ease-out,left}.range-slider>input+output::after{content:var(--prefix, "") var(--text-value-b) var(--suffix, "");font:var(--value-font)}body>.range-slider,label[dir=rtl] .range-slider{width:clamp(300px,50vw,800px);min-width:200px}.superhide{display:none} \ No newline at end of file + 0));--thumb-close-to-max:Min(1, Max(98 - var(--cb), 0));display:inline-block;height:max(var(--track-height),var(--thumb-size));background:linear-gradient(to right,var(--ticks-color,silver) var(--ticks-thickness),transparent 1px) repeat-x;background-size:var(--tickIntervalPerc) var(--ticks-height);background-position-x:calc(var(--thumb-size)/ 2 - var(--ticks-thickness)/ 2);background-position-y:var(--flip-y,bottom);padding-bottom:var(--flip-y,var(--ticks-gap));padding-top:calc(var(--flip-y) * var(--ticks-gap));position:relative;z-index:1}.range-slider::after,.range-slider::before{--offset:calc(var(--thumb-size) / 2);content:counter(x);display:var(--show-min-max,block);font:var(--min-max-font, 12px Arial);position:absolute;bottom:var(--flip-y,-2.5ch);top:calc(-2.5ch * var(--flip-y));opacity:clamp(0, var(--at-edge), var(--min-max-opacity));transform:translateX(calc(var(--min-max-x-offset) * var(--before,-1) * -1)) scale(var(--at-edge));pointer-events:none}.dark .range-slider::after,.dark .range-slider::before,.dark .range-slider>input+output::after,.dark .range-slider>input:first-of-type+output::after{color:#fff}.range-slider::before{--before:1;--at-edge:var(--thumb-close-to-min);counter-reset:x var(--min);left:var(--offset)}.range-slider::after{--at-edge:var(--thumb-close-to-max);counter-reset:x var(--max);right:var(--offset)}.range-slider__progress::after,.range-slider__progress::before{content:"";top:0;right:0;bottom:0;border-radius:inherit;left:0}.range-slider__values{position:relative;top:50%;line-height:0;text-align:justify;width:100%;pointer-events:none;margin:0 auto;z-index:5}.range-slider__values::after{content:"";width:100%;display:inline-block;height:0;background:red}.range-slider__progress{--start-end:calc(var(--thumb-size) / 2);--clip-end:calc(100% - (var(--cb)) * 1%);--clip-start:calc(var(--ca) * 1%);--clip:inset(-20px var(--clip-end) -20px var(--clip-start));position:absolute;left:var(--start-end);right:var(--start-end);top:calc(var(--ticks-gap) * var(--flip-y,0) + var(--thumb-size)/ 2 - var(--track-height)/ 2);height:calc(var(--track-height));background:var(--progress-background,#eee);pointer-events:none;z-index:-1;border-radius:var(--progress-radius)}.range-slider__progress::before{position:absolute;-webkit-clip-path:var(--clip);clip-path:var(--clip);background:var(--fill-color,#0366d6);box-shadow:var(--progress-flll-shadow);z-index:1}.range-slider__progress::after{position:absolute;box-shadow:var(--progress-shadow);pointer-events:none}.range-slider>input{-webkit-appearance:none;width:100%;height:var(--thumb-size);margin:0;position:absolute;left:0;top:calc(50% - Max(var(--track-height),var(--thumb-size))/ 2 + calc(var(--ticks-gap)/ 2 * var(--flip-y,-1)));cursor:-webkit-grab;cursor:grab;outline:0;background:0 0}.range-slider>input:not(:only-of-type){pointer-events:none}.range-slider>input::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;height:var(--thumb-size);width:var(--thumb-size);transform:var(--thumb-transform);border-radius:var(--thumb-radius,50%);background:var(--thumb-color,#fff);box-shadow:var(--thumb-shadow);border:none;pointer-events:auto;-webkit-transition:.1s;transition:.1s}.range-slider>input::-moz-range-thumb{-moz-appearance:none;appearance:none;height:var(--thumb-size);width:var(--thumb-size);transform:var(--thumb-transform);border-radius:var(--thumb-radius,50%);background:var(--thumb-color,#fff);box-shadow:var(--thumb-shadow);border:none;pointer-events:auto;-moz-transition:.1s;transition:.1s}.range-slider>input::-ms-thumb{appearance:none;height:var(--thumb-size);width:var(--thumb-size);transform:var(--thumb-transform);border-radius:var(--thumb-radius,50%);background:var(--thumb-color,#fff);box-shadow:var(--thumb-shadow);border:none;pointer-events:auto;-ms-transition:.1s;transition:.1s}.range-slider>input:hover{--thumb-shadow:var(--thumb-shadow-hover)}.range-slider>input:hover+output{--value-background:var(--value-background-hover, #0366d6);--y-offset:-5px;color:var(--value-active-color,#fff);box-shadow:0 0 0 3px var(--value-background)}.range-slider>input:active{--thumb-shadow:var(--thumb-shadow-active);cursor:-webkit-grabbing;cursor:grabbing;z-index:2}.range-slider>input:active+output{transition:none}.range-slider>input:first-of-type{--is-left-most:Clamp(0, (var(--value-a) - var(--value-b)) * 99999, 1)}.range-slider>input:first-of-type+output{--value:var(--value-a);--x-offset:calc(var(--completed-a) * -1%)}.range-slider>input:first-of-type+output:not(:only-of-type){--flip:calc(var(--thumbs-too-close) * -1)}.range-slider>input:first-of-type+output::after{content:var(--prefix, "") var(--text-value-a) var(--suffix, "")}.range-slider>input:nth-of-type(2){--is-left-most:Clamp(0, (var(--value-b) - var(--value-a)) * 99999, 1)}.range-slider>input:nth-of-type(2)+output{--value:var(--value-b)}.range-slider>input:only-of-type~.range-slider__progress{--clip-start:0}.range-slider>input+output{--flip:-1;--x-offset:calc(var(--completed-b) * -1%);--pos:calc(((var(--value) - var(--min)) / (var(--max) - var(--min))) * 100%);pointer-events:none;position:absolute;z-index:5;background:var(--value-background);border-radius:10px;padding:2px 4px;left:var(--pos);transform:translate(var(--x-offset),calc(150% * var(--flip) - (var(--y-offset,0px) + var(--value-offset-y)) * var(--flip)));transition:.12s ease-out,left}.range-slider>input+output::after{content:var(--prefix, "") var(--text-value-b) var(--suffix, "");font:var(--value-font)}body>.range-slider,label[dir=rtl] .range-slider{width:clamp(300px,50vw,800px);min-width:200px}.superhide{display:none}.lds-hourglass{display:inline-block;position:relative;width:80px;height:80px}.lds-hourglass:after{content:" ";display:block;border-radius:50%;width:0;height:0;margin:8px;box-sizing:border-box;border:32px solid #000;border-color:#000 transparent #fff;animation:1.2s infinite lds-hourglass}.dark .lds-hourglass:after{border:32px solid #fff;border-color:#fff transparent #000}@keyframes lds-hourglass{0%{transform:rotate(0);animation-timing-function:cubic-bezier(0.55,0.055,0.675,0.19)}50%{transform:rotate(900deg);animation-timing-function:cubic-bezier(0.215,0.61,0.355,1)}100%{transform:rotate(1800deg)}} \ No newline at end of file diff --git a/resources/views/components/includes/loading.blade.php b/resources/views/components/includes/loading.blade.php new file mode 100644 index 000000000..7c71772ed --- /dev/null +++ b/resources/views/components/includes/loading.blade.php @@ -0,0 +1,35 @@ +@aware(['isTailwind', 'isBootstrap', 'tableName', 'component']) +@props(['colCount' => 1]) + +@php +$customAttributes['loader-wrapper'] = $component->getLoadingPlaceHolderWrapperAttributes(); +$customAttributes['loader-icon'] = $component->getLoadingPlaceHolderIconAttributes(); +@endphp +@if($this->hasLoadingPlaceholderBlade()) + @include($this->getLoadingPlaceHolderBlade(), ['colCount' => $colCount]) +@else + +