@synerise/ds-icon-picker 1.6.14 → 1.6.16
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/CHANGELOG.md +8 -0
- package/README.md +4 -4
- package/dist/IconPicker.const.js +6 -2
- package/dist/IconPicker.d.ts +2 -2
- package/dist/IconPicker.js +55 -96
- package/dist/IconPicker.styles.d.ts +14 -14
- package/dist/IconPicker.styles.js +41 -44
- package/dist/IconPicker.types.d.ts +3 -3
- package/dist/IconPicker.types.js +1 -1
- package/dist/_virtual/preload-helper.js +57 -0
- package/dist/components/List/List.d.ts +2 -2
- package/dist/components/List/List.js +33 -44
- package/dist/components/ListItem/ListItem.d.ts +3 -3
- package/dist/components/ListItem/ListItem.js +16 -29
- package/dist/components/ListItem/ListItem.types.d.ts +1 -1
- package/dist/components/ListItem/ListItem.types.js +1 -1
- package/dist/components/Overlay/Overlay.d.ts +3 -3
- package/dist/components/Overlay/Overlay.js +23 -31
- package/dist/components/Overlay/Overlay.types.d.ts +1 -1
- package/dist/components/Overlay/Overlay.types.js +1 -1
- package/dist/components/RowItem.d.ts +2 -2
- package/dist/components/RowItem.js +25 -28
- package/dist/hooks/useGroupItems.d.ts +1 -1
- package/dist/hooks/useGroupItems.js +19 -14
- package/dist/hooks/useIconSourceLoader.d.ts +1 -1
- package/dist/hooks/useIconSourceLoader.js +51 -91
- package/dist/index.js +4 -1
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils/createItemData.d.ts +1 -1
- package/dist/utils/createItemData.js +10 -9
- package/dist/utils/loadFontAwesome.d.ts +5 -5
- package/dist/utils/loadFontAwesome.js +35 -38
- package/dist/utils/matchesSearchQuery.js +5 -2
- package/dist/utils/prepareItems.d.ts +1 -1
- package/dist/utils/prepareItems.js +14 -12
- package/dist/utils/typeguards.utils.d.ts +1 -1
- package/dist/utils/typeguards.utils.js +14 -8
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.6.16](https://github.com/Synerise/synerise-design/compare/@synerise/ds-icon-picker@1.6.15...@synerise/ds-icon-picker@1.6.16) (2026-03-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-icon-picker
|
|
9
|
+
|
|
10
|
+
## [1.6.15](https://github.com/Synerise/synerise-design/compare/@synerise/ds-icon-picker@1.6.14...@synerise/ds-icon-picker@1.6.15) (2026-03-20)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-icon-picker
|
|
13
|
+
|
|
6
14
|
## [1.6.14](https://github.com/Synerise/synerise-design/compare/@synerise/ds-icon-picker@1.6.13...@synerise/ds-icon-picker@1.6.14) (2026-03-09)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-icon-picker
|
package/README.md
CHANGED
|
@@ -47,9 +47,9 @@ import IconPicker from '@synerise/ds-icon-picker'
|
|
|
47
47
|
| noResultMsg | Node displayed when no items matches searched query | ReactNode | - |
|
|
48
48
|
| onSelect | Action on icon select | OnSelectType | - |
|
|
49
49
|
| placeholder | Input placeholder | string | - |
|
|
50
|
-
| trigger | Trigger type
|
|
51
|
-
| onClear | Action on icon delete |
|
|
52
|
-
| selectedIcon | Icon Node |
|
|
53
|
-
| clearTooltip | tooltip text |
|
|
50
|
+
| trigger | Trigger type, e.g. `['click']` | PopoverTriggerType[] | - |
|
|
51
|
+
| onClear | Action on icon delete | () => void | - |
|
|
52
|
+
| selectedIcon | Icon Node | ReactNode | - |
|
|
53
|
+
| clearTooltip | tooltip text | ReactNode | - |
|
|
54
54
|
|
|
55
55
|
OnSelectType depends on the icon list source. For `design-system` or plain items provided as `DataSource[]` it is `(item: ReactNode) => void;`. For `font-awesome` it is `(item: [IconPrefix, IconName]) => void;`. See FontAwesome docs on how to use the IconPrefix and IconName to display an icon.
|
package/dist/IconPicker.const.js
CHANGED
package/dist/IconPicker.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IconPickerProps, SourceType } from './IconPicker.types';
|
|
3
3
|
declare const IconPicker: <IconSource extends SourceType>({ button, data, onSelect, trigger, placeholder, noResultMsg, onClear, selectedIcon, clearTooltip, }: IconPickerProps<IconSource>) => React.JSX.Element;
|
|
4
4
|
export default IconPicker;
|
package/dist/IconPicker.js
CHANGED
|
@@ -1,114 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import Button from
|
|
4
|
-
import ButtonGroup from
|
|
5
|
-
import Dropdown from
|
|
6
|
-
import Icon, { AddM, Close3S } from
|
|
7
|
-
import Tooltip from
|
|
8
|
-
import { useOnClickOutside } from
|
|
9
|
-
import
|
|
10
|
-
import Overlay from
|
|
11
|
-
import { useIconSourceLoader } from
|
|
12
|
-
import { matchesSearchQuery } from
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
isOpen = _useState3[0],
|
|
32
|
-
setOpen = _useState3[1];
|
|
33
|
-
var _useState4 = useState(false),
|
|
34
|
-
focus = _useState4[0],
|
|
35
|
-
setFocus = _useState4[1];
|
|
36
|
-
var ref = useRef(null);
|
|
37
|
-
useEffect(function () {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from "react";
|
|
3
|
+
import Button from "@synerise/ds-button";
|
|
4
|
+
import ButtonGroup from "@synerise/ds-button-group";
|
|
5
|
+
import Dropdown from "@synerise/ds-dropdown";
|
|
6
|
+
import Icon, { AddM, Close3S } from "@synerise/ds-icon";
|
|
7
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
8
|
+
import { useOnClickOutside } from "@synerise/ds-utils";
|
|
9
|
+
import { ClearIcon, Overlay } from "./IconPicker.styles.js";
|
|
10
|
+
import Overlay$1 from "./components/Overlay/Overlay.js";
|
|
11
|
+
import { useIconSourceLoader } from "./hooks/useIconSourceLoader.js";
|
|
12
|
+
import { matchesSearchQuery } from "./utils/matchesSearchQuery.js";
|
|
13
|
+
const IconPicker = ({
|
|
14
|
+
button,
|
|
15
|
+
data,
|
|
16
|
+
onSelect,
|
|
17
|
+
trigger,
|
|
18
|
+
placeholder,
|
|
19
|
+
noResultMsg,
|
|
20
|
+
onClear,
|
|
21
|
+
selectedIcon,
|
|
22
|
+
clearTooltip
|
|
23
|
+
}) => {
|
|
24
|
+
const items = useIconSourceLoader(data);
|
|
25
|
+
const [filteredItems, setFilteredItems] = useState(items);
|
|
26
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
27
|
+
const [isOpen, setOpen] = useState(false);
|
|
28
|
+
const [focus, setFocus] = useState(false);
|
|
29
|
+
const ref = useRef(null);
|
|
30
|
+
useEffect(() => {
|
|
38
31
|
if (searchQuery) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return _extends({}, group, {
|
|
32
|
+
const groups = items.map((group) => {
|
|
33
|
+
const matching = group.items.filter((icon) => icon.keywords && matchesSearchQuery(icon.keywords, searchQuery));
|
|
34
|
+
return {
|
|
35
|
+
...group,
|
|
44
36
|
items: matching
|
|
45
|
-
}
|
|
46
|
-
}).filter(
|
|
47
|
-
return group.items.length;
|
|
48
|
-
});
|
|
37
|
+
};
|
|
38
|
+
}).filter((group) => group.items.length);
|
|
49
39
|
setFilteredItems(groups);
|
|
50
40
|
return;
|
|
51
41
|
}
|
|
52
42
|
setFilteredItems(items);
|
|
53
43
|
}, [searchQuery, items]);
|
|
54
|
-
useOnClickOutside(ref,
|
|
44
|
+
useOnClickOutside(ref, () => {
|
|
55
45
|
setOpen(false);
|
|
56
|
-
setSearchQuery(
|
|
46
|
+
setSearchQuery("");
|
|
57
47
|
});
|
|
58
|
-
|
|
59
|
-
setSearchQuery(
|
|
48
|
+
const onClearInput = () => {
|
|
49
|
+
setSearchQuery("");
|
|
60
50
|
};
|
|
61
|
-
|
|
51
|
+
const toggleOpen = (newState) => {
|
|
62
52
|
setOpen(newState);
|
|
63
53
|
setFocus(newState);
|
|
64
54
|
};
|
|
65
|
-
|
|
55
|
+
const handleSelect = (value) => {
|
|
66
56
|
toggleOpen(false);
|
|
67
57
|
onSelect(value);
|
|
68
58
|
};
|
|
69
|
-
return
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
popoverProps: {
|
|
77
|
-
testId: 'icon-picker'
|
|
78
|
-
},
|
|
79
|
-
overlay: /*#__PURE__*/React.createElement(S.Overlay, {
|
|
80
|
-
ref: ref
|
|
81
|
-
}, /*#__PURE__*/React.createElement(Overlay, {
|
|
82
|
-
value: searchQuery,
|
|
83
|
-
onSearchChange: setSearchQuery,
|
|
84
|
-
onClearInput: onClearInput,
|
|
85
|
-
placeholder: placeholder,
|
|
86
|
-
data: filteredItems,
|
|
87
|
-
onSelect: handleSelect,
|
|
88
|
-
focus: focus,
|
|
89
|
-
noResultMsg: noResultMsg
|
|
90
|
-
}))
|
|
91
|
-
}, button || (!selectedIcon ? /*#__PURE__*/React.createElement(Button, {
|
|
92
|
-
type: "secondary",
|
|
93
|
-
mode: "icon-label"
|
|
94
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
95
|
-
component: /*#__PURE__*/React.createElement(AddM, null)
|
|
96
|
-
}), "Choose icon") : /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
|
|
97
|
-
onClick: function onClick() {
|
|
59
|
+
return /* @__PURE__ */ jsx(Dropdown, { open: isOpen, onOpenChange: toggleOpen, trigger, placement: "bottomRight", size: "auto", asChild: false, popoverProps: {
|
|
60
|
+
testId: "icon-picker"
|
|
61
|
+
}, overlay: /* @__PURE__ */ jsx(Overlay, { ref, children: /* @__PURE__ */ jsx(Overlay$1, { value: searchQuery, onSearchChange: setSearchQuery, onClearInput, placeholder, data: filteredItems, onSelect: handleSelect, focus, noResultMsg }) }), children: button || (!selectedIcon ? /* @__PURE__ */ jsxs(Button, { type: "secondary", mode: "icon-label", children: [
|
|
62
|
+
/* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(AddM, {}) }),
|
|
63
|
+
"Choose icon"
|
|
64
|
+
] }) : /* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
65
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => {
|
|
98
66
|
setOpen(!isOpen);
|
|
99
|
-
},
|
|
100
|
-
mode: "single-icon",
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
mode: "single-icon",
|
|
106
|
-
type: "secondary",
|
|
107
|
-
onClick: onClear
|
|
108
|
-
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
109
|
-
title: clearTooltip
|
|
110
|
-
}, /*#__PURE__*/React.createElement(S.ClearIcon, {
|
|
111
|
-
component: /*#__PURE__*/React.createElement(Close3S, null)
|
|
112
|
-
}))))));
|
|
67
|
+
}, mode: "single-icon", type: "secondary", children: /* @__PURE__ */ jsx(Icon, { component: selectedIcon }) }),
|
|
68
|
+
/* @__PURE__ */ jsx(Button, { mode: "single-icon", type: "secondary", onClick: onClear, children: /* @__PURE__ */ jsx(Tooltip, { title: clearTooltip, children: /* @__PURE__ */ jsx(ClearIcon, { component: /* @__PURE__ */ jsx(Close3S, {}) }) }) })
|
|
69
|
+
] })) });
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
IconPicker as default
|
|
113
73
|
};
|
|
114
|
-
export default IconPicker;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { FixedSizeList } from '
|
|
2
|
-
export declare const List: import(
|
|
3
|
-
export declare const ClearIcon: import(
|
|
4
|
-
export declare const ListItem: import(
|
|
1
|
+
import { FixedSizeList } from '../../../../config/vitest/__mocks__/reactWindowMock.js';
|
|
2
|
+
export declare const List: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const ClearIcon: import('styled-components').StyledComponent<import('react').ForwardRefExoticComponent<import('@synerise/ds-icon').BaseIconProps & Omit<import('react').HTMLAttributes<HTMLDivElement>, keyof import('@synerise/ds-icon').BaseIconProps> & import('@synerise/ds-utils').DataAttributes & import('react').RefAttributes<HTMLDivElement>>, any, {}, never>;
|
|
4
|
+
export declare const ListItem: import('styled-components').StyledComponent<"div", any, {
|
|
5
5
|
itemsPerRow: number;
|
|
6
6
|
}, never>;
|
|
7
|
-
export declare const OverlayWrapper: import(
|
|
8
|
-
export declare const VirtualList: import(
|
|
7
|
+
export declare const OverlayWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const VirtualList: import('styled-components').StyledComponent<typeof FixedSizeList, any, {
|
|
9
9
|
listHeight: number;
|
|
10
10
|
}, never>;
|
|
11
|
-
export declare const Overlay: import(
|
|
12
|
-
export declare const Title: import(
|
|
11
|
+
export declare const Overlay: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
12
|
+
export declare const Title: import('styled-components').StyledComponent<"div", any, {
|
|
13
13
|
elementSize: string;
|
|
14
14
|
}, never>;
|
|
15
|
-
export declare const FontIcon: import(
|
|
16
|
-
export declare const IconTrigger: import(
|
|
17
|
-
export declare const NoResults: import(
|
|
18
|
-
export declare const Content: import(
|
|
19
|
-
export declare const ListRow: import(
|
|
20
|
-
export declare const NoResultIcon: import(
|
|
15
|
+
export declare const FontIcon: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
16
|
+
export declare const IconTrigger: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
17
|
+
export declare const NoResults: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
18
|
+
export declare const Content: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
19
|
+
export declare const ListRow: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
20
|
+
export declare const NoResultIcon: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -1,77 +1,74 @@
|
|
|
1
|
-
import { FixedSizeList } from
|
|
2
|
-
import styled from
|
|
3
|
-
import Icon from
|
|
4
|
-
|
|
1
|
+
import { FixedSizeList } from "react-window";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import Icon from "@synerise/ds-icon";
|
|
4
|
+
const List = /* @__PURE__ */ styled.div.withConfig({
|
|
5
5
|
displayName: "IconPickerstyles__List",
|
|
6
6
|
componentId: "sc-iun0xm-0"
|
|
7
7
|
})(["display:flex;flex-wrap:wrap;"]);
|
|
8
|
-
|
|
8
|
+
const ClearIcon = /* @__PURE__ */ styled(Icon).withConfig({
|
|
9
9
|
displayName: "IconPickerstyles__ClearIcon",
|
|
10
10
|
componentId: "sc-iun0xm-1"
|
|
11
|
-
})(["&&&&&,&&&&&:hover{svg{color:", ";fill:", ";}}"],
|
|
12
|
-
|
|
13
|
-
}, function (props) {
|
|
14
|
-
return props.theme.palette['red-600'];
|
|
15
|
-
});
|
|
16
|
-
export var ListItem = styled.div.withConfig({
|
|
11
|
+
})(["&&&&&,&&&&&:hover{svg{color:", ";fill:", ";}}"], (props) => props.theme.palette["red-600"], (props) => props.theme.palette["red-600"]);
|
|
12
|
+
const ListItem = /* @__PURE__ */ styled.div.withConfig({
|
|
17
13
|
displayName: "IconPickerstyles__ListItem",
|
|
18
14
|
componentId: "sc-iun0xm-2"
|
|
19
|
-
})(["display:flex;width:", "%;align-items:center;justify-content:center;button{transition-duration:0s;}"],
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
export var OverlayWrapper = styled.div.withConfig({
|
|
15
|
+
})(["display:flex;width:", "%;align-items:center;justify-content:center;button{transition-duration:0s;}"], (props) => 100 / props.itemsPerRow);
|
|
16
|
+
const OverlayWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
23
17
|
displayName: "IconPickerstyles__OverlayWrapper",
|
|
24
18
|
componentId: "sc-iun0xm-3"
|
|
25
19
|
})(["padding:6px;"]);
|
|
26
|
-
|
|
20
|
+
const VirtualList = /* @__PURE__ */ styled(FixedSizeList).withConfig({
|
|
27
21
|
displayName: "IconPickerstyles__VirtualList",
|
|
28
22
|
componentId: "sc-iun0xm-4"
|
|
29
|
-
})(["max-height:", "px;height:auto !important;overflow-x:unset !important;overflow-y:unset !important;"],
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
export var Overlay = styled.span.withConfig({
|
|
23
|
+
})(["max-height:", "px;height:auto !important;overflow-x:unset !important;overflow-y:unset !important;"], (props) => props.listHeight);
|
|
24
|
+
const Overlay = /* @__PURE__ */ styled.span.withConfig({
|
|
33
25
|
displayName: "IconPickerstyles__Overlay",
|
|
34
26
|
componentId: "sc-iun0xm-5"
|
|
35
|
-
})(["width:250px;background-color:", ";position:relative;display:block;border-radius:3px;", ":not(:last-child){&::after{content:'';display:flex;width:calc(100% - 6px);height:1px;background-image:linear-gradient( to right,", " 40%,", " 100%,transparent 0% );background-position:0 bottom;background-size:4px 1px;background-repeat:repeat-x;margin:4px auto 0;}}", ":first-child{padding-top:16px;}"],
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var theme = _ref2.theme;
|
|
42
|
-
return theme.palette['grey-300'];
|
|
43
|
-
}, OverlayWrapper);
|
|
44
|
-
export var Title = styled.div.withConfig({
|
|
27
|
+
})(["width:250px;background-color:", ";position:relative;display:block;border-radius:3px;", ":not(:last-child){&::after{content:'';display:flex;width:calc(100% - 6px);height:1px;background-image:linear-gradient( to right,", " 40%,", " 100%,transparent 0% );background-position:0 bottom;background-size:4px 1px;background-repeat:repeat-x;margin:4px auto 0;}}", ":first-child{padding-top:16px;}"], (props) => props.theme.palette.white, OverlayWrapper, ({
|
|
28
|
+
theme
|
|
29
|
+
}) => theme.palette.white, ({
|
|
30
|
+
theme
|
|
31
|
+
}) => theme.palette["grey-300"], OverlayWrapper);
|
|
32
|
+
const Title = /* @__PURE__ */ styled.div.withConfig({
|
|
45
33
|
displayName: "IconPickerstyles__Title",
|
|
46
34
|
componentId: "sc-iun0xm-6"
|
|
47
|
-
})(["font-size:10px;line-height:1.6;font-weight:500;text-transform:uppercase;color:", ";padding:0 12px;flex-basis:100%;height:", ";line-height:", ";"],
|
|
48
|
-
|
|
49
|
-
}, function (props) {
|
|
50
|
-
return props.elementSize;
|
|
51
|
-
}, function (props) {
|
|
52
|
-
return props.elementSize;
|
|
53
|
-
});
|
|
54
|
-
export var FontIcon = styled.div.withConfig({
|
|
35
|
+
})(["font-size:10px;line-height:1.6;font-weight:500;text-transform:uppercase;color:", ";padding:0 12px;flex-basis:100%;height:", ";line-height:", ";"], (props) => props.theme.palette["grey-500"], (props) => props.elementSize, (props) => props.elementSize);
|
|
36
|
+
const FontIcon = /* @__PURE__ */ styled.div.withConfig({
|
|
55
37
|
displayName: "IconPickerstyles__FontIcon",
|
|
56
38
|
componentId: "sc-iun0xm-7"
|
|
57
39
|
})(["font-family:'apple color emoji,segoe ui emoji,noto color emoji,android emoji,emojisymbols,emojione mozilla,twemoji mozilla,segoe ui symbol';font-size:18px;line-height:35px;"]);
|
|
58
|
-
|
|
40
|
+
const IconTrigger = /* @__PURE__ */ styled.div.withConfig({
|
|
59
41
|
displayName: "IconPickerstyles__IconTrigger",
|
|
60
42
|
componentId: "sc-iun0xm-8"
|
|
61
43
|
})(["display:inline-block;cursor:pointer;&&&{.icon-wrapper{display:flex;pointer-events:none;svg{fill:currentColor;}}}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:144dpi){letter-spacing:-0.2em;}"]);
|
|
62
|
-
|
|
44
|
+
const NoResults = /* @__PURE__ */ styled.div.withConfig({
|
|
63
45
|
displayName: "IconPickerstyles__NoResults",
|
|
64
46
|
componentId: "sc-iun0xm-9"
|
|
65
47
|
})(["min-height:206px;display:flex;justify-content:center;"]);
|
|
66
|
-
|
|
48
|
+
const Content = /* @__PURE__ */ styled.div.withConfig({
|
|
67
49
|
displayName: "IconPickerstyles__Content",
|
|
68
50
|
componentId: "sc-iun0xm-10"
|
|
69
51
|
})(["margin-top:42px;p{margin-top:16px;font-size:14px;line-height:1.43;text-align:center;}"]);
|
|
70
|
-
|
|
52
|
+
const ListRow = /* @__PURE__ */ styled.div.withConfig({
|
|
71
53
|
displayName: "IconPickerstyles__ListRow",
|
|
72
54
|
componentId: "sc-iun0xm-11"
|
|
73
55
|
})(["display:flex;flex-wrap:wrap;justify-content:flex-start;align-items:center;box-sizing:border-box;width:100%;height:100%;max-width:100%;"]);
|
|
74
|
-
|
|
56
|
+
const NoResultIcon = /* @__PURE__ */ styled.div.withConfig({
|
|
75
57
|
displayName: "IconPickerstyles__NoResultIcon",
|
|
76
58
|
componentId: "sc-iun0xm-12"
|
|
77
|
-
})(["width:40px;height:40px;background:rgba(148,158,166,0.05);border-radius:50%;display:flex;align-items:center;justify-content:center;margin:0 auto;"]);
|
|
59
|
+
})(["width:40px;height:40px;background:rgba(148,158,166,0.05);border-radius:50%;display:flex;align-items:center;justify-content:center;margin:0 auto;"]);
|
|
60
|
+
export {
|
|
61
|
+
ClearIcon,
|
|
62
|
+
Content,
|
|
63
|
+
FontIcon,
|
|
64
|
+
IconTrigger,
|
|
65
|
+
List,
|
|
66
|
+
ListItem,
|
|
67
|
+
ListRow,
|
|
68
|
+
NoResultIcon,
|
|
69
|
+
NoResults,
|
|
70
|
+
Overlay,
|
|
71
|
+
OverlayWrapper,
|
|
72
|
+
Title,
|
|
73
|
+
VirtualList
|
|
74
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { IconName, IconPrefix } from '@fortawesome/fontawesome-svg-core';
|
|
3
|
+
import { PopoverTriggerType } from '@synerise/ds-popover';
|
|
4
4
|
export type FilterItem<ValueType extends FAValue | ReactNode> = {
|
|
5
5
|
keywords?: string;
|
|
6
6
|
value: ValueType;
|
package/dist/IconPicker.types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const scriptRel = "modulepreload";
|
|
2
|
+
const assetsURL = function(dep) {
|
|
3
|
+
return "/" + dep;
|
|
4
|
+
};
|
|
5
|
+
const seen = {};
|
|
6
|
+
const __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
7
|
+
let promise = Promise.resolve();
|
|
8
|
+
if (deps && deps.length > 0) {
|
|
9
|
+
let allSettled = function(promises$2) {
|
|
10
|
+
return Promise.all(promises$2.map((p) => Promise.resolve(p).then((value$1) => ({
|
|
11
|
+
status: "fulfilled",
|
|
12
|
+
value: value$1
|
|
13
|
+
}), (reason) => ({
|
|
14
|
+
status: "rejected",
|
|
15
|
+
reason
|
|
16
|
+
}))));
|
|
17
|
+
};
|
|
18
|
+
document.getElementsByTagName("link");
|
|
19
|
+
const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
|
|
20
|
+
const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute("nonce");
|
|
21
|
+
promise = allSettled(deps.map((dep) => {
|
|
22
|
+
dep = assetsURL(dep);
|
|
23
|
+
if (dep in seen) return;
|
|
24
|
+
seen[dep] = true;
|
|
25
|
+
const isCss = dep.endsWith(".css");
|
|
26
|
+
const cssSelector = isCss ? '[rel="stylesheet"]' : "";
|
|
27
|
+
if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) return;
|
|
28
|
+
const link = document.createElement("link");
|
|
29
|
+
link.rel = isCss ? "stylesheet" : scriptRel;
|
|
30
|
+
if (!isCss) link.as = "script";
|
|
31
|
+
link.crossOrigin = "";
|
|
32
|
+
link.href = dep;
|
|
33
|
+
if (cspNonce) link.setAttribute("nonce", cspNonce);
|
|
34
|
+
document.head.appendChild(link);
|
|
35
|
+
if (isCss) return new Promise((res, rej) => {
|
|
36
|
+
link.addEventListener("load", res);
|
|
37
|
+
link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`)));
|
|
38
|
+
});
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
function handlePreloadError(err$2) {
|
|
42
|
+
const e$1 = new Event("vite:preloadError", { cancelable: true });
|
|
43
|
+
e$1.payload = err$2;
|
|
44
|
+
window.dispatchEvent(e$1);
|
|
45
|
+
if (!e$1.defaultPrevented) throw err$2;
|
|
46
|
+
}
|
|
47
|
+
return promise.then((res) => {
|
|
48
|
+
for (const item of res || []) {
|
|
49
|
+
if (item.status !== "rejected") continue;
|
|
50
|
+
handlePreloadError(item.reason);
|
|
51
|
+
}
|
|
52
|
+
return baseModule().catch(handlePreloadError);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
__vitePreload
|
|
57
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ListProps, SourceType } from '../../IconPicker.types';
|
|
3
3
|
declare const List: <Source extends SourceType>({ data, onSelect, noResultMsg, }: ListProps<Source>) => React.JSX.Element;
|
|
4
4
|
export default List;
|
|
@@ -1,49 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { FormattedMessage } from "react-intl";
|
|
4
|
+
import { useTheme } from "@synerise/ds-core";
|
|
5
|
+
import Icon, { SearchNoResultsM } from "@synerise/ds-icon";
|
|
6
|
+
import Scrollbar from "@synerise/ds-scrollbar";
|
|
7
|
+
import { ITEMS_PER_ROW, ELEMENT_HEIGHT } from "../../IconPicker.const.js";
|
|
8
|
+
import { OverlayWrapper, NoResults, Content, NoResultIcon, VirtualList } from "../../IconPicker.styles.js";
|
|
9
|
+
import { useGroupItems } from "../../hooks/useGroupItems.js";
|
|
10
|
+
import { createItemData } from "../../utils/createItemData.js";
|
|
11
|
+
import { RowItem } from "../RowItem.js";
|
|
12
|
+
const List = ({
|
|
13
|
+
data,
|
|
14
|
+
onSelect,
|
|
15
|
+
noResultMsg = /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.ICON-PICKER.NO-RESULTS" })
|
|
16
|
+
}) => {
|
|
17
|
+
const theme = useTheme();
|
|
18
|
+
const groupedData = useGroupItems(data, ITEMS_PER_ROW);
|
|
19
|
+
const listRef = useRef(null);
|
|
20
|
+
const handleScroll = ({
|
|
21
|
+
currentTarget
|
|
22
|
+
}) => {
|
|
23
|
+
const {
|
|
24
|
+
scrollTop
|
|
25
|
+
} = currentTarget;
|
|
24
26
|
if (listRef.current) {
|
|
25
27
|
listRef.current.scrollTo(scrollTop);
|
|
26
28
|
}
|
|
27
29
|
};
|
|
28
|
-
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
color: theme.palette['grey-600']
|
|
37
|
-
})), /*#__PURE__*/React.createElement("p", null, noResultMsg)))) : /*#__PURE__*/React.createElement(S.VirtualList, {
|
|
38
|
-
listHeight: 330,
|
|
39
|
-
ref: listRef,
|
|
40
|
-
height: 330,
|
|
41
|
-
itemCount: groupedData.length,
|
|
42
|
-
itemData: itemData,
|
|
43
|
-
itemSize: ELEMENT_HEIGHT,
|
|
44
|
-
width: "100%"
|
|
45
|
-
}, function (props) {
|
|
46
|
-
return /*#__PURE__*/React.createElement(RowItem, props);
|
|
47
|
-
}));
|
|
30
|
+
const itemData = createItemData(groupedData, ELEMENT_HEIGHT, onSelect, ITEMS_PER_ROW);
|
|
31
|
+
return /* @__PURE__ */ jsx(Scrollbar, { absolute: true, "data-testid": "icon-list", maxHeight: 330, onScroll: handleScroll, children: !data.length ? /* @__PURE__ */ jsx(OverlayWrapper, { children: /* @__PURE__ */ jsx(NoResults, { children: /* @__PURE__ */ jsxs(Content, { children: [
|
|
32
|
+
/* @__PURE__ */ jsx(NoResultIcon, { children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(SearchNoResultsM, {}), color: theme.palette["grey-600"] }) }),
|
|
33
|
+
/* @__PURE__ */ jsx("p", { children: noResultMsg })
|
|
34
|
+
] }) }) }) : /* @__PURE__ */ jsx(VirtualList, { listHeight: 330, ref: listRef, height: 330, itemCount: groupedData.length, itemData, itemSize: ELEMENT_HEIGHT, width: "100%", children: (props) => /* @__PURE__ */ jsx(RowItem, { ...props }) }) });
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
List as default
|
|
48
38
|
};
|
|
49
|
-
export default List;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SourceType } from '../../IconPicker.types';
|
|
3
|
+
import { ListItemProps } from './ListItem.types';
|
|
4
4
|
declare const ListItem: <Source extends SourceType>({ element, index, onSelect, itemsPerRow, }: ListItemProps<Source>) => React.JSX.Element;
|
|
5
5
|
export default ListItem;
|
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Button from
|
|
3
|
-
import Tooltip from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import Button from "@synerise/ds-button";
|
|
3
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
4
|
+
import { ListItem as ListItem$1, IconTrigger, FontIcon } from "../../IconPicker.styles.js";
|
|
5
|
+
const ListItem = ({
|
|
6
|
+
element,
|
|
7
|
+
index,
|
|
8
|
+
onSelect,
|
|
9
|
+
itemsPerRow
|
|
10
|
+
}) => {
|
|
11
|
+
const selectIcon = () => {
|
|
11
12
|
onSelect(element.value);
|
|
12
13
|
};
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
onMouseUp: selectIcon,
|
|
19
|
-
"data-testid": "icon-" + index
|
|
20
|
-
}, element.item) : /*#__PURE__*/React.createElement(Tooltip, {
|
|
21
|
-
title: element.keywords
|
|
22
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
23
|
-
type: "ghost",
|
|
24
|
-
mode: "single-icon",
|
|
25
|
-
onClick: selectIcon
|
|
26
|
-
}, /*#__PURE__*/React.createElement(S.IconTrigger, {
|
|
27
|
-
"data-testid": "icon-" + index
|
|
28
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
29
|
-
className: "icon-wrapper"
|
|
30
|
-
}, typeof element.item === 'string' ? /*#__PURE__*/React.createElement(S.FontIcon, null, element.item) : element.item)))));
|
|
14
|
+
return /* @__PURE__ */ jsx(ListItem$1, { itemsPerRow, children: typeof element.item !== "string" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
element.item.type.name === "Avatar" ? /* @__PURE__ */ jsx(IconTrigger, { onMouseUp: selectIcon, "data-testid": `icon-${index}`, children: element.item }) : /* @__PURE__ */ jsx(Tooltip, { title: element.keywords, children: /* @__PURE__ */ jsx(Button, { type: "ghost", mode: "single-icon", onClick: selectIcon, children: /* @__PURE__ */ jsx(IconTrigger, { "data-testid": `icon-${index}`, children: /* @__PURE__ */ jsx("div", { className: "icon-wrapper", children: typeof element.item === "string" ? /* @__PURE__ */ jsx(FontIcon, { children: element.item }) : element.item }) }) }) }) });
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
ListItem as default
|
|
31
19
|
};
|
|
32
|
-
export default ListItem;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FilterItem, ListProps, SourceType, ValueTypeForSource } from '../../IconPicker.types';
|
|
2
2
|
export type ListItemProps<Source extends SourceType> = {
|
|
3
3
|
element: FilterItem<ValueTypeForSource<Source>>;
|
|
4
4
|
index: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|