@pega/cosmos-react-condition-builder 5.0.0-dev.4.7 → 5.0.0-dev.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts +0 -57
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/AtomicCondition.js +0 -164
- package/lib/components/ConditionBuilder/AtomicCondition.js.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.d.ts +0 -6
- package/lib/components/ConditionBuilder/ConditionBuilder.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.js +0 -271
- package/lib/components/ConditionBuilder/ConditionBuilder.js.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts +0 -7
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.js +0 -59
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.js.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +0 -136
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.js +0 -2
- package/lib/components/ConditionBuilder/ConditionBuilder.types.js.map +0 -1
- package/lib/components/ConditionBuilder/FieldCondition.d.ts +0 -7
- package/lib/components/ConditionBuilder/FieldCondition.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/FieldCondition.js +0 -26
- package/lib/components/ConditionBuilder/FieldCondition.js.map +0 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts +0 -30
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.js +0 -2
- package/lib/components/ConditionBuilder/FieldCondition.types.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts +0 -18
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js +0 -155
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts +0 -21
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js +0 -60
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts +0 -18
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.js +0 -22
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts +0 -18
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js +0 -119
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts +0 -26
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js +0 -156
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts +0 -6
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js +0 -112
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts +0 -20
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js +0 -12
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts +0 -45
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js +0 -196
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts +0 -42
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/RhsControls/index.js +0 -321
- package/lib/components/ConditionBuilder/RhsControls/index.js.map +0 -1
- package/lib/components/ConditionBuilder/core/comparators.d.ts +0 -12
- package/lib/components/ConditionBuilder/core/comparators.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/comparators.js +0 -78
- package/lib/components/ConditionBuilder/core/comparators.js.map +0 -1
- package/lib/components/ConditionBuilder/core/evaluator.d.ts +0 -17
- package/lib/components/ConditionBuilder/core/evaluator.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/evaluator.js +0 -314
- package/lib/components/ConditionBuilder/core/evaluator.js.map +0 -1
- package/lib/components/ConditionBuilder/core/extendDayJs.d.ts +0 -2
- package/lib/components/ConditionBuilder/core/extendDayJs.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/extendDayJs.js +0 -4
- package/lib/components/ConditionBuilder/core/extendDayJs.js.map +0 -1
- package/lib/components/ConditionBuilder/core/formatter.d.ts +0 -17
- package/lib/components/ConditionBuilder/core/formatter.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/formatter.js +0 -262
- package/lib/components/ConditionBuilder/core/formatter.js.map +0 -1
- package/lib/components/ConditionBuilder/core/rows-reducer.d.ts +0 -27
- package/lib/components/ConditionBuilder/core/rows-reducer.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/rows-reducer.js +0 -50
- package/lib/components/ConditionBuilder/core/rows-reducer.js.map +0 -1
- package/lib/components/ConditionBuilder/core/time-utils.d.ts +0 -5
- package/lib/components/ConditionBuilder/core/time-utils.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/time-utils.js +0 -23
- package/lib/components/ConditionBuilder/core/time-utils.js.map +0 -1
- package/lib/components/ConditionBuilder/core/transformer.d.ts +0 -7
- package/lib/components/ConditionBuilder/core/transformer.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/transformer.js +0 -210
- package/lib/components/ConditionBuilder/core/transformer.js.map +0 -1
- package/lib/components/ConditionBuilder/core/types.d.ts +0 -47
- package/lib/components/ConditionBuilder/core/types.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/types.js +0 -2
- package/lib/components/ConditionBuilder/core/types.js.map +0 -1
- package/lib/components/ConditionBuilder/core/utils.d.ts +0 -37
- package/lib/components/ConditionBuilder/core/utils.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/core/utils.js +0 -454
- package/lib/components/ConditionBuilder/core/utils.js.map +0 -1
- package/lib/components/ConditionBuilder/index.d.ts +0 -11
- package/lib/components/ConditionBuilder/index.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/index.js +0 -8
- package/lib/components/ConditionBuilder/index.js.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.d.ts +0 -6
- package/lib/components/ConditionInput/ConditionInput.d.ts.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.js +0 -302
- package/lib/components/ConditionInput/ConditionInput.js.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.styles.d.ts +0 -5
- package/lib/components/ConditionInput/ConditionInput.styles.d.ts.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.styles.js +0 -27
- package/lib/components/ConditionInput/ConditionInput.styles.js.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.types.d.ts +0 -32
- package/lib/components/ConditionInput/ConditionInput.types.d.ts.map +0 -1
- package/lib/components/ConditionInput/ConditionInput.types.js +0 -2
- package/lib/components/ConditionInput/ConditionInput.types.js.map +0 -1
- package/lib/components/ConditionInput/index.d.ts +0 -3
- package/lib/components/ConditionInput/index.d.ts.map +0 -1
- package/lib/components/ConditionInput/index.js +0 -2
- package/lib/components/ConditionInput/index.js.map +0 -1
- package/lib/components/ConditionInput/utils.d.ts +0 -17
- package/lib/components/ConditionInput/utils.d.ts.map +0 -1
- package/lib/components/ConditionInput/utils.js +0 -121
- package/lib/components/ConditionInput/utils.js.map +0 -1
- package/lib/components/PromotedFilters/ConditionSelector.d.ts +0 -31
- package/lib/components/PromotedFilters/ConditionSelector.d.ts.map +0 -1
- package/lib/components/PromotedFilters/ConditionSelector.js +0 -44
- package/lib/components/PromotedFilters/ConditionSelector.js.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.d.ts +0 -11
- package/lib/components/PromotedFilters/PromotedFilters.d.ts.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.js +0 -153
- package/lib/components/PromotedFilters/PromotedFilters.js.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.styles.d.ts +0 -4
- package/lib/components/PromotedFilters/PromotedFilters.styles.d.ts.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.styles.js +0 -38
- package/lib/components/PromotedFilters/PromotedFilters.styles.js.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts +0 -33
- package/lib/components/PromotedFilters/PromotedFilters.types.d.ts.map +0 -1
- package/lib/components/PromotedFilters/PromotedFilters.types.js +0 -2
- package/lib/components/PromotedFilters/PromotedFilters.types.js.map +0 -1
- package/lib/components/PromotedFilters/index.d.ts +0 -3
- package/lib/components/PromotedFilters/index.d.ts.map +0 -1
- package/lib/components/PromotedFilters/index.js +0 -2
- package/lib/components/PromotedFilters/index.js.map +0 -1
- package/lib/index.d.ts +0 -7
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -8
- package/lib/index.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionBuilder.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,QAAQ,EAER,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,MAAM,EACN,SAAS,EACV,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,MAAM,EACN,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,UAAU,EAEV,OAAO,EACP,OAAO,EACP,aAAa,EAEb,KAAK,EACL,MAAM,EACN,UAAU,EACV,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,eAAe,EAAE,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAMtE,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AACtB,OAAO,WAAW,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,WAAW,EACX,sBAAsB,EACvB,MAAM,2BAA2B,CAAC;AAEnC,gCAAgC;AAChC,MAAM,YAAY,GAAmC;IACnD,SAAS,EAAE;QACT,SAAS,EAAE;YACT,UAAU,EAAE,aAAa;YACzB,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;SACnB;KACF;CACF,CAAC;AAEF,4BAA4B;AAC5B,MAAM,gBAAgB,GAA4D,CAChF,KAA4B,EAC5B,EAAE;IACF,MAAM,EACJ,MAAM,EACN,SAAS,EAAE,aAAa,EACxB,gBAAgB,EAChB,aAAa,GAAG,IAAI,GAAG,CAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,EACtD,aAAa,EACb,WAAW,EACX,MAAM,EACP,GAAG,KAAK,CAAC;IAEV,6EAA6E;IAC7E,MAAM,eAAe,GAAc,IAAI,CAAC,KAAK,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ACZ,UAAU,CAAC,KAAK,CAAC,CAAC;4BACpB,CAAC,gBAEC,WAAW;gCACT,CAAC,CAAC,CAAC,CAAC,mDAAmD,CAAC;gCACxD,CAAC,CAAC,CAAC,CAAC,gDAAgD,CAAC,EAEzD,GAAG,EAAE,SAAS,YAEb,WAAW;gCACV,CAAC,CAAC,CAAC,CAAC,8CAA8C,CAAC;gCACnD,CAAC,CAAC,CAAC,CAAC,2CAA2C,CAAC,GAC3C,GACJ,IACF,IACgB,CAC1B,CAAC;AACJ,CAAC,CAAC;AACF,gBAAgB,CAAC,YAAY,GAAG,YAAY,CAAC;AAE7C,eAAe,gBAAgB,CAAC","sourcesContent":["import {\n FunctionComponent,\n Fragment,\n ChangeEvent,\n useState,\n useReducer,\n useImperativeHandle,\n useRef,\n useEffect\n} from 'react';\n\nimport {\n Banner,\n Button,\n Flex,\n Icon,\n Input,\n MenuButton,\n ForwardProps,\n hasProp,\n useI18n,\n getFocusables,\n BannerHandleValue,\n Label,\n useUID,\n useLiveLog,\n AdditionalInfo\n} from '@pega/cosmos-react-core';\n\nimport AtomicCondition, { isValidCondition } from './AtomicCondition';\nimport ConditionBuilderProps, {\n Condition,\n HandleValue,\n LeafCondition\n} from './ConditionBuilder.types';\nimport {\n splitConditionForBuilder,\n parseLogicString,\n disambiguateLogic,\n isBasicModeApplicable,\n getBasicModeOperators,\n getLogicFromBasicMode\n} from './core/utils';\nimport rowsReducer, { INSERT_ROW, UPDATE_ROW, REMOVE_ROW } from './core/rows-reducer';\nimport { RHSType } from './core/types';\nimport {\n StyledRowWithSeparator,\n StyledRow,\n StyledLabel,\n StyledConditionBuilder\n} from './ConditionBuilder.styles';\n\n// Default props for the builder\nconst defaultProps: Partial<ConditionBuilderProps> = {\n condition: {\n condition: {\n comparator: 'IS_NOT_NULL',\n lhs: { field: '' }\n }\n }\n};\n\n// Component for the builder\nconst ConditionBuilder: FunctionComponent<ConditionBuilderProps & ForwardProps> = (\n props: ConditionBuilderProps\n) => {\n const {\n fields,\n condition: seedCondition,\n validComparators,\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions,\n disallowNOT,\n handle\n } = props;\n\n // Split the condition tree into a logic-string and a list of condition-rows.\n const clonedCondition: Condition = JSON.parse(JSON.stringify(seedCondition)); // Cloning to avoid modifying the original\n const { logic: seedLogic, rows: seedRows } = splitConditionForBuilder(clonedCondition);\n\n // On load, look to use the Basic-mode if the seed-condition is simple enough\n const [isBasicMode, setBasicMode] = useState(() => isBasicModeApplicable(clonedCondition));\n const [operatorsList, setOperatorsList] = useState(() => getBasicModeOperators(seedLogic)); // Operators-list used in Basic-mode to render dropdowns between the rows. NOTE: When in Advanced-mode, this can contain stale values.\n const [logicString, setLogicString] = useState(seedLogic); // Logic-string used in Advanced-mode. NOTE: When in Basic-mode, this can contain stale values.\n const [conditionRows, dispatch] = useReducer(rowsReducer, seedRows); // Conditions-rows\n const [logicError, setLogicError] = useState<string | null>(null); // Used to indicate errors in the logic string\n const [showModeWarning, setModeWarning] = useState(false); // Used to warn user about losing information when moving away from Advanced mode\n const [showErrorIndicators, setErrorIndicators] = useState(false); // Used to enable inline error indicators in the condition rows\n const enableShading =\n isBasicMode && operatorsList.includes('AND') && operatorsList.includes('OR'); // In Basic mode, enable shading to indicate grouping only when both operators are present\n const labelId = useUID();\n\n const newOperatorButtonRef = useRef<HTMLButtonElement | null>(null);\n const focusRowRef = useRef<HTMLElement | null>(null);\n const [focusRowIndex, setFocusRowIndex] = useState<number | null>(null);\n const bannerHandleRef = useRef<BannerHandleValue>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n // Upon adding/removing rows in Advanced mode, update the logic string to reflect the change in labels\n // NOTE: The input is updated only if the previous logicString was simple enough\n const updateLogicString = (actionType: string): void => {\n const numNewRows =\n actionType === INSERT_ROW ? conditionRows.length + 1 : conditionRows.length - 1;\n\n // If only one row left after the action, simply use its label as logicString\n // NOTE: If none left, the rowsReducer adds a new empty row\n if (numNewRows <= 1) {\n setLogicString('1');\n return;\n }\n\n // If the previous string was a simple AND/OR between all the rows, update the logicString to follow the same for the new list of rows.\n // If the previous string was a single token like `1` and a new row is inserted, do an AND between the new rows, i.e. `1 AND 2`\n // For all other complex cases, skip automatically updating the string and wait for the user to change it\n // To check this, split the previous string by `OR/AND` and check if each of the resultant token is a simple numeric token\n const splitter = logicString.includes('OR') ? 'OR' : 'AND';\n const tokens = logicString.split(splitter);\n const isEveryTokenInteger = tokens.every(w => /^\\d+$/.test(w.trim()));\n if (isEveryTokenInteger) {\n setLogicString(\n new Array(numNewRows)\n .fill(0)\n .map((w, i) => i + 1)\n .join(` ${splitter} `)\n );\n }\n };\n\n // Manages the focus behavior when inserting/removing a row\n useEffect(() => {\n if (focusRowIndex === null) return;\n\n if (newOperatorButtonRef.current) {\n newOperatorButtonRef.current.focus();\n newOperatorButtonRef.current = null;\n } else if (focusRowIndex !== null) {\n getFocusables(focusRowRef)[0]?.focus();\n }\n\n setFocusRowIndex(null);\n }, [focusRowIndex]);\n\n // Insert a new row at the given index\n const insertRow = (insertAt: number): void => {\n dispatch({ type: INSERT_ROW, payload: { insertAt } }); // Insert an entry in conditionRows\n if (isBasicMode) {\n // Set up a new AND/OR selector\n const insertOpAt = insertAt - 1; // Using `insertAt-1` since the operatorsList has one less entry compared to the conditionRows\n setOperatorsList([\n ...operatorsList.slice(0, insertOpAt),\n 'AND',\n ...operatorsList.slice(insertOpAt)\n ]);\n } else {\n updateLogicString(INSERT_ROW); // Update the logicString input to reflect the insertion\n }\n setFocusRowIndex(insertAt);\n };\n\n // Remove the row at the given index\n const removeRow = (removeAt: number): void => {\n dispatch({ type: REMOVE_ROW, payload: { removeAt } }); // Remove an entry in conditionRows\n if (isBasicMode) {\n // Remove an AND/OR selector\n if (removeAt === 0) {\n // If removing the first of the condition rows, remove the extraneous operator\n setOperatorsList(operatorsList.slice(1));\n } else {\n let removeOpAt = removeAt - 1; // Using `removeAt-1` since the operatorsList has one less entry compared to the conditionRows\n if (operatorsList[removeOpAt] === 'OR' && operatorsList[removeOpAt + 1] === 'AND') {\n // If removing a condition at the start of a nested group, remove the first operator from that group. e.g. Take `(1 AND 2) OR (3 AND 4 AND 5)`. If `3` is being deleted, it should become `(1 AND 2) OR (4 AND 5)` instead of `1 AND 2 AND 4 AND 5`\n removeOpAt += 1;\n }\n setOperatorsList([\n ...operatorsList.slice(0, removeOpAt),\n ...operatorsList.slice(removeOpAt + 1)\n ]);\n }\n } else {\n updateLogicString(REMOVE_ROW); // Update the logicString input to reflect the removal\n }\n setFocusRowIndex(() => {\n if (removeAt !== 0 && removeAt === conditionRows.length - 1) {\n return removeAt - 1;\n }\n\n return removeAt;\n });\n };\n\n // Update a Basic-mode operator at the given index\n const updateOperator = (updateAt: number, newValue: 'AND' | 'OR'): void => {\n setOperatorsList([\n ...operatorsList.slice(0, updateAt),\n newValue,\n ...operatorsList.slice(updateAt + 1)\n ]);\n };\n\n // Validate the logic input. Called upon clicking outside the textBox or upon submission.\n // If the expression is invalid, shows appropriate feedback and returns null.\n // If the expression is valid, formats it by setting up brackets at necessary places (to clear any ambiguities e.g. `1 AND 2 OR 3` is formatted as `(1 AND 2) OR 3` ). Returns a save-ready condition\n const validateLogicString = (logicToUse: string): Condition | null => {\n // Set up a lookup with row-labels as keys and rows as values\n const conditionLookup: { [label: string]: LeafCondition } = {};\n conditionRows.forEach(row => {\n const { id, label, ...leaf } = row; // Discard the extra properties added by ConditionRow to the LeafCondition interface\n conditionLookup[row.label] = leaf;\n });\n\n // Convert the logic string into a condition tree\n const parseResult = parseLogicString(logicToUse, conditionLookup, disallowNOT);\n\n // Indicate any parse error\n if (hasProp(parseResult, 'error')) {\n setLogicError(parseResult.error);\n return null;\n }\n\n // If no errors\n setLogicError(null); // Clear any previous error\n setLogicString(disambiguateLogic(logicToUse)); // Disambiguating the logic string by placing parentheses at appropriate places\n return parseResult.condition;\n };\n\n // Toggle between the Basic and Advanced modes\n // `forceToggle:true` is passed when switching from Advanced to Basic mode despite a loss of information\n const toggleMode = (forceToggle?: boolean): void => {\n setModeWarning(false); // Clear any previous warning\n if (isBasicMode) {\n // Update the logicString to match the operatorsList before switching the mode\n setLogicString(getLogicFromBasicMode(operatorsList));\n setBasicMode(false);\n } else if (forceToggle) {\n // If forcibly toggling from Advanced to Basic despite a loss of operators\n // Set up the default `AND` operator between all rows before switching to Basic mode\n setOperatorsList(new Array(conditionRows.length - 1).fill('AND'));\n setBasicMode(true);\n } else {\n // If switching from Advanced mode\n const condition = validateLogicString(logicString); // Validate the logicString. If it is an invalid, an appropriate error is shown for the user to act on\n if (condition !== null) {\n // If it's a valid condition, check if it's simple enough to be shown in Basic mode without any loss of information\n if (isBasicModeApplicable(condition)) {\n // If the logic is simple enough, identify the new set of operators before switching to Basic mode\n setOperatorsList(getBasicModeOperators(logicString));\n setBasicMode(true);\n } else {\n // If the logic is too complex show a warning for the user to act on\n setModeWarning(true);\n }\n }\n }\n };\n\n const getCondition: HandleValue['getCondition'] = () => {\n setErrorIndicators(false); // Reset any previous flag\n setLogicError(null); // Clear any previous error\n\n // If there's a single empty condition, submit with an `undefined` value (useful for clearing a previous condition)\n if (conditionRows.length === 1 && conditionRows[0].lhs.field === '') {\n return [true, undefined];\n }\n\n // Identify and indicate any invalid values in the condition rows\n const hasInvalidRows = conditionRows.some(row => !isValidCondition(row, fields, true));\n if (hasInvalidRows) {\n setErrorIndicators(true); // Enable inline error indications\n return [false];\n }\n\n // Validate the Logic string\n const logicToUse = isBasicMode ? getLogicFromBasicMode(operatorsList) : logicString; // If in Basic-mode, construct a different logicString based on the operatorsList\n const condition = validateLogicString(logicToUse); // This also takes care of showing an appropriate error feedback as needed\n if (condition !== null) {\n // Can be null when the logic string has errors\n return [true, condition];\n }\n\n return [false];\n };\n\n useImperativeHandle(\n handle,\n () => ({\n getCondition\n }),\n [getCondition]\n );\n\n const t = useI18n();\n\n useEffect(() => {\n if (showModeWarning) bannerHandleRef.current?.focus();\n }, [showModeWarning]);\n\n const { announceAssertive } = useLiveLog();\n\n useEffect(() => {\n announceAssertive({ message: t('condition_builder_mode_switch') });\n }, [isBasicMode]);\n\n return (\n <StyledConditionBuilder container={{ direction: 'column', gap: 4 }}>\n {/* Condition Rows */}\n <div>\n {conditionRows.map(({ id, label, ...leaf }, index) => {\n const deleteAriaLabel = `${t('condition_builder_field_label')} ${leaf.lhs.field\n .split('.')\n .pop()}`;\n\n let alignItems = 'end';\n if (showErrorIndicators && !isValidCondition(leaf, fields, false)) {\n alignItems = 'center';\n }\n\n return (\n <Fragment key={id}>\n {/* Row with the operator dropdown in Basic mode */}\n {isBasicMode && index > 0 && (\n <StyledRowWithSeparator\n container\n shaded={enableShading && operatorsList[index - 1] === 'AND'}\n >\n <MenuButton\n popover={{ hideOnTargetHidden: false }}\n text={operatorsList[index - 1].toLowerCase()}\n variant='simple'\n menu={{\n items: [\n {\n id: 'AND',\n primary: 'and',\n onClick: () => updateOperator(index - 1, 'AND')\n },\n {\n id: 'OR',\n primary: 'or',\n onClick: () => updateOperator(index - 1, 'OR')\n }\n ]\n }}\n ref={index === focusRowIndex ? newOperatorButtonRef : null}\n />\n </StyledRowWithSeparator>\n )}\n\n {/* Row with the AtomicCondition */}\n <StyledRow\n container={{ gap: 0.5, alignItems }}\n shaded={isBasicMode && enableShading}\n ref={index === focusRowIndex ? focusRowRef : null}\n >\n {/* Label */}\n {!isBasicMode && <StyledLabel>{label}</StyledLabel>}\n\n {/* Condition controls */}\n <Flex item={{ grow: 1 }}>\n <AtomicCondition\n condition={leaf}\n fields={fields}\n indicateErrors={showErrorIndicators}\n validComparators={validComparators}\n dateFunctions={dateFunctions}\n onChange={(newCondition: LeafCondition) => {\n const newRow = { id, label, ...newCondition };\n dispatch({ type: UPDATE_ROW, payload: { updateAt: index, newRow } });\n }}\n validRhsTypes={validRhsTypes}\n />\n </Flex>\n\n {/* Row actions */}\n <Button\n icon\n variant='simple'\n onClick={() => insertRow(index + 1)}\n label={t('add_condition')}\n >\n <Icon name='plus' />\n </Button>\n <Button\n icon\n variant='simple'\n onClick={() => removeRow(index)}\n label={t('delete')}\n aria-label={deleteAriaLabel ? t('delete_noun', [deleteAriaLabel]) : undefined}\n >\n <Icon name='trash' />\n </Button>\n </StyledRow>\n </Fragment>\n );\n })}\n </div>\n\n {/* LogicString input */}\n {!isBasicMode && (\n <div>\n <Flex container={{ gap: 0.25, direction: 'column' }}>\n <Flex container={{ alignItems: 'center' }}>\n <Label htmlFor={labelId}>\n {t('condition_builder_advanced_condition_label')} \n </Label>\n\n <AdditionalInfo heading={t('condition_builder_advanced_condition_label')}>\n {t('condition_builder_advanced_condition_tooltip', [\n disallowNOT ? 'AND/OR' : 'AND/OR/NOT',\n disallowNOT ? '(1 OR 2) AND (3 OR 4 OR 5)' : '(1 AND 2) OR (3 AND NOT 4)'\n ])}\n </AdditionalInfo>\n </Flex>\n\n <Input\n id={labelId}\n type='text'\n placeholder={t('condition_builder_advanced_condition_placeholder')}\n value={logicString}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setLogicString(e.target.value)}\n onBlur={() => validateLogicString(logicString)}\n status={logicError !== null ? 'error' : undefined}\n info={logicError}\n />\n </Flex>\n </div>\n )}\n\n {/* Submit block */}\n <Flex container={{ direction: 'column', gap: 2 }}>\n {/* Banner to show a warning when switching from Advanced to Basic mode */}\n {showModeWarning && (\n <Banner\n variant='warning'\n messages={[\n {\n label: t('condition_builder_switch_banner_text'),\n action: {\n text: t('condition_builder_confirm_button_label'),\n onClick: () => {\n toggleMode(true);\n buttonRef.current?.focus();\n }\n }\n }\n ]}\n onDismiss={() => {\n setModeWarning(false);\n buttonRef.current?.focus();\n }}\n handle={bannerHandleRef}\n />\n )}\n\n {/* Footer buttons */}\n <Flex container={{ justify: 'between' }}>\n <Button\n name='mode-switch'\n variant='simple'\n onClick={() => {\n toggleMode(false);\n }}\n aria-label={\n isBasicMode\n ? t('condition_builder_advanced_mode_button_aria_label')\n : t('condition_builder_basic_mode_button_aria_label')\n }\n ref={buttonRef}\n >\n {isBasicMode\n ? t('condition_builder_advanced_mode_button_label')\n : t('condition_builder_basic_mode_button_label')}\n </Button>\n </Flex>\n </Flex>\n </StyledConditionBuilder>\n );\n};\nConditionBuilder.defaultProps = defaultProps;\n\nexport default ConditionBuilder;\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const StyledConditionBuilder: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").FlexProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
2
|
-
export declare const StyledRow: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").FlexProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
-
export declare const StyledTimePeriodContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
-
export declare const StyledRowWithSeparator: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").FlexProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
5
|
-
export declare const StyledLabel: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
6
|
-
export declare const StyledAtomicCondition: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").FieldGroupProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
7
|
-
//# sourceMappingURL=ConditionBuilder.styles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionBuilder.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.styles.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,sBAAsB,mOAYlC,CAAC;AAKF,eAAO,MAAM,SAAS,mOAGrB,CAAC;AAIF,eAAO,MAAM,yBAAyB,yGAIpC,CAAC;AAKH,eAAO,MAAM,sBAAsB,mOAUlC,CAAC;AAKF,eAAO,MAAM,WAAW,yGAOvB,CAAC;AAIF,eAAO,MAAM,qBAAqB,yOAoBjC,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components';
|
|
2
|
-
import { calculateFontSize, defaultThemeProp, FieldGroup, Flex, StyledFieldGroupLegend, StyledPopover } from '@pega/cosmos-react-core';
|
|
3
|
-
import { StyledDialog } from '@pega/cosmos-react-core/lib/components/Dialog/Dialog.styles';
|
|
4
|
-
export const StyledConditionBuilder = styled(Flex)(({ theme: { base: { 'content-width': contentWidth, spacing } } }) => {
|
|
5
|
-
return css `
|
|
6
|
-
${StyledPopover}:not(${StyledDialog}) & {
|
|
7
|
-
min-width: min(${contentWidth.lg}, calc(100vw - 4 * ${spacing}));
|
|
8
|
-
}
|
|
9
|
-
`;
|
|
10
|
-
});
|
|
11
|
-
StyledConditionBuilder.defaultProps = defaultThemeProp;
|
|
12
|
-
// Styled wrapper for each Condition row
|
|
13
|
-
export const StyledRow = styled(Flex) `
|
|
14
|
-
padding: 0.25rem;
|
|
15
|
-
background: ${props => (props.shaded ? 'rgba(0, 0, 0, 0.05)' : 'transparent')};
|
|
16
|
-
`;
|
|
17
|
-
StyledRow.defaultProps = defaultThemeProp;
|
|
18
|
-
export const StyledTimePeriodContainer = styled.div(({ theme }) => {
|
|
19
|
-
return css `
|
|
20
|
-
width: ${theme.base['content-width'].sm};
|
|
21
|
-
`;
|
|
22
|
-
});
|
|
23
|
-
StyledTimePeriodContainer.defaultProps = defaultThemeProp;
|
|
24
|
-
// Styled row-separators for Basic-mode
|
|
25
|
-
export const StyledRowWithSeparator = styled(StyledRow) `
|
|
26
|
-
padding: 0 0.25rem;
|
|
27
|
-
&::after {
|
|
28
|
-
content: '';
|
|
29
|
-
flex-grow: 1;
|
|
30
|
-
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.2) 60%, rgba(0, 0, 0, 0) 0%);
|
|
31
|
-
background-position: left center;
|
|
32
|
-
background-size: 1.75rem 0.0625rem;
|
|
33
|
-
background-repeat: repeat-x;
|
|
34
|
-
}
|
|
35
|
-
`;
|
|
36
|
-
StyledRowWithSeparator.defaultProps = defaultThemeProp;
|
|
37
|
-
// Styled label for the rows in Advanced-mode
|
|
38
|
-
export const StyledLabel = styled.div `
|
|
39
|
-
line-height: 2rem;
|
|
40
|
-
height: 2rem;
|
|
41
|
-
width: 2rem;
|
|
42
|
-
min-width: 2rem;
|
|
43
|
-
text-align: center;
|
|
44
|
-
background: rgba(0, 0, 0, 0.04);
|
|
45
|
-
`;
|
|
46
|
-
StyledLabel.defaultProps = defaultThemeProp;
|
|
47
|
-
export const StyledAtomicCondition = styled(FieldGroup)(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, spacing }, components: { text } }, collapsed }) => {
|
|
48
|
-
const fontSizes = calculateFontSize(fontSize, fontScale);
|
|
49
|
-
return (!collapsed &&
|
|
50
|
-
css `
|
|
51
|
-
${StyledFieldGroupLegend} {
|
|
52
|
-
font-size: ${fontSizes[text.secondary['font-size']]};
|
|
53
|
-
font-weight: ${text.secondary['font-weight']};
|
|
54
|
-
margin-block-end: calc(0.5 * ${spacing});
|
|
55
|
-
}
|
|
56
|
-
`);
|
|
57
|
-
});
|
|
58
|
-
StyledAtomicCondition.defaultProps = defaultThemeProp;
|
|
59
|
-
//# sourceMappingURL=ConditionBuilder.styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionBuilder.styles.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,IAAI,EAEJ,sBAAsB,EACtB,aAAa,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,6DAA6D,CAAC;AAE3F,MAAM,C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,EACL,IAAI,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,EACjE,UAAU,EAAE,EAAE,IAAI,EAAE,EACrB,EACD,SAAS,EACV,EAAE,EAAE;IACH,MAAM,SAAS,GAAG,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACzD,OAAO,CACL,CAAC,SAAS;QACV,GAAG,CAAA;UACC,sBAAsB;uBACT,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAa,CAAC;yBAChD,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;yCACb,OAAO;;OAEzC,CACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport {\n calculateFontSize,\n defaultThemeProp,\n FieldGroup,\n Flex,\n FontSize,\n StyledFieldGroupLegend,\n StyledPopover\n} from '@pega/cosmos-react-core';\nimport { StyledDialog } from '@pega/cosmos-react-core/lib/components/Dialog/Dialog.styles';\n\nexport const StyledConditionBuilder = styled(Flex)(\n ({\n theme: {\n base: { 'content-width': contentWidth, spacing }\n }\n }) => {\n return css`\n ${StyledPopover}:not(${StyledDialog}) & {\n min-width: min(${contentWidth.lg}, calc(100vw - 4 * ${spacing}));\n }\n `;\n }\n);\n\nStyledConditionBuilder.defaultProps = defaultThemeProp;\n\n// Styled wrapper for each Condition row\nexport const StyledRow = styled(Flex)`\n padding: 0.25rem;\n background: ${props => (props.shaded ? 'rgba(0, 0, 0, 0.05)' : 'transparent')};\n`;\n\nStyledRow.defaultProps = defaultThemeProp;\n\nexport const StyledTimePeriodContainer = styled.div(({ theme }) => {\n return css`\n width: ${theme.base['content-width'].sm};\n `;\n});\n\nStyledTimePeriodContainer.defaultProps = defaultThemeProp;\n\n// Styled row-separators for Basic-mode\nexport const StyledRowWithSeparator = styled(StyledRow)`\n padding: 0 0.25rem;\n &::after {\n content: '';\n flex-grow: 1;\n background-image: linear-gradient(to right, rgba(0, 0, 0, 0.2) 60%, rgba(0, 0, 0, 0) 0%);\n background-position: left center;\n background-size: 1.75rem 0.0625rem;\n background-repeat: repeat-x;\n }\n`;\n\nStyledRowWithSeparator.defaultProps = defaultThemeProp;\n\n// Styled label for the rows in Advanced-mode\nexport const StyledLabel = styled.div`\n line-height: 2rem;\n height: 2rem;\n width: 2rem;\n min-width: 2rem;\n text-align: center;\n background: rgba(0, 0, 0, 0.04);\n`;\n\nStyledLabel.defaultProps = defaultThemeProp;\n\nexport const StyledAtomicCondition = styled(FieldGroup)(\n ({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { text }\n },\n collapsed\n }) => {\n const fontSizes = calculateFontSize(fontSize, fontScale);\n return (\n !collapsed &&\n css`\n ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.secondary['font-size'] as FontSize]};\n font-weight: ${text.secondary['font-weight']};\n margin-block-end: calc(0.5 * ${spacing});\n }\n `\n );\n }\n);\n\nStyledAtomicCondition.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'react';
|
|
2
|
-
import type { BaseProps, NoChildrenProp, MenuItemProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { FieldType, Comparator, ComparatorsByType, DateFunction, RHSType, TimePeriod, DatePart } from './core/types';
|
|
4
|
-
/** RHS object with a Date function */
|
|
5
|
-
export interface RhsWithDateFunction {
|
|
6
|
-
/**
|
|
7
|
-
* Output format for the value varies based on the dateFunction:
|
|
8
|
-
* YEARS: First day of year as YYYY-MM-DD
|
|
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
|
-
* MINUTES: YYYY-MM-DDTHH:mm:ss
|
|
15
|
-
* SECONDS: YYYY-MM-DDTHH:mm:ss
|
|
16
|
-
* HOURS_OF_DAY: 0-23
|
|
17
|
-
* MONTHS_OF_YEAR: 1-12
|
|
18
|
-
* DAYS_OF_MONTH: 1-31
|
|
19
|
-
* DAYS_OF_WEEK: 1-7
|
|
20
|
-
*/
|
|
21
|
-
value: string | number;
|
|
22
|
-
dateFunction: DateFunction;
|
|
23
|
-
}
|
|
24
|
-
/** RHS object with a Relative Date */
|
|
25
|
-
export interface RhsWithRelativeDate {
|
|
26
|
-
relativeDate: {
|
|
27
|
-
timePeriod: TimePeriod;
|
|
28
|
-
interval?: number;
|
|
29
|
-
datePart: DatePart;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/** RHS object with PARAMETER type */
|
|
33
|
-
export interface RhsWithParameter {
|
|
34
|
-
parameterId: string;
|
|
35
|
-
}
|
|
36
|
-
/** Type definition for the leaf-level nodes in nested conditions */
|
|
37
|
-
export interface LeafCondition {
|
|
38
|
-
comparator: Comparator;
|
|
39
|
-
lhs: {
|
|
40
|
-
field: string;
|
|
41
|
-
};
|
|
42
|
-
rhs?: {
|
|
43
|
-
field: string;
|
|
44
|
-
} | {
|
|
45
|
-
value: string | number;
|
|
46
|
-
} | {
|
|
47
|
-
values: string[] | number[];
|
|
48
|
-
} | {
|
|
49
|
-
start: string | number;
|
|
50
|
-
end: string | number;
|
|
51
|
-
} | RhsWithDateFunction | RhsWithRelativeDate | RhsWithParameter;
|
|
52
|
-
}
|
|
53
|
-
/** Type definition for objects representing condition-rows in the builder UI */
|
|
54
|
-
export interface ConditionRow extends LeafCondition {
|
|
55
|
-
id: string;
|
|
56
|
-
label: string;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Type definition for simple/complex conditions
|
|
60
|
-
* At a given node in the condition tree, it can have exactly one of the keys AND/OR/NOT/condition
|
|
61
|
-
*/
|
|
62
|
-
export type Condition = {
|
|
63
|
-
AND: Condition[];
|
|
64
|
-
} | {
|
|
65
|
-
OR: Condition[];
|
|
66
|
-
} | {
|
|
67
|
-
NOT: Condition;
|
|
68
|
-
} | {
|
|
69
|
-
condition: LeafCondition;
|
|
70
|
-
};
|
|
71
|
-
/** Type definition for the input Field objects for the ConditionBuilder */
|
|
72
|
-
export type ParameterValue = Pick<MenuItemProps, 'id' | 'primary'>;
|
|
73
|
-
export type ReferenceValue = Pick<MenuItemProps, 'id' | 'primary'>;
|
|
74
|
-
export type ValueSelection<F> = string[] | ReferenceValue[] | (({ searchString, comparator, lhs }: {
|
|
75
|
-
searchString?: string;
|
|
76
|
-
comparator?: string;
|
|
77
|
-
lhs?: F;
|
|
78
|
-
}) => Promise<string[] | ReferenceValue[]>);
|
|
79
|
-
interface BasicField extends Pick<MenuItemProps, 'id' | 'primary'> {
|
|
80
|
-
}
|
|
81
|
-
export type Field = BasicField & ({
|
|
82
|
-
parameters?: ParameterValue[];
|
|
83
|
-
/**
|
|
84
|
-
* For TEXT fields, if a list of possible values is known ahead of time, they can be passed.
|
|
85
|
-
* Otherwise we fetch data from api and pass a promise which returns list of values
|
|
86
|
-
* This enables users to select from those values instead of manually typing them
|
|
87
|
-
*/
|
|
88
|
-
possibleValues?: ValueSelection<Field>;
|
|
89
|
-
/**
|
|
90
|
-
* Data-type for the field.
|
|
91
|
-
* Has to be one of these values. Convert where necessary
|
|
92
|
-
* e.g. Integer/Decimal/... should be used as `NUMBER`
|
|
93
|
-
* e.g. Text(single value)/Picklist/... should be used as `TEXT`
|
|
94
|
-
*/
|
|
95
|
-
type: FieldType;
|
|
96
|
-
} | {
|
|
97
|
-
/** An array of type Field to represent the child items. */
|
|
98
|
-
items: Field[];
|
|
99
|
-
});
|
|
100
|
-
/** Valid date functions by field type */
|
|
101
|
-
export interface DateFunctionsByType {
|
|
102
|
-
/** Date functions to enable for DATE_TIME fields */
|
|
103
|
-
DATE_TIME: DateFunction[];
|
|
104
|
-
/** Date functions to enable for DATE_ONLY fields */
|
|
105
|
-
DATE_ONLY: DateFunction[];
|
|
106
|
-
}
|
|
107
|
-
export interface HandleValue {
|
|
108
|
-
/**
|
|
109
|
-
* Returns condition validity and condition or undefined if valid.
|
|
110
|
-
* Undefined indicates no condition.
|
|
111
|
-
*/
|
|
112
|
-
getCondition: () => [valid: false] | [valid: true, condition: Condition | undefined];
|
|
113
|
-
}
|
|
114
|
-
/** Type definition for the input props of ConditionBuilder */
|
|
115
|
-
export default interface ConditionBuilderProps extends BaseProps, NoChildrenProp {
|
|
116
|
-
/** Metadata (data-model) for the Fields to use in the builder */
|
|
117
|
-
fields: Field[];
|
|
118
|
-
/** (Optional) A seed condition for the builder. To use when editing an existing condition */
|
|
119
|
-
condition?: Condition;
|
|
120
|
-
/** (Optional) Used to limit the Comparators allowed in the builder. */
|
|
121
|
-
validComparators?: ComparatorsByType[];
|
|
122
|
-
/**
|
|
123
|
-
* (Optional) Pass this to control which all types of RHS are enabled in the component
|
|
124
|
-
* DEFAULT: Set(['LITERAL', 'FIELD'])
|
|
125
|
-
* NOTE: If enabling `DATE_FUNCTION`s, additionally pass a `dateFunctions` prop to specify which functions are enabled
|
|
126
|
-
*/
|
|
127
|
-
validRhsTypes?: Set<RHSType>;
|
|
128
|
-
/** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */
|
|
129
|
-
dateFunctions?: DateFunctionsByType;
|
|
130
|
-
/** (Optional) Pass this if the `NOT` operator should be considered as invalid */
|
|
131
|
-
disallowNOT?: boolean;
|
|
132
|
-
/** Imperative handle for the component. */
|
|
133
|
-
handle?: Ref<HandleValue>;
|
|
134
|
-
}
|
|
135
|
-
export {};
|
|
136
|
-
//# 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":"AAC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AAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;CACtF;AAED,8DAA8D;AAC9D,MAAM,CAAC,OAAO,WAAW,qBAAsB,SAAQ,SAAS,EAAE,cAAc;IAC9E,iEAAiE;IACjE,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,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;IAEtB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAC3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionBuilder.types.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/ConditionBuilder.types.ts"],"names":[],"mappings":"","sourcesContent":["// cspell:words DDTHH\nimport { Ref } from 'react';\n\nimport type { BaseProps, NoChildrenProp, MenuItemProps } 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 * MINUTES: YYYY-MM-DDTHH:mm:ss\n * SECONDS: YYYY-MM-DDTHH:mm:ss\n * HOURS_OF_DAY: 0-23\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/** RHS object with PARAMETER type */\nexport interface RhsWithParameter {\n parameterId: string;\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 | { start: string | number; end: string | number } // When comparing numeric or date field with two values that determine range\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 | RhsWithParameter; // When comparing the LHS with PARAMETER type\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 */\n\nexport type ParameterValue = Pick<MenuItemProps, 'id' | 'primary'>;\n\nexport type ReferenceValue = Pick<MenuItemProps, 'id' | 'primary'>;\n\nexport type ValueSelection<F> =\n | string[]\n | ReferenceValue[]\n | (({\n searchString,\n comparator,\n lhs\n }: {\n searchString?: string;\n comparator?: string;\n lhs?: F;\n }) => Promise<string[] | ReferenceValue[]>);\n\ninterface BasicField extends Pick<MenuItemProps, 'id' | 'primary'> {}\n\nexport type Field = BasicField &\n (\n | {\n parameters?: ParameterValue[];\n\n /**\n * For TEXT fields, if a list of possible values is known ahead of time, they can be passed.\n * Otherwise we fetch data from api and pass a promise which returns list of values\n * This enables users to select from those values instead of manually typing them\n */\n possibleValues?: ValueSelection<Field>;\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 | {\n /** An array of type Field to represent the child items. */\n items: Field[];\n }\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\nexport interface HandleValue {\n /**\n * Returns condition validity and condition or undefined if valid.\n * Undefined indicates no condition.\n */\n getCondition: () => [valid: false] | [valid: true, condition: Condition | undefined];\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 /** (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 /** Imperative handle for the component. */\n handle?: Ref<HandleValue>;\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,EAAiC,MAAM,OAAO,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,mBAAoC,MAAM,wBAAwB,CAAC;AAI1E,kEAAkE;AAClE,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CA0DzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useImperativeHandle, useState } from 'react';
|
|
3
|
-
import AtomicCondition, { getInitConditionForLhs, isValidCondition } from './AtomicCondition';
|
|
4
|
-
/** Component for building an atomic condition on a given field */
|
|
5
|
-
const FieldCondition = (props) => {
|
|
6
|
-
const { targetField, fields, condition: seedCondition, validComparators, validRhsTypes = new Set(['LITERAL', 'FIELD']), dateFunctions, handle } = props;
|
|
7
|
-
const [condition, setCondition] = useState(
|
|
8
|
-
// If editing use the seedCondition, otherwise, determine an initial condition based on the targetField
|
|
9
|
-
() => seedCondition ||
|
|
10
|
-
getInitConditionForLhs({ field: targetField }, fields, validRhsTypes, validComparators, dateFunctions));
|
|
11
|
-
const [showErrorIndicators, setErrorIndicators] = useState(false); // Used to enable inline error indicators on the controls
|
|
12
|
-
const getCondition = () => {
|
|
13
|
-
setErrorIndicators(false);
|
|
14
|
-
if (isValidCondition(condition, fields, true)) {
|
|
15
|
-
return [true, condition];
|
|
16
|
-
}
|
|
17
|
-
setErrorIndicators(true);
|
|
18
|
-
return [false];
|
|
19
|
-
};
|
|
20
|
-
useImperativeHandle(handle, () => ({
|
|
21
|
-
getCondition
|
|
22
|
-
}), [getCondition]);
|
|
23
|
-
return (_jsx(AtomicCondition, { condition: condition, fields: fields, indicateErrors: showErrorIndicators, validComparators: validComparators, dateFunctions: dateFunctions, onChange: c => setCondition(c), itemDirection: 'column', validRhsTypes: validRhsTypes, lhsMode: 'label' }));
|
|
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,mBAAmB,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAKzE,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,SAAS,EAAE,aAAa,EACxB,gBAAgB,EAChB,aAAa,GAAG,IAAI,GAAG,CAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,EACtD,aAAa,EACb,MAAM,EACP,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;IAE5H,MAAM,YAAY,GAAgC,GAAG,EAAE;QACrD,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAE1B,IAAI,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;YAC7C,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;SAC1B;QAED,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC,CAAC;IAEF,mBAAmB,CACjB,MAAM,EACN,GAAG,EAAE,CAAC,CAAC;QACL,YAAY;KACb,CAAC,EACF,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,OAAO,CACL,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,OAAO,EAAC,OAAO,GACf,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FunctionComponent, useImperativeHandle, useState } from 'react';\n\nimport { ForwardProps } from '@pega/cosmos-react-core';\n\nimport FieldConditionProps, { HandleValue } 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 condition: seedCondition,\n validComparators,\n validRhsTypes = new Set<RHSType>(['LITERAL', 'FIELD']),\n dateFunctions,\n handle\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\n const getCondition: HandleValue['getCondition'] = () => {\n setErrorIndicators(false);\n\n if (isValidCondition(condition, fields, true)) {\n return [true, condition];\n }\n\n setErrorIndicators(true);\n return [false];\n };\n\n useImperativeHandle(\n handle,\n () => ({\n getCondition\n }),\n [getCondition]\n );\n\n return (\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 lhsMode='label'\n />\n );\n};\n\nexport default FieldCondition;\n"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'react';
|
|
2
|
-
import { BaseProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { ComparatorsByType, RHSType } from './core/types';
|
|
4
|
-
import { Field, LeafCondition, DateFunctionsByType } from './ConditionBuilder.types';
|
|
5
|
-
export interface HandleValue {
|
|
6
|
-
/** Returns condition validity and condition if valid. */
|
|
7
|
-
getCondition: () => [valid: false] | [valid: true, condition: LeafCondition];
|
|
8
|
-
}
|
|
9
|
-
/** Type definition for the input props of FieldCondition */
|
|
10
|
-
export default interface FieldConditionProps extends BaseProps {
|
|
11
|
-
/** Id of the field on which the condition should be constructed */
|
|
12
|
-
targetField: Field['id'];
|
|
13
|
-
/** Metadata (data-model) for the Fields to use in the RHS field-selector etc. */
|
|
14
|
-
fields: Field[];
|
|
15
|
-
/** (Optional) Passed when editing an existing condition */
|
|
16
|
-
condition?: LeafCondition;
|
|
17
|
-
/** (Optional) Used to limit the Comparators allowed in the component. */
|
|
18
|
-
validComparators?: ComparatorsByType[];
|
|
19
|
-
/**
|
|
20
|
-
* (Optional) Pass this to control which all types of RHS are enabled in the component
|
|
21
|
-
* DEFAULT: Set(['LITERAL', 'FIELD'])
|
|
22
|
-
* NOTE: If enabling `DATE_FUNCTION`s, additionally pass a `dateFunctions` prop to specify which functions are enabled
|
|
23
|
-
*/
|
|
24
|
-
validRhsTypes?: Set<RHSType>;
|
|
25
|
-
/** (Optional) When enabling 'DATE_FUNCTION's via `validRhsTypes`, pass this to specify which all date functions are applicable per field type */
|
|
26
|
-
dateFunctions?: DateFunctionsByType;
|
|
27
|
-
/** Imperative handle for the component. */
|
|
28
|
-
handle?: Ref<HandleValue>;
|
|
29
|
-
}
|
|
30
|
-
//# 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,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,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,MAAM,WAAW,WAAW;IAC1B,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;CAC9E;AAED,4DAA4D;AAC5D,MAAM,CAAC,OAAO,WAAW,mBAAoB,SAAQ,SAAS;IAC5D,mEAAmE;IACnE,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEzB,iFAAiF;IACjF,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,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;IAEpC,2CAA2C;IAC3C,MAAM,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAC3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FieldCondition.types.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/FieldCondition.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref } from 'react';\n\nimport { BaseProps } from '@pega/cosmos-react-core';\n\nimport { ComparatorsByType, RHSType } from './core/types';\nimport { Field, LeafCondition, DateFunctionsByType } from './ConditionBuilder.types';\n\nexport interface HandleValue {\n /** Returns condition validity and condition if valid. */\n getCondition: () => [valid: false] | [valid: true, condition: LeafCondition];\n}\n\n/** Type definition for the input props of FieldCondition */\nexport default interface FieldConditionProps extends BaseProps {\n /** Id of the field on which the condition should be constructed */\n targetField: Field['id'];\n\n /** Metadata (data-model) for the Fields to use in the RHS field-selector etc. */\n fields: Field[];\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 /** Imperative handle for the component. */\n handle?: Ref<HandleValue>;\n}\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,EAKf,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAqC7C,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+M7E,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
// cspell:words DDTHH
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
import { Select, Option, MonthInput, WeekInput, DateInput, DateTimeInput, NumberInput, DayOfWeekInput, useI18n, useConfiguration, QuarterInput, range, ComboBox, menuHelpers } 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
|
-
const mm = date.getUTCMinutes().toString().padStart(2, '0');
|
|
22
|
-
const ss = date.getUTCSeconds().toString().padStart(2, '0');
|
|
23
|
-
switch (dateFunction) {
|
|
24
|
-
case 'QUARTERS':
|
|
25
|
-
case 'MONTHS':
|
|
26
|
-
return `${YYYY}-${MM}-01`;
|
|
27
|
-
case 'WEEKS':
|
|
28
|
-
case 'DAYS':
|
|
29
|
-
return `${YYYY}-${MM}-${DD}`;
|
|
30
|
-
case 'MINUTES':
|
|
31
|
-
return `${YYYY}-${MM}-${DD}T${HH}:${mm}:00`;
|
|
32
|
-
case 'SECONDS':
|
|
33
|
-
return `${YYYY}-${MM}-${DD}T${HH}:${mm}:${ss}`;
|
|
34
|
-
default:
|
|
35
|
-
return `${YYYY}-${MM}-${DD}T${HH}:00:00`; // HOURS
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/** A menu with controls to select a Time period value on RHS */
|
|
39
|
-
const DateFunctionMenu = (props) => {
|
|
40
|
-
const { rhs, onChange, dateFunctionsList, status } = props;
|
|
41
|
-
const { locale } = useConfiguration();
|
|
42
|
-
const t = useI18n();
|
|
43
|
-
// Options for the Date-function selector
|
|
44
|
-
const dateFunctionOptions = useMemo(() => {
|
|
45
|
-
const dateFunctionLabels = {
|
|
46
|
-
YEARS: t('condition_builder_year'),
|
|
47
|
-
QUARTERS: t('condition_builder_quarter'),
|
|
48
|
-
MONTHS: t('condition_builder_month'),
|
|
49
|
-
WEEKS: t('condition_builder_week'),
|
|
50
|
-
DAYS: t('condition_builder_day'),
|
|
51
|
-
HOURS: t('condition_builder_hour'),
|
|
52
|
-
MINUTES: t('condition_builder_minute'),
|
|
53
|
-
SECONDS: t('condition_builder_second'),
|
|
54
|
-
HOURS_OF_DAY: t('condition_builder_date_function_hour_of_day'),
|
|
55
|
-
MONTHS_OF_YEAR: t('condition_builder_date_function_month_of_year'),
|
|
56
|
-
DAYS_OF_MONTH: t('condition_builder_date_function_day_of_month'),
|
|
57
|
-
DAYS_OF_WEEK: t('condition_builder_date_function_day_of_week')
|
|
58
|
-
};
|
|
59
|
-
return dateFunctionsList.map(func => ({ id: func, label: dateFunctionLabels[func] }));
|
|
60
|
-
}, [dateFunctionsList, t]);
|
|
61
|
-
// Handle changes to the Date-function selector
|
|
62
|
-
const handleDatePartChange = (e) => {
|
|
63
|
-
const selection = e.target.value;
|
|
64
|
-
onChange({ dateFunction: selection, value: '' });
|
|
65
|
-
};
|
|
66
|
-
// Common props for all value controls
|
|
67
|
-
const valueComponentProps = {
|
|
68
|
-
value: rhs.value === '' ? undefined : rhs.value.toString(),
|
|
69
|
-
label: t('condition_builder_value_label'),
|
|
70
|
-
status,
|
|
71
|
-
info: status ? t('condition_builder_invalid_value') : undefined
|
|
72
|
-
};
|
|
73
|
-
// Props for all functions that use a component from the DateTime package
|
|
74
|
-
const dateComponentProps = {
|
|
75
|
-
...valueComponentProps,
|
|
76
|
-
onChange: ({ valueAsISOString, state }) => {
|
|
77
|
-
// NOTE: Not relying fully on `state` since in some cases state and valueAsTimestamp are both undefined
|
|
78
|
-
if (valueAsISOString === undefined || state === 'incomplete' || state === 'invalid')
|
|
79
|
-
return;
|
|
80
|
-
// Format the value as per spec and return
|
|
81
|
-
onChange({ ...rhs, value: formatDateFunctionValue(valueAsISOString, rhs.dateFunction) });
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
// HOURS_OF_DAY
|
|
85
|
-
const hoursOfDayItems = useMemo(() => range(0, 23).map(i => {
|
|
86
|
-
const index = i.toString();
|
|
87
|
-
return {
|
|
88
|
-
id: index,
|
|
89
|
-
primary: `${index.toString().padStart(2, '0')}:00`,
|
|
90
|
-
selected: rhs.value === i
|
|
91
|
-
};
|
|
92
|
-
}), [rhs.value]);
|
|
93
|
-
const hoursOfDaySelected = useMemo(() => {
|
|
94
|
-
return menuHelpers.getSelected(hoursOfDayItems)[0];
|
|
95
|
-
}, [hoursOfDayItems]);
|
|
96
|
-
const hourOfDayProps = {
|
|
97
|
-
...valueComponentProps,
|
|
98
|
-
value: `${rhs.value.toString().padStart(2, '0')}:00`,
|
|
99
|
-
mode: 'single-select',
|
|
100
|
-
menu: {
|
|
101
|
-
items: hoursOfDayItems,
|
|
102
|
-
onItemClick: id => {
|
|
103
|
-
onChange({ ...rhs, value: Number(id) });
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
selected: hoursOfDaySelected
|
|
107
|
-
? {
|
|
108
|
-
items: {
|
|
109
|
-
id: hoursOfDaySelected.id,
|
|
110
|
-
text: hoursOfDaySelected.primary
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
: undefined
|
|
114
|
-
};
|
|
115
|
-
// YEARS
|
|
116
|
-
const yearOptions = useMemo(() => {
|
|
117
|
-
const currentYear = new Date().getFullYear();
|
|
118
|
-
const years = range(currentYear - 10, currentYear + 10);
|
|
119
|
-
return years.map(year => ({
|
|
120
|
-
id: `${year}-01-01`,
|
|
121
|
-
label: new Date(year, 0, 1).toLocaleString(locale, { year: 'numeric' })
|
|
122
|
-
}));
|
|
123
|
-
}, [locale]);
|
|
124
|
-
const onYearChange = (e) => {
|
|
125
|
-
onChange({ ...rhs, value: e.target.value });
|
|
126
|
-
};
|
|
127
|
-
// MONTHS_OF_YEAR
|
|
128
|
-
const monthOfYearOptions = useMemo(() => range(1, 12).map(n => ({
|
|
129
|
-
id: `${n}`,
|
|
130
|
-
label: new Date(2021, n - 1, 1).toLocaleString(locale, { month: 'long' })
|
|
131
|
-
})), [locale]);
|
|
132
|
-
const onMonthOfYearChange = (e) => {
|
|
133
|
-
const value = e.target.value ? Number(e.target.value) : '';
|
|
134
|
-
onChange({ ...rhs, value });
|
|
135
|
-
};
|
|
136
|
-
// DAYS_OF_MONTH
|
|
137
|
-
const onDayOfMonthChange = (value) => {
|
|
138
|
-
let newValue = value;
|
|
139
|
-
if (newValue !== '') {
|
|
140
|
-
newValue = Number(newValue);
|
|
141
|
-
if (newValue > 31)
|
|
142
|
-
newValue = 31;
|
|
143
|
-
if (newValue < 1)
|
|
144
|
-
newValue = 1;
|
|
145
|
-
}
|
|
146
|
-
onChange({ ...rhs, value: newValue });
|
|
147
|
-
};
|
|
148
|
-
// DAYS_OF_WEEK
|
|
149
|
-
const onDayOfWeekChange = (value) => {
|
|
150
|
-
onChange({ ...rhs, value });
|
|
151
|
-
};
|
|
152
|
-
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))) }), rhs.dateFunction === 'YEARS' && (_jsxs(Select, { ...valueComponentProps, onChange: onYearChange, name: 'year-selector', children: [_jsx(Option, { children: " " }), yearOptions.map(o => (_jsx(Option, { value: o.id, children: o.label }, o.id)))] })), rhs.dateFunction === 'QUARTERS' && _jsx(QuarterInput, { ...dateComponentProps }), rhs.dateFunction === 'MONTHS' && _jsx(MonthInput, { ...dateComponentProps }), rhs.dateFunction === 'WEEKS' && _jsx(WeekInput, { ...dateComponentProps }), rhs.dateFunction === 'DAYS' && _jsx(DateInput, { ...dateComponentProps }), rhs.dateFunction === 'HOURS' && (_jsx(DateTimeInput, { ...dateComponentProps, pickerInterval: 60 })), rhs.dateFunction === 'MINUTES' && (_jsx(DateTimeInput, { ...dateComponentProps, pickerInterval: 60 })), rhs.dateFunction === 'SECONDS' && (_jsx(DateTimeInput, { ...dateComponentProps, pickerInterval: 60, withSeconds: true })), rhs.dateFunction === 'HOURS_OF_DAY' && _jsx(ComboBox, { ...hourOfDayProps }), rhs.dateFunction === 'MONTHS_OF_YEAR' && (_jsxs(Select, { ...valueComponentProps, onChange: onMonthOfYearChange, name: 'month-of-year-selector', children: [_jsx(Option, { children: " " }), monthOfYearOptions.map(o => (_jsx(Option, { value: o.id, children: o.label }, o.id)))] })), rhs.dateFunction === 'DAYS_OF_MONTH' && (_jsx(NumberInput, { ...valueComponentProps, placeholder: '1 - 31', min: 1, max: 31, step: 1, showDecimal: false, onChange: onDayOfMonthChange })), rhs.dateFunction === 'DAYS_OF_WEEK' && (_jsx(DayOfWeekInput, { ...valueComponentProps, value: rhs.value, onChange: onDayOfWeekChange }))] }));
|
|
153
|
-
};
|
|
154
|
-
export default DateFunctionMenu;
|
|
155
|
-
//# sourceMappingURL=DateFunctionMenu.js.map
|