@genesislcap/expression-builder 14.289.1 → 14.290.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.
@@ -883,6 +883,30 @@
883
883
  "kind": "javascript-module",
884
884
  "path": "src/utils/misc.ts",
885
885
  "declarations": [
886
+ {
887
+ "kind": "function",
888
+ "name": "getFieldInput",
889
+ "parameters": [
890
+ {
891
+ "name": "context",
892
+ "type": {
893
+ "text": "RuleValue | ModelRule"
894
+ }
895
+ }
896
+ ]
897
+ },
898
+ {
899
+ "kind": "function",
900
+ "name": "getFieldType",
901
+ "parameters": [
902
+ {
903
+ "name": "context",
904
+ "type": {
905
+ "text": "RuleValue | ModelRule"
906
+ }
907
+ }
908
+ ]
909
+ },
886
910
  {
887
911
  "kind": "function",
888
912
  "name": "processOptGroups",
@@ -935,6 +959,22 @@
935
959
  }
936
960
  ],
937
961
  "exports": [
962
+ {
963
+ "kind": "js",
964
+ "name": "getFieldInput",
965
+ "declaration": {
966
+ "name": "getFieldInput",
967
+ "module": "src/utils/misc.ts"
968
+ }
969
+ },
970
+ {
971
+ "kind": "js",
972
+ "name": "getFieldType",
973
+ "declaration": {
974
+ "name": "getFieldType",
975
+ "module": "src/utils/misc.ts"
976
+ }
977
+ },
938
978
  {
939
979
  "kind": "js",
940
980
  "name": "processOptGroups",
@@ -1212,33 +1252,53 @@
1212
1252
  "name": "defaultVal",
1213
1253
  "parameters": [
1214
1254
  {
1215
- "name": "f",
1255
+ "name": "newOpt",
1216
1256
  "type": {
1217
- "text": "Field"
1257
+ "text": "Operator"
1258
+ }
1259
+ },
1260
+ {
1261
+ "name": "m",
1262
+ "type": {
1263
+ "text": "ModelRule"
1218
1264
  }
1219
1265
  }
1220
- ]
1266
+ ],
1267
+ "description": "Gets the default value for a field accounting for\n- any default value hard coded on the config\n- any previous values when appropriate\n- account for different value types when switching operators"
1221
1268
  },
1222
1269
  {
1223
1270
  "kind": "function",
1224
1271
  "name": "getValue",
1225
1272
  "parameters": [
1273
+ {
1274
+ "name": "newOpt",
1275
+ "type": {
1276
+ "text": "Operator"
1277
+ }
1278
+ },
1226
1279
  {
1227
1280
  "name": "m",
1228
1281
  "type": {
1229
1282
  "text": "ModelRule"
1230
1283
  }
1231
1284
  }
1232
- ]
1285
+ ],
1286
+ "description": "If the user has changed the operator on a rule then we try and remember their value when possible\nIf the operators differ with type (e.g. an operator has a `valueType`) then we always create a new field default via returning null)"
1233
1287
  },
