sanity-plugin-iconify 1.0.4 → 1.1.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/package.json +1 -1
- package/src/combobox/iconify-combobox.styles.tsx +9 -1
- package/src/combobox/search-result.tsx +5 -1
- package/dist/index.d.ts +0 -206
- package/dist/index.esm.js +0 -456
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -467
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -13,11 +13,15 @@ export const OptionsWrapper = styled(Box)`
|
|
|
13
13
|
|
|
14
14
|
& [role='listbox'] {
|
|
15
15
|
display: grid;
|
|
16
|
-
grid-template-columns: repeat(
|
|
16
|
+
grid-template-columns: repeat(auto-fill, minmax(min(100%, 2.5rem), 1fr));
|
|
17
17
|
gap: 0.5rem;
|
|
18
18
|
list-style: none;
|
|
19
19
|
margin: 0;
|
|
20
20
|
padding: 0;
|
|
21
|
+
|
|
22
|
+
@media (min-width: 650px) {
|
|
23
|
+
grid-template-columns: repeat(10, minmax(min(100%, 2.5rem), 1fr));
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
& [role='option'] {
|
|
@@ -28,6 +32,10 @@ export const OptionsWrapper = styled(Box)`
|
|
|
28
32
|
aspect-ratio: 1;
|
|
29
33
|
cursor: pointer;
|
|
30
34
|
width: 100%;
|
|
35
|
+
|
|
36
|
+
& > [data-ui='Box'] {
|
|
37
|
+
display: flex;
|
|
38
|
+
}
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
`;
|
|
@@ -35,7 +35,11 @@ export function SearchResults(props: SearchResultsProps) {
|
|
|
35
35
|
<Combobox.Options style={{ opacity: state === 'stale' ? 0.5 : 1 }}>
|
|
36
36
|
{data!.map((icon) => (
|
|
37
37
|
<Combobox.Option key={icon} value={icon}>
|
|
38
|
-
{({ active }) =>
|
|
38
|
+
{({ active }) => (
|
|
39
|
+
<Button padding={3} mode="bleed" selected={active}>
|
|
40
|
+
<Icon icon={icon} width="100%" height="100%" />
|
|
41
|
+
</Button>
|
|
42
|
+
)}
|
|
39
43
|
</Combobox.Option>
|
|
40
44
|
))}
|
|
41
45
|
</Combobox.Options>
|
package/dist/index.d.ts
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { BaseSchemaDefinition } from 'sanity';
|
|
2
|
-
import { IconifyInfo } from '@iconify/types';
|
|
3
|
-
import { Plugin as Plugin_2 } from 'sanity';
|
|
4
|
-
|
|
5
|
-
export { BaseSchemaDefinition };
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Usage in `sanity.config.ts` (or .js)
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { defineConfig } from 'sanity'
|
|
12
|
-
* import { iconify } from 'sanity-plugin-iconify'
|
|
13
|
-
*
|
|
14
|
-
* export default defineConfig({
|
|
15
|
-
* // ...
|
|
16
|
-
* plugins: [iconify()],
|
|
17
|
-
* })
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare const iconify: Plugin_2<void | IconifyPluginConfig>;
|
|
21
|
-
|
|
22
|
-
export declare interface IconifyPluginConfig {
|
|
23
|
-
collections?: IconPrefix[];
|
|
24
|
-
showName?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export declare interface IconifySearchResult {
|
|
28
|
-
icons: string[];
|
|
29
|
-
collections: Record<string, IconifyInfo>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export declare interface IconOptions {
|
|
33
|
-
collections?: IconPrefix[];
|
|
34
|
-
showName?: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export declare type IconPrefix =
|
|
38
|
-
| 'material-symbols'
|
|
39
|
-
| 'ic'
|
|
40
|
-
| 'mdi'
|
|
41
|
-
| 'ph'
|
|
42
|
-
| 'solar'
|
|
43
|
-
| 'tabler'
|
|
44
|
-
| 'ri'
|
|
45
|
-
| 'bi'
|
|
46
|
-
| 'carbon'
|
|
47
|
-
| 'iconamoon'
|
|
48
|
-
| 'ion'
|
|
49
|
-
| 'uil'
|
|
50
|
-
| 'tdesign'
|
|
51
|
-
| 'teenyicons'
|
|
52
|
-
| 'mingcute'
|
|
53
|
-
| 'clarity'
|
|
54
|
-
| 'iconoir'
|
|
55
|
-
| 'majesticons'
|
|
56
|
-
| 'zondicons'
|
|
57
|
-
| 'ant-design'
|
|
58
|
-
| 'bx'
|
|
59
|
-
| 'bxs'
|
|
60
|
-
| 'gg'
|
|
61
|
-
| 'octicon'
|
|
62
|
-
| 'cil'
|
|
63
|
-
| 'lucide'
|
|
64
|
-
| 'basil'
|
|
65
|
-
| 'pixelarticons'
|
|
66
|
-
| 'system-uicons'
|
|
67
|
-
| 'ci'
|
|
68
|
-
| 'akar-icons'
|
|
69
|
-
| 'memory'
|
|
70
|
-
| 'typcn'
|
|
71
|
-
| 'radix-icons'
|
|
72
|
-
| 'ep'
|
|
73
|
-
| 'circum'
|
|
74
|
-
| 'mdi-light'
|
|
75
|
-
| 'fe'
|
|
76
|
-
| 'eos-icons'
|
|
77
|
-
| 'charm'
|
|
78
|
-
| 'prime'
|
|
79
|
-
| 'humbleicons'
|
|
80
|
-
| 'uiw'
|
|
81
|
-
| 'uim'
|
|
82
|
-
| 'uit'
|
|
83
|
-
| 'uis'
|
|
84
|
-
| 'maki'
|
|
85
|
-
| 'gridicons'
|
|
86
|
-
| 'mi'
|
|
87
|
-
| 'quill'
|
|
88
|
-
| 'gala'
|
|
89
|
-
| 'fluent'
|
|
90
|
-
| 'icon-park-outline'
|
|
91
|
-
| 'icon-park-solid'
|
|
92
|
-
| 'icon-park-twotone'
|
|
93
|
-
| 'icon-park'
|
|
94
|
-
| 'vscode-icons'
|
|
95
|
-
| 'jam'
|
|
96
|
-
| 'heroicons'
|
|
97
|
-
| 'codicon'
|
|
98
|
-
| 'pajamas'
|
|
99
|
-
| 'pepicons-pop'
|
|
100
|
-
| 'pepicons-print'
|
|
101
|
-
| 'pepicons-pencil'
|
|
102
|
-
| 'bytesize'
|
|
103
|
-
| 'ei'
|
|
104
|
-
| 'streamline'
|
|
105
|
-
| 'guidance'
|
|
106
|
-
| 'fa6-solid'
|
|
107
|
-
| 'fa6-regular'
|
|
108
|
-
| 'ooui'
|
|
109
|
-
| 'nimbus'
|
|
110
|
-
| 'formkit'
|
|
111
|
-
| 'line-md'
|
|
112
|
-
| 'svg-spinners'
|
|
113
|
-
| 'openmoji'
|
|
114
|
-
| 'twemoji'
|
|
115
|
-
| 'noto'
|
|
116
|
-
| 'fluent-emoji'
|
|
117
|
-
| 'fluent-emoji-flat'
|
|
118
|
-
| 'fluent-emoji-high-contrast'
|
|
119
|
-
| 'noto-v1'
|
|
120
|
-
| 'emojione'
|
|
121
|
-
| 'emojione-monotone'
|
|
122
|
-
| 'emojione-v1'
|
|
123
|
-
| 'fxemoji'
|
|
124
|
-
| 'streamline-emojis'
|
|
125
|
-
| 'bxl'
|
|
126
|
-
| 'logos'
|
|
127
|
-
| 'simple-icons'
|
|
128
|
-
| 'cib'
|
|
129
|
-
| 'fa6-brands'
|
|
130
|
-
| 'nonicons'
|
|
131
|
-
| 'arcticons'
|
|
132
|
-
| 'file-icons'
|
|
133
|
-
| 'devicon'
|
|
134
|
-
| 'devicon-plain'
|
|
135
|
-
| 'skill-icons'
|
|
136
|
-
| 'brandico'
|
|
137
|
-
| 'entypo-social'
|
|
138
|
-
| 'cryptocurrency'
|
|
139
|
-
| 'cryptocurrency-color'
|
|
140
|
-
| 'flag'
|
|
141
|
-
| 'circle-flags'
|
|
142
|
-
| 'flagpack'
|
|
143
|
-
| 'cif'
|
|
144
|
-
| 'gis'
|
|
145
|
-
| 'map'
|
|
146
|
-
| 'geo'
|
|
147
|
-
| 'game-icons'
|
|
148
|
-
| 'fad'
|
|
149
|
-
| 'academicons'
|
|
150
|
-
| 'wi'
|
|
151
|
-
| 'healthicons'
|
|
152
|
-
| 'medical-icon'
|
|
153
|
-
| 'covid'
|
|
154
|
-
| 'la'
|
|
155
|
-
| 'eva'
|
|
156
|
-
| 'dashicons'
|
|
157
|
-
| 'flat-color-icons'
|
|
158
|
-
| 'entypo'
|
|
159
|
-
| 'foundation'
|
|
160
|
-
| 'raphael'
|
|
161
|
-
| 'icons8'
|
|
162
|
-
| 'iwwa'
|
|
163
|
-
| 'heroicons-outline'
|
|
164
|
-
| 'heroicons-solid'
|
|
165
|
-
| 'fa-solid'
|
|
166
|
-
| 'fa-regular'
|
|
167
|
-
| 'fa-brands'
|
|
168
|
-
| 'fa'
|
|
169
|
-
| 'fluent-mdl2'
|
|
170
|
-
| 'fontisto'
|
|
171
|
-
| 'icomoon-free'
|
|
172
|
-
| 'subway'
|
|
173
|
-
| 'oi'
|
|
174
|
-
| 'wpf'
|
|
175
|
-
| 'simple-line-icons'
|
|
176
|
-
| 'et'
|
|
177
|
-
| 'el'
|
|
178
|
-
| 'vaadin'
|
|
179
|
-
| 'grommet-icons'
|
|
180
|
-
| 'whh'
|
|
181
|
-
| 'si-glyph'
|
|
182
|
-
| 'zmdi'
|
|
183
|
-
| 'ls'
|
|
184
|
-
| 'bpmn'
|
|
185
|
-
| 'flat-ui'
|
|
186
|
-
| 'vs'
|
|
187
|
-
| 'topcoat'
|
|
188
|
-
| 'il'
|
|
189
|
-
| 'websymbol'
|
|
190
|
-
| 'fontelico'
|
|
191
|
-
| 'ps'
|
|
192
|
-
| 'feather'
|
|
193
|
-
| 'mono-icons'
|
|
194
|
-
| 'pepicons';
|
|
195
|
-
|
|
196
|
-
export {};
|
|
197
|
-
|
|
198
|
-
declare module 'sanity' {
|
|
199
|
-
interface IconDefinition extends BaseSchemaDefinition {
|
|
200
|
-
type: 'icon';
|
|
201
|
-
options?: IconOptions;
|
|
202
|
-
}
|
|
203
|
-
interface IntrinsicDefinitions {
|
|
204
|
-
icon: IconDefinition;
|
|
205
|
-
}
|
|
206
|
-
}
|
package/dist/index.esm.js
DELETED
|
@@ -1,456 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { unset, set, definePlugin } from 'sanity';
|
|
3
|
-
import { Grid, Box, Card, Text, TextInput, Button, useToast, Popover, useTheme, studioTheme, ThemeProvider, Stack, Flex } from '@sanity/ui';
|
|
4
|
-
import { useState, useCallback, forwardRef, useId, useRef, useEffect, useMemo } from 'react';
|
|
5
|
-
import { Combobox } from '@headlessui/react';
|
|
6
|
-
import { match } from 'ts-pattern';
|
|
7
|
-
import { useQueryClient, useQuery, QueryClient, QueryClientProvider as QueryClientProvider$1 } from '@tanstack/react-query';
|
|
8
|
-
import { useDebounce } from 'use-debounce';
|
|
9
|
-
import styled from 'styled-components';
|
|
10
|
-
import { Icon } from '@iconify/react';
|
|
11
|
-
import { TrashIcon } from '@sanity/icons';
|
|
12
|
-
import { stringToIcon } from '@iconify/utils';
|
|
13
|
-
import { sentenceCase } from 'change-case';
|
|
14
|
-
const BASE_API_URL = "https://api.iconify.design";
|
|
15
|
-
function fetchJson(_ref) {
|
|
16
|
-
let {
|
|
17
|
-
url,
|
|
18
|
-
signal
|
|
19
|
-
} = _ref;
|
|
20
|
-
return fetch(url, {
|
|
21
|
-
signal
|
|
22
|
-
}).then(response => {
|
|
23
|
-
if (!response.ok) {
|
|
24
|
-
throw new Error("Network error: status ".concat(response.status));
|
|
25
|
-
}
|
|
26
|
-
return response.json();
|
|
27
|
-
}).then(result => result, error => {
|
|
28
|
-
if (error instanceof Error) {
|
|
29
|
-
throw error;
|
|
30
|
-
} else {
|
|
31
|
-
console.error("Unknown error: ".concat(error));
|
|
32
|
-
throw new Error("Something went wrong");
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
function useSearch(_ref2) {
|
|
37
|
-
let {
|
|
38
|
-
collections
|
|
39
|
-
} = _ref2;
|
|
40
|
-
const queryClient = useQueryClient();
|
|
41
|
-
const [term, setTerm] = useState("");
|
|
42
|
-
const [debouncedTerm, setDebouncedTerm] = useDebounce(term, 500);
|
|
43
|
-
const updateTerm = useCallback(function (newTerm) {
|
|
44
|
-
let updateImmediately = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
45
|
-
setTerm(newTerm);
|
|
46
|
-
if (updateImmediately) {
|
|
47
|
-
setDebouncedTerm(newTerm);
|
|
48
|
-
}
|
|
49
|
-
}, [setDebouncedTerm]);
|
|
50
|
-
const {
|
|
51
|
-
isInitialLoading,
|
|
52
|
-
isError,
|
|
53
|
-
error,
|
|
54
|
-
data,
|
|
55
|
-
isPreviousData
|
|
56
|
-
} = useQuery({
|
|
57
|
-
queryKey: ["search", collections, debouncedTerm],
|
|
58
|
-
queryFn: async _ref3 => {
|
|
59
|
-
let {
|
|
60
|
-
signal
|
|
61
|
-
} = _ref3;
|
|
62
|
-
var _a;
|
|
63
|
-
const url = new URL("/search", BASE_API_URL);
|
|
64
|
-
url.searchParams.append("query", debouncedTerm);
|
|
65
|
-
url.searchParams.append("limit", "60");
|
|
66
|
-
if (collections) {
|
|
67
|
-
url.searchParams.append("prefixes", collections.join(","));
|
|
68
|
-
}
|
|
69
|
-
const result = debouncedTerm ? await fetchJson({
|
|
70
|
-
url,
|
|
71
|
-
signal
|
|
72
|
-
}) : null;
|
|
73
|
-
if (result) {
|
|
74
|
-
Object.entries(result.collections).forEach(_ref4 => {
|
|
75
|
-
let [prefix, info] = _ref4;
|
|
76
|
-
queryClient.setQueryData(["iconSetInfo", prefix], info);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return (_a = result == null ? void 0 : result.icons) != null ? _a : [];
|
|
80
|
-
},
|
|
81
|
-
enabled: debouncedTerm.length > 0,
|
|
82
|
-
keepPreviousData: debouncedTerm.length > 0,
|
|
83
|
-
staleTime: 5 * 60 * 1e3
|
|
84
|
-
// 5 minutes
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
term,
|
|
89
|
-
setTerm: updateTerm,
|
|
90
|
-
debouncedTerm,
|
|
91
|
-
isInitialLoading,
|
|
92
|
-
isError,
|
|
93
|
-
error,
|
|
94
|
-
data,
|
|
95
|
-
isPreviousData
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function useIconSetInfo(_ref5) {
|
|
99
|
-
let {
|
|
100
|
-
prefix
|
|
101
|
-
} = _ref5;
|
|
102
|
-
return useQuery({
|
|
103
|
-
queryKey: ["iconSetInfo", prefix],
|
|
104
|
-
queryFn: async _ref6 => {
|
|
105
|
-
let {
|
|
106
|
-
signal
|
|
107
|
-
} = _ref6;
|
|
108
|
-
var _a;
|
|
109
|
-
if (!prefix) return null;
|
|
110
|
-
const url = new URL("/collection", BASE_API_URL);
|
|
111
|
-
url.searchParams.append("prefix", prefix);
|
|
112
|
-
url.searchParams.append("info", "true");
|
|
113
|
-
const result = await fetchJson({
|
|
114
|
-
url,
|
|
115
|
-
signal
|
|
116
|
-
});
|
|
117
|
-
return (_a = result == null ? void 0 : result.info) != null ? _a : null;
|
|
118
|
-
},
|
|
119
|
-
staleTime: Infinity
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
var __freeze = Object.freeze;
|
|
123
|
-
var __defProp = Object.defineProperty;
|
|
124
|
-
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", {
|
|
125
|
-
value: __freeze(raw || cooked.slice())
|
|
126
|
-
}));
|
|
127
|
-
var _a, _b;
|
|
128
|
-
const ComboboxWrapper = styled(Grid)(_a || (_a = __template(["\n grid-template-columns: 1fr min-content;\n position: relative;\n"])));
|
|
129
|
-
const OptionsWrapper = styled(Box)(_b || (_b = __template(["\n box-sizing: border-box;\n padding: 0.5rem;\n\n & [role='listbox'] {\n display: grid;\n grid-template-columns: repeat(10, minmax(min(100%, 1rem), 1fr));\n gap: 0.5rem;\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n & [role='option'] {\n display: grid;\n place-items: center;\n\n & button {\n aspect-ratio: 1;\n cursor: pointer;\n width: 100%;\n }\n }\n"])));
|
|
130
|
-
function MessageWrapper(_ref7) {
|
|
131
|
-
let {
|
|
132
|
-
children
|
|
133
|
-
} = _ref7;
|
|
134
|
-
return /* @__PURE__ */jsx(Card, {
|
|
135
|
-
padding: 4,
|
|
136
|
-
children: /* @__PURE__ */jsx(Text, {
|
|
137
|
-
align: "center",
|
|
138
|
-
muted: true,
|
|
139
|
-
children
|
|
140
|
-
})
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
const SearchInput = forwardRef((props, ref) => {
|
|
144
|
-
const {
|
|
145
|
-
term,
|
|
146
|
-
selectedIcon,
|
|
147
|
-
onChange
|
|
148
|
-
} = props;
|
|
149
|
-
return /* @__PURE__ */jsx(Combobox.Input, {
|
|
150
|
-
as: TextInput,
|
|
151
|
-
ref,
|
|
152
|
-
inputMode: "search",
|
|
153
|
-
value: term,
|
|
154
|
-
onChange,
|
|
155
|
-
icon: selectedIcon ? /* @__PURE__ */jsx(Icon, {
|
|
156
|
-
icon: selectedIcon
|
|
157
|
-
}) : null,
|
|
158
|
-
placeholder: selectedIcon ? "Search and replace selected icon..." : "Search for an icon..."
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
SearchInput.displayName = "SearchInput";
|
|
162
|
-
function SearchResults(props) {
|
|
163
|
-
const {
|
|
164
|
-
state,
|
|
165
|
-
data
|
|
166
|
-
} = props;
|
|
167
|
-
if (state === "initial") {
|
|
168
|
-
return /* @__PURE__ */jsx(MessageWrapper, {
|
|
169
|
-
children: "Search for icons"
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
if (state === "loading") {
|
|
173
|
-
return /* @__PURE__ */jsx(MessageWrapper, {
|
|
174
|
-
children: "Searching..."
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
if (state === "error") {
|
|
178
|
-
return /* @__PURE__ */jsx(MessageWrapper, {
|
|
179
|
-
children: "Something went wrong..."
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
if (state === "empty") {
|
|
183
|
-
return /* @__PURE__ */jsx(MessageWrapper, {
|
|
184
|
-
children: "No icons found"
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
return /* @__PURE__ */jsx(Combobox.Options, {
|
|
188
|
-
style: {
|
|
189
|
-
opacity: state === "stale" ? 0.5 : 1
|
|
190
|
-
},
|
|
191
|
-
children: data.map(icon => /* @__PURE__ */jsx(Combobox.Option, {
|
|
192
|
-
value: icon,
|
|
193
|
-
children: _ref8 => {
|
|
194
|
-
let {
|
|
195
|
-
active
|
|
196
|
-
} = _ref8;
|
|
197
|
-
return /* @__PURE__ */jsx(Button, {
|
|
198
|
-
mode: "bleed",
|
|
199
|
-
icon: /* @__PURE__ */jsx(Icon, {
|
|
200
|
-
icon
|
|
201
|
-
}),
|
|
202
|
-
selected: active
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}, icon))
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
function UnsetButton(props) {
|
|
209
|
-
const {
|
|
210
|
-
onUnset
|
|
211
|
-
} = props;
|
|
212
|
-
return /* @__PURE__ */jsx(Card, {
|
|
213
|
-
border: true,
|
|
214
|
-
borderLeft: false,
|
|
215
|
-
padding: 1,
|
|
216
|
-
display: "flex",
|
|
217
|
-
children: /* @__PURE__ */jsx(Button, {
|
|
218
|
-
icon: /* @__PURE__ */jsx(TrashIcon, {}),
|
|
219
|
-
onClick: onUnset,
|
|
220
|
-
mode: "bleed",
|
|
221
|
-
fontSize: 1,
|
|
222
|
-
padding: 2
|
|
223
|
-
})
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
function IconifyCombobox(props) {
|
|
227
|
-
const {
|
|
228
|
-
selectedIcon,
|
|
229
|
-
onSelect: pushSelection,
|
|
230
|
-
collections
|
|
231
|
-
} = props;
|
|
232
|
-
const id = useId();
|
|
233
|
-
const toast = useToast();
|
|
234
|
-
const inputRef = useRef(null);
|
|
235
|
-
const {
|
|
236
|
-
term,
|
|
237
|
-
setTerm,
|
|
238
|
-
debouncedTerm,
|
|
239
|
-
isInitialLoading,
|
|
240
|
-
isError,
|
|
241
|
-
error,
|
|
242
|
-
data,
|
|
243
|
-
isPreviousData
|
|
244
|
-
} = useSearch({
|
|
245
|
-
collections
|
|
246
|
-
});
|
|
247
|
-
const handleTermChange = useCallback(event => setTerm(event.target.value), [setTerm]);
|
|
248
|
-
const handleSelect = useCallback(icon => {
|
|
249
|
-
pushSelection(icon);
|
|
250
|
-
setTerm("", true);
|
|
251
|
-
}, [pushSelection, setTerm]);
|
|
252
|
-
const handleUnset = useCallback(() => handleSelect(""), [handleSelect]);
|
|
253
|
-
useEffect(() => {
|
|
254
|
-
if (isError) {
|
|
255
|
-
console.error("Iconify input error:", error);
|
|
256
|
-
toast.push({
|
|
257
|
-
id,
|
|
258
|
-
status: "error",
|
|
259
|
-
title: "Iconify input error",
|
|
260
|
-
description: error == null ? void 0 : error.message
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
}, [error, id, isError, toast]);
|
|
264
|
-
return /* @__PURE__ */jsxs(ComboboxWrapper, {
|
|
265
|
-
children: [/* @__PURE__ */jsx(Combobox, {
|
|
266
|
-
onChange: handleSelect,
|
|
267
|
-
children: _ref9 => {
|
|
268
|
-
let {
|
|
269
|
-
open
|
|
270
|
-
} = _ref9;
|
|
271
|
-
return /* @__PURE__ */jsxs(Fragment, {
|
|
272
|
-
children: [/* @__PURE__ */jsx(SearchInput, {
|
|
273
|
-
ref: inputRef,
|
|
274
|
-
term,
|
|
275
|
-
selectedIcon,
|
|
276
|
-
onChange: handleTermChange
|
|
277
|
-
}), /* @__PURE__ */jsx(Popover, {
|
|
278
|
-
open,
|
|
279
|
-
placement: "bottom",
|
|
280
|
-
arrow: false,
|
|
281
|
-
matchReferenceWidth: true,
|
|
282
|
-
portal: true,
|
|
283
|
-
constrainSize: true,
|
|
284
|
-
referenceElement: inputRef.current,
|
|
285
|
-
content: /* @__PURE__ */jsx(OptionsWrapper, {
|
|
286
|
-
children: /* @__PURE__ */jsx(SearchResults, {
|
|
287
|
-
state: match(true).returnType().with(isInitialLoading, () => "loading").with(!debouncedTerm, () => "initial").with(isError, () => "error").with(!data || data.length === 0, () => "empty").with(isPreviousData, () => "stale").otherwise(() => "data"),
|
|
288
|
-
data
|
|
289
|
-
})
|
|
290
|
-
})
|
|
291
|
-
})]
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
}), selectedIcon ? /* @__PURE__ */jsx(UnsetButton, {
|
|
295
|
-
onUnset: handleUnset
|
|
296
|
-
}) : null]
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
const queryClient = new QueryClient();
|
|
300
|
-
function QueryClientProvider(props) {
|
|
301
|
-
return /* @__PURE__ */jsx(QueryClientProvider$1, {
|
|
302
|
-
client: queryClient,
|
|
303
|
-
children: props.children
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
function usePrettyIconName(props) {
|
|
307
|
-
var _a, _b;
|
|
308
|
-
const {
|
|
309
|
-
name
|
|
310
|
-
} = props;
|
|
311
|
-
const iconMeta = useMemo(() => {
|
|
312
|
-
var _a2;
|
|
313
|
-
return (_a2 = props.iconMeta) != null ? _a2 : name ? stringToIcon(name) : null;
|
|
314
|
-
}, [name, props.iconMeta]);
|
|
315
|
-
const iconSetInfo = useIconSetInfo({
|
|
316
|
-
prefix: (_a = iconMeta == null ? void 0 : iconMeta.prefix) != null ? _a : null
|
|
317
|
-
});
|
|
318
|
-
return useMemo(() => {
|
|
319
|
-
var _a2, _b2;
|
|
320
|
-
return iconMeta ? {
|
|
321
|
-
name: sentenceCase(iconMeta.name),
|
|
322
|
-
collection: (_b2 = (_a2 = iconSetInfo.data) == null ? void 0 : _a2.name) != null ? _b2 : iconMeta.prefix
|
|
323
|
-
} : null;
|
|
324
|
-
}, [iconMeta, (_b = iconSetInfo.data) == null ? void 0 : _b.name]);
|
|
325
|
-
}
|
|
326
|
-
function IconifyInput(props) {
|
|
327
|
-
var _a, _b, _c, _d, _e;
|
|
328
|
-
const {
|
|
329
|
-
config,
|
|
330
|
-
value,
|
|
331
|
-
onChange: pushChange,
|
|
332
|
-
schemaType
|
|
333
|
-
} = props;
|
|
334
|
-
const selectedIcon = (_a = value == null ? void 0 : value.name) != null ? _a : null;
|
|
335
|
-
const options = schemaType.options;
|
|
336
|
-
const collections = !!((_b = options == null ? void 0 : options.collections) == null ? void 0 : _b.length) && options.collections || !!((_c = config == null ? void 0 : config.collections) == null ? void 0 : _c.length) && config.collections || null;
|
|
337
|
-
const showName = (_e = (_d = options == null ? void 0 : options.showName) != null ? _d : config == null ? void 0 : config.showName) != null ? _e : false;
|
|
338
|
-
const parentTheme = useTheme();
|
|
339
|
-
const theme = useMemo(() => parentTheme ? {
|
|
340
|
-
...parentTheme.sanity,
|
|
341
|
-
color: studioTheme.color
|
|
342
|
-
} : studioTheme, [parentTheme]);
|
|
343
|
-
const handleSelect = useCallback(icon => {
|
|
344
|
-
pushChange(icon === "" ? unset() : set(icon, ["name"]));
|
|
345
|
-
}, [pushChange]);
|
|
346
|
-
return /* @__PURE__ */jsx(QueryClientProvider, {
|
|
347
|
-
children: /* @__PURE__ */jsx(ThemeProvider, {
|
|
348
|
-
theme,
|
|
349
|
-
children: /* @__PURE__ */jsxs(Stack, {
|
|
350
|
-
space: 2,
|
|
351
|
-
children: [/* @__PURE__ */jsx(IconifyCombobox, {
|
|
352
|
-
selectedIcon,
|
|
353
|
-
onSelect: handleSelect,
|
|
354
|
-
collections
|
|
355
|
-
}), showName && selectedIcon ? /* @__PURE__ */jsx(IconifyNameDisplay, {
|
|
356
|
-
name: selectedIcon
|
|
357
|
-
}) : null]
|
|
358
|
-
})
|
|
359
|
-
})
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
function IconifyNameDisplay(props) {
|
|
363
|
-
var _a;
|
|
364
|
-
const {
|
|
365
|
-
name
|
|
366
|
-
} = props;
|
|
367
|
-
const prettyName = usePrettyIconName({
|
|
368
|
-
name
|
|
369
|
-
});
|
|
370
|
-
return /* @__PURE__ */jsxs(Flex, {
|
|
371
|
-
gap: 1,
|
|
372
|
-
children: [/* @__PURE__ */jsx(Text, {
|
|
373
|
-
size: 1,
|
|
374
|
-
muted: true,
|
|
375
|
-
children: "Selected:"
|
|
376
|
-
}), /* @__PURE__ */jsx(Text, {
|
|
377
|
-
size: 1,
|
|
378
|
-
weight: "semibold",
|
|
379
|
-
children: (_a = prettyName == null ? void 0 : prettyName.name) != null ? _a : name
|
|
380
|
-
}), (prettyName == null ? void 0 : prettyName.collection) && /* @__PURE__ */jsxs(Text, {
|
|
381
|
-
size: 1,
|
|
382
|
-
muted: true,
|
|
383
|
-
style: {
|
|
384
|
-
fontStyle: "italic"
|
|
385
|
-
},
|
|
386
|
-
children: ["by ", prettyName == null ? void 0 : prettyName.collection]
|
|
387
|
-
})]
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
function IconifyPreview(props) {
|
|
391
|
-
const {
|
|
392
|
-
title
|
|
393
|
-
} = props;
|
|
394
|
-
const iconName = typeof props.title === "string" ? stringToIcon(props.title) : null;
|
|
395
|
-
if (typeof title === "string" && iconName) {
|
|
396
|
-
return /* @__PURE__ */jsx(QueryClientProvider, {
|
|
397
|
-
children: /* @__PURE__ */jsx(IconifyPreviewInner, {
|
|
398
|
-
...props,
|
|
399
|
-
iconName: title,
|
|
400
|
-
iconMeta: iconName
|
|
401
|
-
})
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
return props.renderDefault(props);
|
|
405
|
-
}
|
|
406
|
-
function IconifyPreviewInner(props) {
|
|
407
|
-
var _a;
|
|
408
|
-
const {
|
|
409
|
-
iconMeta,
|
|
410
|
-
iconName,
|
|
411
|
-
...previewProps
|
|
412
|
-
} = props;
|
|
413
|
-
const prettyName = usePrettyIconName({
|
|
414
|
-
iconMeta
|
|
415
|
-
});
|
|
416
|
-
return props.renderDefault({
|
|
417
|
-
...previewProps,
|
|
418
|
-
media: /* @__PURE__ */jsx(Icon, {
|
|
419
|
-
icon: iconName
|
|
420
|
-
}),
|
|
421
|
-
title: (_a = prettyName == null ? void 0 : prettyName.name) != null ? _a : iconName,
|
|
422
|
-
subtitle: prettyName == null ? void 0 : prettyName.collection
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
const iconify = definePlugin(function () {
|
|
426
|
-
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
427
|
-
return {
|
|
428
|
-
name: "sanity-plugin-iconify",
|
|
429
|
-
schema: {
|
|
430
|
-
types: [{
|
|
431
|
-
name: "icon",
|
|
432
|
-
title: "Icon",
|
|
433
|
-
type: "object",
|
|
434
|
-
fields: [{
|
|
435
|
-
name: "name",
|
|
436
|
-
title: "Name",
|
|
437
|
-
type: "string"
|
|
438
|
-
}],
|
|
439
|
-
components: {
|
|
440
|
-
input: props => /* @__PURE__ */jsx(IconifyInput, {
|
|
441
|
-
...props,
|
|
442
|
-
config
|
|
443
|
-
}),
|
|
444
|
-
preview: IconifyPreview,
|
|
445
|
-
// This makes sure the input component is not indented
|
|
446
|
-
field: props => props.renderDefault({
|
|
447
|
-
...props,
|
|
448
|
-
level: 0
|
|
449
|
-
})
|
|
450
|
-
}
|
|
451
|
-
}]
|
|
452
|
-
}
|
|
453
|
-
};
|
|
454
|
-
});
|
|
455
|
-
export { iconify };
|
|
456
|
-
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/lib/api.ts","../src/combobox/iconify-combobox.styles.tsx","../src/combobox/search-input.tsx","../src/combobox/search-result.tsx","../src/combobox/unset-button.tsx","../src/combobox/iconify-combobox.tsx","../src/lib/query-client.tsx","../src/lib/use-pretty-icon-name.ts","../src/iconify-input.tsx","../src/iconify-preview.tsx","../src/iconify-plugin.tsx"],"sourcesContent":["import { IconifyInfo } from '@iconify/types';\nimport { useQuery, useQueryClient } from '@tanstack/react-query';\nimport { IconifySearchResult } from './types';\nimport { useCallback, useState } from 'react';\nimport { useDebounce } from 'use-debounce';\n\nconst BASE_API_URL = 'https://api.iconify.design';\n\nfunction fetchJson<T>({ url, signal }: { url: string | URL; signal?: AbortSignal }): Promise<T> {\n return fetch(url, { signal })\n .then((response) => {\n if (!response.ok) {\n throw new Error(`Network error: status ${response.status}`);\n }\n\n return response.json();\n })\n .then(\n (result) => result as T,\n (error) => {\n if (error instanceof Error) {\n throw error;\n } else {\n console.error(`Unknown error: ${error}`);\n throw new Error('Something went wrong');\n }\n },\n );\n}\n\nexport function useSearch({ collections }: { collections: string[] | null }) {\n const queryClient = useQueryClient();\n const [term, setTerm] = useState('');\n const [debouncedTerm, setDebouncedTerm] = useDebounce(term, 500);\n\n const updateTerm = useCallback(\n (newTerm: string, updateImmediately = false) => {\n setTerm(newTerm);\n\n if (updateImmediately) {\n setDebouncedTerm(newTerm);\n }\n },\n [setDebouncedTerm],\n );\n\n const { isInitialLoading, isError, error, data, isPreviousData } = useQuery<string[], Error>({\n queryKey: ['search', collections, debouncedTerm],\n queryFn: async ({ signal }) => {\n const url = new URL(`/search`, BASE_API_URL);\n\n url.searchParams.append('query', debouncedTerm);\n url.searchParams.append('limit', '60');\n\n if (collections) {\n url.searchParams.append('prefixes', collections.join(','));\n }\n\n const result = debouncedTerm ? await fetchJson<IconifySearchResult>({ url, signal }) : null;\n\n if (result) {\n // Cache the info for each collection\n Object.entries(result.collections).forEach(([prefix, info]) => {\n queryClient.setQueryData<IconifyInfo>(['iconSetInfo', prefix], info);\n });\n }\n\n return result?.icons ?? [];\n },\n enabled: debouncedTerm.length > 0,\n keepPreviousData: debouncedTerm.length > 0,\n staleTime: 5 * 60 * 1000, // 5 minutes\n });\n\n return {\n term,\n setTerm: updateTerm,\n debouncedTerm,\n isInitialLoading,\n isError,\n error,\n data,\n isPreviousData,\n };\n}\n\nexport function useIconSetInfo({ prefix }: { prefix?: string | null }) {\n return useQuery<IconifyInfo | null, Error>({\n queryKey: ['iconSetInfo', prefix],\n queryFn: async ({ signal }) => {\n if (!prefix) return null;\n\n const url = new URL('/collection', BASE_API_URL);\n\n url.searchParams.append('prefix', prefix);\n url.searchParams.append('info', 'true');\n\n const result = await fetchJson<{ info: IconifyInfo }>({ url, signal });\n\n return result?.info ?? null;\n },\n staleTime: Infinity,\n });\n}\n","import { Box, Card, Grid, Text } from '@sanity/ui';\nimport { ReactNode } from 'react';\nimport styled from 'styled-components';\n\nexport const ComboboxWrapper = styled(Grid)`\n grid-template-columns: 1fr min-content;\n position: relative;\n`;\n\nexport const OptionsWrapper = styled(Box)`\n box-sizing: border-box;\n padding: 0.5rem;\n\n & [role='listbox'] {\n display: grid;\n grid-template-columns: repeat(10, minmax(min(100%, 1rem), 1fr));\n gap: 0.5rem;\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n & [role='option'] {\n display: grid;\n place-items: center;\n\n & button {\n aspect-ratio: 1;\n cursor: pointer;\n width: 100%;\n }\n }\n`;\n\nexport function MessageWrapper({ children }: { children: ReactNode }) {\n return (\n <Card padding={4}>\n <Text align=\"center\" muted>\n {children}\n </Text>\n </Card>\n );\n}\n","import { Combobox } from '@headlessui/react';\nimport { Icon } from '@iconify/react';\nimport { TextInput } from '@sanity/ui';\nimport { ChangeEventHandler, forwardRef } from 'react';\n\n// ------------ //\n// SEARCH INPUT //\n// ------------ //\n\ninterface SearchInputProps {\n term: string;\n selectedIcon: string | null;\n onChange: ChangeEventHandler<HTMLInputElement>;\n}\n\nexport const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>((props, ref) => {\n const { term, selectedIcon, onChange } = props;\n\n return (\n <Combobox.Input\n as={TextInput}\n ref={ref}\n inputMode=\"search\"\n value={term}\n onChange={onChange}\n icon={selectedIcon ? <Icon icon={selectedIcon} /> : null}\n placeholder={selectedIcon ? 'Search and replace selected icon...' : 'Search for an icon...'}\n />\n );\n});\n\nSearchInput.displayName = 'SearchInput';\n","import { Combobox } from '@headlessui/react';\nimport { Icon } from '@iconify/react';\nimport { Button } from '@sanity/ui';\nimport { MessageWrapper } from './iconify-combobox.styles';\n\n// -------------- //\n// SEARCH RESULTS //\n// -------------- //\n\nexport interface SearchResultsProps {\n state: 'initial' | 'loading' | 'error' | 'empty' | 'data' | 'stale';\n data?: string[];\n}\n\nexport function SearchResults(props: SearchResultsProps) {\n const { state, data } = props;\n\n if (state === 'initial') {\n return <MessageWrapper>Search for icons</MessageWrapper>;\n }\n\n if (state === 'loading') {\n return <MessageWrapper>Searching...</MessageWrapper>;\n }\n\n if (state === 'error') {\n return <MessageWrapper>Something went wrong...</MessageWrapper>;\n }\n\n if (state === 'empty') {\n return <MessageWrapper>No icons found</MessageWrapper>;\n }\n\n return (\n <Combobox.Options style={{ opacity: state === 'stale' ? 0.5 : 1 }}>\n {data!.map((icon) => (\n <Combobox.Option key={icon} value={icon}>\n {({ active }) => <Button mode=\"bleed\" icon={<Icon icon={icon} />} selected={active} />}\n </Combobox.Option>\n ))}\n </Combobox.Options>\n );\n}\n","import { TrashIcon } from '@sanity/icons';\nimport { Button, Card } from '@sanity/ui';\n\n// ------------ //\n// UNSET BUTTON //\n// ------------ //\n\ninterface UnsetButtonProps {\n onUnset: () => void;\n}\n\nexport function UnsetButton(props: UnsetButtonProps) {\n const { onUnset } = props;\n\n return (\n <Card border borderLeft={false} padding={1} display=\"flex\">\n <Button icon={<TrashIcon />} onClick={onUnset} mode=\"bleed\" fontSize={1} padding={2} />\n </Card>\n );\n}\n","import { Combobox } from '@headlessui/react';\nimport { Popover, useToast } from '@sanity/ui';\nimport { ChangeEventHandler, useCallback, useEffect, useId, useRef } from 'react';\nimport { match } from 'ts-pattern';\nimport { useSearch } from '../lib/api';\nimport { ComboboxWrapper, OptionsWrapper } from './iconify-combobox.styles';\nimport { SearchInput } from './search-input';\nimport { SearchResults, SearchResultsProps } from './search-result';\nimport { UnsetButton } from './unset-button';\n\nexport interface IconifyComboboxProps {\n selectedIcon: string | null;\n onSelect: (newValue: string) => void;\n collections: string[] | null;\n}\n\nexport function IconifyCombobox(props: IconifyComboboxProps) {\n const { selectedIcon, onSelect: pushSelection, collections } = props;\n\n const id = useId();\n const toast = useToast();\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { term, setTerm, debouncedTerm, isInitialLoading, isError, error, data, isPreviousData } =\n useSearch({\n collections,\n });\n\n const handleTermChange: ChangeEventHandler<HTMLInputElement> = useCallback(\n (event) => setTerm(event.target.value),\n [setTerm],\n );\n\n const handleSelect = useCallback(\n (icon: string) => {\n pushSelection(icon);\n setTerm('', true);\n },\n [pushSelection, setTerm],\n );\n\n const handleUnset = useCallback(() => handleSelect(''), [handleSelect]);\n\n useEffect(() => {\n if (isError) {\n console.error('Iconify input error:', error);\n\n toast.push({\n id,\n status: 'error',\n title: 'Iconify input error',\n description: error?.message,\n });\n }\n }, [error, id, isError, toast]);\n\n return (\n <ComboboxWrapper>\n <Combobox onChange={handleSelect}>\n {({ open }) => (\n <>\n <SearchInput\n ref={inputRef}\n term={term}\n selectedIcon={selectedIcon}\n onChange={handleTermChange}\n />\n\n <Popover\n open={open}\n placement=\"bottom\"\n arrow={false}\n matchReferenceWidth\n portal\n constrainSize\n referenceElement={inputRef.current}\n content={\n <OptionsWrapper>\n <SearchResults\n state={match<boolean>(true)\n .returnType<SearchResultsProps['state']>()\n .with(isInitialLoading, () => 'loading')\n .with(!debouncedTerm, () => 'initial')\n .with(isError, () => 'error')\n .with(!data || data.length === 0, () => 'empty')\n .with(isPreviousData, () => 'stale')\n .otherwise(() => 'data')}\n data={data}\n />\n </OptionsWrapper>\n }\n />\n </>\n )}\n </Combobox>\n\n {selectedIcon ? <UnsetButton onUnset={handleUnset} /> : null}\n </ComboboxWrapper>\n );\n}\n","import {\n QueryClient,\n QueryClientProvider as ReactQueryClientProvider,\n} from '@tanstack/react-query';\nimport { ReactNode } from 'react';\n\nexport const queryClient = new QueryClient();\n\nexport function QueryClientProvider(props: { children: ReactNode }) {\n return <ReactQueryClientProvider client={queryClient}>{props.children}</ReactQueryClientProvider>;\n}\n","import { IconifyIconName, stringToIcon } from '@iconify/utils';\nimport { sentenceCase } from 'change-case';\nimport { useMemo } from 'react';\nimport { useIconSetInfo } from './api';\n\ninterface UsePrettyIconNameProps {\n name?: string | null;\n iconMeta?: IconifyIconName | null;\n}\n\nexport function usePrettyIconName(props: UsePrettyIconNameProps) {\n const { name } = props;\n const iconMeta = useMemo(\n () => props.iconMeta ?? (name ? stringToIcon(name) : null),\n [name, props.iconMeta],\n );\n const iconSetInfo = useIconSetInfo({ prefix: iconMeta?.prefix ?? null });\n\n return useMemo(\n () =>\n iconMeta\n ? {\n name: sentenceCase(iconMeta.name),\n collection: iconSetInfo.data?.name ?? iconMeta.prefix,\n }\n : null,\n [iconMeta, iconSetInfo.data?.name],\n );\n}\n","import { Flex, RootTheme, Stack, Text, ThemeProvider, studioTheme, useTheme } from '@sanity/ui';\nimport { useCallback, useMemo } from 'react';\nimport { ObjectInputProps, set, unset } from 'sanity';\nimport { IconifyCombobox } from './combobox';\nimport { QueryClientProvider } from './lib/query-client';\nimport { IconOptions, IconifyPluginConfig } from './lib/types';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\n\n// -------------- //\n// ICONIFY INPUT //\n// -------------- //\n\ninterface IconifyInputProps extends ObjectInputProps {\n config: IconifyPluginConfig;\n}\n\nexport function IconifyInput(props: IconifyInputProps) {\n const { config, value, onChange: pushChange, schemaType } = props;\n\n const selectedIcon: string | null = value?.name ?? null;\n\n const options: IconOptions = schemaType.options;\n const collections =\n (!!options?.collections?.length && options.collections) ||\n (!!config?.collections?.length && config.collections) ||\n null;\n const showName = options?.showName ?? config?.showName ?? false;\n\n const parentTheme = useTheme();\n const theme: RootTheme = useMemo(\n () => (parentTheme ? { ...parentTheme.sanity, color: studioTheme.color } : studioTheme),\n [parentTheme],\n );\n\n const handleSelect = useCallback(\n (icon: string) => {\n pushChange(icon === '' ? unset() : set(icon, ['name']));\n },\n [pushChange],\n );\n\n return (\n <QueryClientProvider>\n <ThemeProvider theme={theme}>\n <Stack space={2}>\n <IconifyCombobox\n selectedIcon={selectedIcon}\n onSelect={handleSelect}\n collections={collections}\n />\n\n {showName && selectedIcon ? <IconifyNameDisplay name={selectedIcon} /> : null}\n </Stack>\n </ThemeProvider>\n </QueryClientProvider>\n );\n}\n\ninterface IconifyNameDisplayProps {\n name?: string | null;\n}\n\nfunction IconifyNameDisplay(props: IconifyNameDisplayProps) {\n const { name } = props;\n const prettyName = usePrettyIconName({ name });\n\n return (\n <Flex gap={1}>\n <Text size={1} muted>\n Selected:\n </Text>\n\n <Text size={1} weight=\"semibold\">\n {prettyName?.name ?? name}\n </Text>\n\n {prettyName?.collection && (\n <Text size={1} muted style={{ fontStyle: 'italic' }}>\n by {prettyName?.collection}\n </Text>\n )}\n </Flex>\n );\n}\n","import { Icon } from '@iconify/react';\nimport { PreviewProps } from 'sanity';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\nimport { IconifyIconName, stringToIcon } from '@iconify/utils';\nimport { QueryClientProvider } from './lib/query-client';\n\n// --------------- //\n// ICONIFY PREVIEW //\n// --------------- //\n\nexport function IconifyPreview(props: PreviewProps) {\n const { title } = props;\n const iconName = typeof props.title === 'string' ? stringToIcon(props.title) : null;\n\n // We check this double to avoid the TS error\n if (typeof title === 'string' && iconName) {\n return (\n <QueryClientProvider>\n <IconifyPreviewInner {...props} iconName={title} iconMeta={iconName} />\n </QueryClientProvider>\n );\n }\n\n return props.renderDefault(props);\n}\n\n// --------------------- //\n// ICONIFY PREVIEW INNER //\n// --------------------- //\n\ninterface IconifyPreviewInnerProps extends PreviewProps {\n iconName: string;\n iconMeta: IconifyIconName;\n}\n\nfunction IconifyPreviewInner(props: IconifyPreviewInnerProps) {\n const { iconMeta, iconName, ...previewProps } = props;\n const prettyName = usePrettyIconName({ iconMeta });\n\n return props.renderDefault({\n ...previewProps,\n media: <Icon icon={iconName} />,\n title: prettyName?.name ?? iconName,\n subtitle: prettyName?.collection,\n });\n}\n","import { FieldProps, ObjectInputProps, definePlugin } from 'sanity';\nimport { IconifyInput } from './iconify-input';\nimport { IconifyPreview } from './iconify-preview';\nimport { IconifyPluginConfig } from './lib/types';\n\n/**\n * Usage in `sanity.config.ts` (or .js)\n *\n * ```ts\n * import { defineConfig } from 'sanity'\n * import { iconify } from 'sanity-plugin-iconify'\n *\n * export default defineConfig({\n * // ...\n * plugins: [iconify()],\n * })\n * ```\n */\nexport const iconify = definePlugin<IconifyPluginConfig | void>((config = {}) => {\n return {\n name: 'sanity-plugin-iconify',\n schema: {\n types: [\n {\n name: 'icon',\n title: 'Icon',\n type: 'object',\n fields: [\n {\n name: 'name',\n title: 'Name',\n type: 'string',\n },\n ],\n components: {\n input: (props: ObjectInputProps) => <IconifyInput {...props} config={config!} />,\n preview: IconifyPreview,\n\n // This makes sure the input component is not indented\n field: (props: FieldProps) => props.renderDefault({ ...props, level: 0 }),\n },\n },\n ],\n },\n };\n});\n"],"names":["BASE_API_URL","fetchJson","_ref","url","signal","fetch","then","response","ok","Error","concat","status","json","result","error","console","useSearch","_ref2","collections","queryClient","useQueryClient","term","setTerm","useState","debouncedTerm","setDebouncedTerm","useDebounce","updateTerm","useCallback","newTerm","updateImmediately","arguments","length","undefined","isInitialLoading","isError","data","isPreviousData","useQuery","queryKey","queryFn","_ref3","_a","URL","searchParams","append","join","Object","entries","forEach","_ref4","prefix","info","setQueryData","icons","enabled","keepPreviousData","staleTime","useIconSetInfo","_ref5","_ref6","Infinity","_b","ComboboxWrapper","styled","Grid","__template","OptionsWrapper","Box","MessageWrapper","_ref7","children","jsx","Card","padding","Text","align","muted","SearchInput","forwardRef","props","ref","selectedIcon","onChange","Combobox","Input","as","TextInput","inputMode","value","icon","Icon","placeholder","displayName","SearchResults","state","Options","style","opacity","map","Option","active","Button","mode","selected","UnsetButton","onUnset","border","borderLeft","display","TrashIcon","onClick","fontSize","IconifyCombobox","onSelect","pushSelection","id","useId","toast","useToast","inputRef","useRef","handleTermChange","event","target","handleSelect","handleUnset","useEffect","push","title","description","message","open","jsxs","Fragment","Popover","placement","arrow","matchReferenceWidth","portal","constrainSize","referenceElement","current","content","match","returnType","with","otherwise","QueryClient","QueryClientProvider","ReactQueryClientProvider","client","usePrettyIconName","name","iconMeta","useMemo","stringToIcon","iconSetInfo","sentenceCase","collection","IconifyInput","_c","_d","_e","config","pushChange","schemaType","options","showName","parentTheme","useTheme","theme","sanity","color","studioTheme","unset","set","ThemeProvider","Stack","space","IconifyNameDisplay","prettyName","Flex","gap","size","weight","fontStyle","IconifyPreview","iconName","IconifyPreviewInner","renderDefault","previewProps","media","subtitle","iconify","definePlugin","schema","types","type","fields","components","input","preview","field","level"],"mappings":";;;;;;;;;;;;;AAMA,MAAMA,YAAe,GAAA,4BAAA;AAErB,SAASC,SAAaA,CAAAC,IAAA,EAA0E;EAAA,IAA1E;IAAEC,GAAK;IAAAC;GAAmE,GAAAF,IAAA;EACvF,OAAAG,KAAA,CAAMF,KAAK;IAAEC;EAAQ,CAAA,CACzB,CAAAE,IAAA,CAAMC,QAAa,IAAA;IACd,IAAA,CAACA,SAASC,EAAI,EAAA;MAChB,MAAM,IAAIC,KAAA,CAAM,wBAAyB,CAAAC,MAAA,CAAAH,QAAA,CAASI,MAAQ,CAAA,CAAA;IAC5D;IAEA,OAAOJ,SAASK,IAAK,EAAA;EACtB,CAAA,CACA,CAAAN,IAAA,CACEO,MAAW,IAAAA,MAAA,EACXC,KAAU,IAAA;IACT,IAAIA,iBAAiBL,KAAO,EAAA;MACpB,MAAAK,KAAA;IAAA,CACD,MAAA;MACGC,OAAA,CAAAD,KAAA,CAAM,kBAAkBJ,MAAO,CAAAI,KAAA,CAAA,CAAA;MACjC,MAAA,IAAIL,MAAM,sBAAsB,CAAA;IACxC;EACF,CAAA,CACF;AACJ;AAEgB,SAAAO,SAAAA,CAAAC,KAAA,EAA6D;EAAA,IAAnD;IAAEC;GAAiD,GAAAD,KAAA;EAC3E,MAAME,cAAcC,cAAe,EAAA;EACnC,MAAM,CAACC,IAAA,EAAMC,OAAO,CAAA,GAAIC,SAAS,EAAE,C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J;EAAA,CACF;AACF,CAAC,CAAA;"}
|
package/dist/index.js
DELETED
|
@@ -1,467 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
var sanity = require('sanity');
|
|
8
|
-
var ui = require('@sanity/ui');
|
|
9
|
-
var react = require('react');
|
|
10
|
-
var react$1 = require('@headlessui/react');
|
|
11
|
-
var tsPattern = require('ts-pattern');
|
|
12
|
-
var reactQuery = require('@tanstack/react-query');
|
|
13
|
-
var useDebounce = require('use-debounce');
|
|
14
|
-
var styled = require('styled-components');
|
|
15
|
-
var react$2 = require('@iconify/react');
|
|
16
|
-
var icons = require('@sanity/icons');
|
|
17
|
-
var utils = require('@iconify/utils');
|
|
18
|
-
var changeCase = require('change-case');
|
|
19
|
-
function _interopDefaultCompat(e) {
|
|
20
|
-
return e && typeof e === 'object' && 'default' in e ? e : {
|
|
21
|
-
default: e
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
25
|
-
const BASE_API_URL = "https://api.iconify.design";
|
|
26
|
-
function fetchJson(_ref) {
|
|
27
|
-
let {
|
|
28
|
-
url,
|
|
29
|
-
signal
|
|
30
|
-
} = _ref;
|
|
31
|
-
return fetch(url, {
|
|
32
|
-
signal
|
|
33
|
-
}).then(response => {
|
|
34
|
-
if (!response.ok) {
|
|
35
|
-
throw new Error("Network error: status ".concat(response.status));
|
|
36
|
-
}
|
|
37
|
-
return response.json();
|
|
38
|
-
}).then(result => result, error => {
|
|
39
|
-
if (error instanceof Error) {
|
|
40
|
-
throw error;
|
|
41
|
-
} else {
|
|
42
|
-
console.error("Unknown error: ".concat(error));
|
|
43
|
-
throw new Error("Something went wrong");
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function useSearch(_ref2) {
|
|
48
|
-
let {
|
|
49
|
-
collections
|
|
50
|
-
} = _ref2;
|
|
51
|
-
const queryClient = reactQuery.useQueryClient();
|
|
52
|
-
const [term, setTerm] = react.useState("");
|
|
53
|
-
const [debouncedTerm, setDebouncedTerm] = useDebounce.useDebounce(term, 500);
|
|
54
|
-
const updateTerm = react.useCallback(function (newTerm) {
|
|
55
|
-
let updateImmediately = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
56
|
-
setTerm(newTerm);
|
|
57
|
-
if (updateImmediately) {
|
|
58
|
-
setDebouncedTerm(newTerm);
|
|
59
|
-
}
|
|
60
|
-
}, [setDebouncedTerm]);
|
|
61
|
-
const {
|
|
62
|
-
isInitialLoading,
|
|
63
|
-
isError,
|
|
64
|
-
error,
|
|
65
|
-
data,
|
|
66
|
-
isPreviousData
|
|
67
|
-
} = reactQuery.useQuery({
|
|
68
|
-
queryKey: ["search", collections, debouncedTerm],
|
|
69
|
-
queryFn: async _ref3 => {
|
|
70
|
-
let {
|
|
71
|
-
signal
|
|
72
|
-
} = _ref3;
|
|
73
|
-
var _a;
|
|
74
|
-
const url = new URL("/search", BASE_API_URL);
|
|
75
|
-
url.searchParams.append("query", debouncedTerm);
|
|
76
|
-
url.searchParams.append("limit", "60");
|
|
77
|
-
if (collections) {
|
|
78
|
-
url.searchParams.append("prefixes", collections.join(","));
|
|
79
|
-
}
|
|
80
|
-
const result = debouncedTerm ? await fetchJson({
|
|
81
|
-
url,
|
|
82
|
-
signal
|
|
83
|
-
}) : null;
|
|
84
|
-
if (result) {
|
|
85
|
-
Object.entries(result.collections).forEach(_ref4 => {
|
|
86
|
-
let [prefix, info] = _ref4;
|
|
87
|
-
queryClient.setQueryData(["iconSetInfo", prefix], info);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return (_a = result == null ? void 0 : result.icons) != null ? _a : [];
|
|
91
|
-
},
|
|
92
|
-
enabled: debouncedTerm.length > 0,
|
|
93
|
-
keepPreviousData: debouncedTerm.length > 0,
|
|
94
|
-
staleTime: 5 * 60 * 1e3
|
|
95
|
-
// 5 minutes
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
term,
|
|
100
|
-
setTerm: updateTerm,
|
|
101
|
-
debouncedTerm,
|
|
102
|
-
isInitialLoading,
|
|
103
|
-
isError,
|
|
104
|
-
error,
|
|
105
|
-
data,
|
|
106
|
-
isPreviousData
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function useIconSetInfo(_ref5) {
|
|
110
|
-
let {
|
|
111
|
-
prefix
|
|
112
|
-
} = _ref5;
|
|
113
|
-
return reactQuery.useQuery({
|
|
114
|
-
queryKey: ["iconSetInfo", prefix],
|
|
115
|
-
queryFn: async _ref6 => {
|
|
116
|
-
let {
|
|
117
|
-
signal
|
|
118
|
-
} = _ref6;
|
|
119
|
-
var _a;
|
|
120
|
-
if (!prefix) return null;
|
|
121
|
-
const url = new URL("/collection", BASE_API_URL);
|
|
122
|
-
url.searchParams.append("prefix", prefix);
|
|
123
|
-
url.searchParams.append("info", "true");
|
|
124
|
-
const result = await fetchJson({
|
|
125
|
-
url,
|
|
126
|
-
signal
|
|
127
|
-
});
|
|
128
|
-
return (_a = result == null ? void 0 : result.info) != null ? _a : null;
|
|
129
|
-
},
|
|
130
|
-
staleTime: Infinity
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
var __freeze = Object.freeze;
|
|
134
|
-
var __defProp = Object.defineProperty;
|
|
135
|
-
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", {
|
|
136
|
-
value: __freeze(raw || cooked.slice())
|
|
137
|
-
}));
|
|
138
|
-
var _a, _b;
|
|
139
|
-
const ComboboxWrapper = styled__default.default(ui.Grid)(_a || (_a = __template(["\n grid-template-columns: 1fr min-content;\n position: relative;\n"])));
|
|
140
|
-
const OptionsWrapper = styled__default.default(ui.Box)(_b || (_b = __template(["\n box-sizing: border-box;\n padding: 0.5rem;\n\n & [role='listbox'] {\n display: grid;\n grid-template-columns: repeat(10, minmax(min(100%, 1rem), 1fr));\n gap: 0.5rem;\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n & [role='option'] {\n display: grid;\n place-items: center;\n\n & button {\n aspect-ratio: 1;\n cursor: pointer;\n width: 100%;\n }\n }\n"])));
|
|
141
|
-
function MessageWrapper(_ref7) {
|
|
142
|
-
let {
|
|
143
|
-
children
|
|
144
|
-
} = _ref7;
|
|
145
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
146
|
-
padding: 4,
|
|
147
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
148
|
-
align: "center",
|
|
149
|
-
muted: true,
|
|
150
|
-
children
|
|
151
|
-
})
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
const SearchInput = react.forwardRef((props, ref) => {
|
|
155
|
-
const {
|
|
156
|
-
term,
|
|
157
|
-
selectedIcon,
|
|
158
|
-
onChange
|
|
159
|
-
} = props;
|
|
160
|
-
return /* @__PURE__ */jsxRuntime.jsx(react$1.Combobox.Input, {
|
|
161
|
-
as: ui.TextInput,
|
|
162
|
-
ref,
|
|
163
|
-
inputMode: "search",
|
|
164
|
-
value: term,
|
|
165
|
-
onChange,
|
|
166
|
-
icon: selectedIcon ? /* @__PURE__ */jsxRuntime.jsx(react$2.Icon, {
|
|
167
|
-
icon: selectedIcon
|
|
168
|
-
}) : null,
|
|
169
|
-
placeholder: selectedIcon ? "Search and replace selected icon..." : "Search for an icon..."
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
SearchInput.displayName = "SearchInput";
|
|
173
|
-
function SearchResults(props) {
|
|
174
|
-
const {
|
|
175
|
-
state,
|
|
176
|
-
data
|
|
177
|
-
} = props;
|
|
178
|
-
if (state === "initial") {
|
|
179
|
-
return /* @__PURE__ */jsxRuntime.jsx(MessageWrapper, {
|
|
180
|
-
children: "Search for icons"
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
if (state === "loading") {
|
|
184
|
-
return /* @__PURE__ */jsxRuntime.jsx(MessageWrapper, {
|
|
185
|
-
children: "Searching..."
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
if (state === "error") {
|
|
189
|
-
return /* @__PURE__ */jsxRuntime.jsx(MessageWrapper, {
|
|
190
|
-
children: "Something went wrong..."
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
if (state === "empty") {
|
|
194
|
-
return /* @__PURE__ */jsxRuntime.jsx(MessageWrapper, {
|
|
195
|
-
children: "No icons found"
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
return /* @__PURE__ */jsxRuntime.jsx(react$1.Combobox.Options, {
|
|
199
|
-
style: {
|
|
200
|
-
opacity: state === "stale" ? 0.5 : 1
|
|
201
|
-
},
|
|
202
|
-
children: data.map(icon => /* @__PURE__ */jsxRuntime.jsx(react$1.Combobox.Option, {
|
|
203
|
-
value: icon,
|
|
204
|
-
children: _ref8 => {
|
|
205
|
-
let {
|
|
206
|
-
active
|
|
207
|
-
} = _ref8;
|
|
208
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
209
|
-
mode: "bleed",
|
|
210
|
-
icon: /* @__PURE__ */jsxRuntime.jsx(react$2.Icon, {
|
|
211
|
-
icon
|
|
212
|
-
}),
|
|
213
|
-
selected: active
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}, icon))
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
function UnsetButton(props) {
|
|
220
|
-
const {
|
|
221
|
-
onUnset
|
|
222
|
-
} = props;
|
|
223
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
224
|
-
border: true,
|
|
225
|
-
borderLeft: false,
|
|
226
|
-
padding: 1,
|
|
227
|
-
display: "flex",
|
|
228
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
229
|
-
icon: /* @__PURE__ */jsxRuntime.jsx(icons.TrashIcon, {}),
|
|
230
|
-
onClick: onUnset,
|
|
231
|
-
mode: "bleed",
|
|
232
|
-
fontSize: 1,
|
|
233
|
-
padding: 2
|
|
234
|
-
})
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
function IconifyCombobox(props) {
|
|
238
|
-
const {
|
|
239
|
-
selectedIcon,
|
|
240
|
-
onSelect: pushSelection,
|
|
241
|
-
collections
|
|
242
|
-
} = props;
|
|
243
|
-
const id = react.useId();
|
|
244
|
-
const toast = ui.useToast();
|
|
245
|
-
const inputRef = react.useRef(null);
|
|
246
|
-
const {
|
|
247
|
-
term,
|
|
248
|
-
setTerm,
|
|
249
|
-
debouncedTerm,
|
|
250
|
-
isInitialLoading,
|
|
251
|
-
isError,
|
|
252
|
-
error,
|
|
253
|
-
data,
|
|
254
|
-
isPreviousData
|
|
255
|
-
} = useSearch({
|
|
256
|
-
collections
|
|
257
|
-
});
|
|
258
|
-
const handleTermChange = react.useCallback(event => setTerm(event.target.value), [setTerm]);
|
|
259
|
-
const handleSelect = react.useCallback(icon => {
|
|
260
|
-
pushSelection(icon);
|
|
261
|
-
setTerm("", true);
|
|
262
|
-
}, [pushSelection, setTerm]);
|
|
263
|
-
const handleUnset = react.useCallback(() => handleSelect(""), [handleSelect]);
|
|
264
|
-
react.useEffect(() => {
|
|
265
|
-
if (isError) {
|
|
266
|
-
console.error("Iconify input error:", error);
|
|
267
|
-
toast.push({
|
|
268
|
-
id,
|
|
269
|
-
status: "error",
|
|
270
|
-
title: "Iconify input error",
|
|
271
|
-
description: error == null ? void 0 : error.message
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
}, [error, id, isError, toast]);
|
|
275
|
-
return /* @__PURE__ */jsxRuntime.jsxs(ComboboxWrapper, {
|
|
276
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(react$1.Combobox, {
|
|
277
|
-
onChange: handleSelect,
|
|
278
|
-
children: _ref9 => {
|
|
279
|
-
let {
|
|
280
|
-
open
|
|
281
|
-
} = _ref9;
|
|
282
|
-
return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
283
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(SearchInput, {
|
|
284
|
-
ref: inputRef,
|
|
285
|
-
term,
|
|
286
|
-
selectedIcon,
|
|
287
|
-
onChange: handleTermChange
|
|
288
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Popover, {
|
|
289
|
-
open,
|
|
290
|
-
placement: "bottom",
|
|
291
|
-
arrow: false,
|
|
292
|
-
matchReferenceWidth: true,
|
|
293
|
-
portal: true,
|
|
294
|
-
constrainSize: true,
|
|
295
|
-
referenceElement: inputRef.current,
|
|
296
|
-
content: /* @__PURE__ */jsxRuntime.jsx(OptionsWrapper, {
|
|
297
|
-
children: /* @__PURE__ */jsxRuntime.jsx(SearchResults, {
|
|
298
|
-
state: tsPattern.match(true).returnType().with(isInitialLoading, () => "loading").with(!debouncedTerm, () => "initial").with(isError, () => "error").with(!data || data.length === 0, () => "empty").with(isPreviousData, () => "stale").otherwise(() => "data"),
|
|
299
|
-
data
|
|
300
|
-
})
|
|
301
|
-
})
|
|
302
|
-
})]
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
}), selectedIcon ? /* @__PURE__ */jsxRuntime.jsx(UnsetButton, {
|
|
306
|
-
onUnset: handleUnset
|
|
307
|
-
}) : null]
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
const queryClient = new reactQuery.QueryClient();
|
|
311
|
-
function QueryClientProvider(props) {
|
|
312
|
-
return /* @__PURE__ */jsxRuntime.jsx(reactQuery.QueryClientProvider, {
|
|
313
|
-
client: queryClient,
|
|
314
|
-
children: props.children
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
function usePrettyIconName(props) {
|
|
318
|
-
var _a, _b;
|
|
319
|
-
const {
|
|
320
|
-
name
|
|
321
|
-
} = props;
|
|
322
|
-
const iconMeta = react.useMemo(() => {
|
|
323
|
-
var _a2;
|
|
324
|
-
return (_a2 = props.iconMeta) != null ? _a2 : name ? utils.stringToIcon(name) : null;
|
|
325
|
-
}, [name, props.iconMeta]);
|
|
326
|
-
const iconSetInfo = useIconSetInfo({
|
|
327
|
-
prefix: (_a = iconMeta == null ? void 0 : iconMeta.prefix) != null ? _a : null
|
|
328
|
-
});
|
|
329
|
-
return react.useMemo(() => {
|
|
330
|
-
var _a2, _b2;
|
|
331
|
-
return iconMeta ? {
|
|
332
|
-
name: changeCase.sentenceCase(iconMeta.name),
|
|
333
|
-
collection: (_b2 = (_a2 = iconSetInfo.data) == null ? void 0 : _a2.name) != null ? _b2 : iconMeta.prefix
|
|
334
|
-
} : null;
|
|
335
|
-
}, [iconMeta, (_b = iconSetInfo.data) == null ? void 0 : _b.name]);
|
|
336
|
-
}
|
|
337
|
-
function IconifyInput(props) {
|
|
338
|
-
var _a, _b, _c, _d, _e;
|
|
339
|
-
const {
|
|
340
|
-
config,
|
|
341
|
-
value,
|
|
342
|
-
onChange: pushChange,
|
|
343
|
-
schemaType
|
|
344
|
-
} = props;
|
|
345
|
-
const selectedIcon = (_a = value == null ? void 0 : value.name) != null ? _a : null;
|
|
346
|
-
const options = schemaType.options;
|
|
347
|
-
const collections = !!((_b = options == null ? void 0 : options.collections) == null ? void 0 : _b.length) && options.collections || !!((_c = config == null ? void 0 : config.collections) == null ? void 0 : _c.length) && config.collections || null;
|
|
348
|
-
const showName = (_e = (_d = options == null ? void 0 : options.showName) != null ? _d : config == null ? void 0 : config.showName) != null ? _e : false;
|
|
349
|
-
const parentTheme = ui.useTheme();
|
|
350
|
-
const theme = react.useMemo(() => parentTheme ? {
|
|
351
|
-
...parentTheme.sanity,
|
|
352
|
-
color: ui.studioTheme.color
|
|
353
|
-
} : ui.studioTheme, [parentTheme]);
|
|
354
|
-
const handleSelect = react.useCallback(icon => {
|
|
355
|
-
pushChange(icon === "" ? sanity.unset() : sanity.set(icon, ["name"]));
|
|
356
|
-
}, [pushChange]);
|
|
357
|
-
return /* @__PURE__ */jsxRuntime.jsx(QueryClientProvider, {
|
|
358
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.ThemeProvider, {
|
|
359
|
-
theme,
|
|
360
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
361
|
-
space: 2,
|
|
362
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(IconifyCombobox, {
|
|
363
|
-
selectedIcon,
|
|
364
|
-
onSelect: handleSelect,
|
|
365
|
-
collections
|
|
366
|
-
}), showName && selectedIcon ? /* @__PURE__ */jsxRuntime.jsx(IconifyNameDisplay, {
|
|
367
|
-
name: selectedIcon
|
|
368
|
-
}) : null]
|
|
369
|
-
})
|
|
370
|
-
})
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
function IconifyNameDisplay(props) {
|
|
374
|
-
var _a;
|
|
375
|
-
const {
|
|
376
|
-
name
|
|
377
|
-
} = props;
|
|
378
|
-
const prettyName = usePrettyIconName({
|
|
379
|
-
name
|
|
380
|
-
});
|
|
381
|
-
return /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
382
|
-
gap: 1,
|
|
383
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
384
|
-
size: 1,
|
|
385
|
-
muted: true,
|
|
386
|
-
children: "Selected:"
|
|
387
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
388
|
-
size: 1,
|
|
389
|
-
weight: "semibold",
|
|
390
|
-
children: (_a = prettyName == null ? void 0 : prettyName.name) != null ? _a : name
|
|
391
|
-
}), (prettyName == null ? void 0 : prettyName.collection) && /* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
|
|
392
|
-
size: 1,
|
|
393
|
-
muted: true,
|
|
394
|
-
style: {
|
|
395
|
-
fontStyle: "italic"
|
|
396
|
-
},
|
|
397
|
-
children: ["by ", prettyName == null ? void 0 : prettyName.collection]
|
|
398
|
-
})]
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
function IconifyPreview(props) {
|
|
402
|
-
const {
|
|
403
|
-
title
|
|
404
|
-
} = props;
|
|
405
|
-
const iconName = typeof props.title === "string" ? utils.stringToIcon(props.title) : null;
|
|
406
|
-
if (typeof title === "string" && iconName) {
|
|
407
|
-
return /* @__PURE__ */jsxRuntime.jsx(QueryClientProvider, {
|
|
408
|
-
children: /* @__PURE__ */jsxRuntime.jsx(IconifyPreviewInner, {
|
|
409
|
-
...props,
|
|
410
|
-
iconName: title,
|
|
411
|
-
iconMeta: iconName
|
|
412
|
-
})
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
return props.renderDefault(props);
|
|
416
|
-
}
|
|
417
|
-
function IconifyPreviewInner(props) {
|
|
418
|
-
var _a;
|
|
419
|
-
const {
|
|
420
|
-
iconMeta,
|
|
421
|
-
iconName,
|
|
422
|
-
...previewProps
|
|
423
|
-
} = props;
|
|
424
|
-
const prettyName = usePrettyIconName({
|
|
425
|
-
iconMeta
|
|
426
|
-
});
|
|
427
|
-
return props.renderDefault({
|
|
428
|
-
...previewProps,
|
|
429
|
-
media: /* @__PURE__ */jsxRuntime.jsx(react$2.Icon, {
|
|
430
|
-
icon: iconName
|
|
431
|
-
}),
|
|
432
|
-
title: (_a = prettyName == null ? void 0 : prettyName.name) != null ? _a : iconName,
|
|
433
|
-
subtitle: prettyName == null ? void 0 : prettyName.collection
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
const iconify = sanity.definePlugin(function () {
|
|
437
|
-
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
438
|
-
return {
|
|
439
|
-
name: "sanity-plugin-iconify",
|
|
440
|
-
schema: {
|
|
441
|
-
types: [{
|
|
442
|
-
name: "icon",
|
|
443
|
-
title: "Icon",
|
|
444
|
-
type: "object",
|
|
445
|
-
fields: [{
|
|
446
|
-
name: "name",
|
|
447
|
-
title: "Name",
|
|
448
|
-
type: "string"
|
|
449
|
-
}],
|
|
450
|
-
components: {
|
|
451
|
-
input: props => /* @__PURE__ */jsxRuntime.jsx(IconifyInput, {
|
|
452
|
-
...props,
|
|
453
|
-
config
|
|
454
|
-
}),
|
|
455
|
-
preview: IconifyPreview,
|
|
456
|
-
// This makes sure the input component is not indented
|
|
457
|
-
field: props => props.renderDefault({
|
|
458
|
-
...props,
|
|
459
|
-
level: 0
|
|
460
|
-
})
|
|
461
|
-
}
|
|
462
|
-
}]
|
|
463
|
-
}
|
|
464
|
-
};
|
|
465
|
-
});
|
|
466
|
-
exports.iconify = iconify;
|
|
467
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/lib/api.ts","../src/combobox/iconify-combobox.styles.tsx","../src/combobox/search-input.tsx","../src/combobox/search-result.tsx","../src/combobox/unset-button.tsx","../src/combobox/iconify-combobox.tsx","../src/lib/query-client.tsx","../src/lib/use-pretty-icon-name.ts","../src/iconify-input.tsx","../src/iconify-preview.tsx","../src/iconify-plugin.tsx"],"sourcesContent":["import { IconifyInfo } from '@iconify/types';\nimport { useQuery, useQueryClient } from '@tanstack/react-query';\nimport { IconifySearchResult } from './types';\nimport { useCallback, useState } from 'react';\nimport { useDebounce } from 'use-debounce';\n\nconst BASE_API_URL = 'https://api.iconify.design';\n\nfunction fetchJson<T>({ url, signal }: { url: string | URL; signal?: AbortSignal }): Promise<T> {\n return fetch(url, { signal })\n .then((response) => {\n if (!response.ok) {\n throw new Error(`Network error: status ${response.status}`);\n }\n\n return response.json();\n })\n .then(\n (result) => result as T,\n (error) => {\n if (error instanceof Error) {\n throw error;\n } else {\n console.error(`Unknown error: ${error}`);\n throw new Error('Something went wrong');\n }\n },\n );\n}\n\nexport function useSearch({ collections }: { collections: string[] | null }) {\n const queryClient = useQueryClient();\n const [term, setTerm] = useState('');\n const [debouncedTerm, setDebouncedTerm] = useDebounce(term, 500);\n\n const updateTerm = useCallback(\n (newTerm: string, updateImmediately = false) => {\n setTerm(newTerm);\n\n if (updateImmediately) {\n setDebouncedTerm(newTerm);\n }\n },\n [setDebouncedTerm],\n );\n\n const { isInitialLoading, isError, error, data, isPreviousData } = useQuery<string[], Error>({\n queryKey: ['search', collections, debouncedTerm],\n queryFn: async ({ signal }) => {\n const url = new URL(`/search`, BASE_API_URL);\n\n url.searchParams.append('query', debouncedTerm);\n url.searchParams.append('limit', '60');\n\n if (collections) {\n url.searchParams.append('prefixes', collections.join(','));\n }\n\n const result = debouncedTerm ? await fetchJson<IconifySearchResult>({ url, signal }) : null;\n\n if (result) {\n // Cache the info for each collection\n Object.entries(result.collections).forEach(([prefix, info]) => {\n queryClient.setQueryData<IconifyInfo>(['iconSetInfo', prefix], info);\n });\n }\n\n return result?.icons ?? [];\n },\n enabled: debouncedTerm.length > 0,\n keepPreviousData: debouncedTerm.length > 0,\n staleTime: 5 * 60 * 1000, // 5 minutes\n });\n\n return {\n term,\n setTerm: updateTerm,\n debouncedTerm,\n isInitialLoading,\n isError,\n error,\n data,\n isPreviousData,\n };\n}\n\nexport function useIconSetInfo({ prefix }: { prefix?: string | null }) {\n return useQuery<IconifyInfo | null, Error>({\n queryKey: ['iconSetInfo', prefix],\n queryFn: async ({ signal }) => {\n if (!prefix) return null;\n\n const url = new URL('/collection', BASE_API_URL);\n\n url.searchParams.append('prefix', prefix);\n url.searchParams.append('info', 'true');\n\n const result = await fetchJson<{ info: IconifyInfo }>({ url, signal });\n\n return result?.info ?? null;\n },\n staleTime: Infinity,\n });\n}\n","import { Box, Card, Grid, Text } from '@sanity/ui';\nimport { ReactNode } from 'react';\nimport styled from 'styled-components';\n\nexport const ComboboxWrapper = styled(Grid)`\n grid-template-columns: 1fr min-content;\n position: relative;\n`;\n\nexport const OptionsWrapper = styled(Box)`\n box-sizing: border-box;\n padding: 0.5rem;\n\n & [role='listbox'] {\n display: grid;\n grid-template-columns: repeat(10, minmax(min(100%, 1rem), 1fr));\n gap: 0.5rem;\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n & [role='option'] {\n display: grid;\n place-items: center;\n\n & button {\n aspect-ratio: 1;\n cursor: pointer;\n width: 100%;\n }\n }\n`;\n\nexport function MessageWrapper({ children }: { children: ReactNode }) {\n return (\n <Card padding={4}>\n <Text align=\"center\" muted>\n {children}\n </Text>\n </Card>\n );\n}\n","import { Combobox } from '@headlessui/react';\nimport { Icon } from '@iconify/react';\nimport { TextInput } from '@sanity/ui';\nimport { ChangeEventHandler, forwardRef } from 'react';\n\n// ------------ //\n// SEARCH INPUT //\n// ------------ //\n\ninterface SearchInputProps {\n term: string;\n selectedIcon: string | null;\n onChange: ChangeEventHandler<HTMLInputElement>;\n}\n\nexport const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>((props, ref) => {\n const { term, selectedIcon, onChange } = props;\n\n return (\n <Combobox.Input\n as={TextInput}\n ref={ref}\n inputMode=\"search\"\n value={term}\n onChange={onChange}\n icon={selectedIcon ? <Icon icon={selectedIcon} /> : null}\n placeholder={selectedIcon ? 'Search and replace selected icon...' : 'Search for an icon...'}\n />\n );\n});\n\nSearchInput.displayName = 'SearchInput';\n","import { Combobox } from '@headlessui/react';\nimport { Icon } from '@iconify/react';\nimport { Button } from '@sanity/ui';\nimport { MessageWrapper } from './iconify-combobox.styles';\n\n// -------------- //\n// SEARCH RESULTS //\n// -------------- //\n\nexport interface SearchResultsProps {\n state: 'initial' | 'loading' | 'error' | 'empty' | 'data' | 'stale';\n data?: string[];\n}\n\nexport function SearchResults(props: SearchResultsProps) {\n const { state, data } = props;\n\n if (state === 'initial') {\n return <MessageWrapper>Search for icons</MessageWrapper>;\n }\n\n if (state === 'loading') {\n return <MessageWrapper>Searching...</MessageWrapper>;\n }\n\n if (state === 'error') {\n return <MessageWrapper>Something went wrong...</MessageWrapper>;\n }\n\n if (state === 'empty') {\n return <MessageWrapper>No icons found</MessageWrapper>;\n }\n\n return (\n <Combobox.Options style={{ opacity: state === 'stale' ? 0.5 : 1 }}>\n {data!.map((icon) => (\n <Combobox.Option key={icon} value={icon}>\n {({ active }) => <Button mode=\"bleed\" icon={<Icon icon={icon} />} selected={active} />}\n </Combobox.Option>\n ))}\n </Combobox.Options>\n );\n}\n","import { TrashIcon } from '@sanity/icons';\nimport { Button, Card } from '@sanity/ui';\n\n// ------------ //\n// UNSET BUTTON //\n// ------------ //\n\ninterface UnsetButtonProps {\n onUnset: () => void;\n}\n\nexport function UnsetButton(props: UnsetButtonProps) {\n const { onUnset } = props;\n\n return (\n <Card border borderLeft={false} padding={1} display=\"flex\">\n <Button icon={<TrashIcon />} onClick={onUnset} mode=\"bleed\" fontSize={1} padding={2} />\n </Card>\n );\n}\n","import { Combobox } from '@headlessui/react';\nimport { Popover, useToast } from '@sanity/ui';\nimport { ChangeEventHandler, useCallback, useEffect, useId, useRef } from 'react';\nimport { match } from 'ts-pattern';\nimport { useSearch } from '../lib/api';\nimport { ComboboxWrapper, OptionsWrapper } from './iconify-combobox.styles';\nimport { SearchInput } from './search-input';\nimport { SearchResults, SearchResultsProps } from './search-result';\nimport { UnsetButton } from './unset-button';\n\nexport interface IconifyComboboxProps {\n selectedIcon: string | null;\n onSelect: (newValue: string) => void;\n collections: string[] | null;\n}\n\nexport function IconifyCombobox(props: IconifyComboboxProps) {\n const { selectedIcon, onSelect: pushSelection, collections } = props;\n\n const id = useId();\n const toast = useToast();\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { term, setTerm, debouncedTerm, isInitialLoading, isError, error, data, isPreviousData } =\n useSearch({\n collections,\n });\n\n const handleTermChange: ChangeEventHandler<HTMLInputElement> = useCallback(\n (event) => setTerm(event.target.value),\n [setTerm],\n );\n\n const handleSelect = useCallback(\n (icon: string) => {\n pushSelection(icon);\n setTerm('', true);\n },\n [pushSelection, setTerm],\n );\n\n const handleUnset = useCallback(() => handleSelect(''), [handleSelect]);\n\n useEffect(() => {\n if (isError) {\n console.error('Iconify input error:', error);\n\n toast.push({\n id,\n status: 'error',\n title: 'Iconify input error',\n description: error?.message,\n });\n }\n }, [error, id, isError, toast]);\n\n return (\n <ComboboxWrapper>\n <Combobox onChange={handleSelect}>\n {({ open }) => (\n <>\n <SearchInput\n ref={inputRef}\n term={term}\n selectedIcon={selectedIcon}\n onChange={handleTermChange}\n />\n\n <Popover\n open={open}\n placement=\"bottom\"\n arrow={false}\n matchReferenceWidth\n portal\n constrainSize\n referenceElement={inputRef.current}\n content={\n <OptionsWrapper>\n <SearchResults\n state={match<boolean>(true)\n .returnType<SearchResultsProps['state']>()\n .with(isInitialLoading, () => 'loading')\n .with(!debouncedTerm, () => 'initial')\n .with(isError, () => 'error')\n .with(!data || data.length === 0, () => 'empty')\n .with(isPreviousData, () => 'stale')\n .otherwise(() => 'data')}\n data={data}\n />\n </OptionsWrapper>\n }\n />\n </>\n )}\n </Combobox>\n\n {selectedIcon ? <UnsetButton onUnset={handleUnset} /> : null}\n </ComboboxWrapper>\n );\n}\n","import {\n QueryClient,\n QueryClientProvider as ReactQueryClientProvider,\n} from '@tanstack/react-query';\nimport { ReactNode } from 'react';\n\nexport const queryClient = new QueryClient();\n\nexport function QueryClientProvider(props: { children: ReactNode }) {\n return <ReactQueryClientProvider client={queryClient}>{props.children}</ReactQueryClientProvider>;\n}\n","import { IconifyIconName, stringToIcon } from '@iconify/utils';\nimport { sentenceCase } from 'change-case';\nimport { useMemo } from 'react';\nimport { useIconSetInfo } from './api';\n\ninterface UsePrettyIconNameProps {\n name?: string | null;\n iconMeta?: IconifyIconName | null;\n}\n\nexport function usePrettyIconName(props: UsePrettyIconNameProps) {\n const { name } = props;\n const iconMeta = useMemo(\n () => props.iconMeta ?? (name ? stringToIcon(name) : null),\n [name, props.iconMeta],\n );\n const iconSetInfo = useIconSetInfo({ prefix: iconMeta?.prefix ?? null });\n\n return useMemo(\n () =>\n iconMeta\n ? {\n name: sentenceCase(iconMeta.name),\n collection: iconSetInfo.data?.name ?? iconMeta.prefix,\n }\n : null,\n [iconMeta, iconSetInfo.data?.name],\n );\n}\n","import { Flex, RootTheme, Stack, Text, ThemeProvider, studioTheme, useTheme } from '@sanity/ui';\nimport { useCallback, useMemo } from 'react';\nimport { ObjectInputProps, set, unset } from 'sanity';\nimport { IconifyCombobox } from './combobox';\nimport { QueryClientProvider } from './lib/query-client';\nimport { IconOptions, IconifyPluginConfig } from './lib/types';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\n\n// -------------- //\n// ICONIFY INPUT //\n// -------------- //\n\ninterface IconifyInputProps extends ObjectInputProps {\n config: IconifyPluginConfig;\n}\n\nexport function IconifyInput(props: IconifyInputProps) {\n const { config, value, onChange: pushChange, schemaType } = props;\n\n const selectedIcon: string | null = value?.name ?? null;\n\n const options: IconOptions = schemaType.options;\n const collections =\n (!!options?.collections?.length && options.collections) ||\n (!!config?.collections?.length && config.collections) ||\n null;\n const showName = options?.showName ?? config?.showName ?? false;\n\n const parentTheme = useTheme();\n const theme: RootTheme = useMemo(\n () => (parentTheme ? { ...parentTheme.sanity, color: studioTheme.color } : studioTheme),\n [parentTheme],\n );\n\n const handleSelect = useCallback(\n (icon: string) => {\n pushChange(icon === '' ? unset() : set(icon, ['name']));\n },\n [pushChange],\n );\n\n return (\n <QueryClientProvider>\n <ThemeProvider theme={theme}>\n <Stack space={2}>\n <IconifyCombobox\n selectedIcon={selectedIcon}\n onSelect={handleSelect}\n collections={collections}\n />\n\n {showName && selectedIcon ? <IconifyNameDisplay name={selectedIcon} /> : null}\n </Stack>\n </ThemeProvider>\n </QueryClientProvider>\n );\n}\n\ninterface IconifyNameDisplayProps {\n name?: string | null;\n}\n\nfunction IconifyNameDisplay(props: IconifyNameDisplayProps) {\n const { name } = props;\n const prettyName = usePrettyIconName({ name });\n\n return (\n <Flex gap={1}>\n <Text size={1} muted>\n Selected:\n </Text>\n\n <Text size={1} weight=\"semibold\">\n {prettyName?.name ?? name}\n </Text>\n\n {prettyName?.collection && (\n <Text size={1} muted style={{ fontStyle: 'italic' }}>\n by {prettyName?.collection}\n </Text>\n )}\n </Flex>\n );\n}\n","import { Icon } from '@iconify/react';\nimport { PreviewProps } from 'sanity';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\nimport { IconifyIconName, stringToIcon } from '@iconify/utils';\nimport { QueryClientProvider } from './lib/query-client';\n\n// --------------- //\n// ICONIFY PREVIEW //\n// --------------- //\n\nexport function IconifyPreview(props: PreviewProps) {\n const { title } = props;\n const iconName = typeof props.title === 'string' ? stringToIcon(props.title) : null;\n\n // We check this double to avoid the TS error\n if (typeof title === 'string' && iconName) {\n return (\n <QueryClientProvider>\n <IconifyPreviewInner {...props} iconName={title} iconMeta={iconName} />\n </QueryClientProvider>\n );\n }\n\n return props.renderDefault(props);\n}\n\n// --------------------- //\n// ICONIFY PREVIEW INNER //\n// --------------------- //\n\ninterface IconifyPreviewInnerProps extends PreviewProps {\n iconName: string;\n iconMeta: IconifyIconName;\n}\n\nfunction IconifyPreviewInner(props: IconifyPreviewInnerProps) {\n const { iconMeta, iconName, ...previewProps } = props;\n const prettyName = usePrettyIconName({ iconMeta });\n\n return props.renderDefault({\n ...previewProps,\n media: <Icon icon={iconName} />,\n title: prettyName?.name ?? iconName,\n subtitle: prettyName?.collection,\n });\n}\n","import { FieldProps, ObjectInputProps, definePlugin } from 'sanity';\nimport { IconifyInput } from './iconify-input';\nimport { IconifyPreview } from './iconify-preview';\nimport { IconifyPluginConfig } from './lib/types';\n\n/**\n * Usage in `sanity.config.ts` (or .js)\n *\n * ```ts\n * import { defineConfig } from 'sanity'\n * import { iconify } from 'sanity-plugin-iconify'\n *\n * export default defineConfig({\n * // ...\n * plugins: [iconify()],\n * })\n * ```\n */\nexport const iconify = definePlugin<IconifyPluginConfig | void>((config = {}) => {\n return {\n name: 'sanity-plugin-iconify',\n schema: {\n types: [\n {\n name: 'icon',\n title: 'Icon',\n type: 'object',\n fields: [\n {\n name: 'name',\n title: 'Name',\n type: 'string',\n },\n ],\n components: {\n input: (props: ObjectInputProps) => <IconifyInput {...props} config={config!} />,\n preview: IconifyPreview,\n\n // This makes sure the input component is not indented\n field: (props: FieldProps) => props.renderDefault({ ...props, level: 0 }),\n },\n },\n ],\n },\n };\n});\n"],"names":["BASE_API_URL","fetchJson","_ref","url","signal","fetch","then","response","ok","Error","concat","status","json","result","error","console","useSearch","_ref2","collections","queryClient","useQueryClient","term","setTerm","useState","debouncedTerm","setDebouncedTerm","useDebounce","updateTerm","useCallback","newTerm","updateImmediately","arguments","length","undefined","isInitialLoading","isError","data","isPreviousData","useQuery","queryKey","queryFn","_ref3","_a","URL","searchParams","append","join","Object","entries","forEach","_ref4","prefix","info","setQueryData","icons","enabled","keepPreviousData","staleTime","useIconSetInfo","_ref5","_ref6","Infinity","_b","ComboboxWrapper","styled","Grid","__template","OptionsWrapper","Box","MessageWrapper","_ref7","children","jsx","Card","padding","Text","align","muted","SearchInput","forwardRef","props","ref","selectedIcon","onChange","Combobox","Input","as","TextInput","inputMode","value","icon","Icon","placeholder","displayName","SearchResults","state","Options","style","opacity","map","Option","active","Button","mode","selected","UnsetButton","onUnset","border","borderLeft","display","TrashIcon","onClick","fontSize","IconifyCombobox","onSelect","pushSelection","id","useId","toast","useToast","inputRef","useRef","handleTermChange","event","target","handleSelect","handleUnset","useEffect","push","title","description","message","open","jsxs","Fragment","Popover","placement","arrow","matchReferenceWidth","portal","constrainSize","referenceElement","current","content","match","returnType","with","otherwise","QueryClient","QueryClientProvider","ReactQueryClientProvider","client","usePrettyIconName","name","iconMeta","useMemo","stringToIcon","iconSetInfo","sentenceCase","collection","IconifyInput","_c","_d","_e","config","pushChange","schemaType","options","showName","parentTheme","useTheme","theme","sanity","color","studioTheme","unset","set","ThemeProvider","Stack","space","IconifyNameDisplay","prettyName","Flex","gap","size","weight","fontStyle","IconifyPreview","iconName","IconifyPreviewInner","renderDefault","previewProps","media","subtitle","iconify","definePlugin","schema","types","type","fields","components","input","preview","field","level"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAMA,YAAe,GAAA,4BAAA;AAErB,SAASC,SAAaA,CAAAC,IAAA,EAA0E;EAAA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