@independo/capacitor-emoji-picker 1.2.0 → 1.3.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 (111) hide show
  1. package/README.md +25 -7
  2. package/dist/docs.json +54 -0
  3. package/dist/esm/core/emoji-locale.d.ts +4 -0
  4. package/dist/esm/core/emoji-locale.js +32 -0
  5. package/dist/esm/core/emoji-locale.js.map +1 -0
  6. package/dist/esm/definitions.d.ts +44 -0
  7. package/dist/esm/definitions.js.map +1 -1
  8. package/dist/esm/index.d.ts +1 -0
  9. package/dist/esm/index.js +1 -0
  10. package/dist/esm/index.js.map +1 -1
  11. package/dist/esm/platform/web/WebEmojiPickerPresenter.d.ts +7 -0
  12. package/dist/esm/platform/web/WebEmojiPickerPresenter.js +24 -6
  13. package/dist/esm/platform/web/WebEmojiPickerPresenter.js.map +1 -1
  14. package/dist/esm/platform/web/emoji-data-source.d.ts +15 -3
  15. package/dist/esm/platform/web/emoji-data-source.js +70 -11
  16. package/dist/esm/platform/web/emoji-data-source.js.map +1 -1
  17. package/dist/esm/platform/web/locales/bn.d.ts +9 -0
  18. package/dist/esm/platform/web/locales/bn.js +10 -0
  19. package/dist/esm/platform/web/locales/bn.js.map +1 -0
  20. package/dist/esm/platform/web/locales/create-locale-loader.d.ts +11 -0
  21. package/dist/esm/platform/web/locales/create-locale-loader.js +4 -0
  22. package/dist/esm/platform/web/locales/create-locale-loader.js.map +1 -0
  23. package/dist/esm/platform/web/locales/da.d.ts +9 -0
  24. package/dist/esm/platform/web/locales/da.js +10 -0
  25. package/dist/esm/platform/web/locales/da.js.map +1 -0
  26. package/dist/esm/platform/web/locales/de.d.ts +9 -0
  27. package/dist/esm/platform/web/locales/de.js +10 -0
  28. package/dist/esm/platform/web/locales/de.js.map +1 -0
  29. package/dist/esm/platform/web/locales/en-gb.d.ts +5 -0
  30. package/dist/esm/platform/web/locales/en-gb.js +6 -0
  31. package/dist/esm/platform/web/locales/en-gb.js.map +1 -0
  32. package/dist/esm/platform/web/locales/en.d.ts +7 -0
  33. package/dist/esm/platform/web/locales/en.js +9 -0
  34. package/dist/esm/platform/web/locales/en.js.map +1 -0
  35. package/dist/esm/platform/web/locales/es-mx.d.ts +9 -0
  36. package/dist/esm/platform/web/locales/es-mx.js +10 -0
  37. package/dist/esm/platform/web/locales/es-mx.js.map +1 -0
  38. package/dist/esm/platform/web/locales/es.d.ts +9 -0
  39. package/dist/esm/platform/web/locales/es.js +10 -0
  40. package/dist/esm/platform/web/locales/es.js.map +1 -0
  41. package/dist/esm/platform/web/locales/et.d.ts +9 -0
  42. package/dist/esm/platform/web/locales/et.js +10 -0
  43. package/dist/esm/platform/web/locales/et.js.map +1 -0
  44. package/dist/esm/platform/web/locales/fi.d.ts +9 -0
  45. package/dist/esm/platform/web/locales/fi.js +10 -0
  46. package/dist/esm/platform/web/locales/fi.js.map +1 -0
  47. package/dist/esm/platform/web/locales/fr.d.ts +5 -0
  48. package/dist/esm/platform/web/locales/fr.js +6 -0
  49. package/dist/esm/platform/web/locales/fr.js.map +1 -0
  50. package/dist/esm/platform/web/locales/hi.d.ts +9 -0
  51. package/dist/esm/platform/web/locales/hi.js +10 -0
  52. package/dist/esm/platform/web/locales/hi.js.map +1 -0
  53. package/dist/esm/platform/web/locales/hu.d.ts +9 -0
  54. package/dist/esm/platform/web/locales/hu.js +10 -0
  55. package/dist/esm/platform/web/locales/hu.js.map +1 -0
  56. package/dist/esm/platform/web/locales/index.d.ts +36 -0
  57. package/dist/esm/platform/web/locales/index.js +37 -0
  58. package/dist/esm/platform/web/locales/index.js.map +1 -0
  59. package/dist/esm/platform/web/locales/it.d.ts +9 -0
  60. package/dist/esm/platform/web/locales/it.js +10 -0
  61. package/dist/esm/platform/web/locales/it.js.map +1 -0
  62. package/dist/esm/platform/web/locales/ja.d.ts +5 -0
  63. package/dist/esm/platform/web/locales/ja.js +6 -0
  64. package/dist/esm/platform/web/locales/ja.js.map +1 -0
  65. package/dist/esm/platform/web/locales/ko.d.ts +9 -0
  66. package/dist/esm/platform/web/locales/ko.js +10 -0
  67. package/dist/esm/platform/web/locales/ko.js.map +1 -0
  68. package/dist/esm/platform/web/locales/lt.d.ts +9 -0
  69. package/dist/esm/platform/web/locales/lt.js +10 -0
  70. package/dist/esm/platform/web/locales/lt.js.map +1 -0
  71. package/dist/esm/platform/web/locales/ms.d.ts +9 -0
  72. package/dist/esm/platform/web/locales/ms.js +10 -0
  73. package/dist/esm/platform/web/locales/ms.js.map +1 -0
  74. package/dist/esm/platform/web/locales/nb.d.ts +9 -0
  75. package/dist/esm/platform/web/locales/nb.js +10 -0
  76. package/dist/esm/platform/web/locales/nb.js.map +1 -0
  77. package/dist/esm/platform/web/locales/nl.d.ts +9 -0
  78. package/dist/esm/platform/web/locales/nl.js +10 -0
  79. package/dist/esm/platform/web/locales/nl.js.map +1 -0
  80. package/dist/esm/platform/web/locales/pl.d.ts +9 -0
  81. package/dist/esm/platform/web/locales/pl.js +10 -0
  82. package/dist/esm/platform/web/locales/pl.js.map +1 -0
  83. package/dist/esm/platform/web/locales/pt.d.ts +9 -0
  84. package/dist/esm/platform/web/locales/pt.js +10 -0
  85. package/dist/esm/platform/web/locales/pt.js.map +1 -0
  86. package/dist/esm/platform/web/locales/ru.d.ts +5 -0
  87. package/dist/esm/platform/web/locales/ru.js +6 -0
  88. package/dist/esm/platform/web/locales/ru.js.map +1 -0
  89. package/dist/esm/platform/web/locales/sv.d.ts +5 -0
  90. package/dist/esm/platform/web/locales/sv.js +6 -0
  91. package/dist/esm/platform/web/locales/sv.js.map +1 -0
  92. package/dist/esm/platform/web/locales/th.d.ts +9 -0
  93. package/dist/esm/platform/web/locales/th.js +10 -0
  94. package/dist/esm/platform/web/locales/th.js.map +1 -0
  95. package/dist/esm/platform/web/locales/uk.d.ts +9 -0
  96. package/dist/esm/platform/web/locales/uk.js +10 -0
  97. package/dist/esm/platform/web/locales/uk.js.map +1 -0
  98. package/dist/esm/platform/web/locales/vi.d.ts +9 -0
  99. package/dist/esm/platform/web/locales/vi.js +10 -0
  100. package/dist/esm/platform/web/locales/vi.js.map +1 -0
  101. package/dist/esm/platform/web/locales/zh-hant.d.ts +9 -0
  102. package/dist/esm/platform/web/locales/zh-hant.js +10 -0
  103. package/dist/esm/platform/web/locales/zh-hant.js.map +1 -0
  104. package/dist/esm/platform/web/locales/zh.d.ts +5 -0
  105. package/dist/esm/platform/web/locales/zh.js +6 -0
  106. package/dist/esm/platform/web/locales/zh.js.map +1 -0
  107. package/dist/plugin.cjs.js +109 -15
  108. package/dist/plugin.cjs.js.map +1 -1
  109. package/dist/plugin.js +109 -15
  110. package/dist/plugin.js.map +1 -1
  111. package/package.json +1 -1
package/README.md CHANGED
@@ -199,13 +199,15 @@ Result of presenting the emoji picker.
199
199
 
200
200
  Options for presenting the emoji picker.
201
201
 
