advanced-filter-system 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/dist/AFS.esm.js +106 -73
- package/dist/AFS.esm.js.map +1 -1
- package/dist/AFS.js +106 -73
- package/dist/AFS.js.map +1 -1
- package/dist/AFS.min.js +1 -1
- package/dist/AFS.min.js.map +1 -1
- package/package.json +1 -1
package/dist/AFS.js
CHANGED
|
@@ -145,11 +145,11 @@
|
|
|
145
145
|
*/
|
|
146
146
|
static defaults = {
|
|
147
147
|
// Selectors
|
|
148
|
-
containerSelector: '.filter-container',
|
|
149
|
-
itemSelector: '.filter-item',
|
|
150
|
-
filterButtonSelector: '.btn-filter',
|
|
151
|
-
searchInputSelector: '.filter-search',
|
|
152
|
-
counterSelector: '.filter-counter',
|
|
148
|
+
containerSelector: '.afs-filter-container',
|
|
149
|
+
itemSelector: '.afs-filter-item',
|
|
150
|
+
filterButtonSelector: '.afs-btn-filter',
|
|
151
|
+
searchInputSelector: '.afs-filter-search',
|
|
152
|
+
counterSelector: '.afs-filter-counter',
|
|
153
153
|
// Classes
|
|
154
154
|
activeClass: 'active',
|
|
155
155
|
hiddenClass: 'hidden',
|
|
@@ -176,26 +176,65 @@
|
|
|
176
176
|
// Styles
|
|
177
177
|
styles: {
|
|
178
178
|
slider: {
|
|
179
|
-
class: 'afs-range-slider',
|
|
180
|
-
trackClass: 'afs-range-track',
|
|
181
|
-
thumbClass: 'afs-range-thumb',
|
|
182
|
-
valueClass: 'afs-range-value',
|
|
183
|
-
selectedClass: 'afs-range-selected',
|
|
184
179
|
// Add new UI options
|
|
185
180
|
ui: {
|
|
186
181
|
showHistogram: false,
|
|
187
|
-
bins: 10
|
|
182
|
+
bins: 10,
|
|
183
|
+
// Number of bins for histogram
|
|
184
|
+
track: {
|
|
185
|
+
radius: '2px',
|
|
186
|
+
// Button radius
|
|
187
|
+
background: '#e5e7eb' // Track color
|
|
188
|
+
},
|
|
189
|
+
thumb: {
|
|
190
|
+
radius: '50%',
|
|
191
|
+
// Button radius
|
|
192
|
+
size: '16px',
|
|
193
|
+
// Button size
|
|
194
|
+
background: '#000' // Button color
|
|
195
|
+
},
|
|
196
|
+
histogram: {
|
|
197
|
+
background: '#e5e7eb',
|
|
198
|
+
// Histogram background
|
|
199
|
+
bar: {
|
|
200
|
+
background: '#000' // Bar color
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
pagination: {
|
|
206
|
+
ui: {
|
|
207
|
+
button: {
|
|
208
|
+
background: 'transparent',
|
|
209
|
+
border: '1px solid #000',
|
|
210
|
+
borderRadius: '4px',
|
|
211
|
+
padding: '8px 12px',
|
|
212
|
+
color: '#000',
|
|
213
|
+
active: {
|
|
214
|
+
background: '#000',
|
|
215
|
+
color: '#fff'
|
|
216
|
+
},
|
|
217
|
+
hover: {
|
|
218
|
+
background: '#000',
|
|
219
|
+
color: '#fff'
|
|
220
|
+
}
|
|
221
|
+
}
|
|
188
222
|
}
|
|
189
223
|
},
|
|
190
224
|
colors: {
|
|
191
225
|
primary: '#000',
|
|
192
226
|
background: '#e5e7eb',
|
|
193
|
-
text: '#000'
|
|
194
|
-
histogram: '#e5e7eb',
|
|
195
|
-
// For histogram bars
|
|
196
|
-
histogramActive: '#000' // For active histogram bars
|
|
227
|
+
text: '#000'
|
|
197
228
|
}
|
|
198
229
|
},
|
|
230
|
+
// Slider
|
|
231
|
+
slider: {
|
|
232
|
+
containerClass: 'afs-range-slider',
|
|
233
|
+
trackClass: 'afs-range-track',
|
|
234
|
+
thumbClass: 'afs-range-thumb',
|
|
235
|
+
valueClass: 'afs-range-value',
|
|
236
|
+
selectedClass: 'afs-range-selected'
|
|
237
|
+
},
|
|
199
238
|
// Pagination
|
|
200
239
|
pagination: {
|
|
201
240
|
enabled: false,
|
|
@@ -521,24 +560,6 @@
|
|
|
521
560
|
constructor(options) {
|
|
522
561
|
this.options = options;
|
|
523
562
|
this.styleElement = null;
|
|
524
|
-
this.defaultStyles = {
|
|
525
|
-
slider: {
|
|
526
|
-
class: "afs-range-slider",
|
|
527
|
-
trackClass: "afs-range-track",
|
|
528
|
-
thumbClass: "afs-range-thumb",
|
|
529
|
-
valueClass: "afs-range-value",
|
|
530
|
-
selectedClass: "afs-range-selected"
|
|
531
|
-
},
|
|
532
|
-
colors: {
|
|
533
|
-
primary: "#000",
|
|
534
|
-
background: "#ddd",
|
|
535
|
-
text: "#000"
|
|
536
|
-
},
|
|
537
|
-
animation: {
|
|
538
|
-
duration: "300ms",
|
|
539
|
-
type: "ease-out"
|
|
540
|
-
}
|
|
541
|
-
};
|
|
542
563
|
}
|
|
543
564
|
|
|
544
565
|
/**
|
|
@@ -548,8 +569,8 @@
|
|
|
548
569
|
*/
|
|
549
570
|
createBaseStyles() {
|
|
550
571
|
const hiddenClass = this.options.get("hiddenClass") || "hidden";
|
|
551
|
-
const itemSelector = this.options.get("itemSelector") || ".filter-item";
|
|
552
|
-
const filterButtonSelector = this.options.get("filterButtonSelector") || ".btn-filter";
|
|
572
|
+
const itemSelector = this.options.get("itemSelector") || ".afs-filter-item";
|
|
573
|
+
const filterButtonSelector = this.options.get("filterButtonSelector") || ".afs-btn-filter";
|
|
553
574
|
const activeClass = this.options.get("activeClass") || "active";
|
|
554
575
|
const animationDuration = this.options.get("animationDuration") || '300ms';
|
|
555
576
|
const animationEasing = this.options.get("animationEasing") || 'ease-out';
|
|
@@ -590,12 +611,18 @@
|
|
|
590
611
|
* @returns {string} CSS styles
|
|
591
612
|
*/
|
|
592
613
|
createRangeStyles() {
|
|
593
|
-
const styles = this.options.get("styles")
|
|
594
|
-
const
|
|
595
|
-
const
|
|
614
|
+
const styles = this.options.get("styles");
|
|
615
|
+
const sliderOptions = this.options.get("slider") || {};
|
|
616
|
+
const sliderStyles = styles.slider;
|
|
617
|
+
const colors = styles.colors;
|
|
618
|
+
const containerClass = sliderOptions.containerClass || "afs-range-slider";
|
|
619
|
+
const trackClass = sliderOptions.trackClass || "afs-range-track";
|
|
620
|
+
const thumbClass = sliderOptions.thumbClass || "afs-range-thumb";
|
|
621
|
+
const valueClass = sliderOptions.valueClass || "afs-range-value";
|
|
622
|
+
const selectedClass = sliderOptions.selectedClass || "afs-range-selected";
|
|
596
623
|
return `
|
|
597
624
|
/* Range Slider Styles */
|
|
598
|
-
.${
|
|
625
|
+
.${containerClass} {
|
|
599
626
|
position: relative;
|
|
600
627
|
width: auto;
|
|
601
628
|
height: 40px;
|
|
@@ -603,29 +630,29 @@
|
|
|
603
630
|
padding: 0 8px;
|
|
604
631
|
}
|
|
605
632
|
|
|
606
|
-
.${
|
|
633
|
+
.${trackClass} {
|
|
607
634
|
position: absolute;
|
|
608
635
|
top: 50%;
|
|
609
636
|
transform: translateY(-50%);
|
|
610
637
|
width: 100%;
|
|
611
638
|
height: 4px;
|
|
612
|
-
background: ${colors.background};
|
|
613
|
-
border-radius: 2px;
|
|
639
|
+
background: ${sliderStyles.ui.thumb.background || colors.background};
|
|
640
|
+
border-radius: ${sliderStyles.ui.track.radius || "2px"};
|
|
614
641
|
}
|
|
615
642
|
|
|
616
|
-
.${
|
|
643
|
+
.${thumbClass} {
|
|
617
644
|
position: absolute;
|
|
618
645
|
top: 50%;
|
|
619
|
-
width: 16px;
|
|
620
|
-
height: 16px;
|
|
621
|
-
background: ${colors.primary};
|
|
622
|
-
border-radius: 50
|
|
646
|
+
width: ${sliderStyles.ui.thumb.size || "16px"};
|
|
647
|
+
height: ${sliderStyles.ui.thumb.size || "16px"};
|
|
648
|
+
background: ${sliderStyles.ui.thumb.background || colors.primary};
|
|
649
|
+
border-radius: ${sliderStyles.ui.thumb.radius || "50%"};
|
|
623
650
|
transform: translate(-50%, -50%);
|
|
624
651
|
cursor: pointer;
|
|
625
652
|
z-index: 2;
|
|
626
653
|
}
|
|
627
654
|
|
|
628
|
-
.${
|
|
655
|
+
.${valueClass} {
|
|
629
656
|
position: absolute;
|
|
630
657
|
top: -20px;
|
|
631
658
|
transform: translateX(-50%);
|
|
@@ -633,7 +660,7 @@
|
|
|
633
660
|
color: ${colors.text};
|
|
634
661
|
}
|
|
635
662
|
|
|
636
|
-
.${
|
|
663
|
+
.${selectedClass} {
|
|
637
664
|
position: absolute;
|
|
638
665
|
height: 4px;
|
|
639
666
|
background: ${colors.primary};
|
|
@@ -656,13 +683,13 @@
|
|
|
656
683
|
|
|
657
684
|
.afs-histogram-bar {
|
|
658
685
|
flex: 1;
|
|
659
|
-
background-color: ${colors.background};
|
|
686
|
+
background-color: ${sliderStyles.ui.histogram.background || colors.background};
|
|
660
687
|
min-height: 4px;
|
|
661
688
|
transition: background-color 0.2s ease;
|
|
662
689
|
}
|
|
663
690
|
|
|
664
691
|
.afs-histogram-bar.active {
|
|
665
|
-
background-color: ${colors.primary};
|
|
692
|
+
background-color: ${sliderStyles.ui.histogram.bar.background || colors.primary};
|
|
666
693
|
}
|
|
667
694
|
`;
|
|
668
695
|
}
|
|
@@ -673,7 +700,7 @@
|
|
|
673
700
|
* @returns {string} CSS styles
|
|
674
701
|
*/
|
|
675
702
|
createDateStyles() {
|
|
676
|
-
const colors =
|
|
703
|
+
const colors = this.options.get("styles").colors;
|
|
677
704
|
return `
|
|
678
705
|
.afs-date-range-container {
|
|
679
706
|
display: flex;
|
|
@@ -758,11 +785,13 @@
|
|
|
758
785
|
* @returns {string} CSS styles
|
|
759
786
|
*/
|
|
760
787
|
createPaginationStyles() {
|
|
788
|
+
const styles = this.options.get("styles");
|
|
761
789
|
const paginationOptions = this.options.get("pagination") || {};
|
|
762
|
-
const colors =
|
|
790
|
+
const colors = this.options.get("styles").colors;
|
|
763
791
|
const containerClass = paginationOptions.containerClass || "afs-pagination";
|
|
764
792
|
const buttonClass = paginationOptions.pageButtonClass || "afs-page-button";
|
|
765
793
|
const activeClass = paginationOptions.activePageClass || "afs-page-active";
|
|
794
|
+
const paginationStyles = styles.pagination;
|
|
766
795
|
return `
|
|
767
796
|
.${containerClass} {
|
|
768
797
|
display: flex;
|
|
@@ -772,23 +801,23 @@
|
|
|
772
801
|
}
|
|
773
802
|
|
|
774
803
|
.${buttonClass} {
|
|
775
|
-
padding: 8px 12px;
|
|
776
|
-
border: 1px solid
|
|
777
|
-
border-radius: 4px;
|
|
804
|
+
padding: ${paginationStyles.ui.button.padding || '8px 12px'};
|
|
805
|
+
border: ${paginationStyles.ui.button.border || '1px solid ' + colors.primary};
|
|
806
|
+
border-radius: ${paginationStyles.ui.button.borderRadius || '4px'};
|
|
778
807
|
cursor: pointer;
|
|
779
808
|
transition: all 200ms ease-out;
|
|
780
|
-
background: transparent;
|
|
781
|
-
color: ${colors.primary};
|
|
809
|
+
background: ${paginationStyles.ui.button.background || 'transparent'};
|
|
810
|
+
color: ${paginationStyles.ui.button.color || colors.primary};
|
|
782
811
|
}
|
|
783
812
|
|
|
784
813
|
.${buttonClass}:hover {
|
|
785
|
-
background: ${colors.primary};
|
|
786
|
-
color: white;
|
|
814
|
+
background: ${paginationStyles.ui.button.hover.background || colors.primary};
|
|
815
|
+
color: ${paginationStyles.ui.button.hover.color || 'white'};
|
|
787
816
|
}
|
|
788
817
|
|
|
789
818
|
.${buttonClass}.${activeClass} {
|
|
790
|
-
background: ${colors.primary};
|
|
791
|
-
color: white;
|
|
819
|
+
background: ${paginationStyles.ui.button.active.background || colors.primary};
|
|
820
|
+
color: ${paginationStyles.ui.button.active.color || 'white'};
|
|
792
821
|
}
|
|
793
822
|
|
|
794
823
|
.${buttonClass}:disabled {
|
|
@@ -805,7 +834,7 @@
|
|
|
805
834
|
*/
|
|
806
835
|
createSearchStyles() {
|
|
807
836
|
const searchClass = this.options.get("searchInputClass") || "afs-search";
|
|
808
|
-
const colors =
|
|
837
|
+
const colors = this.options.get("styles").colors;
|
|
809
838
|
return `
|
|
810
839
|
.${searchClass} {
|
|
811
840
|
padding: 8px;
|
|
@@ -3178,6 +3207,9 @@
|
|
|
3178
3207
|
currentPage,
|
|
3179
3208
|
itemsPerPage
|
|
3180
3209
|
} = state.pagination;
|
|
3210
|
+
if (!this.afs.options.get('pagination.enabled')) {
|
|
3211
|
+
return;
|
|
3212
|
+
}
|
|
3181
3213
|
if (currentPage > 1) {
|
|
3182
3214
|
params.set('page', currentPage.toString());
|
|
3183
3215
|
}
|
|
@@ -3470,6 +3502,7 @@
|
|
|
3470
3502
|
constructor(afs) {
|
|
3471
3503
|
this.afs = afs;
|
|
3472
3504
|
this.activeRanges = new Map();
|
|
3505
|
+
this.options = this.afs.options.get("slider");
|
|
3473
3506
|
if (!this.afs.styleManager) {
|
|
3474
3507
|
this.afs.styleManager = new StyleManager(this.afs.options);
|
|
3475
3508
|
}
|
|
@@ -3584,14 +3617,14 @@
|
|
|
3584
3617
|
*/
|
|
3585
3618
|
createSliderElements(histogramData, sliderUiOptions) {
|
|
3586
3619
|
const styles = this.afs.options.get("styles") || this.afs.styleManager.defaultStyles;
|
|
3587
|
-
const sliderStyles = styles.slider || this.afs.styleManager.defaultStyles.slider;
|
|
3588
3620
|
const colors = styles.colors || this.afs.styleManager.defaultStyles.colors;
|
|
3621
|
+
const sliderOptions = this.afs.options.get("slider") || {};
|
|
3589
3622
|
const container = document.createElement("div");
|
|
3590
|
-
container.className = "
|
|
3623
|
+
container.className = "afs-range-container";
|
|
3591
3624
|
const slider = document.createElement("div");
|
|
3592
|
-
slider.className =
|
|
3625
|
+
slider.className = sliderOptions.containerClass;
|
|
3593
3626
|
const track = document.createElement("div");
|
|
3594
|
-
track.className =
|
|
3627
|
+
track.className = sliderOptions.trackClass;
|
|
3595
3628
|
|
|
3596
3629
|
// Only add histogram if enabled in the slider-specific options
|
|
3597
3630
|
if (sliderUiOptions?.showHistogram && histogramData?.counts?.length > 0) {
|
|
@@ -3599,15 +3632,15 @@
|
|
|
3599
3632
|
slider.appendChild(histogram);
|
|
3600
3633
|
}
|
|
3601
3634
|
const selectedRange = document.createElement("div");
|
|
3602
|
-
selectedRange.className =
|
|
3635
|
+
selectedRange.className = sliderOptions.selectedClass;
|
|
3603
3636
|
const minThumb = document.createElement("div");
|
|
3604
|
-
minThumb.className =
|
|
3637
|
+
minThumb.className = sliderOptions.thumbClass;
|
|
3605
3638
|
const maxThumb = document.createElement("div");
|
|
3606
|
-
maxThumb.className =
|
|
3639
|
+
maxThumb.className = sliderOptions.thumbClass;
|
|
3607
3640
|
const minValue = document.createElement("div");
|
|
3608
|
-
minValue.className =
|
|
3641
|
+
minValue.className = sliderOptions.valueClass;
|
|
3609
3642
|
const maxValue = document.createElement("div");
|
|
3610
|
-
maxValue.className =
|
|
3643
|
+
maxValue.className = sliderOptions.valueClass;
|
|
3611
3644
|
|
|
3612
3645
|
// Build the slider
|
|
3613
3646
|
slider.appendChild(track);
|
|
@@ -4327,7 +4360,7 @@
|
|
|
4327
4360
|
*/
|
|
4328
4361
|
|
|
4329
4362
|
// Version
|
|
4330
|
-
const VERSION = '1.0.
|
|
4363
|
+
const VERSION = '1.0.8';
|
|
4331
4364
|
class AFS extends EventEmitter {
|
|
4332
4365
|
/**
|
|
4333
4366
|
* @param {Object} options - Configuration options
|