@pega/cosmos-react-condition-builder 2.0.0-dev.2.0 → 2.0.0-dev.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts +11 -4
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/AtomicCondition.js +22 -24
- package/lib/components/ConditionBuilder/AtomicCondition.js.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.js +23 -44
- package/lib/components/ConditionBuilder/ConditionBuilder.js.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +42 -2
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.js.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.js +6 -9
- package/lib/components/ConditionBuilder/FieldCondition.js.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts +10 -2
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.js.map +1 -1
- package/lib/components/ConditionBuilder/HelpButton.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/HelpButton.js +2 -4
- package/lib/components/ConditionBuilder/HelpButton.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts +18 -0
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js +115 -0
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js.map +1 -0
- package/lib/components/ConditionBuilder/{FieldSelector.d.ts → RhsControls/FieldSelector.d.ts} +1 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/{FieldSelector.js → RhsControls/FieldSelector.js} +5 -5
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js.map +1 -0
- package/lib/components/ConditionBuilder/{MultiValueSelector.d.ts → RhsControls/MultiValueSelector.d.ts} +1 -1
- package/lib/components/ConditionBuilder/RhsControls/MultiValueSelector.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/MultiValueSelector.js +43 -0
- package/lib/components/ConditionBuilder/RhsControls/MultiValueSelector.js.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts +18 -0
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.js +19 -0
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.js.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts +18 -0
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js +109 -0
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts +24 -0
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js +122 -0
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts +8 -0
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js +89 -0
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts +20 -0
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js +11 -0
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js.map +1 -0
- package/lib/components/ConditionBuilder/{RhsControls.d.ts → RhsControls/index.d.ts} +16 -6
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/RhsControls/index.js +219 -0
- package/lib/components/ConditionBuilder/RhsControls/index.js.map +1 -0
- package/lib/components/ConditionBuilder/core/evaluator.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/evaluator.js +110 -9
- package/lib/components/ConditionBuilder/core/evaluator.js.map +1 -1
- package/lib/components/ConditionBuilder/core/extendDayJs.d.ts +2 -0
- package/lib/components/ConditionBuilder/core/extendDayJs.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/core/extendDayJs.js +4 -0
- package/lib/components/ConditionBuilder/core/extendDayJs.js.map +1 -0
- package/lib/components/ConditionBuilder/core/formatter.d.ts +10 -1
- package/lib/components/ConditionBuilder/core/formatter.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/formatter.js +95 -13
- package/lib/components/ConditionBuilder/core/formatter.js.map +1 -1
- package/lib/components/ConditionBuilder/core/transformer.d.ts +7 -0
- package/lib/components/ConditionBuilder/core/transformer.d.ts.map +1 -0
- package/lib/components/ConditionBuilder/core/transformer.js +154 -0
- package/lib/components/ConditionBuilder/core/transformer.js.map +1 -0
- package/lib/components/ConditionBuilder/core/types.d.ts +7 -1
- package/lib/components/ConditionBuilder/core/types.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/types.js.map +1 -1
- package/lib/components/ConditionBuilder/core/utils.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/utils.js +4 -8
- package/lib/components/ConditionBuilder/core/utils.js.map +1 -1
- package/lib/components/ConditionBuilder/index.d.ts +2 -1
- package/lib/components/ConditionBuilder/index.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/index.js +2 -1
- package/lib/components/ConditionBuilder/index.js.map +1 -1
- package/package.json +17 -15
- package/lib/components/ConditionBuilder/FieldSelector.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/FieldSelector.js.map +0 -1
- package/lib/components/ConditionBuilder/MultiValueSelector.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/MultiValueSelector.js +0 -77
- package/lib/components/ConditionBuilder/MultiValueSelector.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls.js +0 -277
- package/lib/components/ConditionBuilder/RhsControls.js.map +0 -1
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import { Flex, Button, useI18n } from '@pega/cosmos-react-core';
|
|
3
4
|
import AtomicCondition, { getInitConditionForLhs, isValidCondition } from './AtomicCondition';
|
|
4
5
|
/** Component for building an atomic condition on a given field */
|
|
5
6
|
const FieldCondition = (props) => {
|
|
6
|
-
const { targetField, fields, onSubmit, condition: seedCondition, validComparators } = props;
|
|
7
|
-
const validRhsTypes = new Set(['LITERAL', 'FIELD']);
|
|
7
|
+
const { targetField, fields, onSubmit, condition: seedCondition, validComparators, validRhsTypes = new Set(['LITERAL', 'FIELD']), dateFunctions } = props;
|
|
8
8
|
const [condition, setCondition] = useState(
|
|
9
9
|
// If editing use the seedCondition, otherwise, determine an initial condition based on the targetField
|
|
10
10
|
() => seedCondition ||
|
|
11
|
-
getInitConditionForLhs({ field: targetField }, fields, validRhsTypes, validComparators));
|
|
11
|
+
getInitConditionForLhs({ field: targetField }, fields, validRhsTypes, validComparators, dateFunctions));
|
|
12
12
|
const [showErrorIndicators, setErrorIndicators] = useState(false); // Used to enable inline error indicators on the controls
|
|
13
13
|
const t = useI18n();
|
|
14
14
|
const handleSubmission = () => {
|
|
15
15
|
setErrorIndicators(false); // Reset any previous flag
|
|
16
|
-
if (isValidCondition(condition, fields,
|
|
16
|
+
if (isValidCondition(condition, fields, true)) {
|
|
17
17
|
onSubmit(condition); // If it's a valid condition, submit it
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
setErrorIndicators(true); // Otherwise, indicate errors
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
return (
|
|
24
|
-
React.createElement(AtomicCondition, { condition: condition, fields: fields, indicateErrors: showErrorIndicators, validComparators: validComparators, onChange: c => setCondition(c), itemDirection: 'column', validRhsTypes: validRhsTypes, showLhsAsLabel: true }),
|
|
25
|
-
React.createElement(Flex, { container: { justify: 'end' } },
|
|
26
|
-
React.createElement(Button, { type: 'submit', variant: 'primary', onClick: handleSubmission }, t('condition_builder_submit_button_label')))));
|
|
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));
|
|
27
24
|
};
|
|
28
25
|
export default FieldCondition;
|
|
29
26
|
//# sourceMappingURL=FieldCondition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldCondition.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;A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E,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,6 +1,6 @@
|
|
|
1
1
|
import { BaseProps } from '@pega/cosmos-react-core';
|
|
2
|
-
import { ComparatorsByType } from './core/types';
|
|
3
|
-
import { Field, LeafCondition } from './ConditionBuilder.types';
|
|
2
|
+
import { ComparatorsByType, RHSType } from './core/types';
|
|
3
|
+
import { Field, LeafCondition, DateFunctionsByType } from './ConditionBuilder.types';
|
|
4
4
|
/** Type definition for the input props of FieldCondition */
|
|
5
5
|
export default interface FieldConditionProps extends BaseProps {
|
|
6
6
|
/** Name of the field on which the condition should be constructed */
|
|
@@ -13,5 +13,13 @@ export default interface FieldConditionProps extends BaseProps {
|
|
|
13
13
|
condition?: LeafCondition;
|
|
14
14
|
/** (Optional) Used to limit the Comparators allowed in the component. */
|
|
15
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;
|
|
16
24
|
}
|
|
17
25
|
//# sourceMappingURL=FieldCondition.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,MAAM,cAAc,CAAC;
|
|
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 +1 @@
|
|
|
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 } from './core/types';\nimport { Field, LeafCondition } 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"]}
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelpButton.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/HelpButton.tsx"],"names":[],"mappings":"AAAA,
|
|
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,13 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Icon, Tooltip, useElement, useUID } from '@pega/cosmos-react-core';
|
|
3
3
|
/** Renders an inline Help icon that shows help content on hover */
|
|
4
4
|
const HelpButton = (props) => {
|
|
5
5
|
const { children } = props;
|
|
6
6
|
const [iconEl, setIconEl] = useElement();
|
|
7
7
|
const id = useUID();
|
|
8
|
-
return (
|
|
9
|
-
React.createElement(Icon, { name: 'information', ref: setIconEl, "aria-describedby": id }),
|
|
10
|
-
iconEl && (React.createElement(Tooltip, { target: iconEl, id: id }, children))));
|
|
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));
|
|
11
9
|
};
|
|
12
10
|
export default HelpButton;
|
|
13
11
|
//# sourceMappingURL=HelpButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelpButton.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/HelpButton.tsx"],"names":[],"mappings":"
|
|
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"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { BaseProps, ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { RhsWithDateFunction } from '../ConditionBuilder.types';
|
|
4
|
+
import { DateFunction } from '../core/types';
|
|
5
|
+
export interface DateFunctionMenuProps extends BaseProps {
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,EAcb,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;IACtD,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"}
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,EA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C,MAAC,MAAM,OACD,mBAAmB,EACvB,QAAQ,EAAE,mBAAmB,EAC7B,IAAI,EAAC,wBAAwB,aAE7B,KAAC,MAAM,4BAAW,EACjB,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAC3B,KAAC,MAAM,IAAY,KAAK,EAAE,CAAC,CAAC,EAAE,YAC3B,CAAC,CAAC,KAAK,IADG,CAAC,CAAC,EAAE,CAER,CACV,CAAC,YACK,CACV,EACA,GAAG,CAAC,YAAY,KAAK,eAAe,IAAI,CACvC,KAAC,WAAW,OACN,mBAAmB,EACvB,WAAW,EAAC,QAAQ,EACpB,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,EAAE,EACP,IAAI,EAAE,CAAC,EACP,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAE,kBAAkB,WAC5B,CACH,EACA,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} 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 {\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"]}
|
package/lib/components/ConditionBuilder/{FieldSelector.d.ts → RhsControls/FieldSelector.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
import { BaseProps, ForwardProps, FormControlProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { Field } from '
|
|
3
|
+
import { Field } from '../ConditionBuilder.types';
|
|
4
4
|
interface FieldSelectorProps extends BaseProps {
|
|
5
5
|
/** Current selection */
|
|
6
6
|
value: string;
|
|
@@ -0,0 +1 @@
|
|
|
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,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AA4BlD,UAAU,kBAAmB,SAAQ,SAAS;IAC5C,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,14 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
2
3
|
import { ComboBox, menuHelpers } from '@pega/cosmos-react-core';
|
|
3
4
|
/** Convert input Fields to use as ComboBox options */
|
|
4
5
|
function getMenuItemsFromFields(fields, selection) {
|
|
5
6
|
const items = [];
|
|
6
7
|
const itemsByGroupLabel = {};
|
|
7
8
|
fields.forEach(field => {
|
|
8
|
-
var _a;
|
|
9
9
|
const item = {
|
|
10
10
|
id: field.name,
|
|
11
|
-
primary:
|
|
11
|
+
primary: field.label ?? field.name,
|
|
12
12
|
selected: field.name === selection // set Selected field to selection
|
|
13
13
|
};
|
|
14
14
|
if (field.groupLabel) {
|
|
@@ -47,7 +47,7 @@ const FieldSelector = (props) => {
|
|
|
47
47
|
? menuHelpers.flatten(items).filter(({ primary }) => filterRegex.test(primary))
|
|
48
48
|
: items;
|
|
49
49
|
}, [filterRegex, items]);
|
|
50
|
-
return (
|
|
50
|
+
return (_jsx(ComboBox, { label: 'field', labelHidden: true, status: status, info: info, placeholder: 'Select\u2026', mode: 'single-select', value: filterValue, onChange: (ev) => {
|
|
51
51
|
setFilterValue(ev.target.value);
|
|
52
52
|
if (!ev.target.value)
|
|
53
53
|
onChange('');
|
|
@@ -61,7 +61,7 @@ const FieldSelector = (props) => {
|
|
|
61
61
|
onChange(id);
|
|
62
62
|
setFilterValue(''); // To show the selected value in the input
|
|
63
63
|
}
|
|
64
|
-
} }));
|
|
64
|
+
} }, void 0));
|
|
65
65
|
};
|
|
66
66
|
export default FieldSelector;
|
|
67
67
|
//# sourceMappingURL=FieldSelector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldSelector.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/FieldSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EACL,QAAQ,EAER,WAAW,EAIZ,MAAM,yBAAyB,CAAC;AAKjC,sDAAsD;AACtD,SAAS,sBAAsB,CAAC,MAAe,EAAE,SAAiB;IACh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,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} 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 {\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"]}
|
|
@@ -8,7 +8,7 @@ interface MultiSelectorProps extends BaseProps {
|
|
|
8
8
|
/** Callback for changes */
|
|
9
9
|
onChange: (selection: string[]) => void;
|
|
10
10
|
/** Used to indicate any errors on the control */
|
|
11
|
-
status
|
|
11
|
+
status?: 'error';
|
|
12
12
|
}
|
|
13
13
|
/** A control for selecting multiple values using checkboxes in an overlay */
|
|
14
14
|
declare const MultiValueSelector: FunctionComponent<MultiSelectorProps & ForwardProps>;
|
|
@@ -0,0 +1 @@
|
|
|
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,EAIb,MAAM,yBAAyB,CAAC;AAEjC,UAAU,kBAAmB,SAAQ,SAAS;IAC5C,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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiValueSelector.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/MultiValueSelector.tsx"],"names":[],"mappings":";AAAA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,\n createStringMatcher,\n useAfterInitialEffect\n} from '@pega/cosmos-react-core';\n\ninterface MultiSelectorProps extends BaseProps {\n /** Previous selection */\n values: string[];\n\n /** Options for the selector */\n options: string[];\n\n /** Callback for changes */\n onChange: (selection: string[]) => void;\n\n /** Used to indicate any errors on the control */\n status?: 'error';\n}\n\n/** A control for selecting multiple values using checkboxes in an overlay */\nconst MultiValueSelector: FunctionComponent<MultiSelectorProps & ForwardProps> = ({\n values,\n options,\n onChange,\n status\n}: MultiSelectorProps) => {\n const t = useI18n();\n\n const [selections, setSelections] = useState(values);\n const [filterValue, setFilterValue] = useState('');\n\n const itemsToRender = useMemo(() => {\n let opts = options;\n\n if (filterValue) {\n const matcher = createStringMatcher(filterValue, 'boundary');\n opts = opts.filter(opt => matcher.test(opt));\n }\n\n return opts.map(option => {\n return {\n id: option,\n primary: option,\n selected: selections.includes(option)\n };\n });\n }, [options, filterValue, selections]);\n\n useAfterInitialEffect(() => {\n onChange(selections);\n }, [selections]);\n\n return (\n <ComboBox\n mode='multi-select'\n label={t('condition_builder_possible_values_label')}\n labelHidden\n placeholder={t('condition_builder_selection_text_default')}\n value={filterValue}\n onChange={e => {\n setFilterValue(e.target.value);\n }}\n menu={{\n items: itemsToRender,\n onItemClick: option => {\n setSelections(cur =>\n cur.includes(option) ? cur.filter(selection => selection !== option) : [...cur, option]\n );\n }\n }}\n selected={\n selections.length > 0\n ? {\n items: selections.map(s => ({ id: s, text: s })),\n onRemove: value => {\n setSelections(cur => cur.filter(selection => selection !== value));\n }\n }\n : undefined\n }\n status={status}\n info={status === 'error' ? t('condition_builder_empty_selection_error_text') : undefined}\n />\n );\n};\n\nexport default MultiValueSelector;\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { BaseProps } from '@pega/cosmos-react-core';
|
|
3
|
+
interface NumericInputProps extends BaseProps {
|
|
4
|
+
/** Rhs for the condition */
|
|
5
|
+
rhs: {
|
|
6
|
+
value: string | number;
|
|
7
|
+
};
|
|
8
|
+
/** Callback for any modifications to the Rhs */
|
|
9
|
+
onChange: (rhs: {
|
|
10
|
+
value: string | number;
|
|
11
|
+
}) => void;
|
|
12
|
+
/** Used to indicate any errors on the control */
|
|
13
|
+
status?: 'error';
|
|
14
|
+
}
|
|
15
|
+
/** Wrapper over the NumberInput to parse values as Numbers, while still allowing the user to type partial values like `12.`, `12.0`, ... */
|
|
16
|
+
declare const NumericInput: FunctionComponent<NumericInputProps>;
|
|
17
|
+
export default NumericInput;
|
|
18
|
+
//# sourceMappingURL=NumericInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumericInput.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/NumericInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAwB,MAAM,yBAAyB,CAAC;AAE1E,UAAU,iBAAkB,SAAQ,SAAS;IAC3C,4BAA4B;IAC5B,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAEhC,gDAAgD;IAChD,QAAQ,EAAE,CAAC,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAEpD,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,4IAA4I;AAC5I,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAwBtD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { NumberInput, useI18n } from '@pega/cosmos-react-core';
|
|
4
|
+
/** Wrapper over the NumberInput to parse values as Numbers, while still allowing the user to type partial values like `12.`, `12.0`, ... */
|
|
5
|
+
const NumericInput = (props) => {
|
|
6
|
+
const { rhs, onChange, status } = props;
|
|
7
|
+
const t = useI18n();
|
|
8
|
+
// Since we want to always call onChange with parsed Numbers,
|
|
9
|
+
// if we parse values like `12.`, `12.0`, etc., the decimals will be lost leading to bad UX
|
|
10
|
+
// Using a local state to avoid that
|
|
11
|
+
const [localValue, setLocalValue] = useState(rhs.value.toString());
|
|
12
|
+
const handleInputChange = (newValue) => {
|
|
13
|
+
setLocalValue(newValue);
|
|
14
|
+
onChange({ value: newValue.trim() ? Number(newValue) : '' }); // Save as a number unless the input is empty
|
|
15
|
+
};
|
|
16
|
+
return (_jsx(NumberInput, { value: localValue, onChange: handleInputChange, status: status, info: status === 'error' ? t('condition_builder_invalid_number') : undefined, label: t('condition_builder_compare_with_numeric_value'), labelHidden: true }, void 0));
|
|
17
|
+
};
|
|
18
|
+
export default NumericInput;
|
|
19
|
+
//# sourceMappingURL=NumericInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumericInput.js","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/NumericInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAa,WAAW,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAa1E,4IAA4I;AAC5I,MAAM,YAAY,GAAyC,CAAC,KAAwB,EAAE,EAAE;IACtF,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACxC,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,6DAA6D;IAC7D,2FAA2F;IAC3F,oCAAoC;IACpC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEnE,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,EAAE;QAC7C,aAAa,CAAC,QAAQ,CAAC,CAAC;QACxB,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,6CAA6C;IAC7G,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,WAAW,IACV,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,CAAC,SAAS,EAC5E,KAAK,EAAE,CAAC,CAAC,8CAA8C,CAAC,EACxD,WAAW,iBACX,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { FunctionComponent, useState } from 'react';\n\nimport { BaseProps, NumberInput, useI18n } from '@pega/cosmos-react-core';\n\ninterface NumericInputProps extends BaseProps {\n /** Rhs for the condition */\n rhs: { value: string | number };\n\n /** Callback for any modifications to the Rhs */\n onChange: (rhs: { value: string | number }) => void;\n\n /** Used to indicate any errors on the control */\n status?: 'error';\n}\n\n/** Wrapper over the NumberInput to parse values as Numbers, while still allowing the user to type partial values like `12.`, `12.0`, ... */\nconst NumericInput: FunctionComponent<NumericInputProps> = (props: NumericInputProps) => {\n const { rhs, onChange, status } = props;\n const t = useI18n();\n\n // Since we want to always call onChange with parsed Numbers,\n // if we parse values like `12.`, `12.0`, etc., the decimals will be lost leading to bad UX\n // Using a local state to avoid that\n const [localValue, setLocalValue] = useState(rhs.value.toString());\n\n const handleInputChange = (newValue: string) => {\n setLocalValue(newValue);\n onChange({ value: newValue.trim() ? Number(newValue) : '' }); // Save as a number unless the input is empty\n };\n\n return (\n <NumberInput\n value={localValue}\n onChange={handleInputChange}\n status={status}\n info={status === 'error' ? t('condition_builder_invalid_number') : undefined}\n label={t('condition_builder_compare_with_numeric_value')}\n labelHidden\n />\n );\n};\n\nexport default NumericInput;\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { BaseProps, ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { RhsWithRelativeDate } from '../ConditionBuilder.types';
|
|
4
|
+
import { FieldType } from '../core/types';
|
|
5
|
+
export interface RelativeDateMenuProps extends BaseProps {
|
|
6
|
+
/** Rhs for the condition */
|
|
7
|
+
rhs: RhsWithRelativeDate;
|
|
8
|
+
/** Callback for any modifications to the Rhs */
|
|
9
|
+
onChange: (rhs: RhsWithRelativeDate) => void;
|
|
10
|
+
/** FieldType of the LHS Field. Will only be DATE_TIME or DATE_ONLY */
|
|
11
|
+
fieldType: FieldType;
|
|
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 RelativeDateMenu: FunctionComponent<RelativeDateMenuProps & ForwardProps>;
|
|
17
|
+
export default RelativeDateMenu;
|
|
18
|
+
//# sourceMappingURL=RelativeDateMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RelativeDateMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionBuilder/RhsControls/RelativeDateMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAEhE,OAAO,EACL,SAAS,EACT,YAAY,EAOb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAsC,SAAS,EAAE,MAAM,eAAe,CAAC;AAE9E,MAAM,WAAW,qBAAsB,SAAQ,SAAS;IACtD,4BAA4B;IAC5B,GAAG,EAAE,mBAAmB,CAAC;IAEzB,gDAAgD;IAChD,QAAQ,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAE7C,sEAAsE;IACtE,SAAS,EAAE,SAAS,CAAC;IAErB,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,gEAAgE;AAChE,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,GAAG,YAAY,CAqJ7E,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|