202
- | Prop | Type | Description | Default |
203
- | -------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
204
- | **`presentation`** | <code><a href="#emojipickerpresentation">EmojiPickerPresentation</a></code> | `auto`: prefer native/system UI and fall back to the web picker when native presentation is not available or fails. `web`: always use the web picker, including inside Capacitor native apps. | <code>'auto'</code> |
205
- | **`closeButton`** | <code><a href="#emojipickerclosebuttonoptions">EmojiPickerCloseButtonOptions</a></code> | Configures the close button rendered above the iOS keyboard/the web picker sheet (iOS has no system-provided one). Ignored on Android. | |
206
- | **`backdrop`** | <code><a href="#emojipickerbackdropoptions">EmojiPickerBackdropOptions</a></code> | Configures the dimming/blur shown behind the picker. | |
207
- | **`dismissOnBackdropTap`** | <code>boolean</code> | Dismiss the picker when the user taps the transparent area outside the keyboard/button (iOS) or the scrim outside the picker sheet (Android and web). On iOS and web, if `closeButton.hidden` is `true`, this is treated as `true` regardless of the value passed here, so the user always has a way to dismiss the picker. | <code>true</code> |
208
- | **`theme`** | <code><a href="#emojipickertheme">EmojiPickerTheme</a></code> | `system`: follows the OS/app appearance setting. `light` / `dark`: forces the picker's appearance regardless of the system setting. On iOS native presentation, this also sets `keyboardAppearance` on the underlying text input, which is the mechanism the system emoji keyboard itself honors (separate from the app's own `overrideUserInterfaceStyle`, which only themes the plugin's own overlay/close button). | <code>'system'</code> |
202
+ | Prop | Type | Description | Default |
203
+ | -------------------------- | --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
204
+ | **`presentation`** | <code><a href="#emojipickerpresentation">EmojiPickerPresentation</a></code> | `auto`: prefer native/system UI and fall back to the web picker when native presentation is not available or fails. `web`: always use the web picker, including inside Capacitor native apps. | <code>'auto'</code> |
205
+ | **`closeButton`** | <code><a href="#emojipickerclosebuttonoptions">EmojiPickerCloseButtonOptions</a></code> | Configures the close button rendered above the iOS keyboard/the web picker sheet (iOS has no system-provided one). Ignored on Android. | |
206
+ | **`backdrop`** | <code><a href="#emojipickerbackdropoptions">EmojiPickerBackdropOptions</a></code> | Configures the dimming/blur shown behind the picker. | |
207
+ | **`dismissOnBackdropTap`** | <code>boolean</code> | Dismiss the picker when the user taps the transparent area outside the keyboard/button (iOS) or the scrim outside the picker sheet (Android and web). On iOS and web, if `closeButton.hidden` is `true`, this is treated as `true` regardless of the value passed here, so the user always has a way to dismiss the picker. | <code>true</code> |
208
+ | **`theme`** | <code><a href="#emojipickertheme">EmojiPickerTheme</a></code> | `system`: follows the OS/app appearance setting. `light` / `dark`: forces the picker's appearance regardless of the system setting. On iOS native presentation, this also sets `keyboardAppearance` on the underlying text input, which is the mechanism the system emoji keyboard itself honors (separate from the app's own `overrideUserInterfaceStyle`, which only themes the plugin's own overlay/close button). | <code>'system'</code> |
209
+ | **`locale`** | <code><a href="#emojipickerlocale">EmojiPickerLocale</a></code> | BCP-47-ish locale code for the emoji dataset/UI strings (e.g. `'en'`, `'de'`, `'fr'`). Web only — ignored on iOS/Android, which follow the device locale automatically via the system emoji keyboard/`androidx.emoji2.emojipicker`. `'en'` is the only locale bundled and available offline by default; any other locale is fetched from a CDN at present-time unless registered ahead of time via `registerEmojiLocale`. Every locale `emoji-picker-element-data` ships is available as an individually importable loader (e.g. `enGbLocale`, `ptLocale`, `zhHantLocale`, ...) from `capacitor-emoji-picker/dist/esm/platform/web/locales`, each carrying its own code as a typed `.locale` property, so an app can register — and pass to this option — any of them offline without a CDN dependency by importing only the ones it needs: ```ts import { registerEmojiLocale } from 'capacitor-emoji-picker'; import { ptLocale } from 'capacitor-emoji-picker/dist/esm/platform/web/locales'; registerEmojiLocale(ptLocale.locale, await ptLocale()); EmojiPicker.present({ locale: ptLocale.locale }); ``` This is a deep import rather than a root-level export deliberately: the package root is also the standalone `dist/plugin.js` bundle's entry point, which inlines every dynamic import it can reach (there's no code-splitting in that single-file build) — re-exporting all 28 loaders from there would have pulled every locale's dataset into it. A bundler resolving this deep import still tree-shakes away every loader (and its underlying dataset) the app never imports. | <code>'en'</code> |
210
+ | **`skinTone`** | <code>0 \| 1 \| 2 \| 5 \| 4 \| 3</code> | Seeds the picker's starting skin tone (`0` = none/default, `1`-`5` = light through dark). Web only — iOS/Android use the OS's own last-selected skin tone. On web, the underlying picker persists the user's own choice after this via IndexedDB (keyed by `locale`), so this only affects the very first render for a given locale/origin. | <code>0</code> |
209
211
 
210
212
 
211
213
  #### EmojiPickerCloseButtonOptions
@@ -245,6 +247,22 @@ The picker's appearance.
245
247
 
246
248
  <code>'system' | 'light' | 'dark'</code>
247
249
 
250
+
251
+ #### EmojiPickerLocale
252
+
253
+ A locale code `emoji-picker-element-data` ships a dataset for, usable with
254
+ `EmojiPickerOptions.locale`/`registerEmojiLocale`. Widened to accept any other string too, so a
255
+ locale registered under a code outside this list still type-checks.
256
+
257
+ <code><a href="#emojipickerlocalecode">EmojiPickerLocaleCode</a> | (string & {})</code>
258
+
259
+
260
+ #### EmojiPickerLocaleCode
261
+
262
+ One of the locale codes `emoji-picker-element-data` ships a dataset for.
263
+
264
+ <code>(typeof EMOJI_PICKER_LOCALES)[number]</code>
265
+
248
266
  </docgen-api>
249
267
 
250
268
  ---
package/dist/docs.json CHANGED
@@ -121,6 +121,32 @@
121
121
  "EmojiPickerTheme"
122
122
  ],
123
123
  "type": "EmojiPickerTheme"
124
+ },
125
+ {
126
+ "name": "locale",
127
+ "tags": [
128
+ {
129
+ "text": "'en'",
130
+ "name": "default"
131
+ }
132
+ ],
133
+ "docs": "BCP-47-ish locale code for the emoji dataset/UI strings (e.g. `'en'`, `'de'`, `'fr'`).\n\nWeb only — ignored on iOS/Android, which follow the device locale automatically via the\nsystem emoji keyboard/`androidx.emoji2.emojipicker`. `'en'` is the only locale bundled and\navailable offline by default; any other locale is fetched from a CDN at present-time unless\nregistered ahead of time via `registerEmojiLocale`.\n\nEvery locale `emoji-picker-element-data` ships is available as an individually importable\nloader (e.g. `enGbLocale`, `ptLocale`, `zhHantLocale`, ...) from\n`capacitor-emoji-picker/dist/esm/platform/web/locales`, each carrying its own code as a\ntyped `.locale` property, so an app can register — and pass to this option — any of them\noffline without a CDN dependency by importing only the ones it needs:\n```ts\nimport { registerEmojiLocale } from 'capacitor-emoji-picker';\nimport { ptLocale } from 'capacitor-emoji-picker/dist/esm/platform/web/locales';\nregisterEmojiLocale(ptLocale.locale, await ptLocale());\nEmojiPicker.present({ locale: ptLocale.locale });\n```\nThis is a deep import rather than a root-level export deliberately: the package root is\nalso the standalone `dist/plugin.js` bundle's entry point, which inlines every dynamic\nimport it can reach (there's no code-splitting in that single-file build) — re-exporting\nall 28 loaders from there would have pulled every locale's dataset into it. A bundler\nresolving this deep import still tree-shakes away every loader (and its underlying\ndataset) the app never imports.",
134
+ "complexTypes": [
135
+ "EmojiPickerLocale"
136
+ ],
137
+ "type": "EmojiPickerLocale"
138
+ },
139
+ {
140
+ "name": "skinTone",
141
+ "tags": [
142
+ {
143
+ "text": "0",
144
+ "name": "default"
145
+ }
146
+ ],
147
+ "docs": "Seeds the picker's starting skin tone (`0` = none/default, `1`-`5` = light through dark).\n\nWeb only — iOS/Android use the OS's own last-selected skin tone. On web, the underlying\npicker persists the user's own choice after this via IndexedDB (keyed by `locale`), so this\nonly affects the very first render for a given locale/origin.",
148
+ "complexTypes": [],
149
+ "type": "0 | 1 | 2 | 5 | 4 | 3 | undefined"
124
150
  }
125
151
  ]
126
152
  },
@@ -238,6 +264,34 @@
238
264
  "complexTypes": []
239
265
  }
240
266
  ]
267
+ },
268
+ {
269
+ "name": "EmojiPickerLocale",
270
+ "slug": "emojipickerlocale",
271
+ "docs": "A locale code `emoji-picker-element-data` ships a dataset for, usable with\n`EmojiPickerOptions.locale`/`registerEmojiLocale`. Widened to accept any other string too, so a\nlocale registered under a code outside this list still type-checks.",
272
+ "types": [
273
+ {
274
+ "text": "EmojiPickerLocaleCode",
275
+ "complexTypes": [
276
+ "EmojiPickerLocaleCode"
277
+ ]
278
+ },
279
+ {
280
+ "text": "(string & {})",
281
+ "complexTypes": []
282
+ }
283
+ ]
284
+ },
285
+ {
286
+ "name": "EmojiPickerLocaleCode",
287
+ "slug": "emojipickerlocalecode",
288
+ "docs": "One of the locale codes `emoji-picker-element-data` ships a dataset for.",
289
+ "types": [
290
+ {
291
+ "text": "(typeof EMOJI_PICKER_LOCALES)[number]",
292
+ "complexTypes": []
293
+ }
294
+ ]
241
295
  }
242
296
  ],
243
297
  "pluginConfigs": []
@@ -0,0 +1,4 @@
1
+ /** Every locale `emoji-picker-element-data` ships a dataset for. */
2
+ export declare const EMOJI_PICKER_LOCALES: readonly ["en", "bn", "da", "de", "en-gb", "es-mx", "es", "et", "fi", "fr", "hi", "hu", "it", "ja", "ko", "lt", "ms", "nb", "nl", "pl", "pt", "ru", "sv", "th", "uk", "vi", "zh", "zh-hant"];
3
+ /** One of the locale codes `emoji-picker-element-data` ships a dataset for. */
4
+ export type EmojiPickerLocaleCode = (typeof EMOJI_PICKER_LOCALES)[number];
@@ -0,0 +1,32 @@
1
+ /** Every locale `emoji-picker-element-data` ships a dataset for. */
2
+ export const EMOJI_PICKER_LOCALES = [
3
+ 'en',
4
+ 'bn',
5
+ 'da',
6
+ 'de',
7
+ 'en-gb',
8
+ 'es-mx',
9
+ 'es',
10
+ 'et',
11
+ 'fi',
12
+ 'fr',
13
+ 'hi',
14
+ 'hu',
15
+ 'it',
16
+ 'ja',
17
+ 'ko',
18
+ 'lt',
19
+ 'ms',
20
+ 'nb',
21
+ 'nl',
22
+ 'pl',
23
+ 'pt',
24
+ 'ru',
25
+ 'sv',
26
+ 'th',
27
+ 'uk',
28
+ 'vi',
29
+ 'zh',
30
+ 'zh-hant',
31
+ ];
32
+ //# sourceMappingURL=emoji-locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emoji-locale.js","sourceRoot":"","sources":["../../../src/core/emoji-locale.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,SAAS;CACH,CAAC","sourcesContent":["/** Every locale `emoji-picker-element-data` ships a dataset for. */\nexport const EMOJI_PICKER_LOCALES = [\n 'en',\n 'bn',\n 'da',\n 'de',\n 'en-gb',\n 'es-mx',\n 'es',\n 'et',\n 'fi',\n 'fr',\n 'hi',\n 'hu',\n 'it',\n 'ja',\n 'ko',\n 'lt',\n 'ms',\n 'nb',\n 'nl',\n 'pl',\n 'pt',\n 'ru',\n 'sv',\n 'th',\n 'uk',\n 'vi',\n 'zh',\n 'zh-hant',\n] as const;\n\n/** One of the locale codes `emoji-picker-element-data` ships a dataset for. */\nexport type EmojiPickerLocaleCode = (typeof EMOJI_PICKER_LOCALES)[number];\n"]}
@@ -1,3 +1,4 @@
1
+ import type { EmojiPickerLocaleCode } from './core/emoji-locale';
1
2
  /**
2
3
  * How the picker should be presented.
3
4
  */
