@independo/capacitor-emoji-picker 1.1.1-dev.2 → 1.2.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 (27) hide show
  1. package/README.md +25 -0
  2. package/android/src/main/java/app/independo/capacitoremojipicker/EmojiPicker.java +11 -0
  3. package/android/src/main/java/app/independo/capacitoremojipicker/core/EmojiBackdropOptions.java +48 -0
  4. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/DefaultEmojiPickerDialogFactory.java +27 -1
  5. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/DispatchingEmojiPickerPresenter.java +3 -1
  6. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/EmojiPickerDialogFactory.java +8 -1
  7. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/EmojiPickerPresenter.java +2 -0
  8. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/NativeEmojiPickerPresenter.java +19 -4
  9. package/android/src/main/java/app/independo/capacitoremojipicker/presenter/WebFallbackEmojiPickerPresenter.java +18 -5
  10. package/android/src/main/java/app/independo/capacitoremojipicker/service/EmojiPickerService.java +3 -0
  11. package/dist/docs.json +42 -0
  12. package/dist/esm/definitions.d.ts +25 -0
  13. package/dist/esm/definitions.js.map +1 -1
  14. package/dist/esm/platform/web/WebEmojiPickerPresenter.js +34 -9
  15. package/dist/esm/platform/web/WebEmojiPickerPresenter.js.map +1 -1
  16. package/dist/plugin.cjs.js +34 -9
  17. package/dist/plugin.cjs.js.map +1 -1
  18. package/dist/plugin.js +34 -9
  19. package/dist/plugin.js.map +1 -1
  20. package/ios/Sources/EmojiPicker/Bridge/EmojiPicker.swift +14 -0
  21. package/ios/Sources/EmojiPicker/Core/EmojiBackdropColor.swift +27 -0
  22. package/ios/Sources/EmojiPicker/Presenter/DefaultEmojiKeyboardPresentationFactory.swift +69 -3
  23. package/ios/Sources/EmojiPicker/Presenter/EmojiKeyboardPresentationFactory.swift +1 -0
  24. package/ios/Sources/EmojiPicker/Presenter/EmojiPickerPresenter.swift +11 -0
  25. package/ios/Sources/EmojiPicker/Presenter/NativeEmojiPickerPresenter.swift +12 -1
  26. package/ios/Sources/EmojiPicker/Presenter/WebFallbackEmojiPickerPresenter.swift +14 -4
  27. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -95,12 +95,6 @@ var capacitorEmojiPicker = (function (exports, core) {
95
95
  background-color: #222;
96
96
  color: #e8e8e8;
97
97
  }
98
- dialog.emoji-picker-sheet::backdrop {
99
- background: rgba(0, 0, 0, 0.4);
100
- }
101
- dialog.emoji-picker-sheet--dark::backdrop {
102
- background: rgba(0, 0, 0, 0.6);
103
- }
104
98
  dialog.emoji-picker-sheet[data-state='open'] {
105
99
  transform: translateY(0);
106
100
  }
@@ -131,6 +125,35 @@ var capacitorEmojiPicker = (function (exports, core) {
131
125
  `;
132
126
  document.head.appendChild(style);
133
127
  }
128
+ const DEFAULT_BACKDROP_COLOR = '#00000066';
129
+ const HEX_COLOR_PATTERN = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
130
+ let backdropStyleCounter = 0;
131
+ /** Validates a `#RGB`/`#RRGGBB`/`#RRGGBBAA` hex color, falling back to the default on any other input. */
132
+ function resolveBackdropColor(color) {
133
+ if (color !== undefined && HEX_COLOR_PATTERN.test(color)) {
134
+ return color;
135
+ }
136
+ return DEFAULT_BACKDROP_COLOR;
137
+ }
138
+ /** Injects a one-off `::backdrop` rule scoped to a unique class, since inline styles can't target it. */
139
+ function injectBackdropStyle(options) {
140
+ var _a;
141
+ const className = `emoji-picker-backdrop-${++backdropStyleCounter}`;
142
+ const color = resolveBackdropColor(options.color);
143
+ const blur = (_a = options.blur) !== null && _a !== void 0 ? _a : 0;
144
+ const style = document.createElement('style');
145
+ // `backdrop-filter` is always set explicitly, never omitted: some browsers (e.g. Safari/WKWebView)
146
+ // apply their own default blur to a <dialog>'s ::backdrop in their UA stylesheet, which would
147
+ // otherwise leak through unopposed whenever the caller doesn't request blur.
148
+ style.textContent = `
149
+ dialog.${className}::backdrop {
150
+ background: ${color};
151
+ backdrop-filter: ${blur > 0 ? `blur(${blur}px)` : 'none'};
152
+ }
153
+ `;
154
+ document.head.appendChild(style);
155
+ return { className, remove: () => style.remove() };
156
+ }
134
157
  function prefersReducedMotion() {
135
158
  return typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
136
159
  }
@@ -216,7 +239,7 @@ var capacitorEmojiPicker = (function (exports, core) {
216
239
  this.createPickerElement = (_a = options.createPickerElement) !== null && _a !== void 0 ? _a : defaultCreatePickerElement;
217
240
  }
218
241
  async present(options = {}, presentOptions = {}) {
219
- var _a, _b, _c;
242
+ var _a, _b, _c, _d;
220
243
  const { signal } = presentOptions;
221
244
  const closeButtonOptions = (_a = options.closeButton) !== null && _a !== void 0 ? _a : {};
222
245
  // A hidden close button must never leave the user with zero ways to dismiss the picker,
@@ -233,7 +256,7 @@ var capacitorEmojiPicker = (function (exports, core) {
233
256
  picker.dataSource = getBundledEmojiDataSourceUrl();
234
257
  picker.classList.add(resolvedTheme);
235
258
  }
236
- catch (_d) {
259
+ catch (_e) {
237
260
  throw new Error(ErrorCodes.NOT_IMPLEMENTED);
238
261
  }
239
262
  ensureSheetStylesInjected();
@@ -246,8 +269,9 @@ var capacitorEmojiPicker = (function (exports, core) {
246
269
  // border makes it read as full width, part of the sheet rather than nested inside it.
247
270
  picker.style.setProperty('--background', SHEET_BACKGROUND_COLOR[resolvedTheme]);
248
271
  picker.style.setProperty('--border-size', '0');
272
+ const backdropStyle = injectBackdropStyle((_d = options.backdrop) !== null && _d !== void 0 ? _d : {});
249
273
  const dialog = document.createElement('dialog');
250
- dialog.className = `emoji-picker-sheet emoji-picker-sheet--${resolvedTheme}`;
274
+ dialog.className = `emoji-picker-sheet emoji-picker-sheet--${resolvedTheme} ${backdropStyle.className}`;
251
275
  dialog.setAttribute('role', 'dialog');
252
276
  dialog.setAttribute('aria-modal', 'true');
253
277
  dialog.setAttribute('aria-label', 'Emoji picker');
@@ -274,6 +298,7 @@ var capacitorEmojiPicker = (function (exports, core) {
274
298
  document.body.style.overflow = previousBodyOverflow;
275
299
  dialog.close();
276
300
  dialog.remove();
301
+ backdropStyle.remove();
277
302
  if (previouslyFocusedElement instanceof HTMLElement && document.contains(previouslyFocusedElement)) {
278
303
  (_a = previouslyFocusedElement.focus) === null || _a === void 0 ? void 0 : _a.call(previouslyFocusedElement);
279
304
  }