@independo/capacitor-emoji-picker 1.0.0-dev.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.
Files changed (64) hide show
  1. package/IndependoCapacitorEmojiPicker.podspec +17 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +28 -0
  4. package/README.md +223 -0
  5. package/android/build.gradle +109 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/app/independo/capacitoremojipicker/EmojiPicker.java +82 -0
  8. package/android/src/main/java/app/independo/capacitoremojipicker/EmojiPickerWebBridgeInterface.java +28 -0
  9. package/android/src/main/java/app/independo/capacitoremojipicker/core/EmojiCloseButtonOptions.java +18 -0
  10. package/android/src/main/java/app/independo/capacitoremojipicker/core/EmojiPickerCallback.java +11 -0
  11. package/android/src/main/java/app/independo/capacitoremojipicker/core/EmojiPickerResult.java +16 -0
  12. package/android/src/main/java/app/independo/capacitoremojipicker/core/ErrorCodes.java +14 -0
  13. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/DefaultEmojiPickerDialogFactory.java +35 -0
  14. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/DispatchingEmojiPickerPresenter.java +26 -0
  15. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/EmojiPickerDialogFactory.java +26 -0
  16. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/EmojiPickerPresenter.java +16 -0
  17. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/NativeEmojiPickerPresenter.java +220 -0
  18. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/WebFallbackEmojiPickerPresenter.java +228 -0
  19. package/android/src/main/java/app/independo/capacitoremojipicker/service/EmojiPickerService.java +46 -0
  20. package/android/src/main/res/.gitkeep +0 -0
  21. package/dist/docs.json +169 -0
  22. package/dist/esm/core/error-codes.d.ts +9 -0
  23. package/dist/esm/core/error-codes.js +10 -0
  24. package/dist/esm/core/error-codes.js.map +1 -0
  25. package/dist/esm/definitions.d.ts +81 -0
  26. package/dist/esm/definitions.js +2 -0
  27. package/dist/esm/definitions.js.map +1 -0
  28. package/dist/esm/index.d.ts +4 -0
  29. package/dist/esm/index.js +9 -0
  30. package/dist/esm/index.js.map +1 -0
  31. package/dist/esm/platform/web/EmojiPickerWebAdapter.d.ts +10 -0
  32. package/dist/esm/platform/web/EmojiPickerWebAdapter.js +12 -0
  33. package/dist/esm/platform/web/EmojiPickerWebAdapter.js.map +1 -0
  34. package/dist/esm/platform/web/WebEmojiPickerPresenter.d.ts +22 -0
  35. package/dist/esm/platform/web/WebEmojiPickerPresenter.js +292 -0
  36. package/dist/esm/platform/web/WebEmojiPickerPresenter.js.map +1 -0
  37. package/dist/esm/platform/web/emoji-data-source.d.ts +5 -0
  38. package/dist/esm/platform/web/emoji-data-source.js +16 -0
  39. package/dist/esm/platform/web/emoji-data-source.js.map +1 -0
  40. package/dist/esm/platform/web/nativeWebBridge.d.ts +29 -0
  41. package/dist/esm/platform/web/nativeWebBridge.js +58 -0
  42. package/dist/esm/platform/web/nativeWebBridge.js.map +1 -0
  43. package/dist/esm/service/EmojiPickerService.d.ts +16 -0
  44. package/dist/esm/service/EmojiPickerService.js +23 -0
  45. package/dist/esm/service/EmojiPickerService.js.map +1 -0
  46. package/dist/esm/web.d.ts +9 -0
  47. package/dist/esm/web.js +16 -0
  48. package/dist/esm/web.js.map +1 -0
  49. package/dist/plugin.cjs.js +3274 -0
  50. package/dist/plugin.cjs.js.map +1 -0
  51. package/dist/plugin.js +3277 -0
  52. package/dist/plugin.js.map +1 -0
  53. package/ios/Sources/EmojiPicker/Bridge/EmojiPicker.swift +79 -0
  54. package/ios/Sources/EmojiPicker/Bridge/EmojiPickerScriptMessageHandler.swift +19 -0
  55. package/ios/Sources/EmojiPicker/Core/EmojiPickerResult.swift +12 -0
  56. package/ios/Sources/EmojiPicker/Core/ErrorCodes.swift +12 -0
  57. package/ios/Sources/EmojiPicker/Presenter/DefaultEmojiKeyboardPresentationFactory.swift +370 -0
  58. package/ios/Sources/EmojiPicker/Presenter/DispatchingEmojiPickerPresenter.swift +19 -0
  59. package/ios/Sources/EmojiPicker/Presenter/EmojiKeyboardPresentationFactory.swift +36 -0
  60. package/ios/Sources/EmojiPicker/Presenter/EmojiPickerPresenter.swift +31 -0
  61. package/ios/Sources/EmojiPicker/Presenter/NativeEmojiPickerPresenter.swift +186 -0
  62. package/ios/Sources/EmojiPicker/Presenter/WebFallbackEmojiPickerPresenter.swift +122 -0
  63. package/ios/Sources/EmojiPicker/Service/EmojiPickerService.swift +25 -0
  64. package/package.json +120 -0
