@sveltia/ui 0.64.0 → 0.65.0

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.
Files changed (48) hide show
  1. package/dist/components/drawer/drawer.svelte.d.ts +2 -2
  2. package/dist/components/emoji/cache.d.ts +3 -0
  3. package/dist/components/emoji/cache.js +96 -0
  4. package/dist/components/emoji/caret.d.ts +2 -0
  5. package/dist/components/emoji/caret.js +106 -0
  6. package/dist/components/emoji/emoji-suggestions.svelte +424 -0
  7. package/dist/components/emoji/emoji-suggestions.svelte.d.ts +66 -0
  8. package/dist/components/emoji/emoji.d.ts +31 -0
  9. package/dist/components/emoji/emoji.js +208 -0
  10. package/dist/components/emoji/loader.d.ts +6 -0
  11. package/dist/components/emoji/loader.js +74 -0
  12. package/dist/components/text-editor/emoji-autocomplete.svelte +225 -0
  13. package/dist/components/text-editor/emoji-autocomplete.svelte.d.ts +12 -0
  14. package/dist/components/text-editor/shiki/generated.d.ts +1 -1
  15. package/dist/components/text-editor/shiki/generated.js +1 -1
  16. package/dist/components/text-editor/store.svelte.js +1 -0
  17. package/dist/components/text-editor/text-editor.svelte +9 -0
  18. package/dist/components/text-editor/text-editor.svelte.d.ts +10 -0
  19. package/dist/components/text-field/emoji-autocomplete.svelte +165 -0
  20. package/dist/components/text-field/emoji-autocomplete.svelte.d.ts +25 -0
  21. package/dist/components/text-field/text-area.svelte +11 -0
  22. package/dist/components/text-field/text-area.svelte.d.ts +19 -1
  23. package/dist/components/text-field/text-input.svelte +7 -0
  24. package/dist/components/text-field/text-input.svelte.d.ts +10 -0
  25. package/dist/locales/ar.yaml +3 -0
  26. package/dist/locales/bg.yaml +3 -0
  27. package/dist/locales/ca.yaml +3 -0
  28. package/dist/locales/cs.yaml +3 -0
  29. package/dist/locales/el.yaml +3 -0
  30. package/dist/locales/en-CA.yaml +3 -0
  31. package/dist/locales/en-GB.yaml +3 -0
  32. package/dist/locales/en-US.yaml +3 -0
  33. package/dist/locales/es-CO.yaml +3 -0
  34. package/dist/locales/fi.yaml +3 -0
  35. package/dist/locales/fr.yaml +3 -0
  36. package/dist/locales/ja.yaml +3 -0
  37. package/dist/locales/ko.yaml +3 -0
  38. package/dist/locales/nl.yaml +3 -0
  39. package/dist/locales/pl.yaml +3 -0
  40. package/dist/locales/pt-BR.yaml +3 -0
  41. package/dist/locales/pt-PT.yaml +3 -0
  42. package/dist/locales/ru.yaml +3 -0
  43. package/dist/locales/tr.yaml +3 -0
  44. package/dist/locales/uk.yaml +3 -0
  45. package/dist/locales/zh-CN.yaml +3 -0
  46. package/dist/typedefs.d.ts +61 -0
  47. package/dist/typedefs.js +34 -0
  48. package/package.json +2 -1
@@ -756,11 +756,72 @@ export type TextEditorConfig = {
756
756
  * Whether the editor is used as a code editor.
757
757
  */
758
758
  isCodeEditor: boolean;
759
+ /**
760
+ * Whether to autocomplete emojis when the user types a
761
+ * shortcode, like `:smi`. Default: `false`.
762
+ */
763
+ useEmojiAutocomplete?: boolean | undefined;
759
764
  /**
760
765
  * Default language for the code editor.
761
766
  */
762
767
  defaultLanguage?: string | undefined;
763
768
  };