@@ -6,6 +7,12 @@ export type EmojiPickerPresentation = 'auto' | 'web';
6
7
  * The picker's appearance.
7
8
  */
8
9
  export type EmojiPickerTheme = 'system' | 'light' | 'dark';
10
+ /**
11
+ * A locale code `emoji-picker-element-data` ships a dataset for, usable with
12
+ * `EmojiPickerOptions.locale`/`registerEmojiLocale`. Widened to accept any other string too, so a
13
+ * locale registered under a code outside this list still type-checks.
14
+ */
15
+ export type EmojiPickerLocale = EmojiPickerLocaleCode | (string & {});
9
16
  /**
10
17
  * Options for presenting the emoji picker.
11
18
  */
@@ -46,6 +53,43 @@ export interface EmojiPickerOptions {
46
53
  * @default 'system'
47
54
  */
48
55
  theme?: EmojiPickerTheme;
56
+ /**
57
+ * BCP-47-ish locale code for the emoji dataset/UI strings (e.g. `'en'`, `'de'`, `'fr'`).
58
+ *
59
+ * Web only — ignored on iOS/Android, which follow the device locale automatically via the
60
+ * system emoji keyboard/`androidx.emoji2.emojipicker`. `'en'` is the only locale bundled and
61
+ * available offline by default; any other locale is fetched from a CDN at present-time unless
62
+ * registered ahead of time via `registerEmojiLocale`.
63
+ *
64
+ * Every locale `emoji-picker-element-data` ships is available as an individually importable
65
+ * loader (e.g. `enGbLocale`, `ptLocale`, `zhHantLocale`, ...) from
66
+ * `capacitor-emoji-picker/dist/esm/platform/web/locales`, each carrying its own code as a
67
+ * typed `.locale` property, so an app can register — and pass to this option — any of them
68
+ * offline without a CDN dependency by importing only the ones it needs:
69
+ * ```ts
70
+ * import { registerEmojiLocale } from 'capacitor-emoji-picker';
71
+ * import { ptLocale } from 'capacitor-emoji-picker/dist/esm/platform/web/locales';
72
+ * registerEmojiLocale(ptLocale.locale, await ptLocale());
73
+ * EmojiPicker.present({ locale: ptLocale.locale });
74
+ * ```
75
+ * This is a deep import rather than a root-level export deliberately: the package root is
76
+ * also the standalone `dist/plugin.js` bundle's entry point, which inlines every dynamic
77
+ * import it can reach (there's no code-splitting in that single-file build) — re-exporting
78
+ * all 28 loaders from there would have pulled every locale's dataset into it. A bundler
79
+ * resolving this deep import still tree-shakes away every loader (and its underlying
80
+ * dataset) the app never imports.
81
+ * @default 'en'
82
+ */
83
+ locale?: EmojiPickerLocale;
84
+ /**
85
+ * Seeds the picker's starting skin tone (`0` = none/default, `1`-`5` = light through dark).
86
+ *
87
+ * Web only — iOS/Android use the OS's own last-selected skin tone. On web, the underlying
88
+ * picker persists the user's own choice after this via IndexedDB (keyed by `locale`), so this
89
+ * only affects the very first render for a given locale/origin.
90
+ * @default 0
91
+ */
92
+ skinTone?: 0 | 1 | 2 | 3 | 4 | 5;
49
93
  }
