@wordpress/dataviews 1.2.0 → 2.0.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 +16 -0
- package/README.md +33 -30
- package/build/add-filter.js +30 -22
- package/build/add-filter.js.map +1 -1
- package/build/bulk-actions-toolbar.js +74 -69
- package/build/bulk-actions-toolbar.js.map +1 -1
- package/build/bulk-actions.js +69 -56
- package/build/bulk-actions.js.map +1 -1
- package/build/constants.js +17 -10
- package/build/constants.js.map +1 -1
- package/build/dataviews.js +63 -56
- package/build/dataviews.js.map +1 -1
- package/build/filter-summary.js +105 -95
- package/build/filter-summary.js.map +1 -1
- package/build/filters.js +18 -17
- package/build/filters.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/item-actions.js +78 -65
- package/build/item-actions.js.map +1 -1
- package/build/layouts.js.map +1 -1
- package/build/pagination.js +60 -57
- package/build/pagination.js.map +1 -1
- package/build/reset-filters.js +9 -4
- package/build/reset-filters.js.map +1 -1
- package/build/search-widget.js +108 -89
- package/build/search-widget.js.map +1 -1
- package/build/search.js +13 -6
- package/build/search.js.map +1 -1
- package/build/single-selection-checkbox.js +2 -2
- package/build/single-selection-checkbox.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils.js +3 -15
- package/build/utils.js.map +1 -1
- package/build/view-actions.js +168 -120
- package/build/view-actions.js.map +1 -1
- package/build/view-grid.js +113 -99
- package/build/view-grid.js.map +1 -1
- package/build/view-list.js +153 -132
- package/build/view-list.js.map +1 -1
- package/build/view-table.js +220 -192
- package/build/view-table.js.map +1 -1
- package/build-module/add-filter.js +30 -22
- package/build-module/add-filter.js.map +1 -1
- package/build-module/bulk-actions-toolbar.js +76 -69
- package/build-module/bulk-actions-toolbar.js.map +1 -1
- package/build-module/bulk-actions.js +71 -56
- package/build-module/bulk-actions.js.map +1 -1
- package/build-module/constants.js +16 -9
- package/build-module/constants.js.map +1 -1
- package/build-module/dataviews.js +64 -56
- package/build-module/dataviews.js.map +1 -1
- package/build-module/filter-summary.js +106 -96
- package/build-module/filter-summary.js.map +1 -1
- package/build-module/filters.js +18 -17
- package/build-module/filters.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/item-actions.js +80 -65
- package/build-module/item-actions.js.map +1 -1
- package/build-module/layouts.js.map +1 -1
- package/build-module/pagination.js +61 -58
- package/build-module/pagination.js.map +1 -1
- package/build-module/reset-filters.js +9 -4
- package/build-module/reset-filters.js.map +1 -1
- package/build-module/search-widget.js +109 -89
- package/build-module/search-widget.js.map +1 -1
- package/build-module/search.js +13 -6
- package/build-module/search.js.map +1 -1
- package/build-module/single-selection-checkbox.js +2 -3
- package/build-module/single-selection-checkbox.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-module/utils.js +2 -13
- package/build-module/utils.js.map +1 -1
- package/build-module/view-actions.js +170 -121
- package/build-module/view-actions.js.map +1 -1
- package/build-module/view-grid.js +115 -99
- package/build-module/view-grid.js.map +1 -1
- package/build-module/view-list.js +154 -132
- package/build-module/view-list.js.map +1 -1
- package/build-module/view-table.js +223 -194
- package/build-module/view-table.js.map +1 -1
- package/build-style/style-rtl.css +109 -20
- package/build-style/style.css +109 -20
- package/build-types/add-filter.d.ts +9 -6
- package/build-types/add-filter.d.ts.map +1 -1
- package/build-types/bulk-actions-toolbar.d.ts +11 -7
- package/build-types/bulk-actions-toolbar.d.ts.map +1 -1
- package/build-types/bulk-actions.d.ts.map +1 -1
- package/build-types/constants.d.ts +19 -32
- package/build-types/constants.d.ts.map +1 -1
- package/build-types/dataviews.d.ts +21 -14
- package/build-types/dataviews.d.ts.map +1 -1
- package/build-types/filter-summary.d.ts +13 -5
- package/build-types/filter-summary.d.ts.map +1 -1
- package/build-types/filters.d.ts +11 -1
- package/build-types/filters.d.ts.map +1 -1
- package/build-types/index.d.ts +3 -3
- package/build-types/index.d.ts.map +1 -1
- package/build-types/item-actions.d.ts +5 -7
- package/build-types/item-actions.d.ts.map +1 -1
- package/build-types/layouts.d.ts +8 -4
- package/build-types/layouts.d.ts.map +1 -1
- package/build-types/reset-filters.d.ts +12 -5
- package/build-types/reset-filters.d.ts.map +1 -1
- package/build-types/search-widget.d.ts +9 -1
- package/build-types/search-widget.d.ts.map +1 -1
- package/build-types/search.d.ts +11 -1
- package/build-types/search.d.ts.map +1 -1
- package/build-types/types.d.ts +78 -10
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils.d.ts +2 -1
- package/build-types/utils.d.ts.map +1 -1
- package/build-types/view-actions.d.ts +10 -1
- package/build-types/view-actions.d.ts.map +1 -1
- package/build-types/view-grid.d.ts +1 -12
- package/build-types/view-grid.d.ts.map +1 -1
- package/build-types/view-list.d.ts +2 -14
- package/build-types/view-list.d.ts.map +1 -1
- package/build-types/view-table.d.ts +3 -12
- package/build-types/view-table.d.ts.map +1 -1
- package/package.json +11 -12
- package/src/{add-filter.js → add-filter.tsx} +17 -1
- package/src/{bulk-actions-toolbar.js → bulk-actions-toolbar.tsx} +68 -40
- package/src/bulk-actions.tsx +5 -1
- package/src/constants.ts +12 -5
- package/src/{dataviews.js → dataviews.tsx} +41 -12
- package/src/{filter-summary.js → filter-summary.tsx} +35 -6
- package/src/{filters.js → filters.tsx} +18 -6
- package/src/item-actions.tsx +20 -15
- package/src/pagination.tsx +1 -1
- package/src/{reset-filters.js → reset-filters.tsx} +17 -2
- package/src/{search-widget.js → search-widget.tsx} +27 -7
- package/src/{search.js → search.tsx} +22 -5
- package/src/style.scss +97 -23
- package/src/types.ts +105 -10
- package/src/{utils.js → utils.ts} +5 -13
- package/src/{view-actions.js → view-actions.tsx} +105 -49
- package/src/view-grid.tsx +4 -20
- package/src/view-list.tsx +12 -23
- package/src/{view-table.js → view-table.tsx} +91 -32
- package/tsconfig.json +0 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dropdown-menu-helper.js +0 -71
- package/build/dropdown-menu-helper.js.map +0 -1
- package/build-module/dropdown-menu-helper.js +0 -64
- package/build-module/dropdown-menu-helper.js.map +0 -1
- package/build-types/dropdown-menu-helper.d.ts +0 -6
- package/build-types/dropdown-menu-helper.d.ts.map +0 -1
- package/src/dropdown-menu-helper.js +0 -61
- /package/src/{index.js → index.ts} +0 -0
- /package/src/{layouts.js → layouts.ts} +0 -0
package/build/search-widget.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = SearchWidget;
|
|
8
|
-
var _react = require("react");
|
|
9
8
|
var Ariakit = _interopRequireWildcard(require("@ariakit/react"));
|
|
10
9
|
var _removeAccents = _interopRequireDefault(require("remove-accents"));
|
|
11
10
|
var _i18n = require("@wordpress/i18n");
|
|
@@ -14,6 +13,7 @@ var _components = require("@wordpress/components");
|
|
|
14
13
|
var _icons = require("@wordpress/icons");
|
|
15
14
|
var _primitives = require("@wordpress/primitives");
|
|
16
15
|
var _lockUnlock = require("./lock-unlock");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
19
|
/**
|
|
@@ -34,14 +34,15 @@ const {
|
|
|
34
34
|
CompositeItemV2: CompositeItem,
|
|
35
35
|
useCompositeStoreV2: useCompositeStore
|
|
36
36
|
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
37
|
-
const radioCheck = (0,
|
|
37
|
+
const radioCheck = /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.SVG, {
|
|
38
38
|
xmlns: "http://www.w3.org/2000/svg",
|
|
39
|
-
viewBox: "0 0 24 24"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})
|
|
39
|
+
viewBox: "0 0 24 24",
|
|
40
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.Circle, {
|
|
41
|
+
cx: 12,
|
|
42
|
+
cy: 12,
|
|
43
|
+
r: 3
|
|
44
|
+
})
|
|
45
|
+
});
|
|
45
46
|
function normalizeSearchInput(input = '') {
|
|
46
47
|
return (0, _removeAccents.default)(input.trim().toLowerCase());
|
|
47
48
|
}
|
|
@@ -82,7 +83,7 @@ function ListBox({
|
|
|
82
83
|
});
|
|
83
84
|
const currentFilter = view.filters.find(f => f.field === filter.field);
|
|
84
85
|
const currentValue = getCurrentValue(filter, currentFilter);
|
|
85
|
-
return (0,
|
|
86
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Composite, {
|
|
86
87
|
store: compositeStore,
|
|
87
88
|
role: "listbox",
|
|
88
89
|
className: "dataviews-search-widget-listbox",
|
|
@@ -93,49 +94,54 @@ function ListBox({
|
|
|
93
94
|
compositeStore.move(compositeStore.first());
|
|
94
95
|
}
|
|
95
96
|
},
|
|
96
|
-
render: (0,
|
|
97
|
+
render: /*#__PURE__*/(0, _jsxRuntime.jsx)(Ariakit.CompositeTypeahead, {
|
|
97
98
|
store: compositeStore
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
}),
|
|
100
|
+
children: filter.elements.map(element => /*#__PURE__*/(0, _jsxRuntime.jsxs)(Ariakit.CompositeHover, {
|
|
101
|
+
store: compositeStore,
|
|
102
|
+
render: /*#__PURE__*/(0, _jsxRuntime.jsx)(CompositeItem, {
|
|
103
|
+
render: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
104
|
+
"aria-label": element.label,
|
|
105
|
+
role: "option",
|
|
106
|
+
className: "dataviews-search-widget-listitem"
|
|
107
|
+
}),
|
|
108
|
+
onClick: () => {
|
|
109
|
+
const newFilters = currentFilter ? [...view.filters.map(_filter => {
|
|
110
|
+
if (_filter.field === filter.field) {
|
|
111
|
+
return {
|
|
112
|
+
..._filter,
|
|
113
|
+
operator: currentFilter.operator || filter.operators[0],
|
|
114
|
+
value: getNewValue(filter, currentFilter, element.value)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return _filter;
|
|
118
|
+
})] : [...view.filters, {
|
|
119
|
+
field: filter.field,
|
|
120
|
+
operator: filter.operators[0],
|
|
121
|
+
value: getNewValue(filter, currentFilter, element.value)
|
|
122
|
+
}];
|
|
123
|
+
onChangeView({
|
|
124
|
+
...view,
|
|
125
|
+
page: 1,
|
|
126
|
+
filters: newFilters
|
|
127
|
+
});
|
|
128
|
+
}
|
|
107
129
|
}),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
onChangeView({
|
|
124
|
-
...view,
|
|
125
|
-
page: 1,
|
|
126
|
-
filters: newFilters
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
}, (0, _react.createElement)("span", {
|
|
131
|
-
className: "dataviews-search-widget-listitem-check"
|
|
132
|
-
}, filter.singleSelection && currentValue === element.value && (0, _react.createElement)(_components.Icon, {
|
|
133
|
-
icon: radioCheck
|
|
134
|
-
}), !filter.singleSelection && currentValue.includes(element.value) && (0, _react.createElement)(_components.Icon, {
|
|
135
|
-
icon: _icons.check
|
|
136
|
-
})), (0, _react.createElement)("span", null, element.label, !!element.description && (0, _react.createElement)("span", {
|
|
137
|
-
className: "dataviews-search-widget-listitem-description"
|
|
138
|
-
}, element.description)))));
|
|
130
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
131
|
+
className: "dataviews-search-widget-listitem-check",
|
|
132
|
+
children: [filter.singleSelection && currentValue === element.value && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
133
|
+
icon: radioCheck
|
|
134
|
+
}), !filter.singleSelection && currentValue.includes(element.value) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
135
|
+
icon: _icons.check
|
|
136
|
+
})]
|
|
137
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
138
|
+
children: [element.label, !!element.description && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
139
|
+
className: "dataviews-search-widget-listitem-description",
|
|
140
|
+
children: element.description
|
|
141
|
+
})]
|
|
142
|
+
})]
|
|
143
|
+
}, element.value))
|
|
144
|
+
});
|
|
139
145
|
}
|
|
140
146
|
function ComboboxList({
|
|
141
147
|
view,
|
|
@@ -150,7 +156,7 @@ function ComboboxList({
|
|
|
150
156
|
const normalizedSearch = normalizeSearchInput(deferredSearchValue);
|
|
151
157
|
return filter.elements.filter(item => normalizeSearchInput(item.label).includes(normalizedSearch));
|
|
152
158
|
}, [filter.elements, deferredSearchValue]);
|
|
153
|
-
return (0,
|
|
159
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Ariakit.ComboboxProvider, {
|
|
154
160
|
resetValueOnSelect: false,
|
|
155
161
|
selectedValue: currentValue,
|
|
156
162
|
setSelectedValue: value => {
|
|
@@ -174,47 +180,60 @@ function ComboboxList({
|
|
|
174
180
|
filters: newFilters
|
|
175
181
|
});
|
|
176
182
|
},
|
|
177
|
-
setValue: setSearchValue
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
183
|
+
setValue: setSearchValue,
|
|
184
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
185
|
+
className: "dataviews-search-widget-filter-combobox__wrapper",
|
|
186
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Ariakit.ComboboxLabel, {
|
|
187
|
+
render: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.VisuallyHidden, {
|
|
188
|
+
children: (0, _i18n.__)('Search items')
|
|
189
|
+
}),
|
|
190
|
+
children: (0, _i18n.__)('Search items')
|
|
191
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Ariakit.Combobox, {
|
|
192
|
+
autoSelect: "always",
|
|
193
|
+
placeholder: (0, _i18n.__)('Search'),
|
|
194
|
+
className: "dataviews-search-widget-filter-combobox__input"
|
|
195
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
196
|
+
className: "dataviews-search-widget-filter-combobox__icon",
|
|
197
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
198
|
+
icon: _icons.search
|
|
199
|
+
})
|
|
200
|
+
})]
|
|
201
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Ariakit.ComboboxList, {
|
|
202
|
+
className: "dataviews-search-widget-filter-combobox-list",
|
|
203
|
+
alwaysVisible: true,
|
|
204
|
+
children: [matches.map(element => {
|
|
205
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Ariakit.ComboboxItem, {
|
|
206
|
+
value: element.value,
|
|
207
|
+
className: "dataviews-search-widget-listitem",
|
|
208
|
+
hideOnClick: false,
|
|
209
|
+
setValueOnClick: false,
|
|
210
|
+
focusOnHover: true,
|
|
211
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
212
|
+
className: "dataviews-search-widget-listitem-check",
|
|
213
|
+
children: [filter.singleSelection && currentValue === element.value && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
214
|
+
icon: radioCheck
|
|
215
|
+
}), !filter.singleSelection && currentValue.includes(element.value) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
216
|
+
icon: _icons.check
|
|
217
|
+
})]
|
|
218
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
219
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Ariakit.ComboboxItemValue, {
|
|
220
|
+
className: "dataviews-search-widget-filter-combobox-item-value",
|
|
221
|
+
value: element.label
|
|
222
|
+
}), !!element.description && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
223
|
+
className: "dataviews-search-widget-listitem-description",
|
|
224
|
+
children: element.description
|
|
225
|
+
})]
|
|
226
|
+
})]
|
|
227
|
+
}, element.value);
|
|
228
|
+
}), !matches.length && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
229
|
+
children: (0, _i18n.__)('No results found')
|
|
230
|
+
})]
|
|
231
|
+
})]
|
|
232
|
+
});
|
|
214
233
|
}
|
|
215
234
|
function SearchWidget(props) {
|
|
216
235
|
const Widget = props.filter.elements.length > 10 ? ComboboxList : ListBox;
|
|
217
|
-
return (0,
|
|
236
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Widget, {
|
|
218
237
|
...props
|
|
219
238
|
});
|
|
220
239
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Ariakit","_interopRequireWildcard","require","_removeAccents","_interopRequireDefault","_i18n","_element","_components","_icons","_primitives","_lockUnlock","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","CompositeV2","Composite","CompositeItemV2","CompositeItem","useCompositeStoreV2","useCompositeStore","unlock","componentsPrivateApis","radioCheck","_react","createElement","SVG","xmlns","viewBox","Circle","cx","cy","normalizeSearchInput","input","removeAccents","trim","toLowerCase","EMPTY_ARRAY","getCurrentValue","filterDefinition","currentFilter","singleSelection","value","Array","isArray","getNewValue","includes","filter","v","ListBox","view","onChangeView","compositeStore","virtualFocus","focusLoop","defaultActiveId","operators","length","undefined","filters","find","f","field","currentValue","store","role","className","sprintf","__","name","onFocusVisible","getState","activeId","move","first","render","CompositeTypeahead","elements","map","element","CompositeHover","key","label","onClick","newFilters","_filter","operator","page","Icon","icon","check","description","ComboboxList","searchValue","setSearchValue","useState","deferredSearchValue","useDeferredValue","matches","useMemo","normalizedSearch","item","ComboboxProvider","resetValueOnSelect","selectedValue","setSelectedValue","setValue","ComboboxLabel","VisuallyHidden","Combobox","autoSelect","placeholder","search","alwaysVisible","ComboboxItem","hideOnClick","setValueOnClick","focusOnHover","ComboboxItemValue","SearchWidget","props","Widget"],"sources":["@wordpress/dataviews/src/search-widget.js"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState, useMemo, useDeferredValue } from '@wordpress/element';\nimport {\n\tVisuallyHidden,\n\tIcon,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { search, check } from '@wordpress/icons';\nimport { SVG, Circle } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst {\n\tCompositeV2: Composite,\n\tCompositeItemV2: CompositeItem,\n\tuseCompositeStoreV2: useCompositeStore,\n} = unlock( componentsPrivateApis );\n\nconst radioCheck = (\n\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">\n\t\t<Circle cx={ 12 } cy={ 12 } r={ 3 }></Circle>\n\t</SVG>\n);\n\nfunction normalizeSearchInput( input = '' ) {\n\treturn removeAccents( input.trim().toLowerCase() );\n}\n\nconst EMPTY_ARRAY = [];\nconst getCurrentValue = ( filterDefinition, currentFilter ) => {\n\tif ( filterDefinition.singleSelection ) {\n\t\treturn currentFilter?.value;\n\t}\n\n\tif ( Array.isArray( currentFilter?.value ) ) {\n\t\treturn currentFilter.value;\n\t}\n\n\tif ( ! Array.isArray( currentFilter?.value ) && !! currentFilter?.value ) {\n\t\treturn [ currentFilter.value ];\n\t}\n\n\treturn EMPTY_ARRAY;\n};\n\nconst getNewValue = ( filterDefinition, currentFilter, value ) => {\n\tif ( filterDefinition.singleSelection ) {\n\t\treturn value;\n\t}\n\n\tif ( Array.isArray( currentFilter?.value ) ) {\n\t\treturn currentFilter.value.includes( value )\n\t\t\t? currentFilter.value.filter( ( v ) => v !== value )\n\t\t\t: [ ...currentFilter.value, value ];\n\t}\n\n\treturn [ value ];\n};\n\nfunction ListBox( { view, filter, onChangeView } ) {\n\tconst compositeStore = useCompositeStore( {\n\t\tvirtualFocus: true,\n\t\tfocusLoop: true,\n\t\t// When we have no or just one operator, we can set the first item as active.\n\t\t// We do that by passing `undefined` to `defaultActiveId`. Otherwise, we set it to `null`,\n\t\t// so the first item is not selected, since the focus is on the operators control.\n\t\tdefaultActiveId: filter.operators?.length === 1 ? undefined : null,\n\t} );\n\tconst currentFilter = view.filters.find(\n\t\t( f ) => f.field === filter.field\n\t);\n\tconst currentValue = getCurrentValue( filter, currentFilter );\n\treturn (\n\t\t<Composite\n\t\t\tstore={ compositeStore }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"dataviews-search-widget-listbox\"\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: List of items for a filter. 1: Filter name. e.g.: \"List of: Author\". */\n\t\t\t\t__( 'List of: %1$s' ),\n\t\t\t\tfilter.name\n\t\t\t) }\n\t\t\tonFocusVisible={ () => {\n\t\t\t\tif ( ! compositeStore.getState().activeId ) {\n\t\t\t\t\tcompositeStore.move( compositeStore.first() );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trender={ <Ariakit.CompositeTypeahead store={ compositeStore } /> }\n\t\t>\n\t\t\t{ filter.elements.map( ( element ) => (\n\t\t\t\t<Ariakit.CompositeHover\n\t\t\t\t\tstore={ compositeStore }\n\t\t\t\t\tkey={ element.value }\n\t\t\t\t\trender={\n\t\t\t\t\t\t<CompositeItem\n\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\taria-label={ element.label }\n\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-listitem\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst newFilters = currentFilter\n\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t...view.filters.map(\n\t\t\t\t\t\t\t\t\t\t\t\t( _filter ) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t_filter.field ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter.field\n\t\t\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\toperator:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter.operator ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: getNewValue(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telement.value\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn _filter;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t\t\t...view.filters,\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\t\t\t\t\toperator: filter.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: getNewValue(\n\t\t\t\t\t\t\t\t\t\t\t\t\tfilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\telement.value\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t ];\n\t\t\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\t\t\tpage: 1,\n\t\t\t\t\t\t\t\t\tfilters: newFilters,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-check\">\n\t\t\t\t\t\t{ filter.singleSelection &&\n\t\t\t\t\t\t\tcurrentValue === element.value && (\n\t\t\t\t\t\t\t\t<Icon icon={ radioCheck } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! filter.singleSelection &&\n\t\t\t\t\t\t\tcurrentValue.includes( element.value ) && (\n\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span>\n\t\t\t\t\t\t{ element.label }\n\t\t\t\t\t\t{ !! element.description && (\n\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-description\">\n\t\t\t\t\t\t\t\t{ element.description }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</Ariakit.CompositeHover>\n\t\t\t) ) }\n\t\t</Composite>\n\t);\n}\n\nfunction ComboboxList( { view, filter, onChangeView } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst deferredSearchValue = useDeferredValue( searchValue );\n\tconst currentFilter = view.filters.find(\n\t\t( _filter ) => _filter.field === filter.field\n\t);\n\tconst currentValue = getCurrentValue( filter, currentFilter );\n\tconst matches = useMemo( () => {\n\t\tconst normalizedSearch = normalizeSearchInput( deferredSearchValue );\n\t\treturn filter.elements.filter( ( item ) =>\n\t\t\tnormalizeSearchInput( item.label ).includes( normalizedSearch )\n\t\t);\n\t}, [ filter.elements, deferredSearchValue ] );\n\treturn (\n\t\t<Ariakit.ComboboxProvider\n\t\t\tresetValueOnSelect={ false }\n\t\t\tselectedValue={ currentValue }\n\t\t\tsetSelectedValue={ ( value ) => {\n\t\t\t\tconst newFilters = currentFilter\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t...view.filters.map( ( _filter ) => {\n\t\t\t\t\t\t\t\tif ( _filter.field === filter.field ) {\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\t\t\t\toperator:\n\t\t\t\t\t\t\t\t\t\t\tcurrentFilter.operator ||\n\t\t\t\t\t\t\t\t\t\t\tfilter.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn _filter;\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t ]\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t...view.filters,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\toperator: filter.operators[ 0 ],\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ];\n\t\t\t\tonChangeView( {\n\t\t\t\t\t...view,\n\t\t\t\t\tpage: 1,\n\t\t\t\t\tfilters: newFilters,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tsetValue={ setSearchValue }\n\t\t>\n\t\t\t<div className=\"dataviews-search-widget-filter-combobox__wrapper\">\n\t\t\t\t<Ariakit.ComboboxLabel render={ <VisuallyHidden /> }>\n\t\t\t\t\t{ __( 'Search items' ) }\n\t\t\t\t</Ariakit.ComboboxLabel>\n\t\t\t\t<Ariakit.Combobox\n\t\t\t\t\tautoSelect=\"always\"\n\t\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox__input\"\n\t\t\t\t/>\n\t\t\t\t<div className=\"dataviews-search-widget-filter-combobox__icon\">\n\t\t\t\t\t<Icon icon={ search } />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<Ariakit.ComboboxList\n\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox-list\"\n\t\t\t\talwaysVisible\n\t\t\t>\n\t\t\t\t{ matches.map( ( element ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Ariakit.ComboboxItem\n\t\t\t\t\t\t\tkey={ element.value }\n\t\t\t\t\t\t\tvalue={ element.value }\n\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-listitem\"\n\t\t\t\t\t\t\thideOnClick={ false }\n\t\t\t\t\t\t\tsetValueOnClick={ false }\n\t\t\t\t\t\t\tfocusOnHover\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-check\">\n\t\t\t\t\t\t\t\t{ filter.singleSelection &&\n\t\t\t\t\t\t\t\t\tcurrentValue === element.value && (\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ radioCheck } />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ ! filter.singleSelection &&\n\t\t\t\t\t\t\t\t\tcurrentValue.includes( element.value ) && (\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<Ariakit.ComboboxItemValue\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox-item-value\"\n\t\t\t\t\t\t\t\t\tvalue={ element.label }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ !! element.description && (\n\t\t\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-description\">\n\t\t\t\t\t\t\t\t\t\t{ element.description }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Ariakit.ComboboxItem>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ ! matches.length && <p>{ __( 'No results found' ) }</p> }\n\t\t\t</Ariakit.ComboboxList>\n\t\t</Ariakit.ComboboxProvider>\n\t);\n}\n\nexport default function SearchWidget( props ) {\n\tconst Widget = props.filter.elements.length > 10 ? ComboboxList : ListBox;\n\treturn <Widget { ...props } />;\n}\n"],"mappings":";;;;;;;;AAIA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,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B,YAAY,CAACjB,QAAQ,CAAEiC,OAAO,CAACrC,KAAM,CAAC,IACrC,IAAAlB,MAAA,CAAAC,aAAA,EAAClC,WAAA,CAAAiG,IAAI;MAACC,IAAI,EAAGC;IAAO,CAAE,CAEnB,CAAC,EACP,IAAAlE,MAAA,CAAAC,aAAA,gBACC,IAAAD,MAAA,CAAAC,aAAA,EAACzC,OAAO,CAACsI,iBAAiB;MACzBpD,SAAS,EAAC,oDAAoD;MAC9DxB,KAAK,EAAGqC,OAAO,CAACG;IAAO,CACvB,CAAC,EACA,CAAC,CAAEH,OAAO,CAACY,WAAW,IACvB,IAAAnE,MAAA,CAAAC,aAAA;MAAMyC,SAAS,EAAC;IAA8C,GAC3Da,OAAO,CAACY,WACL,CAEF,CACe,CAAC;EAEzB,CAAE,CAAC,EACD,CAAEO,OAAO,CAACzC,MAAM,IAAI,IAAAjC,MAAA,CAAAC,aAAA,aAAK,IAAA2C,QAAE,EAAE,kBAAmB,CAAM,CACnC,CACG,CAAC;AAE7B;AAEe,SAASmD,YAAYA,CAAEC,KAAK,EAAG;EAC7C,MAAMC,MAAM,GAAGD,KAAK,CAACzE,MAAM,CAAC8B,QAAQ,CAACpB,MAAM,GAAG,EAAE,GAAGmC,YAAY,GAAG3C,OAAO;EACzE,OAAO,IAAAzB,MAAA,CAAAC,aAAA,EAACgG,MAAM;IAAA,GAAMD;EAAK,CAAI,CAAC;AAC/B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Ariakit","_interopRequireWildcard","require","_removeAccents","_interopRequireDefault","_i18n","_element","_components","_icons","_primitives","_lockUnlock","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","CompositeV2","Composite","CompositeItemV2","CompositeItem","useCompositeStoreV2","useCompositeStore","unlock","componentsPrivateApis","radioCheck","jsx","SVG","xmlns","viewBox","children","Circle","cx","cy","normalizeSearchInput","input","removeAccents","trim","toLowerCase","EMPTY_ARRAY","getCurrentValue","filterDefinition","currentFilter","singleSelection","value","Array","isArray","getNewValue","includes","filter","v","ListBox","view","onChangeView","compositeStore","virtualFocus","focusLoop","defaultActiveId","operators","length","undefined","filters","find","f","field","currentValue","store","role","className","sprintf","__","name","onFocusVisible","getState","activeId","move","first","render","CompositeTypeahead","elements","map","element","jsxs","CompositeHover","label","onClick","newFilters","_filter","operator","page","Icon","icon","check","description","ComboboxList","searchValue","setSearchValue","useState","deferredSearchValue","useDeferredValue","matches","useMemo","normalizedSearch","item","ComboboxProvider","resetValueOnSelect","selectedValue","setSelectedValue","setValue","ComboboxLabel","VisuallyHidden","Combobox","autoSelect","placeholder","search","alwaysVisible","ComboboxItem","hideOnClick","setValueOnClick","focusOnHover","ComboboxItemValue","SearchWidget","props","Widget"],"sources":["@wordpress/dataviews/src/search-widget.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState, useMemo, useDeferredValue } from '@wordpress/element';\nimport {\n\tVisuallyHidden,\n\tIcon,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { search, check } from '@wordpress/icons';\nimport { SVG, Circle } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport type { Filter, NormalizedFilter, View } from './types';\n\nconst {\n\tCompositeV2: Composite,\n\tCompositeItemV2: CompositeItem,\n\tuseCompositeStoreV2: useCompositeStore,\n} = unlock( componentsPrivateApis );\n\ninterface SearchWidgetProps {\n\tview: View;\n\tfilter: NormalizedFilter;\n\tonChangeView: ( view: View ) => void;\n}\n\nconst radioCheck = (\n\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">\n\t\t<Circle cx={ 12 } cy={ 12 } r={ 3 }></Circle>\n\t</SVG>\n);\n\nfunction normalizeSearchInput( input = '' ) {\n\treturn removeAccents( input.trim().toLowerCase() );\n}\n\nconst EMPTY_ARRAY: [] = [];\nconst getCurrentValue = (\n\tfilterDefinition: NormalizedFilter,\n\tcurrentFilter?: Filter\n) => {\n\tif ( filterDefinition.singleSelection ) {\n\t\treturn currentFilter?.value;\n\t}\n\n\tif ( Array.isArray( currentFilter?.value ) ) {\n\t\treturn currentFilter.value;\n\t}\n\n\tif ( ! Array.isArray( currentFilter?.value ) && !! currentFilter?.value ) {\n\t\treturn [ currentFilter.value ];\n\t}\n\n\treturn EMPTY_ARRAY;\n};\n\nconst getNewValue = (\n\tfilterDefinition: NormalizedFilter,\n\tcurrentFilter: Filter | undefined,\n\tvalue: any\n) => {\n\tif ( filterDefinition.singleSelection ) {\n\t\treturn value;\n\t}\n\n\tif ( Array.isArray( currentFilter?.value ) ) {\n\t\treturn currentFilter.value.includes( value )\n\t\t\t? currentFilter.value.filter( ( v ) => v !== value )\n\t\t\t: [ ...currentFilter.value, value ];\n\t}\n\n\treturn [ value ];\n};\n\nfunction ListBox( { view, filter, onChangeView }: SearchWidgetProps ) {\n\tconst compositeStore = useCompositeStore( {\n\t\tvirtualFocus: true,\n\t\tfocusLoop: true,\n\t\t// When we have no or just one operator, we can set the first item as active.\n\t\t// We do that by passing `undefined` to `defaultActiveId`. Otherwise, we set it to `null`,\n\t\t// so the first item is not selected, since the focus is on the operators control.\n\t\tdefaultActiveId: filter.operators?.length === 1 ? undefined : null,\n\t} );\n\tconst currentFilter = view.filters.find(\n\t\t( f ) => f.field === filter.field\n\t);\n\tconst currentValue = getCurrentValue( filter, currentFilter );\n\treturn (\n\t\t<Composite\n\t\t\tstore={ compositeStore }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"dataviews-search-widget-listbox\"\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: List of items for a filter. 1: Filter name. e.g.: \"List of: Author\". */\n\t\t\t\t__( 'List of: %1$s' ),\n\t\t\t\tfilter.name\n\t\t\t) }\n\t\t\tonFocusVisible={ () => {\n\t\t\t\tif ( ! compositeStore.getState().activeId ) {\n\t\t\t\t\tcompositeStore.move( compositeStore.first() );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trender={ <Ariakit.CompositeTypeahead store={ compositeStore } /> }\n\t\t>\n\t\t\t{ filter.elements.map( ( element ) => (\n\t\t\t\t<Ariakit.CompositeHover\n\t\t\t\t\tstore={ compositeStore }\n\t\t\t\t\tkey={ element.value }\n\t\t\t\t\trender={\n\t\t\t\t\t\t<CompositeItem\n\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\taria-label={ element.label }\n\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-listitem\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst newFilters = currentFilter\n\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t...view.filters.map(\n\t\t\t\t\t\t\t\t\t\t\t\t( _filter ) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t_filter.field ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter.field\n\t\t\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\toperator:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter.operator ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: getNewValue(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telement.value\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn _filter;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t\t\t...view.filters,\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\t\t\t\t\toperator: filter.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: getNewValue(\n\t\t\t\t\t\t\t\t\t\t\t\t\tfilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\telement.value\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t ];\n\t\t\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\t\t\tpage: 1,\n\t\t\t\t\t\t\t\t\tfilters: newFilters,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-check\">\n\t\t\t\t\t\t{ filter.singleSelection &&\n\t\t\t\t\t\t\tcurrentValue === element.value && (\n\t\t\t\t\t\t\t\t<Icon icon={ radioCheck } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! filter.singleSelection &&\n\t\t\t\t\t\t\tcurrentValue.includes( element.value ) && (\n\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span>\n\t\t\t\t\t\t{ element.label }\n\t\t\t\t\t\t{ !! element.description && (\n\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-description\">\n\t\t\t\t\t\t\t\t{ element.description }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</Ariakit.CompositeHover>\n\t\t\t) ) }\n\t\t</Composite>\n\t);\n}\n\nfunction ComboboxList( { view, filter, onChangeView }: SearchWidgetProps ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst deferredSearchValue = useDeferredValue( searchValue );\n\tconst currentFilter = view.filters.find(\n\t\t( _filter ) => _filter.field === filter.field\n\t);\n\tconst currentValue = getCurrentValue( filter, currentFilter );\n\tconst matches = useMemo( () => {\n\t\tconst normalizedSearch = normalizeSearchInput( deferredSearchValue );\n\t\treturn filter.elements.filter( ( item ) =>\n\t\t\tnormalizeSearchInput( item.label ).includes( normalizedSearch )\n\t\t);\n\t}, [ filter.elements, deferredSearchValue ] );\n\treturn (\n\t\t<Ariakit.ComboboxProvider\n\t\t\tresetValueOnSelect={ false }\n\t\t\tselectedValue={ currentValue }\n\t\t\tsetSelectedValue={ ( value ) => {\n\t\t\t\tconst newFilters = currentFilter\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t...view.filters.map( ( _filter ) => {\n\t\t\t\t\t\t\t\tif ( _filter.field === filter.field ) {\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\t\t\t\toperator:\n\t\t\t\t\t\t\t\t\t\t\tcurrentFilter.operator ||\n\t\t\t\t\t\t\t\t\t\t\tfilter.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn _filter;\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t ]\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t...view.filters,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\toperator: filter.operators[ 0 ],\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ];\n\t\t\t\tonChangeView( {\n\t\t\t\t\t...view,\n\t\t\t\t\tpage: 1,\n\t\t\t\t\tfilters: newFilters,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tsetValue={ setSearchValue }\n\t\t>\n\t\t\t<div className=\"dataviews-search-widget-filter-combobox__wrapper\">\n\t\t\t\t<Ariakit.ComboboxLabel\n\t\t\t\t\trender={\n\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t{ __( 'Search items' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Search items' ) }\n\t\t\t\t</Ariakit.ComboboxLabel>\n\t\t\t\t<Ariakit.Combobox\n\t\t\t\t\tautoSelect=\"always\"\n\t\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox__input\"\n\t\t\t\t/>\n\t\t\t\t<div className=\"dataviews-search-widget-filter-combobox__icon\">\n\t\t\t\t\t<Icon icon={ search } />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<Ariakit.ComboboxList\n\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox-list\"\n\t\t\t\talwaysVisible\n\t\t\t>\n\t\t\t\t{ matches.map( ( element ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Ariakit.ComboboxItem\n\t\t\t\t\t\t\tkey={ element.value }\n\t\t\t\t\t\t\tvalue={ element.value }\n\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-listitem\"\n\t\t\t\t\t\t\thideOnClick={ false }\n\t\t\t\t\t\t\tsetValueOnClick={ false }\n\t\t\t\t\t\t\tfocusOnHover\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-check\">\n\t\t\t\t\t\t\t\t{ filter.singleSelection &&\n\t\t\t\t\t\t\t\t\tcurrentValue === element.value && (\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ radioCheck } />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ ! filter.singleSelection &&\n\t\t\t\t\t\t\t\t\tcurrentValue.includes( element.value ) && (\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<Ariakit.ComboboxItemValue\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox-item-value\"\n\t\t\t\t\t\t\t\t\tvalue={ element.label }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ !! element.description && (\n\t\t\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-description\">\n\t\t\t\t\t\t\t\t\t\t{ element.description }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Ariakit.ComboboxItem>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ ! matches.length && <p>{ __( 'No results found' ) }</p> }\n\t\t\t</Ariakit.ComboboxList>\n\t\t</Ariakit.ComboboxProvider>\n\t);\n}\n\nexport default function SearchWidget( props: SearchWidgetProps ) {\n\tconst Widget = props.filter.elements.length > 10 ? ComboboxList : ListBox;\n\treturn <Widget { ...props } />;\n}\n"],"mappings":";;;;;;;AAIA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAC,sB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G3C,OAAO;EACzE,oBAAO,IAAAvD,WAAA,CAAA8B,GAAA,EAACiG,MAAM;IAAA,GAAMD;EAAK,CAAI,CAAC;AAC/B","ignoreList":[]}
|
package/build/search.js
CHANGED
|
@@ -4,15 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
7
|
var _i18n = require("@wordpress/i18n");
|
|
9
8
|
var _element = require("@wordpress/element");
|
|
10
9
|
var _components = require("@wordpress/components");
|
|
11
10
|
var _compose = require("@wordpress/compose");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
/**
|
|
13
13
|
* WordPress dependencies
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
16
20
|
const Search = (0, _element.memo)(function Search({
|
|
17
21
|
label,
|
|
18
22
|
view,
|
|
@@ -20,21 +24,24 @@ const Search = (0, _element.memo)(function Search({
|
|
|
20
24
|
}) {
|
|
21
25
|
const [search, setSearch, debouncedSearch] = (0, _compose.useDebouncedInput)(view.search);
|
|
22
26
|
(0, _element.useEffect)(() => {
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
var _view$search;
|
|
28
|
+
setSearch((_view$search = view.search) !== null && _view$search !== void 0 ? _view$search : '');
|
|
29
|
+
}, [view.search, setSearch]);
|
|
25
30
|
const onChangeViewRef = (0, _element.useRef)(onChangeView);
|
|
31
|
+
const viewRef = (0, _element.useRef)(view);
|
|
26
32
|
(0, _element.useEffect)(() => {
|
|
27
33
|
onChangeViewRef.current = onChangeView;
|
|
28
|
-
|
|
34
|
+
viewRef.current = view;
|
|
35
|
+
}, [onChangeView, view]);
|
|
29
36
|
(0, _element.useEffect)(() => {
|
|
30
37
|
onChangeViewRef.current({
|
|
31
|
-
...
|
|
38
|
+
...viewRef.current,
|
|
32
39
|
page: 1,
|
|
33
40
|
search: debouncedSearch
|
|
34
41
|
});
|
|
35
42
|
}, [debouncedSearch]);
|
|
36
43
|
const searchLabel = label || (0, _i18n.__)('Search');
|
|
37
|
-
return (0,
|
|
44
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SearchControl, {
|
|
38
45
|
__nextHasNoMarginBottom: true,
|
|
39
46
|
onChange: setSearch,
|
|
40
47
|
value: search,
|
package/build/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_element","_components","_compose","Search","memo","label","view","onChangeView","search","setSearch","debouncedSearch","useDebouncedInput","useEffect","onChangeViewRef","useRef","current","page","searchLabel","__","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_element","_components","_compose","_jsxRuntime","Search","memo","label","view","onChangeView","search","setSearch","debouncedSearch","useDebouncedInput","useEffect","_view$search","onChangeViewRef","useRef","viewRef","current","page","searchLabel","__","jsx","SearchControl","__nextHasNoMarginBottom","onChange","value","placeholder","size","_default","exports","default"],"sources":["@wordpress/dataviews/src/search.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef, memo } from '@wordpress/element';\nimport { SearchControl } from '@wordpress/components';\nimport { useDebouncedInput } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { View } from './types';\n\ninterface SearchProps {\n\tlabel?: string;\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n}\n\nconst Search = memo( function Search( {\n\tlabel,\n\tview,\n\tonChangeView,\n}: SearchProps ) {\n\tconst [ search, setSearch, debouncedSearch ] = useDebouncedInput(\n\t\tview.search\n\t);\n\tuseEffect( () => {\n\t\tsetSearch( view.search ?? '' );\n\t}, [ view.search, setSearch ] );\n\tconst onChangeViewRef = useRef( onChangeView );\n\tconst viewRef = useRef( view );\n\tuseEffect( () => {\n\t\tonChangeViewRef.current = onChangeView;\n\t\tviewRef.current = view;\n\t}, [ onChangeView, view ] );\n\tuseEffect( () => {\n\t\tonChangeViewRef.current( {\n\t\t\t...viewRef.current,\n\t\t\tpage: 1,\n\t\t\tsearch: debouncedSearch,\n\t\t} );\n\t}, [ debouncedSearch ] );\n\tconst searchLabel = label || __( 'Search' );\n\treturn (\n\t\t<SearchControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tonChange={ setSearch }\n\t\t\tvalue={ search }\n\t\t\tlabel={ searchLabel }\n\t\t\tplaceholder={ searchLabel }\n\t\t\tsize=\"compact\"\n\t\t/>\n\t);\n} );\n\nexport default Search;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAAuD,IAAAI,WAAA,GAAAJ,OAAA;AANvD;AACA;AACA;;AAMA;AACA;AACA;;AASA,MAAMK,MAAM,GAAG,IAAAC,aAAI,EAAE,SAASD,MAAMA,CAAE;EACrCE,KAAK;EACLC,IAAI;EACJC;AACY,CAAC,EAAG;EAChB,MAAM,CAAEC,MAAM,EAAEC,SAAS,EAAEC,eAAe,CAAE,GAAG,IAAAC,0BAAiB,EAC/DL,IAAI,CAACE,MACN,CAAC;EACD,IAAAI,kBAAS,EAAE,MAAM;IAAA,IAAAC,YAAA;IAChBJ,SAAS,EAAAI,YAAA,GAAEP,IAAI,CAACE,MAAM,cAAAK,YAAA,cAAAA,YAAA,GAAI,EAAG,CAAC;EAC/B,CAAC,EAAE,CAAEP,IAAI,CAACE,MAAM,EAAEC,SAAS,CAAG,CAAC;EAC/B,MAAMK,eAAe,GAAG,IAAAC,eAAM,EAAER,YAAa,CAAC;EAC9C,MAAMS,OAAO,GAAG,IAAAD,eAAM,EAAET,IAAK,CAAC;EAC9B,IAAAM,kBAAS,EAAE,MAAM;IAChBE,eAAe,CAACG,OAAO,GAAGV,YAAY;IACtCS,OAAO,CAACC,OAAO,GAAGX,IAAI;EACvB,CAAC,EAAE,CAAEC,YAAY,EAAED,IAAI,CAAG,CAAC;EAC3B,IAAAM,kBAAS,EAAE,MAAM;IAChBE,eAAe,CAACG,OAAO,CAAE;MACxB,GAAGD,OAAO,CAACC,OAAO;MAClBC,IAAI,EAAE,CAAC;MACPV,MAAM,EAAEE;IACT,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEA,eAAe,CAAG,CAAC;EACxB,MAAMS,WAAW,GAAGd,KAAK,IAAI,IAAAe,QAAE,EAAE,QAAS,CAAC;EAC3C,oBACC,IAAAlB,WAAA,CAAAmB,GAAA,EAACrB,WAAA,CAAAsB,aAAa;IACbC,uBAAuB;IACvBC,QAAQ,EAAGf,SAAW;IACtBgB,KAAK,EAAGjB,MAAQ;IAChBH,KAAK,EAAGc,WAAa;IACrBO,WAAW,EAAGP,WAAa;IAC3BQ,IAAI,EAAC;EAAS,CACd,CAAC;AAEJ,CAAE,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEW3B,MAAM","ignoreList":[]}
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = SingleSelectionCheckbox;
|
|
7
|
-
var _react = require("react");
|
|
8
7
|
var _i18n = require("@wordpress/i18n");
|
|
9
8
|
var _components = require("@wordpress/components");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
/**
|
|
11
11
|
* WordPress dependencies
|
|
12
12
|
*/
|
|
@@ -36,7 +36,7 @@ function SingleSelectionCheckbox({
|
|
|
36
36
|
} else {
|
|
37
37
|
selectionLabel = isSelected ? (0, _i18n.__)('Select a new item') : (0, _i18n.__)('Deselect item');
|
|
38
38
|
}
|
|
39
|
-
return (0,
|
|
39
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
|
|
40
40
|
className: "dataviews-view-table-selection-checkbox",
|
|
41
41
|
__nextHasNoMarginBottom: true,
|
|
42
42
|
"aria-label": selectionLabel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","SingleSelectionCheckbox","selection","onSelectionChange","item","data","getItemId","primaryField","disabled","id","isSelected","includes","selectionLabel","getValue","sprintf","__","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_jsxRuntime","SingleSelectionCheckbox","selection","onSelectionChange","item","data","getItemId","primaryField","disabled","id","isSelected","includes","selectionLabel","getValue","sprintf","__","jsx","CheckboxControl","className","__nextHasNoMarginBottom","checked","onChange","filter","_item","itemId"],"sources":["@wordpress/dataviews/src/single-selection-checkbox.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { Field, AnyItem } from './types';\n\ninterface SingleSelectionCheckboxProps< Item extends AnyItem > {\n\tselection: string[];\n\tonSelectionChange: ( selection: Item[] ) => void;\n\titem: Item;\n\tdata: Item[];\n\tgetItemId: ( item: Item ) => string;\n\tprimaryField?: Field< Item >;\n\tdisabled: boolean;\n}\n\nexport default function SingleSelectionCheckbox< Item extends AnyItem >( {\n\tselection,\n\tonSelectionChange,\n\titem,\n\tdata,\n\tgetItemId,\n\tprimaryField,\n\tdisabled,\n}: SingleSelectionCheckboxProps< Item > ) {\n\tconst id = getItemId( item );\n\tconst isSelected = selection.includes( id );\n\tlet selectionLabel;\n\tif ( primaryField?.getValue && item ) {\n\t\t// eslint-disable-next-line @wordpress/valid-sprintf\n\t\tselectionLabel = sprintf(\n\t\t\t/* translators: %s: item title. */\n\t\t\tisSelected ? __( 'Deselect item: %s' ) : __( 'Select item: %s' ),\n\t\t\tprimaryField.getValue( { item } )\n\t\t);\n\t} else {\n\t\tselectionLabel = isSelected\n\t\t\t? __( 'Select a new item' )\n\t\t\t: __( 'Deselect item' );\n\t}\n\treturn (\n\t\t<CheckboxControl\n\t\t\tclassName=\"dataviews-view-table-selection-checkbox\"\n\t\t\t__nextHasNoMarginBottom\n\t\t\taria-label={ selectionLabel }\n\t\t\taria-disabled={ disabled }\n\t\t\tchecked={ isSelected }\n\t\t\tonChange={ () => {\n\t\t\t\tif ( disabled ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! isSelected ) {\n\t\t\t\t\tonSelectionChange(\n\t\t\t\t\t\tdata.filter( ( _item ) => {\n\t\t\t\t\t\t\tconst itemId = getItemId?.( _item );\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\titemId === id || selection.includes( itemId )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tonSelectionChange(\n\t\t\t\t\t\tdata.filter( ( _item ) => {\n\t\t\t\t\t\t\tconst itemId = getItemId?.( _item );\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\titemId !== id && selection.includes( itemId )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAwD,IAAAE,WAAA,GAAAF,OAAA;AAJxD;AACA;AACA;;AAIA;AACA;AACA;;AAae,SAASG,uBAAuBA,CAA0B;EACxEC,SAAS;EACTC,iBAAiB;EACjBC,IAAI;EACJC,IAAI;EACJC,SAAS;EACTC,YAAY;EACZC;AACqC,CAAC,EAAG;EACzC,MAAMC,EAAE,GAAGH,SAAS,CAAEF,IAAK,CAAC;EAC5B,MAAMM,UAAU,GAAGR,SAAS,CAACS,QAAQ,CAAEF,EAAG,CAAC;EAC3C,IAAIG,cAAc;EAClB,IAAKL,YAAY,EAAEM,QAAQ,IAAIT,IAAI,EAAG;IACrC;IACAQ,cAAc,GAAG,IAAAE,aAAO,GACvB;IACAJ,UAAU,GAAG,IAAAK,QAAE,EAAE,mBAAoB,CAAC,GAAG,IAAAA,QAAE,EAAE,iBAAkB,CAAC,EAChER,YAAY,CAACM,QAAQ,CAAE;MAAET;IAAK,CAAE,CACjC,CAAC;EACF,CAAC,MAAM;IACNQ,cAAc,GAAGF,UAAU,GACxB,IAAAK,QAAE,EAAE,mBAAoB,CAAC,GACzB,IAAAA,QAAE,EAAE,eAAgB,CAAC;EACzB;EACA,oBACC,IAAAf,WAAA,CAAAgB,GAAA,EAACjB,WAAA,CAAAkB,eAAe;IACfC,SAAS,EAAC,yCAAyC;IACnDC,uBAAuB;IACvB,cAAaP,cAAgB;IAC7B,iBAAgBJ,QAAU;IAC1BY,OAAO,EAAGV,UAAY;IACtBW,QAAQ,EAAGA,CAAA,KAAM;MAChB,IAAKb,QAAQ,EAAG;QACf;MACD;MAEA,IAAK,CAAEE,UAAU,EAAG;QACnBP,iBAAiB,CAChBE,IAAI,CAACiB,MAAM,CAAIC,KAAK,IAAM;UACzB,MAAMC,MAAM,GAAGlB,SAAS,GAAIiB,KAAM,CAAC;UACnC,OACCC,MAAM,KAAKf,EAAE,IAAIP,SAAS,CAACS,QAAQ,CAAEa,MAAO,CAAC;QAE/C,CAAE,CACH,CAAC;MACF,CAAC,MAAM;QACNrB,iBAAiB,CAChBE,IAAI,CAACiB,MAAM,CAAIC,KAAK,IAAM;UACzB,MAAMC,MAAM,GAAGlB,SAAS,GAAIiB,KAAM,CAAC;UACnC,OACCC,MAAM,KAAKf,EAAE,IAAIP,SAAS,CAACS,QAAQ,CAAEa,MAAO,CAAC;QAE/C,CAAE,CACH,CAAC;MACF;IACD;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
|
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode } from 'react';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode } from 'react';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll';\n\nexport type AnyItem = Record< string, any >;\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport interface Field< Item extends AnyItem > {\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\theader?: string;\n\n\t/**\n\t * Callback used to retrieve the value of the field from the item.\n\t * Defaults to `item[ field.id ]`.\n\t */\n\tgetValue?: ( args: { item: Item } ) => any;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ( args: { item: Item } ) => ReactNode;\n\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | undefined;\n}\n\nexport type NormalizedField< Item extends AnyItem > = Field< Item > &\n\tRequired< Pick< Field< Item >, 'header' | 'getValue' | 'render' > >;\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item extends AnyItem > = Field< Item >[];\n\nexport type Data< Item extends AnyItem > = Item[];\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The hidden fields.\n\t */\n\thiddenFields: string[];\n}\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcolumnFields?: string[];\n\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item extends AnyItem > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n}\n\nexport interface ActionModal< Item extends AnyItem >\n\textends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action has finished.\n\t */\n\tonActionPerformed: ( ( items: Item[] ) => void ) | undefined;\n\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tonActionStart: ( ( items: Item[] ) => void ) | undefined;\n\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionStart,\n\t\tonActionPerformed,\n\t}: {\n\t\titems: Item[];\n\t\tcloseModal?: () => void;\n\t\tonActionStart?: ( items: Item[] ) => void;\n\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t} ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string;\n}\n\nexport interface ActionButton< Item extends AnyItem >\n\textends ActionBase< AnyItem > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: ( items: Item[] ) => void;\n}\n\nexport type Action< Item extends AnyItem > =\n\t| ActionModal< Item >\n\t| ActionButton< Item >;\n\nexport interface ViewBaseProps< Item extends AnyItem > {\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisLoading?: boolean;\n\tonChangeView( view: View ): void;\n\tonSelectionChange: ( items: Item[] ) => void;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tview: View;\n}\n\nexport interface ViewTableProps< Item extends AnyItem >\n\textends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item extends AnyItem >\n\textends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item extends AnyItem >\n\textends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item extends AnyItem > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n"],"mappings":"","ignoreList":[]}
|
package/build/utils.js
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.sanitizeOperators =
|
|
6
|
+
exports.sanitizeOperators = sanitizeOperators;
|
|
7
7
|
var _constants = require("./constants");
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
function sanitizeOperators(field) {
|
|
13
13
|
let operators = field.filterBy?.operators;
|
|
14
14
|
|
|
15
15
|
// Assign default values.
|
|
@@ -17,17 +17,6 @@ const sanitizeOperators = field => {
|
|
|
17
17
|
operators = [_constants.OPERATOR_IS_ANY, _constants.OPERATOR_IS_NONE];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
// Transform legacy in, notIn operators to is, isNot.
|
|
21
|
-
// To be removed in the future.
|
|
22
|
-
if (operators.includes('in')) {
|
|
23
|
-
operators = operators.filter(operator => operator !== 'is');
|
|
24
|
-
operators.push('is');
|
|
25
|
-
}
|
|
26
|
-
if (operators.includes('notIn')) {
|
|
27
|
-
operators = operators.filter(operator => operator !== 'notIn');
|
|
28
|
-
operators.push('isNot');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
20
|
// Make sure only valid operators are used.
|
|
32
21
|
operators = operators.filter(operator => _constants.ALL_OPERATORS.includes(operator));
|
|
33
22
|
|
|
@@ -37,6 +26,5 @@ const sanitizeOperators = field => {
|
|
|
37
26
|
operators = operators.filter(operator => [_constants.OPERATOR_IS, _constants.OPERATOR_IS_NOT].includes(operator));
|
|
38
27
|
}
|
|
39
28
|
return operators;
|
|
40
|
-
}
|
|
41
|
-
exports.sanitizeOperators = sanitizeOperators;
|
|
29
|
+
}
|
|
42
30
|
//# sourceMappingURL=utils.js.map
|
package/build/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_constants","require","sanitizeOperators","field","operators","filterBy","Array","isArray","OPERATOR_IS_ANY","OPERATOR_IS_NONE","
|
|
1
|
+
{"version":3,"names":["_constants","require","sanitizeOperators","field","operators","filterBy","Array","isArray","OPERATOR_IS_ANY","OPERATOR_IS_NONE","filter","operator","ALL_OPERATORS","includes","OPERATOR_IS","OPERATOR_IS_NOT"],"sources":["@wordpress/dataviews/src/utils.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tALL_OPERATORS,\n\tOPERATOR_IS,\n\tOPERATOR_IS_NOT,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n} from './constants';\nimport type { AnyItem, NormalizedField } from './types';\n\nexport function sanitizeOperators< Item extends AnyItem >(\n\tfield: NormalizedField< Item >\n) {\n\tlet operators = field.filterBy?.operators;\n\n\t// Assign default values.\n\tif ( ! operators || ! Array.isArray( operators ) ) {\n\t\toperators = [ OPERATOR_IS_ANY, OPERATOR_IS_NONE ];\n\t}\n\n\t// Make sure only valid operators are used.\n\toperators = operators.filter( ( operator ) =>\n\t\tALL_OPERATORS.includes( operator )\n\t);\n\n\t// Do not allow mixing single & multiselection operators.\n\t// Remove multiselection operators if any of the single selection ones is present.\n\tif (\n\t\toperators.includes( OPERATOR_IS ) ||\n\t\toperators.includes( OPERATOR_IS_NOT )\n\t) {\n\t\toperators = operators.filter( ( operator ) =>\n\t\t\t[ OPERATOR_IS, OPERATOR_IS_NOT ].includes( operator )\n\t\t);\n\t}\n\n\treturn operators;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,UAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAUO,SAASC,iBAAiBA,CAChCC,KAA8B,EAC7B;EACD,IAAIC,SAAS,GAAGD,KAAK,CAACE,QAAQ,EAAED,SAAS;;EAEzC;EACA,IAAK,CAAEA,SAAS,IAAI,CAAEE,KAAK,CAACC,OAAO,CAAEH,SAAU,CAAC,EAAG;IAClDA,SAAS,GAAG,CAAEI,0BAAe,EAAEC,2BAAgB,CAAE;EAClD;;EAEA;EACAL,SAAS,GAAGA,SAAS,CAACM,MAAM,CAAIC,QAAQ,IACvCC,wBAAa,CAACC,QAAQ,CAAEF,QAAS,CAClC,CAAC;;EAED;EACA;EACA,IACCP,SAAS,CAACS,QAAQ,CAAEC,sBAAY,CAAC,IACjCV,SAAS,CAACS,QAAQ,CAAEE,0BAAgB,CAAC,EACpC;IACDX,SAAS,GAAGA,SAAS,CAACM,MAAM,CAAIC,QAAQ,IACvC,CAAEG,sBAAW,EAAEC,0BAAe,CAAE,CAACF,QAAQ,CAAEF,QAAS,CACrD,CAAC;EACF;EAEA,OAAOP,SAAS;AACjB","ignoreList":[]}
|