@player-ui/common-expressions-plugin 0.4.0-next.0 → 0.4.0-next.10

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/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@player-ui/common-expressions-plugin",
3
- "version": "0.4.0-next.0",
3
+ "version": "0.4.0-next.10",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"
7
7
  },
8
8
  "peerDependencies": {
9
- "@player-ui/player": "0.4.0-next.0"
9
+ "@player-ui/player": "0.4.0-next.10"
10
10
  },
11
11
  "dependencies": {
12
- "@player-ui/expression-plugin": "0.4.0-next.0",
12
+ "@player-ui/expression-plugin": "0.4.0-next.10",
13
13
  "@babel/runtime": "7.15.4"
14
14
  },
15
15
  "main": "dist/index.cjs.js",
@@ -53,6 +53,15 @@
53
53
  {
54
54
  "name": "Kelly Harrop",
55
55
  "url": "https://github.com/kharrop"
56
+ },
57
+ {
58
+ "name": "Alejandro Fimbres",
59
+ "url": "https://github.com/lexfm"
60
+ },
61
+ {
62
+ "name": "Rafael Campos",
63
+ "url": "https://github.com/rafbcampos"
56
64
  }
57
- ]
65
+ ],
66
+ "bundle": "./dist/common-expressions-plugin.prod.js"
58
67
  }
@@ -1,7 +1,4 @@
1
- import type {
2
- ExpressionHandler,
3
- ExpressionContext,
4
- } from '@player-ui/expressions';
1
+ import type { ExpressionHandler, ExpressionContext } from '@player-ui/player';
5
2
  import { withoutContext } from '@player-ui/player';
6
3
  import type { Binding } from '@player-ui/types';
7
4
  import { toNum } from './toNum';
@@ -118,14 +115,18 @@ export const sum = withoutContext<Array<number | string>, number>((...args) => {
118
115
 
119
116
  /** Finds the property in an array of objects */
120
117
  export const findPropertyIndex: ExpressionHandler<
121
- [Array<any> | Binding, string | undefined, any],
118
+ [Array<any> | Binding | undefined, string | undefined, any],
122
119
  number
123
120
  > = <T = unknown>(
124
121
  context: ExpressionContext,
125
- bindingOrModel: Binding | Array<Record<string, T>>,
122
+ bindingOrModel: Binding | Array<Record<string, T>> | undefined,
126
123
  propToCheck: string | undefined,
127
124
  valueToCheck: T
128
125
  ) => {
126
+ if (bindingOrModel === undefined) {
127
+ return -1;
128
+ }
129
+
129
130
  const searchArray: Array<Record<string, T>> = Array.isArray(bindingOrModel)
130
131
  ? bindingOrModel
131
132
  : context.model.get(bindingOrModel);
package/src/index.ts CHANGED
@@ -1,11 +1,58 @@
1
- import type { Player, PlayerPlugin } from '@player-ui/player';
1
+ import type { ExtendedPlayerPlugin, Player } from '@player-ui/player';
2
2
  import { ExpressionPlugin } from '@player-ui/expression-plugin';
3
3
  import * as Expressions from './expressions';
4
-
4
+ import type {
5
+ size,
6
+ length,
7
+ isEmpty,
8
+ isNotEmpty,
9
+ concat,
10
+ trim,
11
+ upperCase,
12
+ lowerCase,
13
+ replace,
14
+ titleCase,
15
+ sentenceCase,
16
+ number,
17
+ round,
18
+ floor,
19
+ ceil,
20
+ sum,
21
+ findPropertyIndex,
22
+ findProperty,
23
+ containsAny,
24
+ } from './expressions';
5
25
  /**
6
26
  * Exposes a lot of expressions to Player.
7
27
  */
8
- export class CommonExpressionsPlugin implements PlayerPlugin {
28
+ export class CommonExpressionsPlugin
29
+ implements
30
+ ExtendedPlayerPlugin<
31
+ [],
32
+ [],
33
+ [
34
+ typeof size,
35
+ typeof length,
36
+ typeof isEmpty,
37
+ typeof isNotEmpty,
38
+ typeof concat,
39
+ typeof trim,
40
+ typeof upperCase,
41
+ typeof lowerCase,
42
+ typeof replace,
43
+ typeof titleCase,
44
+ typeof sentenceCase,
45
+ typeof number,
46
+ typeof round,
47
+ typeof floor,
48
+ typeof ceil,
49
+ typeof sum,
50
+ typeof findPropertyIndex,
51
+ typeof findProperty,
52
+ typeof containsAny
53
+ ]
54
+ >
55
+ {
9
56
  name = 'CommonExpressions';
10
57
 
11
58
  apply(player: Player) {