769
+ /**
770
+ * Raw emoji data as published by `emojilib`, keyed by emoji character. Each value lists the
771
+ * canonical name followed by any keywords.
772
+ */
773
+ export type EmojiData = Record<string, string[]>;
774
+ export type EmojiEntry = {
775
+ /**
776
+ * Emoji character, e.g. `🎉`.
777
+ */
778
+ emoji: string;
779
+ /**
780
+ * Canonical name used as the shortcode, e.g. `party_popper`.
781
+ */
782
+ name: string;
783
+ /**
784
+ * Lower-cased alternative keywords, e.g. `party`, `tada`.
785
+ */
786
+ aliases: string[];
787
+ };
788
+ /**
789
+ * A shortcode being typed, as handed to the emoji suggestions. Each host extends this with
790
+ * whatever it needs to locate the shortcode again when the emoji is inserted.
791
+ */
792
+ export type EmojiTrigger = {
793
+ /**
794
+ * Identifier of this shortcode occurrence. It must stay the same while the
795
+ * query grows, so the list can tell a dismissed shortcode from a new one.
796
+ */
797
+ id: string;
798
+ /**
799
+ * Shortcode being typed, without the leading colon.
800
+ */
801
+ query: string;
802
+ };
803
+ /**
804
+ * Viewport-relative bounds of the shortcode being typed, which the emoji suggestions are anchored
805
+ * to.
806
+ */
807
+ export type EmojiAnchorRect = {
808
+ /**
809
+ * Distance from the top of the viewport.
810
+ */
811
+ top: number;
812
+ /**
813
+ * Distance from the top of the viewport to the bottom of the shortcode.
814
+ */
815
+ bottom: number;
816
+ /**
817
+ * Distance from the left of the viewport.
818
+ */
819
+ left: number;
820
+ /**
821
+ * Distance from the left of the viewport to the right of the shortcode.
822
+ */
823
+ right: number;
824
+ };
764
825
  /**
765
826
  * Loaders used to obtain the Shiki syntax highlighting engine, grammars and themes. Each returns
766
827
  * the loaded ES module, or a falsy value when the requested language or theme is unavailable.
package/dist/typedefs.js CHANGED
@@ -314,9 +314,43 @@
314
314
  * @property {boolean} useMarkdownShortcuts Whether to enable Markdown keyboard shortcuts in the
315
315
  * rich text editor.
316
316
  * @property {boolean} isCodeEditor Whether the editor is used as a code editor.
317
+ * @property {boolean} [useEmojiAutocomplete] Whether to autocomplete emojis when the user types a
318
+ * shortcode, like `:smi`. Default: `false`.
317
319
  * @property {string} [defaultLanguage] Default language for the code editor.
318
320
  */
319
321
 
322
+ /**
323
+ * Raw emoji data as published by `emojilib`, keyed by emoji character. Each value lists the
324
+ * canonical name followed by any keywords.
325
+ * @typedef {Record<string, string[]>} EmojiData
326
+ */
327
+
328
+ /**
329
+ * @typedef {object} EmojiEntry
330
+ * @property {string} emoji Emoji character, e.g. `🎉`.
331
+ * @property {string} name Canonical name used as the shortcode, e.g. `party_popper`.
332
+ * @property {string[]} aliases Lower-cased alternative keywords, e.g. `party`, `tada`.
333
+ */
334
+
335
+ /**
336
+ * A shortcode being typed, as handed to the emoji suggestions. Each host extends this with
337
+ * whatever it needs to locate the shortcode again when the emoji is inserted.
338
+ * @typedef {object} EmojiTrigger
339
+ * @property {string} id Identifier of this shortcode occurrence. It must stay the same while the
340
+ * query grows, so the list can tell a dismissed shortcode from a new one.
341
+ * @property {string} query Shortcode being typed, without the leading colon.
342
+ */
343
+
344
+ /**
345
+ * Viewport-relative bounds of the shortcode being typed, which the emoji suggestions are anchored
346
+ * to.
347
+ * @typedef {object} EmojiAnchorRect
348
+ * @property {number} top Distance from the top of the viewport.
349
+ * @property {number} bottom Distance from the top of the viewport to the bottom of the shortcode.
350
+ * @property {number} left Distance from the left of the viewport.
351
+ * @property {number} right Distance from the left of the viewport to the right of the shortcode.
352
+ */
353
+
320
354
  /**
321
355
  * Loaders used to obtain the Shiki syntax highlighting engine, grammars and themes. Each returns
322
356
  * the loaded ES module, or a falsy value when the requested language or theme is unavailable.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.64.0",
3
+ "version": "0.65.0",
4
4
  "description": "A collection of Svelte components and utilities for building user interfaces.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,6 +48,7 @@
48
48
  "@lexical/utils": "^0.49.0",
49
49
  "@sveltia/i18n": "^1.2.3",
50
50
  "@sveltia/utils": "^0.12.1",
51
+ "emojilib": "^4.0.3",
51
52
  "lexical": "^0.49.0"
52
53
  },
53
54
  "devDependencies": {