@pega/cosmos-react-condition-builder 2.1.5 → 2.1.6

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 (105) hide show
  1. package/package.json +3 -3
  2. package/lib/components/ConditionBuilder/AtomicCondition.d.ts +0 -51
  3. package/lib/components/ConditionBuilder/AtomicCondition.d.ts.map +0 -1
  4. package/lib/components/ConditionBuilder/AtomicCondition.js +0 -119
  5. package/lib/components/ConditionBuilder/AtomicCondition.js.map +0 -1
  6. package/lib/components/ConditionBuilder/ConditionBuilder.d.ts +0 -6
  7. package/lib/components/ConditionBuilder/ConditionBuilder.d.ts.map +0 -1
  8. package/lib/components/ConditionBuilder/ConditionBuilder.js +0 -234
  9. package/lib/components/ConditionBuilder/ConditionBuilder.js.map +0 -1
  10. package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +0 -112
  11. package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts.map +0 -1
  12. package/lib/components/ConditionBuilder/ConditionBuilder.types.js +0 -2
  13. package/lib/components/ConditionBuilder/ConditionBuilder.types.js.map +0 -1
  14. package/lib/components/ConditionBuilder/FieldCondition.d.ts +0 -7
  15. package/lib/components/ConditionBuilder/FieldCondition.d.ts.map +0 -1
  16. package/lib/components/ConditionBuilder/FieldCondition.js +0 -26
  17. package/lib/components/ConditionBuilder/FieldCondition.js.map +0 -1
  18. package/lib/components/ConditionBuilder/FieldCondition.types.d.ts +0 -25
  19. package/lib/components/ConditionBuilder/FieldCondition.types.d.ts.map +0 -1
  20. package/lib/components/ConditionBuilder/FieldCondition.types.js +0 -2
  21. package/lib/components/ConditionBuilder/FieldCondition.types.js.map +0 -1
  22. package/lib/components/ConditionBuilder/HelpButton.d.ts +0 -10
  23. package/lib/components/ConditionBuilder/HelpButton.d.ts.map +0 -1
  24. package/lib/components/ConditionBuilder/HelpButton.js +0 -11
  25. package/lib/components/ConditionBuilder/HelpButton.js.map +0 -1
  26. package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts +0 -18
  27. package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts.map +0 -1
  28. package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js +0 -115
  29. package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js.map +0 -1
  30. package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts +0 -19
  31. package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts.map +0 -1
  32. package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js +0 -67
  33. package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js.map +0 -1
  34. package/lib/components/ConditionBuilder/RhsControls/MultiValueSelector.d.ts +0 -16
  35. package/lib/components/ConditionBuilder/RhsControls/MultiValueSelector.d.ts.map +0 -1
  36. package/lib/components/ConditionBuilder/RhsControls/MultiValueSelector.js +0 -43
  37. package/lib/components/ConditionBuilder/RhsControls/MultiValueSelector.js.map +0 -1
  38. package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts +0 -18
  39. package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts.map +0 -1
  40. package/lib/components/ConditionBuilder/RhsControls/NumericInput.js +0 -19
  41. package/lib/components/ConditionBuilder/RhsControls/NumericInput.js.map +0 -1
  42. package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts +0 -18
  43. package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts.map +0 -1
  44. package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js +0 -109
  45. package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js.map +0 -1
  46. package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts +0 -24
  47. package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts.map +0 -1
  48. package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js +0 -122
  49. package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js.map +0 -1
  50. package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts +0 -8
  51. package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts.map +0 -1
  52. package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js +0 -89
  53. package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js.map +0 -1
  54. package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts +0 -20
  55. package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts.map +0 -1
  56. package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js +0 -11
  57. package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js.map +0 -1
  58. package/lib/components/ConditionBuilder/RhsControls/index.d.ts +0 -39
  59. package/lib/components/ConditionBuilder/RhsControls/index.d.ts.map +0 -1
  60. package/lib/components/ConditionBuilder/RhsControls/index.js +0 -219
  61. package/lib/components/ConditionBuilder/RhsControls/index.js.map +0 -1
  62. package/lib/components/ConditionBuilder/core/comparators.d.ts +0 -12
  63. package/lib/components/ConditionBuilder/core/comparators.d.ts.map +0 -1
  64. package/lib/components/ConditionBuilder/core/comparators.js +0 -74
  65. package/lib/components/ConditionBuilder/core/comparators.js.map +0 -1
  66. package/lib/components/ConditionBuilder/core/evaluator.d.ts +0 -14
  67. package/lib/components/ConditionBuilder/core/evaluator.d.ts.map +0 -1
  68. package/lib/components/ConditionBuilder/core/evaluator.js +0 -257
  69. package/lib/components/ConditionBuilder/core/evaluator.js.map +0 -1
  70. package/lib/components/ConditionBuilder/core/extendDayJs.d.ts +0 -2
  71. package/lib/components/ConditionBuilder/core/extendDayJs.d.ts.map +0 -1
  72. package/lib/components/ConditionBuilder/core/extendDayJs.js +0 -4
  73. package/lib/components/ConditionBuilder/core/extendDayJs.js.map +0 -1
  74. package/lib/components/ConditionBuilder/core/formatter.d.ts +0 -16
  75. package/lib/components/ConditionBuilder/core/formatter.d.ts.map +0 -1
  76. package/lib/components/ConditionBuilder/core/formatter.js +0 -190
  77. package/lib/components/ConditionBuilder/core/formatter.js.map +0 -1
  78. package/lib/components/ConditionBuilder/core/rows-reducer.d.ts +0 -27
  79. package/lib/components/ConditionBuilder/core/rows-reducer.d.ts.map +0 -1
  80. package/lib/components/ConditionBuilder/core/rows-reducer.js +0 -50
  81. package/lib/components/ConditionBuilder/core/rows-reducer.js.map +0 -1
  82. package/lib/components/ConditionBuilder/core/time-utils.d.ts +0 -5
  83. package/lib/components/ConditionBuilder/core/time-utils.d.ts.map +0 -1
  84. package/lib/components/ConditionBuilder/core/time-utils.js +0 -23
  85. package/lib/components/ConditionBuilder/core/time-utils.js.map +0 -1
  86. package/lib/components/ConditionBuilder/core/transformer.d.ts +0 -7
  87. package/lib/components/ConditionBuilder/core/transformer.d.ts.map +0 -1
  88. package/lib/components/ConditionBuilder/core/transformer.js +0 -154
  89. package/lib/components/ConditionBuilder/core/transformer.js.map +0 -1
  90. package/lib/components/ConditionBuilder/core/types.d.ts +0 -47
  91. package/lib/components/ConditionBuilder/core/types.d.ts.map +0 -1
  92. package/lib/components/ConditionBuilder/core/types.js +0 -2
  93. package/lib/components/ConditionBuilder/core/types.js.map +0 -1
  94. package/lib/components/ConditionBuilder/core/utils.d.ts +0 -37
  95. package/lib/components/ConditionBuilder/core/utils.d.ts.map +0 -1
  96. package/lib/components/ConditionBuilder/core/utils.js +0 -439
  97. package/lib/components/ConditionBuilder/core/utils.js.map +0 -1
  98. package/lib/components/ConditionBuilder/index.d.ts +0 -11
  99. package/lib/components/ConditionBuilder/index.d.ts.map +0 -1
  100. package/lib/components/ConditionBuilder/index.js +0 -8
  101. package/lib/components/ConditionBuilder/index.js.map +0 -1
  102. package/lib/index.d.ts +0 -3
  103. package/lib/index.d.ts.map +0 -1
  104. package/lib/index.js +0 -4
  105. package/lib/index.js.map +0 -1
