Skip to content

Commit e535648

Browse files
mjcampagnaclaude
andcommitted
feat: remove scoreEmoji export
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 63df20c commit e535648

File tree

4 files changed

+67
-19
lines changed

4 files changed

+67
-19
lines changed

CUSTOM-EMOJIS.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,6 @@ Pass an array of `EmojiPickerEmoji` objects via the `frequently` prop to display
115115

116116
The consumer is responsible for tracking and persisting frequency data — frimousse does not manage localStorage or usage counts internally.
117117

118-
## `scoreEmoji` Utility
119-
120-
The scoring function used internally to rank search results is exported for consumer use:
121-
122-
```ts
123-
import { scoreEmoji } from "@gluegroups/frimousse";
124-
125-
const score = scoreEmoji("Ship It", ["ship", "deploy"], "ship");
126-
// Returns 11 (10 for label match + 1 for tag match)
127-
```
128-
129-
```ts
130-
function scoreEmoji(label: string, tags: string[], searchText: string): number
131-
```
132-
133-
Useful if you want to rank or filter custom emojis outside of the picker (e.g., in a custom search UI or for pre-sorting).
134-
135118
## Prop Reference
136119

137120
All custom emoji props are added to `<EmojiPicker.Root>`:

PR-32-DESCRIPTION.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## Summary
2+
3+
Adds support for image-based custom emoji categories, frequently used emojis, and unified cross-type search — all as opt-in props on `<EmojiPicker.Root>`.
4+
5+
## New Props
6+
7+
| Prop | Type | Default | Description |
8+
| ----------------- | -------------------- | ------------------- | ----------- |
9+
| `custom` | `CustomCategory[]` || Image-based emoji categories appended after standard categories. |
10+
| `frequently` | `EmojiPickerEmoji[]` || Emojis shown in a "Frequently Used" category at the top. Hidden during search. |
11+
| `frequentlyLabel` | `string` | `"Frequently Used"` | Label for the frequently used category header. |
12+
| `unifiedSearch` | `boolean` | `false` | When `true`, all search results are merged into one ranked list. |
13+
| `searchLabel` | `string` | `""` | Category header label when `unifiedSearch` is active. |
14+
15+
## New Types
16+
17+
```ts
18+
type CustomEmoji = { id: string; label: string; url: string; tags?: string[]; };
19+
type CustomCategory = { id: string; label: string; emojis: CustomEmoji[]; };
20+
```
21+
22+
Both are exported from the package. `EmojiPickerRootProps` is augmented via intersection (not mutation) so the public type includes all new props.
23+
24+
## New Exports
25+
26+
- `CustomEmoji` — type for individual custom emoji
27+
- `CustomCategory` — type for a custom emoji category
28+
29+
## Architecture
30+
31+
All new code lives in dedicated files:
32+
33+
- **`src/custom-emoji-types.ts`** — new types and `CustomEmojiRootProps` interface
34+
- **`src/data/custom-emoji.ts`**`buildFrequentlyUsedRows`, `buildCustomCategoryRows`, `buildUnifiedSearchRows`, `scoreEmoji` (internal)
35+
- **`src/utils/emoji-identity.ts`**`isSameEmoji` for comparing native and custom emojis
36+
37+
Upstream files (`src/types.ts`, `src/data/emoji-picker.ts`, `src/components/emoji-picker.tsx`, `src/store.ts`) are touched minimally — each change is a delegation call or an optional-param addition at a single call site.
38+
39+
### Search Scoring
40+
41+
Custom emoji search mirrors the upstream `searchEmojis` scoring (+10 label match, +1 per tag match). `scoreEmoji` is extracted as a shared helper to reduce duplication within our own code.
42+
43+
### Unified Search
44+
45+
When `unifiedSearch` is enabled, `buildUnifiedSearchRows` merges native and custom emoji results into a single score-ranked list instead of displaying them in separate categories.
46+
47+
### Type Widening
48+
49+
`EmojiPickerEmoji` is widened to `{ emoji?: string; label: string; url?: string; id?: string }` to accommodate both native and custom emojis without casts. The upstream `EmojiPickerRootProps` export is shadowed in `src/index.ts` by an augmented version that includes `CustomEmojiRootProps`.
50+
51+
## Bug Fixes
52+
53+
- `sameEmojiPickerEmoji` in `store.ts`: fixed two bugs where custom emojis (with `emoji: undefined`) would always compare as equal, suppressing `useActiveEmoji()` updates. Now guards for `undefined` first and compares custom emojis by `id`.
54+
55+
## Tests
56+
57+
New test files:
58+
- `src/data/__tests__/custom-emoji.test.ts` — 15 tests for `scoreEmoji`, `buildFrequentlyUsedRows`, `buildCustomCategoryRows`, `buildUnifiedSearchRows`
59+
- `src/utils/__tests__/emoji-identity.test.ts` — 4 tests for `isSameEmoji`
60+
61+
Extended:
62+
- `src/data/__tests__/emoji-picker.test.ts` — 9 new tests for custom categories, frequently used, and unified search
63+
64+
## Docs
65+
66+
See `CUSTOM-EMOJIS.md` for full usage documentation including examples, prop reference, and type definitions.

src/data/custom-emoji.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function buildFrequentlyUsedRows(
4545

4646
// Mirrors the scoring algorithm in the upstream searchEmojis() (src/data/emoji-picker.ts).
4747
// If that function's scoring logic changes, update scoreEmoji() to match.
48-
export function scoreEmoji(label: string, tags: string[], searchText: string): number {
48+
function scoreEmoji(label: string, tags: string[], searchText: string): number {
4949
let score = 0;
5050

5151
if (label.toLowerCase().includes(searchText)) {

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export * as EmojiPicker from "./components/emoji-picker";
22
export { useActiveEmoji, useSkinTone } from "./hooks";
33
export type { CustomCategory, CustomEmoji } from "./custom-emoji-types";
4-
export { scoreEmoji } from "./data/custom-emoji";
54
export type { AugmentedEmojiPickerRootProps as EmojiPickerRootProps } from "./custom-emoji-types";
65
export type {
76
Category,

0 commit comments

Comments
 (0)