50
94
  /**
51
95
  * Configures the close button rendered above the iOS native emoji keyboard/the web picker sheet.
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * How the picker should be presented.\n */\nexport type EmojiPickerPresentation = 'auto' | 'web';\n\n/**\n * The picker's appearance.\n */\nexport type EmojiPickerTheme = 'system' | 'light' | 'dark';\n\n/**\n * Options for presenting the emoji picker.\n */\nexport interface EmojiPickerOptions {\n /**\n * `auto`: prefer native/system UI and fall back to the web picker when native presentation\n * is not available or fails.\n * `web`: always use the web picker, including inside Capacitor native apps.\n * @default 'auto'\n */\n presentation?: EmojiPickerPresentation;\n /**\n * Configures the close button rendered above the iOS keyboard/the web picker sheet (iOS has\n * no system-provided one). Ignored on Android.\n */\n closeButton?: EmojiPickerCloseButtonOptions;\n /**\n * Configures the dimming/blur shown behind the picker.\n */\n backdrop?: EmojiPickerBackdropOptions;\n /**\n * Dismiss the picker when the user taps the transparent area outside the keyboard/button (iOS)\n * or the scrim outside the picker sheet (Android and web).\n *\n * On iOS and web, if `closeButton.hidden` is `true`, this is treated as `true` regardless of\n * the value passed here, so the user always has a way to dismiss the picker.\n * @default true\n */\n dismissOnBackdropTap?: boolean;\n /**\n * `system`: follows the OS/app appearance setting.\n * `light` / `dark`: forces the picker's appearance regardless of the system setting.\n *\n * On iOS native presentation, this also sets `keyboardAppearance` on the underlying text\n * input, which is the mechanism the system emoji keyboard itself honors (separate from the\n * app's own `overrideUserInterfaceStyle`, which only themes the plugin's own overlay/close\n * button).\n * @default 'system'\n */\n theme?: EmojiPickerTheme;\n}\n\n/**\n * Configures the close button rendered above the iOS native emoji keyboard/the web picker sheet.\n */\nexport interface EmojiPickerCloseButtonOptions {\n /**\n * `xSmall`: 24pt, `small`: 32pt, `medium`: 48pt, `large`: 64pt.\n * @default 'medium'\n */\n size?: 'xSmall' | 'small' | 'medium' | 'large';\n /**\n * Which side of the keyboard the button docks to.\n * @default 'right'\n */\n position?: 'left' | 'center' | 'right';\n /**\n * Hides the built-in close button. See `EmojiPickerOptions.dismissOnBackdropTap` for the\n * safety net this triggers.\n * @default false\n */\n hidden?: boolean;\n}\n\n/**\n * Configures the dimming/blur shown behind the picker.\n */\nexport interface EmojiPickerBackdropOptions {\n /**\n * CSS hex color for the backdrop; the alpha channel controls darkness (e.g. `'#000000cc'` is\n * 80% black, `'#00000000'` is no darkening). Supports `#RGB`, `#RRGGBB`, and `#RRGGBBAA`.\n * Falls back to the default on an invalid value.\n * @default '#00000066'\n */\n color?: string;\n /**\n * Backdrop blur radius in px, analogous to CSS `backdrop-filter: blur()`.\n *\n * Web applies this directly. iOS approximates it by mapping the value to the nearest system\n * blur material (there is no continuous-radius blur API). Android has no API to blur content\n * behind a dialog window, so this option is accepted but has no visual effect there.\n * @default 0\n */\n blur?: number;\n}\n\n/**\n * Result of presenting the emoji picker.\n */\nexport interface EmojiPickerResult {\n /**\n * The selected emoji as a complete Unicode string/grapheme (unchanged), or `null` when the\n * picker was dismissed without a selection.\n */\n emoji: string | null;\n}\n\n/**\n * Interface for the EmojiPicker plugin, which presents a native or web emoji picker and\n * resolves with the emoji the user selected.\n */\nexport interface EmojiPickerPlugin {\n /**\n * Presents the emoji picker.\n *\n * Resolves with `{ emoji: null }` rather than leaving the promise pending when the user\n * dismisses the picker without selecting an emoji.\n *\n * Calling this method again while a picker is already active rejects immediately with the\n * `ALREADY_PRESENTING` error code rather than presenting a second, overlapping picker.\n *\n * @param options The options for the presentation.\n * @returns A promise that resolves to an EmojiPickerResult.\n * @throws Error with code `ALREADY_PRESENTING` if a picker is already active.\n */\n present(options?: EmojiPickerOptions): Promise<EmojiPickerResult>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { EmojiPickerLocaleCode } from './core/emoji-locale';\n\n/**\n * How the picker should be presented.\n */\nexport type EmojiPickerPresentation = 'auto' | 'web';\n\n/**\n * The picker's appearance.\n */\nexport type EmojiPickerTheme = 'system' | 'light' | 'dark';\n\n/**\n * A locale code `emoji-picker-element-data` ships a dataset for, usable with\n * `EmojiPickerOptions.locale`/`registerEmojiLocale`. Widened to accept any other string too, so a\n * locale registered under a code outside this list still type-checks.\n */\n// `string & {}` is the standard trick for \"literal union with editor autocomplete, but any\n// string still type-checks\".\nexport type EmojiPickerLocale = EmojiPickerLocaleCode | (string & {});\n\n/**\n * Options for presenting the emoji picker.\n */\nexport interface EmojiPickerOptions {\n /**\n * `auto`: prefer native/system UI and fall back to the web picker when native presentation\n * is not available or fails.\n * `web`: always use the web picker, including inside Capacitor native apps.\n * @default 'auto'\n */\n presentation?: EmojiPickerPresentation;\n /**\n * Configures the close button rendered above the iOS keyboard/the web picker sheet (iOS has\n * no system-provided one). Ignored on Android.\n */\n closeButton?: EmojiPickerCloseButtonOptions;\n /**\n * Configures the dimming/blur shown behind the picker.\n */\n backdrop?: EmojiPickerBackdropOptions;\n /**\n * Dismiss the picker when the user taps the transparent area outside the keyboard/button (iOS)\n * or the scrim outside the picker sheet (Android and web).\n *\n * On iOS and web, if `closeButton.hidden` is `true`, this is treated as `true` regardless of\n * the value passed here, so the user always has a way to dismiss the picker.\n * @default true\n */\n dismissOnBackdropTap?: boolean;\n /**\n * `system`: follows the OS/app appearance setting.\n * `light` / `dark`: forces the picker's appearance regardless of the system setting.\n *\n * On iOS native presentation, this also sets `keyboardAppearance` on the underlying text\n * input, which is the mechanism the system emoji keyboard itself honors (separate from the\n * app's own `overrideUserInterfaceStyle`, which only themes the plugin's own overlay/close\n * button).\n * @default 'system'\n */\n theme?: EmojiPickerTheme;\n /**\n * BCP-47-ish locale code for the emoji dataset/UI strings (e.g. `'en'`, `'de'`, `'fr'`).\n *\n * Web only — ignored on iOS/Android, which follow the device locale automatically via the\n * system emoji keyboard/`androidx.emoji2.emojipicker`. `'en'` is the only locale bundled and\n * available offline by default; any other locale is fetched from a CDN at present-time unless\n * registered ahead of time via `registerEmojiLocale`.\n *\n * Every locale `emoji-picker-element-data` ships is available as an individually importable\n * loader (e.g. `enGbLocale`, `ptLocale`, `zhHantLocale`, ...) from\n * `capacitor-emoji-picker/dist/esm/platform/web/locales`, each carrying its own code as a\n * typed `.locale` property, so an app can register — and pass to this option — any of them\n * offline without a CDN dependency by importing only the ones it needs:\n * ```ts\n * import { registerEmojiLocale } from 'capacitor-emoji-picker';\n * import { ptLocale } from 'capacitor-emoji-picker/dist/esm/platform/web/locales';\n * registerEmojiLocale(ptLocale.locale, await ptLocale());\n * EmojiPicker.present({ locale: ptLocale.locale });\n * ```\n * This is a deep import rather than a root-level export deliberately: the package root is\n * also the standalone `dist/plugin.js` bundle's entry point, which inlines every dynamic\n * import it can reach (there's no code-splitting in that single-file build) — re-exporting\n * all 28 loaders from there would have pulled every locale's dataset into it. A bundler\n * resolving this deep import still tree-shakes away every loader (and its underlying\n * dataset) the app never imports.\n * @default 'en'\n */\n locale?: EmojiPickerLocale;\n /**\n * Seeds the picker's starting skin tone (`0` = none/default, `1`-`5` = light through dark).\n *\n * Web only — iOS/Android use the OS's own last-selected skin tone. On web, the underlying\n * picker persists the user's own choice after this via IndexedDB (keyed by `locale`), so this\n * only affects the very first render for a given locale/origin.\n * @default 0\n */\n skinTone?: 0 | 1 | 2 | 3 | 4 | 5;\n}\n\n/**\n * Configures the close button rendered above the iOS native emoji keyboard/the web picker sheet.\n */\nexport interface EmojiPickerCloseButtonOptions {\n /**\n * `xSmall`: 24pt, `small`: 32pt, `medium`: 48pt, `large`: 64pt.\n * @default 'medium'\n */\n size?: 'xSmall' | 'small' | 'medium' | 'large';\n /**\n * Which side of the keyboard the button docks to.\n * @default 'right'\n */\n position?: 'left' | 'center' | 'right';\n /**\n * Hides the built-in close button. See `EmojiPickerOptions.dismissOnBackdropTap` for the\n * safety net this triggers.\n * @default false\n */\n hidden?: boolean;\n}\n\n/**\n * Configures the dimming/blur shown behind the picker.\n */\nexport interface EmojiPickerBackdropOptions {\n /**\n * CSS hex color for the backdrop; the alpha channel controls darkness (e.g. `'#000000cc'` is\n * 80% black, `'#00000000'` is no darkening). Supports `#RGB`, `#RRGGBB`, and `#RRGGBBAA`.\n * Falls back to the default on an invalid value.\n * @default '#00000066'\n */\n color?: string;\n /**\n * Backdrop blur radius in px, analogous to CSS `backdrop-filter: blur()`.\n *\n * Web applies this directly. iOS approximates it by mapping the value to the nearest system\n * blur material (there is no continuous-radius blur API). Android has no API to blur content\n * behind a dialog window, so this option is accepted but has no visual effect there.\n * @default 0\n */\n blur?: number;\n}\n\n/**\n * Result of presenting the emoji picker.\n */\nexport interface EmojiPickerResult {\n /**\n * The selected emoji as a complete Unicode string/grapheme (unchanged), or `null` when the\n * picker was dismissed without a selection.\n */\n emoji: string | null;\n}\n\n/**\n * Interface for the EmojiPicker plugin, which presents a native or web emoji picker and\n * resolves with the emoji the user selected.\n */\nexport interface EmojiPickerPlugin {\n /**\n * Presents the emoji picker.\n *\n * Resolves with `{ emoji: null }` rather than leaving the promise pending when the user\n * dismisses the picker without selecting an emoji.\n *\n * Calling this method again while a picker is already active rejects immediately with the\n * `ALREADY_PRESENTING` error code rather than presenting a second, overlapping picker.\n *\n * @param options The options for the presentation.\n * @returns A promise that resolves to an EmojiPickerResult.\n * @throws Error with code `ALREADY_PRESENTING` if a picker is already active.\n */\n present(options?: EmojiPickerOptions): Promise<EmojiPickerResult>;\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { EmojiPickerPlugin } from './definitions';
2
+ export { registerEmojiLocale } from './platform/web/emoji-data-source';
2
3
  declare const EmojiPicker: EmojiPickerPlugin;
3
4
  export * from './definitions';
4
5
  export { EmojiPicker };
package/dist/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { registerPlugin } from '@capacitor/core';
2
2
  import { registerNativeWebBridge } from './platform/web/nativeWebBridge';
3
+ export { registerEmojiLocale } from './platform/web/emoji-data-source';
3
4
  const EmojiPicker = registerPlugin('EmojiPicker', {
4
5
  web: () => import('./web').then((m) => new m.EmojiPickerWeb()),
5
6
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,MAAM,WAAW,GAAG,cAAc,CAAoB,aAAa,EAAE;IACjE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CACjE,CAAC,CAAC;AAEH,uBAAuB,EAAE,CAAC;AAE1B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { EmojiPickerPlugin } from './definitions';\nimport { registerNativeWebBridge } from './platform/web/nativeWebBridge';\n\nconst EmojiPicker = registerPlugin<EmojiPickerPlugin>('EmojiPicker', {\n web: () => import('./web').then((m) => new m.EmojiPickerWeb()),\n});\n\nregisterNativeWebBridge();\n\nexport * from './definitions';\nexport { EmojiPicker };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,MAAM,WAAW,GAAG,cAAc,CAAoB,aAAa,EAAE;IACjE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CACjE,CAAC,CAAC;AAEH,uBAAuB,EAAE,CAAC;AAE1B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { EmojiPickerPlugin } from './definitions';\nimport { registerNativeWebBridge } from './platform/web/nativeWebBridge';\n\nexport { registerEmojiLocale } from './platform/web/emoji-data-source';\n\nconst EmojiPicker = registerPlugin<EmojiPickerPlugin>('EmojiPicker', {\n web: () => import('./web').then((m) => new m.EmojiPickerWeb()),\n});\n\nregisterNativeWebBridge();\n\nexport * from './definitions';\nexport { EmojiPicker };\n"]}
@@ -2,10 +2,15 @@ import type { EmojiPickerOptions, EmojiPickerResult } from '../../definitions';
2
2
  /** Minimal shape of the `<emoji-picker>` custom element this presenter depends on. */
3
3
  export interface EmojiPickerElement extends HTMLElement {
4
4
  dataSource: string;
5
+ locale: string;
5
6
  }
6
7
  export interface WebEmojiPickerPresenterOptions {
7
8
  /** Creates the picker element. Overridable for testing. */
8
9
  createPickerElement?: () => Promise<EmojiPickerElement>;
10
+ /** Seeds the locale's persisted preferred skin tone. Overridable for testing. */
11
+ seedSkinTone?: (locale: string, skinTone: number) => Promise<void>;
12
+ /** Resolves the `dataSource` URL for a locale. Overridable for testing. */
13
+ getDataSourceUrl?: (locale: string) => Promise<string>;
9
14
  }
10
15
  /**
11
16
  * Presents `emoji-picker-element` in a bottom-sheet `<dialog>` and resolves with the selected emoji.
@@ -15,6 +20,8 @@ export interface WebEmojiPickerPresenterOptions {
15
20
  */
16
21
  export declare class WebEmojiPickerPresenter {
17
22
  private readonly createPickerElement;
23
+ private readonly seedSkinTone;
24
+ private readonly getDataSourceUrl;
18
25
  constructor(options?: WebEmojiPickerPresenterOptions);
19
26
  present(options?: EmojiPickerOptions, presentOptions?: {
20
27
  signal?: AbortSignal;
@@ -1,5 +1,5 @@
1
1
  import { ErrorCodes } from '../../core/error-codes';
2
- import { getBundledEmojiDataSourceUrl } from './emoji-data-source';
2
+ import { getEmojiDataSourceUrl } from './emoji-data-source';
3
3
  /** Registers `<emoji-picker>` (if needed) and creates the element. */
4
4
  async function defaultCreatePickerElement() {
5
5
  try {
@@ -201,6 +201,16 @@ function createCloseButtonHeader(options) {
201
201
  header.appendChild(button);
202
202
  return { header, button };
203
203
  }
204
+ /**
205
+ * Seeds `locale`'s persisted preferred skin tone via `emoji-picker-element`'s own `Database`, so
206
+ * `<emoji-picker>` picks it up as its default on render. A no-op for `skinTone === undefined`,
207
+ * so an already-made user choice (persisted in IndexedDB) is never overwritten.
208
+ */
209
+ async function defaultSeedSkinTone(locale, skinTone) {
210
+ const { default: Database } = await import('emoji-picker-element/database');
211
+ const db = new Database({ locale });
212
+ await db.setPreferredSkinTone(skinTone);
213
+ }
204
214
  /**
205
215
  * Presents `emoji-picker-element` in a bottom-sheet `<dialog>` and resolves with the selected emoji.
206
216
  *
@@ -209,11 +219,13 @@ function createCloseButtonHeader(options) {
209
219
  */
210
220
  export class WebEmojiPickerPresenter {
211
221
  constructor(options = {}) {
212
- var _a;
222
+ var _a, _b, _c;
213
223
  this.createPickerElement = (_a = options.createPickerElement) !== null && _a !== void 0 ? _a : defaultCreatePickerElement;
224
+ this.seedSkinTone = (_b = options.seedSkinTone) !== null && _b !== void 0 ? _b : defaultSeedSkinTone;
225
+ this.getDataSourceUrl = (_c = options.getDataSourceUrl) !== null && _c !== void 0 ? _c : getEmojiDataSourceUrl;
214
226
  }
215
227
  async present(options = {}, presentOptions = {}) {
216
- var _a, _b, _c, _d;
228
+ var _a, _b, _c, _d, _e;
217
229
  const { signal } = presentOptions;
218
230
  const closeButtonOptions = (_a = options.closeButton) !== null && _a !== void 0 ? _a : {};
219
231
  // A hidden close button must never leave the user with zero ways to dismiss the picker,
@@ -224,13 +236,19 @@ export class WebEmojiPickerPresenter {
224
236
  // `prefers-color-scheme` tracking) so the picker and the sheet chrome around it always
225
237
  // agree, fixing the mismatch from issue #19.
226
238
  const resolvedTheme = resolveTheme(options.theme);
239
+ const locale = (_d = options.locale) !== null && _d !== void 0 ? _d : 'en';
240
+ if (options.skinTone !== undefined) {
241
+ // Seeded before the element is created so its initial render already reflects it.
242
+ await this.seedSkinTone(locale, options.skinTone);
243
+ }
227
244
  let picker;
228
245
  try {
229
246
  picker = await this.createPickerElement();
230
- picker.dataSource = getBundledEmojiDataSourceUrl();
247
+ picker.locale = locale;
248
+ picker.dataSource = await this.getDataSourceUrl(locale);
231
249
  picker.classList.add(resolvedTheme);
232
250
  }
233
- catch (_e) {
251
+ catch (_f) {
234
252
  throw new Error(ErrorCodes.NOT_IMPLEMENTED);
235
253
  }
236
254
  ensureSheetStylesInjected();
@@ -243,7 +261,7 @@ export class WebEmojiPickerPresenter {
243
261
  // border makes it read as full width, part of the sheet rather than nested inside it.
244
262
  picker.style.setProperty('--background', SHEET_BACKGROUND_COLOR[resolvedTheme]);
245
263
  picker.style.setProperty('--border-size', '0');
246
- const backdropStyle = injectBackdropStyle((_d = options.backdrop) !== null && _d !== void 0 ? _d : {});
264
+ const backdropStyle = injectBackdropStyle((_e = options.backdrop) !== null && _e !== void 0 ? _e : {});
247
265
  const dialog = document.createElement('dialog');
248
266
  dialog.className = `emoji-picker-sheet emoji-picker-sheet--${resolvedTheme} ${backdropStyle.className}`;
249
267
  dialog.setAttribute('role', 'dialog');
@@ -1 +1 @@
1
- {"version":3,"file":"WebEmojiPickerPresenter.js","sourceRoot":"","sources":["../../../../src/platform/web/WebEmojiPickerPresenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAQpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAOnE,sEAAsE;AACtE,KAAK,UAAU,0BAA0B;IACrC,IAAI,CAAC;QACD,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;QACrC,OAAO,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAkC,CAAC;IACnF,CAAC;IAAC,WAAM,CAAC;QACL,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IAChD,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,6BAA6B,CAAC,MAAe;;IAClD,IAAI,CAAC,CAAC,MAAM,YAAY,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAChF,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,MAAA,MAAA,MAAM,CAAC,KAAK,0CAAE,QAAQ,CAAC,SAAS,CAAC,mCAAI,KAAK,CAAC;AACtD,CAAC;AAED,MAAM,sBAAsB,GAAG,2BAA2B,CAAC;AAC3D,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB,mF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C9C,CAAC,CAAC,CAAC;YAEH,MAAA,MAAM,CAAC,KAAK,sDAAI,CAAC;QACrB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { ErrorCodes } from '../../core/error-codes';\nimport type {\n EmojiPickerBackdropOptions,\n EmojiPickerCloseButtonOptions,\n EmojiPickerOptions,\n EmojiPickerResult,\n EmojiPickerTheme,\n} from '../../definitions';\nimport { getBundledEmojiDataSourceUrl } from './emoji-data-source';\n\n/** Minimal shape of the `<emoji-picker>` custom element this presenter depends on. */\nexport interface EmojiPickerElement extends HTMLElement {\n dataSource: string;\n}\n\n/** Registers `<emoji-picker>` (if needed) and creates the element. */\nasync function defaultCreatePickerElement(): Promise<EmojiPickerElement> {\n try {\n await import('emoji-picker-element');\n return document.createElement('emoji-picker') as unknown as EmojiPickerElement;\n } catch {\n throw new Error(ErrorCodes.NOT_IMPLEMENTED);\n }\n}\n\n/**\n * `emoji-picker-element`'s internal `Database` runs a background `fetch(dataSource, { method: 'HEAD' })`\n * freshness check whenever it already has cached data for the locale (i.e. on the second+ open in a\n * session). Non-`GET` requests to `blob:` URLs always throw `TypeError` per the Fetch spec, and this\n * internal call isn't awaited, so it otherwise surfaces as a noisy but harmless `unhandledrejection`.\n * This filters out only that specific rejection shape while a picker is open, letting everything else\n * propagate normally to the host app.\n */\nfunction isKnownBlobHeadCheckRejection(reason: unknown): boolean {\n if (!(reason instanceof TypeError) || !reason.message.includes('Failed to fetch')) {\n return false;\n }\n return reason.stack?.includes('getETag') ?? false;\n}\n\nconst SHEET_STYLE_ELEMENT_ID = 'emoji-picker-sheet-styles';\nconst ANIMATION_MS = 200;\n\n/** Injects the bottom-sheet stylesheet into `document.head`, once per document. */\nfunction ensureSheetStylesInjected(): void {\n if (document.getElementById(SHEET_STYLE_ELEMENT_ID)) {\n return;\n }\n const style = document.createElement('style');\n style.id = SHEET_STYLE_ELEMENT_ID;\n style.textContent = `\n dialog.emoji-picker-sheet {\n position: fixed;\n inset: auto 0 0 0;\n margin: 0 auto;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n width: 100%;\n max-width: 30rem;\n height: min(30rem, 80vh);\n max-height: 80vh;\n padding: 0 max(0.5rem, env(safe-area-inset-right, 0px)) max(0.5rem, env(safe-area-inset-bottom, 0px))\n max(0.5rem, env(safe-area-inset-left, 0px));\n border: none;\n border-radius: 1rem 1rem 0 0;\n overflow: hidden;\n transform: translateY(100%);\n transition: transform ${ANIMATION_MS}ms ease-out;\n }\n /*\n * Explicit colors rather than the \\`Canvas\\`/\\`CanvasText\\` system-color keywords: those rely\n * on the UA knowing the page's color-scheme, which isn't reliably signaled inside a\n * Capacitor WKWebView, so they were silently staying light-only regardless of the resolved\n * theme. Values match emoji-picker-element's own light/dark defaults so the seam between\n * the sheet chrome and the picker itself stays invisible.\n */\n dialog.emoji-picker-sheet--light {\n background-color: #fff;\n color: #1f1f1f;\n }\n dialog.emoji-picker-sheet--dark {\n background-color: #222;\n color: #e8e8e8;\n }\n dialog.emoji-picker-sheet[data-state='open'] {\n transform: translateY(0);\n }\n .emoji-picker-sheet__header {\n flex: 0 0 auto;\n display: flex;\n padding-block: 0.5rem;\n }\n .emoji-picker-sheet__close {\n border: none;\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.06);\n color: inherit;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n cursor: pointer;\n }\n dialog.emoji-picker-sheet--dark .emoji-picker-sheet__close {\n background: rgba(255, 255, 255, 0.12);\n }\n @media (prefers-reduced-motion: reduce) {\n dialog.emoji-picker-sheet {\n transition: none;\n }\n }\n `;\n document.head.appendChild(style);\n}\n\nconst DEFAULT_BACKDROP_COLOR = '#00000066';\nconst HEX_COLOR_PATTERN = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;\nlet backdropStyleCounter = 0;\n\n/** Validates a `#RGB`/`#RRGGBB`/`#RRGGBBAA` hex color, falling back to the default on any other input. */\nfunction resolveBackdropColor(color: string | undefined): string {\n if (color !== undefined && HEX_COLOR_PATTERN.test(color)) {\n return color;\n }\n return DEFAULT_BACKDROP_COLOR;\n}\n\n/** Injects a one-off `::backdrop` rule scoped to a unique class, since inline styles can't target it. */\nfunction injectBackdropStyle(options: EmojiPickerBackdropOptions): { className: string; remove: () => void } {\n const className = `emoji-picker-backdrop-${++backdropStyleCounter}`;\n const color = resolveBackdropColor(options.color);\n const blur = options.blur ?? 0;\n const style = document.createElement('style');\n // `backdrop-filter` is always set explicitly, never omitted: some browsers (e.g. Safari/WKWebView)\n // apply their own default blur to a <dialog>'s ::backdrop in their UA stylesheet, which would\n // otherwise leak through unopposed whenever the caller doesn't request blur.\n style.textContent = `\n dialog.${className}::backdrop {\n background: ${color};\n backdrop-filter: ${blur > 0 ? `blur(${blur}px)` : 'none'};\n }\n `;\n document.head.appendChild(style);\n return { className, remove: () => style.remove() };\n}\n\nfunction prefersReducedMotion(): boolean {\n return typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/** Resolves `system` to the OS's current light/dark preference; passes explicit themes through. */\nfunction resolveTheme(theme: EmojiPickerTheme | undefined): 'light' | 'dark' {\n if (theme === 'light' || theme === 'dark') {\n return theme;\n }\n const prefersDark = typeof window.matchMedia === 'function' && window.matchMedia('(prefers-color-scheme: dark)').matches;\n return prefersDark ? 'dark' : 'light';\n}\n\n/**\n * Matches the sheet's own `--light`/`--dark` background colors (see `ensureSheetStylesInjected`).\n * Set explicitly, rather than the `Canvas` system-color keyword, for the same WKWebView\n * color-scheme-detection reason documented there.\n */\nconst SHEET_BACKGROUND_COLOR: Record<'light' | 'dark', string> = {\n light: '#fff',\n dark: '#222',\n};\n\nconst CLOSE_BUTTON_SIZE_PX: Record<NonNullable<EmojiPickerCloseButtonOptions['size']>, number> = {\n xSmall: 24,\n small: 32,\n medium: 48,\n large: 64,\n};\n\n/** An \"x\" glyph sized proportionally to the button, matching the iOS button's icon/button ratio. */\nfunction createCloseIcon(buttonSizePx: number): SVGSVGElement {\n const svgNs = 'http://www.w3.org/2000/svg';\n const iconSizePx = Math.round(buttonSizePx * 0.375);\n const svg = document.createElementNS(svgNs, 'svg');\n svg.setAttribute('viewBox', '0 0 24 24');\n svg.setAttribute('width', String(iconSizePx));\n svg.setAttribute('height', String(iconSizePx));\n svg.setAttribute('fill', 'none');\n svg.setAttribute('stroke', 'currentColor');\n svg.setAttribute('stroke-width', '2.5');\n svg.setAttribute('stroke-linecap', 'round');\n svg.setAttribute('aria-hidden', 'true');\n\n const diagonal1 = document.createElementNS(svgNs, 'line');\n diagonal1.setAttribute('x1', '5');\n diagonal1.setAttribute('y1', '5');\n diagonal1.setAttribute('x2', '19');\n diagonal1.setAttribute('y2', '19');\n\n const diagonal2 = document.createElementNS(svgNs, 'line');\n diagonal2.setAttribute('x1', '19');\n diagonal2.setAttribute('y1', '5');\n diagonal2.setAttribute('x2', '5');\n diagonal2.setAttribute('y2', '19');\n\n svg.append(diagonal1, diagonal2);\n return svg;\n}\n\n/** Builds the header row hosting the close button, or `null` when the button is hidden. */\nfunction createCloseButtonHeader(options: EmojiPickerCloseButtonOptions): {\n header: HTMLDivElement;\n button: HTMLButtonElement;\n} | null {\n if (options.hidden) {\n return null;\n }\n const sizePx = CLOSE_BUTTON_SIZE_PX[options.size ?? 'medium'];\n const position = options.position ?? 'right';\n\n const header = document.createElement('div');\n header.className = 'emoji-picker-sheet__header';\n header.style.justifyContent = position === 'left' ? 'flex-start' : position === 'center' ? 'center' : 'flex-end';\n\n const button = document.createElement('button');\n button.type = 'button';\n button.className = 'emoji-picker-sheet__close';\n button.setAttribute('aria-label', 'Close');\n button.style.width = `${sizePx}px`;\n button.style.height = `${sizePx}px`;\n button.appendChild(createCloseIcon(sizePx));\n\n header.appendChild(button);\n return { header, button };\n}\n\nexport interface WebEmojiPickerPresenterOptions {\n /** Creates the picker element. Overridable for testing. */\n createPickerElement?: () => Promise<EmojiPickerElement>;\n}\n\n/**\n * Presents `emoji-picker-element` in a bottom-sheet `<dialog>` and resolves with the selected emoji.\n *\n * Kept independent of the Capacitor web plugin registration so native-platform fallback\n * orchestration (issue #6) can present the same web picker from inside a native WebView.\n */\nexport class WebEmojiPickerPresenter {\n private readonly createPickerElement: () => Promise<EmojiPickerElement>;\n\n public constructor(options: WebEmojiPickerPresenterOptions = {}) {\n this.createPickerElement = options.createPickerElement ?? defaultCreatePickerElement;\n }\n\n public async present(\n options: EmojiPickerOptions = {},\n presentOptions: { signal?: AbortSignal } = {}\n ): Promise<EmojiPickerResult> {\n const { signal } = presentOptions;\n const closeButtonOptions = options.closeButton ?? {};\n // A hidden close button must never leave the user with zero ways to dismiss the picker,\n // so hiding it force-enables backdrop-tap-to-dismiss regardless of what was explicitly\n // requested (mirrors the iOS presenter's `effectiveDismissOnBackdropTap`).\n const dismissOnBackdropTap = (options.dismissOnBackdropTap ?? true) || (closeButtonOptions.hidden ?? false);\n\n // Resolved once at open time (rather than left to each side's own live\n // `prefers-color-scheme` tracking) so the picker and the sheet chrome around it always\n // agree, fixing the mismatch from issue #19.\n const resolvedTheme = resolveTheme(options.theme);\n\n let picker: EmojiPickerElement;\n try {\n picker = await this.createPickerElement();\n picker.dataSource = getBundledEmojiDataSourceUrl();\n picker.classList.add(resolvedTheme);\n } catch {\n throw new Error(ErrorCodes.NOT_IMPLEMENTED);\n }\n\n ensureSheetStylesInjected();\n\n picker.style.display = 'block';\n picker.style.width = '100%';\n picker.style.flex = '1 1 auto';\n picker.style.minHeight = '0';\n // The picker's own card look (border + background) would otherwise float as a visibly\n // smaller box inside the sheet; matching its background to the sheet's and dropping its\n // border makes it read as full width, part of the sheet rather than nested inside it.\n picker.style.setProperty('--background', SHEET_BACKGROUND_COLOR[resolvedTheme]);\n picker.style.setProperty('--border-size', '0');\n\n const backdropStyle = injectBackdropStyle(options.backdrop ?? {});\n const dialog = document.createElement('dialog');\n dialog.className = `emoji-picker-sheet emoji-picker-sheet--${resolvedTheme} ${backdropStyle.className}`;\n dialog.setAttribute('role', 'dialog');\n dialog.setAttribute('aria-modal', 'true');\n dialog.setAttribute('aria-label', 'Emoji picker');\n\n const closeButtonHeader = createCloseButtonHeader(closeButtonOptions);\n if (closeButtonHeader) {\n // With the picker's own border removed above, this is the only visual separation\n // between the close button and the picker.\n picker.style.borderTop = '1px solid rgba(127, 127, 127, 0.3)';\n }\n\n return new Promise<EmojiPickerResult>((resolve) => {\n let settled = false;\n let pointerDownOnDialog = false;\n\n const previouslyFocusedElement = document.activeElement as HTMLElement | null;\n const previousBodyOverflow = document.body.style.overflow;\n\n const onUnhandledRejection = (event: PromiseRejectionEvent) => {\n if (isKnownBlobHeadCheckRejection(event.reason)) {\n event.preventDefault();\n }\n };\n\n const finish = (result: EmojiPickerResult) => {\n window.removeEventListener('unhandledrejection', onUnhandledRejection);\n document.body.style.overflow = previousBodyOverflow;\n dialog.close();\n dialog.remove();\n backdropStyle.remove();\n\n if (previouslyFocusedElement instanceof HTMLElement && document.contains(previouslyFocusedElement)) {\n previouslyFocusedElement.focus?.();\n }\n\n resolve(result);\n };\n\n const settle = (result: EmojiPickerResult) => {\n if (settled) {\n return;\n }\n settled = true;\n picker.removeEventListener('emoji-click', onEmojiClick as EventListener);\n dialog.removeEventListener('pointerdown', onDialogPointerDown);\n dialog.removeEventListener('click', onDialogClick);\n dialog.removeEventListener('cancel', onCancel);\n document.removeEventListener('keydown', onKeyDown);\n closeButtonHeader?.button.removeEventListener('click', onCloseButtonClick);\n signal?.removeEventListener('abort', onAbort);\n\n dialog.removeAttribute('data-state');\n\n if (prefersReducedMotion()) {\n finish(result);\n } else {\n setTimeout(() => finish(result), ANIMATION_MS);\n }\n };\n\n const onEmojiClick = (event: CustomEvent<{ unicode?: string }>) => {\n settle({ emoji: event.detail.unicode ?? null });\n };\n\n const onDialogPointerDown = (event: PointerEvent) => {\n pointerDownOnDialog = event.target === dialog;\n };\n\n const onDialogClick = (event: MouseEvent) => {\n if (dismissOnBackdropTap && event.target === dialog && pointerDownOnDialog) {\n settle({ emoji: null });\n }\n };\n\n // The dialog's native `cancel` event covers real browsers, where it fires\n // automatically on Escape and its default action would otherwise close the dialog\n // instantly, skipping the close animation. The `keydown` listener is a fallback for\n // environments (e.g. jsdom in tests) that don't implement dialog cancellation;\n // `settle` is idempotent, so both firing for the same keypress is harmless.\n const onCancel = (event: Event) => {\n event.preventDefault();\n settle({ emoji: null });\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n settle({ emoji: null });\n }\n };\n\n const onCloseButtonClick = () => {\n settle({ emoji: null });\n };\n\n const onAbort = () => {\n settle({ emoji: null });\n };\n\n if (signal?.aborted) {\n resolve({ emoji: null });\n return;\n }\n signal?.addEventListener('abort', onAbort);\n\n picker.addEventListener('emoji-click', onEmojiClick as EventListener);\n dialog.addEventListener('pointerdown', onDialogPointerDown);\n dialog.addEventListener('click', onDialogClick);\n dialog.addEventListener('cancel', onCancel);\n document.addEventListener('keydown', onKeyDown);\n window.addEventListener('unhandledrejection', onUnhandledRejection);\n closeButtonHeader?.button.addEventListener('click', onCloseButtonClick);\n\n if (closeButtonHeader) {\n dialog.appendChild(closeButtonHeader.header);\n }\n dialog.appendChild(picker);\n document.body.appendChild(dialog);\n document.body.style.overflow = 'hidden';\n dialog.showModal();\n\n requestAnimationFrame(() => {\n dialog.setAttribute('data-state', 'open');\n });\n\n picker.focus?.();\n });\n }\n}\n"]}
1
+ {"version":3,"file":"WebEmojiPickerPresenter.js","sourceRoot":"","sources":["../../../../src/platform/web/WebEmojiPickerPresenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAQpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAQ5D,sEAAsE;AACtE,KAAK,UAAU,0BAA0B;IACrC,IAAI,CAAC;QACD,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;QACrC,OAAO,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAkC,CAAC;IAC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AAC,YAAY,EAAE,MAAM,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;YAEH,MAAA,MAAM,CAAC,KAAK,sDAAI,CAAC;QACrB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { ErrorCodes } from '../../core/error-codes';\nimport type {\n EmojiPickerBackdropOptions,\n EmojiPickerCloseButtonOptions,\n EmojiPickerOptions,\n EmojiPickerResult,\n EmojiPickerTheme,\n} from '../../definitions';\nimport { getEmojiDataSourceUrl } from './emoji-data-source';\n\n/** Minimal shape of the `<emoji-picker>` custom element this presenter depends on. */\nexport interface EmojiPickerElement extends HTMLElement {\n dataSource: string;\n locale: string;\n}\n\n/** Registers `<emoji-picker>` (if needed) and creates the element. */\nasync function defaultCreatePickerElement(): Promise<EmojiPickerElement> {\n try {\n await import('emoji-picker-element');\n return document.createElement('emoji-picker') as unknown as EmojiPickerElement;\n } catch {\n throw new Error(ErrorCodes.NOT_IMPLEMENTED);\n }\n}\n\n/**\n * `emoji-picker-element`'s internal `Database` runs a background `fetch(dataSource, { method: 'HEAD' })`\n * freshness check whenever it already has cached data for the locale (i.e. on the second+ open in a\n * session). Non-`GET` requests to `blob:` URLs always throw `TypeError` per the Fetch spec, and this\n * internal call isn't awaited, so it otherwise surfaces as a noisy but harmless `unhandledrejection`.\n * This filters out only that specific rejection shape while a picker is open, letting everything else\n * propagate normally to the host app.\n */\nfunction isKnownBlobHeadCheckRejection(reason: unknown): boolean {\n if (!(reason instanceof TypeError) || !reason.message.includes('Failed to fetch')) {\n return false;\n }\n return reason.stack?.includes('getETag') ?? false;\n}\n\nconst SHEET_STYLE_ELEMENT_ID = 'emoji-picker-sheet-styles';\nconst ANIMATION_MS = 200;\n\n/** Injects the bottom-sheet stylesheet into `document.head`, once per document. */\nfunction ensureSheetStylesInjected(): void {\n if (document.getElementById(SHEET_STYLE_ELEMENT_ID)) {\n return;\n }\n const style = document.createElement('style');\n style.id = SHEET_STYLE_ELEMENT_ID;\n style.textContent = `\n dialog.emoji-picker-sheet {\n position: fixed;\n inset: auto 0 0 0;\n margin: 0 auto;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n width: 100%;\n max-width: 30rem;\n height: min(30rem, 80vh);\n max-height: 80vh;\n padding: 0 max(0.5rem, env(safe-area-inset-right, 0px)) max(0.5rem, env(safe-area-inset-bottom, 0px))\n max(0.5rem, env(safe-area-inset-left, 0px));\n border: none;\n border-radius: 1rem 1rem 0 0;\n overflow: hidden;\n transform: translateY(100%);\n transition: transform ${ANIMATION_MS}ms ease-out;\n }\n /*\n * Explicit colors rather than the \\`Canvas\\`/\\`CanvasText\\` system-color keywords: those rely\n * on the UA knowing the page's color-scheme, which isn't reliably signaled inside a\n * Capacitor WKWebView, so they were silently staying light-only regardless of the resolved\n * theme. Values match emoji-picker-element's own light/dark defaults so the seam between\n * the sheet chrome and the picker itself stays invisible.\n */\n dialog.emoji-picker-sheet--light {\n background-color: #fff;\n color: #1f1f1f;\n }\n dialog.emoji-picker-sheet--dark {\n background-color: #222;\n color: #e8e8e8;\n }\n dialog.emoji-picker-sheet[data-state='open'] {\n transform: translateY(0);\n }\n .emoji-picker-sheet__header {\n flex: 0 0 auto;\n display: flex;\n padding-block: 0.5rem;\n }\n .emoji-picker-sheet__close {\n border: none;\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.06);\n color: inherit;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n cursor: pointer;\n }\n dialog.emoji-picker-sheet--dark .emoji-picker-sheet__close {\n background: rgba(255, 255, 255, 0.12);\n }\n @media (prefers-reduced-motion: reduce) {\n dialog.emoji-picker-sheet {\n transition: none;\n }\n }\n `;\n document.head.appendChild(style);\n}\n\nconst DEFAULT_BACKDROP_COLOR = '#00000066';\nconst HEX_COLOR_PATTERN = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;\nlet backdropStyleCounter = 0;\n\n/** Validates a `#RGB`/`#RRGGBB`/`#RRGGBBAA` hex color, falling back to the default on any other input. */\nfunction resolveBackdropColor(color: string | undefined): string {\n if (color !== undefined && HEX_COLOR_PATTERN.test(color)) {\n return color;\n }\n return DEFAULT_BACKDROP_COLOR;\n}\n\n/** Injects a one-off `::backdrop` rule scoped to a unique class, since inline styles can't target it. */\nfunction injectBackdropStyle(options: EmojiPickerBackdropOptions): { className: string; remove: () => void } {\n const className = `emoji-picker-backdrop-${++backdropStyleCounter}`;\n const color = resolveBackdropColor(options.color);\n const blur = options.blur ?? 0;\n const style = document.createElement('style');\n // `backdrop-filter` is always set explicitly, never omitted: some browsers (e.g. Safari/WKWebView)\n // apply their own default blur to a <dialog>'s ::backdrop in their UA stylesheet, which would\n // otherwise leak through unopposed whenever the caller doesn't request blur.\n style.textContent = `\n dialog.${className}::backdrop {\n background: ${color};\n backdrop-filter: ${blur > 0 ? `blur(${blur}px)` : 'none'};\n }\n `;\n document.head.appendChild(style);\n return { className, remove: () => style.remove() };\n}\n\nfunction prefersReducedMotion(): boolean {\n return typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/** Resolves `system` to the OS's current light/dark preference; passes explicit themes through. */\nfunction resolveTheme(theme: EmojiPickerTheme | undefined): 'light' | 'dark' {\n if (theme === 'light' || theme === 'dark') {\n return theme;\n }\n const prefersDark = typeof window.matchMedia === 'function' && window.matchMedia('(prefers-color-scheme: dark)').matches;\n return prefersDark ? 'dark' : 'light';\n}\n\n/**\n * Matches the sheet's own `--light`/`--dark` background colors (see `ensureSheetStylesInjected`).\n * Set explicitly, rather than the `Canvas` system-color keyword, for the same WKWebView\n * color-scheme-detection reason documented there.\n */\nconst SHEET_BACKGROUND_COLOR: Record<'light' | 'dark', string> = {\n light: '#fff',\n dark: '#222',\n};\n\nconst CLOSE_BUTTON_SIZE_PX: Record<NonNullable<EmojiPickerCloseButtonOptions['size']>, number> = {\n xSmall: 24,\n small: 32,\n medium: 48,\n large: 64,\n};\n\n/** An \"x\" glyph sized proportionally to the button, matching the iOS button's icon/button ratio. */\nfunction createCloseIcon(buttonSizePx: number): SVGSVGElement {\n const svgNs = 'http://www.w3.org/2000/svg';\n const iconSizePx = Math.round(buttonSizePx * 0.375);\n const svg = document.createElementNS(svgNs, 'svg');\n svg.setAttribute('viewBox', '0 0 24 24');\n svg.setAttribute('width', String(iconSizePx));\n svg.setAttribute('height', String(iconSizePx));\n svg.setAttribute('fill', 'none');\n svg.setAttribute('stroke', 'currentColor');\n svg.setAttribute('stroke-width', '2.5');\n svg.setAttribute('stroke-linecap', 'round');\n svg.setAttribute('aria-hidden', 'true');\n\n const diagonal1 = document.createElementNS(svgNs, 'line');\n diagonal1.setAttribute('x1', '5');\n diagonal1.setAttribute('y1', '5');\n diagonal1.setAttribute('x2', '19');\n diagonal1.setAttribute('y2', '19');\n\n const diagonal2 = document.createElementNS(svgNs, 'line');\n diagonal2.setAttribute('x1', '19');\n diagonal2.setAttribute('y1', '5');\n diagonal2.setAttribute('x2', '5');\n diagonal2.setAttribute('y2', '19');\n\n svg.append(diagonal1, diagonal2);\n return svg;\n}\n\n/** Builds the header row hosting the close button, or `null` when the button is hidden. */\nfunction createCloseButtonHeader(options: EmojiPickerCloseButtonOptions): {\n header: HTMLDivElement;\n button: HTMLButtonElement;\n} | null {\n if (options.hidden) {\n return null;\n }\n const sizePx = CLOSE_BUTTON_SIZE_PX[options.size ?? 'medium'];\n const position = options.position ?? 'right';\n\n const header = document.createElement('div');\n header.className = 'emoji-picker-sheet__header';\n header.style.justifyContent = position === 'left' ? 'flex-start' : position === 'center' ? 'center' : 'flex-end';\n\n const button = document.createElement('button');\n button.type = 'button';\n button.className = 'emoji-picker-sheet__close';\n button.setAttribute('aria-label', 'Close');\n button.style.width = `${sizePx}px`;\n button.style.height = `${sizePx}px`;\n button.appendChild(createCloseIcon(sizePx));\n\n header.appendChild(button);\n return { header, button };\n}\n\n/**\n * Seeds `locale`'s persisted preferred skin tone via `emoji-picker-element`'s own `Database`, so\n * `<emoji-picker>` picks it up as its default on render. A no-op for `skinTone === undefined`,\n * so an already-made user choice (persisted in IndexedDB) is never overwritten.\n */\nasync function defaultSeedSkinTone(locale: string, skinTone: number): Promise<void> {\n const { default: Database } = await import('emoji-picker-element/database');\n const db = new Database({ locale });\n await db.setPreferredSkinTone(skinTone);\n}\n\nexport interface WebEmojiPickerPresenterOptions {\n /** Creates the picker element. Overridable for testing. */\n createPickerElement?: () => Promise<EmojiPickerElement>;\n /** Seeds the locale's persisted preferred skin tone. Overridable for testing. */\n seedSkinTone?: (locale: string, skinTone: number) => Promise<void>;\n /** Resolves the `dataSource` URL for a locale. Overridable for testing. */\n getDataSourceUrl?: (locale: string) => Promise<string>;\n}\n\n/**\n * Presents `emoji-picker-element` in a bottom-sheet `<dialog>` and resolves with the selected emoji.\n *\n * Kept independent of the Capacitor web plugin registration so native-platform fallback\n * orchestration (issue #6) can present the same web picker from inside a native WebView.\n */\nexport class WebEmojiPickerPresenter {\n private readonly createPickerElement: () => Promise<EmojiPickerElement>;\n private readonly seedSkinTone: (locale: string, skinTone: number) => Promise<void>;\n private readonly getDataSourceUrl: (locale: string) => Promise<string>;\n\n public constructor(options: WebEmojiPickerPresenterOptions = {}) {\n this.createPickerElement = options.createPickerElement ?? defaultCreatePickerElement;\n this.seedSkinTone = options.seedSkinTone ?? defaultSeedSkinTone;\n this.getDataSourceUrl = options.getDataSourceUrl ?? getEmojiDataSourceUrl;\n }\n\n public async present(\n options: EmojiPickerOptions = {},\n presentOptions: { signal?: AbortSignal } = {}\n ): Promise<EmojiPickerResult> {\n const { signal } = presentOptions;\n const closeButtonOptions = options.closeButton ?? {};\n // A hidden close button must never leave the user with zero ways to dismiss the picker,\n // so hiding it force-enables backdrop-tap-to-dismiss regardless of what was explicitly\n // requested (mirrors the iOS presenter's `effectiveDismissOnBackdropTap`).\n const dismissOnBackdropTap = (options.dismissOnBackdropTap ?? true) || (closeButtonOptions.hidden ?? false);\n\n // Resolved once at open time (rather than left to each side's own live\n // `prefers-color-scheme` tracking) so the picker and the sheet chrome around it always\n // agree, fixing the mismatch from issue #19.\n const resolvedTheme = resolveTheme(options.theme);\n const locale = options.locale ?? 'en';\n\n if (options.skinTone !== undefined) {\n // Seeded before the element is created so its initial render already reflects it.\n await this.seedSkinTone(locale, options.skinTone);\n }\n\n let picker: EmojiPickerElement;\n try {\n picker = await this.createPickerElement();\n picker.locale = locale;\n picker.dataSource = await this.getDataSourceUrl(locale);\n picker.classList.add(resolvedTheme);\n } catch {\n throw new Error(ErrorCodes.NOT_IMPLEMENTED);\n }\n\n ensureSheetStylesInjected();\n\n picker.style.display = 'block';\n picker.style.width = '100%';\n picker.style.flex = '1 1 auto';\n picker.style.minHeight = '0';\n // The picker's own card look (border + background) would otherwise float as a visibly\n // smaller box inside the sheet; matching its background to the sheet's and dropping its\n // border makes it read as full width, part of the sheet rather than nested inside it.\n picker.style.setProperty('--background', SHEET_BACKGROUND_COLOR[resolvedTheme]);\n picker.style.setProperty('--border-size', '0');\n\n const backdropStyle = injectBackdropStyle(options.backdrop ?? {});\n const dialog = document.createElement('dialog');\n dialog.className = `emoji-picker-sheet emoji-picker-sheet--${resolvedTheme} ${backdropStyle.className}`;\n dialog.setAttribute('role', 'dialog');\n dialog.setAttribute('aria-modal', 'true');\n dialog.setAttribute('aria-label', 'Emoji picker');\n\n const closeButtonHeader = createCloseButtonHeader(closeButtonOptions);\n if (closeButtonHeader) {\n // With the picker's own border removed above, this is the only visual separation\n // between the close button and the picker.\n picker.style.borderTop = '1px solid rgba(127, 127, 127, 0.3)';\n }\n\n return new Promise<EmojiPickerResult>((resolve) => {\n let settled = false;\n let pointerDownOnDialog = false;\n\n const previouslyFocusedElement = document.activeElement as HTMLElement | null;\n const previousBodyOverflow = document.body.style.overflow;\n\n const onUnhandledRejection = (event: PromiseRejectionEvent) => {\n if (isKnownBlobHeadCheckRejection(event.reason)) {\n event.preventDefault();\n }\n };\n\n const finish = (result: EmojiPickerResult) => {\n window.removeEventListener('unhandledrejection', onUnhandledRejection);\n document.body.style.overflow = previousBodyOverflow;\n dialog.close();\n dialog.remove();\n backdropStyle.remove();\n\n if (previouslyFocusedElement instanceof HTMLElement && document.contains(previouslyFocusedElement)) {\n previouslyFocusedElement.focus?.();\n }\n\n resolve(result);\n };\n\n const settle = (result: EmojiPickerResult) => {\n if (settled) {\n return;\n }\n settled = true;\n picker.removeEventListener('emoji-click', onEmojiClick as EventListener);\n dialog.removeEventListener('pointerdown', onDialogPointerDown);\n dialog.removeEventListener('click', onDialogClick);\n dialog.removeEventListener('cancel', onCancel);\n document.removeEventListener('keydown', onKeyDown);\n closeButtonHeader?.button.removeEventListener('click', onCloseButtonClick);\n signal?.removeEventListener('abort', onAbort);\n\n dialog.removeAttribute('data-state');\n\n if (prefersReducedMotion()) {\n finish(result);\n } else {\n setTimeout(() => finish(result), ANIMATION_MS);\n }\n };\n\n const onEmojiClick = (event: CustomEvent<{ unicode?: string }>) => {\n settle({ emoji: event.detail.unicode ?? null });\n };\n\n const onDialogPointerDown = (event: PointerEvent) => {\n pointerDownOnDialog = event.target === dialog;\n };\n\n const onDialogClick = (event: MouseEvent) => {\n if (dismissOnBackdropTap && event.target === dialog && pointerDownOnDialog) {\n settle({ emoji: null });\n }\n };\n\n // The dialog's native `cancel` event covers real browsers, where it fires\n // automatically on Escape and its default action would otherwise close the dialog\n // instantly, skipping the close animation. The `keydown` listener is a fallback for\n // environments (e.g. jsdom in tests) that don't implement dialog cancellation;\n // `settle` is idempotent, so both firing for the same keypress is harmless.\n const onCancel = (event: Event) => {\n event.preventDefault();\n settle({ emoji: null });\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n settle({ emoji: null });\n }\n };\n\n const onCloseButtonClick = () => {\n settle({ emoji: null });\n };\n\n const onAbort = () => {\n settle({ emoji: null });\n };\n\n if (signal?.aborted) {\n resolve({ emoji: null });\n return;\n }\n signal?.addEventListener('abort', onAbort);\n\n picker.addEventListener('emoji-click', onEmojiClick as EventListener);\n dialog.addEventListener('pointerdown', onDialogPointerDown);\n dialog.addEventListener('click', onDialogClick);\n dialog.addEventListener('cancel', onCancel);\n document.addEventListener('keydown', onKeyDown);\n window.addEventListener('unhandledrejection', onUnhandledRejection);\n closeButtonHeader?.button.addEventListener('click', onCloseButtonClick);\n\n if (closeButtonHeader) {\n dialog.appendChild(closeButtonHeader.header);\n }\n dialog.appendChild(picker);\n document.body.appendChild(dialog);\n document.body.style.overflow = 'hidden';\n dialog.showModal();\n\n requestAnimationFrame(() => {\n dialog.setAttribute('data-state', 'open');\n });\n\n picker.focus?.();\n });\n }\n}\n"]}
@@ -1,5 +1,17 @@
1
1
  /**
2
- * Returns a same-origin object URL serving the bundled emoji dataset, so the web picker
3
- * never depends on `emoji-picker-element`'s default jsDelivr CDN at runtime.
2
+ * Registers emoji data for a locale other than `'en'` (the only one bundled by default), so it's
3
+ * used instead of falling back to a CDN fetch.
4
+ *
5
+ * Pass a loader from `capacitor-emoji-picker/dist/esm/platform/web/locales` (e.g.
6
+ * `registerEmojiLocale(ptLocale.locale, await ptLocale())`) to pick from every locale
7
+ * `emoji-picker-element-data` ships, or supply the dataset yourself. Either way, the host app
8
+ * decides what to import, which lets its own bundler include it statically or split it into a
9
+ * lazy chunk as it sees fit.
4
10
  */
5
- export declare function getBundledEmojiDataSourceUrl(): string;
11
+ export declare function registerEmojiLocale(locale: string, data: unknown): void;
12
+ /**
13
+ * Returns a same-origin object URL serving the emoji dataset for `locale`, so the web picker
14
+ * doesn't depend on a CDN at runtime for registered/bundled locales. Falls back to `'en'` on any
15
+ * resolution failure (unknown locale with no network access, malformed code, etc).
16
+ */
17
+ export declare function getEmojiDataSourceUrl(locale?: string): Promise<string>;