@@ -1,112 +0,0 @@
1
- import type { BaseProps, NoChildrenProp } from '@pega/cosmos-react-core';
2
- import { FieldType, Comparator, ComparatorsByType, DateFunction, RHSType, TimePeriod, DatePart } from './core/types';
3
- /** RHS object with a Date function */
4
- export interface RhsWithDateFunction {
5
- /**
6
- * Output format for the value varies based on the dateFunction:
7
- * YEARS: First day of year as YYYY-MM-DD
8
- * QUARTERS: First day of quarter as YYYY-MM-DD
9
- * MONTHS: First day of month as YYYY-MM-DD
10
- * WEEKS: First day of week as YYYY-MM-DD
11
- * DAYS: Date as YYYY-MM-DD
12
- * HOURS: YYYY-MM-DDTHH:mm:ss
13
- * MONTHS_OF_YEAR: 1-12
14
- * DAYS_OF_MONTH: 1-31
15
- * DAYS_OF_WEEK: 1-7
16
- */
17
- value: string | number;
18
- dateFunction: DateFunction;
19
- }
20
- /** RHS object with a Relative Date */
21
- export interface RhsWithRelativeDate {
22
- relativeDate: {
23
- timePeriod: TimePeriod;
24
- interval?: number;
25
- datePart: DatePart;
26
- };
27
- }
28
- /** Type definition for the leaf-level nodes in nested conditions */
29
- export interface LeafCondition {
30
- comparator: Comparator;
31
- lhs: {
32
- field: string;
33
- };
34
- rhs?: {
35
- field: string;
36
- } | {
37
- value: string | number;
38
- } | {
39
- values: string[] | number[];
40
- } | RhsWithDateFunction | RhsWithRelativeDate;
41
- }
42
- /** Type definition for objects representing condition-rows in the builder UI */
43
- export interface ConditionRow extends LeafCondition {
44
- id: string;
45
- label: string;
46
- }
47
- /**
48
- * Type definition for simple/complex conditions
49
- * At a given node in the condition tree, it can have exactly one of the keys AND/OR/NOT/condition
50
- */
51
- export declare type Condition = {
52
- AND: Condition[];
53
- } | {
54
- OR: Condition[];
55
- } | {
56
- NOT: Condition;
57
- } | {
58
- condition: LeafCondition;
59
- };
60
- /** Type definition for the input Field objects for the ConditionBuilder */
61
- export interface Field {
62
- /** Name of the Field. Saved as part of the output condition */
63
- name: string;
64
- /** (Optional) Display label for the Field. If none passed, the `name` itself will be used */
65
- label?: string;
66
- /**
67
- * Data-type for the field.
68
- * Has to be one of these values. Convert where necessary
69
- * e.g. Integer/Decimal/... should be used as `NUMBER`
70
- * e.g. Text(single value)/Picklist/... should be used as `TEXT`
71
- */
72
- type: FieldType;
73
- /** (Optional) Used to add the field to a group during field-selection */
74
- groupLabel?: string;
75
- /**
76
- * For TEXT fields, if a list of possible values is known ahead of time, they can be passed.
77
- * This enables users to select from those values instead of manually typing them
78
- */
79
- possibleValues?: string[];
80
- }
81
- /** Valid date functions by field type */
82
- export interface DateFunctionsByType {
83
- /** Date functions to enable for DATE_TIME fields */
84
- DATE_TIME: DateFunction[];
85
- /** Date functions to enable for DATE_ONLY fields */
86
- DATE_ONLY: DateFunction[];
87
- }
88
- /** Type definition for the input props of ConditionBuilder */
89
- export default interface ConditionBuilderProps extends BaseProps, NoChildrenProp {
90
- /** Metadata (data-model) for the Fields to use in the builder */
91
- fields: Field[];
92
- /**
93
- * Callback used from the builder's `Submit` button
94
- * Called with undefined when an empty condition is submitted (useful for clearing a previous condition)
95
- */
96
- onConditionSubmit: (condition: Condition | undefined) => void;
97
- /** (Optional) A seed condition for the builder. To use when editing an existing condition */
98
- condition?: Condition;
99
- /** (Optional) Used to limit the Comparators allowed in the builder. */
100
- validComparators?: ComparatorsByType[];
101
- /**
102
- * (Optional) Pass this to control which all types of RHS are enabled in the component
103
- * DEFAULT: Set(['LITERAL', 'FIELD'])
104
- * NOTE: If enabling `DATE_FUNCTION`s, additionally pass a `dateFunctions` prop to specify which functions are enabled
105
- */
106
- validRhsTypes?: Set<RHSType>;
107
- /** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */
108
- dateFunctions?: DateFunctionsByType;
109
- /** (Optional) Pass this if the `NOT` operator should be considered as invalid */
110
- disallowNOT?: boolean;
111
- }
112
- //# sourceMappingURL=ConditionBuilder.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConditionBuilder.types.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAA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A6F;IAC7F,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,IAAI,EAAE,SAAS,CAAC;IAEhB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,yCAAyC;AACzC,MAAM,WAAW,mBAAmB;IAClC,oDAAoD;IACpD,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,oDAAoD;IACpD,SAAS,EAAE,YAAY,EAAE,CAAC;CAC3B;AAED,8DAA8D;AAC9D,MAAM,CAAC,OAAO,WAAW,qBAAsB,SAAQ,SAAS,EAAE,cAAc;IAC9E,iEAAiE;IACjE,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB;;;OAGG;IACH,iBAAiB,EAAE,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;IAE9D,6FAA6F;IAC7F,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEvC;;;;OAIG;IACH,aAAa,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAE7B,iJAAiJ;IACjJ,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAEpC,iFAAiF;IACjF,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ConditionBuilder.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConditionBuilder.types.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"","sourcesContent":["// cspell:ignore words DDTHH\nimport type { BaseProps, NoChildrenProp } from '@pega/cosmos-react-core';\n\nimport {\n FieldType,\n Comparator,\n ComparatorsByType,\n DateFunction,\n RHSType,\n TimePeriod,\n DatePart\n} from './core/types';\n\n/** RHS object with a Date function */\nexport interface RhsWithDateFunction {\n /**\n * Output format for the value varies based on the dateFunction:\n * YEARS: First day of year as YYYY-MM-DD\n * QUARTERS: First day of quarter as YYYY-MM-DD\n * MONTHS: First day of month as YYYY-MM-DD\n * WEEKS: First day of week as YYYY-MM-DD\n * DAYS: Date as YYYY-MM-DD\n * HOURS: YYYY-MM-DDTHH:mm:ss\n * MONTHS_OF_YEAR: 1-12\n * DAYS_OF_MONTH: 1-31\n * DAYS_OF_WEEK: 1-7\n */\n value: string | number;\n dateFunction: DateFunction;\n}\n\n/** RHS object with a Relative Date */\nexport interface RhsWithRelativeDate {\n relativeDate: {\n timePeriod: TimePeriod;\n interval?: number;\n datePart: DatePart;\n };\n}\n\n/** Type definition for the leaf-level nodes in nested conditions */\nexport interface LeafCondition {\n comparator: Comparator;\n\n lhs: {\n field: string;\n };\n\n // Optional for some of the comparators like IS_TRUE, IS_NULL, etc.\n rhs?:\n | { field: string } // When comparing the LHS with another field\n | { value: string | number } // When comparing the LHS with a single literal value (for comparators like EQ, GTE etc.)\n | { values: string[] | number[] } // When comparing the LHS with a list of literal values (for comparators like IN, NOT_IN etc.)\n | RhsWithDateFunction // When comparing a date field with a date function on RHS\n | RhsWithRelativeDate; // When comparing a date field with a symbolic date on RHS\n}\n\n/** Type definition for objects representing condition-rows in the builder UI */\nexport interface ConditionRow extends LeafCondition {\n id: string; // To use as `key` prop when rendering a list of rows\n label: string; // Used to refer the row from a logic-string\n}\n\n/**\n * Type definition for simple/complex conditions\n * At a given node in the condition tree, it can have exactly one of the keys AND/OR/NOT/condition\n */\nexport type Condition =\n | { AND: Condition[] }\n | { OR: Condition[] }\n | { NOT: Condition }\n | { condition: LeafCondition };\n\n/** Type definition for the input Field objects for the ConditionBuilder */\nexport interface Field {\n /** Name of the Field. Saved as part of the output condition */\n name: string;\n\n /** (Optional) Display label for the Field. If none passed, the `name` itself will be used */\n label?: string;\n\n /**\n * Data-type for the field.\n * Has to be one of these values. Convert where necessary\n * e.g. Integer/Decimal/... should be used as `NUMBER`\n * e.g. Text(single value)/Picklist/... should be used as `TEXT`\n */\n type: FieldType;\n\n /** (Optional) Used to add the field to a group during field-selection */\n groupLabel?: string;\n\n /**\n * For TEXT fields, if a list of possible values is known ahead of time, they can be passed.\n * This enables users to select from those values instead of manually typing them\n */\n possibleValues?: string[];\n}\n\n/** Valid date functions by field type */\nexport interface DateFunctionsByType {\n /** Date functions to enable for DATE_TIME fields */\n DATE_TIME: DateFunction[];\n /** Date functions to enable for DATE_ONLY fields */\n DATE_ONLY: DateFunction[];\n}\n\n/** Type definition for the input props of ConditionBuilder */\nexport default interface ConditionBuilderProps extends BaseProps, NoChildrenProp {\n /** Metadata (data-model) for the Fields to use in the builder */\n fields: Field[];\n\n /**\n * Callback used from the builder's `Submit` button\n * Called with undefined when an empty condition is submitted (useful for clearing a previous condition)\n */\n onConditionSubmit: (condition: Condition | undefined) => void;\n\n /** (Optional) A seed condition for the builder. To use when editing an existing condition */\n condition?: Condition;\n\n /** (Optional) Used to limit the Comparators allowed in the builder. */\n validComparators?: ComparatorsByType[];\n\n /**\n * (Optional) Pass this to control which all types of RHS are enabled in the component\n * DEFAULT: Set(['LITERAL', 'FIELD'])\n * NOTE: If enabling `DATE_FUNCTION`s, additionally pass a `dateFunctions` prop to specify which functions are enabled\n */\n validRhsTypes?: Set<RHSType>;\n\n /** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */\n dateFunctions?: DateFunctionsByType;\n\n /** (Optional) Pass this if the `NOT` operator should be considered as invalid */\n disallowNOT?: boolean;\n}\n"]}
@@ -1,7 +0,0 @@
1
- import { FunctionComponent } from 'react';
2
- import { ForwardProps } from '@pega/cosmos-react-core';
3
- import FieldConditionProps from './FieldCondition.types';
4
- /** Component for building an atomic condition on a given field */
5
- declare const FieldCondition: FunctionComponent<FieldConditionProps & ForwardProps>;
6
- export default FieldCondition;
7
- //# sourceMappingURL=FieldCondition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FieldCondition.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAyB,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AAIzD,kEAAkE;AAClE,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CA2DzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,26 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
- import { Flex, Button, useI18n } from '@pega/cosmos-react-core';
4
- import AtomicCondition, { getInitConditionForLhs, isValidCondition } from './AtomicCondition';
5
- /** Component for building an atomic condition on a given field */
6
- const FieldCondition = (props) => {
7
- const { targetField, fields, onSubmit, condition: seedCondition, validComparators, validRhsTypes = new Set(['LITERAL', 'FIELD']), dateFunctions } = props;
8
- const [condition, setCondition] = useState(
9
- // If editing use the seedCondition, otherwise, determine an initial condition based on the targetField
10
- () => seedCondition ||
11
- getInitConditionForLhs({ field: targetField }, fields, validRhsTypes, validComparators, dateFunctions));
12
- const [showErrorIndicators, setErrorIndicators] = useState(false); // Used to enable inline error indicators on the controls
13
- const t = useI18n();
14
- const handleSubmission = () => {
15
- setErrorIndicators(false); // Reset any previous flag
16
- if (isValidCondition(condition, fields, true)) {
17
- onSubmit(condition); // If it's a valid condition, submit it
18
- }
19
- else {
20
- setErrorIndicators(true); // Otherwise, indicate errors
21
- }
22
- };
23
- return (_jsxs(Flex, { container: { direction: 'column', gap: 2 }, children: [_jsx(AtomicCondition, { condition: condition, fields: fields, indicateErrors: showErrorIndicators, validComparators: validComparators, dateFunctions: dateFunctions, onChange: c => setCondition(c), itemDirection: 'column', validRhsTypes: validRhsTypes, showLhsAsLabel: true }, void 0), _jsx(Flex, { container: { justify: 'end' }, children: _jsx(Button, { name: 'field-condition-submit', variant: 'primary', onClick: handleSubmission, children: t('condition_builder_submit_button_label') }, void 0) }, void 0)] }, void 0));
24
- };
25
- export default FieldCondition;
26
- //# sourceMappingURL=FieldCondition.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FieldCondition.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAgB,MAAM,yBAAyB,CAAC;AAG9E,OAAO,eAAe,EAAE,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG9F,kEAAkE;AAClE,MAAM,cAAc,GAA0D,CAC5E,KAA0B,EAC1B,EAAE;IACF,MAAM,EACJ,WAAW,EACX,MAAM,EACN,QAAQ,EACR,SAAS,EAAE,aAAa,EACxB,gBAAgB,EAChB,aAAa,GAAG,IAAI,GAAG,CAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,EACtD,aAAa,EACd,GAAG,KAAK,CAAC;IACV,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ;IACxC,uGAAuG;IACvG,GAAG,EAAE,CACH,aAAa;QACb,sBAAsB,CACpB,EAAE,KAAK,EAAE,WAAW,EAAE,EACtB,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,aAAa,CACd,CACJ,CAAC;IACF,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,yDAAyD;IAC5H,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,MAAM,gBAAgB,GAAG,GAAG,EAAE;QAC5B,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,0BAA0B;QAErD,IAAI,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;YAC7C,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,uCAAuC;SAC7D;aAAM;YACL,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,6BAA6B;SACxD;IACH,CAAC,CAAC;IAEF,OAAO,CACL,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aAC9C,KAAC,eAAe,IACd,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,mBAAmB,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,EAC9B,aAAa,EAAC,QAAQ,EACtB,aAAa,EAAE,aAAa,EAC5B,cAAc,iBACd,EAGF,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,YACjC,KAAC,MAAM,IAAC,IAAI,EAAC,wBAAwB,EAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAE,gBAAgB,YAC9E,CAAC,CAAC,uCAAuC,CAAC,WACpC,WACJ,YACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FunctionComponent, useState } from 'react';\n\nimport { Flex, Button, useI18n, ForwardProps } from '@pega/cosmos-react-core';\n\nimport FieldConditionProps from './FieldCondition.types';\nimport AtomicCondition, { getInitConditionForLhs, isValidCondition } from './AtomicCondition';\nimport { RHSType } from './core/types';\n\n/** Component for building an atomic condition on a given field */\nconst FieldCondition: FunctionComponent<FieldConditionProps & ForwardProps> = (\n props: FieldConditionProps\n) => {\n const {\n targetField,\n fields,\n onSubmit,\n condition: seedCondition,\n validComparators,\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions\n } = props;\n const [condition, setCondition] = useState(\n // If editing use the seedCondition, otherwise, determine an initial condition based on the targetField\n () =>\n seedCondition ||\n getInitConditionForLhs(\n { field: targetField },\n fields,\n validRhsTypes,\n validComparators,\n dateFunctions\n )\n );\n const [showErrorIndicators, setErrorIndicators] = useState(false); // Used to enable inline error indicators on the controls\n const t = useI18n();\n\n const handleSubmission = () => {\n setErrorIndicators(false); // Reset any previous flag\n\n if (isValidCondition(condition, fields, true)) {\n onSubmit(condition); // If it's a valid condition, submit it\n } else {\n setErrorIndicators(true); // Otherwise, indicate errors\n }\n };\n\n return (\n <Flex container={{ direction: 'column', gap: 2 }}>\n <AtomicCondition\n condition={condition}\n fields={fields}\n indicateErrors={showErrorIndicators}\n validComparators={validComparators}\n dateFunctions={dateFunctions}\n onChange={c => setCondition(c)}\n itemDirection='column'\n validRhsTypes={validRhsTypes}\n showLhsAsLabel\n />\n\n {/* Submit block */}\n <Flex container={{ justify: 'end' }}>\n <Button name='field-condition-submit' variant='primary' onClick={handleSubmission}>\n {t('condition_builder_submit_button_label')}\n </Button>\n </Flex>\n </Flex>\n );\n};\n\nexport default FieldCondition;\n"]}
@@ -1,25 +0,0 @@
1
- import { BaseProps } from '@pega/cosmos-react-core';
2
- import { ComparatorsByType, RHSType } from './core/types';
3
- import { Field, LeafCondition, DateFunctionsByType } from './ConditionBuilder.types';
4
- /** Type definition for the input props of FieldCondition */
5
- export default interface FieldConditionProps extends BaseProps {
6
- /** Name of the field on which the condition should be constructed */
7
- targetField: Field['name'];
8
- /** Metadata (data-model) for the Fields to use in the RHS field-selector etc. */
9
- fields: Field[];
10
- /** Callback used from the component's `Submit` button */
11
- onSubmit: (condition: LeafCondition) => void;
12
- /** (Optional) Passed when editing an existing condition */
13
- condition?: LeafCondition;
14
- /** (Optional) Used to limit the Comparators allowed in the component. */
15
- validComparators?: ComparatorsByType[];
16
- /**
17
- * (Optional) Pass this to control which all types of RHS are enabled in the component
18
- * DEFAULT: Set(['LITERAL', 'FIELD'])
19
- * NOTE: If enabling `DATE_FUNCTION`s, additionally pass a `dateFunctions` prop to specify which functions are enabled
20
- */
21
- validRhsTypes?: Set<RHSType>;
22
- /** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */
23
- dateFunctions?: DateFunctionsByType;
24
- }
25
- //# sourceMappingURL=FieldCondition.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FieldCondition.types.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAErF,4DAA4D;AAC5D,MAAM,CAAC,OAAO,WAAW,mBAAoB,SAAQ,SAAS;IAC5D,qEAAqE;IACrE,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE3B,iFAAiF;IACjF,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,yDAAyD;IACzD,QAAQ,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IAE7C,2DAA2D;IAC3D,SAAS,CAAC,EAAE,aAAa,CAAC;IAE1B,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEvC;;;;OAIG;IACH,aAAa,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAE7B,iJAAiJ;IACjJ,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACrC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=FieldCondition.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FieldCondition.types.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.types.ts"],"names":[],"mappings":"","sourcesContent":["import { BaseProps } from '@pega/cosmos-react-core';\n\nimport { ComparatorsByType, RHSType } from './core/types';\nimport { Field, LeafCondition, DateFunctionsByType } from './ConditionBuilder.types';\n\n/** Type definition for the input props of FieldCondition */\nexport default interface FieldConditionProps extends BaseProps {\n /** Name of the field on which the condition should be constructed */\n targetField: Field['name'];\n\n /** Metadata (data-model) for the Fields to use in the RHS field-selector etc. */\n fields: Field[];\n\n /** Callback used from the component's `Submit` button */\n onSubmit: (condition: LeafCondition) => void;\n\n /** (Optional) Passed when editing an existing condition */\n condition?: LeafCondition;\n\n /** (Optional) Used to limit the Comparators allowed in the component. */\n validComparators?: ComparatorsByType[];\n\n /**\n * (Optional) Pass this to control which all types of RHS are enabled in the component\n * DEFAULT: Set(['LITERAL', 'FIELD'])\n * NOTE: If enabling `DATE_FUNCTION`s, additionally pass a `dateFunctions` prop to specify which functions are enabled\n */\n validRhsTypes?: Set<RHSType>;\n\n /** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */\n dateFunctions?: DateFunctionsByType;\n}\n"]}
@@ -1,10 +0,0 @@
1
- import { FunctionComponent } from 'react';
2
- import { BaseProps, ForwardProps } from '@pega/cosmos-react-core';
3
- interface HelpButtonProps extends BaseProps {
4
- /** Content to show on hover of the button */
5
- children: string;
6
- }
7
- /** Renders an inline Help icon that shows help content on hover */
8
- declare const HelpButton: FunctionComponent<HelpButtonProps & ForwardProps>;
9
- export default HelpButton;
10
- //# sourceMappingURL=HelpButton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HelpButton.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/HelpButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAGL,SAAS,EACT,YAAY,EAGb,MAAM,yBAAyB,CAAC;AAEjC,UAAU,eAAgB,SAAQ,SAAS;IACzC,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,mEAAmE;AACnE,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,GAAG,YAAY,CAejE,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Icon, Tooltip, useElement, useUID } from '@pega/cosmos-react-core';
3
- /** Renders an inline Help icon that shows help content on hover */
4
- const HelpButton = (props) => {
5
- const { children } = props;
6
- const [iconEl, setIconEl] = useElement();
7
- const id = useUID();
8
- return (_jsxs(_Fragment, { children: [_jsx(Icon, { name: 'information', ref: setIconEl, "aria-describedby": id }, void 0), iconEl && (_jsx(Tooltip, { target: iconEl, id: id, children: children }, void 0))] }, void 0));
9
- };
10
- export default HelpButton;
11
- //# sourceMappingURL=HelpButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HelpButton.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/HelpButton.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,IAAI,EACJ,OAAO,EAGP,UAAU,EACV,MAAM,EACP,MAAM,yBAAyB,CAAC;AAOjC,mEAAmE;AACnE,MAAM,UAAU,GAAsD,CAAC,KAAsB,EAAE,EAAE;IAC/F,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,UAAU,EAAE,CAAC;IACzC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAEpB,OAAO,CACL,8BACE,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,EAAC,GAAG,EAAE,SAAS,sBAAoB,EAAE,WAAI,EAChE,MAAM,IAAI,CACT,KAAC,OAAO,IAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,YAC5B,QAAQ,WACD,CACX,YACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FunctionComponent } from 'react';\n\nimport {\n Icon,\n Tooltip,\n BaseProps,\n ForwardProps,\n useElement,\n useUID\n} from '@pega/cosmos-react-core';\n\ninterface HelpButtonProps extends BaseProps {\n /** Content to show on hover of the button */\n children: string;\n}\n\n/** Renders an inline Help icon that shows help content on hover */\nconst HelpButton: FunctionComponent<HelpButtonProps & ForwardProps> = (props: HelpButtonProps) => {\n const { children } = props;\n const [iconEl, setIconEl] = useElement();\n const id = useUID();\n\n return (\n <>\n <Icon name='information' ref={setIconEl} aria-describedby={id} />\n {iconEl && (\n <Tooltip target={iconEl} id={id}>\n {children}\n </Tooltip>\n )}\n </>\n );\n};\n\nexport default HelpButton;\n"]}
@@ -1,18 +0,0 @@
1
- import { FunctionComponent } from 'react';
2
- import { BaseProps, ForwardProps, NoChildrenProp } from '@pega/cosmos-react-core';
3
- import { RhsWithDateFunction } from '../ConditionBuilder.types';
4
- import { DateFunction } from '../core/types';
5
- export interface DateFunctionMenuProps extends BaseProps, NoChildrenProp {
6
- /** Rhs for the condition */
7
- rhs: RhsWithDateFunction;
8
- /** Callback for any modifications to the Rhs */
9
- onChange: (rhs: RhsWithDateFunction) => void;
10
- /** List of date functions enabled for the current LHS field type */
11
- dateFunctionsList: DateFunction[];
12
- /** Used to indicate any errors on the control */
13
- status?: 'error';
14
- }
15
- /** A menu with controls to select a Time period value on RHS */
16
- declare const DateFunctionMenu: FunctionComponent<DateFunctionMenuProps & ForwardProps>;
17
- export default DateFunctionMenu;
18
- //# sourceMappingURL=DateFunctionMenu.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DateFunctionMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/DateFunctionMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAEhE,OAAO,EACL,SAAS,EACT,YAAY,EAcZ,cAAc,EACf,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA+B7C,MAAM,WAAW,qBAAsB,SAAQ,SAAS,EAAE,cAAc;IACtE,4BAA4B;IAC5B,GAAG,EAAE,mBAAmB,CAAC;IAEzB,gDAAgD;IAChD,QAAQ,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAE7C,oEAAoE;IACpE,iBAAiB,EAAE,YAAY,EAAE,CAAC;IAElC,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,gEAAgE;AAChE,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,GAAG,YAAY,CA+J7E,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,115 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- // cspell:ignore words DDTHH
3
- import { useMemo } from 'react';
4
- import { Select, Option, MonthInput, WeekInput, DateInput, DateTimeInput, NumberInput, DayOfWeekInput, useI18n, useConfiguration, QuarterInput, range } from '@pega/cosmos-react-core';
5
- /**
6
- * Formats the input date string to match the spec expected for the given date function
7
- * NOTE: This assumes that the input date is set up on the UTC timezone
8
- * SPEC:
9
- * - QUARTERS: First day of quarter as YYYY-MM-DD
10
- * - MONTHS: First day of month as YYYY-MM-DD
11
- * - WEEKS: First day of week as YYYY-MM-DD
12
- * - DAYS: Date as YYYY-MM-DD
13
- * - HOURS: YYYY-MM-DDTHH:mm:ss
14
- */
15
- function formatDateFunctionValue(isoDateString, dateFunction) {
16
- const date = new Date(isoDateString);
17
- const YYYY = date.getUTCFullYear().toString().padStart(4, '0');
18
- const MM = (date.getUTCMonth() + 1).toString().padStart(2, '0');
19
- const DD = date.getUTCDate().toString().padStart(2, '0');
20
- const HH = date.getUTCHours().toString().padStart(2, '0');
21
- switch (dateFunction) {
22
- case 'QUARTERS':
23
- case 'MONTHS':
24
- return `${YYYY}-${MM}-01`;
25
- case 'WEEKS':
26
- case 'DAYS':
27
- return `${YYYY}-${MM}-${DD}`;
28
- default:
29
- return `${YYYY}-${MM}-${DD}T${HH}:00:00`; // HOURS
30
- }
31
- }
32
- /** A menu with controls to select a Time period value on RHS */
33
- const DateFunctionMenu = (props) => {
34
- const { rhs, onChange, dateFunctionsList, status } = props;
35
- const { locale } = useConfiguration();
36
- const t = useI18n();
37
- // Options for the Date-function selector
38
- const dateFunctionOptions = useMemo(() => {
39
- const dateFunctionLabels = {
40
- YEARS: t('condition_builder_date_function_year'),
41
- QUARTERS: t('condition_builder_date_function_quarter'),
42
- MONTHS: t('condition_builder_date_function_month'),
43
- WEEKS: t('condition_builder_date_function_week'),
44
- DAYS: t('condition_builder_date_function_day'),
45
- HOURS: t('condition_builder_date_function_hour'),
46
- MONTHS_OF_YEAR: t('condition_builder_date_function_month_of_year'),
47
- DAYS_OF_MONTH: t('condition_builder_date_function_day_of_month'),
48
- DAYS_OF_WEEK: t('condition_builder_date_function_day_of_week')
49
- };
50
- return dateFunctionsList.map(func => ({ id: func, label: dateFunctionLabels[func] }));
51
- }, [dateFunctionsList, t]);
52
- // Handle changes to the Date-function selector
53
- const handleDatePartChange = (e) => {
54
- const selection = e.target.value;
55
- onChange({ dateFunction: selection, value: '' });
56
- };
57
- // Common props for all value controls
58
- const valueComponentProps = {
59
- value: rhs.value === '' ? undefined : rhs.value.toString(),
60
- label: t('condition_builder_value_label'),
61
- status,
62
- info: status ? t('condition_builder_invalid_value') : undefined
63
- };
64
- // Props for all functions that use a component from the DateTime package
65
- const dateComponentProps = {
66
- ...valueComponentProps,
67
- onChange: ({ valueAsISOString, valueAsTimestamp, state }) => {
68
- // NOTE: Not relying fully on `state` since in some cases state and valueAsTimestamp are both undefined
69
- if (valueAsTimestamp === undefined || state === 'incomplete' || state === 'invalid')
70
- return;
71
- // Format the value as per spec and return
72
- onChange({ ...rhs, value: formatDateFunctionValue(valueAsISOString, rhs.dateFunction) });
73
- }
74
- };
75
- // YEARS
76
- const yearOptions = useMemo(() => {
77
- const currentYear = new Date().getFullYear();
78
- const years = range(currentYear - 10, currentYear + 10);
79
- return years.map(year => ({
80
- id: `${year}-01-01`,
81
- label: new Date(year, 0, 1).toLocaleString(locale, { year: 'numeric' })
82
- }));
83
- }, [locale]);
84
- const onYearChange = (e) => {
85
- onChange({ ...rhs, value: e.target.value });
86
- };
87
- // MONTHS_OF_YEAR
88
- const monthOfYearOptions = useMemo(() => range(1, 12).map(n => ({
89
- id: `${n}`,
90
- label: new Date(2021, n - 1, 1).toLocaleString(locale, { month: 'long' })
91
- })), [locale]);
92
- const onMonthOfYearChange = (e) => {
93
- const value = e.target.value ? Number(e.target.value) : '';
94
- onChange({ ...rhs, value });
95
- };
96
- // DAYS_OF_MONTH
97
- const onDayOfMonthChange = (value) => {
98
- let newValue = value;
99
- if (newValue !== '') {
100
- newValue = Number(newValue);
101
- if (newValue > 31)
102
- newValue = 31;
103
- if (newValue < 1)
104
- newValue = 1;
105
- }
106
- onChange({ ...rhs, value: newValue });
107
- };
108
- // DAYS_OF_WEEK
109
- const onDayOfWeekChange = (value) => {
110
- onChange({ ...rhs, value });
111
- };
112
- return (_jsxs(_Fragment, { children: [_jsx(Select, { label: t('condition_builder_date_part'), value: rhs.dateFunction, onChange: handleDatePartChange, children: dateFunctionOptions.map(o => (_jsx(Option, { value: o.id, children: o.label }, o.id))) }, void 0), rhs.dateFunction === 'YEARS' && (_jsxs(Select, { ...valueComponentProps, onChange: onYearChange, name: 'year-selector', children: [_jsx(Option, { children: " " }, void 0), yearOptions.map(o => (_jsx(Option, { value: o.id, children: o.label }, o.id)))] }, void 0)), rhs.dateFunction === 'QUARTERS' && _jsx(QuarterInput, { ...dateComponentProps }, void 0), rhs.dateFunction === 'MONTHS' && _jsx(MonthInput, { ...dateComponentProps }, void 0), rhs.dateFunction === 'WEEKS' && _jsx(WeekInput, { ...dateComponentProps }, void 0), rhs.dateFunction === 'DAYS' && _jsx(DateInput, { ...dateComponentProps }, void 0), rhs.dateFunction === 'HOURS' && (_jsx(DateTimeInput, { ...dateComponentProps, pickerInterval: 60 }, void 0)), rhs.dateFunction === 'MONTHS_OF_YEAR' && (_jsxs(Select, { ...valueComponentProps, onChange: onMonthOfYearChange, name: 'month-of-year-selector', children: [_jsx(Option, { children: " " }, void 0), monthOfYearOptions.map(o => (_jsx(Option, { value: o.id, children: o.label }, o.id)))] }, void 0)), rhs.dateFunction === 'DAYS_OF_MONTH' && (_jsx(NumberInput, { ...valueComponentProps, placeholder: '1 - 31', min: 1, max: 31, step: 1, showDecimal: false, onChange: onDayOfMonthChange }, void 0)), rhs.dateFunction === 'DAYS_OF_WEEK' && (_jsx(DayOfWeekInput, { ...valueComponentProps, value: rhs.value, onChange: onDayOfWeekChange }, void 0))] }, void 0));
113
- };
114
- export default DateFunctionMenu;
115
- //# sourceMappingURL=DateFunctionMenu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DateFunctionMenu.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/DateFunctionMenu.tsx"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,OAAO,EAAkC,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAGL,MAAM,EACN,MAAM,EACN,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EAEX,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,KAAK,EAEN,MAAM,yBAAyB,CAAC;AASjC;;;;;;;;;GASG;AACH,SAAS,uBAAuB,CAAC,aAAqB,EAAE,YAA0B;IAChF,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC/D,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,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A,GAAG,CAAC,YAAY,KAAK,cAAc,IAAI,CACtC,KAAC,cAAc,OACT,mBAAmB,EACvB,KAAK,EAAE,GAAG,CAAC,KAAkB,EAC7B,QAAQ,EAAE,iBAAiB,WAC3B,CACH,YACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["// cspell:ignore words DDTHH\nimport { ChangeEvent, FunctionComponent, useMemo } from 'react';\n\nimport {\n BaseProps,\n ForwardProps,\n Select,\n Option,\n MonthInput,\n WeekInput,\n DateInput,\n DateTimeInput,\n NumberInput,\n FormControlProps,\n DayOfWeekInput,\n useI18n,\n useConfiguration,\n QuarterInput,\n range,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\nimport DateTimeProps, {\n DateTimeCallbackParameter\n} from '@pega/cosmos-react-core/lib/components/DateTime/DateTime.types';\nimport { DayOfWeek } from '@pega/cosmos-react-core/lib/components/DateTime/Input/DayOfWeekInput';\n\nimport { RhsWithDateFunction } from '../ConditionBuilder.types';\nimport { DateFunction } from '../core/types';\n\n/**\n * Formats the input date string to match the spec expected for the given date function\n * NOTE: This assumes that the input date is set up on the UTC timezone\n * SPEC:\n * - QUARTERS: First day of quarter as YYYY-MM-DD\n * - MONTHS: First day of month as YYYY-MM-DD\n * - WEEKS: First day of week as YYYY-MM-DD\n * - DAYS: Date as YYYY-MM-DD\n * - HOURS: YYYY-MM-DDTHH:mm:ss\n */\nfunction formatDateFunctionValue(isoDateString: string, dateFunction: DateFunction): string {\n const date = new Date(isoDateString);\n const YYYY = date.getUTCFullYear().toString().padStart(4, '0');\n const MM = (date.getUTCMonth() + 1).toString().padStart(2, '0');\n const DD = date.getUTCDate().toString().padStart(2, '0');\n const HH = date.getUTCHours().toString().padStart(2, '0');\n\n switch (dateFunction) {\n case 'QUARTERS':\n case 'MONTHS':\n return `${YYYY}-${MM}-01`;\n case 'WEEKS':\n case 'DAYS':\n return `${YYYY}-${MM}-${DD}`;\n default:\n return `${YYYY}-${MM}-${DD}T${HH}:00:00`; // HOURS\n }\n}\n\nexport interface DateFunctionMenuProps extends BaseProps, NoChildrenProp {\n /** Rhs for the condition */\n rhs: RhsWithDateFunction;\n\n /** Callback for any modifications to the Rhs */\n onChange: (rhs: RhsWithDateFunction) => void;\n\n /** List of date functions enabled for the current LHS field type */\n dateFunctionsList: DateFunction[];\n\n /** Used to indicate any errors on the control */\n status?: 'error';\n}\n\n/** A menu with controls to select a Time period value on RHS */\nconst DateFunctionMenu: FunctionComponent<DateFunctionMenuProps & ForwardProps> = (\n props: DateFunctionMenuProps\n) => {\n const { rhs, onChange, dateFunctionsList, status } = props;\n const { locale } = useConfiguration();\n const t = useI18n();\n\n // Options for the Date-function selector\n const dateFunctionOptions = useMemo(() => {\n const dateFunctionLabels: Record<DateFunction, string> = {\n YEARS: t('condition_builder_date_function_year'),\n QUARTERS: t('condition_builder_date_function_quarter'),\n MONTHS: t('condition_builder_date_function_month'),\n WEEKS: t('condition_builder_date_function_week'),\n DAYS: t('condition_builder_date_function_day'),\n HOURS: t('condition_builder_date_function_hour'),\n MONTHS_OF_YEAR: t('condition_builder_date_function_month_of_year'),\n DAYS_OF_MONTH: t('condition_builder_date_function_day_of_month'),\n DAYS_OF_WEEK: t('condition_builder_date_function_day_of_week')\n };\n\n return dateFunctionsList.map(func => ({ id: func, label: dateFunctionLabels[func] }));\n }, [dateFunctionsList, t]);\n\n // Handle changes to the Date-function selector\n const handleDatePartChange = (e: ChangeEvent<HTMLSelectElement>) => {\n const selection = e.target.value as DateFunction;\n onChange({ dateFunction: selection, value: '' });\n };\n\n // Common props for all value controls\n const valueComponentProps: FormControlProps = {\n value: rhs.value === '' ? undefined : rhs.value.toString(),\n label: t('condition_builder_value_label'),\n status,\n info: status ? t('condition_builder_invalid_value') : undefined\n };\n\n // Props for all functions that use a component from the DateTime package\n const dateComponentProps: DateTimeProps = {\n ...valueComponentProps,\n onChange: ({ valueAsISOString, valueAsTimestamp, state }: DateTimeCallbackParameter) => {\n // NOTE: Not relying fully on `state` since in some cases state and valueAsTimestamp are both undefined\n if (valueAsTimestamp === undefined || state === 'incomplete' || state === 'invalid') return;\n\n // Format the value as per spec and return\n onChange({ ...rhs, value: formatDateFunctionValue(valueAsISOString, rhs.dateFunction) });\n }\n };\n\n // YEARS\n const yearOptions = useMemo(() => {\n const currentYear = new Date().getFullYear();\n const years = range(currentYear - 10, currentYear + 10);\n return years.map(year => ({\n id: `${year}-01-01`,\n label: new Date(year, 0, 1).toLocaleString(locale, { year: 'numeric' })\n }));\n }, [locale]);\n const onYearChange = (e: ChangeEvent<HTMLSelectElement>) => {\n onChange({ ...rhs, value: e.target.value });\n };\n\n // MONTHS_OF_YEAR\n const monthOfYearOptions = useMemo(\n () =>\n range(1, 12).map(n => ({\n id: `${n}`,\n label: new Date(2021, n - 1, 1).toLocaleString(locale, { month: 'long' })\n })),\n [locale]\n );\n const onMonthOfYearChange = (e: ChangeEvent<HTMLSelectElement>) => {\n const value = e.target.value ? Number(e.target.value) : '';\n onChange({ ...rhs, value });\n };\n\n // DAYS_OF_MONTH\n const onDayOfMonthChange = (value: string) => {\n let newValue: string | number = value;\n if (newValue !== '') {\n newValue = Number(newValue);\n if (newValue > 31) newValue = 31;\n if (newValue < 1) newValue = 1;\n }\n onChange({ ...rhs, value: newValue });\n };\n\n // DAYS_OF_WEEK\n const onDayOfWeekChange = (value: DayOfWeek) => {\n onChange({ ...rhs, value });\n };\n\n return (\n <>\n {/* Date function selector */}\n <Select\n label={t('condition_builder_date_part')}\n value={rhs.dateFunction}\n onChange={handleDatePartChange}\n >\n {dateFunctionOptions.map(o => (\n <Option key={o.id} value={o.id}>\n {o.label}\n </Option>\n ))}\n </Select>\n\n {rhs.dateFunction === 'YEARS' && (\n <Select {...valueComponentProps} onChange={onYearChange} name='year-selector'>\n <Option> </Option>\n {yearOptions.map(o => (\n <Option key={o.id} value={o.id}>\n {o.label}\n </Option>\n ))}\n </Select>\n )}\n {rhs.dateFunction === 'QUARTERS' && <QuarterInput {...dateComponentProps} />}\n {rhs.dateFunction === 'MONTHS' && <MonthInput {...dateComponentProps} />}\n {rhs.dateFunction === 'WEEKS' && <WeekInput {...dateComponentProps} />}\n {rhs.dateFunction === 'DAYS' && <DateInput {...dateComponentProps} />}\n {rhs.dateFunction === 'HOURS' && (\n <DateTimeInput {...dateComponentProps} pickerInterval={60} />\n )}\n {rhs.dateFunction === 'MONTHS_OF_YEAR' && (\n <Select\n {...valueComponentProps}\n onChange={onMonthOfYearChange}\n name='month-of-year-selector'\n >\n <Option> </Option>\n {monthOfYearOptions.map(o => (\n <Option key={o.id} value={o.id}>\n {o.label}\n </Option>\n ))}\n </Select>\n )}\n {rhs.dateFunction === 'DAYS_OF_MONTH' && (\n <NumberInput\n {...valueComponentProps}\n placeholder='1 - 31'\n min={1}\n max={31}\n step={1}\n showDecimal={false}\n onChange={onDayOfMonthChange}\n />\n )}\n {rhs.dateFunction === 'DAYS_OF_WEEK' && (\n <DayOfWeekInput\n {...valueComponentProps}\n value={rhs.value as DayOfWeek}\n onChange={onDayOfWeekChange}\n />\n )}\n </>\n );\n};\n\nexport default DateFunctionMenu;\n"]}
@@ -1,19 +0,0 @@
1
- import { FunctionComponent } from 'react';
2
- import { BaseProps, ForwardProps, FormControlProps, NoChildrenProp } from '@pega/cosmos-react-core';
3
- import { Field } from '../ConditionBuilder.types';
4
- interface FieldSelectorProps extends BaseProps, NoChildrenProp {
5
- /** Current selection */
6
- value: string;
7
- /** Change handler */
8
- onChange: (selection: string) => void;
9
- /** Metadata (data-model) for the Fields to use in the selector */
10
- fields: Field[];
11
- /** Status for the ComboBox */
12
- status?: FormControlProps['status'];
13
- /** Info for the ComboBox */
14
- info?: FormControlProps['info'];
15
- }
16
- /** Sets up a ComboBox to select a Field. Handles grouping and autocomplete. */
17
- declare const FieldSelector: FunctionComponent<FieldSelectorProps & ForwardProps>;
18
- export default FieldSelector;
19
- //# sourceMappingURL=FieldSelector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FieldSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/FieldSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAAqB,MAAM,OAAO,CAAC;AAE1E,OAAO,EAIL,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AA4BlD,UAAU,kBAAmB,SAAQ,SAAS,EAAE,cAAc;IAC5D,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IAEd,qBAAqB;IACrB,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtC,kEAAkE;IAClE,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAEpC,4BAA4B;IAC5B,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACjC;AAED,+EAA+E;AAC/E,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAwDvE,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,67 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useMemo, useState } from 'react';
3
- import { ComboBox, menuHelpers } from '@pega/cosmos-react-core';
4
- /** Convert input Fields to use as ComboBox options */
5
- function getMenuItemsFromFields(fields, selection) {
6
- const items = [];
7
- const itemsByGroupLabel = {};
8
- fields.forEach(field => {
9
- const item = {
10
- id: field.name,
11
- primary: field.label ?? field.name,
12
- selected: field.name === selection // set Selected field to selection
13
- };
14
- if (field.groupLabel) {
15
- itemsByGroupLabel[field.groupLabel] = itemsByGroupLabel[field.groupLabel] || [];
16
- itemsByGroupLabel[field.groupLabel].push(item);
17
- }
18
- else {
19
- items.push(item);
20
- }
21
- });
22
- Object.entries(itemsByGroupLabel).forEach(([label, childItems]) => {
23
- items.push({ id: label, primary: label, items: childItems });
24
- });
25
- return items;
26
- }
27
- /** Sets up a ComboBox to select a Field. Handles grouping and autocomplete. */
28
- const FieldSelector = (props) => {
29
- const { value, onChange, fields, status, info } = props;
30
- // Determine ComboBox menu items from the fields
31
- const items = useMemo(() => getMenuItemsFromFields(fields, value), [fields, value]);
32
- const selected = useMemo(() => {
33
- const selectedItem = menuHelpers.getItem(items, value);
34
- return selectedItem ? { id: selectedItem.id, text: selectedItem.primary } : undefined;
35
- }, [items]);
36
- // Set up autocomplete input
37
- const [filterValue, setFilterValue] = useState(''); // NOTE: `''` is needed to show the current selection
38
- const filterRegex = useMemo(() => {
39
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
40
- // Literal string match from input, not user regex input.
41
- return filterValue
42
- ? new RegExp(filterValue.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'), 'i')
43
- : undefined;
44
- }, [filterValue]);
45
- const filteredItems = useMemo(() => {
46
- return filterRegex
47
- ? menuHelpers.flatten(items).filter(({ primary }) => filterRegex.test(primary))
48
- : items;
49
- }, [filterRegex, items]);
50
- return (_jsx(ComboBox, { label: 'field', labelHidden: true, status: status, info: info, placeholder: 'Select\u2026', mode: 'single-select', value: filterValue, onChange: (ev) => {
51
- setFilterValue(ev.target.value);
52
- if (!ev.target.value)
53
- onChange('');
54
- }, onBlur: () => {
55
- setFilterValue('');
56
- }, selected: { items: selected }, menu: {
57
- items: filteredItems,
58
- mode: 'single-select',
59
- accent: filterRegex,
60
- onItemClick: id => {
61
- onChange(id);
62
- setFilterValue(''); // To show the selected value in the input
63
- }
64
- } }, void 0));
65
- };
66
- export default FieldSelector;
67
- //# sourceMappingURL=FieldSelector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FieldSelector.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/FieldSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkC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AQ,IACP,KAAK,EAAC,OAAO,EACb,WAAW,QACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,WAAW,EAAC,cAAS,EACrB,IAAI,EAAC,eAAe,EACpB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,EAAiC,EAAE,EAAE;YAC9C,cAAc,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAChC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK;gBAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;QACrC,CAAC,EACD,MAAM,EAAE,GAAG,EAAE;YACX,cAAc,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC,EACD,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAC7B,IAAI,EAAE;YACJ,KAAK,EAAE,aAAa;YACpB,IAAI,EAAE,eAAe;YACrB,MAAM,EAAE,WAAW;YACnB,WAAW,EAAE,EAAE,CAAC,EAAE;gBAChB,QAAQ,CAAC,EAAE,CAAC,CAAC;gBACb,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,0CAA0C;YAChE,CAAC;SACF,WACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { ChangeEvent, FunctionComponent, useMemo, useState } from 'react';\n\nimport {\n ComboBox,\n MenuProps,\n menuHelpers,\n BaseProps,\n ForwardProps,\n FormControlProps,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\nimport { Selected } from '@pega/cosmos-react-core/lib/components/ComboBox/ComboBox.types';\n\nimport { Field } from '../ConditionBuilder.types';\n\n/** Convert input Fields to use as ComboBox options */\nfunction getMenuItemsFromFields(fields: Field[], selection: string): MenuProps['items'] {\n const items: MenuProps['items'] = [];\n const itemsByGroupLabel: { [label: string]: MenuProps['items'] } = {};\n\n fields.forEach(field => {\n const item = {\n id: field.name,\n primary: field.label ?? field.name, // field.label is optional\n selected: field.name === selection // set Selected field to selection\n };\n if (field.groupLabel) {\n itemsByGroupLabel[field.groupLabel] = itemsByGroupLabel[field.groupLabel] || [];\n itemsByGroupLabel[field.groupLabel].push(item);\n } else {\n items.push(item);\n }\n });\n\n Object.entries(itemsByGroupLabel).forEach(([label, childItems]) => {\n items.push({ id: label, primary: label, items: childItems });\n });\n\n return items;\n}\n\ninterface FieldSelectorProps extends BaseProps, NoChildrenProp {\n /** Current selection */\n value: string;\n\n /** Change handler */\n onChange: (selection: string) => void;\n\n /** Metadata (data-model) for the Fields to use in the selector */\n fields: Field[];\n\n /** Status for the ComboBox */\n status?: FormControlProps['status'];\n\n /** Info for the ComboBox */\n info?: FormControlProps['info'];\n}\n\n/** Sets up a ComboBox to select a Field. Handles grouping and autocomplete. */\nconst FieldSelector: FunctionComponent<FieldSelectorProps & ForwardProps> = (\n props: FieldSelectorProps\n) => {\n const { value, onChange, fields, status, info } = props;\n\n // Determine ComboBox menu items from the fields\n const items = useMemo(() => getMenuItemsFromFields(fields, value), [fields, value]);\n const selected: Selected | undefined = useMemo(() => {\n const selectedItem = menuHelpers.getItem(items, value);\n return selectedItem ? { id: selectedItem.id, text: selectedItem.primary } : undefined;\n }, [items]);\n\n // Set up autocomplete input\n const [filterValue, setFilterValue] = useState<string>(''); // NOTE: `''` is needed to show the current selection\n const filterRegex = useMemo(() => {\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping\n // Literal string match from input, not user regex input.\n return filterValue\n ? new RegExp(filterValue.replace(/[.*+\\-?^${}()|[\\]\\\\]/g, '\\\\$&'), 'i')\n : undefined;\n }, [filterValue]);\n\n const filteredItems = useMemo(() => {\n return filterRegex\n ? menuHelpers.flatten(items).filter(({ primary }) => filterRegex.test(primary))\n : items;\n }, [filterRegex, items]);\n\n return (\n <ComboBox\n label='field'\n labelHidden\n status={status}\n info={info}\n placeholder='Select…'\n mode='single-select'\n value={filterValue}\n onChange={(ev: ChangeEvent<HTMLInputElement>) => {\n setFilterValue(ev.target.value);\n if (!ev.target.value) onChange('');\n }}\n onBlur={() => {\n setFilterValue('');\n }}\n selected={{ items: selected }}\n menu={{\n items: filteredItems,\n mode: 'single-select',\n accent: filterRegex,\n onItemClick: id => {\n onChange(id);\n setFilterValue(''); // To show the selected value in the input\n }\n }}\n />\n );\n};\n\nexport default FieldSelector;\n"]}
@@ -1,16 +0,0 @@
1
- import { FunctionComponent } from 'react';
2
- import { BaseProps, ForwardProps, NoChildrenProp } from '@pega/cosmos-react-core';
3
- interface MultiSelectorProps extends BaseProps, NoChildrenProp {
4
- /** Previous selection */
5
- values: string[];
6
- /** Options for the selector */
7
- options: string[];
8
- /** Callback for changes */
9
- onChange: (selection: string[]) => void;
10
- /** Used to indicate any errors on the control */
11
- status?: 'error';
12
- }
13
- /** A control for selecting multiple values using checkboxes in an overlay */
14
- declare const MultiValueSelector: FunctionComponent<MultiSelectorProps & ForwardProps>;
15
- export default MultiValueSelector;
16
- //# sourceMappingURL=MultiValueSelector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultiValueSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/MultiValueSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,OAAO,CAAC;AAE7D,OAAO,EAEL,SAAS,EACT,YAAY,EAIZ,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,UAAU,kBAAmB,SAAQ,SAAS,EAAE,cAAc;IAC5D,yBAAyB;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,2BAA2B;IAC3B,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAExC,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,6EAA6E;AAC7E,QAAA,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAgE5E,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -1,43 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useState, useMemo } from 'react';
3
- import { useI18n, ComboBox, createStringMatcher, useAfterInitialEffect } from '@pega/cosmos-react-core';
4
- /** A control for selecting multiple values using checkboxes in an overlay */
5
- const MultiValueSelector = ({ values, options, onChange, status }) => {
6
- const t = useI18n();
7
- const [selections, setSelections] = useState(values);
8
- const [filterValue, setFilterValue] = useState('');
9
- const itemsToRender = useMemo(() => {
10
- let opts = options;
11
- if (filterValue) {
12
- const matcher = createStringMatcher(filterValue, 'boundary');
13
- opts = opts.filter(opt => matcher.test(opt));
14
- }
15
- return opts.map(option => {
16
- return {
17
- id: option,
18
- primary: option,
19
- selected: selections.includes(option)
20
- };
21
- });
22
- }, [options, filterValue, selections]);
23
- useAfterInitialEffect(() => {
24
- onChange(selections);
25
- }, [selections]);
26
- return (_jsx(ComboBox, { mode: 'multi-select', label: t('condition_builder_possible_values_label'), labelHidden: true, placeholder: t('condition_builder_selection_text_default'), value: filterValue, onChange: e => {
27
- setFilterValue(e.target.value);
28
- }, menu: {
29
- items: itemsToRender,
30
- onItemClick: option => {
31
- setSelections(cur => cur.includes(option) ? cur.filter(selection => selection !== option) : [...cur, option]);
32
- }
33
- }, selected: selections.length > 0
34
- ? {
35
- items: selections.map(s => ({ id: s, text: s })),
36
- onRemove: value => {
37
- setSelections(cur => cur.filter(selection => selection !== value));
38
- }
39
- }
40
- : undefined, status: status, info: status === 'error' ? t('condition_builder_empty_selection_error_text') : undefined }, void 0));
41
- };
42
- export default MultiValueSelector;
43
- //# sourceMappingURL=MultiValueSelector.js.map