@portabletext/plugin-emoji-picker 1.0.0 → 1.0.1

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.d.cts CHANGED
@@ -1,3 +1,18 @@
1
+ /**
2
+ * The base type representing an emoji match.
3
+ *
4
+ * @beta
5
+ */
6
+ export declare type BaseEmojiMatch =
7
+ | {
8
+ type: 'exact'
9
+ emoji: string
10
+ }
11
+ | {
12
+ type: 'partial'
13
+ emoji: string
14
+ }
15
+
1
16
  /**
2
17
  * Proposed, but not required, function to create a `MatchEmojis` function.
3
18
  *
@@ -15,7 +30,7 @@
15
30
  */
16
31
  export declare function createMatchEmojis(config: {
17
32
  emojis: Record<string, ReadonlyArray<string>>
18
- }): MatchEmojis
33
+ }): MatchEmojis<EmojiMatch>
19
34
 
20
35
  /**
21
36
  * Proposed, but not required type, to represent an emoji match.
@@ -62,7 +77,9 @@ export declare type EmojiMatch =
62
77
  /**
63
78
  * @beta
64
79
  */
65
- export declare type EmojiPicker<TEmojiMatch = EmojiMatch> = {
80
+ export declare type EmojiPicker<
81
+ TEmojiMatch extends BaseEmojiMatch = BaseEmojiMatch,
82
+ > = {
66
83
  /**
67
84
  * The matched keyword, including colons.
68
85
  *
@@ -155,7 +172,9 @@ export declare type EmojiPicker<TEmojiMatch = EmojiMatch> = {
155
172
  /**
156
173
  * @beta
157
174
  */
158
- export declare type EmojiPickerProps<TEmojiMatch = EmojiMatch> = {
175
+ export declare type EmojiPickerProps<
176
+ TEmojiMatch extends BaseEmojiMatch = BaseEmojiMatch,
177
+ > = {
159
178
  matchEmojis: MatchEmojis<TEmojiMatch>
160
179
  }
161
180
 
@@ -164,16 +183,16 @@ export declare type EmojiPickerProps<TEmojiMatch = EmojiMatch> = {
164
183
  *
165
184
  * @beta
166
185
  */
167
- export declare type MatchEmojis<TEmojiMatch = EmojiMatch> = (query: {
168
- keyword: string
169
- }) => ReadonlyArray<TEmojiMatch>
186
+ export declare type MatchEmojis<
187
+ TEmojiMatch extends BaseEmojiMatch = BaseEmojiMatch,
188
+ > = (query: {keyword: string}) => ReadonlyArray<TEmojiMatch>
170
189
 
171
190
  /**
172
191
  * Proposed, but not required, default implementation of `MatchEmojis`.
173
192
  *
174
193
  * @beta
175
194
  */
176
- export declare const matchEmojis: MatchEmojis
195
+ export declare const matchEmojis: MatchEmojis<EmojiMatch>
177
196
 
178
197
  /**
179
198
  * Handles the state and logic needed to create an emoji picker.
@@ -202,8 +221,8 @@ export declare const matchEmojis: MatchEmojis
202
221
  *
203
222
  * @beta
204
223
  */
205
- export declare function useEmojiPicker<TEmojiMatch = EmojiMatch>(
206
- props: EmojiPickerProps<TEmojiMatch>,
207
- ): EmojiPicker<TEmojiMatch>
224
+ export declare function useEmojiPicker<
225
+ TEmojiMatch extends BaseEmojiMatch = BaseEmojiMatch,
226
+ >(props: EmojiPickerProps<TEmojiMatch>): EmojiPicker<TEmojiMatch>
208
227
 
209
228
  export {}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,18 @@
1
+ /**
2
+ * The base type representing an emoji match.
3
+ *
4
+ * @beta
5
+ */
6
+ export declare type BaseEmojiMatch =
7
+ | {
8
+ type: 'exact'
9
+ emoji: string
10
+ }
11
+ | {
12
+ type: 'partial'
13
+ emoji: string
14
+ }
15
+
1
16
  /**
2
17
  * Proposed, but not required, function to create a `MatchEmojis` function.
3
18
  *
@@ -15,7 +30,7 @@
15
30
  */
16
31
  export declare function createMatchEmojis(config: {
17
32
  emojis: Record<string, ReadonlyArray<string>>
18
- }): MatchEmojis
33
+ }): MatchEmojis<EmojiMatch>
19
34
 
20
35
  /**
21
36
  * Proposed, but not required type, to represent an emoji match.
@@ -62,7 +77,9 @@ export declare type EmojiMatch =
62
77
  /**
63
78
  * @beta
64
79
  */
65
- export declare type EmojiPicker<TEmojiMatch = EmojiMatch> = {
80
+ export declare type EmojiPicker<
81
+ TEmojiMatch extends BaseEmojiMatch = BaseEmojiMatch,
82
+ > = {
66
83
  /**
67
84
  * The matched keyword, including colons.
68
85
  *
@@ -155,7 +172,9 @@ export declare type EmojiPicker<TEmojiMatch = EmojiMatch> = {
155
172
  /**
156
173
  * @beta
157
174
  */
158
- export declare type EmojiPickerProps<TEmojiMatch = EmojiMatch> = {
175
+ export declare type EmojiPickerProps<
176
+ TEmojiMatch extends BaseEmojiMatch = BaseEmojiMatch,
177
+ > = {
159
178
  matchEmojis: MatchEmojis<TEmojiMatch>
160
179
  }
161
180
 
@@ -164,16 +183,16 @@ export declare type EmojiPickerProps<TEmojiMatch = EmojiMatch> = {
164
183
  *
165
184
  * @beta
166
185
  */
167
- export declare type MatchEmojis<TEmojiMatch = EmojiMatch> = (query: {
168
- keyword: string
169
- }) => ReadonlyArray<TEmojiMatch>
186
+ export declare type MatchEmojis<
187
+ TEmojiMatch extends BaseEmojiMatch = BaseEmojiMatch,
188
+ > = (query: {keyword: string}) => ReadonlyArray<TEmojiMatch>
170
189
 
171
190
  /**
172
191
  * Proposed, but not required, default implementation of `MatchEmojis`.
173
192
  *
174
193
  * @beta
175
194
  */
176
- export declare const matchEmojis: MatchEmojis
195
+ export declare const matchEmojis: MatchEmojis<EmojiMatch>
177
196
 
178
197
  /**
179
198
  * Handles the state and logic needed to create an emoji picker.
@@ -202,8 +221,8 @@ export declare const matchEmojis: MatchEmojis
202
221
  *
203
222
  * @beta
204
223
  */
205
- export declare function useEmojiPicker<TEmojiMatch = EmojiMatch>(
206
- props: EmojiPickerProps<TEmojiMatch>,
207
- ): EmojiPicker<TEmojiMatch>
224
+ export declare function useEmojiPicker<
225
+ TEmojiMatch extends BaseEmojiMatch = BaseEmojiMatch,
226
+ >(props: EmojiPickerProps<TEmojiMatch>): EmojiPicker<TEmojiMatch>
208
227
 
209
228
  export {}
package/dist/index.js CHANGED
@@ -2623,48 +2623,48 @@ const triggerListenerCallback = ({
2623
2623
  }
2624
2624
  });
2625
2625
  function useEmojiPicker(props) {
2626
- const $ = c(17), editor = useEditor(), t0 = props.matchEmojis;
2627
- let t1;
2628
- $[0] !== editor || $[1] !== t0 ? (t1 = {
2626
+ const $ = c(17), editor = useEditor();
2627
+ let t0;
2628
+ $[0] !== editor || $[1] !== props.matchEmojis ? (t0 = {
2629
2629
  input: {
2630
2630
  editor,
2631
- matchEmojis: t0
2631
+ matchEmojis: props.matchEmojis
2632
2632
  }
2633
- }, $[0] = editor, $[1] = t0, $[2] = t1) : t1 = $[2];
2634
- const emojiPickerActor = useActorRef(emojiPickerMachine, t1), keyword = useSelector(emojiPickerActor, _temp), matches = useSelector(emojiPickerActor, _temp2), selectedIndex = useSelector(emojiPickerActor, _temp3);
2635
- let t2;
2636
- $[3] !== emojiPickerActor ? (t2 = () => {
2633
+ }, $[0] = editor, $[1] = props.matchEmojis, $[2] = t0) : t0 = $[2];
2634
+ const emojiPickerActor = useActorRef(emojiPickerMachine, t0), keyword = useSelector(emojiPickerActor, _temp), matches = useSelector(emojiPickerActor, _temp2), selectedIndex = useSelector(emojiPickerActor, _temp3);
2635
+ let t1;
2636
+ $[3] !== emojiPickerActor ? (t1 = () => {
2637
2637
  emojiPickerActor.send({
2638
2638
  type: "dismiss"
2639
2639
  });
2640
- }, $[3] = emojiPickerActor, $[4] = t2) : t2 = $[4];
2641
- const onDismiss = t2;
2642
- let t3;
2643
- $[5] !== emojiPickerActor ? (t3 = (index) => {
2640
+ }, $[3] = emojiPickerActor, $[4] = t1) : t1 = $[4];
2641
+ const onDismiss = t1;
2642
+ let t2;
2643
+ $[5] !== emojiPickerActor ? (t2 = (index) => {
2644
2644
  emojiPickerActor.send({
2645
2645
  type: "navigate to",
2646
2646
  index
2647
2647
  });
2648
- }, $[5] = emojiPickerActor, $[6] = t3) : t3 = $[6];
2649
- const onNavigateTo = t3;
2650
- let t4;
2651
- $[7] !== editor || $[8] !== emojiPickerActor ? (t4 = () => {
2648
+ }, $[5] = emojiPickerActor, $[6] = t2) : t2 = $[6];
2649
+ const onNavigateTo = t2;
2650
+ let t3;
2651
+ $[7] !== editor || $[8] !== emojiPickerActor ? (t3 = () => {
2652
2652
  emojiPickerActor.send({
2653
2653
  type: "insert selected match"
2654
2654
  }), editor.send({
2655
2655
  type: "focus"
2656
2656
  });
2657
- }, $[7] = editor, $[8] = emojiPickerActor, $[9] = t4) : t4 = $[9];
2658
- const onSelect = t4;
2659
- let t5;
2660
- return $[10] !== keyword || $[11] !== matches || $[12] !== onDismiss || $[13] !== onNavigateTo || $[14] !== onSelect || $[15] !== selectedIndex ? (t5 = {
2657
+ }, $[7] = editor, $[8] = emojiPickerActor, $[9] = t3) : t3 = $[9];
2658
+ const onSelect = t3;
2659
+ let t4;
2660
+ return $[10] !== keyword || $[11] !== matches || $[12] !== onDismiss || $[13] !== onNavigateTo || $[14] !== onSelect || $[15] !== selectedIndex ? (t4 = {
2661
2661
  keyword,
2662
2662
  matches,
2663
2663
  selectedIndex,
2664
2664
  onDismiss,
2665
2665
  onNavigateTo,
2666
2666
  onSelect
2667
- }, $[10] = keyword, $[11] = matches, $[12] = onDismiss, $[13] = onNavigateTo, $[14] = onSelect, $[15] = selectedIndex, $[16] = t5) : t5 = $[16], t5;
2667
+ }, $[10] = keyword, $[11] = matches, $[12] = onDismiss, $[13] = onNavigateTo, $[14] = onSelect, $[15] = selectedIndex, $[16] = t4) : t4 = $[16], t4;
2668
2668
  }
2669
2669
  function _temp3(snapshot_1) {
2670
2670
  return snapshot_1.context.selectedIndex;