package/dist/docs.json ADDED
@@ -0,0 +1,169 @@
1
+ {
2
+ "api": {
3
+ "name": "EmojiPickerPlugin",
4
+ "slug": "emojipickerplugin",
5
+ "docs": "Interface for the EmojiPicker plugin, which presents a native or web emoji picker and\nresolves with the emoji the user selected.",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "present",
10
+ "signature": "(options?: EmojiPickerOptions | undefined) => Promise<EmojiPickerResult>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "The options for the presentation.",
15
+ "type": "EmojiPickerOptions | undefined"
16
+ }
17
+ ],
18
+ "returns": "Promise<EmojiPickerResult>",
19
+ "tags": [
20
+ {
21
+ "name": "param",
22
+ "text": "options The options for the presentation."
23
+ },
24
+ {
25
+ "name": "returns",
26
+ "text": "A promise that resolves to an EmojiPickerResult."
27
+ },
28
+ {
29
+ "name": "throws",
30
+ "text": "Error with code `ALREADY_PRESENTING` if a picker is already active."
31
+ }
32
+ ],
33
+ "docs": "Presents the emoji picker.\n\nResolves with `{ emoji: null }` rather than leaving the promise pending when the user\ndismisses the picker without selecting an emoji.\n\nCalling 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.",
34
+ "complexTypes": [
35
+ "EmojiPickerResult",
36
+ "EmojiPickerOptions"
37
+ ],
38
+ "slug": "present"
39
+ }
40
+ ],
41
+ "properties": []
42
+ },
43
+ "interfaces": [
44
+ {
45
+ "name": "EmojiPickerResult",
46
+ "slug": "emojipickerresult",
47
+ "docs": "Result of presenting the emoji picker.",
48
+ "tags": [],
49
+ "methods": [],
50
+ "properties": [
51
+ {
52
+ "name": "emoji",
53
+ "tags": [],
54
+ "docs": "The selected emoji as a complete Unicode string/grapheme (unchanged), or `null` when the\npicker was dismissed without a selection.",
55
+ "complexTypes": [],
56
+ "type": "string | null"
57
+ }
58
+ ]
59
+ },
60
+ {
61
+ "name": "EmojiPickerOptions",
62
+ "slug": "emojipickeroptions",
63
+ "docs": "Options for presenting the emoji picker.",
64
+ "tags": [],
65
+ "methods": [],
66
+ "properties": [
67
+ {
68
+ "name": "presentation",
69
+ "tags": [
70
+ {
71
+ "text": "'auto'",
72
+ "name": "default"
73
+ }
74
+ ],
75
+ "docs": "`auto`: prefer native/system UI and fall back to the web picker when native presentation\nis not available or fails.\n`web`: always use the web picker, including inside Capacitor native apps.",
76
+ "complexTypes": [
77
+ "EmojiPickerPresentation"
78
+ ],
79
+ "type": "EmojiPickerPresentation"
80
+ },
81
+ {
82
+ "name": "closeButton",
83
+ "tags": [],
84
+ "docs": "Configures the close button rendered above the iOS keyboard/the web picker sheet (iOS has\nno system-provided one). Ignored on Android.",
85
+ "complexTypes": [
86
+ "EmojiPickerCloseButtonOptions"
87
+ ],
88
+ "type": "EmojiPickerCloseButtonOptions"
89
+ },
90
+ {
91
+ "name": "dismissOnBackdropTap",
92
+ "tags": [
93
+ {
94
+ "text": "true",
95
+ "name": "default"
96
+ }
97
+ ],
98
+ "docs": "Dismiss the picker when the user taps the transparent area outside the keyboard/button (iOS)\nor the scrim outside the picker sheet (Android and web).\n\nOn iOS and web, if `closeButton.hidden` is `true`, this is treated as `true` regardless of\nthe value passed here, so the user always has a way to dismiss the picker.",
99
+ "complexTypes": [],
100
+ "type": "boolean | undefined"
101
+ }
102
+ ]
103
+ },
104
+ {
105
+ "name": "EmojiPickerCloseButtonOptions",
106
+ "slug": "emojipickerclosebuttonoptions",
107
+ "docs": "Configures the close button rendered above the iOS native emoji keyboard/the web picker sheet.",
108
+ "tags": [],
109
+ "methods": [],
110
+ "properties": [
111
+ {
112
+ "name": "size",
113
+ "tags": [
114
+ {
115
+ "text": "'medium'",
116
+ "name": "default"
117
+ }
118
+ ],
119
+ "docs": "`xSmall`: 24pt, `small`: 32pt, `medium`: 48pt, `large`: 64pt.",
120
+ "complexTypes": [],
121
+ "type": "'xSmall' | 'small' | 'medium' | 'large' | undefined"
122
+ },
123
+ {
124
+ "name": "position",
125
+ "tags": [
126
+ {
127
+ "text": "'right'",
128
+ "name": "default"
129
+ }
130
+ ],
131
+ "docs": "Which side of the keyboard the button docks to.",
132
+ "complexTypes": [],
133
+ "type": "'left' | 'center' | 'right' | undefined"
134
+ },
135
+ {
136
+ "name": "hidden",
137
+ "tags": [
138
+ {
139
+ "text": "false",
140
+ "name": "default"
141
+ }
142
+ ],
143
+ "docs": "Hides the built-in close button. See `EmojiPickerOptions.dismissOnBackdropTap` for the\nsafety net this triggers.",
144
+ "complexTypes": [],
145
+ "type": "boolean | undefined"
146
+ }
147
+ ]
148
+ }
149
+ ],
150
+ "enums": [],
151
+ "typeAliases": [
152
+ {
153
+ "name": "EmojiPickerPresentation",
154
+ "slug": "emojipickerpresentation",
155
+ "docs": "How the picker should be presented.",
156
+ "types": [
157
+ {
158
+ "text": "'auto'",
159
+ "complexTypes": []
160
+ },
161
+ {
162
+ "text": "'web'",
163
+ "complexTypes": []
164
+ }
165
+ ]
166
+ }
167
+ ],
168
+ "pluginConfigs": []
169
+ }
@@ -0,0 +1,9 @@
1
+ /** Canonical error codes surfaced by the EmojiPicker plugin. */
2
+ export declare const ErrorCodes: {
3
+ /** A `present()` call was made while a picker was already active. */
4
+ readonly ALREADY_PRESENTING: "ALREADY_PRESENTING";
5
+ /** The native picker UI could not be presented (e.g. no active Activity); distinct from user cancellation. */
6
+ readonly NATIVE_UNAVAILABLE: "NATIVE_UNAVAILABLE";
7
+ /** The requested presentation is not implemented on this platform yet. */
8
+ readonly NOT_IMPLEMENTED: "NOT_IMPLEMENTED";
9
+ };
@@ -0,0 +1,10 @@
1
+ /** Canonical error codes surfaced by the EmojiPicker plugin. */
2
+ export const ErrorCodes = {
3
+ /** A `present()` call was made while a picker was already active. */
4
+ ALREADY_PRESENTING: 'ALREADY_PRESENTING',
5
+ /** The native picker UI could not be presented (e.g. no active Activity); distinct from user cancellation. */
6
+ NATIVE_UNAVAILABLE: 'NATIVE_UNAVAILABLE',
7
+ /** The requested presentation is not implemented on this platform yet. */
8
+ NOT_IMPLEMENTED: 'NOT_IMPLEMENTED',
9
+ };
10
+ //# sourceMappingURL=error-codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.js","sourceRoot":"","sources":["../../../src/core/error-codes.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,qEAAqE;IACrE,kBAAkB,EAAE,oBAAoB;IACxC,8GAA8G;IAC9G,kBAAkB,EAAE,oBAAoB;IACxC,0EAA0E;IAC1E,eAAe,EAAE,iBAAiB;CAC5B,CAAC","sourcesContent":["/** Canonical error codes surfaced by the EmojiPicker plugin. */\nexport const ErrorCodes = {\n /** A `present()` call was made while a picker was already active. */\n ALREADY_PRESENTING: 'ALREADY_PRESENTING',\n /** The native picker UI could not be presented (e.g. no active Activity); distinct from user cancellation. */\n NATIVE_UNAVAILABLE: 'NATIVE_UNAVAILABLE',\n /** The requested presentation is not implemented on this platform yet. */\n NOT_IMPLEMENTED: 'NOT_IMPLEMENTED',\n} as const;\n"]}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * How the picker should be presented.
3
+ */
4
+ export type EmojiPickerPresentation = 'auto' | 'web';
5
+ /**
6
+ * Options for presenting the emoji picker.
7
+ */
8
+ export interface EmojiPickerOptions {
9
+ /**
10
+ * `auto`: prefer native/system UI and fall back to the web picker when native presentation
11
+ * is not available or fails.
12
+ * `web`: always use the web picker, including inside Capacitor native apps.
13
+ * @default 'auto'
14
+ */
15
+ presentation?: EmojiPickerPresentation;
16
+ /**
17
+ * Configures the close button rendered above the iOS keyboard/the web picker sheet (iOS has
18
+ * no system-provided one). Ignored on Android.
19
+ */
20
+ closeButton?: EmojiPickerCloseButtonOptions;
21
+ /**
22
+ * Dismiss the picker when the user taps the transparent area outside the keyboard/button (iOS)
23
+ * or the scrim outside the picker sheet (Android and web).
24
+ *
25
+ * On iOS and web, if `closeButton.hidden` is `true`, this is treated as `true` regardless of
26
+ * the value passed here, so the user always has a way to dismiss the picker.
27
+ * @default true
28
+ */
29
+ dismissOnBackdropTap?: boolean;
30
+ }
31
+ /**
32
+ * Configures the close button rendered above the iOS native emoji keyboard/the web picker sheet.
33
+ */
34
+ export interface EmojiPickerCloseButtonOptions {
35
+ /**
36
+ * `xSmall`: 24pt, `small`: 32pt, `medium`: 48pt, `large`: 64pt.
37
+ * @default 'medium'
38
+ */
39
+ size?: 'xSmall' | 'small' | 'medium' | 'large';
40
+ /**
41
+ * Which side of the keyboard the button docks to.
42
+ * @default 'right'
43
+ */
44
+ position?: 'left' | 'center' | 'right';
45
+ /**
46
+ * Hides the built-in close button. See `EmojiPickerOptions.dismissOnBackdropTap` for the
47
+ * safety net this triggers.
48
+ * @default false
49
+ */
50
+ hidden?: boolean;
51
+ }
52
+ /**
53
+ * Result of presenting the emoji picker.
54
+ */
55
+ export interface EmojiPickerResult {
56
+ /**
57
+ * The selected emoji as a complete Unicode string/grapheme (unchanged), or `null` when the
58
+ * picker was dismissed without a selection.
59
+ */
60
+ emoji: string | null;
61
+ }
62
+ /**
63
+ * Interface for the EmojiPicker plugin, which presents a native or web emoji picker and
64
+ * resolves with the emoji the user selected.
65
+ */
66
+ export interface EmojiPickerPlugin {
67
+ /**
68
+ * Presents the emoji picker.
69
+ *
70
+ * Resolves with `{ emoji: null }` rather than leaving the promise pending when the user
71
+ * dismisses the picker without selecting an emoji.
72
+ *
73
+ * Calling this method again while a picker is already active rejects immediately with the
74
+ * `ALREADY_PRESENTING` error code rather than presenting a second, overlapping picker.
75
+ *
76
+ * @param options The options for the presentation.
77
+ * @returns A promise that resolves to an EmojiPickerResult.
78
+ * @throws Error with code `ALREADY_PRESENTING` if a picker is already active.
79
+ */
80
+ present(options?: EmojiPickerOptions): Promise<EmojiPickerResult>;
81
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +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 * 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 * 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\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 * 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"]}
@@ -0,0 +1,4 @@
1
+ import type { EmojiPickerPlugin } from './definitions';
2
+ declare const EmojiPicker: EmojiPickerPlugin;
3
+ export * from './definitions';
4
+ export { EmojiPicker };
@@ -0,0 +1,9 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ import { registerNativeWebBridge } from './platform/web/nativeWebBridge';
3
+ const EmojiPicker = registerPlugin('EmojiPicker', {
4
+ web: () => import('./web').then((m) => new m.EmojiPickerWeb()),
5
+ });
6
+ registerNativeWebBridge();
7
+ export * from './definitions';
8
+ export { EmojiPicker };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,10 @@
1
+ import type { EmojiPickerOptions, EmojiPickerResult } from '../../definitions';
2
+ import type { EmojiPickerPlatform } from '../../service/EmojiPickerService';
3
+ import { WebEmojiPickerPresenter } from './WebEmojiPickerPresenter';
4
+ /** Web adapter that presents `emoji-picker-element` in a bottom-sheet dialog. */
5
+ export declare class EmojiPickerWebAdapter implements EmojiPickerPlatform {
6
+ private readonly presenter;
7
+ constructor(presenter?: WebEmojiPickerPresenter);
8
+ /** Presents the web picker. `presentation` is unused: web has no separate native/web mode. */
9
+ present(options?: EmojiPickerOptions): Promise<EmojiPickerResult>;
10
+ }
@@ -0,0 +1,12 @@
1
+ import { WebEmojiPickerPresenter } from './WebEmojiPickerPresenter';
2
+ /** Web adapter that presents `emoji-picker-element` in a bottom-sheet dialog. */
3
+ export class EmojiPickerWebAdapter {
4
+ constructor(presenter = new WebEmojiPickerPresenter()) {
5
+ this.presenter = presenter;
6
+ }
7
+ /** Presents the web picker. `presentation` is unused: web has no separate native/web mode. */
8
+ present(options) {
9
+ return this.presenter.present(options);
10
+ }
11
+ }
12
+ //# sourceMappingURL=EmojiPickerWebAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmojiPickerWebAdapter.js","sourceRoot":"","sources":["../../../../src/platform/web/EmojiPickerWebAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,iFAAiF;AACjF,MAAM,OAAO,qBAAqB;IAG9B,YAAmB,YAAqC,IAAI,uBAAuB,EAAE;QACjF,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,8FAA8F;IACvF,OAAO,CAAC,OAA4B;QACvC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;CACJ","sourcesContent":["import type { EmojiPickerOptions, EmojiPickerResult } from '../../definitions';\nimport type { EmojiPickerPlatform } from '../../service/EmojiPickerService';\nimport { WebEmojiPickerPresenter } from './WebEmojiPickerPresenter';\n\n/** Web adapter that presents `emoji-picker-element` in a bottom-sheet dialog. */\nexport class EmojiPickerWebAdapter implements EmojiPickerPlatform {\n private readonly presenter: WebEmojiPickerPresenter;\n\n public constructor(presenter: WebEmojiPickerPresenter = new WebEmojiPickerPresenter()) {\n this.presenter = presenter;\n }\n\n /** Presents the web picker. `presentation` is unused: web has no separate native/web mode. */\n public present(options?: EmojiPickerOptions): Promise<EmojiPickerResult> {\n return this.presenter.present(options);\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import type { EmojiPickerOptions, EmojiPickerResult } from '../../definitions';
2
+ /** Minimal shape of the `<emoji-picker>` custom element this presenter depends on. */
3
+ export interface EmojiPickerElement extends HTMLElement {
4
+ dataSource: string;
5
+ }
6
+ export interface WebEmojiPickerPresenterOptions {
7
+ /** Creates the picker element. Overridable for testing. */
8
+ createPickerElement?: () => Promise<EmojiPickerElement>;
9
+ }
10
+ /**
11
+ * Presents `emoji-picker-element` in a bottom-sheet `<dialog>` and resolves with the selected emoji.
12
+ *
13
+ * Kept independent of the Capacitor web plugin registration so native-platform fallback
14
+ * orchestration (issue #6) can present the same web picker from inside a native WebView.
15
+ */
16
+ export declare class WebEmojiPickerPresenter {
17
+ private readonly createPickerElement;
18
+ constructor(options?: WebEmojiPickerPresenterOptions);
19
+ present(options?: EmojiPickerOptions, presentOptions?: {
20
+ signal?: AbortSignal;
21
+ }): Promise<EmojiPickerResult>;
22
+ }
@@ -0,0 +1,292 @@
1
+ import { ErrorCodes } from '../../core/error-codes';
2
+ import { getBundledEmojiDataSourceUrl } from './emoji-data-source';
3
+ /** Registers `<emoji-picker>` (if needed) and creates the element. */
4
+ async function defaultCreatePickerElement() {
5
+ try {
6
+ await import('emoji-picker-element');
7
+ return document.createElement('emoji-picker');
8
+ }
9
+ catch (_a) {
10
+ throw new Error(ErrorCodes.NOT_IMPLEMENTED);
11
+ }
12
+ }
13
+ /**
14
+ * `emoji-picker-element`'s internal `Database` runs a background `fetch(dataSource, { method: 'HEAD' })`
15
+ * freshness check whenever it already has cached data for the locale (i.e. on the second+ open in a
16
+ * session). Non-`GET` requests to `blob:` URLs always throw `TypeError` per the Fetch spec, and this
17
+ * internal call isn't awaited, so it otherwise surfaces as a noisy but harmless `unhandledrejection`.
18
+ * This filters out only that specific rejection shape while a picker is open, letting everything else
19
+ * propagate normally to the host app.
20
+ */
21
+ function isKnownBlobHeadCheckRejection(reason) {
22
+ var _a, _b;
23
+ if (!(reason instanceof TypeError) || !reason.message.includes('Failed to fetch')) {
24
+ return false;
25
+ }
26
+ return (_b = (_a = reason.stack) === null || _a === void 0 ? void 0 : _a.includes('getETag')) !== null && _b !== void 0 ? _b : false;
27
+ }
28
+ const SHEET_STYLE_ELEMENT_ID = 'emoji-picker-sheet-styles';
29
+ const ANIMATION_MS = 200;
30
+ /** Injects the bottom-sheet stylesheet into `document.head`, once per document. */
31
+ function ensureSheetStylesInjected() {
32
+ if (document.getElementById(SHEET_STYLE_ELEMENT_ID)) {
33
+ return;
34
+ }
35
+ const style = document.createElement('style');
36
+ style.id = SHEET_STYLE_ELEMENT_ID;
37
+ style.textContent = `
38
+ dialog.emoji-picker-sheet {
39
+ position: fixed;
40
+ inset: auto 0 0 0;
41
+ margin: 0 auto;
42
+ display: flex;
43
+ flex-direction: column;
44
+ box-sizing: border-box;
45
+ width: 100%;
46
+ max-width: 30rem;
47
+ height: min(30rem, 80vh);
48
+ max-height: 80vh;
49
+ padding: 0 max(0.5rem, env(safe-area-inset-right, 0px)) max(0.5rem, env(safe-area-inset-bottom, 0px))
50
+ max(0.5rem, env(safe-area-inset-left, 0px));
51
+ border: none;
52
+ border-radius: 1rem 1rem 0 0;
53
+ background-color: Canvas;
54
+ overflow: hidden;
55
+ transform: translateY(100%);
56
+ transition: transform ${ANIMATION_MS}ms ease-out;
57
+ }
58
+ dialog.emoji-picker-sheet::backdrop {
59
+ background: rgba(0, 0, 0, 0.4);
60
+ }
61
+ dialog.emoji-picker-sheet[data-state='open'] {
62
+ transform: translateY(0);
63
+ }
64
+ .emoji-picker-sheet__header {
65
+ flex: 0 0 auto;
66
+ display: flex;
67
+ padding-block: 0.5rem;
68
+ }
69
+ .emoji-picker-sheet__close {
70
+ border: none;
71
+ border-radius: 50%;
72
+ background: rgba(0, 0, 0, 0.06);
73
+ color: inherit;
74
+ display: flex;
75
+ align-items: center;
76
+ justify-content: center;
77
+ padding: 0;
78
+ cursor: pointer;
79
+ }
80
+ @media (prefers-reduced-motion: reduce) {
81
+ dialog.emoji-picker-sheet {
82
+ transition: none;
83
+ }
84
+ }
85
+ `;
86
+ document.head.appendChild(style);
87
+ }
88
+ function prefersReducedMotion() {
89
+ return typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
90
+ }
91
+ const CLOSE_BUTTON_SIZE_PX = {
92
+ xSmall: 24,
93
+ small: 32,
94
+ medium: 48,
95
+ large: 64,
96
+ };
97
+ /** An "x" glyph sized proportionally to the button, matching the iOS button's icon/button ratio. */
98
+ function createCloseIcon(buttonSizePx) {
99
+ const svgNs = 'http://www.w3.org/2000/svg';
100
+ const iconSizePx = Math.round(buttonSizePx * 0.375);
101
+ const svg = document.createElementNS(svgNs, 'svg');
102
+ svg.setAttribute('viewBox', '0 0 24 24');
103
+ svg.setAttribute('width', String(iconSizePx));
104
+ svg.setAttribute('height', String(iconSizePx));
105
+ svg.setAttribute('fill', 'none');
106
+ svg.setAttribute('stroke', 'currentColor');
107
+ svg.setAttribute('stroke-width', '2.5');
108
+ svg.setAttribute('stroke-linecap', 'round');
109
+ svg.setAttribute('aria-hidden', 'true');
110
+ const diagonal1 = document.createElementNS(svgNs, 'line');
111
+ diagonal1.setAttribute('x1', '5');
112
+ diagonal1.setAttribute('y1', '5');
113
+ diagonal1.setAttribute('x2', '19');
114
+ diagonal1.setAttribute('y2', '19');
115
+ const diagonal2 = document.createElementNS(svgNs, 'line');
116
+ diagonal2.setAttribute('x1', '19');
117
+ diagonal2.setAttribute('y1', '5');
118
+ diagonal2.setAttribute('x2', '5');
119
+ diagonal2.setAttribute('y2', '19');
120
+ svg.append(diagonal1, diagonal2);
121
+ return svg;
122
+ }
123
+ /** Builds the header row hosting the close button, or `null` when the button is hidden. */
124
+ function createCloseButtonHeader(options) {
125
+ var _a, _b;
126
+ if (options.hidden) {
127
+ return null;
128
+ }
129
+ const sizePx = CLOSE_BUTTON_SIZE_PX[(_a = options.size) !== null && _a !== void 0 ? _a : 'medium'];
130
+ const position = (_b = options.position) !== null && _b !== void 0 ? _b : 'right';
131
+ const header = document.createElement('div');
132
+ header.className = 'emoji-picker-sheet__header';
133
+ header.style.justifyContent = position === 'left' ? 'flex-start' : position === 'center' ? 'center' : 'flex-end';
134
+ const button = document.createElement('button');
135
+ button.type = 'button';
136
+ button.className = 'emoji-picker-sheet__close';
137
+ button.setAttribute('aria-label', 'Close');
138
+ button.style.width = `${sizePx}px`;
139
+ button.style.height = `${sizePx}px`;
140
+ button.appendChild(createCloseIcon(sizePx));
141
+ header.appendChild(button);
142
+ return { header, button };
143
+ }
144
+ /**
145
+ * Presents `emoji-picker-element` in a bottom-sheet `<dialog>` and resolves with the selected emoji.
146
+ *
147
+ * Kept independent of the Capacitor web plugin registration so native-platform fallback
148
+ * orchestration (issue #6) can present the same web picker from inside a native WebView.
149
+ */
150
+ export class WebEmojiPickerPresenter {
151
+ constructor(options = {}) {
152
+ var _a;
153
+ this.createPickerElement = (_a = options.createPickerElement) !== null && _a !== void 0 ? _a : defaultCreatePickerElement;
154
+ }
155
+ async present(options = {}, presentOptions = {}) {
156
+ var _a, _b, _c;
157
+ const { signal } = presentOptions;
158
+ const closeButtonOptions = (_a = options.closeButton) !== null && _a !== void 0 ? _a : {};
159
+ // A hidden close button must never leave the user with zero ways to dismiss the picker,
160
+ // so hiding it force-enables backdrop-tap-to-dismiss regardless of what was explicitly
161
+ // requested (mirrors the iOS presenter's `effectiveDismissOnBackdropTap`).
162
+ const dismissOnBackdropTap = ((_b = options.dismissOnBackdropTap) !== null && _b !== void 0 ? _b : true) || ((_c = closeButtonOptions.hidden) !== null && _c !== void 0 ? _c : false);
163
+ let picker;
164
+ try {
165
+ picker = await this.createPickerElement();
166
+ picker.dataSource = getBundledEmojiDataSourceUrl();
167
+ }
168
+ catch (_d) {
169
+ throw new Error(ErrorCodes.NOT_IMPLEMENTED);
170
+ }
171
+ ensureSheetStylesInjected();
172
+ picker.style.display = 'block';
173
+ picker.style.width = '100%';
174
+ picker.style.flex = '1 1 auto';
175
+ picker.style.minHeight = '0';
176
+ // The picker's own card look (border + background) would otherwise float as a visibly
177
+ // smaller box inside the sheet; matching its background to the sheet's and dropping its
178
+ // border makes it read as full width, part of the sheet rather than nested inside it.
179
+ picker.style.setProperty('--background', 'Canvas');
180
+ picker.style.setProperty('--border-size', '0');
181
+ const dialog = document.createElement('dialog');
182
+ dialog.className = 'emoji-picker-sheet';
183
+ dialog.setAttribute('role', 'dialog');
184
+ dialog.setAttribute('aria-modal', 'true');
185
+ dialog.setAttribute('aria-label', 'Emoji picker');
186
+ const closeButtonHeader = createCloseButtonHeader(closeButtonOptions);
187
+ if (closeButtonHeader) {
188
+ // With the picker's own border removed above, this is the only visual separation
189
+ // between the close button and the picker.
190
+ picker.style.borderTop = '1px solid rgba(127, 127, 127, 0.3)';
191
+ }
192
+ return new Promise((resolve) => {
193
+ var _a;
194
+ let settled = false;
195
+ let pointerDownOnDialog = false;
196
+ const previouslyFocusedElement = document.activeElement;
197
+ const previousBodyOverflow = document.body.style.overflow;
198
+ const onUnhandledRejection = (event) => {
199
+ if (isKnownBlobHeadCheckRejection(event.reason)) {
200
+ event.preventDefault();
201
+ }
202
+ };
203
+ const finish = (result) => {
204
+ var _a;
205
+ window.removeEventListener('unhandledrejection', onUnhandledRejection);
206
+ document.body.style.overflow = previousBodyOverflow;
207
+ dialog.close();
208
+ dialog.remove();
209
+ if (previouslyFocusedElement instanceof HTMLElement && document.contains(previouslyFocusedElement)) {
210
+ (_a = previouslyFocusedElement.focus) === null || _a === void 0 ? void 0 : _a.call(previouslyFocusedElement);
211
+ }
212
+ resolve(result);
213
+ };
214
+ const settle = (result) => {
215
+ if (settled) {
216
+ return;
217
+ }
218
+ settled = true;
219
+ picker.removeEventListener('emoji-click', onEmojiClick);
220
+ dialog.removeEventListener('pointerdown', onDialogPointerDown);
221
+ dialog.removeEventListener('click', onDialogClick);
222
+ dialog.removeEventListener('cancel', onCancel);
223
+ document.removeEventListener('keydown', onKeyDown);
224
+ closeButtonHeader === null || closeButtonHeader === void 0 ? void 0 : closeButtonHeader.button.removeEventListener('click', onCloseButtonClick);
225
+ signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', onAbort);
226
+ dialog.removeAttribute('data-state');
227
+ if (prefersReducedMotion()) {
228
+ finish(result);
229
+ }
230
+ else {
231
+ setTimeout(() => finish(result), ANIMATION_MS);
232
+ }
233
+ };
234
+ const onEmojiClick = (event) => {
235
+ var _a;
236
+ settle({ emoji: (_a = event.detail.unicode) !== null && _a !== void 0 ? _a : null });
237
+ };
238
+ const onDialogPointerDown = (event) => {
239
+ pointerDownOnDialog = event.target === dialog;
240
+ };
241
+ const onDialogClick = (event) => {
242
+ if (dismissOnBackdropTap && event.target === dialog && pointerDownOnDialog) {
243
+ settle({ emoji: null });
244
+ }
245
+ };
246
+ // The dialog's native `cancel` event covers real browsers, where it fires
247
+ // automatically on Escape and its default action would otherwise close the dialog
248
+ // instantly, skipping the close animation. The `keydown` listener is a fallback for
249
+ // environments (e.g. jsdom in tests) that don't implement dialog cancellation;
250
+ // `settle` is idempotent, so both firing for the same keypress is harmless.
251
+ const onCancel = (event) => {
252
+ event.preventDefault();
253
+ settle({ emoji: null });
254
+ };
255
+ const onKeyDown = (event) => {
256
+ if (event.key === 'Escape') {
257
+ settle({ emoji: null });
258
+ }
259
+ };
260
+ const onCloseButtonClick = () => {
261
+ settle({ emoji: null });
262
+ };
263
+ const onAbort = () => {
264
+ settle({ emoji: null });
265
+ };
266
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
267
+ resolve({ emoji: null });
268
+ return;
269
+ }
270
+ signal === null || signal === void 0 ? void 0 : signal.addEventListener('abort', onAbort);
271
+ picker.addEventListener('emoji-click', onEmojiClick);
272
+ dialog.addEventListener('pointerdown', onDialogPointerDown);
273
+ dialog.addEventListener('click', onDialogClick);
274
+ dialog.addEventListener('cancel', onCancel);
275
+ document.addEventListener('keydown', onKeyDown);
276
+ window.addEventListener('unhandledrejection', onUnhandledRejection);
277
+ closeButtonHeader === null || closeButtonHeader === void 0 ? void 0 : closeButtonHeader.button.addEventListener('click', onCloseButtonClick);
278
+ if (closeButtonHeader) {
279
+ dialog.appendChild(closeButtonHeader.header);
280
+ }
281
+ dialog.appendChild(picker);
282
+ document.body.appendChild(dialog);
283
+ document.body.style.overflow = 'hidden';
284
+ dialog.showModal();
285
+ requestAnimationFrame(() => {
286
+ dialog.setAttribute('data-state', 'open');
287
+ });
288
+ (_a = picker.focus) === null || _a === void 0 ? void 0 : _a.call(picker);
289
+ });
290
+ }
291
+ }
292
+ //# sourceMappingURL=WebEmojiPickerPresenter.js.map