@independo/capacitor-emoji-picker 1.0.2 → 1.1.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 (25) hide show
  1. package/README.md +13 -5
  2. package/android/src/main/java/app/independo/capacitoremojipicker/EmojiPicker.java +3 -0
  3. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/DefaultEmojiPickerDialogFactory.java +26 -6
  4. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/DispatchingEmojiPickerPresenter.java +8 -2
  5. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/EmojiPickerDialogFactory.java +1 -1
  6. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/EmojiPickerPresenter.java +7 -1
  7. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/NativeEmojiPickerPresenter.java +12 -5
  8. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/WebFallbackEmojiPickerPresenter.java +20 -7
  9. package/android/src/main/java/app/independo/capacitoremojipicker/service/EmojiPickerService.java +8 -1
  10. package/dist/docs.json +33 -0
  11. package/dist/esm/definitions.d.ts +15 -0
  12. package/dist/esm/definitions.js.map +1 -1
  13. package/dist/esm/platform/web/WebEmojiPickerPresenter.js +45 -7
  14. package/dist/esm/platform/web/WebEmojiPickerPresenter.js.map +1 -1
  15. package/dist/plugin.cjs.js +45 -7
  16. package/dist/plugin.cjs.js.map +1 -1
  17. package/dist/plugin.js +45 -7
  18. package/dist/plugin.js.map +1 -1
  19. package/ios/Sources/EmojiPicker/Bridge/EmojiPicker.swift +4 -1
  20. package/ios/Sources/EmojiPicker/Presenter/DefaultEmojiKeyboardPresentationFactory.swift +42 -3
  21. package/ios/Sources/EmojiPicker/Presenter/EmojiKeyboardPresentationFactory.swift +1 -0
  22. package/ios/Sources/EmojiPicker/Presenter/EmojiPickerPresenter.swift +2 -0
  23. package/ios/Sources/EmojiPicker/Presenter/NativeEmojiPickerPresenter.swift +5 -1
  24. package/ios/Sources/EmojiPicker/Presenter/WebFallbackEmojiPickerPresenter.swift +10 -6
  25. package/package.json +2 -2
@@ -77,14 +77,31 @@ function ensureSheetStylesInjected() {
77
77
  max(0.5rem, env(safe-area-inset-left, 0px));
78
78
  border: none;
79
79
  border-radius: 1rem 1rem 0 0;
80
- background-color: Canvas;
81
80
  overflow: hidden;
82
81
  transform: translateY(100%);
83
82
  transition: transform ${ANIMATION_MS}ms ease-out;
84
83
  }
84
+ /*
85
+ * Explicit colors rather than the \`Canvas\`/\`CanvasText\` system-color keywords: those rely
86
+ * on the UA knowing the page's color-scheme, which isn't reliably signaled inside a
87
+ * Capacitor WKWebView, so they were silently staying light-only regardless of the resolved
88
+ * theme. Values match emoji-picker-element's own light/dark defaults so the seam between
89
+ * the sheet chrome and the picker itself stays invisible.
90
+ */
91
+ dialog.emoji-picker-sheet--light {
92
+ background-color: #fff;
93
+ color: #1f1f1f;
94
+ }
95
+ dialog.emoji-picker-sheet--dark {
96
+ background-color: #222;
97
+ color: #e8e8e8;
98
+ }
85
99
  dialog.emoji-picker-sheet::backdrop {
86
100
  background: rgba(0, 0, 0, 0.4);
87
101
  }
102
+ dialog.emoji-picker-sheet--dark::backdrop {
103
+ background: rgba(0, 0, 0, 0.6);
104
+ }
88
105
  dialog.emoji-picker-sheet[data-state='open'] {
89
106
  transform: translateY(0);
90
107
  }
@@ -104,6 +121,9 @@ function ensureSheetStylesInjected() {
104
121
  padding: 0;
105
122
  cursor: pointer;
106
123
  }
