@firecms/collection_editor 3.0.0-alpha.70 → 3.0.0-alpha.72
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.es.js +2041 -4017
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/ui/EditorCollectionAction.tsx +44 -32
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +3 -5
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +1 -1
- package/src/ui/collection_editor/PropertyEditView.tsx +0 -1
- package/src/ui/collection_editor/utils/strings.ts +1 -1
- package/dist/ui/collection_editor/SelectIcons.d.ts +0 -6
- package/dist/utils/icons.d.ts +0 -1
- package/dist/utils/synonyms.d.ts +0 -1951
- package/src/ui/collection_editor/SelectIcons.tsx +0 -72
- package/src/utils/icons.ts +0 -17
- package/src/utils/synonyms.ts +0 -1952
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import synonyms from "../../utils/synonyms";
|
|
3
|
-
import { iconsSearch } from "../../utils/icons";
|
|
4
|
-
import { coolIconKeys, debounce, Icon, IconButton, iconKeys, SearchBar, Tooltip } from "@firecms/ui";
|
|
5
|
-
|
|
6
|
-
const UPDATE_SEARCH_INDEX_WAIT_MS = 220;
|
|
7
|
-
|
|
8
|
-
if (process.env.NODE_ENV !== "production") {
|
|
9
|
-
Object.keys(synonyms).forEach((icon: string) => {
|
|
10
|
-
if (!iconKeys.includes(icon)) {
|
|
11
|
-
console.warn(`The icon ${icon} no longer exists. Remove it from \`synonyms\``);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface SearchIconsProps {
|
|
17
|
-
selectedIcon?: string;
|
|
18
|
-
onIconSelected: (icon: string) => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function SearchIcons({ selectedIcon = "", onIconSelected }: SearchIconsProps) {
|
|
22
|
-
const [keys, setKeys] = React.useState<string[] | null>(null);
|
|
23
|
-
const [query, setQuery] = React.useState<string>("");
|
|
24
|
-
|
|
25
|
-
const updateSearchResults = React.useMemo(() =>
|
|
26
|
-
debounce((value: string) => {
|
|
27
|
-
if (!value || value === "") {
|
|
28
|
-
setKeys(null);
|
|
29
|
-
} else {
|
|
30
|
-
const searchResult = iconsSearch.search(value);
|
|
31
|
-
setKeys(searchResult.map((e:any) => e.key));
|
|
32
|
-
}
|
|
33
|
-
}, UPDATE_SEARCH_INDEX_WAIT_MS), []
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
React.useEffect(() => {
|
|
37
|
-
updateSearchResults(query);
|
|
38
|
-
return () => {
|
|
39
|
-
updateSearchResults.clear();
|
|
40
|
-
};
|
|
41
|
-
}, [query, updateSearchResults]);
|
|
42
|
-
|
|
43
|
-
const icons = keys === null ? coolIconKeys : keys;
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<SearchBar
|
|
48
|
-
autoFocus
|
|
49
|
-
innerClassName={"w-full sticky top-0 z-10"}
|
|
50
|
-
onTextSearch={(value?: string) => setQuery(value ?? "")}
|
|
51
|
-
placeholder="Search for more icons…"
|
|
52
|
-
/>
|
|
53
|
-
|
|
54
|
-
<div className={"flex max-w-full flex-wrap mt-4"}>
|
|
55
|
-
{icons.map((icon: string) => {
|
|
56
|
-
return (
|
|
57
|
-
<Tooltip title={icon} key={icon}>
|
|
58
|
-
<IconButton
|
|
59
|
-
shape={"square"}
|
|
60
|
-
toggled={selectedIcon === icon}
|
|
61
|
-
onClick={() => onIconSelected(icon)}
|
|
62
|
-
className="box-content m-1"
|
|
63
|
-
>
|
|
64
|
-
<Icon iconKey={icon} size={24} />
|
|
65
|
-
</IconButton>
|
|
66
|
-
</Tooltip>
|
|
67
|
-
);
|
|
68
|
-
})}
|
|
69
|
-
</div>
|
|
70
|
-
</>
|
|
71
|
-
);
|
|
72
|
-
}
|
package/src/utils/icons.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import synonyms from "./synonyms";
|
|
2
|
-
import { iconKeys } from "@firecms/ui";
|
|
3
|
-
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import * as JsSearch from "js-search";
|
|
6
|
-
|
|
7
|
-
export const iconsSearch = new JsSearch.Search("key");
|
|
8
|
-
iconsSearch.addIndex("synonyms");
|
|
9
|
-
|
|
10
|
-
iconsSearch.addDocuments(iconKeys
|
|
11
|
-
.map((importName) => {
|
|
12
|
-
return {
|
|
13
|
-
key: importName,
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
synonyms: synonyms[importName] ?? [],
|
|
16
|
-
}
|
|
17
|
-
}));
|