1234
1288
  {
1235
1289
  "kind": "function",
1236
1290
  "name": "fieldDefault",
1237
1291
  "parameters": [
1238
1292
  {
1239
- "name": "f",
1293
+ "name": "newOpt",
1240
1294
  "type": {
1241
- "text": "Field"
1295
+ "text": "Operator"
1296
+ }
1297
+ },
1298
+ {
1299
+ "name": "m",
1300
+ "type": {
1301
+ "text": "ModelRule"
1242
1302
  }
1243
1303
  }
1244
1304
  ]
@@ -1413,7 +1473,7 @@
1413
1473
  {
1414
1474
  "kind": "variable",
1415
1475
  "name": "template",
1416
- "default": "html<ExpressionRule>`\n ${(context) => {\n const buttonTag = context.styles?.customElements?.button || 'button';\n\n return html<ExpressionRule>`\n <div class=\"rule-container ${(x) => classNames(['error', x.error])}\">\n <div class=\"rule-content\">\n <expression-rule-field\nclass=\"margin\"\n :fields=${(x) => x.config.fields}\n :field=${(x) => x.model?.field}\n :config=${(x) => x.config}\n :styles=${(x) => x.styles}\n @field-selected=${(x, c) =>\n x.handleFieldSelected(c.event as CustomEvent<EventsDetailMap[Events.FieldSelected]>)}\n ></expression-rule-field>\n <expression-rule-operator\nclass=\"margin\"\n :operators=${(x) => x.config.operators}\n :field=${(x) => x.model.field}\n :operator=${(x) => x.model?.operator}\n :config=${(x) => x.config}\n :styles=${(x) => x.styles}\n @operator-selected=${(x, c) =>\n x.handleOperatorSelected(\n c.event as CustomEvent<EventsDetailMap[Events.OperatorSelected]>,\n )}\n ></expression-rule-operator>\n ${repeat(\n (x) => x.operandIterator,\n html<true, ExpressionRule>`\n <expression-rule-value\n class=\"margin\"\n :config=${(_, c) => c.parent.config}\n :styles=${(_, c) => c.parent.styles}\n :field=${(_, c) => c.parent.model.field}\n :value=${(_, c) => c.parent.operandValue(c.index)}\n value-index=${(_, c) => c.index}\n ?variadic=${(_, c) => c.parent.model?.operator?.nbInputs === 'many'}\n @value-updated=${(_, c) =>\n c.parent.handleValueChanged(\n c.event as CustomEvent<EventsDetailMap[Events.ValueUpdated]>,\n )}\n @remove-variadic-operand=${(_, c) =>\n c.parent.handleRemoveVarArg(\n c.event as CustomEvent<EventsDetailMap[Events.RemoveVarArg]>,\n )}\n ></expression-rule-value>\n `,\n { positioning: true, recycle: false },\n )}\n ${when(\n (x) => x.model?.operator?.nbInputs === 'many',\n html<ExpressionRule>`\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-accept\"\n @click=\"${(x) => x.dispatchAddVarArg()}\"\n >\n +\n </${buttonTag}>\n `,\n )}\n </div>\n\n <div class=\"rule-header\">\n <div class=\"btn-group rule-actions\">\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-danger\"\n data-delete=\"rule\"\n @click=\"${(x, c) => x.dispatchDeleteRule(c.event)}\"\n >\n Delete Rule\n </${buttonTag}>\n </div>\n </div>\n </div>\n `;\n }}\n`"
1476
+ "default": "html<ExpressionRule>`\n ${(context) => {\n const buttonTag = context.styles?.customElements?.button || 'button';\n\n return html<ExpressionRule>`\n <div class=\"rule-container ${(x) => classNames(['error', x.error])}\">\n <div class=\"rule-content\">\n <expression-rule-field\nclass=\"margin\"\n :fields=${(x) => x.config.fields}\n :field=${(x) => x.model?.field}\n :config=${(x) => x.config}\n :styles=${(x) => x.styles}\n @field-selected=${(x, c) =>\n x.handleFieldSelected(c.event as CustomEvent<EventsDetailMap[Events.FieldSelected]>)}\n ></expression-rule-field>\n <expression-rule-operator\nclass=\"margin\"\n :operators=${(x) => x.config.operators}\n :field=${(x) => x.model.field}\n :operator=${(x) => x.model?.operator}\n :config=${(x) => x.config}\n :styles=${(x) => x.styles}\n @operator-selected=${(x, c) =>\n x.handleOperatorSelected(\n c.event as CustomEvent<EventsDetailMap[Events.OperatorSelected]>,\n )}\n ></expression-rule-operator>\n ${repeat(\n (x) => x.operandIterator,\n html<true, ExpressionRule>`\n <expression-rule-value\n class=\"margin\"\n :config=${(_, c) => c.parent.config}\n :styles=${(_, c) => c.parent.styles}\n :field=${(_, c) => c.parent.model.field}\n :operator=${(_, c) => c.parent.model.operator}\n :value=${(_, c) => c.parent.operandValue(c.index)}\n value-index=${(_, c) => c.index}\n ?variadic=${(_, c) => c.parent.model?.operator?.nbInputs === 'many'}\n @value-updated=${(_, c) =>\n c.parent.handleValueChanged(\n c.event as CustomEvent<EventsDetailMap[Events.ValueUpdated]>,\n )}\n @remove-variadic-operand=${(_, c) =>\n c.parent.handleRemoveVarArg(\n c.event as CustomEvent<EventsDetailMap[Events.RemoveVarArg]>,\n )}\n ></expression-rule-value>\n `,\n { positioning: true, recycle: false },\n )}\n ${when(\n (x) => x.model?.operator?.nbInputs === 'many',\n html<ExpressionRule>`\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-accept\"\n @click=\"${(x) => x.dispatchAddVarArg()}\"\n >\n +\n </${buttonTag}>\n `,\n )}\n </div>\n\n <div class=\"rule-header\">\n <div class=\"btn-group rule-actions\">\n <${buttonTag}\n type=\"button\"\n class=\"btn btn-sm btn-danger\"\n data-delete=\"rule\"\n @click=\"${(x, c) => x.dispatchDeleteRule(c.event)}\"\n >\n Delete Rule\n </${buttonTag}>\n </div>\n </div>\n </div>\n `;\n }}\n`"
1417
1477
  }
1418
1478
  ],