124
+ dialog.emoji-picker-sheet--dark .emoji-picker-sheet__close {
125
+ background: rgba(255, 255, 255, 0.12);
126
+ }
107
127
  @media (prefers-reduced-motion: reduce) {
108
128
  dialog.emoji-picker-sheet {
109
129
  transition: none;
@@ -115,6 +135,23 @@ function ensureSheetStylesInjected() {
115
135
  function prefersReducedMotion() {
116
136
  return typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
117
137
  }
138
+ /** Resolves `system` to the OS's current light/dark preference; passes explicit themes through. */
139
+ function resolveTheme(theme) {
140
+ if (theme === 'light' || theme === 'dark') {
141
+ return theme;
142
+ }
143
+ const prefersDark = typeof window.matchMedia === 'function' && window.matchMedia('(prefers-color-scheme: dark)').matches;
144
+ return prefersDark ? 'dark' : 'light';
145
+ }
146
+ /**
147
+ * Matches the sheet's own `--light`/`--dark` background colors (see `ensureSheetStylesInjected`).
148
+ * Set explicitly, rather than the `Canvas` system-color keyword, for the same WKWebView
149
+ * color-scheme-detection reason documented there.
150
+ */
151
+ const SHEET_BACKGROUND_COLOR = {
152
+ light: '#fff',
153
+ dark: '#222',
154
+ };
118
155
  const CLOSE_BUTTON_SIZE_PX = {
119
156
  xSmall: 24,
120
157
  small: 32,
@@ -187,14 +224,15 @@ class WebEmojiPickerPresenter {
187
224
  // so hiding it force-enables backdrop-tap-to-dismiss regardless of what was explicitly
188
225
  // requested (mirrors the iOS presenter's `effectiveDismissOnBackdropTap`).
189
226
  const dismissOnBackdropTap = ((_b = options.dismissOnBackdropTap) !== null && _b !== void 0 ? _b : true) || ((_c = closeButtonOptions.hidden) !== null && _c !== void 0 ? _c : false);
227
+ // Resolved once at open time (rather than left to each side's own live
228
+ // `prefers-color-scheme` tracking) so the picker and the sheet chrome around it always
229
+ // agree, fixing the mismatch from issue #19.
230
+ const resolvedTheme = resolveTheme(options.theme);
190
231
  let picker;
191
232
  try {
192
233
  picker = await this.createPickerElement();
193
234
  picker.dataSource = getBundledEmojiDataSourceUrl();
194
- // The sheet chrome around the picker doesn't yet adapt to dark mode (issue #19), so
195
- // force the picker to light mode too rather than let it auto-follow
196
- // `prefers-color-scheme` on its own and visually mismatch the chrome.
197
- picker.classList.add('light');
235
+ picker.classList.add(resolvedTheme);
198
236
  }
199
237
  catch (_d) {
200
238
  throw new Error(ErrorCodes.NOT_IMPLEMENTED);
@@ -207,10 +245,10 @@ class WebEmojiPickerPresenter {
207
245
  // The picker's own card look (border + background) would otherwise float as a visibly
208
246
  // smaller box inside the sheet; matching its background to the sheet's and dropping its
209
247
  // border makes it read as full width, part of the sheet rather than nested inside it.
210
- picker.style.setProperty('--background', 'Canvas');
248
+ picker.style.setProperty('--background', SHEET_BACKGROUND_COLOR[resolvedTheme]);
211
249
  picker.style.setProperty('--border-size', '0');
212
250
  const dialog = document.createElement('dialog');
213
- dialog.className = 'emoji-picker-sheet';
251
+ dialog.className = `emoji-picker-sheet emoji-picker-sheet--${resolvedTheme}`;
214
252
  dialog.setAttribute('role', 'dialog');
215
253
  dialog.setAttribute('aria-modal', 'true');
216
254
  dialog.setAttribute('aria-label', 'Emoji picker');