sanity-plugin-iconify 1.1.0 → 1.1.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/LICENSE +1 -1
- package/dist/index.cjs +283 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +218 -0
- package/dist/index.d.ts +218 -0
- package/dist/index.js +291 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -42
- package/src/combobox/iconify-combobox.tsx +3 -2
- package/src/combobox/search-result.tsx +1 -0
- package/src/iconify-input.tsx +3 -2
- package/src/iconify-plugin.tsx +2 -1
- package/src/iconify-preview.tsx +3 -2
- package/src/lib/api.ts +7 -6
- package/src/lib/{generate-types.ts → generate-types.js} +2 -1
- package/src/lib/use-pretty-icon-name.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-iconify",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Icon picker based on Iconify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -16,18 +16,19 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"author": "Wannes Salomé <mail@wannessalome.nl>",
|
|
19
|
+
"sideEffects": true,
|
|
20
|
+
"type": "module",
|
|
19
21
|
"exports": {
|
|
20
22
|
".": {
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
22
23
|
"source": "./src/index.ts",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"default": "./dist/index.
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"require": "./dist/index.cjs",
|
|
26
|
+
"default": "./dist/index.js"
|
|
26
27
|
},
|
|
27
28
|
"./package.json": "./package.json"
|
|
28
29
|
},
|
|
29
|
-
"main": "./dist/index.
|
|
30
|
-
"module": "./dist/index.
|
|
30
|
+
"main": "./dist/index.cjs",
|
|
31
|
+
"module": "./dist/index.js",
|
|
31
32
|
"source": "./src/index.ts",
|
|
32
33
|
"types": "./dist/index.d.ts",
|
|
33
34
|
"files": [
|
|
@@ -44,63 +45,71 @@
|
|
|
44
45
|
"lint": "eslint .",
|
|
45
46
|
"prepublish-only": "run-s build",
|
|
46
47
|
"watch": "pkg-utils watch --strict",
|
|
47
|
-
"generate-types": "
|
|
48
|
+
"generate-types": "node src/lib/generate-types",
|
|
48
49
|
"prepare": "husky install"
|
|
49
50
|
},
|
|
51
|
+
"browserslist": "extends @sanity/browserslist-config",
|
|
50
52
|
"dependencies": {
|
|
51
|
-
"@headlessui/react": "^1.7.
|
|
53
|
+
"@headlessui/react": "^1.7.18",
|
|
52
54
|
"@iconify/react": "^4.1.1",
|
|
53
|
-
"@iconify/utils": "^2.1.
|
|
54
|
-
"@sanity/icons": "^2.4
|
|
55
|
+
"@iconify/utils": "^2.1.22",
|
|
56
|
+
"@sanity/icons": "^2.11.4",
|
|
55
57
|
"@sanity/incompatible-plugin": "^1.0.4",
|
|
56
|
-
"@sanity/ui": "^1.
|
|
57
|
-
"@tanstack/react-query": "^
|
|
58
|
-
"change-case": "^4.
|
|
59
|
-
"ts-pattern": "^5.0.
|
|
60
|
-
"use-debounce": "^
|
|
58
|
+
"@sanity/ui": "^1.9.3",
|
|
59
|
+
"@tanstack/react-query": "^5.28.6",
|
|
60
|
+
"change-case": "^5.4.3",
|
|
61
|
+
"ts-pattern": "^5.0.8",
|
|
62
|
+
"use-debounce": "^10.0.0"
|
|
61
63
|
},
|
|
62
64
|
"devDependencies": {
|
|
63
|
-
"@commitlint/cli": "^
|
|
64
|
-
"@commitlint/config-conventional": "^
|
|
65
|
-
"@commitlint/load": "^
|
|
66
|
-
"@iconify/json": "^2.2.
|
|
65
|
+
"@commitlint/cli": "^19.2.1",
|
|
66
|
+
"@commitlint/config-conventional": "^19.1.0",
|
|
67
|
+
"@commitlint/load": "^19.2.0",
|
|
68
|
+
"@iconify/json": "^2.2.195",
|
|
67
69
|
"@iconify/types": "^2.0.0",
|
|
68
|
-
"@sanity/pkg-utils": "^
|
|
70
|
+
"@sanity/pkg-utils": "^5.1.4",
|
|
69
71
|
"@sanity/plugin-kit": "^3.1.10",
|
|
70
|
-
"@sanity/semantic-release-preset": "^4.1.
|
|
71
|
-
"@tanstack/eslint-plugin-query": "^
|
|
72
|
-
"@tanstack/react-query-devtools": "^
|
|
73
|
-
"@types/react": "^18.2.
|
|
74
|
-
"@types/styled-components": "^5.1.
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
76
|
-
"@typescript-eslint/parser": "^
|
|
77
|
-
"eslint": "^8.
|
|
78
|
-
"eslint-config-prettier": "^9.
|
|
79
|
-
"eslint-config-sanity": "^
|
|
80
|
-
"eslint-plugin-prettier": "^5.
|
|
81
|
-
"eslint-plugin-react": "^7.
|
|
72
|
+
"@sanity/semantic-release-preset": "^4.1.7",
|
|
73
|
+
"@tanstack/eslint-plugin-query": "^5.28.6",
|
|
74
|
+
"@tanstack/react-query-devtools": "^5.28.6",
|
|
75
|
+
"@types/react": "^18.2.69",
|
|
76
|
+
"@types/styled-components": "^5.1.34",
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
|
78
|
+
"@typescript-eslint/parser": "^7.3.1",
|
|
79
|
+
"eslint": "^8.57.0",
|
|
80
|
+
"eslint-config-prettier": "^9.1.0",
|
|
81
|
+
"eslint-config-sanity": "^7.1.2",
|
|
82
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
83
|
+
"eslint-plugin-react": "^7.34.1",
|
|
82
84
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
83
|
-
"husky": "^
|
|
84
|
-
"lint-staged": "^
|
|
85
|
+
"husky": "^9.0.11",
|
|
86
|
+
"lint-staged": "^15.2.2",
|
|
85
87
|
"npm-run-all": "^4.1.5",
|
|
86
|
-
"prettier": "^3.
|
|
87
|
-
"prettier-plugin-packagejson": "^2.4.
|
|
88
|
+
"prettier": "^3.2.5",
|
|
89
|
+
"prettier-plugin-packagejson": "^2.4.12",
|
|
88
90
|
"react": "^18.2.0",
|
|
89
91
|
"react-dom": "^18.2.0",
|
|
90
92
|
"react-is": "^18.2.0",
|
|
91
|
-
"rimraf": "^5.0.
|
|
92
|
-
"sanity": "^3.
|
|
93
|
-
"
|
|
94
|
-
"typescript": "^5.2.2"
|
|
93
|
+
"rimraf": "^5.0.5",
|
|
94
|
+
"sanity": "^3.35.2",
|
|
95
|
+
"typescript": "^5.4.3"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
98
|
"react": "^18",
|
|
98
99
|
"sanity": "^3",
|
|
99
|
-
"styled-components": "^5"
|
|
100
|
+
"styled-components": "^5.2 || ^6"
|
|
100
101
|
},
|
|
101
102
|
"engines": {
|
|
102
103
|
"node": ">=14"
|
|
103
104
|
},
|
|
105
|
+
"pnpm": {
|
|
106
|
+
"overrides": {
|
|
107
|
+
"@babel/traverse@<7.23.2": ">=7.23.2",
|
|
108
|
+
"postcss@<8.4.31": ">=8.4.31",
|
|
109
|
+
"follow-redirects@<1.15.4": ">=1.15.4",
|
|
110
|
+
"follow-redirects@<=1.15.5": ">=1.15.6"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
104
113
|
"sanityPlugin": {
|
|
105
114
|
"verifyPackage": {
|
|
106
115
|
"scripts": false
|
|
@@ -2,6 +2,7 @@ import { Combobox } from '@headlessui/react';
|
|
|
2
2
|
import { Popover, useToast } from '@sanity/ui';
|
|
3
3
|
import { ChangeEventHandler, useCallback, useEffect, useId, useRef } from 'react';
|
|
4
4
|
import { match } from 'ts-pattern';
|
|
5
|
+
|
|
5
6
|
import { useSearch } from '../lib/api';
|
|
6
7
|
import { ComboboxWrapper, OptionsWrapper } from './iconify-combobox.styles';
|
|
7
8
|
import { SearchInput } from './search-input';
|
|
@@ -21,7 +22,7 @@ export function IconifyCombobox(props: IconifyComboboxProps) {
|
|
|
21
22
|
const toast = useToast();
|
|
22
23
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
23
24
|
|
|
24
|
-
const { term, setTerm, debouncedTerm,
|
|
25
|
+
const { term, setTerm, debouncedTerm, isLoading, isError, error, data, isPreviousData } =
|
|
25
26
|
useSearch({
|
|
26
27
|
collections,
|
|
27
28
|
});
|
|
@@ -79,7 +80,7 @@ export function IconifyCombobox(props: IconifyComboboxProps) {
|
|
|
79
80
|
<SearchResults
|
|
80
81
|
state={match<boolean>(true)
|
|
81
82
|
.returnType<SearchResultsProps['state']>()
|
|
82
|
-
.with(
|
|
83
|
+
.with(isLoading, () => 'loading')
|
|
83
84
|
.with(!debouncedTerm, () => 'initial')
|
|
84
85
|
.with(isError, () => 'error')
|
|
85
86
|
.with(!data || data.length === 0, () => 'empty')
|
package/src/iconify-input.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Flex, RootTheme, Stack, Text, ThemeProvider,
|
|
1
|
+
import { Flex, RootTheme, Stack, studioTheme, Text, ThemeProvider, useTheme } from '@sanity/ui';
|
|
2
2
|
import { useCallback, useMemo } from 'react';
|
|
3
3
|
import { ObjectInputProps, set, unset } from 'sanity';
|
|
4
|
+
|
|
4
5
|
import { IconifyCombobox } from './combobox';
|
|
5
6
|
import { QueryClientProvider } from './lib/query-client';
|
|
6
|
-
import {
|
|
7
|
+
import { IconifyPluginConfig, IconOptions } from './lib/types';
|
|
7
8
|
import { usePrettyIconName } from './lib/use-pretty-icon-name';
|
|
8
9
|
|
|
9
10
|
// -------------- //
|
package/src/iconify-plugin.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FieldProps, ObjectInputProps
|
|
1
|
+
import { definePlugin, FieldProps, ObjectInputProps } from 'sanity';
|
|
2
|
+
|
|
2
3
|
import { IconifyInput } from './iconify-input';
|
|
3
4
|
import { IconifyPreview } from './iconify-preview';
|
|
4
5
|
import { IconifyPluginConfig } from './lib/types';
|
package/src/iconify-preview.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Icon } from '@iconify/react';
|
|
2
|
-
import { PreviewProps } from 'sanity';
|
|
3
|
-
import { usePrettyIconName } from './lib/use-pretty-icon-name';
|
|
4
2
|
import { IconifyIconName, stringToIcon } from '@iconify/utils';
|
|
3
|
+
import { PreviewProps } from 'sanity';
|
|
4
|
+
|
|
5
5
|
import { QueryClientProvider } from './lib/query-client';
|
|
6
|
+
import { usePrettyIconName } from './lib/use-pretty-icon-name';
|
|
6
7
|
|
|
7
8
|
// --------------- //
|
|
8
9
|
// ICONIFY PREVIEW //
|
package/src/lib/api.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { IconifyInfo } from '@iconify/types';
|
|
2
|
-
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
3
|
-
import { IconifySearchResult } from './types';
|
|
2
|
+
import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
3
|
import { useCallback, useState } from 'react';
|
|
5
4
|
import { useDebounce } from 'use-debounce';
|
|
6
5
|
|
|
6
|
+
import { IconifySearchResult } from './types';
|
|
7
|
+
|
|
7
8
|
const BASE_API_URL = 'https://api.iconify.design';
|
|
8
9
|
|
|
9
10
|
function fetchJson<T>({ url, signal }: { url: string | URL; signal?: AbortSignal }): Promise<T> {
|
|
@@ -44,7 +45,7 @@ export function useSearch({ collections }: { collections: string[] | null }) {
|
|
|
44
45
|
[setDebouncedTerm],
|
|
45
46
|
);
|
|
46
47
|
|
|
47
|
-
const {
|
|
48
|
+
const { isLoading, isError, error, data, isPlaceholderData } = useQuery<string[], Error>({
|
|
48
49
|
queryKey: ['search', collections, debouncedTerm],
|
|
49
50
|
queryFn: async ({ signal }) => {
|
|
50
51
|
const url = new URL(`/search`, BASE_API_URL);
|
|
@@ -68,7 +69,7 @@ export function useSearch({ collections }: { collections: string[] | null }) {
|
|
|
68
69
|
return result?.icons ?? [];
|
|
69
70
|
},
|
|
70
71
|
enabled: debouncedTerm.length > 0,
|
|
71
|
-
|
|
72
|
+
placeholderData: keepPreviousData,
|
|
72
73
|
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
73
74
|
});
|
|
74
75
|
|
|
@@ -76,11 +77,11 @@ export function useSearch({ collections }: { collections: string[] | null }) {
|
|
|
76
77
|
term,
|
|
77
78
|
setTerm: updateTerm,
|
|
78
79
|
debouncedTerm,
|
|
79
|
-
|
|
80
|
+
isLoading,
|
|
80
81
|
isError,
|
|
81
82
|
error,
|
|
82
83
|
data,
|
|
83
|
-
isPreviousData,
|
|
84
|
+
isPreviousData: isPlaceholderData,
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
|