sanity-plugin-iconify 1.0.0 → 1.0.2
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/dist/index.d.ts +206 -0
- package/dist/index.esm.js +408 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +419 -0
- package/dist/index.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,408 @@
|
|
|
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, Stack, Flex } from '@sanity/ui';
|
|
4
|
+
import { useQueryClient, useQuery, QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
5
|
+
import { useState, useCallback, forwardRef, useId, useRef, useEffect, useMemo } from 'react';
|
|
6
|
+
import { Combobox } from '@headlessui/react';
|
|
7
|
+
import { match } from 'ts-pattern';
|
|
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
|
+
function usePrettyIconName(name) {
|
|
300
|
+
var _a, _b;
|
|
301
|
+
const iconMeta = useMemo(() => name ? stringToIcon(name) : null, [name]);
|
|
302
|
+
const iconSetInfo = useIconSetInfo({
|
|
303
|
+
prefix: (_a = iconMeta == null ? void 0 : iconMeta.prefix) != null ? _a : null
|
|
304
|
+
});
|
|
305
|
+
return useMemo(() => {
|
|
306
|
+
var _a2, _b2;
|
|
307
|
+
return iconMeta ? {
|
|
308
|
+
name: sentenceCase(iconMeta.name),
|
|
309
|
+
collection: (_b2 = (_a2 = iconSetInfo.data) == null ? void 0 : _a2.name) != null ? _b2 : iconMeta.prefix
|
|
310
|
+
} : null;
|
|
311
|
+
}, [iconMeta, (_b = iconSetInfo.data) == null ? void 0 : _b.name]);
|
|
312
|
+
}
|
|
313
|
+
const queryClient = new QueryClient();
|
|
314
|
+
function IconifyInput(props) {
|
|
315
|
+
var _a, _b, _c, _d, _e, _f;
|
|
316
|
+
const {
|
|
317
|
+
config,
|
|
318
|
+
value,
|
|
319
|
+
onChange: pushChange,
|
|
320
|
+
schemaType
|
|
321
|
+
} = props;
|
|
322
|
+
const selectedIcon = (_a = value == null ? void 0 : value.name) != null ? _a : null;
|
|
323
|
+
const prettyName = usePrettyIconName(selectedIcon);
|
|
324
|
+
const options = schemaType.options;
|
|
325
|
+
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;
|
|
326
|
+
const showName = (_e = (_d = options == null ? void 0 : options.showName) != null ? _d : config == null ? void 0 : config.showName) != null ? _e : false;
|
|
327
|
+
const handleSelect = useCallback(icon => {
|
|
328
|
+
pushChange(icon === "" ? unset() : set(icon, ["name"]));
|
|
329
|
+
}, [pushChange]);
|
|
330
|
+
return /* @__PURE__ */jsx(QueryClientProvider, {
|
|
331
|
+
client: queryClient,
|
|
332
|
+
children: /* @__PURE__ */jsxs(Stack, {
|
|
333
|
+
space: 2,
|
|
334
|
+
children: [/* @__PURE__ */jsx(IconifyCombobox, {
|
|
335
|
+
selectedIcon,
|
|
336
|
+
onSelect: handleSelect,
|
|
337
|
+
collections
|
|
338
|
+
}), showName && selectedIcon ? /* @__PURE__ */jsxs(Flex, {
|
|
339
|
+
gap: 1,
|
|
340
|
+
children: [/* @__PURE__ */jsx(Text, {
|
|
341
|
+
size: 1,
|
|
342
|
+
muted: true,
|
|
343
|
+
children: "Selected:"
|
|
344
|
+
}), /* @__PURE__ */jsx(Text, {
|
|
345
|
+
size: 1,
|
|
346
|
+
weight: "semibold",
|
|
347
|
+
children: (_f = prettyName == null ? void 0 : prettyName.name) != null ? _f : selectedIcon
|
|
348
|
+
}), (prettyName == null ? void 0 : prettyName.collection) && /* @__PURE__ */jsxs(Text, {
|
|
349
|
+
size: 1,
|
|
350
|
+
muted: true,
|
|
351
|
+
style: {
|
|
352
|
+
fontStyle: "italic"
|
|
353
|
+
},
|
|
354
|
+
children: ["by ", prettyName == null ? void 0 : prettyName.collection]
|
|
355
|
+
})]
|
|
356
|
+
}) : null]
|
|
357
|
+
})
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
function IconifyPreview(props) {
|
|
361
|
+
const {
|
|
362
|
+
title
|
|
363
|
+
} = props;
|
|
364
|
+
const prettyName = usePrettyIconName(typeof title === "string" ? title : null);
|
|
365
|
+
if (typeof title === "string" && prettyName) {
|
|
366
|
+
return props.renderDefault({
|
|
367
|
+
...props,
|
|
368
|
+
media: /* @__PURE__ */jsx(Icon, {
|
|
369
|
+
icon: title
|
|
370
|
+
}),
|
|
371
|
+
title: prettyName.name,
|
|
372
|
+
subtitle: prettyName.collection
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return props.renderDefault(props);
|
|
376
|
+
}
|
|
377
|
+
const iconify = definePlugin(function () {
|
|
378
|
+
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
379
|
+
return {
|
|
380
|
+
name: "sanity-plugin-iconify",
|
|
381
|
+
schema: {
|
|
382
|
+
types: [{
|
|
383
|
+
name: "icon",
|
|
384
|
+
title: "Icon",
|
|
385
|
+
type: "object",
|
|
386
|
+
fields: [{
|
|
387
|
+
name: "name",
|
|
388
|
+
title: "Name",
|
|
389
|
+
type: "string"
|
|
390
|
+
}],
|
|
391
|
+
components: {
|
|
392
|
+
input: props => /* @__PURE__ */jsx(IconifyInput, {
|
|
393
|
+
...props,
|
|
394
|
+
config
|
|
395
|
+
}),
|
|
396
|
+
preview: IconifyPreview,
|
|
397
|
+
// This makes sure the input component is not indented
|
|
398
|
+
field: props => props.renderDefault({
|
|
399
|
+
...props,
|
|
400
|
+
level: 0
|
|
401
|
+
})
|
|
402
|
+
}
|
|
403
|
+
}]
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
});
|
|
407
|
+
export { iconify };
|
|
408
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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/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 { stringToIcon } from '@iconify/utils';\nimport { sentenceCase } from 'change-case';\nimport { useMemo } from 'react';\nimport { useIconSetInfo } from './api';\n\nexport function usePrettyIconName(name?: string | null) {\n const iconMeta = useMemo(() => (name ? stringToIcon(name) : null), [name]);\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, Stack, Text } from '@sanity/ui';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { useCallback } from 'react';\nimport { ObjectInputProps, set, unset } from 'sanity';\nimport { IconifyCombobox } from './combobox';\nimport { IconOptions, IconifyPluginConfig } from './lib/types';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\n\nconst queryClient = new QueryClient();\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 = value?.name ?? null;\n const prettyName = usePrettyIconName(selectedIcon);\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 handleSelect = useCallback(\n (icon: string) => {\n pushChange(icon === '' ? unset() : set(icon, ['name']));\n },\n [pushChange],\n );\n\n return (\n <QueryClientProvider client={queryClient}>\n <Stack space={2}>\n <IconifyCombobox\n selectedIcon={selectedIcon}\n onSelect={handleSelect}\n collections={collections}\n />\n\n {showName && selectedIcon ? (\n <Flex gap={1}>\n <Text size={1} muted>\n Selected:\n </Text>\n\n <Text size={1} weight=\"semibold\">\n {prettyName?.name ?? selectedIcon}\n </Text>\n\n {prettyName?.collection && (\n <Text size={1} muted style={{ fontStyle: 'italic' }}>\n by {prettyName?.collection}\n </Text>\n )}\n </Flex>\n ) : null}\n </Stack>\n </QueryClientProvider>\n );\n}\n","import { Icon } from '@iconify/react';\nimport { PreviewProps } from 'sanity';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\n\nexport function IconifyPreview(props: PreviewProps) {\n const { title } = props;\n const prettyName = usePrettyIconName(typeof title === 'string' ? title : null);\n\n // We check this double to avoid the TS error\n if (typeof title === 'string' && prettyName) {\n return props.renderDefault({\n ...props,\n media: <Icon icon={title} />,\n title: prettyName.name,\n subtitle: prettyName.collection,\n });\n }\n\n return props.renderDefault(props);\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","usePrettyIconName","name","iconMeta","useMemo","stringToIcon","iconSetInfo","sentenceCase","collection","QueryClient","IconifyInput","_c","_d","_e","_f","config","pushChange","schemaType","prettyName","options","showName","unset","set","QueryClientProvider","client","Stack","space","Flex","gap","size","weight","fontStyle","IconifyPreview","renderDefault","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,CAA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EJ;EAAA,CACF;AACF,CAAC,CAAA;"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,419 @@
|
|
|
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 reactQuery = require('@tanstack/react-query');
|
|
10
|
+
var react = require('react');
|
|
11
|
+
var react$1 = require('@headlessui/react');
|
|
12
|
+
var tsPattern = require('ts-pattern');
|
|
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
|
+
function usePrettyIconName(name) {
|
|
311
|
+
var _a, _b;
|
|
312
|
+
const iconMeta = react.useMemo(() => name ? utils.stringToIcon(name) : null, [name]);
|
|
313
|
+
const iconSetInfo = useIconSetInfo({
|
|
314
|
+
prefix: (_a = iconMeta == null ? void 0 : iconMeta.prefix) != null ? _a : null
|
|
315
|
+
});
|
|
316
|
+
return react.useMemo(() => {
|
|
317
|
+
var _a2, _b2;
|
|
318
|
+
return iconMeta ? {
|
|
319
|
+
name: changeCase.sentenceCase(iconMeta.name),
|
|
320
|
+
collection: (_b2 = (_a2 = iconSetInfo.data) == null ? void 0 : _a2.name) != null ? _b2 : iconMeta.prefix
|
|
321
|
+
} : null;
|
|
322
|
+
}, [iconMeta, (_b = iconSetInfo.data) == null ? void 0 : _b.name]);
|
|
323
|
+
}
|
|
324
|
+
const queryClient = new reactQuery.QueryClient();
|
|
325
|
+
function IconifyInput(props) {
|
|
326
|
+
var _a, _b, _c, _d, _e, _f;
|
|
327
|
+
const {
|
|
328
|
+
config,
|
|
329
|
+
value,
|
|
330
|
+
onChange: pushChange,
|
|
331
|
+
schemaType
|
|
332
|
+
} = props;
|
|
333
|
+
const selectedIcon = (_a = value == null ? void 0 : value.name) != null ? _a : null;
|
|
334
|
+
const prettyName = usePrettyIconName(selectedIcon);
|
|
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 handleSelect = react.useCallback(icon => {
|
|
339
|
+
pushChange(icon === "" ? sanity.unset() : sanity.set(icon, ["name"]));
|
|
340
|
+
}, [pushChange]);
|
|
341
|
+
return /* @__PURE__ */jsxRuntime.jsx(reactQuery.QueryClientProvider, {
|
|
342
|
+
client: queryClient,
|
|
343
|
+
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
344
|
+
space: 2,
|
|
345
|
+
children: [/* @__PURE__ */jsxRuntime.jsx(IconifyCombobox, {
|
|
346
|
+
selectedIcon,
|
|
347
|
+
onSelect: handleSelect,
|
|
348
|
+
collections
|
|
349
|
+
}), showName && selectedIcon ? /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
350
|
+
gap: 1,
|
|
351
|
+
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
352
|
+
size: 1,
|
|
353
|
+
muted: true,
|
|
354
|
+
children: "Selected:"
|
|
355
|
+
}), /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
356
|
+
size: 1,
|
|
357
|
+
weight: "semibold",
|
|
358
|
+
children: (_f = prettyName == null ? void 0 : prettyName.name) != null ? _f : selectedIcon
|
|
359
|
+
}), (prettyName == null ? void 0 : prettyName.collection) && /* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
|
|
360
|
+
size: 1,
|
|
361
|
+
muted: true,
|
|
362
|
+
style: {
|
|
363
|
+
fontStyle: "italic"
|
|
364
|
+
},
|
|
365
|
+
children: ["by ", prettyName == null ? void 0 : prettyName.collection]
|
|
366
|
+
})]
|
|
367
|
+
}) : null]
|
|
368
|
+
})
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
function IconifyPreview(props) {
|
|
372
|
+
const {
|
|
373
|
+
title
|
|
374
|
+
} = props;
|
|
375
|
+
const prettyName = usePrettyIconName(typeof title === "string" ? title : null);
|
|
376
|
+
if (typeof title === "string" && prettyName) {
|
|
377
|
+
return props.renderDefault({
|
|
378
|
+
...props,
|
|
379
|
+
media: /* @__PURE__ */jsxRuntime.jsx(react$2.Icon, {
|
|
380
|
+
icon: title
|
|
381
|
+
}),
|
|
382
|
+
title: prettyName.name,
|
|
383
|
+
subtitle: prettyName.collection
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
return props.renderDefault(props);
|
|
387
|
+
}
|
|
388
|
+
const iconify = sanity.definePlugin(function () {
|
|
389
|
+
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
390
|
+
return {
|
|
391
|
+
name: "sanity-plugin-iconify",
|
|
392
|
+
schema: {
|
|
393
|
+
types: [{
|
|
394
|
+
name: "icon",
|
|
395
|
+
title: "Icon",
|
|
396
|
+
type: "object",
|
|
397
|
+
fields: [{
|
|
398
|
+
name: "name",
|
|
399
|
+
title: "Name",
|
|
400
|
+
type: "string"
|
|
401
|
+
}],
|
|
402
|
+
components: {
|
|
403
|
+
input: props => /* @__PURE__ */jsxRuntime.jsx(IconifyInput, {
|
|
404
|
+
...props,
|
|
405
|
+
config
|
|
406
|
+
}),
|
|
407
|
+
preview: IconifyPreview,
|
|
408
|
+
// This makes sure the input component is not indented
|
|
409
|
+
field: props => props.renderDefault({
|
|
410
|
+
...props,
|
|
411
|
+
level: 0
|
|
412
|
+
})
|
|
413
|
+
}
|
|
414
|
+
}]
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
});
|
|
418
|
+
exports.iconify = iconify;
|
|
419
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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/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 { stringToIcon } from '@iconify/utils';\nimport { sentenceCase } from 'change-case';\nimport { useMemo } from 'react';\nimport { useIconSetInfo } from './api';\n\nexport function usePrettyIconName(name?: string | null) {\n const iconMeta = useMemo(() => (name ? stringToIcon(name) : null), [name]);\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, Stack, Text } from '@sanity/ui';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { useCallback } from 'react';\nimport { ObjectInputProps, set, unset } from 'sanity';\nimport { IconifyCombobox } from './combobox';\nimport { IconOptions, IconifyPluginConfig } from './lib/types';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\n\nconst queryClient = new QueryClient();\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 = value?.name ?? null;\n const prettyName = usePrettyIconName(selectedIcon);\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 handleSelect = useCallback(\n (icon: string) => {\n pushChange(icon === '' ? unset() : set(icon, ['name']));\n },\n [pushChange],\n );\n\n return (\n <QueryClientProvider client={queryClient}>\n <Stack space={2}>\n <IconifyCombobox\n selectedIcon={selectedIcon}\n onSelect={handleSelect}\n collections={collections}\n />\n\n {showName && selectedIcon ? (\n <Flex gap={1}>\n <Text size={1} muted>\n Selected:\n </Text>\n\n <Text size={1} weight=\"semibold\">\n {prettyName?.name ?? selectedIcon}\n </Text>\n\n {prettyName?.collection && (\n <Text size={1} muted style={{ fontStyle: 'italic' }}>\n by {prettyName?.collection}\n </Text>\n )}\n </Flex>\n ) : null}\n </Stack>\n </QueryClientProvider>\n );\n}\n","import { Icon } from '@iconify/react';\nimport { PreviewProps } from 'sanity';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\n\nexport function IconifyPreview(props: PreviewProps) {\n const { title } = props;\n const prettyName = usePrettyIconName(typeof title === 'string' ? title : null);\n\n // We check this double to avoid the TS error\n if (typeof title === 'string' && prettyName) {\n return props.renderDefault({\n ...props,\n media: <Icon icon={title} />,\n title: prettyName.name,\n subtitle: prettyName.collection,\n });\n }\n\n return props.renderDefault(props);\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","usePrettyIconName","name","iconMeta","useMemo","stringToIcon","iconSetInfo","sentenceCase","collection","QueryClient","IconifyInput","_c","_d","_e","_f","config","pushChange","schemaType","prettyName","options","showName","unset","set","QueryClientProvider","client","Stack","space","Flex","gap","size","weight","fontStyle","IconifyPreview","renderDefault","media","subtitle","iconify","definePlugin","schema","types","type","fields","components","input","preview","field","level"],"mappings":";;;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