@fluid-topics/ft-wc-utils 2.0.14 → 2.0.16

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.
@@ -18,3 +18,4 @@ export declare function getComposedPathTo(element: EventTarget): EventTarget[];
18
18
  export declare function deepCopy<T = any>(value: T): T;
19
19
  export declare function randomId(size: number, prefix?: string): string;
20
20
  export declare function applyMixinOnce<IN extends Constructor<unknown>, OUT>(mixinIdentifier: symbol, mixin: (c: IN) => OUT): (c: IN) => OUT;
21
+ export declare function ignoreComposingEvents(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
package/build/helpers.js CHANGED
@@ -24,7 +24,10 @@ export function forEachDeep(arr, getChildren, callback) {
24
24
  var _a;
25
25
  for (let index = 0; index < currentArray.length; index++) {
26
26
  const current = currentArray[index];
27
- const shouldContinue = ((_a = callback(current, index, currentArray, breadcrumb)) !== null && _a !== void 0 ? _a : true) && recursiveForEach(getChildren(current), [...breadcrumb, current]);
27
+ const shouldContinue = ((_a = callback(current, index, currentArray, breadcrumb)) !== null && _a !== void 0 ? _a : true) && recursiveForEach(getChildren(current), [
28
+ ...breadcrumb,
29
+ current,
30
+ ]);
28
31
  if (!shouldContinue) {
29
32
  return false;
30
33
  }
@@ -202,3 +205,18 @@ export function applyMixinOnce(mixinIdentifier, mixin) {
202
205
  return result;
203
206
  };
204
207
  }
208
+ // Decorator to annotate a KeyboardEvent handling method to ignore composing events (e.g. selecting a character with the japanese keyboard).
209
+ // It will perform an early return if a composing event is matched, and execute the annotated method otherwise.
210
+ export function ignoreComposingEvents() {
211
+ return function (target, propertyKey, descriptor) {
212
+ const original = descriptor.value;
213
+ descriptor.value = function (e) {
214
+ // The use of event.keyCode is normal and acts as a safeguard for a Safari bug. See following link
215
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event#keydown_events_with_ime
216
+ if (e.isComposing || e.keyCode === 229) {
217
+ return;
218
+ }
219
+ return original.apply(this, [e]);
220
+ };
221
+ };
222
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-wc-utils",
3
- "version": "2.0.14",
3
+ "version": "2.0.16",
4
4
  "description": "Internal web components tools",
5
5
  "author": "Fluid Topics <devtopics@antidot.net>",
6
6
  "license": "ISC",
@@ -15,7 +15,7 @@
15
15
  "dependencies": {
16
16
  "@floating-ui/dom": "1.7.6",
17
17
  "@fluid-topics/design-system-variables": "3.2.2",
18
- "@fluid-topics/public-api": "1.0.119",
18
+ "@fluid-topics/public-api": "1.0.120",
19
19
  "@reduxjs/toolkit": "1.9.5",
20
20
  "@types/mark.js": "8.11.12",
21
21
  "@webcomponents/scoped-custom-element-registry": "0.0.9",
@@ -24,5 +24,5 @@
24
24
  "mark.js": "8.11.1",
25
25
  "moment": "2.29.4"
26
26
  },
27
- "gitHead": "4c50289bffd5b4b58542856830adc1399b93a70f"
27
+ "gitHead": "a972b95acf70b2bfab648ae99cec9d9cbe77c86f"
28
28
  }