@choice-ui/react 1.9.0 → 1.9.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/components/button/dist/index.js +7 -0
- package/dist/components/checkbox/dist/index.d.ts +10 -1
- package/dist/components/checkbox/dist/index.js +49 -5
- package/dist/components/colors/dist/index.d.ts +39 -6
- package/dist/components/colors/src/color-gradients-paint/color-gradient-combined.js +1 -4
- package/dist/components/colors/src/color-gradients-paint/color-gradient-slider.d.ts +4 -4
- package/dist/components/colors/src/color-gradients-paint/color-gradient-slider.js +9 -8
- package/dist/components/colors/src/color-image-paint/color-image-paint.js +2 -2
- package/dist/components/colors/src/color-slider/color-slider.d.ts +14 -6
- package/dist/components/colors/src/color-slider/color-slider.js +124 -46
- package/dist/components/colors/src/color-slider/components/index.d.ts +2 -0
- package/dist/components/colors/src/color-slider/components/thumb.d.ts +8 -0
- package/dist/components/colors/src/color-slider/components/thumb.js +49 -0
- package/dist/components/colors/src/color-slider/components/track.d.ts +18 -0
- package/dist/components/colors/src/color-slider/components/track.js +19 -0
- package/dist/components/colors/src/color-slider/context.d.ts +23 -0
- package/dist/components/colors/src/color-slider/context.js +13 -0
- package/dist/components/colors/src/color-slider/index.d.ts +2 -0
- package/dist/components/colors/src/color-slider/tv.d.ts +3 -0
- package/dist/components/colors/src/color-slider/tv.js +2 -1
- package/dist/components/colors/src/color-solid-paint/color-solid-paint.js +4 -7
- package/dist/components/colors/src/color-solid-paint/solid-paint-alpha-slider.js +2 -2
- package/dist/components/colors/src/color-solid-paint/solid-paint-hue-slider.js +2 -2
- package/dist/components/colors/src/simple-color-picker/simple-color-picker.js +4 -7
- package/dist/components/dropdown/dist/index.d.ts +6 -0
- package/dist/components/dropdown/dist/index.js +20 -10
- package/dist/components/emoji-picker/dist/index.d.ts +29 -1
- package/dist/components/emoji-picker/dist/index.js +144 -42
- package/dist/components/form/src/adapters/range-adapter.js +2 -2
- package/dist/components/icon-button/dist/index.d.ts +1 -1
- package/dist/components/icon-button/dist/index.js +39 -0
- package/dist/components/menus/dist/index.d.ts +5 -0
- package/dist/components/menus/dist/index.js +32 -3
- package/dist/components/radio/dist/index.d.ts +9 -1
- package/dist/components/radio/dist/index.js +50 -6
- package/dist/components/range/dist/index.d.ts +276 -20
- package/dist/components/range/dist/index.js +1030 -602
- package/dist/components/textarea/dist/index.js +3 -1
- package/dist/components/tooltip/dist/index.d.ts +2 -0
- package/dist/components/tooltip/dist/index.js +23 -5
- package/dist/components/virtual-select/dist/index.d.ts +48 -0
- package/package.json +20 -32
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSSProperties, MutableRefObject, RefObject } from 'react';
|
|
2
|
+
import { PickerSliderType } from '../types/colors';
|
|
3
|
+
import { ColorSliderTv } from './tv';
|
|
4
|
+
export interface ColorSliderContextValue {
|
|
5
|
+
position: number;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
type: PickerSliderType;
|
|
8
|
+
hue: number;
|
|
9
|
+
thumbSize: number;
|
|
10
|
+
trackWidth: number;
|
|
11
|
+
trackHeight: number;
|
|
12
|
+
thumbWrapperStyle: CSSProperties;
|
|
13
|
+
thumbStyle: CSSProperties;
|
|
14
|
+
trackStyle: CSSProperties;
|
|
15
|
+
thumbRef: RefObject<HTMLDivElement>;
|
|
16
|
+
inputRef: RefObject<HTMLInputElement>;
|
|
17
|
+
isDragging: MutableRefObject<boolean>;
|
|
18
|
+
handlePointerDown: (e: React.PointerEvent) => void;
|
|
19
|
+
handleKeyDown: (e: React.KeyboardEvent) => void;
|
|
20
|
+
tv: ReturnType<typeof ColorSliderTv>;
|
|
21
|
+
}
|
|
22
|
+
export declare const ColorSliderContext: import('react').Context<ColorSliderContextValue | null>;
|
|
23
|
+
export declare function useColorSlider(): ColorSliderContextValue;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const ColorSliderContext = createContext(null);
|
|
3
|
+
function useColorSlider() {
|
|
4
|
+
const context = useContext(ColorSliderContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error("ColorSlider compound components must be used within ColorSlider");
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
ColorSliderContext,
|
|
12
|
+
useColorSlider
|
|
13
|
+
};
|
|
@@ -6,6 +6,7 @@ export declare const ColorSliderTv: import('tailwind-variants').TVReturnType<{
|
|
|
6
6
|
};
|
|
7
7
|
}, {
|
|
8
8
|
root: string;
|
|
9
|
+
thumbWrapper: string;
|
|
9
10
|
thumb: string;
|
|
10
11
|
thumbInput: string;
|
|
11
12
|
}, undefined, {
|
|
@@ -16,6 +17,7 @@ export declare const ColorSliderTv: import('tailwind-variants').TVReturnType<{
|
|
|
16
17
|
};
|
|
17
18
|
}, {
|
|
18
19
|
root: string;
|
|
20
|
+
thumbWrapper: string;
|
|
19
21
|
thumb: string;
|
|
20
22
|
thumbInput: string;
|
|
21
23
|
}, import('tailwind-variants').TVReturnType<{
|
|
@@ -26,6 +28,7 @@ export declare const ColorSliderTv: import('tailwind-variants').TVReturnType<{
|
|
|
26
28
|
};
|
|
27
29
|
}, {
|
|
28
30
|
root: string;
|
|
31
|
+
thumbWrapper: string;
|
|
29
32
|
thumb: string;
|
|
30
33
|
thumbInput: string;
|
|
31
34
|
}, undefined, unknown, unknown, undefined>>;
|
|
@@ -2,7 +2,8 @@ import { tcv } from "../../../../shared/utils/tcx/tcx.js";
|
|
|
2
2
|
const ColorSliderTv = tcv({
|
|
3
3
|
slots: {
|
|
4
4
|
root: "relative touch-none rounded-full select-none",
|
|
5
|
-
|
|
5
|
+
thumbWrapper: "absolute top-1/2 box-border origin-center",
|
|
6
|
+
thumb: "rounded-full absolute -translate-y-1/2 -translate-x-1/2 left-1/2 top-1/2 w-[calc(var(--thumb-size)-2px)] h-[calc(var(--thumb-size)-2px)]",
|
|
6
7
|
thumbInput: "absolute inset-0 cursor-default opacity-0"
|
|
7
8
|
},
|
|
8
9
|
variants: {
|
|
@@ -59,7 +59,7 @@ const ColorSolidPaint = forwardRef(
|
|
|
59
59
|
const handleNativeColorChange = useEventCallback((rgb) => {
|
|
60
60
|
onColorChange == null ? void 0 : onColorChange(rgb);
|
|
61
61
|
});
|
|
62
|
-
const
|
|
62
|
+
const sliderWidth = useMemo(() => {
|
|
63
63
|
const getPadding = () => {
|
|
64
64
|
if (!features.alpha && !features.nativePicker) {
|
|
65
65
|
return 32;
|
|
@@ -69,10 +69,7 @@ const ColorSolidPaint = forwardRef(
|
|
|
69
69
|
padding += features.nativePicker ? 48 : 0;
|
|
70
70
|
return padding;
|
|
71
71
|
};
|
|
72
|
-
return
|
|
73
|
-
width: ((features == null ? void 0 : features.containerWidth) ?? 240) - getPadding(),
|
|
74
|
-
height: 16
|
|
75
|
-
};
|
|
72
|
+
return ((features == null ? void 0 : features.containerWidth) ?? 240) - getPadding();
|
|
76
73
|
}, [features.containerWidth, features.alpha, features.nativePicker]);
|
|
77
74
|
const styles = ColorSolidPaintTv({
|
|
78
75
|
alpha: features.alpha,
|
|
@@ -235,7 +232,7 @@ const ColorSolidPaint = forwardRef(
|
|
|
235
232
|
onChangeEnd,
|
|
236
233
|
onChange: onChangeEnd,
|
|
237
234
|
type: "hue",
|
|
238
|
-
|
|
235
|
+
width: sliderWidth,
|
|
239
236
|
updateSourceRef
|
|
240
237
|
}
|
|
241
238
|
),
|
|
@@ -246,7 +243,7 @@ const ColorSolidPaint = forwardRef(
|
|
|
246
243
|
alpha: opacity,
|
|
247
244
|
onAlphaChange,
|
|
248
245
|
type: "alpha",
|
|
249
|
-
|
|
246
|
+
width: sliderWidth,
|
|
250
247
|
onChangeStart,
|
|
251
248
|
onChangeEnd
|
|
252
249
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ColorSlider } from "../color-slider/color-slider.js";
|
|
3
3
|
const SolidPaintAlphaSlider = (props) => {
|
|
4
|
-
const { hue, alpha, onAlphaChange, onChangeStart, onChangeEnd,
|
|
4
|
+
const { hue, alpha, onAlphaChange, onChangeStart, onChangeEnd, width } = props;
|
|
5
5
|
return /* @__PURE__ */ jsx(
|
|
6
6
|
ColorSlider,
|
|
7
7
|
{
|
|
@@ -9,7 +9,7 @@ const SolidPaintAlphaSlider = (props) => {
|
|
|
9
9
|
onChange: onAlphaChange,
|
|
10
10
|
type: "alpha",
|
|
11
11
|
hue,
|
|
12
|
-
|
|
12
|
+
width,
|
|
13
13
|
onChangeStart,
|
|
14
14
|
onChangeEnd
|
|
15
15
|
}
|
|
@@ -9,7 +9,7 @@ const SolidPaintHueSlider = (props) => {
|
|
|
9
9
|
setHue,
|
|
10
10
|
color,
|
|
11
11
|
onColorChange,
|
|
12
|
-
|
|
12
|
+
width,
|
|
13
13
|
onChangeStart,
|
|
14
14
|
onChangeEnd,
|
|
15
15
|
updateSourceRef
|
|
@@ -32,7 +32,7 @@ const SolidPaintHueSlider = (props) => {
|
|
|
32
32
|
position: hue / 360,
|
|
33
33
|
onChange: handleHueChange,
|
|
34
34
|
type: "hue",
|
|
35
|
-
|
|
35
|
+
width,
|
|
36
36
|
onChangeStart,
|
|
37
37
|
onChangeEnd: () => {
|
|
38
38
|
onChangeEnd == null ? void 0 : onChangeEnd();
|
|
@@ -43,16 +43,13 @@ const SimpleColorPicker = forwardRef(
|
|
|
43
43
|
hsb: true,
|
|
44
44
|
...featureProps
|
|
45
45
|
};
|
|
46
|
-
const
|
|
46
|
+
const sliderWidth = useMemo(() => {
|
|
47
47
|
const getPadding = () => {
|
|
48
48
|
let padding = 0;
|
|
49
49
|
padding += 32;
|
|
50
50
|
return padding;
|
|
51
51
|
};
|
|
52
|
-
return
|
|
53
|
-
width: 240 - getPadding(),
|
|
54
|
-
height: 16
|
|
55
|
-
};
|
|
52
|
+
return 240 - getPadding();
|
|
56
53
|
}, []);
|
|
57
54
|
const styles = ColorSolidPaintTv({
|
|
58
55
|
alpha: true,
|
|
@@ -104,7 +101,7 @@ const SimpleColorPicker = forwardRef(
|
|
|
104
101
|
onChangeEnd,
|
|
105
102
|
onChange: onChangeEnd,
|
|
106
103
|
type: "hue",
|
|
107
|
-
|
|
104
|
+
width: sliderWidth,
|
|
108
105
|
updateSourceRef
|
|
109
106
|
}
|
|
110
107
|
),
|
|
@@ -115,7 +112,7 @@ const SimpleColorPicker = forwardRef(
|
|
|
115
112
|
alpha: opacity,
|
|
116
113
|
onAlphaChange,
|
|
117
114
|
type: "alpha",
|
|
118
|
-
|
|
115
|
+
width: sliderWidth,
|
|
119
116
|
onChangeStart,
|
|
120
117
|
onChangeEnd
|
|
121
118
|
}
|
|
@@ -7,6 +7,12 @@ interface DropdownProps {
|
|
|
7
7
|
* @default true
|
|
8
8
|
*/
|
|
9
9
|
autoSelectFirstItem?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to avoid collisions by flipping or shifting the dropdown position.
|
|
12
|
+
* When false, the dropdown will strictly follow the placement direction.
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
avoidCollisions?: boolean;
|
|
10
16
|
children?: React.ReactNode;
|
|
11
17
|
disabledNested?: boolean;
|
|
12
18
|
focusManagerProps?: Partial<FloatingFocusManagerProps>;
|
|
@@ -13,6 +13,7 @@ var DropdownComponent = memo(function DropdownComponent2(props) {
|
|
|
13
13
|
const {
|
|
14
14
|
children,
|
|
15
15
|
autoSelectFirstItem = true,
|
|
16
|
+
avoidCollisions = true,
|
|
16
17
|
disabledNested = false,
|
|
17
18
|
offset: offsetDistance = DEFAULT_OFFSET,
|
|
18
19
|
placement = "bottom-start",
|
|
@@ -53,7 +54,7 @@ var DropdownComponent = memo(function DropdownComponent2(props) {
|
|
|
53
54
|
}
|
|
54
55
|
onOpenChange == null ? void 0 : onOpenChange(newOpen);
|
|
55
56
|
});
|
|
56
|
-
const { nodeId, item, isNested } = useMenuTree({
|
|
57
|
+
const { nodeId, item, isNested, tree } = useMenuTree({
|
|
57
58
|
disabledNested,
|
|
58
59
|
handleOpenChange,
|
|
59
60
|
isControlledOpen
|
|
@@ -77,11 +78,14 @@ var DropdownComponent = memo(function DropdownComponent2(props) {
|
|
|
77
78
|
});
|
|
78
79
|
});
|
|
79
80
|
const lastPositionRef = useRef(null);
|
|
80
|
-
const middleware = useMemo(
|
|
81
|
-
|
|
82
|
-
offset({ mainAxis: isNested ? 10 : offsetDistance, alignmentAxis: isNested ? -4 : 0 })
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
const middleware = useMemo(() => {
|
|
82
|
+
const baseMiddleware = [
|
|
83
|
+
offset({ mainAxis: isNested ? 10 : offsetDistance, alignmentAxis: isNested ? -4 : 0 })
|
|
84
|
+
];
|
|
85
|
+
if (avoidCollisions) {
|
|
86
|
+
baseMiddleware.push(flip(), shift());
|
|
87
|
+
}
|
|
88
|
+
baseMiddleware.push(
|
|
85
89
|
size({
|
|
86
90
|
padding: 4,
|
|
87
91
|
apply({ elements, availableHeight, rects }) {
|
|
@@ -104,9 +108,9 @@ var DropdownComponent = memo(function DropdownComponent2(props) {
|
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
110
|
})
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
);
|
|
111
|
+
);
|
|
112
|
+
return baseMiddleware;
|
|
113
|
+
}, [isNested, offsetDistance, matchTriggerWidth, scrollRef, avoidCollisions]);
|
|
110
114
|
const { refs, floatingStyles, context, isPositioned } = useFloating({
|
|
111
115
|
nodeId,
|
|
112
116
|
open: isControlledOpen,
|
|
@@ -165,11 +169,17 @@ var DropdownComponent = memo(function DropdownComponent2(props) {
|
|
|
165
169
|
bubbles: true,
|
|
166
170
|
escapeKey: true
|
|
167
171
|
});
|
|
172
|
+
const handleNavigate = useEventCallback((index) => {
|
|
173
|
+
setActiveIndex(index);
|
|
174
|
+
if (tree && index !== null) {
|
|
175
|
+
tree.events.emit("navigate", { nodeId, index });
|
|
176
|
+
}
|
|
177
|
+
});
|
|
168
178
|
const listNavigation = useListNavigation(context, {
|
|
169
179
|
listRef: elementsRef,
|
|
170
180
|
activeIndex,
|
|
171
181
|
nested: isNested,
|
|
172
|
-
onNavigate:
|
|
182
|
+
onNavigate: handleNavigate,
|
|
173
183
|
loop: true
|
|
174
184
|
});
|
|
175
185
|
const typeahead = useTypeahead(context, {
|
|
@@ -15,12 +15,24 @@ type VirtualItem = {
|
|
|
15
15
|
emojis: EmojiData[];
|
|
16
16
|
type: "emojis";
|
|
17
17
|
};
|
|
18
|
+
interface CategoryNames {
|
|
19
|
+
activities: string;
|
|
20
|
+
animalsNature: string;
|
|
21
|
+
flags: string;
|
|
22
|
+
foodDrink: string;
|
|
23
|
+
frequentlyUsed: string;
|
|
24
|
+
objects: string;
|
|
25
|
+
smileysPeople: string;
|
|
26
|
+
symbols: string;
|
|
27
|
+
travelPlaces: string;
|
|
28
|
+
}
|
|
18
29
|
interface UseEmojiDataProps {
|
|
30
|
+
categoryNames?: CategoryNames;
|
|
19
31
|
columns: number;
|
|
20
32
|
searchQuery: string;
|
|
21
33
|
showFrequentlyUsed: boolean;
|
|
22
34
|
}
|
|
23
|
-
declare function useEmojiData({ searchQuery, columns, showFrequentlyUsed }: UseEmojiDataProps): {
|
|
35
|
+
declare function useEmojiData({ searchQuery, columns, showFrequentlyUsed, categoryNames, }: UseEmojiDataProps): {
|
|
24
36
|
categorizedData: VirtualItem[];
|
|
25
37
|
categoryIndexMap: Map<EmojiCategory, number>;
|
|
26
38
|
searchResults: {
|
|
@@ -52,6 +64,22 @@ interface EmojiPickerProps {
|
|
|
52
64
|
showFooter?: boolean;
|
|
53
65
|
value?: EmojiData | null;
|
|
54
66
|
variant?: "default" | "dark" | "light";
|
|
67
|
+
i18n?: {
|
|
68
|
+
noEmojisFoundTitle?: string;
|
|
69
|
+
noEmojisFoundDescription?: string;
|
|
70
|
+
footerPickAnEmoji?: string;
|
|
71
|
+
categories?: {
|
|
72
|
+
frequentlyUsed: string;
|
|
73
|
+
smileysPeople: string;
|
|
74
|
+
animalsNature: string;
|
|
75
|
+
foodDrink: string;
|
|
76
|
+
travelPlaces: string;
|
|
77
|
+
activities: string;
|
|
78
|
+
objects: string;
|
|
79
|
+
symbols: string;
|
|
80
|
+
flags: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
55
83
|
}
|
|
56
84
|
declare const EmojiPicker: React.NamedExoticComponent<EmojiPickerProps>;
|
|
57
85
|
|
|
@@ -141,7 +141,7 @@ var emojiFooterTv = tcv({
|
|
|
141
141
|
var emojiEmptyTv = tcv({
|
|
142
142
|
slots: {
|
|
143
143
|
container: "flex h-32 flex-col items-center justify-center p-4 text-center",
|
|
144
|
-
title: "text-
|
|
144
|
+
title: "text-body-large-strong",
|
|
145
145
|
description: "mt-2 w-32"
|
|
146
146
|
},
|
|
147
147
|
variants: {
|
|
@@ -179,13 +179,20 @@ var EmojiCategoryHeader = forwardRef(
|
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
181
|
);
|
|
182
|
-
|
|
182
|
+
var EmojiFooter = memo(function EmojiFooter2({
|
|
183
|
+
hoveredEmoji,
|
|
184
|
+
selectedEmoji,
|
|
185
|
+
variant = "dark",
|
|
186
|
+
i18n = {
|
|
187
|
+
pickAnEmoji: "Pick an emoji..."
|
|
188
|
+
}
|
|
189
|
+
}) {
|
|
183
190
|
var _a, _b;
|
|
184
191
|
const tv = emojiFooterTv({ variant });
|
|
185
192
|
return /* @__PURE__ */ jsxs("div", { className: tv.footer(), children: [
|
|
186
193
|
/* @__PURE__ */ jsx("div", { className: tv.emojiPreview(), children: ((_a = hoveredEmoji || selectedEmoji) == null ? void 0 : _a.emoji) || /* @__PURE__ */ jsx("div", { className: tv.emojiPreviewEmpty() }) }),
|
|
187
194
|
/* @__PURE__ */ jsxs("div", { className: tv.emojiInfo(), children: [
|
|
188
|
-
/* @__PURE__ */ jsx("div", { className: tv.emojiName(), children: (hoveredEmoji == null ? void 0 : hoveredEmoji.name) || (selectedEmoji == null ? void 0 : selectedEmoji.name) ||
|
|
195
|
+
/* @__PURE__ */ jsx("div", { className: tv.emojiName(), children: (hoveredEmoji == null ? void 0 : hoveredEmoji.name) || (selectedEmoji == null ? void 0 : selectedEmoji.name) || i18n.pickAnEmoji }),
|
|
189
196
|
hoveredEmoji || selectedEmoji ? /* @__PURE__ */ jsxs("div", { className: tv.emojiCode(), children: [
|
|
190
197
|
":",
|
|
191
198
|
(_b = hoveredEmoji || selectedEmoji) == null ? void 0 : _b.nameUrl,
|
|
@@ -193,7 +200,7 @@ function EmojiFooter({ hoveredEmoji, selectedEmoji, variant = "dark" }) {
|
|
|
193
200
|
] }) : /* @__PURE__ */ jsx(Fragment, {})
|
|
194
201
|
] })
|
|
195
202
|
] });
|
|
196
|
-
}
|
|
203
|
+
});
|
|
197
204
|
var EmojiItem = memo(function EmojiItem2(props) {
|
|
198
205
|
const { emoji, onSelect, onHover, selected = false, variant = "dark" } = props;
|
|
199
206
|
return /* @__PURE__ */ jsx(
|
|
@@ -209,11 +216,17 @@ var EmojiItem = memo(function EmojiItem2(props) {
|
|
|
209
216
|
}
|
|
210
217
|
);
|
|
211
218
|
});
|
|
212
|
-
var EmojiEmpty = memo(function EmojiEmpty2({
|
|
219
|
+
var EmojiEmpty = memo(function EmojiEmpty2({
|
|
220
|
+
variant = "dark",
|
|
221
|
+
i18n = {
|
|
222
|
+
title: "No emoji found",
|
|
223
|
+
description: "You can search for an emoji by name or use the search bar to find it."
|
|
224
|
+
}
|
|
225
|
+
}) {
|
|
213
226
|
const tv = emojiEmptyTv({ variant });
|
|
214
227
|
return /* @__PURE__ */ jsxs("div", { className: tv.container(), children: [
|
|
215
|
-
/* @__PURE__ */ jsx("div", { className: tv.title(), children:
|
|
216
|
-
/* @__PURE__ */ jsx("p", { className: tv.description(), children:
|
|
228
|
+
/* @__PURE__ */ jsx("div", { className: tv.title(), children: i18n.title }),
|
|
229
|
+
/* @__PURE__ */ jsx("p", { className: tv.description(), children: i18n.description })
|
|
217
230
|
] });
|
|
218
231
|
});
|
|
219
232
|
var emojis = [
|
|
@@ -11727,15 +11740,15 @@ var emojis = [
|
|
|
11727
11740
|
}
|
|
11728
11741
|
];
|
|
11729
11742
|
var categories = [
|
|
11730
|
-
{ id: "frequently_used"
|
|
11731
|
-
{ id: "smileys_people",
|
|
11732
|
-
{ id: "animals_nature",
|
|
11733
|
-
{ id: "food_drink",
|
|
11734
|
-
{ id: "travel_places",
|
|
11735
|
-
{ id: "activities",
|
|
11736
|
-
{ id: "objects",
|
|
11737
|
-
{ id: "symbols",
|
|
11738
|
-
{ id: "flags",
|
|
11743
|
+
{ id: "frequently_used" },
|
|
11744
|
+
{ id: "smileys_people", range: [1, 460] },
|
|
11745
|
+
{ id: "animals_nature", range: [465, 591] },
|
|
11746
|
+
{ id: "food_drink", range: [592, 712] },
|
|
11747
|
+
{ id: "travel_places", range: [713, 922] },
|
|
11748
|
+
{ id: "activities", range: [923, 1001] },
|
|
11749
|
+
{ id: "objects", range: [1002, 1234] },
|
|
11750
|
+
{ id: "symbols", range: [1235, 1451] },
|
|
11751
|
+
{ id: "flags", range: [1452, 1719] }
|
|
11739
11752
|
];
|
|
11740
11753
|
var STORAGE_KEY = "emoji-picker-frequently-used";
|
|
11741
11754
|
function getEmojiCategory(id) {
|
|
@@ -11769,7 +11782,34 @@ function saveFrequentlyUsedEmoji(emojiId) {
|
|
|
11769
11782
|
} catch {
|
|
11770
11783
|
}
|
|
11771
11784
|
}
|
|
11772
|
-
|
|
11785
|
+
var defaultCategoryNames = {
|
|
11786
|
+
frequentlyUsed: "Frequently used",
|
|
11787
|
+
smileysPeople: "Smileys & People",
|
|
11788
|
+
animalsNature: "Animals & Nature",
|
|
11789
|
+
foodDrink: "Food & Drink",
|
|
11790
|
+
travelPlaces: "Travel & Places",
|
|
11791
|
+
activities: "Activities",
|
|
11792
|
+
objects: "Objects",
|
|
11793
|
+
symbols: "Symbols",
|
|
11794
|
+
flags: "Flags"
|
|
11795
|
+
};
|
|
11796
|
+
var categoryIdToI18nKey = {
|
|
11797
|
+
frequently_used: "frequentlyUsed",
|
|
11798
|
+
smileys_people: "smileysPeople",
|
|
11799
|
+
animals_nature: "animalsNature",
|
|
11800
|
+
food_drink: "foodDrink",
|
|
11801
|
+
travel_places: "travelPlaces",
|
|
11802
|
+
activities: "activities",
|
|
11803
|
+
objects: "objects",
|
|
11804
|
+
symbols: "symbols",
|
|
11805
|
+
flags: "flags"
|
|
11806
|
+
};
|
|
11807
|
+
function useEmojiData({
|
|
11808
|
+
searchQuery,
|
|
11809
|
+
columns,
|
|
11810
|
+
showFrequentlyUsed,
|
|
11811
|
+
categoryNames = defaultCategoryNames
|
|
11812
|
+
}) {
|
|
11773
11813
|
const [frequentlyUsed, setFrequentlyUsed] = useState([]);
|
|
11774
11814
|
useEffect(() => {
|
|
11775
11815
|
if (showFrequentlyUsed) {
|
|
@@ -11799,7 +11839,7 @@ function useEmojiData({ searchQuery, columns, showFrequentlyUsed }) {
|
|
|
11799
11839
|
items.push({
|
|
11800
11840
|
type: "header",
|
|
11801
11841
|
category: "frequently_used",
|
|
11802
|
-
title:
|
|
11842
|
+
title: categoryNames.frequentlyUsed
|
|
11803
11843
|
});
|
|
11804
11844
|
for (let i = 0; i < frequentlyUsed.length; i += columns) {
|
|
11805
11845
|
items.push({
|
|
@@ -11814,10 +11854,11 @@ function useEmojiData({ searchQuery, columns, showFrequentlyUsed }) {
|
|
|
11814
11854
|
(emoji) => emoji.id >= category.range[0] && emoji.id <= category.range[1]
|
|
11815
11855
|
);
|
|
11816
11856
|
if (categoryEmojis.length > 0) {
|
|
11857
|
+
const i18nKey = categoryIdToI18nKey[category.id];
|
|
11817
11858
|
items.push({
|
|
11818
11859
|
type: "header",
|
|
11819
11860
|
category: category.id,
|
|
11820
|
-
title: category.
|
|
11861
|
+
title: i18nKey ? categoryNames[i18nKey] : category.id
|
|
11821
11862
|
});
|
|
11822
11863
|
for (let i = 0; i < categoryEmojis.length; i += columns) {
|
|
11823
11864
|
items.push({
|
|
@@ -11828,7 +11869,7 @@ function useEmojiData({ searchQuery, columns, showFrequentlyUsed }) {
|
|
|
11828
11869
|
}
|
|
11829
11870
|
});
|
|
11830
11871
|
return items;
|
|
11831
|
-
}, [searchQuery, searchResults, frequentlyUsed, columns, showFrequentlyUsed]);
|
|
11872
|
+
}, [searchQuery, searchResults, frequentlyUsed, columns, showFrequentlyUsed, categoryNames]);
|
|
11832
11873
|
const categoryIndexMap = useMemo(() => {
|
|
11833
11874
|
const map = /* @__PURE__ */ new Map();
|
|
11834
11875
|
categorizedData.forEach((item, index) => {
|
|
@@ -11884,6 +11925,8 @@ function useEmojiScroll({
|
|
|
11884
11925
|
const [currentVisibleCategory, setCurrentVisibleCategory] = useState("frequently_used");
|
|
11885
11926
|
const isScrollingToTarget = useRef(false);
|
|
11886
11927
|
const isInternalUpdate = useRef(false);
|
|
11928
|
+
const scrollingTimeoutRef = useRef(null);
|
|
11929
|
+
const internalUpdateTimeoutRef = useRef(null);
|
|
11887
11930
|
const virtualizer = useVirtualizer({
|
|
11888
11931
|
count: categorizedData.length,
|
|
11889
11932
|
getScrollElement: () => scrollRef.current,
|
|
@@ -11948,7 +11991,10 @@ function useEmojiScroll({
|
|
|
11948
11991
|
align: "start",
|
|
11949
11992
|
behavior: "auto"
|
|
11950
11993
|
});
|
|
11951
|
-
|
|
11994
|
+
if (scrollingTimeoutRef.current) {
|
|
11995
|
+
clearTimeout(scrollingTimeoutRef.current);
|
|
11996
|
+
}
|
|
11997
|
+
scrollingTimeoutRef.current = setTimeout(() => {
|
|
11952
11998
|
isScrollingToTarget.current = false;
|
|
11953
11999
|
}, 100);
|
|
11954
12000
|
}
|
|
@@ -11961,17 +12007,33 @@ function useEmojiScroll({
|
|
|
11961
12007
|
align: "center",
|
|
11962
12008
|
behavior: "auto"
|
|
11963
12009
|
});
|
|
11964
|
-
|
|
12010
|
+
if (scrollingTimeoutRef.current) {
|
|
12011
|
+
clearTimeout(scrollingTimeoutRef.current);
|
|
12012
|
+
}
|
|
12013
|
+
scrollingTimeoutRef.current = setTimeout(() => {
|
|
11965
12014
|
isScrollingToTarget.current = false;
|
|
11966
12015
|
}, 100);
|
|
11967
12016
|
}
|
|
11968
12017
|
});
|
|
11969
12018
|
const markInternalUpdate = useEventCallback(() => {
|
|
11970
12019
|
isInternalUpdate.current = true;
|
|
11971
|
-
|
|
12020
|
+
if (internalUpdateTimeoutRef.current) {
|
|
12021
|
+
clearTimeout(internalUpdateTimeoutRef.current);
|
|
12022
|
+
}
|
|
12023
|
+
internalUpdateTimeoutRef.current = setTimeout(() => {
|
|
11972
12024
|
isInternalUpdate.current = false;
|
|
11973
12025
|
}, 50);
|
|
11974
12026
|
});
|
|
12027
|
+
useEffect(() => {
|
|
12028
|
+
return () => {
|
|
12029
|
+
if (scrollingTimeoutRef.current) {
|
|
12030
|
+
clearTimeout(scrollingTimeoutRef.current);
|
|
12031
|
+
}
|
|
12032
|
+
if (internalUpdateTimeoutRef.current) {
|
|
12033
|
+
clearTimeout(internalUpdateTimeoutRef.current);
|
|
12034
|
+
}
|
|
12035
|
+
};
|
|
12036
|
+
}, []);
|
|
11975
12037
|
useEffect(() => {
|
|
11976
12038
|
if (value && !searchQuery.trim() && !isInternalUpdate.current) {
|
|
11977
12039
|
scrollToEmoji(value);
|
|
@@ -11996,17 +12058,6 @@ function useEmojiScroll({
|
|
|
11996
12058
|
PADDING
|
|
11997
12059
|
};
|
|
11998
12060
|
}
|
|
11999
|
-
var categoriesWithIcons = [
|
|
12000
|
-
{ id: "frequently_used", name: "Frequently used", icon: /* @__PURE__ */ jsx(EmojiFrequentlyUsed, {}) },
|
|
12001
|
-
{ id: "smileys_people", name: "Smileys & People", icon: /* @__PURE__ */ jsx(EmojiSmileysPeople, {}) },
|
|
12002
|
-
{ id: "animals_nature", name: "Animals & Nature", icon: /* @__PURE__ */ jsx(EmojiAnimalsNature, {}) },
|
|
12003
|
-
{ id: "food_drink", name: "Food & Drink", icon: /* @__PURE__ */ jsx(EmojiFoodDrink, {}) },
|
|
12004
|
-
{ id: "travel_places", name: "Travel & Places", icon: /* @__PURE__ */ jsx(EmojiTravelPlaces, {}) },
|
|
12005
|
-
{ id: "activities", name: "Activities", icon: /* @__PURE__ */ jsx(EmojiActivity, {}) },
|
|
12006
|
-
{ id: "objects", name: "Objects", icon: /* @__PURE__ */ jsx(EmojiObjects, {}) },
|
|
12007
|
-
{ id: "symbols", name: "Symbols", icon: /* @__PURE__ */ jsx(EmojiSymbols, {}) },
|
|
12008
|
-
{ id: "flags", name: "Flags", icon: /* @__PURE__ */ jsx(EmojiFlags, {}) }
|
|
12009
|
-
];
|
|
12010
12061
|
var EmojiPicker = memo(function EmojiPicker2({
|
|
12011
12062
|
value,
|
|
12012
12063
|
onChange,
|
|
@@ -12019,11 +12070,49 @@ var EmojiPicker = memo(function EmojiPicker2({
|
|
|
12019
12070
|
showSearch = true,
|
|
12020
12071
|
showFooter = true,
|
|
12021
12072
|
children,
|
|
12022
|
-
variant = "dark"
|
|
12073
|
+
variant = "dark",
|
|
12074
|
+
i18n = {
|
|
12075
|
+
noEmojisFoundTitle: "No emoji found",
|
|
12076
|
+
noEmojisFoundDescription: "You can search for an emoji by name or use the search bar to find it.",
|
|
12077
|
+
footerPickAnEmoji: "Pick an emoji...",
|
|
12078
|
+
categories: {
|
|
12079
|
+
frequentlyUsed: "Frequently used",
|
|
12080
|
+
smileysPeople: "Smileys & People",
|
|
12081
|
+
animalsNature: "Animals & Nature",
|
|
12082
|
+
foodDrink: "Food & Drink",
|
|
12083
|
+
travelPlaces: "Travel & Places",
|
|
12084
|
+
activities: "Activities",
|
|
12085
|
+
objects: "Objects",
|
|
12086
|
+
symbols: "Symbols",
|
|
12087
|
+
flags: "Flags"
|
|
12088
|
+
}
|
|
12089
|
+
}
|
|
12023
12090
|
}) {
|
|
12024
12091
|
const [searchQuery, setSearchQuery] = useState("");
|
|
12025
12092
|
const [hoveredEmoji, setHoveredEmoji] = useState(null);
|
|
12093
|
+
const safeColumns = Math.max(1, columns);
|
|
12026
12094
|
const tv = emojiTv({ variant });
|
|
12095
|
+
const categoriesWithIcons = useMemo(
|
|
12096
|
+
() => {
|
|
12097
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
12098
|
+
return [
|
|
12099
|
+
{
|
|
12100
|
+
id: "frequently_used",
|
|
12101
|
+
name: (_a = i18n.categories) == null ? void 0 : _a.frequentlyUsed,
|
|
12102
|
+
icon: /* @__PURE__ */ jsx(EmojiFrequentlyUsed, {})
|
|
12103
|
+
},
|
|
12104
|
+
{ id: "smileys_people", name: (_b = i18n.categories) == null ? void 0 : _b.smileysPeople, icon: /* @__PURE__ */ jsx(EmojiSmileysPeople, {}) },
|
|
12105
|
+
{ id: "animals_nature", name: (_c = i18n.categories) == null ? void 0 : _c.animalsNature, icon: /* @__PURE__ */ jsx(EmojiAnimalsNature, {}) },
|
|
12106
|
+
{ id: "food_drink", name: (_d = i18n.categories) == null ? void 0 : _d.foodDrink, icon: /* @__PURE__ */ jsx(EmojiFoodDrink, {}) },
|
|
12107
|
+
{ id: "travel_places", name: (_e = i18n.categories) == null ? void 0 : _e.travelPlaces, icon: /* @__PURE__ */ jsx(EmojiTravelPlaces, {}) },
|
|
12108
|
+
{ id: "activities", name: (_f = i18n.categories) == null ? void 0 : _f.activities, icon: /* @__PURE__ */ jsx(EmojiActivity, {}) },
|
|
12109
|
+
{ id: "objects", name: (_g = i18n.categories) == null ? void 0 : _g.objects, icon: /* @__PURE__ */ jsx(EmojiObjects, {}) },
|
|
12110
|
+
{ id: "symbols", name: (_h = i18n.categories) == null ? void 0 : _h.symbols, icon: /* @__PURE__ */ jsx(EmojiSymbols, {}) },
|
|
12111
|
+
{ id: "flags", name: (_i = i18n.categories) == null ? void 0 : _i.flags, icon: /* @__PURE__ */ jsx(EmojiFlags, {}) }
|
|
12112
|
+
];
|
|
12113
|
+
},
|
|
12114
|
+
[i18n.categories]
|
|
12115
|
+
);
|
|
12027
12116
|
const {
|
|
12028
12117
|
categorizedData,
|
|
12029
12118
|
categoryIndexMap,
|
|
@@ -12031,8 +12120,9 @@ var EmojiPicker = memo(function EmojiPicker2({
|
|
|
12031
12120
|
findEmojiPosition
|
|
12032
12121
|
} = useEmojiData({
|
|
12033
12122
|
searchQuery,
|
|
12034
|
-
columns,
|
|
12035
|
-
showFrequentlyUsed
|
|
12123
|
+
columns: safeColumns,
|
|
12124
|
+
showFrequentlyUsed,
|
|
12125
|
+
categoryNames: i18n.categories
|
|
12036
12126
|
});
|
|
12037
12127
|
const {
|
|
12038
12128
|
scrollRef,
|
|
@@ -12048,7 +12138,7 @@ var EmojiPicker = memo(function EmojiPicker2({
|
|
|
12048
12138
|
findEmojiPosition,
|
|
12049
12139
|
searchQuery,
|
|
12050
12140
|
value,
|
|
12051
|
-
columns
|
|
12141
|
+
columns: safeColumns
|
|
12052
12142
|
});
|
|
12053
12143
|
const availableCategories = useMemo(() => {
|
|
12054
12144
|
return categoriesWithIcons.filter((category) => {
|
|
@@ -12057,7 +12147,7 @@ var EmojiPicker = memo(function EmojiPicker2({
|
|
|
12057
12147
|
}
|
|
12058
12148
|
return true;
|
|
12059
12149
|
});
|
|
12060
|
-
}, [showFrequentlyUsed]);
|
|
12150
|
+
}, [categoriesWithIcons, showFrequentlyUsed]);
|
|
12061
12151
|
const handleEmojiSelect = useEventCallback((emoji) => {
|
|
12062
12152
|
markInternalUpdate();
|
|
12063
12153
|
addToFrequentlyUsed(emoji.id);
|
|
@@ -12073,7 +12163,7 @@ var EmojiPicker = memo(function EmojiPicker2({
|
|
|
12073
12163
|
const rootStyle = {
|
|
12074
12164
|
"--emoji-height": `${height}px`,
|
|
12075
12165
|
"--emoji-padding": `${PADDING2}px`,
|
|
12076
|
-
"--emoji-columns": `${
|
|
12166
|
+
"--emoji-columns": `${safeColumns}`
|
|
12077
12167
|
};
|
|
12078
12168
|
return /* @__PURE__ */ jsxs(
|
|
12079
12169
|
"div",
|
|
@@ -12176,7 +12266,16 @@ var EmojiPicker = memo(function EmojiPicker2({
|
|
|
12176
12266
|
},
|
|
12177
12267
|
virtualItem.key
|
|
12178
12268
|
);
|
|
12179
|
-
}) : /* @__PURE__ */ jsx(
|
|
12269
|
+
}) : /* @__PURE__ */ jsx(
|
|
12270
|
+
EmojiEmpty,
|
|
12271
|
+
{
|
|
12272
|
+
variant,
|
|
12273
|
+
i18n: {
|
|
12274
|
+
title: i18n.noEmojisFoundTitle,
|
|
12275
|
+
description: i18n.noEmojisFoundDescription
|
|
12276
|
+
}
|
|
12277
|
+
}
|
|
12278
|
+
)
|
|
12180
12279
|
}
|
|
12181
12280
|
)
|
|
12182
12281
|
}
|
|
@@ -12188,7 +12287,10 @@ var EmojiPicker = memo(function EmojiPicker2({
|
|
|
12188
12287
|
{
|
|
12189
12288
|
hoveredEmoji,
|
|
12190
12289
|
selectedEmoji: value || null,
|
|
12191
|
-
variant
|
|
12290
|
+
variant,
|
|
12291
|
+
i18n: {
|
|
12292
|
+
pickAnEmoji: i18n.footerPickAnEmoji
|
|
12293
|
+
}
|
|
12192
12294
|
}
|
|
12193
12295
|
),
|
|
12194
12296
|
children
|