sanity-plugin-iconify 2.1.0 → 3.0.0-beta.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.cjs +115 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -7
- package/dist/index.d.ts +43 -7
- package/dist/index.js +115 -51
- package/dist/index.js.map +1 -1
- package/package.json +37 -27
- package/src/combobox/iconify-combobox.tsx +76 -6
- package/src/combobox/search-input.tsx +16 -14
- package/src/combobox/search-result.tsx +37 -30
- package/src/combobox/unset-button.tsx +8 -1
- package/src/iconify-input.tsx +9 -5
- package/src/iconify-preview.tsx +3 -2
- package/src/lib/icon-types.gen.ts +1 -1
- package/src/lib/types.test.ts +57 -0
- package/src/lib/types.ts +44 -8
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), ui = require("@sanity/ui"), theme = require("@sanity/ui/theme"), react = require("react"), downshift = require("downshift"), tsPattern = require("ts-pattern"), reactQuery = require("@tanstack/react-query"), useDebounce = require("use-debounce"), styled = require("styled-components"), react$1 = require("@iconify/react"), icons = require("@sanity/icons"), utils = require("@iconify/utils"), changeCase = require("change-case");
|
|
3
|
+
var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), ui = require("@sanity/ui"), theme$1 = require("@sanity/ui/theme"), react = require("react"), downshift = require("downshift"), tsPattern = require("ts-pattern"), reactQuery = require("@tanstack/react-query"), useDebounce = require("use-debounce"), styled = require("styled-components"), react$1 = require("@iconify/react"), icons = require("@sanity/icons"), utils = require("@iconify/utils"), changeCase = require("change-case");
|
|
4
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
@@ -100,45 +100,95 @@ const OptionsWrapper = styled__default.default(ui.Box)`
|
|
|
100
100
|
function MessageWrapper({ children }) {
|
|
101
101
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { align: "center", muted: !0, children }) });
|
|
102
102
|
}
|
|
103
|
-
const SearchInput = react.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
SearchInput.displayName = "SearchInput";
|
|
118
|
-
const SearchResults = react.forwardRef((props, ref) => {
|
|
119
|
-
const { state, data, getItemProps, highlightedIndex, ...rest } = props;
|
|
120
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
121
|
-
(() => {
|
|
122
|
-
switch (state) {
|
|
123
|
-
case "initial":
|
|
124
|
-
return /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "Search for icons" });
|
|
125
|
-
case "loading":
|
|
126
|
-
return /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "Searching..." });
|
|
127
|
-
case "error":
|
|
128
|
-
return /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "Something went wrong..." });
|
|
129
|
-
case "empty":
|
|
130
|
-
return /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "No icons found" });
|
|
103
|
+
const SearchInput = react.memo(
|
|
104
|
+
react.forwardRef((props, ref) => {
|
|
105
|
+
const { selectedIcon, suffix, ...rest } = props;
|
|
106
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
107
|
+
ui.TextInput,
|
|
108
|
+
{
|
|
109
|
+
...rest,
|
|
110
|
+
ref,
|
|
111
|
+
inputMode: "search",
|
|
112
|
+
icon: selectedIcon ? /* @__PURE__ */ jsxRuntime.jsx(react$1.Icon, { icon: selectedIcon }) : null,
|
|
113
|
+
placeholder: selectedIcon ? "Search and replace selected icon..." : "Search for an icon...",
|
|
114
|
+
suffix
|
|
131
115
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
116
|
+
);
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
SearchInput.displayName = "SearchInput";
|
|
120
|
+
const SearchResults = react.memo(
|
|
121
|
+
react.forwardRef((props, ref) => {
|
|
122
|
+
const { state, data, getItemProps, highlightedIndex, ...rest } = props;
|
|
123
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
124
|
+
(() => {
|
|
125
|
+
switch (state) {
|
|
126
|
+
case "initial":
|
|
127
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "Search for icons" });
|
|
128
|
+
case "loading":
|
|
129
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "Searching..." });
|
|
130
|
+
case "error":
|
|
131
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "Something went wrong..." });
|
|
132
|
+
case "empty":
|
|
133
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "No icons found" });
|
|
134
|
+
}
|
|
135
|
+
})(),
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
137
|
+
"ul",
|
|
138
|
+
{
|
|
139
|
+
...rest,
|
|
140
|
+
ref,
|
|
141
|
+
"data-testid": "iconify-results",
|
|
142
|
+
style: { opacity: state === "stale" ? 0.5 : 1 },
|
|
143
|
+
children: (state === "data" || state === "stale") && data?.map((icon, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { ...getItemProps({ item: icon, index }), children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { padding: 3, mode: "bleed", selected: index === highlightedIndex, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Icon, { icon, width: "100%", height: "100%" }) }) }, icon))
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
] });
|
|
147
|
+
})
|
|
148
|
+
);
|
|
136
149
|
function UnsetButton(props) {
|
|
137
150
|
const { onUnset } = props;
|
|
138
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: !0, borderLeft: !1, padding: 1, display: "flex", radius: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
151
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: !0, borderLeft: !1, padding: 1, display: "flex", radius: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
152
|
+
ui.Button,
|
|
153
|
+
{
|
|
154
|
+
"data-testid": "iconify-unset",
|
|
155
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.TrashIcon, {}),
|
|
156
|
+
onClick: onUnset,
|
|
157
|
+
mode: "bleed",
|
|
158
|
+
fontSize: 1,
|
|
159
|
+
padding: 2
|
|
160
|
+
}
|
|
161
|
+
) });
|
|
139
162
|
}
|
|
140
|
-
|
|
141
|
-
const {
|
|
163
|
+
const IconifyCombobox = react.memo(function(props) {
|
|
164
|
+
const {
|
|
165
|
+
selectedIcon,
|
|
166
|
+
onSelect: pushSelection,
|
|
167
|
+
collections,
|
|
168
|
+
studioElementProps,
|
|
169
|
+
fieldFocused
|
|
170
|
+
} = props, id = react.useId(), toast = ui.useToast(), inputRef = react.useRef(null), composedInputRef = react.useCallback(
|
|
171
|
+
(node) => {
|
|
172
|
+
inputRef.current = node, studioElementProps?.ref && (studioElementProps.ref.current = node);
|
|
173
|
+
},
|
|
174
|
+
[studioElementProps?.ref]
|
|
175
|
+
), suppressNextBlur = react.useRef(!1), handleFocus = react.useCallback(
|
|
176
|
+
(event) => {
|
|
177
|
+
suppressNextBlur.current = !0, setTimeout(() => {
|
|
178
|
+
suppressNextBlur.current = !1;
|
|
179
|
+
}, 0), studioElementProps?.onFocus?.(event);
|
|
180
|
+
},
|
|
181
|
+
[studioElementProps]
|
|
182
|
+
), handleBlur = react.useCallback(
|
|
183
|
+
(event) => {
|
|
184
|
+
if (suppressNextBlur.current) {
|
|
185
|
+
suppressNextBlur.current = !1;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
studioElementProps?.onBlur?.(event);
|
|
189
|
+
},
|
|
190
|
+
[studioElementProps]
|
|
191
|
+
), { term, setTerm, debouncedTerm, isLoading, isError, error, data, isPreviousData } = useSearch({
|
|
142
192
|
collections
|
|
143
193
|
}), {
|
|
144
194
|
isOpen,
|
|
@@ -147,7 +197,8 @@ function IconifyCombobox(props) {
|
|
|
147
197
|
highlightedIndex,
|
|
148
198
|
getItemProps,
|
|
149
199
|
selectItem,
|
|
150
|
-
setInputValue
|
|
200
|
+
setInputValue,
|
|
201
|
+
closeMenu
|
|
151
202
|
} = downshift.useCombobox({
|
|
152
203
|
items: data ?? [],
|
|
153
204
|
inputValue: term,
|
|
@@ -157,21 +208,33 @@ function IconifyCombobox(props) {
|
|
|
157
208
|
onSelectedItemChange({ selectedItem }) {
|
|
158
209
|
selectedItem && (pushSelection(selectedItem), setTerm("", !0), setInputValue(""));
|
|
159
210
|
}
|
|
160
|
-
})
|
|
211
|
+
});
|
|
212
|
+
react.useEffect(() => {
|
|
213
|
+
fieldFocused || closeMenu();
|
|
214
|
+
}, [fieldFocused, closeMenu]);
|
|
215
|
+
const handleUnset = react.useCallback(() => {
|
|
161
216
|
pushSelection(""), setTerm("", !0), selectItem("");
|
|
162
|
-
}, []);
|
|
163
|
-
|
|
217
|
+
}, [pushSelection, setTerm, selectItem]);
|
|
218
|
+
react.useEffect(() => {
|
|
164
219
|
isError && (console.error("Iconify input error:", error), toast.push({
|
|
165
220
|
id,
|
|
166
221
|
status: "error",
|
|
167
222
|
title: "Iconify input error",
|
|
168
223
|
description: error?.message
|
|
169
224
|
}));
|
|
170
|
-
}, [error, id, isError, toast])
|
|
225
|
+
}, [error, id, isError, toast]);
|
|
226
|
+
const { onBlur: _downshiftOnBlur, ...inputProps } = getInputProps({
|
|
227
|
+
ref: composedInputRef,
|
|
228
|
+
id: studioElementProps?.id,
|
|
229
|
+
"aria-describedby": studioElementProps?.["aria-describedby"],
|
|
230
|
+
onFocus: handleFocus
|
|
231
|
+
});
|
|
232
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
171
233
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
172
234
|
SearchInput,
|
|
173
235
|
{
|
|
174
|
-
...
|
|
236
|
+
...inputProps,
|
|
237
|
+
onBlur: handleBlur,
|
|
175
238
|
selectedIcon,
|
|
176
239
|
suffix: selectedIcon ? /* @__PURE__ */ jsxRuntime.jsx(UnsetButton, { onUnset: handleUnset }) : null
|
|
177
240
|
}
|
|
@@ -199,8 +262,7 @@ function IconifyCombobox(props) {
|
|
|
199
262
|
}
|
|
200
263
|
)
|
|
201
264
|
] });
|
|
202
|
-
}
|
|
203
|
-
const queryClient = new reactQuery.QueryClient();
|
|
265
|
+
}), queryClient = new reactQuery.QueryClient();
|
|
204
266
|
function QueryClientProvider(props) {
|
|
205
267
|
return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClient, children: props.children });
|
|
206
268
|
}
|
|
@@ -217,25 +279,27 @@ function usePrettyIconName(props) {
|
|
|
217
279
|
[iconMeta, iconSetInfo.data?.name]
|
|
218
280
|
);
|
|
219
281
|
}
|
|
220
|
-
|
|
221
|
-
const { config, value, onChange: pushChange, schemaType } = props, selectedIcon = value?.name ?? null, options = schemaType.options, collections = !!options?.collections?.length && options.collections || !!config?.collections?.length && config.collections || null, showName = options?.showName ?? config?.showName ?? !1, handleSelect = react.useCallback(
|
|
282
|
+
const theme = theme$1.buildTheme(), IconifyInput = react.memo(function(props) {
|
|
283
|
+
const { config, value, onChange: pushChange, schemaType, elementProps, focused } = props, selectedIcon = value?.name ?? null, options = schemaType.options, collections = !!options?.collections?.length && options.collections || !!config?.collections?.length && config.collections || null, showName = options?.showName ?? config?.showName ?? !1, handleSelect = react.useCallback(
|
|
222
284
|
(icon) => {
|
|
223
285
|
pushChange(icon === "" ? sanity.unset() : sanity.set(icon, ["name"]));
|
|
224
286
|
},
|
|
225
287
|
[pushChange]
|
|
226
288
|
);
|
|
227
|
-
return /* @__PURE__ */ jsxRuntime.jsx(QueryClientProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.ThemeProvider, { theme
|
|
289
|
+
return /* @__PURE__ */ jsxRuntime.jsx(QueryClientProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.ThemeProvider, { theme, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
228
290
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
229
291
|
IconifyCombobox,
|
|
230
292
|
{
|
|
231
293
|
selectedIcon,
|
|
232
294
|
onSelect: handleSelect,
|
|
233
|
-
collections
|
|
295
|
+
collections,
|
|
296
|
+
studioElementProps: elementProps,
|
|
297
|
+
fieldFocused: focused
|
|
234
298
|
}
|
|
235
299
|
),
|
|
236
300
|
showName && selectedIcon ? /* @__PURE__ */ jsxRuntime.jsx(IconifyNameDisplay, { name: selectedIcon }) : null
|
|
237
301
|
] }) }) });
|
|
238
|
-
}
|
|
302
|
+
});
|
|
239
303
|
function IconifyNameDisplay(props) {
|
|
240
304
|
const { name } = props, prettyName = usePrettyIconName({ name });
|
|
241
305
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, children: [
|
|
@@ -247,10 +311,10 @@ function IconifyNameDisplay(props) {
|
|
|
247
311
|
] })
|
|
248
312
|
] });
|
|
249
313
|
}
|
|
250
|
-
|
|
314
|
+
const IconifyPreview = react.memo(function(props) {
|
|
251
315
|
const { title } = props, iconName = typeof props.title == "string" ? utils.stringToIcon(props.title) : null;
|
|
252
316
|
return typeof title == "string" && iconName ? /* @__PURE__ */ jsxRuntime.jsx(QueryClientProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(IconifyPreviewInner, { ...props, iconName: title, iconMeta: iconName }) }) : props.renderDefault(props);
|
|
253
|
-
}
|
|
317
|
+
});
|
|
254
318
|
function IconifyPreviewInner(props) {
|
|
255
319
|
const { iconMeta, iconName, ...previewProps } = props, prettyName = usePrettyIconName({ iconMeta });
|
|
256
320
|
return props.renderDefault({
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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 type { IconifyInfo } from '@iconify/types';\nimport { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useCallback, useState } from 'react';\nimport { useDebounce } from 'use-debounce';\nimport type { IconifySearchResult } from './types';\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 { isLoading, isError, error, data, isPlaceholderData } = 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 placeholderData: keepPreviousData,\n staleTime: 5 * 60 * 1000, // 5 minutes\n });\n\n return {\n term,\n setTerm: updateTerm,\n debouncedTerm,\n isLoading,\n isError,\n error,\n data,\n isPreviousData: isPlaceholderData,\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 type { 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: flex;\n flex-wrap: wrap;\n gap: 0.5rem;\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n & [role='option'] {\n display: grid;\n place-items: center;\n width: clamp(3rem, 10vw, 4rem);\n\n & button {\n cursor: pointer;\n width: 100%;\n\n & > [data-ui='Box'] {\n display: flex;\n }\n\n & svg {\n aspect-ratio: 1;\n }\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 { Icon } from '@iconify/react';\nimport { TextInput } from '@sanity/ui';\nimport { forwardRef } from 'react';\n\ninterface SearchInputProps extends React.HTMLAttributes<HTMLInputElement> {\n selectedIcon: string | null;\n suffix?: React.ReactNode;\n}\n\nexport const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>((props, ref) => {\n const { selectedIcon, suffix, ...rest } = props;\n\n return (\n <TextInput\n {...rest}\n ref={ref}\n inputMode=\"search\"\n icon={selectedIcon ? <Icon icon={selectedIcon} /> : null}\n placeholder={selectedIcon ? 'Search and replace selected icon...' : 'Search for an icon...'}\n suffix={suffix}\n />\n );\n});\n\nSearchInput.displayName = 'SearchInput';\n","import { Icon } from '@iconify/react';\nimport { Button } from '@sanity/ui';\nimport type { UseComboboxGetItemPropsOptions, UseComboboxGetItemPropsReturnValue } from 'downshift';\nimport { forwardRef } from 'react';\nimport { MessageWrapper } from './iconify-combobox.styles';\n\ntype GetItemProps = (\n options: UseComboboxGetItemPropsOptions<string>,\n) => UseComboboxGetItemPropsReturnValue;\n\nexport interface SearchResultsProps extends React.HTMLAttributes<HTMLUListElement> {\n state: 'initial' | 'loading' | 'error' | 'empty' | 'data' | 'stale';\n data?: string[];\n getItemProps: GetItemProps;\n highlightedIndex: number;\n}\n\nexport const SearchResults = forwardRef<HTMLUListElement, SearchResultsProps>((props, ref) => {\n const { state, data, getItemProps, highlightedIndex, ...rest } = props;\n\n return (\n <>\n {(() => {\n switch (state) {\n case 'initial':\n return <MessageWrapper>Search for icons</MessageWrapper>;\n case 'loading':\n return <MessageWrapper>Searching...</MessageWrapper>;\n case 'error':\n return <MessageWrapper>Something went wrong...</MessageWrapper>;\n case 'empty':\n return <MessageWrapper>No icons found</MessageWrapper>;\n }\n })()}\n\n <ul {...rest} ref={ref} style={{ opacity: state === 'stale' ? 0.5 : 1 }}>\n {(state === 'data' || state === 'stale') &&\n data?.map((icon, index) => (\n <li key={icon} {...getItemProps({ item: icon, index })}>\n <Button padding={3} mode=\"bleed\" selected={index === highlightedIndex}>\n <Icon icon={icon} width=\"100%\" height=\"100%\" />\n </Button>\n </li>\n ))}\n </ul>\n </>\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\" radius={2}>\n <Button icon={<TrashIcon />} onClick={onUnset} mode=\"bleed\" fontSize={1} padding={2} />\n </Card>\n );\n}\n","import { Popover, useToast } from '@sanity/ui';\nimport { useCombobox } from 'downshift';\nimport { useCallback, useEffect, useId, useRef } from 'react';\nimport { match } from 'ts-pattern';\nimport { useSearch } from '../lib/api';\nimport { OptionsWrapper } from './iconify-combobox.styles';\nimport { SearchInput } from './search-input';\nimport type { SearchResultsProps } from './search-result';\nimport { SearchResults } 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, isLoading, isError, error, data, isPreviousData } =\n useSearch({\n collections,\n });\n\n const {\n isOpen,\n getMenuProps,\n getInputProps,\n highlightedIndex,\n getItemProps,\n selectItem,\n setInputValue,\n } = useCombobox({\n items: data ?? [],\n inputValue: term,\n onInputValueChange({ inputValue, selectedItem }) {\n if (inputValue !== selectedItem) {\n setTerm(inputValue);\n }\n },\n onSelectedItemChange({ selectedItem }) {\n if (selectedItem) {\n pushSelection(selectedItem);\n setTerm('', true);\n setInputValue('');\n }\n },\n });\n\n const handleUnset = useCallback(() => {\n pushSelection('');\n setTerm('', true);\n selectItem('');\n }, []);\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 <div>\n {/* @ts-expect-error wrong typings */}\n <SearchInput\n {...getInputProps({ ref: inputRef })}\n selectedIcon={selectedIcon}\n suffix={selectedIcon ? <UnsetButton onUnset={handleUnset} /> : null}\n />\n\n <Popover\n open={true}\n style={{ display: isOpen ? 'block' : 'none' }}\n placement=\"bottom\"\n arrow={false}\n matchReferenceWidth\n constrainSize\n referenceElement={inputRef.current}\n content={\n <OptionsWrapper>\n <SearchResults\n {...getMenuProps()}\n state={match<boolean>(true)\n .returnType<SearchResultsProps['state']>()\n .with(isLoading, () => '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 getItemProps={getItemProps}\n highlightedIndex={highlightedIndex}\n />\n </OptionsWrapper>\n }\n />\n </div>\n );\n}\n","import {\n QueryClient,\n QueryClientProvider as ReactQueryClientProvider,\n} from '@tanstack/react-query';\nimport type { 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 type { IconifyIconName } from '@iconify/utils';\nimport { 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, Stack, Text, ThemeProvider } from '@sanity/ui';\nimport { buildTheme } from '@sanity/ui/theme';\nimport { useCallback } from 'react';\nimport type { ObjectInputProps } from 'sanity';\nimport { set, unset } from 'sanity';\nimport { IconifyCombobox } from './combobox';\nimport { QueryClientProvider } from './lib/query-client';\nimport type { IconifyPluginConfig, IconOptions } from './lib/types';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\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 handleSelect = useCallback(\n (icon: string) => {\n pushChange(icon === '' ? unset() : set(icon, ['name']));\n },\n [pushChange],\n );\n\n return (\n <QueryClientProvider>\n <ThemeProvider theme={buildTheme()}>\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\nexport function 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 type { IconifyIconName } from '@iconify/utils';\nimport { stringToIcon } from '@iconify/utils';\nimport type { PreviewProps } from 'sanity';\nimport { QueryClientProvider } from './lib/query-client';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\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 type { FieldProps, ObjectInputProps } from 'sanity';\nimport { definePlugin } from 'sanity';\nimport { IconifyInput } from './iconify-input';\nimport { IconifyPreview } from './iconify-preview';\nimport type { 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":["queryClient","useQueryClient","useState","useDebounce","useCallback","useQuery","keepPreviousData","styled","Grid","Box","jsx","Card","Text","forwardRef","TextInput","Icon","jsxs","Fragment","Button","TrashIcon","useId","useToast","useRef","useCombobox","useEffect","Popover","match","QueryClient","ReactQueryClientProvider","useMemo","stringToIcon","sentenceCase","unset","set","ThemeProvider","buildTheme","Stack","Flex","definePlugin"],"mappings":";;;;;;;AAMA,MAAM,eAAe;AAErB,SAAS,UAAa,EAAE,KAAK,UAAmE;AAC9F,SAAO,MAAM,KAAK,EAAE,OAAA,CAAQ,EACzB,KAAK,CAAC,aAAa;AAClB,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,yBAAyB,SAAS,MAAM,EAAE;AAG5D,WAAO,SAAS,KAAA;AAAA,EAClB,CAAC,EACA;AAAA,IACC,CAAC,WAAW;AAAA,IACZ,CAAC,UAAU;AACT,YAAI,iBAAiB,QACb,SAEN,QAAQ,MAAM,kBAAkB,KAAK,EAAE,GACjC,IAAI,MAAM,sBAAsB;AAAA,IAE1C;AAAA,EAAA;AAEN;AAEO,SAAS,UAAU,EAAE,eAAiD;AAC3E,QAAMA,eAAcC,WAAAA,kBACd,CAAC,MAAM,OAAO,IAAIC,MAAAA,SAAS,EAAE,GAC7B,CAAC,eAAe,gBAAgB,IAAIC,YAAAA,YAAY,MAAM,GAAG,GAEzD,aAAaC,MAAAA;AAAAA,IACjB,CAAC,SAAiB,oBAAoB,OAAU;AAC9C,cAAQ,OAAO,GAEX,qBACF,iBAAiB,OAAO;AAAA,IAE5B;AAAA,IACA,CAAC,gBAAgB;AAAA,EAAA,GAGb,EAAE,WAAW,SAAS,OAAO,MAAM,kBAAA,IAAsBC,oBAA0B;AAAA,IACvF,UAA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,CAAU,GACvE,IAIG,MAAM,cAAc,KAAK;AAClC;AAWA,SAAS,oBAAoB,OAAiC;AAC5D,QAAM,EAAE,UAAU,UAAU,GAAG,aAAA,IAAiB,OAC1C,aAAa,kBAAkB,EAAE,UAAU;AAEjD,SAAO,MAAM,cAAc;AAAA,IACzB,GAAG;AAAA,IACH,OAAOA,2BAAAA,IAACK,QAAAA,MAAA,EAAK,MAAM,SAAA,CAAU;AAAA,IAC7B,OAAO,YAAY,QAAQ;AAAA,IAC3B,UAAU,YAAY;AAAA,EAAA,CACvB;AACH;AC3BO,MAAM,UAAUuB,OAAAA,aAAyC,CAAC,SAAS,QACjE;AAAA,EACL,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,OAAO;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,OAAO;AAAA,QACP,MAAM;AAAA,QACN,QAAQ;AAAA,UACN;AAAA,YACE,MAAM;AAAA,YACN,OAAO;AAAA,YACP,MAAM;AAAA,UAAA;AAAA,QACR;AAAA,QAEF,YAAY;AAAA,UACV,OAAO,CAAC,yCAA6B,cAAA,EAAc,GAAG,OAAO,QAAiB;AAAA,UAC9E,SAAS;AAAA;AAAA,UAGT,OAAO,CAAC,UAAsB,MAAM,cAAc,EAAE,GAAG,OAAO,OAAO,EAAA,CAAG;AAAA,QAAA;AAAA,MAC1E;AAAA,IACF;AAAA,EACF;AAEJ,EACD;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","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 type { IconifyInfo } from '@iconify/types';\nimport { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useCallback, useState } from 'react';\nimport { useDebounce } from 'use-debounce';\nimport type { IconifySearchResult } from './types';\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 { isLoading, isError, error, data, isPlaceholderData } = 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 placeholderData: keepPreviousData,\n staleTime: 5 * 60 * 1000, // 5 minutes\n });\n\n return {\n term,\n setTerm: updateTerm,\n debouncedTerm,\n isLoading,\n isError,\n error,\n data,\n isPreviousData: isPlaceholderData,\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 type { 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: flex;\n flex-wrap: wrap;\n gap: 0.5rem;\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n & [role='option'] {\n display: grid;\n place-items: center;\n width: clamp(3rem, 10vw, 4rem);\n\n & button {\n cursor: pointer;\n width: 100%;\n\n & > [data-ui='Box'] {\n display: flex;\n }\n\n & svg {\n aspect-ratio: 1;\n }\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 { Icon } from '@iconify/react';\nimport { TextInput } from '@sanity/ui';\nimport { forwardRef, memo } from 'react';\n\ninterface SearchInputProps extends React.HTMLAttributes<HTMLInputElement> {\n selectedIcon: string | null;\n suffix?: React.ReactNode;\n}\n\nexport const SearchInput = memo(\n forwardRef<HTMLInputElement, SearchInputProps>((props, ref) => {\n const { selectedIcon, suffix, ...rest } = props;\n\n return (\n <TextInput\n {...rest}\n ref={ref}\n inputMode=\"search\"\n icon={selectedIcon ? <Icon icon={selectedIcon} /> : null}\n placeholder={selectedIcon ? 'Search and replace selected icon...' : 'Search for an icon...'}\n suffix={suffix}\n />\n );\n }),\n);\n\nSearchInput.displayName = 'SearchInput';\n","import { Icon } from '@iconify/react';\nimport { Button } from '@sanity/ui';\nimport type { UseComboboxGetItemPropsOptions, UseComboboxGetItemPropsReturnValue } from 'downshift';\nimport { forwardRef, memo } from 'react';\nimport { MessageWrapper } from './iconify-combobox.styles';\n\ntype GetItemProps = (\n options: UseComboboxGetItemPropsOptions<string>,\n) => UseComboboxGetItemPropsReturnValue;\n\nexport interface SearchResultsProps extends React.HTMLAttributes<HTMLUListElement> {\n state: 'initial' | 'loading' | 'error' | 'empty' | 'data' | 'stale';\n data?: string[];\n getItemProps: GetItemProps;\n highlightedIndex: number;\n}\n\nexport const SearchResults = memo(\n forwardRef<HTMLUListElement, SearchResultsProps>((props, ref) => {\n const { state, data, getItemProps, highlightedIndex, ...rest } = props;\n\n return (\n <>\n {(() => {\n switch (state) {\n case 'initial':\n return <MessageWrapper>Search for icons</MessageWrapper>;\n case 'loading':\n return <MessageWrapper>Searching...</MessageWrapper>;\n case 'error':\n return <MessageWrapper>Something went wrong...</MessageWrapper>;\n case 'empty':\n return <MessageWrapper>No icons found</MessageWrapper>;\n }\n })()}\n\n <ul\n {...rest}\n ref={ref}\n data-testid=\"iconify-results\"\n style={{ opacity: state === 'stale' ? 0.5 : 1 }}\n >\n {(state === 'data' || state === 'stale') &&\n data?.map((icon, index) => (\n <li key={icon} {...getItemProps({ item: icon, index })}>\n <Button padding={3} mode=\"bleed\" selected={index === highlightedIndex}>\n <Icon icon={icon} width=\"100%\" height=\"100%\" />\n </Button>\n </li>\n ))}\n </ul>\n </>\n );\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\" radius={2}>\n <Button\n data-testid=\"iconify-unset\"\n icon={<TrashIcon />}\n onClick={onUnset}\n mode=\"bleed\"\n fontSize={1}\n padding={2}\n />\n </Card>\n );\n}\n","import { Popover, useToast } from '@sanity/ui';\nimport { useCombobox } from 'downshift';\nimport { memo, useCallback, useEffect, useId, useRef } from 'react';\nimport type { ObjectInputProps } from 'sanity';\nimport { match } from 'ts-pattern';\nimport { useSearch } from '../lib/api';\nimport { OptionsWrapper } from './iconify-combobox.styles';\nimport { SearchInput } from './search-input';\nimport type { SearchResultsProps } from './search-result';\nimport { SearchResults } 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 studioElementProps?: ObjectInputProps['elementProps'];\n fieldFocused?: boolean;\n}\n\nexport const IconifyCombobox = memo(function IconifyCombobox(props: IconifyComboboxProps) {\n const {\n selectedIcon,\n onSelect: pushSelection,\n collections,\n studioElementProps,\n fieldFocused,\n } = props;\n\n const id = useId();\n const toast = useToast();\n const inputRef = useRef<HTMLInputElement>(null);\n\n // Compose our inputRef (used by the Popover for positioning) with Studio's focusRef.\n // Standard Sanity inputs spread all of elementProps onto the native element, which\n // lets Studio programmatically re-focus the field and track focus via onPathFocus/onPathBlur.\n const composedInputRef = useCallback(\n (node: HTMLInputElement | null) => {\n inputRef.current = node;\n if (studioElementProps?.ref) {\n (studioElementProps.ref as React.RefObject<HTMLInputElement | null>).current = node;\n }\n },\n [studioElementProps?.ref],\n );\n\n // Studio steals focus to its field-actions-trigger immediately after field activation, then\n // re-focuses the actual input — all within the same macrotask as the original focus event.\n // We suppress the onPathBlur for this activation blur so Studio's focused state stays accurate.\n // The flag is reset via setTimeout so any blur in a later macrotask (real user navigation) is\n // forwarded normally.\n const suppressNextBlur = useRef(false);\n\n const handleFocus = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n suppressNextBlur.current = true;\n setTimeout(() => {\n suppressNextBlur.current = false;\n }, 0);\n studioElementProps?.onFocus?.(event as unknown as React.FocusEvent<HTMLDivElement>);\n },\n [studioElementProps],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n if (suppressNextBlur.current) {\n suppressNextBlur.current = false;\n return;\n }\n studioElementProps?.onBlur?.(event as unknown as React.FocusEvent<HTMLDivElement>);\n },\n [studioElementProps],\n );\n\n const { term, setTerm, debouncedTerm, isLoading, isError, error, data, isPreviousData } =\n useSearch({\n collections,\n });\n\n const {\n isOpen,\n getMenuProps,\n getInputProps,\n highlightedIndex,\n getItemProps,\n selectItem,\n setInputValue,\n closeMenu,\n } = useCombobox({\n items: data ?? [],\n inputValue: term,\n onInputValueChange({ inputValue, selectedItem }) {\n if (inputValue !== selectedItem) {\n setTerm(inputValue);\n }\n },\n onSelectedItemChange({ selectedItem }) {\n if (selectedItem) {\n pushSelection(selectedItem);\n setTerm('', true);\n setInputValue('');\n }\n },\n });\n\n // Close the menu when Studio considers the field unfocused. This is the state→UI equivalent\n // of the old stateReducer: instead of intercepting downshift's blur handling imperatively,\n // we let Studio's focused state drive whether the menu should be open.\n useEffect(() => {\n if (!fieldFocused) closeMenu();\n }, [fieldFocused, closeMenu]);\n\n const handleUnset = useCallback(() => {\n pushSelection('');\n setTerm('', true);\n selectItem('');\n }, [pushSelection, setTerm, selectItem]);\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 // Destructure onBlur out so downshift's InputBlur doesn't close the menu —\n // menu lifecycle is now driven by fieldFocused via the effect above.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { onBlur: _downshiftOnBlur, ...inputProps } = getInputProps({\n ref: composedInputRef,\n id: studioElementProps?.id,\n 'aria-describedby': studioElementProps?.['aria-describedby'],\n onFocus: handleFocus,\n });\n\n return (\n <div>\n {/* @ts-expect-error wrong typings */}\n <SearchInput\n {...inputProps}\n onBlur={handleBlur}\n selectedIcon={selectedIcon}\n suffix={selectedIcon ? <UnsetButton onUnset={handleUnset} /> : null}\n />\n\n <Popover\n open={true}\n style={{ display: isOpen ? 'block' : 'none' }}\n placement=\"bottom\"\n arrow={false}\n matchReferenceWidth\n constrainSize\n referenceElement={inputRef.current}\n content={\n <OptionsWrapper>\n <SearchResults\n {...getMenuProps()}\n state={match<boolean>(true)\n .returnType<SearchResultsProps['state']>()\n .with(isLoading, () => '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 getItemProps={getItemProps}\n highlightedIndex={highlightedIndex}\n />\n </OptionsWrapper>\n }\n />\n </div>\n );\n});\n","import {\n QueryClient,\n QueryClientProvider as ReactQueryClientProvider,\n} from '@tanstack/react-query';\nimport type { 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 type { IconifyIconName } from '@iconify/utils';\nimport { 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, Stack, Text, ThemeProvider } from '@sanity/ui';\nimport { buildTheme } from '@sanity/ui/theme';\nimport { memo, useCallback } from 'react';\nimport type { ObjectInputProps } from 'sanity';\nimport { set, unset } from 'sanity';\nimport { IconifyCombobox } from './combobox';\nimport { QueryClientProvider } from './lib/query-client';\nimport type { IconifyPluginConfig, IconOptions } from './lib/types';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\n\nconst theme = buildTheme();\n\ninterface IconifyInputProps extends ObjectInputProps {\n config: IconifyPluginConfig;\n}\n\nexport const IconifyInput = memo(function IconifyInput(props: IconifyInputProps) {\n const { config, value, onChange: pushChange, schemaType, elementProps, focused } = 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 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 studioElementProps={elementProps}\n fieldFocused={focused}\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\nexport function 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 type { IconifyIconName } from '@iconify/utils';\nimport { stringToIcon } from '@iconify/utils';\nimport { memo } from 'react';\nimport type { PreviewProps } from 'sanity';\nimport { QueryClientProvider } from './lib/query-client';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\n\n// --------------- //\n// ICONIFY PREVIEW //\n// --------------- //\n\nexport const IconifyPreview = memo(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 type { FieldProps, ObjectInputProps } from 'sanity';\nimport { definePlugin } from 'sanity';\nimport { IconifyInput } from './iconify-input';\nimport { IconifyPreview } from './iconify-preview';\nimport type { 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":["queryClient","useQueryClient","useState","useDebounce","useCallback","useQuery","keepPreviousData","styled","Grid","Box","jsx","Card","Text","memo","forwardRef","TextInput","Icon","jsxs","Fragment","Button","TrashIcon","useId","useToast","useRef","useCombobox","useEffect","Popover","match","QueryClient","ReactQueryClientProvider","useMemo","stringToIcon","sentenceCase","buildTheme","unset","set","ThemeProvider","Stack","Flex","definePlugin"],"mappings":";;;;;;;AAMA,MAAM,eAAe;AAErB,SAAS,UAAa,EAAE,KAAK,UAAmE;AAC9F,SAAO,MAAM,KAAK,EAAE,OAAA,CAAQ,EACzB,KAAK,CAAC,aAAa;AAClB,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,yBAAyB,SAAS,MAAM,EAAE;AAG5D,WAAO,SAAS,KAAA;AAAA,EAClB,CAAC,EACA;AAAA,IACC,CAAC,WAAW;AAAA,IACZ,CAAC,UAAU;AACT,YAAI,iBAAiB,QACb,SAEN,QAAQ,MAAM,kBAAkB,KAAK,EAAE,GACjC,IAAI,MAAM,sBAAsB;AAAA,IAE1C;AAAA,EAAA;AAEN;AAEO,SAAS,UAAU,EAAE,eAAiD;AAC3E,QAAMA,eAAcC,WAAAA,kBACd,CAAC,MAAM,OAAO,IAAIC,MAAAA,SAAS,EAAE,GAC7B,CAAC,eAAe,gBAAgB,IAAIC,YAAAA,YAAY,MAAM,GAAG,GAEzD,aAAaC,MAAAA;AAAAA,IACjB,CAAC,SAAiB,oBAAoB,OAAU;AAC9C,cAAQ,OAAO,GAEX,qBACF,iBAAiB,OAAO;AAAA,IAE5B;AAAA,IACA,CAAC,gBAAgB;AAAA,EAAA,GAGb,EAAE,WAAW,SAAS,OAAO,MAAM,kBAAA,IAAsBC,oBAA0B;AAAA,IACvF,UAAU,CAAC,UAAU,aAAa,aAAa;AAAA,IAC/C,SAAS,OAAO,EAAE,aAAa;AAC7B,YAAM,MAAM,IAAI,IAAI,WAAW,YAAY;AAE3C,UAAI,aAAa,OAAO,SAAS,aAAa,GAC9C,IAAI,aAAa,OAAO,SAAS,IAAI,GAEjC,eACF,IAAI,aAAa,OAAO,YAAY,YAAY,KAAK,GAAG,CAAC;AAG3D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AAM,SAAA,CAAU;AAAA,IAC7B,OAAO,YAAY,QAAQ;AAAA,IAC3B,UAAU,YAAY;AAAA,EAAA,CACvB;AACH;AC5BO,MAAM,UAAUuB,OAAAA,aAAyC,CAAC,SAAS,QACjE;AAAA,EACL,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,OAAO;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,OAAO;AAAA,QACP,MAAM;AAAA,QACN,QAAQ;AAAA,UACN;AAAA,YACE,MAAM;AAAA,YACN,OAAO;AAAA,YACP,MAAM;AAAA,UAAA;AAAA,QACR;AAAA,QAEF,YAAY;AAAA,UACV,OAAO,CAAC,yCAA6B,cAAA,EAAc,GAAG,OAAO,QAAiB;AAAA,UAC9E,SAAS;AAAA;AAAA,UAGT,OAAO,CAAC,UAAsB,MAAM,cAAc,EAAE,GAAG,OAAO,OAAO,EAAA,CAAG;AAAA,QAAA;AAAA,MAC1E;AAAA,IACF;AAAA,EACF;AAEJ,EACD;;"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
import { BaseSchemaDefinition } from 'sanity';
|
|
2
|
+
import type { ConditionalPropertyCallbackContext } from 'sanity';
|
|
3
|
+
import type { FieldGroupDefinition } from 'sanity';
|
|
4
|
+
import type { FieldsetDefinition } from 'sanity';
|
|
5
|
+
import type { InitialValueProperty } from 'sanity';
|
|
6
|
+
import type { ObjectOptions } from 'sanity';
|
|
2
7
|
import { Plugin as Plugin_2 } from 'sanity';
|
|
8
|
+
import type { RuleDef } from 'sanity';
|
|
9
|
+
import type { ValidationBuilder } from 'sanity';
|
|
3
10
|
|
|
4
11
|
export { BaseSchemaDefinition };
|
|
5
12
|
|
|
13
|
+
export declare type IconConditionalProperty =
|
|
14
|
+
| boolean
|
|
15
|
+
| ((context: IconConditionalPropertyCallbackContext) => boolean)
|
|
16
|
+
| undefined;
|
|
17
|
+
|
|
18
|
+
export declare type IconConditionalPropertyCallbackContext = Omit<
|
|
19
|
+
ConditionalPropertyCallbackContext,
|
|
20
|
+
'value'
|
|
21
|
+
> & {
|
|
22
|
+
value: IconValue;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export declare interface IconDefinition extends Omit<BaseSchemaDefinition, 'hidden' | 'readOnly'> {
|
|
26
|
+
type: 'icon';
|
|
27
|
+
groups?: FieldGroupDefinition[];
|
|
28
|
+
fieldsets?: FieldsetDefinition[];
|
|
29
|
+
options?: IconOptions;
|
|
30
|
+
hidden?: IconConditionalProperty;
|
|
31
|
+
readOnly?: IconConditionalProperty;
|
|
32
|
+
validation?: ValidationBuilder<IconRule, IconValue>;
|
|
33
|
+
initialValue?: InitialValueProperty<any, IconValue>;
|
|
34
|
+
}
|
|
35
|
+
|
|
6
36
|
/**
|
|
7
37
|
* Usage in `sanity.config.ts` (or .js)
|
|
8
38
|
*
|
|
@@ -85,10 +115,10 @@ export declare interface IconifySearchResult {
|
|
|
85
115
|
collections: Record<string, IconifyInfo>;
|
|
86
116
|
}
|
|
87
117
|
|
|
88
|
-
export declare
|
|
118
|
+
export declare type IconOptions = {
|
|
89
119
|
collections?: IconPrefix[];
|
|
90
120
|
showName?: boolean;
|
|
91
|
-
}
|
|
121
|
+
} & Pick<ObjectOptions, 'collapsed' | 'collapsible'>;
|
|
92
122
|
|
|
93
123
|
export declare type IconPrefix =
|
|
94
124
|
| 'material-symbols'
|
|
@@ -158,6 +188,7 @@ export declare type IconPrefix =
|
|
|
158
188
|
| 'lsicon'
|
|
159
189
|
| 'gravity-ui'
|
|
160
190
|
| 'cil'
|
|
191
|
+
| 'roentgen'
|
|
161
192
|
| 'ep'
|
|
162
193
|
| 'charm'
|
|
163
194
|
| 'quill'
|
|
@@ -180,7 +211,6 @@ export declare type IconPrefix =
|
|
|
180
211
|
| 'radix-icons'
|
|
181
212
|
| 'zondicons'
|
|
182
213
|
| 'uiw'
|
|
183
|
-
| 'maki'
|
|
184
214
|
| 'codex'
|
|
185
215
|
| 'ei'
|
|
186
216
|
| 'heroicons'
|
|
@@ -197,6 +227,8 @@ export declare type IconPrefix =
|
|
|
197
227
|
| 'fa7-regular'
|
|
198
228
|
| 'picon'
|
|
199
229
|
| 'ooui'
|
|
230
|
+
| 'maki'
|
|
231
|
+
| 'temaki'
|
|
200
232
|
| 'oui'
|
|
201
233
|
| 'nrk'
|
|
202
234
|
| 'dinkie-icons'
|
|
@@ -310,13 +342,17 @@ export declare type IconPrefix =
|
|
|
310
342
|
| 'pepicons'
|
|
311
343
|
| 'fluent-emoji';
|
|
312
344
|
|
|
345
|
+
export declare interface IconRule extends RuleDef<IconRule, IconValue> {}
|
|
346
|
+
|
|
347
|
+
export declare type IconValue =
|
|
348
|
+
| {
|
|
349
|
+
name?: string;
|
|
350
|
+
}
|
|
351
|
+
| undefined;
|
|
352
|
+
|
|
313
353
|
export {};
|
|
314
354
|
|
|
315
355
|
declare module 'sanity' {
|
|
316
|
-
interface IconDefinition extends BaseSchemaDefinition {
|
|
317
|
-
type: 'icon';
|
|
318
|
-
options?: IconOptions;
|
|
319
|
-
}
|
|
320
356
|
interface IntrinsicDefinitions {
|
|
321
357
|
icon: IconDefinition;
|
|
322
358
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
import { BaseSchemaDefinition } from 'sanity';
|
|
2
|
+
import type { ConditionalPropertyCallbackContext } from 'sanity';
|
|
3
|
+
import type { FieldGroupDefinition } from 'sanity';
|
|
4
|
+
import type { FieldsetDefinition } from 'sanity';
|
|
5
|
+
import type { InitialValueProperty } from 'sanity';
|
|
6
|
+
import type { ObjectOptions } from 'sanity';
|
|
2
7
|
import { Plugin as Plugin_2 } from 'sanity';
|
|
8
|
+
import type { RuleDef } from 'sanity';
|
|
9
|
+
import type { ValidationBuilder } from 'sanity';
|
|
3
10
|
|
|
4
11
|
export { BaseSchemaDefinition };
|
|
5
12
|
|
|
13
|
+
export declare type IconConditionalProperty =
|
|
14
|
+
| boolean
|
|
15
|
+
| ((context: IconConditionalPropertyCallbackContext) => boolean)
|
|
16
|
+
| undefined;
|
|
17
|
+
|
|
18
|
+
export declare type IconConditionalPropertyCallbackContext = Omit<
|
|
19
|
+
ConditionalPropertyCallbackContext,
|
|
20
|
+
'value'
|
|
21
|
+
> & {
|
|
22
|
+
value: IconValue;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export declare interface IconDefinition extends Omit<BaseSchemaDefinition, 'hidden' | 'readOnly'> {
|
|
26
|
+
type: 'icon';
|
|
27
|
+
groups?: FieldGroupDefinition[];
|
|
28
|
+
fieldsets?: FieldsetDefinition[];
|
|
29
|
+
options?: IconOptions;
|
|
30
|
+
hidden?: IconConditionalProperty;
|
|
31
|
+
readOnly?: IconConditionalProperty;
|
|
32
|
+
validation?: ValidationBuilder<IconRule, IconValue>;
|
|
33
|
+
initialValue?: InitialValueProperty<any, IconValue>;
|
|
34
|
+
}
|
|
35
|
+
|
|
6
36
|
/**
|
|
7
37
|
* Usage in `sanity.config.ts` (or .js)
|
|
8
38
|
*
|
|
@@ -85,10 +115,10 @@ export declare interface IconifySearchResult {
|
|
|
85
115
|
collections: Record<string, IconifyInfo>;
|
|
86
116
|
}
|
|
87
117
|
|
|
88
|
-
export declare
|
|
118
|
+
export declare type IconOptions = {
|
|
89
119
|
collections?: IconPrefix[];
|
|
90
120
|
showName?: boolean;
|
|
91
|
-
}
|
|
121
|
+
} & Pick<ObjectOptions, 'collapsed' | 'collapsible'>;
|
|
92
122
|
|
|
93
123
|
export declare type IconPrefix =
|
|
94
124
|
| 'material-symbols'
|
|
@@ -158,6 +188,7 @@ export declare type IconPrefix =
|
|
|
158
188
|
| 'lsicon'
|
|
159
189
|
| 'gravity-ui'
|
|
160
190
|
| 'cil'
|
|
191
|
+
| 'roentgen'
|
|
161
192
|
| 'ep'
|
|
162
193
|
| 'charm'
|
|
163
194
|
| 'quill'
|
|
@@ -180,7 +211,6 @@ export declare type IconPrefix =
|
|
|
180
211
|
| 'radix-icons'
|
|
181
212
|
| 'zondicons'
|
|
182
213
|
| 'uiw'
|
|
183
|
-
| 'maki'
|
|
184
214
|
| 'codex'
|
|
185
215
|
| 'ei'
|
|
186
216
|
| 'heroicons'
|
|
@@ -197,6 +227,8 @@ export declare type IconPrefix =
|
|
|
197
227
|
| 'fa7-regular'
|
|
198
228
|
| 'picon'
|
|
199
229
|
| 'ooui'
|
|
230
|
+
| 'maki'
|
|
231
|
+
| 'temaki'
|
|
200
232
|
| 'oui'
|
|
201
233
|
| 'nrk'
|
|
202
234
|
| 'dinkie-icons'
|
|
@@ -310,13 +342,17 @@ export declare type IconPrefix =
|
|
|
310
342
|
| 'pepicons'
|
|
311
343
|
| 'fluent-emoji';
|
|
312
344
|
|
|
345
|
+
export declare interface IconRule extends RuleDef<IconRule, IconValue> {}
|
|
346
|
+
|
|
347
|
+
export declare type IconValue =
|
|
348
|
+
| {
|
|
349
|
+
name?: string;
|
|
350
|
+
}
|
|
351
|
+
| undefined;
|
|
352
|
+
|
|
313
353
|
export {};
|
|
314
354
|
|
|
315
355
|
declare module 'sanity' {
|
|
316
|
-
interface IconDefinition extends BaseSchemaDefinition {
|
|
317
|
-
type: 'icon';
|
|
318
|
-
options?: IconOptions;
|
|
319
|
-
}
|
|
320
356
|
interface IntrinsicDefinitions {
|
|
321
357
|
icon: IconDefinition;
|
|
322
358
|
}
|