@wordpress/dataviews 0.4.1 → 0.5.0
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/CHANGELOG.md +2 -0
- package/README.md +1 -0
- package/build/add-filter.js +25 -108
- package/build/add-filter.js.map +1 -1
- package/build/constants.js +9 -18
- package/build/constants.js.map +1 -1
- package/build/dataviews.js +22 -16
- package/build/dataviews.js.map +1 -1
- package/build/dropdown-menu-helper.js +1 -2
- package/build/dropdown-menu-helper.js.map +1 -1
- package/build/filter-summary.js +180 -77
- package/build/filter-summary.js.map +1 -1
- package/build/filters.js +32 -18
- package/build/filters.js.map +1 -1
- package/build/pagination.js +1 -2
- package/build/pagination.js.map +1 -1
- package/build/reset-filters.js +4 -1
- package/build/reset-filters.js.map +1 -1
- package/build/search-widget.js +111 -0
- package/build/search-widget.js.map +1 -0
- package/build/search.js +2 -3
- package/build/search.js.map +1 -1
- package/build/single-selection-checkbox.js +54 -0
- package/build/single-selection-checkbox.js.map +1 -0
- package/build/utils.js +14 -1
- package/build/utils.js.map +1 -1
- package/build/view-actions.js +2 -3
- package/build/view-actions.js.map +1 -1
- package/build/view-grid.js +92 -22
- package/build/view-grid.js.map +1 -1
- package/build/view-list.js +2 -1
- package/build/view-list.js.map +1 -1
- package/build/view-table.js +43 -132
- package/build/view-table.js.map +1 -1
- package/build-module/add-filter.js +28 -111
- package/build-module/add-filter.js.map +1 -1
- package/build-module/dataviews.js +23 -17
- package/build-module/dataviews.js.map +1 -1
- package/build-module/filter-summary.js +181 -79
- package/build-module/filter-summary.js.map +1 -1
- package/build-module/filters.js +32 -17
- package/build-module/filters.js.map +1 -1
- package/build-module/reset-filters.js +4 -1
- package/build-module/reset-filters.js.map +1 -1
- package/build-module/search-widget.js +101 -0
- package/build-module/search-widget.js.map +1 -0
- package/build-module/search.js +1 -1
- package/build-module/search.js.map +1 -1
- package/build-module/single-selection-checkbox.js +47 -0
- package/build-module/single-selection-checkbox.js.map +1 -0
- package/build-module/utils.js +12 -0
- package/build-module/utils.js.map +1 -1
- package/build-module/view-actions.js +1 -1
- package/build-module/view-actions.js.map +1 -1
- package/build-module/view-grid.js +92 -22
- package/build-module/view-grid.js.map +1 -1
- package/build-module/view-list.js +2 -1
- package/build-module/view-list.js.map +1 -1
- package/build-module/view-table.js +43 -131
- package/build-module/view-table.js.map +1 -1
- package/build-style/style-rtl.css +253 -44
- package/build-style/style.css +253 -44
- package/package.json +12 -11
- package/src/add-filter.js +39 -230
- package/src/dataviews.js +31 -20
- package/src/filter-summary.js +228 -135
- package/src/filters.js +42 -29
- package/src/reset-filters.js +12 -2
- package/src/search-widget.js +128 -0
- package/src/search.js +1 -1
- package/src/single-selection-checkbox.js +59 -0
- package/src/style.scss +259 -44
- package/src/utils.js +15 -0
- package/src/view-actions.js +1 -2
- package/src/view-grid.js +127 -53
- package/src/view-list.js +5 -1
- package/src/view-table.js +57 -230
package/build-style/style.css
CHANGED
|
@@ -115,13 +115,19 @@
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
.dataviews-filters__view-actions {
|
|
118
|
-
padding: 12px 32px;
|
|
118
|
+
padding: 12px 32px 0;
|
|
119
119
|
}
|
|
120
120
|
.dataviews-filters__view-actions .components-search-control {
|
|
121
121
|
flex-grow: 1;
|
|
122
|
+
}
|
|
123
|
+
.dataviews-filters__view-actions .components-search-control .components-base-control__field {
|
|
122
124
|
max-width: 240px;
|
|
123
125
|
}
|
|
124
126
|
|
|
127
|
+
.dataviews-filters__container {
|
|
128
|
+
padding: 0 32px;
|
|
129
|
+
}
|
|
130
|
+
|
|
125
131
|
.dataviews-filters__view-actions.components-h-stack {
|
|
126
132
|
align-items: center;
|
|
127
133
|
}
|
|
@@ -130,24 +136,6 @@
|
|
|
130
136
|
position: relative;
|
|
131
137
|
}
|
|
132
138
|
|
|
133
|
-
.dataviews-filters-count {
|
|
134
|
-
position: absolute;
|
|
135
|
-
top: 0;
|
|
136
|
-
right: 0;
|
|
137
|
-
height: 16px;
|
|
138
|
-
color: var(--wp-components-color-accent-inverted, #fff);
|
|
139
|
-
background-color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
140
|
-
border-radius: 8px;
|
|
141
|
-
min-width: 16px;
|
|
142
|
-
padding: 0 4px;
|
|
143
|
-
transform: translateX(40%) translateY(-40%);
|
|
144
|
-
display: flex;
|
|
145
|
-
align-items: center;
|
|
146
|
-
justify-content: center;
|
|
147
|
-
font-size: 11px;
|
|
148
|
-
font-weight: 300;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
139
|
.dataviews-pagination {
|
|
152
140
|
margin-top: auto;
|
|
153
141
|
position: sticky;
|
|
@@ -192,12 +180,6 @@
|
|
|
192
180
|
padding: 12px;
|
|
193
181
|
white-space: nowrap;
|
|
194
182
|
}
|
|
195
|
-
@media (min-width: 1440px) {
|
|
196
|
-
.dataviews-view-table td,
|
|
197
|
-
.dataviews-view-table th {
|
|
198
|
-
min-width: 200px;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
183
|
.dataviews-view-table td[data-field-id=actions],
|
|
202
184
|
.dataviews-view-table th[data-field-id=actions] {
|
|
203
185
|
text-align: right;
|
|
@@ -365,11 +347,18 @@
|
|
|
365
347
|
justify-content: flex-start;
|
|
366
348
|
}
|
|
367
349
|
.dataviews-view-grid .dataviews-view-grid__card .dataviews-view-grid__title-actions {
|
|
368
|
-
padding:
|
|
350
|
+
padding: 4px 8px 4px 4px;
|
|
369
351
|
}
|
|
370
352
|
.dataviews-view-grid .dataviews-view-grid__card .dataviews-view-grid__primary-field {
|
|
371
353
|
min-height: 40px;
|
|
372
354
|
}
|
|
355
|
+
.dataviews-view-grid .dataviews-view-grid__card.is-selected {
|
|
356
|
+
border-color: var(--wp-admin-theme-color);
|
|
357
|
+
background-color: rgba(var(--wp-admin-theme-color--rgb), 0.04);
|
|
358
|
+
}
|
|
359
|
+
.dataviews-view-grid .dataviews-view-grid__card.is-selected .dataviews-view-grid__fields .dataviews-view-grid__field .dataviews-view-grid__field-value {
|
|
360
|
+
color: #1e1e1e;
|
|
361
|
+
}
|
|
373
362
|
.dataviews-view-grid .dataviews-view-grid__media {
|
|
374
363
|
width: 100%;
|
|
375
364
|
min-height: 200px;
|
|
@@ -383,9 +372,6 @@
|
|
|
383
372
|
width: 100%;
|
|
384
373
|
height: 100%;
|
|
385
374
|
}
|
|
386
|
-
.dataviews-view-grid .dataviews-view-grid__primary-field {
|
|
387
|
-
padding: 8px;
|
|
388
|
-
}
|
|
389
375
|
.dataviews-view-grid .dataviews-view-grid__fields {
|
|
390
376
|
position: relative;
|
|
391
377
|
font-size: 12px;
|
|
@@ -460,14 +446,12 @@
|
|
|
460
446
|
z-index: -1;
|
|
461
447
|
border-radius: 4px;
|
|
462
448
|
}
|
|
463
|
-
.dataviews-view-list .dataviews-view-list__item
|
|
464
|
-
|
|
465
|
-
text-overflow: ellipsis;
|
|
466
|
-
white-space: nowrap;
|
|
449
|
+
.dataviews-view-list .dataviews-view-list__item .dataviews-view-list__primary-field {
|
|
450
|
+
min-height: 20px;
|
|
467
451
|
}
|
|
468
452
|
.dataviews-view-list .dataviews-view-list__media-wrapper {
|
|
469
|
-
width:
|
|
470
|
-
height:
|
|
453
|
+
width: 40px;
|
|
454
|
+
height: 40px;
|
|
471
455
|
border-radius: 4px;
|
|
472
456
|
overflow: hidden;
|
|
473
457
|
position: relative;
|
|
@@ -496,15 +480,11 @@
|
|
|
496
480
|
}
|
|
497
481
|
.dataviews-view-list .dataviews-view-list__fields {
|
|
498
482
|
color: #757575;
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
margin-right: 12px;
|
|
505
|
-
}
|
|
506
|
-
.dataviews-view-list .dataviews-view-list__fields .dataviews-view-list__field:last-child {
|
|
507
|
-
margin-right: 0;
|
|
483
|
+
display: flex;
|
|
484
|
+
gap: 8px;
|
|
485
|
+
flex-wrap: wrap;
|
|
486
|
+
font-size: 12px;
|
|
487
|
+
line-height: 16px;
|
|
508
488
|
}
|
|
509
489
|
.dataviews-view-list .dataviews-view-list__fields .dataviews-view-list__field:empty {
|
|
510
490
|
display: none;
|
|
@@ -553,4 +533,233 @@
|
|
|
553
533
|
|
|
554
534
|
.dataviews-bulk-edit-button.components-button {
|
|
555
535
|
flex-shrink: 0;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.dataviews-view-grid__title-actions .dataviews-view-table-selection-checkbox {
|
|
539
|
+
margin-left: 8px;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.dataviews-view-grid__card.has-no-pointer-events * {
|
|
543
|
+
pointer-events: none;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
.dataviews-filter-summary__popover .components-popover__content {
|
|
547
|
+
width: 230px;
|
|
548
|
+
padding: 0;
|
|
549
|
+
border-radius: 4px;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.dataviews-search-widget-filter-combobox-list {
|
|
553
|
+
max-height: 184px;
|
|
554
|
+
padding: 4px;
|
|
555
|
+
overflow: auto;
|
|
556
|
+
border-top: 1px solid #e0e0e0;
|
|
557
|
+
}
|
|
558
|
+
.dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item {
|
|
559
|
+
display: flex;
|
|
560
|
+
align-items: center;
|
|
561
|
+
gap: 8px;
|
|
562
|
+
border-radius: 2px;
|
|
563
|
+
box-sizing: border-box;
|
|
564
|
+
padding: 8px 12px;
|
|
565
|
+
cursor: default;
|
|
566
|
+
margin-block-end: 2px;
|
|
567
|
+
}
|
|
568
|
+
.dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item:last-child {
|
|
569
|
+
margin-block-end: 0;
|
|
570
|
+
}
|
|
571
|
+
.dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item:hover, .dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item[data-active-item], .dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item:focus {
|
|
572
|
+
background-color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
|
|
573
|
+
color: #fff;
|
|
574
|
+
}
|
|
575
|
+
.dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item:hover .dataviews-search-widget-filter-combobox-item-check, .dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item[data-active-item] .dataviews-search-widget-filter-combobox-item-check, .dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item:focus .dataviews-search-widget-filter-combobox-item-check {
|
|
576
|
+
fill: #fff;
|
|
577
|
+
}
|
|
578
|
+
.dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item:hover .dataviews-search-widget-filter-combobox-item-description, .dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item[data-active-item] .dataviews-search-widget-filter-combobox-item-description, .dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item:focus .dataviews-search-widget-filter-combobox-item-description {
|
|
579
|
+
color: #fff;
|
|
580
|
+
}
|
|
581
|
+
.dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item .dataviews-search-widget-filter-combobox-item-check {
|
|
582
|
+
width: 24px;
|
|
583
|
+
height: 24px;
|
|
584
|
+
flex-shrink: 0;
|
|
585
|
+
}
|
|
586
|
+
.dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item .dataviews-search-widget-filter-combobox-item-value [data-user-value] {
|
|
587
|
+
font-weight: 600;
|
|
588
|
+
}
|
|
589
|
+
.dataviews-search-widget-filter-combobox-list .dataviews-search-widget-filter-combobox-item .dataviews-search-widget-filter-combobox-item-description {
|
|
590
|
+
display: block;
|
|
591
|
+
overflow: hidden;
|
|
592
|
+
text-overflow: ellipsis;
|
|
593
|
+
font-size: 12px;
|
|
594
|
+
line-height: 16px;
|
|
595
|
+
color: #757575;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.dataviews-search-widget-filter-combobox__wrapper {
|
|
599
|
+
position: relative;
|
|
600
|
+
padding: 8px;
|
|
601
|
+
}
|
|
602
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input {
|
|
603
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
604
|
+
padding: 6px 8px;
|
|
605
|
+
box-shadow: 0 0 0 transparent;
|
|
606
|
+
transition: box-shadow 0.1s linear;
|
|
607
|
+
border-radius: 2px;
|
|
608
|
+
border: 1px solid #949494;
|
|
609
|
+
/* Fonts smaller than 16px causes mobile safari to zoom. */
|
|
610
|
+
font-size: 16px;
|
|
611
|
+
/* Override core line-height. To be reviewed. */
|
|
612
|
+
line-height: normal;
|
|
613
|
+
display: block;
|
|
614
|
+
padding: 0 32px 0 8px;
|
|
615
|
+
background: #f0f0f0;
|
|
616
|
+
border: none;
|
|
617
|
+
width: 100%;
|
|
618
|
+
height: 32px;
|
|
619
|
+
margin-left: 0;
|
|
620
|
+
margin-right: 0;
|
|
621
|
+
/* Fonts smaller than 16px causes mobile safari to zoom. */
|
|
622
|
+
font-size: 16px;
|
|
623
|
+
}
|
|
624
|
+
@media (prefers-reduced-motion: reduce) {
|
|
625
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input {
|
|
626
|
+
transition-duration: 0s;
|
|
627
|
+
transition-delay: 0s;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
@media (min-width: 600px) {
|
|
631
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input {
|
|
632
|
+
font-size: 13px;
|
|
633
|
+
/* Override core line-height. To be reviewed. */
|
|
634
|
+
line-height: normal;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input:focus {
|
|
638
|
+
border-color: var(--wp-admin-theme-color);
|
|
639
|
+
box-shadow: 0 0 0 0.5px var(--wp-admin-theme-color);
|
|
640
|
+
outline: 2px solid transparent;
|
|
641
|
+
}
|
|
642
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input::-webkit-input-placeholder {
|
|
643
|
+
color: rgba(30, 30, 30, 0.62);
|
|
644
|
+
}
|
|
645
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input::-moz-placeholder {
|
|
646
|
+
opacity: 1;
|
|
647
|
+
color: rgba(30, 30, 30, 0.62);
|
|
648
|
+
}
|
|
649
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input:-ms-input-placeholder {
|
|
650
|
+
color: rgba(30, 30, 30, 0.62);
|
|
651
|
+
}
|
|
652
|
+
@media (min-width: 600px) {
|
|
653
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input {
|
|
654
|
+
font-size: 13px;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input:focus {
|
|
658
|
+
background: #fff;
|
|
659
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
660
|
+
}
|
|
661
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input::placeholder {
|
|
662
|
+
color: #757575;
|
|
663
|
+
}
|
|
664
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input::-webkit-search-decoration, .dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input::-webkit-search-cancel-button, .dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input::-webkit-search-results-button, .dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__input::-webkit-search-results-decoration {
|
|
665
|
+
-webkit-appearance: none;
|
|
666
|
+
}
|
|
667
|
+
.dataviews-search-widget-filter-combobox__wrapper .dataviews-search-widget-filter-combobox__icon {
|
|
668
|
+
position: absolute;
|
|
669
|
+
right: 12px;
|
|
670
|
+
top: 50%;
|
|
671
|
+
transform: translateY(-50%);
|
|
672
|
+
display: flex;
|
|
673
|
+
align-items: center;
|
|
674
|
+
justify-content: center;
|
|
675
|
+
width: 24px;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.dataviews-filter-summary__operators-container {
|
|
679
|
+
padding: 8px 8px 4px;
|
|
680
|
+
padding-bottom: 0;
|
|
681
|
+
}
|
|
682
|
+
.dataviews-filter-summary__operators-container:empty {
|
|
683
|
+
display: none;
|
|
684
|
+
}
|
|
685
|
+
.dataviews-filter-summary__operators-container .dataviews-filter-summary__operators-filter-name {
|
|
686
|
+
color: #757575;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
.dataviews-filter-summary__reset {
|
|
690
|
+
padding: 4px;
|
|
691
|
+
border-top: 1px solid #e0e0e0;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.dataviews-filter-summary__chip-container {
|
|
695
|
+
position: relative;
|
|
696
|
+
white-space: pre-wrap;
|
|
697
|
+
}
|
|
698
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip {
|
|
699
|
+
border-radius: 16px;
|
|
700
|
+
border: 1px solid transparent;
|
|
701
|
+
cursor: pointer;
|
|
702
|
+
padding: 0 12px;
|
|
703
|
+
height: 32px;
|
|
704
|
+
background: #f0f0f0;
|
|
705
|
+
color: #757575;
|
|
706
|
+
position: relative;
|
|
707
|
+
display: flex;
|
|
708
|
+
align-items: center;
|
|
709
|
+
}
|
|
710
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip.has-reset {
|
|
711
|
+
padding-inline-end: 28px;
|
|
712
|
+
}
|
|
713
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip:hover, .dataviews-filter-summary__chip-container .dataviews-filter-summary__chip:focus-visible {
|
|
714
|
+
background: #e0e0e0;
|
|
715
|
+
color: #1e1e1e;
|
|
716
|
+
}
|
|
717
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip.has-values {
|
|
718
|
+
color: var(--wp-admin-theme-color);
|
|
719
|
+
background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
|
|
720
|
+
}
|
|
721
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip.has-values:hover {
|
|
722
|
+
background: rgba(var(--wp-admin-theme-color--rgb), 0.08);
|
|
723
|
+
}
|
|
724
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip:focus-visible {
|
|
725
|
+
outline: none;
|
|
726
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
727
|
+
}
|
|
728
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip .dataviews-filter-summary__filter-text-name {
|
|
729
|
+
font-weight: 500;
|
|
730
|
+
}
|
|
731
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip-remove {
|
|
732
|
+
width: 24px;
|
|
733
|
+
height: 24px;
|
|
734
|
+
border-radius: 50%;
|
|
735
|
+
border: 0;
|
|
736
|
+
padding: 0;
|
|
737
|
+
position: absolute;
|
|
738
|
+
right: 4px;
|
|
739
|
+
top: 50%;
|
|
740
|
+
transform: translateY(-50%);
|
|
741
|
+
display: flex;
|
|
742
|
+
align-items: center;
|
|
743
|
+
justify-content: center;
|
|
744
|
+
background: transparent;
|
|
745
|
+
cursor: pointer;
|
|
746
|
+
}
|
|
747
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip-remove svg {
|
|
748
|
+
fill: #757575;
|
|
749
|
+
}
|
|
750
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip-remove:hover, .dataviews-filter-summary__chip-container .dataviews-filter-summary__chip-remove:focus {
|
|
751
|
+
background: #e0e0e0;
|
|
752
|
+
}
|
|
753
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip-remove:hover svg, .dataviews-filter-summary__chip-container .dataviews-filter-summary__chip-remove:focus svg {
|
|
754
|
+
fill: #1e1e1e;
|
|
755
|
+
}
|
|
756
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip-remove.has-values svg {
|
|
757
|
+
fill: var(--wp-admin-theme-color);
|
|
758
|
+
}
|
|
759
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip-remove.has-values:hover {
|
|
760
|
+
background: rgba(var(--wp-admin-theme-color--rgb), 0.08);
|
|
761
|
+
}
|
|
762
|
+
.dataviews-filter-summary__chip-container .dataviews-filter-summary__chip-remove:focus-visible {
|
|
763
|
+
outline: none;
|
|
764
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
556
765
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dataviews",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,16 +27,17 @@
|
|
|
27
27
|
"types": "build-types",
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"@ariakit/react": "^0.3.12",
|
|
30
31
|
"@babel/runtime": "^7.16.0",
|
|
31
|
-
"@wordpress/a11y": "^3.
|
|
32
|
-
"@wordpress/components": "^
|
|
33
|
-
"@wordpress/compose": "^6.
|
|
34
|
-
"@wordpress/element": "^5.
|
|
35
|
-
"@wordpress/i18n": "^4.
|
|
36
|
-
"@wordpress/icons": "^9.
|
|
37
|
-
"@wordpress/keycodes": "^3.
|
|
38
|
-
"@wordpress/primitives": "^3.
|
|
39
|
-
"@wordpress/private-apis": "^0.
|
|
32
|
+
"@wordpress/a11y": "^3.51.0",
|
|
33
|
+
"@wordpress/components": "^26.0.0",
|
|
34
|
+
"@wordpress/compose": "^6.28.0",
|
|
35
|
+
"@wordpress/element": "^5.28.0",
|
|
36
|
+
"@wordpress/i18n": "^4.51.0",
|
|
37
|
+
"@wordpress/icons": "^9.42.0",
|
|
38
|
+
"@wordpress/keycodes": "^3.51.0",
|
|
39
|
+
"@wordpress/primitives": "^3.49.0",
|
|
40
|
+
"@wordpress/private-apis": "^0.33.0",
|
|
40
41
|
"classnames": "^2.3.1",
|
|
41
42
|
"remove-accents": "^0.5.0"
|
|
42
43
|
},
|
|
@@ -46,5 +47,5 @@
|
|
|
46
47
|
"publishConfig": {
|
|
47
48
|
"access": "public"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "eb796371e9630636a4a8837033807b0c4a06ed67"
|
|
50
51
|
}
|
package/src/add-filter.js
CHANGED
|
@@ -5,261 +5,70 @@ import {
|
|
|
5
5
|
privateApis as componentsPrivateApis,
|
|
6
6
|
Button,
|
|
7
7
|
} from '@wordpress/components';
|
|
8
|
-
import {
|
|
9
|
-
import { __
|
|
10
|
-
import {
|
|
8
|
+
import { plus } from '@wordpress/icons';
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { forwardRef } from '@wordpress/element';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
15
|
import { unlock } from './lock-unlock';
|
|
16
|
-
import { LAYOUT_LIST, OPERATORS } from './constants';
|
|
17
|
-
import { DropdownMenuRadioItemCustom } from './dropdown-menu-helper';
|
|
18
16
|
|
|
19
17
|
const {
|
|
20
18
|
DropdownMenuV2: DropdownMenu,
|
|
21
|
-
DropdownMenuGroupV2: DropdownMenuGroup,
|
|
22
19
|
DropdownMenuItemV2: DropdownMenuItem,
|
|
23
|
-
DropdownMenuRadioItemV2: DropdownMenuRadioItem,
|
|
24
|
-
DropdownMenuSeparatorV2: DropdownMenuSeparator,
|
|
25
20
|
DropdownMenuItemLabelV2: DropdownMenuItemLabel,
|
|
26
|
-
DropdownMenuItemHelpTextV2: DropdownMenuItemHelpText,
|
|
27
21
|
} = unlock( componentsPrivateApis );
|
|
28
22
|
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
.filter( Boolean )
|
|
32
|
-
.map( ( child, i ) => (
|
|
33
|
-
<Fragment key={ i }>
|
|
34
|
-
{ i > 0 && <DropdownMenuSeparator /> }
|
|
35
|
-
{ child }
|
|
36
|
-
</Fragment>
|
|
37
|
-
) );
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default function AddFilter( { filters, view, onChangeView } ) {
|
|
41
|
-
if ( filters.length === 0 ) {
|
|
23
|
+
function AddFilter( { filters, view, onChangeView, setOpenedFilter }, ref ) {
|
|
24
|
+
if ( ! filters.length || filters.every( ( { isPrimary } ) => isPrimary ) ) {
|
|
42
25
|
return null;
|
|
43
26
|
}
|
|
44
|
-
|
|
45
|
-
const filterCount = view.filters.reduce( ( acc, filter ) => {
|
|
46
|
-
if ( filter.value !== undefined ) {
|
|
47
|
-
return acc + 1;
|
|
48
|
-
}
|
|
49
|
-
return acc;
|
|
50
|
-
}, 0 );
|
|
51
|
-
|
|
27
|
+
const inactiveFilters = filters.filter( ( filter ) => ! filter.isVisible );
|
|
52
28
|
return (
|
|
53
29
|
<DropdownMenu
|
|
54
30
|
trigger={
|
|
55
31
|
<Button
|
|
56
32
|
__experimentalIsFocusable
|
|
57
|
-
label={ __( 'Filters' ) }
|
|
58
33
|
size="compact"
|
|
59
|
-
icon={
|
|
34
|
+
icon={ plus }
|
|
60
35
|
className="dataviews-filters-button"
|
|
36
|
+
variant="tertiary"
|
|
37
|
+
disabled={ ! inactiveFilters.length }
|
|
38
|
+
ref={ ref }
|
|
61
39
|
>
|
|
62
|
-
{
|
|
63
|
-
<span className="dataviews-filters-count">
|
|
64
|
-
{ filterCount }
|
|
65
|
-
</span>
|
|
66
|
-
) : null }
|
|
40
|
+
{ __( 'Add filter' ) }
|
|
67
41
|
</Button>
|
|
68
42
|
}
|
|
69
|
-
style={ {
|
|
70
|
-
minWidth: '230px',
|
|
71
|
-
} }
|
|
72
43
|
>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
</span>
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
>
|
|
103
|
-
<DropdownMenuItemLabel>
|
|
104
|
-
{ filter.name }
|
|
105
|
-
</DropdownMenuItemLabel>
|
|
106
|
-
</DropdownMenuItem>
|
|
107
|
-
}
|
|
108
|
-
style={ {
|
|
109
|
-
minWidth: '200px',
|
|
110
|
-
} }
|
|
111
|
-
>
|
|
112
|
-
<WithSeparators>
|
|
113
|
-
<DropdownMenuGroup>
|
|
114
|
-
{ filter.elements.map( ( element ) => {
|
|
115
|
-
const isActive =
|
|
116
|
-
activeElement?.value ===
|
|
117
|
-
element.value;
|
|
118
|
-
return (
|
|
119
|
-
<DropdownMenuRadioItemCustom
|
|
120
|
-
key={ element.value }
|
|
121
|
-
name={ `add-filter-${ filter.field }` }
|
|
122
|
-
value={ element.value }
|
|
123
|
-
checked={ isActive }
|
|
124
|
-
onChange={ ( e ) => {
|
|
125
|
-
onChangeView( {
|
|
126
|
-
...view,
|
|
127
|
-
page: 1,
|
|
128
|
-
filters: [
|
|
129
|
-
...otherFilters,
|
|
130
|
-
{
|
|
131
|
-
field: filter.field,
|
|
132
|
-
operator:
|
|
133
|
-
activeOperator,
|
|
134
|
-
value: isActive
|
|
135
|
-
? undefined
|
|
136
|
-
: e
|
|
137
|
-
.target
|
|
138
|
-
.value,
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
} );
|
|
142
|
-
} }
|
|
143
|
-
>
|
|
144
|
-
<DropdownMenuItemLabel>
|
|
145
|
-
{ element.label }
|
|
146
|
-
</DropdownMenuItemLabel>
|
|
147
|
-
{ !! element.description && (
|
|
148
|
-
<DropdownMenuItemHelpText>
|
|
149
|
-
{
|
|
150
|
-
element.description
|
|
151
|
-
}
|
|
152
|
-
</DropdownMenuItemHelpText>
|
|
153
|
-
) }
|
|
154
|
-
</DropdownMenuRadioItemCustom>
|
|
155
|
-
);
|
|
156
|
-
} ) }
|
|
157
|
-
</DropdownMenuGroup>
|
|
158
|
-
{ filter.operators.length > 1 && (
|
|
159
|
-
<DropdownMenu
|
|
160
|
-
trigger={
|
|
161
|
-
<DropdownMenuItem
|
|
162
|
-
suffix={
|
|
163
|
-
<span aria-hidden="true">
|
|
164
|
-
{
|
|
165
|
-
OPERATORS[
|
|
166
|
-
activeOperator
|
|
167
|
-
]?.label
|
|
168
|
-
}
|
|
169
|
-
</span>
|
|
170
|
-
}
|
|
171
|
-
>
|
|
172
|
-
<DropdownMenuItemLabel>
|
|
173
|
-
{ __( 'Conditions' ) }
|
|
174
|
-
</DropdownMenuItemLabel>
|
|
175
|
-
</DropdownMenuItem>
|
|
176
|
-
}
|
|
177
|
-
>
|
|
178
|
-
{ Object.entries( OPERATORS ).map(
|
|
179
|
-
( [
|
|
180
|
-
operator,
|
|
181
|
-
{ label, key },
|
|
182
|
-
] ) => (
|
|
183
|
-
<DropdownMenuRadioItem
|
|
184
|
-
key={ key }
|
|
185
|
-
name={ `add-filter-${ filter.field }-conditions` }
|
|
186
|
-
value={ operator }
|
|
187
|
-
checked={
|
|
188
|
-
activeOperator ===
|
|
189
|
-
operator
|
|
190
|
-
}
|
|
191
|
-
onChange={ ( e ) => {
|
|
192
|
-
onChangeView( {
|
|
193
|
-
...view,
|
|
194
|
-
page: 1,
|
|
195
|
-
filters: [
|
|
196
|
-
...otherFilters,
|
|
197
|
-
{
|
|
198
|
-
field: filter.field,
|
|
199
|
-
operator:
|
|
200
|
-
e
|
|
201
|
-
.target
|
|
202
|
-
.value,
|
|
203
|
-
value: filterInView?.value,
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
} );
|
|
207
|
-
} }
|
|
208
|
-
>
|
|
209
|
-
<DropdownMenuItemLabel>
|
|
210
|
-
{ label }
|
|
211
|
-
</DropdownMenuItemLabel>
|
|
212
|
-
</DropdownMenuRadioItem>
|
|
213
|
-
)
|
|
214
|
-
) }
|
|
215
|
-
</DropdownMenu>
|
|
216
|
-
) }
|
|
217
|
-
<DropdownMenuItem
|
|
218
|
-
key={ 'reset-filter-' + filter.name }
|
|
219
|
-
disabled={ ! activeElement }
|
|
220
|
-
hideOnClick={ false }
|
|
221
|
-
onClick={ () => {
|
|
222
|
-
onChangeView( {
|
|
223
|
-
...view,
|
|
224
|
-
page: 1,
|
|
225
|
-
filters: view.filters.filter(
|
|
226
|
-
( f ) =>
|
|
227
|
-
f.field !== filter.field
|
|
228
|
-
),
|
|
229
|
-
} );
|
|
230
|
-
} }
|
|
231
|
-
>
|
|
232
|
-
<DropdownMenuItemLabel>
|
|
233
|
-
{ sprintf(
|
|
234
|
-
/* translators: 1: Filter name. e.g.: "Reset Author". */
|
|
235
|
-
__( 'Reset %1$s' ),
|
|
236
|
-
filter.name.toLowerCase()
|
|
237
|
-
) }
|
|
238
|
-
</DropdownMenuItemLabel>
|
|
239
|
-
</DropdownMenuItem>
|
|
240
|
-
</WithSeparators>
|
|
241
|
-
</DropdownMenu>
|
|
242
|
-
);
|
|
243
|
-
} ) }
|
|
244
|
-
</DropdownMenuGroup>
|
|
245
|
-
<DropdownMenuItem
|
|
246
|
-
disabled={
|
|
247
|
-
view.search === '' && view.filters?.length === 0
|
|
248
|
-
}
|
|
249
|
-
hideOnClick={ false }
|
|
250
|
-
onClick={ () => {
|
|
251
|
-
onChangeView( {
|
|
252
|
-
...view,
|
|
253
|
-
page: 1,
|
|
254
|
-
filters: [],
|
|
255
|
-
} );
|
|
256
|
-
} }
|
|
257
|
-
>
|
|
258
|
-
<DropdownMenuItemLabel>
|
|
259
|
-
{ __( 'Reset filters' ) }
|
|
260
|
-
</DropdownMenuItemLabel>
|
|
261
|
-
</DropdownMenuItem>
|
|
262
|
-
</WithSeparators>
|
|
44
|
+
{ inactiveFilters.map( ( filter ) => {
|
|
45
|
+
return (
|
|
46
|
+
<DropdownMenuItem
|
|
47
|
+
key={ filter.field }
|
|
48
|
+
onClick={ () => {
|
|
49
|
+
setOpenedFilter( filter.field );
|
|
50
|
+
onChangeView( {
|
|
51
|
+
...view,
|
|
52
|
+
page: 1,
|
|
53
|
+
filters: [
|
|
54
|
+
...( view.filters || [] ),
|
|
55
|
+
{
|
|
56
|
+
field: filter.field,
|
|
57
|
+
value: undefined,
|
|
58
|
+
operator: filter.operators[ 0 ],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
} );
|
|
62
|
+
} }
|
|
63
|
+
>
|
|
64
|
+
<DropdownMenuItemLabel>
|
|
65
|
+
{ filter.name }
|
|
66
|
+
</DropdownMenuItemLabel>
|
|
67
|
+
</DropdownMenuItem>
|
|
68
|
+
);
|
|
69
|
+
} ) }
|
|
263
70
|
</DropdownMenu>
|
|
264
71
|
);
|
|
265
72
|
}
|
|
73
|
+
|
|
74
|
+
export default forwardRef( AddFilter );
|