1419
1479
  "exports": [
@@ -2051,6 +2111,14 @@
2051
2111
  },
2052
2112
  "default": "null"
2053
2113
  },
2114
+ {
2115
+ "kind": "field",
2116
+ "name": "operator",
2117
+ "type": {
2118
+ "text": "Operator | null"
2119
+ },
2120
+ "default": "null"
2121
+ },
2054
2122
  {
2055
2123
  "kind": "field",
2056
2124
  "name": "value",
@@ -1,7 +1,17 @@
1
- import { Field, ModelRule, Operator, Rule } from '../../types';
2
- export declare const defaultVal: (f: Field) => any;
3
- export declare const getValue: (m: ModelRule) => (index: number) => any;
4
- export declare const fieldDefault: (f: Field) => string | false | 0;
1
+ import { ModelRule, Operator, Rule } from '../../types';
2
+ /**
3
+ * Gets the default value for a field accounting for
4
+ * - any default value hard coded on the config
5
+ * - any previous values when appropriate
6
+ * - account for different value types when switching operators
7
+ */
8
+ export declare const defaultVal: (newOpt: Operator, m: ModelRule) => any;
9
+ /**
10
+ * If the user has changed the operator on a rule then we try and remember their value when possible
11
+ * If the operators differ with type (e.g. an operator has a `valueType`) then we always create a new field default via returning null)
12
+ */
13
+ export declare const getValue: (newOpt: Operator, m: ModelRule) => (index: number) => any;
14
+ export declare const fieldDefault: (newOpt: Operator, m: ModelRule) => string | false | 0;
5
15
  export declare const operatorChangedUpdatedModel: (newOperator: Operator, model: ModelRule) => Rule;
6
16
  export declare const valueChangedUpdateModel: (model: ModelRule, value: any, argIndex: number) => Rule;
7
17
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"expression-rule.helpers.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-rule/expression-rule.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EACL,SAAS,EACT,QAAQ,EACR,IAAI,EAIL,MAAM,aAAa,CAAC;AAGrB,eAAO,MAAM,UAAU,MAAO,KAAK,QAC8B,CAAC;AAElE,eAAO,MAAM,QAAQ,MAAO,SAAS,aAAa,MAAM,QAKvD,CAAC;AAEF,eAAO,MAAM,YAAY,MAAO,KAAK,uBAqBpC,CAAC;AAEF,eAAO,MAAM,2BAA2B,gBAAiB,QAAQ,SAAS,SAAS,KAAG,IA4BrF,CAAC;AAEF,eAAO,MAAM,uBAAuB,UAAW,SAAS,SAAS,GAAG,YAAY,MAAM,KAAG,IAqBxF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,MAAO,GAAG,YAAkB,CAAC;AAExD,eAAO,MAAM,kBAAkB,UAAW,SAAS,KAAG,OASrD,CAAC"}
1
+ {"version":3,"file":"expression-rule.helpers.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-rule/expression-rule.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,QAAQ,EACR,IAAI,EAIL,MAAM,aAAa,CAAC;AAIrB;;;;;GAKG;AACH,eAAO,MAAM,UAAU,WAAY,QAAQ,KAAK,SAAS,QAC4B,CAAC;AAEtF;;;GAGG;AACH,eAAO,MAAM,QAAQ,WAAY,QAAQ,KAAK,SAAS,aAAa,MAAM,QAOzE,CAAC;AAEF,eAAO,MAAM,YAAY,WAAY,QAAQ,KAAK,SAAS,uBA2B1D,CAAC;AAEF,eAAO,MAAM,2BAA2B,gBAAiB,QAAQ,SAAS,SAAS,KAAG,IAgCrF,CAAC;AAEF,eAAO,MAAM,uBAAuB,UAAW,SAAS,SAAS,GAAG,YAAY,MAAM,KAAG,IAqBxF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,MAAO,GAAG,YAAkB,CAAC;AAExD,eAAO,MAAM,kBAAkB,UAAW,SAAS,KAAG,OASrD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"expression-rule.template.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-rule/expression-rule.template.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,eAAO,MAAM,QAAQ,qEAgFpB,CAAC"}
1
+ {"version":3,"file":"expression-rule.template.d.ts","sourceRoot":"","sources":["../../../../src/main/expression-rule/expression-rule.template.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,eAAO,MAAM,QAAQ,qEAiFpB,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import { GenesisElement } from '@genesislcap/web-core';
2
- import { Config, Field, Styles } from '../../types';
2
+ import { Config, Field, Operator, Styles } from '../../types';
3
3
  export declare class RuleValue extends GenesisElement {
4
4
  valueIndex: string;
5
5
  variadic: boolean;
6
6
  validationError: boolean;
7
7
  validationMsg: string;
8
8
  field: Field | null;
9
+ operator: Operator | null;
9
10
  value: any;
10
11
  config: Config;
11
12
  styles?: Styles;
@@ -1 +1 @@
1
- {"version":3,"file":"rule-value.d.ts","sourceRoot":"","sources":["../../../../src/main/rule-value/rule-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,cAAc,EAAc,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAOpD,qBAQa,SAAU,SAAQ,cAAc;IACP,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAS;IACK,eAAe,EAAE,OAAO,CAAS;IACpD,aAAa,EAAE,MAAM,CAAC;IACjD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAQ;IAC3B,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAE5B,iBAAiB,IAAI,IAAI;IAMzB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAc3C,iBAAiB,CAAC,KAAK,EAAE,KAAK;IA6C9B,2BAA2B;CAS5B"}
1
+ {"version":3,"file":"rule-value.d.ts","sourceRoot":"","sources":["../../../../src/main/rule-value/rule-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,cAAc,EAAc,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAO9D,qBAQa,SAAU,SAAQ,cAAc;IACP,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAS;IACK,eAAe,EAAE,OAAO,CAAS;IACpD,aAAa,EAAE,MAAM,CAAC;IACjD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAQ;IAC3B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAQ;IACjC,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAE5B,iBAAiB,IAAI,IAAI;IAMzB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAc3C,iBAAiB,CAAC,KAAK,EAAE,KAAK;IA6C9B,2BAA2B;CAS5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"rule-value.template.d.ts","sourceRoot":"","sources":["../../../../src/main/rule-value/rule-value.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA4H9C,eAAO,MAAM,iBAAiB,gEAQ7B,CAAC"}
1
+ {"version":3,"file":"rule-value.template.d.ts","sourceRoot":"","sources":["../../../../src/main/rule-value/rule-value.template.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAuI9C,eAAO,MAAM,iBAAiB,gEAQ7B,CAAC"}
@@ -117,6 +117,8 @@ export type Config = {
117
117
  * `type`: The name of the operator (e.g. one_of)
118
118
  *
119
119
  * `tooltip`: Optional tooltip to display on mouse hover
120
+ *
121
+ * `valueType`: [EXPERIMENTAL] Optional override to change the input type for the operator (e.g. a date field could present a string input)
120
122
  */
121
123
  /** @beta **/
122
124
  export type _Operator = {
@@ -124,6 +126,7 @@ export type _Operator = {
124
126
  optgroup?: string | null;
125
127
  type: string;
126
128
  tooltip?: string;
129
+ valueType?: FieldTypes;
127
130
  };
128
131
  /**
129
132
  * An operator which doesn't have any value. Example `is_null`
@@ -1 +1 @@
1
- {"version":3,"file":"public.types.d.ts","sourceRoot":"","sources":["../../../src/types/public.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAA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CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;WAWW;AACX,MAAM,MAAM,IAAI,GAAG;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB,GAAG,CACA;IACE,QAAQ,EAAE,IAAI,CAAC;CAChB,GACD;IACE,QAAQ,EAAE,eAAe,CAAC;CAC3B,GACD;IACE,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,GAAG,CAAC;CACZ,GACD;IACE,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;CACnB,GACD;IACE,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,GAAG,EAAE,CAAC;CACd,CACJ,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;CAC5B,CAAC"}
@@ -1,4 +1,7 @@
1
- import { Field, Operator, Styles } from '../types';
1
+ import type { RuleValue } from '../main/rule-value/rule-value';
2
+ import type { Field, ModelRule, Operator, Styles } from '../types';
3
+ export declare const getFieldInput: (context: RuleValue | ModelRule) => "number" | "date" | "text" | "checkbox" | "select" | "datetime-local";
4
+ export declare const getFieldType: (context: RuleValue | ModelRule) => "string" | "boolean" | "int" | "short" | "double" | "long" | "bigdecimal" | "enum" | "date" | "date-time";
2
5
  export declare const processOptGroups: <T extends Operator | Field>(xs: T[]) => (T | {
3
6
  optgroup: string | null;
4
7
  xs: T[];
@@ -1 +1 @@
1
- {"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/utils/misc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEnD,eAAO,MAAM,gBAAgB;cAET,MAAM,GAAG,IAAI;;IAyChC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,WAAW,EACtB,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EACjC,QAAQ,EAAE,MAAM,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,GAClD,IAAI,CAeN"}
1
+ {"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/utils/misc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEnE,eAAO,MAAM,aAAa,YAAa,SAAS,GAAG,SAAS,0EACD,CAAC;AAE5D,eAAO,MAAM,YAAY,YAAa,SAAS,GAAG,SAAS,8GACF,CAAC;AAE1D,eAAO,MAAM,gBAAgB;cAET,MAAM,GAAG,IAAI;;IAyChC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,WAAW,EACtB,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EACjC,QAAQ,EAAE,MAAM,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,GAClD,IAAI,CAeN"}
@@ -1,6 +1,20 @@
1
- import { formatDateString, formatDateTimeString } from '../../utils';
2
- export const defaultVal = (f) => f.defaultValue !== undefined ? f.defaultValue : fieldDefault(f);
3
- export const getValue = (m) => (index) => {
1
+ import { formatDateString, formatDateTimeString, getFieldType } from '../../utils';
2
+ /**
3
+ * Gets the default value for a field accounting for
4
+ * - any default value hard coded on the config
5
+ * - any previous values when appropriate
6
+ * - account for different value types when switching operators
7
+ */
8
+ export const defaultVal = (newOpt, m) => m.field.defaultValue !== undefined ? m.field.defaultValue : fieldDefault(newOpt, m);
9
+ /**
10
+ * If the user has changed the operator on a rule then we try and remember their value when possible
11
+ * If the operators differ with type (e.g. an operator has a `valueType`) then we always create a new field default via returning null)
12
+ */
13
+ export const getValue = (newOpt, m) => (index) => {
14
+ var _a, _b, _c;
15
+ // If neither opt uses a value type then we compare null and don't exit early
16
+ if (((_a = newOpt === null || newOpt === void 0 ? void 0 : newOpt.valueType) === null || _a === void 0 ? void 0 : _a.type) !== ((_c = (_b = m.operator) === null || _b === void 0 ? void 0 : _b.valueType) === null || _c === void 0 ? void 0 : _c.type))
17
+ return null;
4
18
  if (!('value' in m) || !m.value || !m.operator)
5
19
  return null;
6
20
  const value = m.operator.nbInputs === 1 ? [m.value] : m.value;
@@ -8,8 +22,9 @@ export const getValue = (m) => (index) => {
8
22
  return null;
9
23
  return value[index];
10
24
  };
11
- export const fieldDefault = (f) => {
12
- switch (f.type) {
25
+ export const fieldDefault = (newOpt, m) => {
26
+ var _a, _b;
27
+ switch (getFieldType(Object.assign(Object.assign({}, m), { operator: newOpt }))) {
13
28
  case 'string':
14
29
  return '';
15
30
  case 'boolean':
@@ -25,39 +40,48 @@ export const fieldDefault = (f) => {
25
40
  case 'long':
26
41
  return 0;
27
42
  case 'enum': {
28
- if (Object.keys(f.values).length === 0)
43
+ const values = ((_a = newOpt === null || newOpt === void 0 ? void 0 : newOpt.valueType) === null || _a === void 0 ? void 0 : _a.type) === 'enum'
44
+ ? (_b = newOpt === null || newOpt === void 0 ? void 0 : newOpt.valueType) === null || _b === void 0 ? void 0 : _b.values
45
+ : m.field.type === 'enum'
46
+ ? m.field.values
47
+ : {};
48
+ if (Object.keys(values).length === 0)
29
49
  throw new Error('Enums require configured values');
30
- return Object.keys(f.values)[0];
50
+ return Object.keys(values)[0];
31
51
  }
32
52
  }
33
53
  };
34
54
  export const operatorChangedUpdatedModel = (newOperator, model) => {
35
55
  var _a, _b, _c, _d;
36
- const tryPrevVal = getValue(model);
56
+ const tryPrevVal = getValue(newOperator, model);
37
57
  switch (newOperator.nbInputs) {
38
58
  case 0:
39
59
  return {
40
60
  field: model.field,
41
61
  operator: newOperator,
62
+ value: undefined,
42
63
  };
43
64
  case 1:
44
65
  return {
45
66
  field: model.field,
46
67
  operator: newOperator,
47
- value: (_a = tryPrevVal(0)) !== null && _a !== void 0 ? _a : defaultVal(model.field),
68
+ value: (_a = tryPrevVal(0)) !== null && _a !== void 0 ? _a : defaultVal(newOperator, model),
48
69
  };
49
70
  case 2:
50
71
  return {
51
72
  field: model.field,
52
73
  operator: newOperator,
53
- value: [(_b = tryPrevVal(0)) !== null && _b !== void 0 ? _b : defaultVal(model.field), (_c = tryPrevVal(1)) !== null && _c !== void 0 ? _c : defaultVal(model.field)],
74
+ value: [
75
+ (_b = tryPrevVal(0)) !== null && _b !== void 0 ? _b : defaultVal(newOperator, model),
76
+ (_c = tryPrevVal(1)) !== null && _c !== void 0 ? _c : defaultVal(newOperator, model),
77
+ ],
54
78
  };
55
79
  case 'many':
56
80
  return {
57
81
  field: model.field,
58
82
  operator: newOperator,
59
83
  // Variadic operators always start with 1 operand
60
- value: [(_d = tryPrevVal(0)) !== null && _d !== void 0 ? _d : defaultVal(model.field)],
84
+ value: [(_d = tryPrevVal(0)) !== null && _d !== void 0 ? _d : defaultVal(newOperator, model)],
61
85
  };
62
86
  }
63
87
  };
@@ -100,7 +124,7 @@ export const isPartialRuleError = (model) => {
100
124
  if (!('value' in model))
101
125
  throw new Error('No value set as required for operator');
102
126
  // Checking against either false or true boolean is valid
103
- if (model.field.type === 'boolean')
127
+ if (getFieldType(model) === 'boolean')
104
128
  return false;
105
129
  const value = Array.isArray(model.value) ? model.value : [model.value];
106
130
  if (value.some(isValueInvalid))
@@ -60,7 +60,7 @@ let ExpressionRule = class ExpressionRule extends GenesisElement {
60
60
  newData: {
61
61
  operator: this.model.operator,
62
62
  field: this.model.field,
63
- value: [...this.model.value, defaultVal(this.model.field)],
63
+ value: [...this.model.value, defaultVal(this.model.operator, this.model)],
64
64
  },
65
65
  };
66
66
  this.dispatchEvent(new CustomEvent(Events.UpdateRule, { detail, bubbles: true, composed: true }));
@@ -29,6 +29,7 @@ class="margin"
29
29
  :config=${(_, c) => c.parent.config}
30
30
  :styles=${(_, c) => c.parent.styles}
31
31
  :field=${(_, c) => c.parent.model.field}
32
+ :operator=${(_, c) => c.parent.model.operator}
32
33
  :value=${(_, c) => c.parent.operandValue(c.index)}
33
34
  value-index=${(_, c) => c.index}
34
35
  ?variadic=${(_, c) => { var _a, _b; return ((_b = (_a = c.parent.model) === null || _a === void 0 ? void 0 : _a.operator) === null || _b === void 0 ? void 0 : _b.nbInputs) === 'many'; }}
@@ -1,6 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { attr, customElement, GenesisElement, observable } from '@genesislcap/web-core';
3
- import { applyCustomStyles } from '../../utils/misc';
3
+ import { applyCustomStyles, getFieldType } from '../../utils/misc';
4
4
  import { Events } from '../events';
5
5
  import { isFloatType, isIntType, numberPatternValidator } from './rule-value.helpers';
6
6
  import { styles } from './rule-value.styles';
@@ -11,6 +11,7 @@ let RuleValue = class RuleValue extends GenesisElement {
11
11
  this.variadic = false;
12
12
  this.validationError = false;
13
13
  this.field = null;
14
+ this.operator = null;
14
15
  }
15
16
  connectedCallback() {
16
17
  super.connectedCallback();
@@ -22,7 +23,7 @@ let RuleValue = class RuleValue extends GenesisElement {
22
23
  return null;
23
24
  const errorMsg = [
24
25
  'validation' in this.field ? this.field.validation(value) : null,
25
- numberPatternValidator(this.field.type, value),
26
+ numberPatternValidator(getFieldType(this), value),
26
27
  ]
27
28
  .filter((v) => !!v)
28
29
  .join(', ');
@@ -53,10 +54,10 @@ let RuleValue = class RuleValue extends GenesisElement {
53
54
  else if (target.type === 'select-one') {
54
55
  newValue = event.target.value;
55
56
  }
56
- else if (this.field && isIntType(this.field.type)) {
57
+ else if (this.field && isIntType(getFieldType(this))) {
57
58
  newValue = parseInt(target.value);
58
59
  }
59
- else if (this.field && isFloatType(this.field.type)) {
60
+ else if (this.field && isFloatType(getFieldType(this))) {
60
61
  newValue = parseFloat(target.value);
61
62
  }
62
63
  else {
@@ -93,6 +94,9 @@ __decorate([
93
94
  __decorate([
94
95
  observable
95
96
  ], RuleValue.prototype, "field", void 0);
97
+ __decorate([
98
+ observable
99
+ ], RuleValue.prototype, "operator", void 0);
96
100
  __decorate([
97
101
  observable
98
102
  ], RuleValue.prototype, "value", void 0);
@@ -1,9 +1,10 @@
1
1
  import { classNames, html, repeat, when, whenElse } from '@genesislcap/web-core';
2
+ import { getFieldInput } from '../../utils';
2
3
  // Simple input template with custom element tags support
3
4
  const simpleTemplate = html `
4
5
  ${(context) => {
5
6
  var _a, _b;
6
- const inputType = context.field.input;
7
+ const inputType = getFieldInput(context);
7
8
  // Convert datetime-local to datetimeLocal for the config property name
8
9
  const configKey = inputType === 'datetime-local' ? 'datetimeLocal' : inputType;
9
10
  // Get custom tag if available
@@ -33,9 +34,13 @@ const selectTemplate = html `
33
34
  value=${(x) => x.value}
34
35
  >
35
36
  ${repeat((x) => {
36
- var _a, _b;
37
+ var _a, _b, _c, _d;
37
38
  // Ensure values is defined and an object before calling Object.entries
38
- const values = ((_a = x.field) === null || _a === void 0 ? void 0 : _a.type) === 'enum' && ((_b = x.field) === null || _b === void 0 ? void 0 : _b.values) ? x.field.values : {};
39
+ const values = ((_b = (_a = x.operator) === null || _a === void 0 ? void 0 : _a.valueType) === null || _b === void 0 ? void 0 : _b.type) === 'enum' && ((_d = (_c = x === null || x === void 0 ? void 0 : x.operator) === null || _c === void 0 ? void 0 : _c.valueType) === null || _d === void 0 ? void 0 : _d.values)
40
+ ? x.operator.valueType.values
41
+ : x.field.type === 'enum' && x.field.values
42
+ ? x.field.values
43
+ : {};
39
44
  return Object.entries(values);
40
45
  }, () => html `
41
46
  <${optionTag} value="${(x) => x[0]}" ?selected=${(x, c) => x[0] === c.parent.value}>
@@ -69,24 +74,27 @@ const checkboxTemplate = html `
69
74
  `;
70
75
  // Unsupported input template
71
76
  const unsupportedTemplate = html `
72
- <div>Input type "${(x) => x.field.input}" not yet supported.</div>
77
+ <div>Input type "${(x) => getFieldInput(x)}" not yet supported.</div>
73
78
  `;
74
79
  // Template switcher
75
80
  const templateSwitcher = html `
76
- <div class="value-and-validation">
77
- ${when((x) => ['text', 'number', 'date', 'datetime-local'].includes(x.field.input), simpleTemplate)}
78
- ${when((x) => x.field.input === 'select', selectTemplate)}
79
- ${when((x) => x.field.input === 'checkbox', checkboxTemplate)}
80
- ${when((x) => !['text', 'number', 'select', 'checkbox', 'date', 'datetime-local'].includes(x.field.input), unsupportedTemplate)}
81
- ${when((x) => x.validationMsg, html `
82
- <p class="validation-msg">${(x) => x.validationMsg}</p>
83
- `)}
84
- </div>
85
- ${when((x) => x.variadic && x.valueIndex !== '0', html `
86
- ${(context) => {
87
- var _a, _b;
88
- const buttonTag = ((_b = (_a = context.styles) === null || _a === void 0 ? void 0 : _a.customElements) === null || _b === void 0 ? void 0 : _b.button) || 'button';
81
+ ${(context) => {
82
+ const inputFieldType = getFieldInput(context);
89
83
  return html `
84
+ <div class="value-and-validation">
85
+ ${when(() => ['text', 'number', 'date', 'datetime-local'].includes(inputFieldType), simpleTemplate)}
86
+ ${when(() => inputFieldType === 'select', selectTemplate)}
87
+ ${when(() => inputFieldType === 'checkbox', checkboxTemplate)}
88
+ ${when(() => !['text', 'number', 'select', 'checkbox', 'date', 'datetime-local'].includes(inputFieldType), unsupportedTemplate)}
89
+ ${when((x) => x.validationMsg, html `
90
+ <p class="validation-msg">${(x) => x.validationMsg}</p>
91
+ `)}
92
+ </div>
93
+ ${when((x) => x.variadic && x.valueIndex !== '0', html `
94
+ ${() => {
95
+ var _a, _b;
96
+ const buttonTag = ((_b = (_a = context.styles) === null || _a === void 0 ? void 0 : _a.customElements) === null || _b === void 0 ? void 0 : _b.button) || 'button';
97
+ return html `
90
98
  <${buttonTag}
91
99
  type="button"
92
100
  class="btn btn-sm btn-remove"
@@ -95,8 +103,10 @@ const templateSwitcher = html `
95
103
  -
96
104
  </${buttonTag}>
97
105
  `;
106
+ }}
107
+ `)}
108
+ `;
98
109
  }}
99
- `)}
100
110
  `;
101
111
  // Main template
102
112
  export const ruleValueTemplate = html `
@@ -1,3 +1,5 @@
1
+ export const getFieldInput = (context) => { var _a, _b, _c; return (_c = (_b = (_a = context.operator) === null || _a === void 0 ? void 0 : _a.valueType) === null || _b === void 0 ? void 0 : _b.input) !== null && _c !== void 0 ? _c : context.field.input; };
2
+ export const getFieldType = (context) => { var _a, _b, _c; return (_c = (_b = (_a = context.operator) === null || _a === void 0 ? void 0 : _a.valueType) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : context.field.type; };
1
3
  export const processOptGroups = (xs) => {
2
4
  const grouped = {};
3
5
  const ungrouped = [];
@@ -562,7 +562,16 @@
562
562
  },
563
563
  {
564
564
  "kind": "Content",
565
- "text": "['type'][];\n optgroup?: string | null;\n type: string;\n tooltip?: string;\n}"
565
+ "text": "['type'][];\n optgroup?: string | null;\n type: string;\n tooltip?: string;\n valueType?: "
566
+ },
567
+ {
568
+ "kind": "Reference",
569
+ "text": "FieldTypes",
570
+ "canonicalReference": "@genesislcap/expression-builder!Types.FieldTypes:type"
571
+ },
572
+ {
573
+ "kind": "Content",
574
+ "text": ";\n}"
566
575
  },
567
576
  {
568
577
  "kind": "Content",
@@ -574,7 +583,7 @@
574
583
  "name": "_Operator",
575
584
  "typeTokenRange": {
576
585
  "startIndex": 1,
577
- "endIndex": 4
586
+ "endIndex": 6
578
587
  }
579
588
  },
580
589
  {
@@ -494,6 +494,8 @@ declare type Operator = UniraryOperator | BinaryOperator | TernararyOperator | V
494
494
  * `type`: The name of the operator (e.g. one_of)
495
495
  *
496
496
  * `tooltip`: Optional tooltip to display on mouse hover
497
+ *
498
+ * `valueType`: [EXPERIMENTAL] Optional override to change the input type for the operator (e.g. a date field could present a string input)
497
499
  */
498
500
  /** @beta **/
499
501
  declare type _Operator = {
@@ -501,6 +503,7 @@ declare type _Operator = {
501
503
  optgroup?: string | null;
502
504
  type: string;
503
505
  tooltip?: string;
506
+ valueType?: FieldTypes;
504
507
  };
505
508
 
506
509
  /**
@@ -17,6 +17,7 @@ export type _Operator = {
17
17
  optgroup?: string | null;
18
18
  type: string;
19
19
  tooltip?: string;
20
+ valueType?: FieldTypes;
20
21
  };
21
22
  ```
22
23
  **References:** [FieldTypes](./expression-builder.types.fieldtypes.md)
@@ -169,6 +169,7 @@ type _Operator = {
169
169
  optgroup?: string | null;
170
170
  type: string;
171
171
  tooltip?: string;
172
+ valueType?: FieldTypes;
172
173
  };
173
174
 
174
175
  // @beta
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/expression-builder",
3
3
  "description": "Genesis Foundation Expression Builder",
4
- "version": "14.289.1",
4
+ "version": "14.290.0",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "main": "dist/esm/index.js",
7
7
  "types": "dist/expression-builder.d.ts",
@@ -59,5 +59,5 @@
59
59
  "access": "public"
60
60
  },
61
61
  "customElements": "dist/custom-elements.json",
62
- "gitHead": "db2f7a2aba6d628296a52a0eebb8b4cadcc829aa"
62
+ "gitHead": "d06408e1848d98c9de0bd3a7f3998e5650128d5d"
63
63
  }