PluginProbe ʕ •ᴥ•ʔ
Presto Player / 2.3.0
Presto Player v2.3.0
4.3.1 4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / src / admin / blocks / shared / components / EntitySearchDropdown.js
presto-player / src / admin / blocks / shared / components Last commit date
ColorPopup.js 2 years ago EntitySearchDropdown.js 2 years ago LoadSelect.js 5 years ago ProBadge.js 5 years ago SelectMediaDropdown.js 2 years ago UrlSelect.js 2 years ago VideoIcon.js 2 years ago
EntitySearchDropdown.js
155 lines
1 import {
2 Spinner,
3 Button,
4 MenuGroup,
5 MenuItem,
6 Dropdown,
7 } from "@wordpress/components";
8 import { __ } from "@wordpress/i18n";
9 import { SearchControl } from "@wordpress/components";
10 import { css } from "@emotion/core";
11
12 const EntitySearchDropdown = ({
13 options,
14 isLoading,
15 hasMore,
16 search,
17 onSearch,
18 onSelect,
19 onNextPage,
20 onCreate,
21 renderItem = null,
22 ...dropdownProps
23 }) => {
24 const renderContent = () => {
25 if (isLoading && !options.length) return <Spinner />;
26
27 if (!options.length)
28 return (
29 <p
30 css={css`
31 margin-left: 0.5em;
32 `}
33 >
34 {__("None found.", "presto-player")}
35 </p>
36 );
37
38 return (
39 <>
40 {!!onCreate && (
41 <MenuGroup>
42 <MenuItem
43 icon={
44 <svg
45 xmlns="http://www.w3.org/2000/svg"
46 viewBox="0 0 20 20"
47 fill="currentColor"
48 css={css`
49 width: 18px;
50 `}
51 >
52 <path d="M10.75 4.75a.75.75 0 0 0-1.5 0v4.5h-4.5a.75.75 0 0 0 0 1.5h4.5v4.5a.75.75 0 0 0 1.5 0v-4.5h4.5a.75.75 0 0 0 0-1.5h-4.5v-4.5Z" />
53 </svg>
54 }
55 iconPosition="left"
56 onClick={onCreate}
57 >
58 {__("Add New", "presto-player")}
59 </MenuItem>
60 </MenuGroup>
61 )}
62
63 <MenuGroup>
64 {(options || []).map((item) => {
65 if (renderItem) return renderItem({ item, onSelect });
66 return (
67 <MenuItem
68 icon={item?.icon}
69 iconPosition="left"
70 onClick={() => onSelect(item)}
71 {...item}
72 >
73 {item?.title?.raw || "Untitled"}
74 </MenuItem>
75 );
76 })}
77 </MenuGroup>
78
79 {hasMore && options.length && (
80 <div
81 css={css`
82 margin-top: 20px;
83 text-align: center;
84 display: flex;
85 justify-content: center;
86 width: 100%;
87 `}
88 >
89 <Button
90 variant="secondary"
91 size={"small"}
92 onClick={onNextPage}
93 isBusy={isLoading}
94 >
95 {__("Load More", "presto-player")}
96 </Button>
97 </div>
98 )}
99 </>
100 );
101 };
102
103 return (
104 <div
105 class="pp_search_dropdown_container"
106 css={css`
107 width: 100%;
108 position: relative;
109 `}
110 >
111 <Dropdown
112 renderContent={() => (
113 <div
114 css={css`
115 width: 500px;
116 max-width: 100vw;
117 .components-menu-group {
118 padding: 8px;
119 margin-top: 0;
120 margin-bottom: 0;
121 margin-left: -8px;
122 margin-right: -8px;
123 }
124 .components-menu-group + .components-menu-group {
125 margin-top: 0;
126 border-top: 1px solid #ccc;
127 padding: 8px;
128 }
129 .components-menu-group:last-child {
130 margin-bottom: -8px;
131 }
132 .components-menu-group:first-child {
133 margin-top: -8px;
134 }
135 `}
136 >
137 <SearchControl
138 placeholder={__("Search...", "presto-player")}
139 value={search}
140 onChange={onSearch}
141 css={css`
142 padding: 0.5em 0.5em 0em 0.5em;
143 `}
144 />
145 {renderContent()}
146 </div>
147 )}
148 {...dropdownProps}
149 />
150 </div>
151 );
152 };
153
154 export default EntitySearchDropdown;
155