Skip to content

Commit bcb3b3b

Browse files
committed
CollapseRework5
1 parent f7e08d5 commit bcb3b3b

31 files changed

+644
-726
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"blade-ui-kit/blade-heroicons": "^2.1",
2828
"illuminate/contracts": "^10.0|^11.0|^12.0",
2929
"illuminate/support": "^10.0|^11.0|^12.0",
30-
"livewire/livewire": "^3.0|dev-main"
30+
"livewire/livewire": "*"
3131
},
3232
"require-dev": {
3333
"ext-sqlite3": "*",

resources/js/laravel-livewire-tables.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
/*jshint esversion: 6 */
2-
import reorder from "./partials/core/reorder.min.js";
32
import table from "./partials/core/table.min.js";
43
import tableWrap from "./partials/core/tableWrap.min.js";
54
import filterPills from "./partials/core/filterPills.min.js";
65
import externalFilter from "./partials/core/externalFilter.min.js";
7-
8-
6+
import tools from "./partials/core/tools.min.js";
97
import boolean from "./partials/filters/boolean.js";
108
import fpf from "./partials/filters/fpf.js";
119
import nrF from "./partials/filters/numberRange.js";
@@ -15,9 +13,8 @@ document.addEventListener('alpine:init', () => {
1513
table();
1614
tableWrap();
1715
filterPills();
18-
reorder();
1916
externalFilter();
20-
17+
tools();
2118
boolean();
2219
fpf();
2320
nrF();

resources/js/laravel-livewire-tables.min.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
/*jshint esversion: 6 */
2-
import reorder from "./partials/core/reorder.min.js";
32
import table from "./partials/core/table.min.js";
43
import tableWrap from "./partials/core/tableWrap.min.js";
54
import filterPills from "./partials/core/filterPills.min.js";
65
import externalFilter from "./partials/core/externalFilter.min.js";
7-
8-
6+
import tools from "./partials/core/tools.min.js";
97
import boolean from "./partials/filters/boolean.js";
108
import fpf from "./partials/filters/fpf.js";
119
import nrF from "./partials/filters/numberRange.js";
@@ -15,9 +13,8 @@ document.addEventListener('alpine:init', () => {
1513
table();
1614
tableWrap();
1715
filterPills();
18-
reorder();
1916
externalFilter();
20-
17+
tools();
2118
boolean();
2219
fpf();
2320
nrF();
Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,135 @@
11
/*jshint esversion: 6 */
2-
function filterPills(){Alpine.data("filterPillsHandler",l=>({localData:l,localFilterKey:"",localFilterTitle:"",isExternalFilter:!1,shouldRenderAsHTML:!1,shouldWatchPillValues:!1,pillsSeparator:",",pillValues:null,pillHasValues:!1,displayString:"",generateLocalFilterPillImplodedValues(l){if(void 0!==l){var t,i="---tablepillsseparator---",e=RegExp(i,"g");if(t=Array.isArray(l)?l.join(i):l,this.shouldRenderAsHTML||(t=this.removeHTMLTags(t)),null!==t)return t.replace(e,this.pillsSeparator)}return""},clearExternalFilterPill(){this.isExternalFilter&&(this.externalFilterPillsVals[this.localFilterKey]=[],this.displayString=this.generateLocalFilterPillImplodedValues(this.externalFilterPillsVals[this.localFilterKey]),this.updatePillHasValues(),this.resetSpecificFilter(this.localFilterKey))},trigger:{"@filterpillupdate.window"(l){this.watchForUpdateEvent(l)}},checkEventIsValid(l,t){return this.tableName===l&&this.localFilterKey===t},watchForUpdateEvent(l){if(this.checkEventIsValid(l.detail.tableName??"",l.detail.filterKey??"")){let t=l.detail.pillItem??"";if(this.shouldRenderAsHTML||(t=this.removeHTMLTags(t)),""!=t){if(this.isExternalFilter){let i=this.externalFilterPillsVals[this.localFilterKey];i.push(t),this.updatePillValues(i)}else this.updatePillValues(t)}}},updatePillValues(l){return this.pillValues=l,this.displayString=this.generateLocalFilterPillImplodedValues(l),this.updatePillHasValues(),this.displayString},updatePillHasValues(){this.pillHasValues=this.displayString.length>0},init(){this.localFilterKey=this.localData.filterKey??"unknown",this.localFilterTitle=this.localData.filterPillTitle??"Unknown",this.pillsSeparator=this.localData.separator??",",this.shouldWatchPillValues=Boolean(this.localData.watchForEvents??0),this.isExternalFilter=Boolean(this.localData.isAnExternalLivewireFilter??0),this.shouldRenderAsHTML=Boolean(this.localData.renderPillsAsHtml??0),this.pillValues=this.localData.pillValues??null,this.$nextTick(()=>{this.isExternalFilter?this.updatePillValues(this.externalFilterPillsVals[this.localFilterKey]):this.updatePillValues(this.pillValues)}),this.isExternalFilter&&this.shouldWatchPillValues&&this.$watch("externalFilterPillsVals."+this.localFilterKey,l=>{this.updatePillValues(l)})}}))}export default filterPills;
2+
3+
function filterPills() {
4+
Alpine.data('filterPillsHandler', (data) => ({
5+
localData: data,
6+
localFilterKey: '',
7+
localFilterTitle: '',
8+
isExternalFilter: false,
9+
shouldRenderAsHTML: false,
10+
shouldWatchPillValues: false,
11+
pillsSeparator: ',',
12+
pillValues: null,
13+
pillHasValues: false,
14+
displayString: '',
15+
generateLocalFilterPillImplodedValues(filterPillValues)
16+
{
17+
if(typeof(filterPillValues) !== 'undefined')
18+
{
19+
var temporarySeparatorString = '---tablepillsseparator---';
20+
var regex = new RegExp(temporarySeparatorString, 'g');
21+
var joinedValues;
22+
23+
if(Array.isArray(filterPillValues))
24+
{
25+
joinedValues = filterPillValues.join(temporarySeparatorString);
26+
}
27+
else
28+
{
29+
joinedValues = filterPillValues;
30+
}
31+
32+
if(!this.shouldRenderAsHTML)
33+
{
34+
joinedValues = this.removeHTMLTags(joinedValues);
35+
}
36+
37+
if (joinedValues !== null)
38+
{
39+
let replacedJoinedValues = joinedValues.replace(regex, this.pillsSeparator);
40+
return replacedJoinedValues;
41+
42+
}
43+
return "";
44+
}
45+
return "";
46+
},
47+
clearExternalFilterPill()
48+
{
49+
if(this.isExternalFilter)
50+
{
51+
this.externalFilterPillsVals[this.localFilterKey] = [];
52+
this.displayString = this.generateLocalFilterPillImplodedValues(this.externalFilterPillsVals[this.localFilterKey]);
53+
this.updatePillHasValues();
54+
this.resetSpecificFilter(this.localFilterKey);
55+
}
56+
},
57+
trigger: {
58+
['@filterpillupdate.window'](event) {
59+
this.watchForUpdateEvent(event);
60+
},
61+
},
62+
checkEventIsValid(eventTableName, eventFilterKey)
63+
{
64+
return ((this.tableName === eventTableName) && (this.localFilterKey === eventFilterKey));
65+
},
66+
watchForUpdateEvent(event)
67+
{
68+
if(this.checkEventIsValid(event.detail.tableName ?? '', event.detail.filterKey ?? ''))
69+
{
70+
let eventPillItem = event.detail.pillItem ?? '';
71+
if(!this.shouldRenderAsHTML)
72+
{
73+
eventPillItem = this.removeHTMLTags(eventPillItem);
74+
}
75+
76+
if(eventPillItem != "")
77+
{
78+
if(this.isExternalFilter)
79+
{
80+
let filterPillValues = this.externalFilterPillsVals[this.localFilterKey];
81+
82+
filterPillValues.push(eventPillItem);
83+
this.updatePillValues(filterPillValues);
84+
}
85+
else
86+
{
87+
this.updatePillValues(eventPillItem);
88+
}
89+
}
90+
}
91+
},
92+
updatePillValues(filterPillValues)
93+
{
94+
this.pillValues = filterPillValues;
95+
this.displayString = this.generateLocalFilterPillImplodedValues(filterPillValues);
96+
this.updatePillHasValues();
97+
98+
return this.displayString;
99+
},
100+
updatePillHasValues()
101+
{
102+
this.pillHasValues = (this.displayString.length > 0);
103+
},
104+
init()
105+
{
106+
this.localFilterKey = this.localData['filterKey'] ?? 'unknown';
107+
this.localFilterTitle = this.localData['filterPillTitle'] ?? 'Unknown';
108+
this.pillsSeparator = this.localData['separator'] ?? ',';
109+
this.shouldWatchPillValues = Boolean(this.localData['watchForEvents'] ?? 0);
110+
this.isExternalFilter = Boolean(this.localData['isAnExternalLivewireFilter'] ?? 0);
111+
this.shouldRenderAsHTML = Boolean(this.localData['renderPillsAsHtml'] ?? 0);
112+
this.pillValues = this.localData['pillValues'] ?? null;
113+
114+
this.$nextTick(() => {
115+
if(this.isExternalFilter)
116+
{
117+
this.updatePillValues(this.externalFilterPillsVals[this.localFilterKey]);
118+
}
119+
else
120+
{
121+
this.updatePillValues(this.pillValues);
122+
}
123+
});
124+
if(this.isExternalFilter && this.shouldWatchPillValues)
125+
{
126+
this.$watch('externalFilterPillsVals.'+this.localFilterKey, filterPillValues => {
127+
this.updatePillValues(filterPillValues);
128+
});
129+
}
130+
}
131+
}));
132+
133+
}
134+
135+
export default filterPills;

resources/js/partials/core/reorder.js

Lines changed: 0 additions & 139 deletions
This file was deleted.

resources/js/partials/core/reorder.min.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)