@baleada/logic 0.23.2 → 0.23.3

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.
package/lib/index.cjs CHANGED
@@ -761,15 +761,13 @@ function createToGraph(options = {}) {
761
761
  }
762
762
 
763
763
  const defaultOptions$k = {
764
- toKey: (alias) => fromAliasToKeyStatusKey(alias)
764
+ toKey: (alias) => fromAliasToKeyStatusKey(alias),
765
+ toAliases: (event) => fromEventToAliases(event)
765
766
  };
766
767
  const createPredicateKeycomboMatch$1 = (keycombo, options = {}) => {
767
- const { toKey } = { ...defaultOptions$k, ...options }, keys = lazyCollections.pipe(
768
- fromComboToAliases,
769
- lazyCollections.map(toKey)
770
- )(keycombo);
768
+ const { toKey, toAliases } = { ...defaultOptions$k, ...options }, aliases = fromComboToAliases(keycombo), keys = lazyCollections.map(toKey)(aliases);
771
769
  return (event) => {
772
- const { toValue, set } = createKeyStatuses();
770
+ const { toValue, set, toEntries } = createKeyStatuses();
773
771
  set(fromEventToKeyStatusKey(event), "down");
774
772
  for (const modifier of modifiers) {
775
773
  if (event[`${modifier.toLowerCase()}Key`])
@@ -778,7 +776,11 @@ const createPredicateKeycomboMatch$1 = (keycombo, options = {}) => {
778
776
  return lazyCollections.every(lazyCollections.pipe(
779
777
  toValue,
780
778
  predicateDown
781
- ))(keys);
779
+ ))(keys) && lazyCollections.every(
780
+ ([key]) => lazyCollections.some(
781
+ (alias) => lazyCollections.includes(alias)(aliases)
782
+ )(toAliases(key))
783
+ )(toEntries());
782
784
  };
783
785
  };
784
786
 
package/lib/index.d.ts CHANGED
@@ -1245,6 +1245,7 @@ declare function createToGraph<TreeNode>(options?: CreateToGraphOptions<TreeNode
1245
1245
  type KeyboardEventFn<Returned> = (keyboardEvent: KeyboardEvent) => Returned;
1246
1246
  type CreatePredicateKeycomboMatchOptions = {
1247
1247
  toKey?: (alias: string) => KeyStatusKey;
1248
+ toAliases?: (event: KeyboardEvent) => string[];
1248
1249
  };
1249
1250
  declare const createPredicateKeycomboMatch: (keycombo: string, options?: CreatePredicateKeycomboMatchOptions) => KeyboardEventFn<boolean>;
1250
1251
 
package/lib/index.js CHANGED
@@ -759,15 +759,13 @@ function createToGraph(options = {}) {
759
759
  }
760
760
 
761
761
  const defaultOptions$k = {
762
- toKey: (alias) => fromAliasToKeyStatusKey(alias)
762
+ toKey: (alias) => fromAliasToKeyStatusKey(alias),
763
+ toAliases: (event) => fromEventToAliases(event)
763
764
  };
764
765
  const createPredicateKeycomboMatch$1 = (keycombo, options = {}) => {
765
- const { toKey } = { ...defaultOptions$k, ...options }, keys = pipe(
766
- fromComboToAliases,
767
- map(toKey)
768
- )(keycombo);
766
+ const { toKey, toAliases } = { ...defaultOptions$k, ...options }, aliases = fromComboToAliases(keycombo), keys = map(toKey)(aliases);
769
767
  return (event) => {
770
- const { toValue, set } = createKeyStatuses();
768
+ const { toValue, set, toEntries } = createKeyStatuses();
771
769
  set(fromEventToKeyStatusKey(event), "down");
772
770
  for (const modifier of modifiers) {
773
771
  if (event[`${modifier.toLowerCase()}Key`])
@@ -776,7 +774,11 @@ const createPredicateKeycomboMatch$1 = (keycombo, options = {}) => {
776
774
  return every(pipe(
777
775
  toValue,
778
776
  predicateDown
779
- ))(keys);
777
+ ))(keys) && every(
778
+ ([key]) => some(
779
+ (alias) => includes(alias)(aliases)
780
+ )(toAliases(key))
781
+ )(toEntries());
780
782
  };
781
783
  };
782
784
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baleada/logic",
3
- "version": "0.23.2",
3
+ "version": "0.23.3",
4
4
  "description": "UI logic for the Baleada toolkit",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.js",