@pega/cosmos-react-build 3.0.0-dev.27.1 → 3.0.0-dev.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.d.ts +8 -0
  2. package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.d.ts.map +1 -0
  3. package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.js +100 -0
  4. package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.js.map +1 -0
  5. package/lib/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.d.ts +13 -0
  6. package/lib/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.d.ts.map +1 -0
  7. package/lib/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.js +27 -0
  8. package/lib/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.js.map +1 -0
  9. package/lib/components/ExpressionBuilder/ExpressionBuilder.d.ts.map +1 -1
  10. package/lib/components/ExpressionBuilder/ExpressionBuilder.js +16 -42
  11. package/lib/components/ExpressionBuilder/ExpressionBuilder.js.map +1 -1
  12. package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.d.ts +3 -1
  13. package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.d.ts.map +1 -1
  14. package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.js +474 -9
  15. package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.js.map +1 -1
  16. package/lib/components/ExpressionBuilder/ExpressionBuilder.types.d.ts +33 -3
  17. package/lib/components/ExpressionBuilder/ExpressionBuilder.types.d.ts.map +1 -1
  18. package/lib/components/ExpressionBuilder/ExpressionBuilder.types.js.map +1 -1
  19. package/lib/components/ExpressionBuilder/ExpressionBuilderContext.d.ts +7 -0
  20. package/lib/components/ExpressionBuilder/ExpressionBuilderContext.d.ts.map +1 -0
  21. package/lib/components/ExpressionBuilder/ExpressionBuilderContext.js +6 -0
  22. package/lib/components/ExpressionBuilder/ExpressionBuilderContext.js.map +1 -0
  23. package/lib/components/ExpressionBuilder/ExpressionItem.d.ts.map +1 -1
  24. package/lib/components/ExpressionBuilder/ExpressionItem.js +22 -6
  25. package/lib/components/ExpressionBuilder/ExpressionItem.js.map +1 -1
  26. package/lib/components/ExpressionBuilder/index.d.ts +2 -1
  27. package/lib/components/ExpressionBuilder/index.d.ts.map +1 -1
  28. package/lib/components/ExpressionBuilder/index.js +1 -0
  29. package/lib/components/ExpressionBuilder/index.js.map +1 -1
  30. package/package.json +6 -3
@@ -0,0 +1,8 @@
1
+ import { FunctionComponent } from 'react';
2
+ import 'codemirror/addon/edit/closebrackets';
3
+ import 'codemirror/addon/hint/show-hint.js';
4
+ import { ForwardProps } from '@pega/cosmos-react-core';
5
+ import { CodeEditorProps } from '../ExpressionBuilder.types';
6
+ declare const CodeEditor: FunctionComponent<CodeEditorProps & ForwardProps>;
7
+ export default CodeEditor;
8
+ //# sourceMappingURL=CodeEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAGf,OAAO,qCAAqC,CAAC;AAC7C,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAkC,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvF,OAAO,EAEL,eAAe,EAGhB,MAAM,4BAA4B,CAAC;AAqCpC,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,GAAG,YAAY,CAoFjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,100 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // cSpell:words unfocus
3
+ import { forwardRef, useRef, useState, useEffect, useImperativeHandle } from 'react';
4
+ import { Controlled as ReactCodeMirror } from 'react-codemirror2';
5
+ import { showHint, defineMode } from 'codemirror';
6
+ import 'codemirror/addon/edit/closebrackets';
7
+ import 'codemirror/addon/hint/show-hint.js';
8
+ import { useConsolidatedRef, useElement } from '@pega/cosmos-react-core';
9
+ import { StyledCodeEditor } from '../ExpressionBuilder.styles';
10
+ import getCodeSuggestions from './getCodeSuggestions';
11
+ const defaultConfigOptions = {
12
+ lineWrapping: true,
13
+ smartIndent: true,
14
+ autoCloseTags: true,
15
+ matchBrackets: true,
16
+ autoCloseBrackets: true
17
+ };
18
+ defineMode('expression', () => {
19
+ const currTokens = [
20
+ {
21
+ token: /[a-zA-Z_$]*[.]+[a-zA-Z_$][a-zA-Z\d_$]*/i,
22
+ style: 'ex-properties'
23
+ },
24
+ {
25
+ token: /(^[@]+)(\([\w.-]+:[\w.-]+\))*([\w.]+)(\s*)/i,
26
+ style: 'ex-functions'
27
+ }
28
+ ];
29
+ return {
30
+ token(stream) {
31
+ for (let i = 0; i < currTokens.length; i += 1) {
32
+ if (stream.match('#') || stream.match('//'))
33
+ stream.skipToEnd();
34
+ else if (stream.match(currTokens[i].token))
35
+ return currTokens[i].style;
36
+ }
37
+ stream.next();
38
+ return null;
39
+ }
40
+ };
41
+ });
42
+ const CodeEditor = forwardRef(({ fetchSuggestions, autoCompleteTriggers, editorConfigProps, codeEditorHandle, defaultValue = '', ...props }, ref) => {
43
+ const [value, setCode] = useState(defaultValue);
44
+ const [suggestions, setList] = useState([]);
45
+ const [codeMirror, setCodeMirror] = useState(null);
46
+ const [codeEditorContainer, setCodeEditorContainer] = useElement();
47
+ const codeEditorConsolidatedRef = useConsolidatedRef(setCodeEditorContainer, ref);
48
+ const mounted = useRef(false);
49
+ useImperativeHandle(codeEditorHandle, () => ({
50
+ insertText: (text) => {
51
+ if (codeMirror) {
52
+ const cur = codeMirror.getCursor();
53
+ codeMirror.replaceRange(text, cur);
54
+ }
55
+ },
56
+ getValue: () => {
57
+ return codeMirror?.getValue();
58
+ }
59
+ }), [codeMirror]);
60
+ const autoComplete = (codeEditor) => {
61
+ const hintOptions = {
62
+ completeSingle: false,
63
+ completeOnSingleClick: true,
64
+ closeOnUnfocus: true,
65
+ suggestions,
66
+ container: codeEditorContainer
67
+ };
68
+ showHint(codeEditor, getCodeSuggestions, hintOptions);
69
+ };
70
+ useEffect(() => {
71
+ if (suggestions.length > 0 && value.length > 0 && codeMirror) {
72
+ autoComplete(codeMirror);
73
+ }
74
+ else {
75
+ codeMirror?.closeHint();
76
+ }
77
+ }, [suggestions]);
78
+ useEffect(() => {
79
+ mounted.current = true;
80
+ return () => {
81
+ mounted.current = false;
82
+ };
83
+ }, []);
84
+ return (_jsx(StyledCodeEditor, { ref: codeEditorConsolidatedRef, ...props, children: _jsx(ReactCodeMirror, { value: value, onBeforeChange: async (editor, _data, textvalue) => {
85
+ setCode(textvalue);
86
+ const currentCursor = editor.getCursor();
87
+ const autoCompleteTrigger = editor.getTokenAt(currentCursor)
88
+ .string;
89
+ if (autoCompleteTriggers?.includes(autoCompleteTrigger) && fetchSuggestions) {
90
+ const newSuggestions = [...(await fetchSuggestions(autoCompleteTrigger))];
91
+ if (mounted.current)
92
+ setList(newSuggestions);
93
+ }
94
+ }, options: { ...defaultConfigOptions, ...editorConfigProps }, editorDidMount: editor => {
95
+ editor.setSize('100%', '100%');
96
+ setCodeMirror(editor);
97
+ } }) }));
98
+ });
99
+ export default CodeEditor;
100
+ //# sourceMappingURL=CodeEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeEditor.js","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.tsx"],"names":[],"mappings":";AAAA,uBAAuB;AACvB,OAAO,EACL,UAAU,EAGV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,mBAAmB,EACpB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAoB,MAAM,YAAY,CAAC;AACpE,OA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,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["// cSpell:words unfocus\nimport {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useRef,\n useState,\n useEffect,\n useImperativeHandle\n} from 'react';\nimport { Controlled as ReactCodeMirror } from 'react-codemirror2';\nimport { showHint, defineMode, Editor, Position } from 'codemirror';\nimport 'codemirror/addon/edit/closebrackets';\nimport 'codemirror/addon/hint/show-hint.js';\n\nimport { useConsolidatedRef, useElement, ForwardProps } from '@pega/cosmos-react-core';\n\nimport {\n AutoCompleteTriggerType,\n CodeEditorProps,\n EditorState,\n SuggestionsType\n} from '../ExpressionBuilder.types';\nimport { StyledCodeEditor } from '../ExpressionBuilder.styles';\n\nimport getCodeSuggestions from './getCodeSuggestions';\n\nconst defaultConfigOptions = {\n lineWrapping: true,\n smartIndent: true,\n autoCloseTags: true,\n matchBrackets: true,\n autoCloseBrackets: true\n};\n\ndefineMode('expression', () => {\n const currTokens = [\n {\n token: /[a-zA-Z_$]*[.]+[a-zA-Z_$][a-zA-Z\\d_$]*/i,\n style: 'ex-properties'\n },\n {\n token: /(^[@]+)(\\([\\w.-]+:[\\w.-]+\\))*([\\w.]+)(\\s*)/i,\n style: 'ex-functions'\n }\n ];\n\n return {\n token(stream) {\n for (let i = 0; i < currTokens.length; i += 1) {\n if (stream.match('#') || stream.match('//')) stream.skipToEnd();\n else if (stream.match(currTokens[i].token)) return currTokens[i].style;\n }\n stream.next();\n return null;\n }\n };\n});\n\nconst CodeEditor: FunctionComponent<CodeEditorProps & ForwardProps> = forwardRef(\n (\n {\n fetchSuggestions,\n autoCompleteTriggers,\n editorConfigProps,\n codeEditorHandle,\n defaultValue = '',\n ...props\n }: PropsWithoutRef<CodeEditorProps>,\n ref: CodeEditorProps['ref']\n ) => {\n const [value, setCode] = useState<string>(defaultValue);\n const [suggestions, setList] = useState<SuggestionsType[]>([]);\n const [codeMirror, setCodeMirror] = useState<Editor | null>(null);\n const [codeEditorContainer, setCodeEditorContainer] = useElement<HTMLDivElement>();\n const codeEditorConsolidatedRef = useConsolidatedRef(setCodeEditorContainer, ref);\n const mounted = useRef(false);\n\n useImperativeHandle<any, EditorState>(\n codeEditorHandle,\n () => ({\n insertText: (text: string) => {\n if (codeMirror) {\n const cur: Position = codeMirror.getCursor();\n codeMirror.replaceRange(text, cur);\n }\n },\n getValue: () => {\n return codeMirror?.getValue();\n }\n }),\n [codeMirror]\n );\n\n const autoComplete = (codeEditor: Editor) => {\n const hintOptions = {\n completeSingle: false,\n completeOnSingleClick: true,\n closeOnUnfocus: true,\n suggestions,\n container: codeEditorContainer\n };\n showHint(codeEditor, getCodeSuggestions, hintOptions);\n };\n\n useEffect(() => {\n if (suggestions.length > 0 && value.length > 0 && codeMirror) {\n autoComplete(codeMirror);\n } else {\n codeMirror?.closeHint();\n }\n }, [suggestions]);\n\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n return (\n <StyledCodeEditor ref={codeEditorConsolidatedRef} {...props}>\n <ReactCodeMirror\n value={value}\n onBeforeChange={async (editor, _data, textvalue) => {\n setCode(textvalue);\n const currentCursor = editor.getCursor();\n const autoCompleteTrigger = editor.getTokenAt(currentCursor)\n .string as AutoCompleteTriggerType;\n if (autoCompleteTriggers?.includes(autoCompleteTrigger) && fetchSuggestions) {\n const newSuggestions = [...(await fetchSuggestions(autoCompleteTrigger))];\n if (mounted.current) setList(newSuggestions);\n }\n }}\n options={{ ...defaultConfigOptions, ...editorConfigProps }}\n editorDidMount={editor => {\n editor.setSize('100%', '100%');\n setCodeMirror(editor);\n }}\n />\n </StyledCodeEditor>\n );\n }\n);\n\nexport default CodeEditor;\n"]}
@@ -0,0 +1,13 @@
1
+ import { Editor, Hint, Hints } from 'codemirror';
2
+ import { EditorHintOptions } from '../ExpressionBuilder.types';
3
+ declare const getCodeSuggestions: (codeMirror: Editor, options: EditorHintOptions) => {
4
+ list: {
5
+ text: string;
6
+ displayText: string;
7
+ render: (Element: HTMLLIElement, _self: Hints, data: Hint) => void;
8
+ }[];
9
+ from: import("codemirror").Position;
10
+ to: import("codemirror").Position;
11
+ };
12
+ export default getCodeSuggestions;
13
+ //# sourceMappingURL=getCodeSuggestions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCodeSuggestions.d.ts","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAO,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,QAAA,MAAM,kBAAkB,eAAgB,MAAM,WAAW,iBAAiB;;;;0BAUlD,aAAa,SAAS,KAAK,QAAQ,IAAI;;;;CAe9D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { Pos } from 'codemirror';
2
+ const getCodeSuggestions = (codeMirror, options) => {
3
+ const { suggestions = [] } = options;
4
+ const curPos = codeMirror.getCursor();
5
+ const token = codeMirror.getTokenAt(curPos);
6
+ token.end = curPos.ch;
7
+ const suggestionsList = suggestions.map(hint => {
8
+ return {
9
+ text: hint.value,
10
+ displayText: hint.label,
11
+ render: (Element, _self, data) => {
12
+ const itemDiv = document.createElement('div');
13
+ const labelSpan = document.createElement('span');
14
+ labelSpan.textContent = data.text;
15
+ itemDiv.appendChild(labelSpan);
16
+ Element.appendChild(itemDiv);
17
+ }
18
+ };
19
+ });
20
+ return {
21
+ list: suggestionsList,
22
+ from: Pos(curPos.line, token.start),
23
+ to: Pos(curPos.line, token.end)
24
+ };
25
+ };
26
+ export default getCodeSuggestions;
27
+ //# sourceMappingURL=getCodeSuggestions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCodeSuggestions.js","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,GAAG,EA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codeMirror: Editor, options: EditorHintOptions) => {\n const { suggestions = [] } = options;\n const curPos = codeMirror.getCursor();\n const token = codeMirror.getTokenAt(curPos);\n token.end = curPos.ch;\n\n const suggestionsList = suggestions.map(hint => {\n return {\n text: hint.value,\n displayText: hint.label,\n render: (Element: HTMLLIElement, _self: Hints, data: Hint) => {\n const itemDiv = document.createElement('div');\n const labelSpan = document.createElement('span');\n labelSpan.textContent = data.text;\n itemDiv.appendChild(labelSpan);\n Element.appendChild(itemDiv);\n }\n };\n });\n\n return {\n list: suggestionsList,\n from: Pos(curPos.line, token.start),\n to: Pos(curPos.line, token.end)\n };\n};\n\nexport default getCodeSuggestions;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpressionBuilder.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,YAAY,EAKb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAuB,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAIxF,QAAA,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,sBAAsB,GAAG,YAAY,CAiI/E,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"ExpressionBuilder.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,YAAY,EAIb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAEL,sBAAsB,EAEvB,MAAM,2BAA2B,CAAC;AAMnC,QAAA,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,sBAAsB,GAAG,YAAY,CAqG/E,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,56 +1,28 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
3
- import { Flex, SearchInput, TextArea, useI18n, VisuallyHiddenText } from '@pega/cosmos-react-core';
2
+ import { forwardRef, useImperativeHandle, useMemo, useRef } from 'react';
3
+ import { Flex, SearchInput, useI18n, VisuallyHiddenText } from '@pega/cosmos-react-core';
4
4
  import ExpressionList from './ExpressionList';
5
- import { StyledExpressionBuilder, StyledExpressionEditor } from './ExpressionBuilder.styles';
6
- const ExpressionBuilder = forwardRef(({ list, search, errors, defaultValue, handle, ...restProps }, ref) => {
5
+ import { StyledExpressionBuilder, StyledCodeEditor } from './ExpressionBuilder.styles';
6
+ import CodeEditor from './CodeEditor/CodeEditor';
7
+ import ExpressionBuilderContext from './ExpressionBuilderContext';
8
+ const ExpressionBuilder = forwardRef(({ list, search, errors, defaultValue, handle, fetchSuggestions, ...restProps }, ref) => {
7
9
  const t = useI18n();
8
- const textArea = useRef();
9
- const [selection, setSelection] = useState({
10
- start: 0,
11
- end: 0
12
- });
10
+ const codeEditorHandle = useRef(null);
13
11
  const getExpression = () => {
14
- return textArea.current?.value || '';
12
+ return codeEditorHandle.current?.getValue() || '';
15
13
  };
16
14
  useImperativeHandle(handle, () => ({
17
15
  getExpression
18
16
  }), [getExpression]);
19
17
  const addExpression = (expression) => {
20
- if (!textArea.current)
21
- return;
22
- const currentValue = textArea.current.value;
23
- const newValue = `${currentValue.slice(0, selection.start)}${expression}${currentValue.slice(selection.end)}`;
24
- textArea.current.value = newValue;
25
- setSelection(prev => {
26
- return { start: prev.start + expression.length, end: prev.start + expression.length };
27
- });
28
- };
29
- const onBlur = () => {
30
- if (!textArea.current)
31
- return;
32
- const lastIndex = textArea.current.value.length >= 0 ? textArea.current.value.length : 0;
33
- const selectionStart = textArea.current.selectionStart === null ? lastIndex : textArea.current.selectionStart;
34
- const selectionEnd = textArea.current.selectionEnd === null ? lastIndex : textArea.current.selectionEnd;
35
- const currentSelection = {
36
- start: selectionStart,
37
- end: selectionEnd
38
- };
39
- if (selectionStart > selectionEnd) {
40
- currentSelection.start = selectionEnd;
41
- currentSelection.end = selectionStart;
42
- }
43
- setSelection(currentSelection);
18
+ codeEditorHandle.current?.insertText(expression);
44
19
  };
45
20
  const onItemAdd = (id) => {
46
21
  list.onItemAdd(id, addExpression);
47
22
  };
48
- useEffect(() => {
49
- if (defaultValue && textArea.current) {
50
- setSelection({ start: defaultValue.length, end: defaultValue.length });
51
- textArea.current.value = defaultValue;
52
- }
53
- }, []);
23
+ const ctxValue = useMemo(() => ({
24
+ accent: search.accent
25
+ }), [search.accent]);
54
26
  return (_jsxs(Flex, { ...restProps, as: StyledExpressionBuilder, ref: ref, container: {
55
27
  justify: 'between',
56
28
  colGap: 2,
@@ -64,13 +36,15 @@ const ExpressionBuilder = forwardRef(({ list, search, errors, defaultValue, hand
64
36
  }, item: {
65
37
  grow: 1,
66
38
  basis: '50%'
67
- }, children: [_jsx(SearchInput, { ...search }), _jsx(ExpressionList, { ...list, onItemAdd: onItemAdd })] }), _jsx(Flex, { as: StyledExpressionEditor, container: {
39
+ }, children: [_jsx(SearchInput, { ...search }), _jsx(ExpressionBuilderContext.Provider, { value: ctxValue, children: _jsx(ExpressionList, { ...list, onItemAdd: onItemAdd }) })] }), _jsx(Flex, { as: StyledCodeEditor, container: {
68
40
  direction: 'column',
69
41
  justify: 'between'
70
42
  }, item: {
71
43
  grow: 1,
72
44
  basis: '50%'
73
- }, children: _jsx(TextArea, { status: errors ? 'error' : undefined, ref: textArea, onBlur: onBlur, label: t('expression_editor'), labelHidden: true, info: errors }) })] }));
45
+ }, children: _jsx(CodeEditor, { fetchSuggestions: fetchSuggestions, codeEditorHandle: codeEditorHandle, autoCompleteTriggers: ['.', '@'], editorConfigProps: {
46
+ mode: 'expression'
47
+ }, defaultValue: defaultValue }) })] }));
74
48
  });
75
49
  export default ExpressionBuilder;
76
50
  //# sourceMappingURL=ExpressionBuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Expression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EAAE;oBACJ,IAAI,EAAE,CAAC;oBACP,KAAK,EAAE,KAAK;iBACb,YAED,KAAC,QAAQ,IACP,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACpC,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,CAAC,CAAC,mBAAmB,CAAC,EAC7B,WAAW,QACX,IAAI,EAAE,MAAM,GACZ,GACG,IACF,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState\n} from 'react';\n\nimport {\n Flex,\n ForwardProps,\n SearchInput,\n TextArea,\n useI18n,\n VisuallyHiddenText\n} from '@pega/cosmos-react-core';\n\nimport { ExpressionItemProps, ExpressionBuilderProps } from './ExpressionBuilder.types';\nimport ExpressionList from './ExpressionList';\nimport { StyledExpressionBuilder, StyledExpressionEditor } from './ExpressionBuilder.styles';\n\nconst ExpressionBuilder: FunctionComponent<ExpressionBuilderProps & ForwardProps> = forwardRef(\n (\n {\n list,\n search,\n errors,\n defaultValue,\n handle,\n ...restProps\n }: PropsWithoutRef<ExpressionBuilderProps>,\n ref: ExpressionBuilderProps['ref']\n ) => {\n const t = useI18n();\n const textArea = useRef<HTMLInputElement>();\n const [selection, setSelection] = useState<{ start: number; end: number }>({\n start: 0,\n end: 0\n });\n\n const getExpression = () => {\n return textArea.current?.value || '';\n };\n\n useImperativeHandle(\n handle,\n () => ({\n getExpression\n }),\n [getExpression]\n );\n\n const addExpression = (expression: string) => {\n if (!textArea.current) return;\n const currentValue = textArea.current.value;\n const newValue = `${currentValue.slice(0, selection.start)}${expression}${currentValue.slice(\n selection.end\n )}`;\n textArea.current.value = newValue;\n setSelection(prev => {\n return { start: prev.start + expression.length, end: prev.start + expression.length };\n });\n };\n\n const onBlur = () => {\n if (!textArea.current) return;\n const lastIndex = textArea.current.value.length >= 0 ? textArea.current.value.length : 0;\n const selectionStart =\n textArea.current.selectionStart === null ? lastIndex : textArea.current.selectionStart;\n const selectionEnd =\n textArea.current.selectionEnd === null ? lastIndex : textArea.current.selectionEnd;\n const currentSelection = {\n start: selectionStart,\n end: selectionEnd\n };\n if (selectionStart > selectionEnd) {\n currentSelection.start = selectionEnd;\n currentSelection.end = selectionStart;\n }\n\n setSelection(currentSelection);\n };\n\n const onItemAdd = (id: ExpressionItemProps['id']) => {\n list.onItemAdd(id, addExpression);\n };\n\n useEffect(() => {\n if (defaultValue && textArea.current) {\n setSelection({ start: defaultValue.length, end: defaultValue.length });\n textArea.current.value = defaultValue;\n }\n }, []);\n\n return (\n <Flex\n {...restProps}\n as={StyledExpressionBuilder}\n ref={ref}\n container={{\n justify: 'between',\n colGap: 2,\n pad: 1\n }}\n item={{\n grow: 1\n }}\n >\n <VisuallyHiddenText aria-live='polite' role='status'>\n {t('results_count', [list.items?.length || 0], { count: list.items?.length || 0 })}\n </VisuallyHiddenText>\n {/* Column 1 */}\n <Flex\n container={{\n direction: 'column',\n justify: 'between',\n gap: 1\n }}\n item={{\n grow: 1,\n basis: '50%'\n }}\n >\n <SearchInput {...search} />\n <ExpressionList {...list} onItemAdd={onItemAdd} />\n </Flex>\n {/* Column 2 */}\n <Flex\n as={StyledExpressionEditor}\n container={{\n direction: 'column',\n justify: 'between'\n }}\n item={{\n grow: 1,\n basis: '50%'\n }}\n >\n <TextArea\n status={errors ? 'error' : undefined}\n ref={textArea}\n onBlur={onBlur}\n label={t('expression_editor')}\n labelHidden\n info={errors}\n />\n </Flex>\n </Flex>\n );\n }\n);\n\nexport default ExpressionBuilder;\n"]}
1
+ {"version":3,"file":"ExpressionBuilder.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,mBAAmB,EACnB,OAAO,EACP,MAAM,EACP,MAAM,OAAO,C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AiB,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useImperativeHandle,\n useMemo,\n useRef\n} from 'react';\n\nimport {\n Flex,\n ForwardProps,\n SearchInput,\n useI18n,\n VisuallyHiddenText\n} from '@pega/cosmos-react-core';\n\nimport {\n ExpressionItemProps,\n ExpressionBuilderProps,\n EditorState\n} from './ExpressionBuilder.types';\nimport ExpressionList from './ExpressionList';\nimport { StyledExpressionBuilder, StyledCodeEditor } from './ExpressionBuilder.styles';\nimport CodeEditor from './CodeEditor/CodeEditor';\nimport ExpressionBuilderContext from './ExpressionBuilderContext';\n\nconst ExpressionBuilder: FunctionComponent<ExpressionBuilderProps & ForwardProps> = forwardRef(\n (\n {\n list,\n search,\n errors,\n defaultValue,\n handle,\n fetchSuggestions,\n ...restProps\n }: PropsWithoutRef<ExpressionBuilderProps>,\n ref: ExpressionBuilderProps['ref']\n ) => {\n const t = useI18n();\n const codeEditorHandle = useRef<EditorState>(null);\n\n const getExpression = () => {\n return codeEditorHandle.current?.getValue() || '';\n };\n\n useImperativeHandle(\n handle,\n () => ({\n getExpression\n }),\n [getExpression]\n );\n\n const addExpression = (expression: string) => {\n codeEditorHandle.current?.insertText(expression);\n };\n const onItemAdd = (id: ExpressionItemProps['id']) => {\n list.onItemAdd(id, addExpression);\n };\n\n const ctxValue = useMemo(\n () => ({\n accent: search.accent\n }),\n [search.accent]\n );\n\n return (\n <Flex\n {...restProps}\n as={StyledExpressionBuilder}\n ref={ref}\n container={{\n justify: 'between',\n colGap: 2,\n pad: 1\n }}\n item={{\n grow: 1\n }}\n >\n <VisuallyHiddenText aria-live='polite' role='status'>\n {t('results_count', [list.items?.length || 0], { count: list.items?.length || 0 })}\n </VisuallyHiddenText>\n {/* Column 1 */}\n <Flex\n container={{\n direction: 'column',\n justify: 'between',\n gap: 1\n }}\n item={{\n grow: 1,\n basis: '50%'\n }}\n >\n <SearchInput {...search} />\n <ExpressionBuilderContext.Provider value={ctxValue}>\n <ExpressionList {...list} onItemAdd={onItemAdd} />\n </ExpressionBuilderContext.Provider>\n </Flex>\n {/* Column 2 */}\n <Flex\n as={StyledCodeEditor}\n container={{\n direction: 'column',\n justify: 'between'\n }}\n item={{\n grow: 1,\n basis: '50%'\n }}\n >\n <CodeEditor\n fetchSuggestions={fetchSuggestions}\n codeEditorHandle={codeEditorHandle}\n autoCompleteTriggers={['.', '@']}\n editorConfigProps={{\n mode: 'expression'\n }}\n defaultValue={defaultValue}\n />\n </Flex>\n </Flex>\n );\n }\n);\n\nexport default ExpressionBuilder;\n"]}
@@ -1,8 +1,9 @@
1
+ /// <reference types="react" />
1
2
  import { ExpressionItemProps } from './ExpressionBuilder.types';
3
+ export declare const StyledPrimaryText: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").TextProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
2
4
  export declare const StyledExpressionSummary: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
5
  export declare const StyledExpressionList: import("styled-components").StyledComponent<"ul", import("styled-components").DefaultTheme, {}, never>;
4
6
  export declare const StyledExpressionBuilder: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
5
- export declare const StyledExpressionEditor: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
6
7
  export declare const StyledParamsGroup: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
7
8
  export declare const StyledInputParamsGroup: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
8
9
  export declare const StyledExpressionDetails: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -10,4 +11,5 @@ export declare const StyledExpandCollapseContent: import("styled-components").St
10
11
  export declare const StyledExpressionItem: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, {
11
12
  expanded: ExpressionItemProps['expanded'];
12
13
  }, never>;
14
+ export declare const StyledCodeEditor: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
13
15
  //# sourceMappingURL=ExpressionBuilder.styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpressionBuilder.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.styles.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,eAAO,MAAM,uBAAuB,yGAKlC,CAAC;AAIH,eAAO,MAAM,oBAAoB,wGAIhC,CAAC;AAEF,eAAO,MAAM,uBAAuB,yGAYlC,CAAC;AAIH,eAAO,MAAM,sBAAsB,yGAMjC,CAAC;AAEH,eAAO,MAAM,iBAAiB,yGAQ5B,CAAC;AAIH,eAAO,MAAM,sBAAsB,yGAIjC,CAAC;AAIH,eAAO,MAAM,uBAAuB,yGAAe,CAAC;AAIpD,eAAO,MAAM,2BAA2B,yGAQtC,CAAC;AAIH,eAAO,MAAM,oBAAoB;cACrB,mBAAmB,CAAC,UAAU,CAAC;SAkBzC,CAAC"}
1
+ {"version":3,"file":"ExpressionBuilder.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.styles.ts"],"names":[],"mappings":";AAYA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,eAAO,MAAM,iBAAiB,mOAE7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,yGAKlC,CAAC;AAIH,eAAO,MAAM,oBAAoB,wGAIhC,CAAC;AAEF,eAAO,MAAM,uBAAuB,yGAalC,CAAC;AAIH,eAAO,MAAM,iBAAiB,yGAQ5B,CAAC;AAIH,eAAO,MAAM,sBAAsB,yGAIjC,CAAC;AAIH,eAAO,MAAM,uBAAuB,yGAAe,CAAC;AAIpD,eAAO,MAAM,2BAA2B,yGAQtC,CAAC;AAIH,eAAO,MAAM,oBAAoB;cACrB,mBAAmB,CAAC,UAAU,CAAC;SAuBzC,CAAC;AAIH,eAAO,MAAM,gBAAgB,yGA6c3B,CAAC"}
@@ -1,7 +1,10 @@
1
+ // cSpell:words vscrollbar hscrollbar
1
2
  import styled, { css } from 'styled-components';
2
- import { defaultThemeProp, StyledButton, StyledText } from '@pega/cosmos-react-core';
3
+ import { defaultThemeProp, StyledButton, StyledLabel, StyledText, Text } from '@pega/cosmos-react-core';
3
4
  import StyledTextArea from '@pega/cosmos-react-core/lib/components/TextArea/TextArea.styles';
4
- import { StyledFormField } from '@pega/cosmos-react-core/lib/components/FormField/FormField';
5
+ export const StyledPrimaryText = styled(Text) `
6
+ word-break: break-word;
7
+ `;
5
8
  export const StyledExpressionSummary = styled.div(({ theme }) => {
6
9
  return css `
7
10
  padding-block: ${theme.base.spacing};
@@ -16,6 +19,7 @@ export const StyledExpressionList = styled.ul `
16
19
  `;
17
20
  export const StyledExpressionBuilder = styled.div(({ theme }) => {
18
21
  return css `
22
+ position: relative;
19
23
  background-color: ${theme.base.palette['primary-background']};
20
24
  min-height: calc(30 * ${theme.base.spacing});
21
25
  max-height: 100%;
@@ -28,13 +32,6 @@ export const StyledExpressionBuilder = styled.div(({ theme }) => {
28
32
  `;
29
33
  });
30
34
  StyledExpressionBuilder.defaultProps = defaultThemeProp;
31
- export const StyledExpressionEditor = styled.div(() => {
32
- return css `
33
- ${StyledFormField} {
34
- flex-grow: 1;
35
- }
36
- `;
37
- });
38
35
  export const StyledParamsGroup = styled.div(({ theme }) => {
39
36
  return css `
40
37
  margin-block-start: calc(2 * ${theme.base.spacing});
@@ -79,7 +76,475 @@ export const StyledExpressionItem = styled.li(({ theme, expanded }) => {
79
76
  ${StyledExpressionDetails} {
80
77
  padding-block-end: calc(2 * ${theme.base.spacing});
81
78
  }
79
+
80
+ ${StyledLabel} {
81
+ margin-inline-end: calc(0.5 * ${theme.base.spacing});
82
+ color: ${theme.base.palette['foreground-color']};
83
+ }
82
84
  `;
83
85
  });
84
86
  StyledExpressionItem.defaultProps = defaultThemeProp;
87
+ export const StyledCodeEditor = styled.div(({ theme }) => {
88
+ return css `
89
+ /* PADDING */
90
+
91
+ .CodeMirror-lines {
92
+ cursor: text;
93
+ min-height: 0.063rem; /* prevents collapsing before first draw */
94
+ padding: 0.25rem 0; /* Vertical padding around content */
95
+ }
96
+
97
+ .CodeMirror-scrollbar-filler,
98
+ .CodeMirror-gutter-filler {
99
+ background-color: white; /* The little square between H and V scrollbars */
100
+ }
101
+
102
+ /* GUTTER */
103
+
104
+ .CodeMirror-gutters {
105
+ position: absolute;
106
+ left: 0;
107
+ top: 0;
108
+ min-height: 100%;
109
+ z-index: 3;
110
+ border-right: 0.063rem solid #dddddd;
111
+ background-color: #f7f7f7;
112
+ white-space: nowrap;
113
+ }
114
+ .CodeMirror-linenumber {
115
+ padding: 0 0.125rem 0 0.313rem;
116
+ min-width: 1.25rem;
117
+ text-align: right;
118
+ color: #999999;
119
+ white-space: nowrap;
120
+ }
121
+
122
+ .CodeMirror-guttermarker {
123
+ color: black;
124
+ }
125
+ .CodeMirror-guttermarker-subtle {
126
+ color: #999999;
127
+ }
128
+
129
+ /* CURSOR */
130
+
131
+ .CodeMirror-cursor {
132
+ position: absolute;
133
+ pointer-events: none;
134
+ border-left: 0.0625rem solid ${theme.base.palette['border-line']};
135
+ border-right: none;
136
+ width: 0;
137
+ }
138
+
139
+ /* Shown when moving in bi-directional text */
140
+ .CodeMirror div.CodeMirror-secondarycursor {
141
+ border-left: 0.063rem solid silver;
142
+ }
143
+ .cm-fat-cursor-mark {
144
+ background-color: rgba(20, 255, 20, 0.5);
145
+ -webkit-animation: blink 1.06s steps(1) infinite;
146
+ -moz-animation: blink 1.06s steps(1) infinite;
147
+ animation: blink 1.06s steps(1) infinite;
148
+ }
149
+ .cm-animate-fat-cursor {
150
+ width: auto;
151
+ border: 0;
152
+ -webkit-animation: blink 1.06s steps(1) infinite;
153
+ -moz-animation: blink 1.06s steps(1) infinite;
154
+ animation: blink 1.06s steps(1) infinite;
155
+ background-color: #77ee77;
156
+ }
157
+ @-moz-keyframes blink {
158
+ 50% {
159
+ background-color: transparent;
160
+ }
161
+ }
162
+ @-webkit-keyframes blink {
163
+ 50% {
164
+ background-color: transparent;
165
+ }
166
+ }
167
+ @keyframes blink {
168
+ 50% {
169
+ background-color: transparent;
170
+ }
171
+ }
172
+
173
+ .cm-tab {
174
+ display: inline-block;
175
+ text-decoration: inherit;
176
+ }
177
+
178
+ .CodeMirror-rulers {
179
+ position: absolute;
180
+ left: 0;
181
+ right: 0;
182
+ top: -3.125rem;
183
+ bottom: 0;
184
+ overflow: hidden;
185
+ }
186
+ .CodeMirror-ruler {
187
+ border-left: 0.063rem solid #cccccc;
188
+ top: 0;
189
+ bottom: 0;
190
+ position: absolute;
191
+ }
192
+
193
+ /* DEFAULT THEME */
194
+
195
+ .cm-s-default .cm-header {
196
+ color: blue;
197
+ }
198
+ .cm-negative {
199
+ color: #dd4444;
200
+ }
201
+ .cm-positive {
202
+ color: #229922;
203
+ }
204
+ .cm-strong {
205
+ font-weight: bold;
206
+ }
207
+ .cm-s-default .cm-quote {
208
+ color: #009900;
209
+ }
210
+ .cm-em {
211
+ font-style: italic;
212
+ }
213
+ .cm-link {
214
+ text-decoration: underline;
215
+ }
216
+ .cm-strikethrough {
217
+ text-decoration: line-through;
218
+ }
219
+
220
+ .cm-s-default .cm-keyword {
221
+ color: #770088;
222
+ }
223
+ .cm-s-default .cm-atom {
224
+ color: #221199;
225
+ }
226
+ .cm-s-default .cm-number {
227
+ color: #116644;
228
+ }
229
+ .cm-s-default .cm-def {
230
+ color: #0000ff;
231
+ }
232
+ .cm-s-default .cm-variable-2 {
233
+ color: #0055aa;
234
+ }
235
+ .cm-s-default .cm-variable-3,
236
+ .cm-s-default .cm-type {
237
+ color: #008855;
238
+ }
239
+ .cm-s-default .cm-comment {
240
+ color: #aa5500;
241
+ }
242
+ .cm-s-default .cm-string {
243
+ color: #aa1111;
244
+ }
245
+ .cm-s-default .cm-string-2 {
246
+ color: #ff5500;
247
+ }
248
+ .cm-s-default .cm-meta {
249
+ color: #555555;
250
+ }
251
+ .cm-s-default .cm-qualifier {
252
+ color: #555555;
253
+ }
254
+ .cm-s-default .cm-builtin {
255
+ color: #3300aa;
256
+ }
257
+ .cm-s-default .cm-bracket {
258
+ color: #999977;
259
+ }
260
+ .cm-s-default .cm-tag {
261
+ color: #117700;
262
+ }
263
+ .cm-s-default .cm-attribute {
264
+ color: #0000cc;
265
+ }
266
+ .cm-s-default .cm-hr {
267
+ color: #999999;
268
+ }
269
+ .cm-s-default .cm-link {
270
+ color: #0000cc;
271
+ }
272
+
273
+ .cm-s-default .cm-error {
274
+ color: #ff0000;
275
+ }
276
+ .cm-invalidchar {
277
+ color: #ff0000;
278
+ }
279
+
280
+ .CodeMirror-composing {
281
+ border-bottom: 0.125rem solid;
282
+ }
283
+
284
+ /* Default styles for common addons */
285
+
286
+ div.CodeMirror span.CodeMirror-matchingbracket {
287
+ color: #00bb00;
288
+ }
289
+ div.CodeMirror span.CodeMirror-nonmatchingbracket {
290
+ color: #aa2222;
291
+ }
292
+ .CodeMirror-matchingtag {
293
+ background: rgba(255, 150, 0, 0.3);
294
+ }
295
+ .CodeMirror-activeline-background {
296
+ background: #e8f2ff;
297
+ }
298
+
299
+ /* STOP */
300
+
301
+ /* The rest of this file contains styles related to the mechanics of
302
+ the editor. You probably shouldn't touch them. */
303
+
304
+ .CodeMirror-scroll {
305
+ overflow: scroll !important;
306
+ margin-bottom: -3.125rem;
307
+ margin-right: -3.125rem;
308
+ padding-bottom: 3.125rem;
309
+ height: 100%;
310
+ outline: none; /* Prevent dragging from highlighting the element */
311
+ position: relative;
312
+ }
313
+ .CodeMirror-sizer {
314
+ position: relative;
315
+ border-right: 3.125rem solid transparent;
316
+ }
317
+
318
+ /* The fake, visible scrollbars. Used to force redraw during scrolling
319
+ before actual scrolling happens, thus preventing shaking and
320
+ flickering artifacts. */
321
+ .CodeMirror-vscrollbar,
322
+ .CodeMirror-hscrollbar,
323
+ .CodeMirror-scrollbar-filler,
324
+ .CodeMirror-gutter-filler {
325
+ position: absolute;
326
+ z-index: 6;
327
+ display: none;
328
+ }
329
+ .CodeMirror-vscrollbar {
330
+ right: 0;
331
+ top: 0;
332
+ overflow-x: hidden;
333
+ overflow-y: scroll;
334
+ }
335
+ .CodeMirror-hscrollbar {
336
+ bottom: 0;
337
+ left: 0;
338
+ overflow-y: hidden;
339
+ overflow-x: scroll;
340
+ }
341
+ .CodeMirror-scrollbar-filler {
342
+ right: 0;
343
+ bottom: 0;
344
+ }
345
+ .CodeMirror-gutter-filler {
346
+ left: 0;
347
+ bottom: 0;
348
+ }
349
+ .CodeMirror-gutter {
350
+ white-space: normal;
351
+ height: 100%;
352
+ display: inline-block;
353
+ vertical-align: top;
354
+ margin-bottom: -3.125rem;
355
+ }
356
+ .CodeMirror-gutter-wrapper {
357
+ position: absolute;
358
+ z-index: 4;
359
+ background: none !important;
360
+ border: none !important;
361
+ }
362
+ .CodeMirror-gutter-background {
363
+ position: absolute;
364
+ top: 0;
365
+ bottom: 0;
366
+ z-index: 4;
367
+ }
368
+ .CodeMirror-gutter-elt {
369
+ position: absolute;
370
+ cursor: default;
371
+ z-index: 4;
372
+ }
373
+ .CodeMirror-gutter-wrapper ::selection {
374
+ background-color: transparent;
375
+ }
376
+ .CodeMirror-gutter-wrapper ::-moz-selection {
377
+ background-color: transparent;
378
+ }
379
+
380
+ .CodeMirror pre.CodeMirror-line,
381
+ .CodeMirror pre.CodeMirror-line-like {
382
+ /* Reset some styles that the rest of the page might have set */
383
+ -moz-border-radius: 0;
384
+ -webkit-border-radius: 0;
385
+ border-radius: 0;
386
+ border-width: 0;
387
+ background: transparent;
388
+ font-family: inherit;
389
+ font-size: inherit;
390
+ margin: 0;
391
+ white-space: pre;
392
+ word-wrap: normal;
393
+ line-height: inherit;
394
+ color: inherit;
395
+ z-index: 2;
396
+ position: relative;
397
+ overflow: visible;
398
+ -webkit-tap-highlight-color: transparent;
399
+ -webkit-font-variant-ligatures: contextual;
400
+ font-variant-ligatures: contextual;
401
+ }
402
+ .CodeMirror-wrap pre.CodeMirror-line,
403
+ .CodeMirror-wrap pre.CodeMirror-line-like {
404
+ word-wrap: break-word;
405
+ white-space: pre-wrap;
406
+ word-break: normal;
407
+ }
408
+
409
+ .CodeMirror-linebackground {
410
+ position: absolute;
411
+ left: 0;
412
+ right: 0;
413
+ top: 0;
414
+ bottom: 0;
415
+ z-index: 0;
416
+ }
417
+
418
+ .CodeMirror-linewidget {
419
+ position: relative;
420
+ z-index: 2;
421
+ padding: 0.006rem; /* Force widget margins to stay inside of the container */
422
+ }
423
+
424
+ .CodeMirror-rtl pre {
425
+ direction: rtl;
426
+ }
427
+
428
+ .CodeMirror-code {
429
+ outline: none;
430
+ }
431
+
432
+ /* Force content-box sizing for the elements where we expect it */
433
+ .CodeMirror-scroll,
434
+ .CodeMirror-sizer,
435
+ .CodeMirror-gutter,
436
+ .CodeMirror-linenumber {
437
+ -moz-box-sizing: content-box;
438
+ box-sizing: content-box;
439
+ }
440
+
441
+ .CodeMirror-measure {
442
+ position: absolute;
443
+ width: 100%;
444
+ height: 0;
445
+ overflow: hidden;
446
+ visibility: hidden;
447
+ }
448
+
449
+ .CodeMirror-measure pre {
450
+ position: static;
451
+ }
452
+
453
+ div.CodeMirror-dragcursors {
454
+ visibility: visible;
455
+ }
456
+
457
+ .CodeMirror-selected {
458
+ background: #d9d9d9;
459
+ }
460
+ .CodeMirror-focused .CodeMirror-selected {
461
+ background: #d7d4f0;
462
+ }
463
+ .CodeMirror-crosshair {
464
+ cursor: crosshair;
465
+ }
466
+ .CodeMirror-line::selection,
467
+ .CodeMirror-line > span::selection,
468
+ .CodeMirror-line > span > span::selection {
469
+ background: #d7d4f0;
470
+ }
471
+ .CodeMirror-line::-moz-selection,
472
+ .CodeMirror-line > span::-moz-selection,
473
+ .CodeMirror-line > span > span::-moz-selection {
474
+ background: #d7d4f0;
475
+ }
476
+
477
+ .cm-searching {
478
+ background-color: rgba(255, 255, 0, 0.4);
479
+ }
480
+
481
+ /* Used to force a border model for a node */
482
+ .cm-force-border {
483
+ padding-right: 0.006rem;
484
+ }
485
+
486
+ /* See issue #2901 */
487
+ .cm-tab-wrap-hack::after {
488
+ content: '';
489
+ }
490
+
491
+ /* Help users use markselection to safely style text background */
492
+ span.CodeMirror-selectedtext {
493
+ background: none;
494
+ }
495
+
496
+ .CodeMirror {
497
+ overflow: hidden;
498
+ font-family: monospace;
499
+ height: 18.75rem;
500
+ direction: ltr;
501
+ position: absolute;
502
+ background-color: ${theme.base.palette['background-color']};
503
+ color: ${theme.base.palette['foreground-color']};
504
+ max-height: 98%;
505
+ max-width: 49%;
506
+ border: 0.0625rem solid ${theme.base.palette['border-line']};
507
+ border-radius: calc(0.5 * ${theme.base['border-radius']});
508
+ }
509
+ .cm-ex-properties {
510
+ color: ${theme.base.palette.success};
511
+ }
512
+ .cm-ex-functions {
513
+ color: ${theme.base.palette.warn};
514
+ }
515
+ .CodeMirror-hints {
516
+ position: absolute;
517
+ z-index: 10;
518
+ overflow: hidden;
519
+ list-style: none;
520
+ margin: 0;
521
+ padding: 0.125rem;
522
+ -webkit-box-shadow: 0.125rem 0.188rem 0.313rem rgba(0, 0, 0, 0.2);
523
+ -moz-box-shadow: 0.125rem 0.188rem 0.313rem rgba(0, 0, 0, 0.2);
524
+ box-shadow: 0.125rem 0.188rem 0.313rem rgba(0, 0, 0, 0.2);
525
+ border-radius: 0.188rem;
526
+ border: 0.063rem solid silver;
527
+ background: white;
528
+ font-size: 90%;
529
+ font-family: monospace;
530
+ max-height: 20em;
531
+ overflow-y: auto;
532
+ }
533
+
534
+ .CodeMirror-hint {
535
+ margin: 0;
536
+ padding: 0 0.25rem;
537
+ border-radius: 0.125rem;
538
+ white-space: pre;
539
+ color: black;
540
+ cursor: pointer;
541
+ }
542
+
543
+ li.CodeMirror-hint-active {
544
+ background: #0088ff;
545
+ color: white;
546
+ }
547
+ `;
548
+ });
549
+ StyledCodeEditor.defaultProps = defaultThemeProp;
85
550
  //# sourceMappingURL=ExpressionBuilder.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpressionBuilder.styles.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,cAAc,MAAM,iEAAiE,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,4DAA4D,CAAC;AAI7F,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC9D,OAAO,GAAG,CAAA;qBACS,KAAK,CAAC,IAAI,CAAC,OAAO;iCACN,KAAK,CAAC,IAAI,CAAC,OAAO;GAChD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,uBAAuB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAExD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,EAAE,CAAA;;;;CAI5C,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC9D,OAAO,GAAG,CAAA;wBACY,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;4BACpC,KAAK,CAAC,IAAI,CAAC,OAAO;;0BAEpB,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,UAAU,KAAK,CAAC,IAAI,CAAC,OAAO;sBAC9D,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,UAAU,KAAK,CAAC,IAAI,CAAC,OAAO;;MAE1E,cAAc;;;GAGjB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,uBAAuB,CAAC,YAAY,GAAG,gBAAgB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AAQ,EAAE,EAAE,EAAE;IACzB,OAAO,GAAG,CAAA;;wBAEY,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;MAC1D,QAAQ;QACV,GAAG,CAAA;0BACmB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC;KAC/D;;;uCAGkC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;;;MAGlE,uBAAuB;oCACO,KAAK,CAAC,IAAI,CAAC,OAAO;;GAEnD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp, StyledButton, StyledText } from '@pega/cosmos-react-core';\nimport StyledTextArea from '@pega/cosmos-react-core/lib/components/TextArea/TextArea.styles';\nimport { StyledFormField } from '@pega/cosmos-react-core/lib/components/FormField/FormField';\n\nimport { ExpressionItemProps } from './ExpressionBuilder.types';\n\nexport const StyledExpressionSummary = styled.div(({ theme }) => {\n return css`\n padding-block: ${theme.base.spacing};\n padding-inline: calc(0.5 * ${theme.base.spacing});\n `;\n});\n\nStyledExpressionSummary.defaultProps = defaultThemeProp;\n\nexport const StyledExpressionList = styled.ul`\n overflow-y: auto;\n flex-grow: 1;\n list-style: none;\n`;\n\nexport const StyledExpressionBuilder = styled.div(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['primary-background']};\n min-height: calc(30 * ${theme.base.spacing});\n max-height: 100%;\n max-width: calc(2 * ${theme.base['content-width'].lg} + 4 * ${theme.base.spacing});\n min-width: calc(${theme.base['content-width'].lg} + 4 * ${theme.base.spacing});\n\n ${StyledTextArea} {\n flex-grow: 1;\n }\n `;\n});\n\nStyledExpressionBuilder.defaultProps = defaultThemeProp;\n\nexport const StyledExpressionEditor = styled.div(() => {\n return css`\n ${StyledFormField} {\n flex-grow: 1;\n }\n `;\n});\n\nexport const StyledParamsGroup = styled.div(({ theme }) => {\n return css`\n margin-block-start: calc(2 * ${theme.base.spacing});\n\n ${StyledText} {\n margin-block-end: ${theme.base.spacing};\n }\n `;\n});\n\nStyledParamsGroup.defaultProps = defaultThemeProp;\n\nexport const StyledInputParamsGroup = styled(StyledParamsGroup)(({ theme }) => {\n return css`\n max-width: ${theme.base['content-width'].lg};\n `;\n});\n\nStyledInputParamsGroup.defaultProps = defaultThemeProp;\n\nexport const StyledExpressionDetails = styled.div``;\n\nStyledExpressionDetails.defaultProps = defaultThemeProp;\n\nexport const StyledExpandCollapseContent = styled.div(({ theme }) => {\n return css`\n padding-inline: calc(2 * ${theme.base.spacing});\n padding-block-end: calc(2 * ${theme.base.spacing});\n ${StyledButton} {\n align-self: flex-end;\n }\n `;\n});\n\nStyledExpandCollapseContent.defaultProps = defaultThemeProp;\n\nexport const StyledExpressionItem = styled.li<{\n expanded: ExpressionItemProps['expanded'];\n}>(({ theme, expanded }) => {\n return css`\n list-style: none;\n background-color: ${theme.base.palette['primary-background']};\n ${expanded &&\n css`\n background-color: ${theme.base.palette['secondary-background']};\n `}\n\n :not(:last-child) {\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n }\n\n ${StyledExpressionDetails} {\n padding-block-end: calc(2 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledExpressionItem.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"ExpressionBuilder.styles.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.styles.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,IAAI,EACL,MAAM,yBAAyB,CAAC;AACjC,OAAO,cAAc,MAAM,iEAAiE,CAAC;AAI7F,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;CAE5C,CAAC;AAEF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,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACvD,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA8CyB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAgX5C,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;eACjD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;;;gCAGrB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;kCAC/B,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;;;eAG9C,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO;;;eAG1B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCnC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["// cSpell:words vscrollbar hscrollbar\nimport styled, { css } from 'styled-components';\n\nimport {\n defaultThemeProp,\n StyledButton,\n StyledLabel,\n StyledText,\n Text\n} from '@pega/cosmos-react-core';\nimport StyledTextArea from '@pega/cosmos-react-core/lib/components/TextArea/TextArea.styles';\n\nimport { ExpressionItemProps } from './ExpressionBuilder.types';\n\nexport const StyledPrimaryText = styled(Text)`\n word-break: break-word;\n`;\n\nexport const StyledExpressionSummary = styled.div(({ theme }) => {\n return css`\n padding-block: ${theme.base.spacing};\n padding-inline: calc(0.5 * ${theme.base.spacing});\n `;\n});\n\nStyledExpressionSummary.defaultProps = defaultThemeProp;\n\nexport const StyledExpressionList = styled.ul`\n overflow-y: auto;\n flex-grow: 1;\n list-style: none;\n`;\n\nexport const StyledExpressionBuilder = styled.div(({ theme }) => {\n return css`\n position: relative;\n background-color: ${theme.base.palette['primary-background']};\n min-height: calc(30 * ${theme.base.spacing});\n max-height: 100%;\n max-width: calc(2 * ${theme.base['content-width'].lg} + 4 * ${theme.base.spacing});\n min-width: calc(${theme.base['content-width'].lg} + 4 * ${theme.base.spacing});\n\n ${StyledTextArea} {\n flex-grow: 1;\n }\n `;\n});\n\nStyledExpressionBuilder.defaultProps = defaultThemeProp;\n\nexport const StyledParamsGroup = styled.div(({ theme }) => {\n return css`\n margin-block-start: calc(2 * ${theme.base.spacing});\n\n ${StyledText} {\n margin-block-end: ${theme.base.spacing};\n }\n `;\n});\n\nStyledParamsGroup.defaultProps = defaultThemeProp;\n\nexport const StyledInputParamsGroup = styled(StyledParamsGroup)(({ theme }) => {\n return css`\n max-width: ${theme.base['content-width'].lg};\n `;\n});\n\nStyledInputParamsGroup.defaultProps = defaultThemeProp;\n\nexport const StyledExpressionDetails = styled.div``;\n\nStyledExpressionDetails.defaultProps = defaultThemeProp;\n\nexport const StyledExpandCollapseContent = styled.div(({ theme }) => {\n return css`\n padding-inline: calc(2 * ${theme.base.spacing});\n padding-block-end: calc(2 * ${theme.base.spacing});\n ${StyledButton} {\n align-self: flex-end;\n }\n `;\n});\n\nStyledExpandCollapseContent.defaultProps = defaultThemeProp;\n\nexport const StyledExpressionItem = styled.li<{\n expanded: ExpressionItemProps['expanded'];\n}>(({ theme, expanded }) => {\n return css`\n list-style: none;\n background-color: ${theme.base.palette['primary-background']};\n ${expanded &&\n css`\n background-color: ${theme.base.palette['secondary-background']};\n `}\n\n :not(:last-child) {\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n }\n\n ${StyledExpressionDetails} {\n padding-block-end: calc(2 * ${theme.base.spacing});\n }\n\n ${StyledLabel} {\n margin-inline-end: calc(0.5 * ${theme.base.spacing});\n color: ${theme.base.palette['foreground-color']};\n }\n `;\n});\n\nStyledExpressionItem.defaultProps = defaultThemeProp;\n\nexport const StyledCodeEditor = styled.div(({ theme }) => {\n return css`\n /* PADDING */\n\n .CodeMirror-lines {\n cursor: text;\n min-height: 0.063rem; /* prevents collapsing before first draw */\n padding: 0.25rem 0; /* Vertical padding around content */\n }\n\n .CodeMirror-scrollbar-filler,\n .CodeMirror-gutter-filler {\n background-color: white; /* The little square between H and V scrollbars */\n }\n\n /* GUTTER */\n\n .CodeMirror-gutters {\n position: absolute;\n left: 0;\n top: 0;\n min-height: 100%;\n z-index: 3;\n border-right: 0.063rem solid #dddddd;\n background-color: #f7f7f7;\n white-space: nowrap;\n }\n .CodeMirror-linenumber {\n padding: 0 0.125rem 0 0.313rem;\n min-width: 1.25rem;\n text-align: right;\n color: #999999;\n white-space: nowrap;\n }\n\n .CodeMirror-guttermarker {\n color: black;\n }\n .CodeMirror-guttermarker-subtle {\n color: #999999;\n }\n\n /* CURSOR */\n\n .CodeMirror-cursor {\n position: absolute;\n pointer-events: none;\n border-left: 0.0625rem solid ${theme.base.palette['border-line']};\n border-right: none;\n width: 0;\n }\n\n /* Shown when moving in bi-directional text */\n .CodeMirror div.CodeMirror-secondarycursor {\n border-left: 0.063rem solid silver;\n }\n .cm-fat-cursor-mark {\n background-color: rgba(20, 255, 20, 0.5);\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n }\n .cm-animate-fat-cursor {\n width: auto;\n border: 0;\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n background-color: #77ee77;\n }\n @-moz-keyframes blink {\n 50% {\n background-color: transparent;\n }\n }\n @-webkit-keyframes blink {\n 50% {\n background-color: transparent;\n }\n }\n @keyframes blink {\n 50% {\n background-color: transparent;\n }\n }\n\n .cm-tab {\n display: inline-block;\n text-decoration: inherit;\n }\n\n .CodeMirror-rulers {\n position: absolute;\n left: 0;\n right: 0;\n top: -3.125rem;\n bottom: 0;\n overflow: hidden;\n }\n .CodeMirror-ruler {\n border-left: 0.063rem solid #cccccc;\n top: 0;\n bottom: 0;\n position: absolute;\n }\n\n /* DEFAULT THEME */\n\n .cm-s-default .cm-header {\n color: blue;\n }\n .cm-negative {\n color: #dd4444;\n }\n .cm-positive {\n color: #229922;\n }\n .cm-strong {\n font-weight: bold;\n }\n .cm-s-default .cm-quote {\n color: #009900;\n }\n .cm-em {\n font-style: italic;\n }\n .cm-link {\n text-decoration: underline;\n }\n .cm-strikethrough {\n text-decoration: line-through;\n }\n\n .cm-s-default .cm-keyword {\n color: #770088;\n }\n .cm-s-default .cm-atom {\n color: #221199;\n }\n .cm-s-default .cm-number {\n color: #116644;\n }\n .cm-s-default .cm-def {\n color: #0000ff;\n }\n .cm-s-default .cm-variable-2 {\n color: #0055aa;\n }\n .cm-s-default .cm-variable-3,\n .cm-s-default .cm-type {\n color: #008855;\n }\n .cm-s-default .cm-comment {\n color: #aa5500;\n }\n .cm-s-default .cm-string {\n color: #aa1111;\n }\n .cm-s-default .cm-string-2 {\n color: #ff5500;\n }\n .cm-s-default .cm-meta {\n color: #555555;\n }\n .cm-s-default .cm-qualifier {\n color: #555555;\n }\n .cm-s-default .cm-builtin {\n color: #3300aa;\n }\n .cm-s-default .cm-bracket {\n color: #999977;\n }\n .cm-s-default .cm-tag {\n color: #117700;\n }\n .cm-s-default .cm-attribute {\n color: #0000cc;\n }\n .cm-s-default .cm-hr {\n color: #999999;\n }\n .cm-s-default .cm-link {\n color: #0000cc;\n }\n\n .cm-s-default .cm-error {\n color: #ff0000;\n }\n .cm-invalidchar {\n color: #ff0000;\n }\n\n .CodeMirror-composing {\n border-bottom: 0.125rem solid;\n }\n\n /* Default styles for common addons */\n\n div.CodeMirror span.CodeMirror-matchingbracket {\n color: #00bb00;\n }\n div.CodeMirror span.CodeMirror-nonmatchingbracket {\n color: #aa2222;\n }\n .CodeMirror-matchingtag {\n background: rgba(255, 150, 0, 0.3);\n }\n .CodeMirror-activeline-background {\n background: #e8f2ff;\n }\n\n /* STOP */\n\n /* The rest of this file contains styles related to the mechanics of\n the editor. You probably shouldn't touch them. */\n\n .CodeMirror-scroll {\n overflow: scroll !important;\n margin-bottom: -3.125rem;\n margin-right: -3.125rem;\n padding-bottom: 3.125rem;\n height: 100%;\n outline: none; /* Prevent dragging from highlighting the element */\n position: relative;\n }\n .CodeMirror-sizer {\n position: relative;\n border-right: 3.125rem solid transparent;\n }\n\n /* The fake, visible scrollbars. Used to force redraw during scrolling\n before actual scrolling happens, thus preventing shaking and\n flickering artifacts. */\n .CodeMirror-vscrollbar,\n .CodeMirror-hscrollbar,\n .CodeMirror-scrollbar-filler,\n .CodeMirror-gutter-filler {\n position: absolute;\n z-index: 6;\n display: none;\n }\n .CodeMirror-vscrollbar {\n right: 0;\n top: 0;\n overflow-x: hidden;\n overflow-y: scroll;\n }\n .CodeMirror-hscrollbar {\n bottom: 0;\n left: 0;\n overflow-y: hidden;\n overflow-x: scroll;\n }\n .CodeMirror-scrollbar-filler {\n right: 0;\n bottom: 0;\n }\n .CodeMirror-gutter-filler {\n left: 0;\n bottom: 0;\n }\n .CodeMirror-gutter {\n white-space: normal;\n height: 100%;\n display: inline-block;\n vertical-align: top;\n margin-bottom: -3.125rem;\n }\n .CodeMirror-gutter-wrapper {\n position: absolute;\n z-index: 4;\n background: none !important;\n border: none !important;\n }\n .CodeMirror-gutter-background {\n position: absolute;\n top: 0;\n bottom: 0;\n z-index: 4;\n }\n .CodeMirror-gutter-elt {\n position: absolute;\n cursor: default;\n z-index: 4;\n }\n .CodeMirror-gutter-wrapper ::selection {\n background-color: transparent;\n }\n .CodeMirror-gutter-wrapper ::-moz-selection {\n background-color: transparent;\n }\n\n .CodeMirror pre.CodeMirror-line,\n .CodeMirror pre.CodeMirror-line-like {\n /* Reset some styles that the rest of the page might have set */\n -moz-border-radius: 0;\n -webkit-border-radius: 0;\n border-radius: 0;\n border-width: 0;\n background: transparent;\n font-family: inherit;\n font-size: inherit;\n margin: 0;\n white-space: pre;\n word-wrap: normal;\n line-height: inherit;\n color: inherit;\n z-index: 2;\n position: relative;\n overflow: visible;\n -webkit-tap-highlight-color: transparent;\n -webkit-font-variant-ligatures: contextual;\n font-variant-ligatures: contextual;\n }\n .CodeMirror-wrap pre.CodeMirror-line,\n .CodeMirror-wrap pre.CodeMirror-line-like {\n word-wrap: break-word;\n white-space: pre-wrap;\n word-break: normal;\n }\n\n .CodeMirror-linebackground {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n z-index: 0;\n }\n\n .CodeMirror-linewidget {\n position: relative;\n z-index: 2;\n padding: 0.006rem; /* Force widget margins to stay inside of the container */\n }\n\n .CodeMirror-rtl pre {\n direction: rtl;\n }\n\n .CodeMirror-code {\n outline: none;\n }\n\n /* Force content-box sizing for the elements where we expect it */\n .CodeMirror-scroll,\n .CodeMirror-sizer,\n .CodeMirror-gutter,\n .CodeMirror-linenumber {\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n }\n\n .CodeMirror-measure {\n position: absolute;\n width: 100%;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n }\n\n .CodeMirror-measure pre {\n position: static;\n }\n\n div.CodeMirror-dragcursors {\n visibility: visible;\n }\n\n .CodeMirror-selected {\n background: #d9d9d9;\n }\n .CodeMirror-focused .CodeMirror-selected {\n background: #d7d4f0;\n }\n .CodeMirror-crosshair {\n cursor: crosshair;\n }\n .CodeMirror-line::selection,\n .CodeMirror-line > span::selection,\n .CodeMirror-line > span > span::selection {\n background: #d7d4f0;\n }\n .CodeMirror-line::-moz-selection,\n .CodeMirror-line > span::-moz-selection,\n .CodeMirror-line > span > span::-moz-selection {\n background: #d7d4f0;\n }\n\n .cm-searching {\n background-color: rgba(255, 255, 0, 0.4);\n }\n\n /* Used to force a border model for a node */\n .cm-force-border {\n padding-right: 0.006rem;\n }\n\n /* See issue #2901 */\n .cm-tab-wrap-hack::after {\n content: '';\n }\n\n /* Help users use markselection to safely style text background */\n span.CodeMirror-selectedtext {\n background: none;\n }\n\n .CodeMirror {\n overflow: hidden;\n font-family: monospace;\n height: 18.75rem;\n direction: ltr;\n position: absolute;\n background-color: ${theme.base.palette['background-color']};\n color: ${theme.base.palette['foreground-color']};\n max-height: 98%;\n max-width: 49%;\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n }\n .cm-ex-properties {\n color: ${theme.base.palette.success};\n }\n .cm-ex-functions {\n color: ${theme.base.palette.warn};\n }\n .CodeMirror-hints {\n position: absolute;\n z-index: 10;\n overflow: hidden;\n list-style: none;\n margin: 0;\n padding: 0.125rem;\n -webkit-box-shadow: 0.125rem 0.188rem 0.313rem rgba(0, 0, 0, 0.2);\n -moz-box-shadow: 0.125rem 0.188rem 0.313rem rgba(0, 0, 0, 0.2);\n box-shadow: 0.125rem 0.188rem 0.313rem rgba(0, 0, 0, 0.2);\n border-radius: 0.188rem;\n border: 0.063rem solid silver;\n background: white;\n font-size: 90%;\n font-family: monospace;\n max-height: 20em;\n overflow-y: auto;\n }\n\n .CodeMirror-hint {\n margin: 0;\n padding: 0 0.25rem;\n border-radius: 0.125rem;\n white-space: pre;\n color: black;\n cursor: pointer;\n }\n\n li.CodeMirror-hint-active {\n background: #0088ff;\n color: white;\n }\n `;\n});\n\nStyledCodeEditor.defaultProps = defaultThemeProp;\n"]}
@@ -1,5 +1,6 @@
1
1
  import { ComponentType, Ref } from 'react';
2
- import { BaseProps, EmptyStateProps, OmitStrict, SearchInputProps, TextAreaProps, FieldValueListProps } from '@pega/cosmos-react-core';
2
+ import { ShowHintOptions, EditorConfiguration } from 'codemirror';
3
+ import { BaseProps, EmptyStateProps, OmitStrict, SearchInputProps, TextAreaProps, FieldValueListProps, MenuProps } from '@pega/cosmos-react-core';
3
4
  export interface ExpressionItemProps {
4
5
  /** Id of the item */
5
6
  id: string;
@@ -17,6 +18,11 @@ export interface ExpressionItemProps {
17
18
  expanded?: boolean;
18
19
  /** Expression details to show in expanded view */
19
20
  details?: ExpressionDetailsProps;
21
+ /** Matched field to be shown in expression item collapsed mode during search */
22
+ matchedField?: {
23
+ name: string;
24
+ value: string;
25
+ };
20
26
  }
21
27
  export interface ExpressionListProps extends BaseProps {
22
28
  ref?: Ref<HTMLDivElement>;
@@ -39,6 +45,11 @@ export interface HandleValue {
39
45
  /** Returns the expression value */
40
46
  getExpression: () => string;
41
47
  }
48
+ export declare type AutoCompleteTriggerType = '@' | '.';
49
+ export declare type SuggestionsType = {
50
+ label: string;
51
+ value: string;
52
+ };
42
53
  export interface ExpressionBuilderProps extends BaseProps {
43
54
  ref?: Ref<HTMLDivElement>;
44
55
  /** Expression items list */
@@ -46,13 +57,19 @@ export interface ExpressionBuilderProps extends BaseProps {
46
57
  onItemAdd: (id: ExpressionItemProps['id'], addExpression: (expression: string) => void) => void;
47
58
  };
48
59
  /** Search input props */
49
- search: Pick<Required<SearchInputProps>, 'filters' | 'onFilterChange' | 'onSearchChange' | 'value'> & Pick<SearchInputProps, 'defaultFilter'>;
50
- /** Default expression to set in the text area */
60
+ search: Pick<Required<SearchInputProps>, 'filters' | 'onFilterChange' | 'onSearchChange' | 'value'> & Pick<SearchInputProps, 'defaultFilter'> & Pick<MenuProps, 'accent'>;
61
+ /** Default expression to set in the code editor */
51
62
  defaultValue?: string;
52
63
  /** Compiled error message */
53
64
  errors?: TextAreaProps['info'];
54
65
  /** Imperative handle */
55
66
  handle?: Ref<HandleValue>;
67
+ /** Fetches suggestion list for suggestions popover */
68
+ fetchSuggestions?: (autoCompleteTrigger: AutoCompleteTriggerType) => Promise<SuggestionsType[]>;
69
+ /** characters which triggers suggestions */
70
+ autoCompleteTriggers?: AutoCompleteTriggerType[];
71
+ /** Code editor configuration props */
72
+ editorConfigProps?: EditorConfiguration;
56
73
  }
57
74
  export interface InputParams<P> {
58
75
  id: string;
@@ -69,4 +86,17 @@ export interface ExpressionDetailsProps extends BaseProps {
69
86
  /** Ref to the component */
70
87
  ref?: Ref<HTMLElement>;
71
88
  }
89
+ export declare type EditorState = {
90
+ getValue: () => string | undefined;
91
+ insertText: (text: string) => void;
92
+ };
93
+ export interface CodeEditorProps extends OmitStrict<ExpressionBuilderProps, 'list' | 'search'> {
94
+ ref?: Ref<HTMLDivElement>;
95
+ codeEditorHandle: Ref<EditorState>;
96
+ /** Default expression to set in the code editor */
97
+ defaultValue?: string;
98
+ }
99
+ export interface EditorHintOptions extends ShowHintOptions {
100
+ suggestions?: SuggestionsType[];
101
+ }
72
102
  //# sourceMappingURL=ExpressionBuilder.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpressionBuilder.types.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EACL,SAAS,EACT,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,mBAAmB;IAClC,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,KAAK,EAAE,CAAC,EAAE,EAAE,mBAAmB,CAAC,IAAI,CAAC,KAAK,IAA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der/ExpressionBuilder.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentType, Ref } from 'react';\n\nimport {\n BaseProps,\n EmptyStateProps,\n OmitStrict,\n SearchInputProps,\n TextAreaProps,\n FieldValueListProps\n} from '@pega/cosmos-react-core';\n\nexport interface ExpressionItemProps {\n /** Id of the item */\n id: string;\n /** Item name to be displayed as rule name */\n primary: string;\n /** Type of expression item. Eg: Decision, When, Automation etc. */\n type: string;\n /** Callback for add event */\n onAdd: (id: ExpressionItemProps['id']) => void;\n /** Callback for expand event */\n onExpand?: (id: ExpressionItemProps['id']) => void;\n /** Callback for collapse event */\n onCollapse?: (id: ExpressionItemProps['id']) => void;\n /** Show the expanded details */\n expanded?: boolean;\n /** Expression details to show in expanded view */\n details?: ExpressionDetailsProps;\n}\n\nexport interface ExpressionListProps extends BaseProps {\n ref?: Ref<HTMLDivElement>;\n /** Expression builder items */\n items?: OmitStrict<ExpressionItemProps, 'onAdd' | 'onExpand' | 'onCollapse' | 'details'>[];\n /** Callback for item add */\n onItemAdd: ExpressionItemProps['onAdd'];\n /** Callback for item expand */\n onItemExpand?: ExpressionItemProps['onExpand'];\n /** Callback for item collapse */\n onItemCollapse?: ExpressionItemProps['onCollapse'];\n /** No items */\n emptyText?: EmptyStateProps['message'];\n /** Expanded items data */\n details: {\n [id: string]: ExpressionDetailsProps;\n };\n}\n\nexport interface HandleValue {\n /** Returns the expression value */\n getExpression: () => string;\n}\n\nexport interface ExpressionBuilderProps extends BaseProps {\n ref?: Ref<HTMLDivElement>;\n /** Expression items list */\n list: OmitStrict<ExpressionListProps, 'ref' | 'onItemAdd'> & {\n onItemAdd: (id: ExpressionItemProps['id'], addExpression: (expression: string) => void) => void;\n };\n /** Search input props */\n search: Pick<\n Required<SearchInputProps>,\n 'filters' | 'onFilterChange' | 'onSearchChange' | 'value'\n > &\n Pick<SearchInputProps, 'defaultFilter'>;\n\n /** Default expression to set in the text area */\n defaultValue?: string;\n /** Compiled error message */\n errors?: TextAreaProps['info'];\n /** Imperative handle */\n handle?: Ref<HandleValue>;\n}\n\nexport interface InputParams<P> {\n id: string;\n renderer: ComponentType<P>;\n rendererProps: P;\n}\n\nexport interface ExpressionDetailsProps extends BaseProps {\n /** Primary details of the expression */\n primary: Required<FieldValueListProps['fields']>;\n /** Output params of the expression */\n outputParams?: Required<FieldValueListProps['fields']>;\n /** Input params of the expression */\n inputParams?: InputParams<any>[];\n /** Ref to the component */\n ref?: Ref<HTMLElement>;\n}\n"]}
1
+ {"version":3,"file":"ExpressionBuilder.types.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentType, Ref } from 'react';\nimport { ShowHintOptions, EditorConfiguration } from 'codemirror';\n\nimport {\n BaseProps,\n EmptyStateProps,\n OmitStrict,\n SearchInputProps,\n TextAreaProps,\n FieldValueListProps,\n MenuProps\n} from '@pega/cosmos-react-core';\n\nexport interface ExpressionItemProps {\n /** Id of the item */\n id: string;\n /** Item name to be displayed as rule name */\n primary: string;\n /** Type of expression item. Eg: Decision, When, Automation etc. */\n type: string;\n /** Callback for add event */\n onAdd: (id: ExpressionItemProps['id']) => void;\n /** Callback for expand event */\n onExpand?: (id: ExpressionItemProps['id']) => void;\n /** Callback for collapse event */\n onCollapse?: (id: ExpressionItemProps['id']) => void;\n /** Show the expanded details */\n expanded?: boolean;\n /** Expression details to show in expanded view */\n details?: ExpressionDetailsProps;\n /** Matched field to be shown in expression item collapsed mode during search */\n matchedField?: { name: string; value: string };\n}\n\nexport interface ExpressionListProps extends BaseProps {\n ref?: Ref<HTMLDivElement>;\n /** Expression builder items */\n items?: OmitStrict<ExpressionItemProps, 'onAdd' | 'onExpand' | 'onCollapse' | 'details'>[];\n /** Callback for item add */\n onItemAdd: ExpressionItemProps['onAdd'];\n /** Callback for item expand */\n onItemExpand?: ExpressionItemProps['onExpand'];\n /** Callback for item collapse */\n onItemCollapse?: ExpressionItemProps['onCollapse'];\n /** No items */\n emptyText?: EmptyStateProps['message'];\n /** Expanded items data */\n details: {\n [id: string]: ExpressionDetailsProps;\n };\n}\n\nexport interface HandleValue {\n /** Returns the expression value */\n getExpression: () => string;\n}\n\nexport type AutoCompleteTriggerType = '@' | '.';\n\nexport type SuggestionsType = { label: string; value: string };\n\nexport interface ExpressionBuilderProps extends BaseProps {\n ref?: Ref<HTMLDivElement>;\n /** Expression items list */\n list: OmitStrict<ExpressionListProps, 'ref' | 'onItemAdd'> & {\n onItemAdd: (id: ExpressionItemProps['id'], addExpression: (expression: string) => void) => void;\n };\n /** Search input props */\n search: Pick<\n Required<SearchInputProps>,\n 'filters' | 'onFilterChange' | 'onSearchChange' | 'value'\n > &\n Pick<SearchInputProps, 'defaultFilter'> &\n Pick<MenuProps, 'accent'>;\n\n /** Default expression to set in the code editor */\n defaultValue?: string;\n /** Compiled error message */\n errors?: TextAreaProps['info'];\n /** Imperative handle */\n handle?: Ref<HandleValue>;\n /** Fetches suggestion list for suggestions popover */\n fetchSuggestions?: (autoCompleteTrigger: AutoCompleteTriggerType) => Promise<SuggestionsType[]>;\n /** characters which triggers suggestions */\n autoCompleteTriggers?: AutoCompleteTriggerType[];\n /** Code editor configuration props */\n editorConfigProps?: EditorConfiguration;\n}\n\nexport interface InputParams<P> {\n id: string;\n renderer: ComponentType<P>;\n rendererProps: P;\n}\n\nexport interface ExpressionDetailsProps extends BaseProps {\n /** Primary details of the expression */\n primary: Required<FieldValueListProps['fields']>;\n /** Output params of the expression */\n outputParams?: Required<FieldValueListProps['fields']>;\n /** Input params of the expression */\n inputParams?: InputParams<any>[];\n /** Ref to the component */\n ref?: Ref<HTMLElement>;\n}\n\nexport type EditorState = {\n getValue: () => string | undefined;\n insertText: (text: string) => void;\n};\n\nexport interface CodeEditorProps extends OmitStrict<ExpressionBuilderProps, 'list' | 'search'> {\n ref?: Ref<HTMLDivElement>;\n codeEditorHandle: Ref<EditorState>;\n /** Default expression to set in the code editor */\n defaultValue?: string;\n}\n\nexport interface EditorHintOptions extends ShowHintOptions {\n suggestions?: SuggestionsType[];\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { MenuProps } from '@pega/cosmos-react-core';
3
+ declare const ExpressionBuilderContext: import("react").Context<{
4
+ accent: MenuProps['accent'];
5
+ }>;
6
+ export default ExpressionBuilderContext;
7
+ //# sourceMappingURL=ExpressionBuilderContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressionBuilderContext.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilderContext.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,QAAA,MAAM,wBAAwB;YAA2B,SAAS,CAAC,QAAQ,CAAC;EAE1E,CAAC;AAEH,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { createContext } from 'react';
2
+ const ExpressionBuilderContext = createContext({
3
+ accent: undefined
4
+ });
5
+ export default ExpressionBuilderContext;
6
+ //# sourceMappingURL=ExpressionBuilderContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressionBuilderContext.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilderContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC,MAAM,wBAAwB,GAAG,aAAa,CAAkC;IAC9E,MAAM,EAAE,SAAS;CAClB,CAAC,CAAC;AAEH,eAAe,wBAAwB,CAAC","sourcesContent":["import { createContext } from 'react';\n\nimport { MenuProps } from '@pega/cosmos-react-core';\n\nconst ExpressionBuilderContext = createContext<{ accent: MenuProps['accent'] }>({\n accent: undefined\n});\n\nexport default ExpressionBuilderContext;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpressionItem.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAEnD,OAAO,EAIL,YAAY,EAMb,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAUhE,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CA8EzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"ExpressionItem.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAE/D,OAAO,EAIL,YAAY,EASb,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAYhE,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CAwGzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,18 +1,34 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
3
- import { Button, ExpandCollapse, Flex, Icon, registerIcon, Text, useDirection, useI18n } from '@pega/cosmos-react-core';
2
+ import { useContext, useMemo } from 'react';
3
+ import { Button, ExpandCollapse, Flex, Icon, Mark, registerIcon, replaceMatchWithElement, StyledLabel, Text, useDirection, useI18n } from '@pega/cosmos-react-core';
4
4
  import * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';
5
5
  import * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';
6
- import { StyledExpandCollapseContent, StyledExpressionSummary, StyledExpressionItem } from './ExpressionBuilder.styles';
6
+ import { StyledPrimaryText, StyledExpandCollapseContent, StyledExpressionSummary, StyledExpressionItem } from './ExpressionBuilder.styles';
7
7
  import ExpressionDetails from './ExpressionDetails';
8
+ import ExpressionBuilderContext from './ExpressionBuilderContext';
8
9
  registerIcon(caretLeftIcon, caretRightIcon);
9
- const ExpressionItem = ({ id, primary, type, onAdd, onExpand, onCollapse, details, expanded = false, ...restProps }) => {
10
+ const ExpressionItem = ({ id, primary, type, onAdd, onExpand, onCollapse, details, matchedField, expanded = false, ...restProps }) => {
10
11
  const { end: caretDirection } = useDirection();
11
12
  const t = useI18n();
13
+ const { accent } = useContext(ExpressionBuilderContext);
14
+ const accentedText = (text) => {
15
+ let accentedValue;
16
+ if (accent) {
17
+ const accentRegex = typeof accent === 'function' ? accent(text) : accent;
18
+ const accentedArr = replaceMatchWithElement(text, accentRegex, str => {
19
+ return _jsx(Mark, { children: str });
20
+ });
21
+ if (accentedArr.length > 1)
22
+ accentedValue = accentedArr;
23
+ return accentedValue;
24
+ }
25
+ return null;
26
+ };
12
27
  const caretIcon = useMemo(() => {
13
28
  return expanded ? 'caret-down' : `caret-${caretDirection}`;
14
29
  }, [expanded, caretDirection]);
15
- return (_jsxs(StyledExpressionItem, { expanded: expanded, children: [_jsxs(Flex, { ...restProps, as: StyledExpressionSummary, id: id, container: { gap: 1, alignItems: 'center' }, children: [_jsx(Button, { icon: true, variant: 'simple', onClick: onCollapse || onExpand
30
+ const accentedPrimary = accentedText(primary);
31
+ return (_jsxs(StyledExpressionItem, { expanded: expanded, children: [_jsxs(Flex, { ...restProps, as: StyledExpressionSummary, id: id, container: { gap: 1, alignItems: 'start' }, children: [_jsx(Button, { icon: true, variant: 'simple', onClick: onCollapse || onExpand
16
32
  ? () => {
17
33
  if (expanded) {
18
34
  onCollapse?.(id);
@@ -21,7 +37,7 @@ const ExpressionItem = ({ id, primary, type, onAdd, onExpand, onCollapse, detail
21
37
  onExpand?.(id);
22
38
  }
23
39
  }
24
- : undefined, "aria-label": `${type}: ${primary}`, "aria-expanded": expanded, label: expanded ? t('collapse') : t('expand'), children: _jsx(Icon, { name: caretIcon }) }), _jsxs(Flex, { container: { alignItems: 'start', direction: 'column' }, item: { grow: 1 }, children: [_jsx(Text, { variant: 'primary', children: primary }), _jsx(Text, { variant: 'secondary', children: type })] }), !expanded && (_jsx(Button, { icon: true, variant: 'simple', onClick: () => onAdd(id), "aria-label": t('add_noun', [`${type}: ${primary}`]), label: t('add'), children: _jsx(Icon, { name: 'plus' }) }))] }), _jsx(ExpandCollapse, { collapsed: !expanded, children: _jsxs(Flex, { as: StyledExpandCollapseContent, container: { direction: 'column' }, children: [details && _jsx(ExpressionDetails, { ...details }), _jsx(Button, { variant: 'primary', onClick: () => onAdd(id), "aria-label": t('add_noun', [`${type}: ${primary}`]), children: t('add') })] }) })] }));
40
+ : undefined, "aria-label": `${type}: ${primary}`, "aria-expanded": expanded, label: expanded ? t('collapse') : t('expand'), children: _jsx(Icon, { name: caretIcon }) }), _jsxs(Flex, { container: { alignItems: 'start', direction: 'column' }, item: { grow: 1 }, children: [_jsx(StyledPrimaryText, { variant: 'primary', children: accentedPrimary || primary }), !accentedPrimary && matchedField && !expanded ? (_jsxs("div", { children: [_jsxs(StyledLabel, { as: 'span', children: [matchedField.name, ":"] }), accentedText(matchedField.value) || matchedField.value] })) : (_jsx(Text, { variant: 'secondary', children: type }))] }), !expanded && (_jsx(Button, { icon: true, variant: 'simple', onClick: () => onAdd(id), "aria-label": t('add_noun', [`${type}: ${primary}`]), label: t('add'), children: _jsx(Icon, { name: 'plus' }) }))] }), _jsx(ExpandCollapse, { collapsed: !expanded, children: _jsxs(Flex, { as: StyledExpandCollapseContent, container: { direction: 'column' }, children: [details && _jsx(ExpressionDetails, { ...details }), _jsx(Button, { variant: 'primary', onClick: () => onAdd(id), "aria-label": t('add_noun', [`${type}: ${primary}`]), children: t('add') })] }) })] }));
25
41
  };
26
42
  export default ExpressionItem;
27
43
  //# sourceMappingURL=ExpressionItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpressionItem.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,OAAO,EAAE,MAAM,OAAO,CAAC;AAEnD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AAE,CAAC,gBACZ,CAAC,CAAC,UAAU,EAAE,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC,YAEjD,CAAC,CAAC,KAAK,CAAC,GACF,IACJ,GACQ,IACI,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FunctionComponent, useMemo } from 'react';\n\nimport {\n Button,\n ExpandCollapse,\n Flex,\n ForwardProps,\n Icon,\n registerIcon,\n Text,\n useDirection,\n useI18n\n} from '@pega/cosmos-react-core';\nimport * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';\nimport * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';\n\nimport { ExpressionItemProps } from './ExpressionBuilder.types';\nimport {\n StyledExpandCollapseContent,\n StyledExpressionSummary,\n StyledExpressionItem\n} from './ExpressionBuilder.styles';\nimport ExpressionDetails from './ExpressionDetails';\n\nregisterIcon(caretLeftIcon, caretRightIcon);\n\nconst ExpressionItem: FunctionComponent<ExpressionItemProps & ForwardProps> = ({\n id,\n primary,\n type,\n onAdd,\n onExpand,\n onCollapse,\n details,\n expanded = false,\n ...restProps\n}) => {\n const { end: caretDirection } = useDirection();\n const t = useI18n();\n\n const caretIcon = useMemo(() => {\n return expanded ? 'caret-down' : `caret-${caretDirection}`;\n }, [expanded, caretDirection]);\n\n return (\n <StyledExpressionItem expanded={expanded}>\n <Flex\n {...restProps}\n as={StyledExpressionSummary}\n id={id}\n container={{ gap: 1, alignItems: 'center' }}\n >\n <Button\n icon\n variant='simple'\n onClick={\n onCollapse || onExpand\n ? () => {\n if (expanded) {\n onCollapse?.(id);\n } else {\n onExpand?.(id);\n }\n }\n : undefined\n }\n aria-label={`${type}: ${primary}`}\n aria-expanded={expanded}\n label={expanded ? t('collapse') : t('expand')}\n >\n <Icon name={caretIcon} />\n </Button>\n\n <Flex container={{ alignItems: 'start', direction: 'column' }} item={{ grow: 1 }}>\n <Text variant='primary'>{primary}</Text>\n <Text variant='secondary'>{type}</Text>\n </Flex>\n\n {!expanded && (\n <Button\n icon\n variant='simple'\n onClick={() => onAdd(id)}\n aria-label={t('add_noun', [`${type}: ${primary}`])}\n label={t('add')}\n >\n <Icon name='plus' />\n </Button>\n )}\n </Flex>\n <ExpandCollapse collapsed={!expanded}>\n <Flex as={StyledExpandCollapseContent} container={{ direction: 'column' }}>\n {details && <ExpressionDetails {...details} />}\n <Button\n variant='primary'\n onClick={() => onAdd(id)}\n aria-label={t('add_noun', [`${type}: ${primary}`])}\n >\n {t('add')}\n </Button>\n </Flex>\n </ExpandCollapse>\n </StyledExpressionItem>\n );\n};\n\nexport default ExpressionItem;\n"]}
1
+ {"version":3,"file":"ExpressionItem.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,EACL,MAAM,EACN,cAAc,EACd,IAAI,EAEJ,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,uBAAuB,EACvB,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,OAAO,EACR,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,cAAc,MAAM,oEAAoE,CAAC;AACrG,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AAGnG,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAElE,YAAY,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;AAE5C,MAAM,cAAc,GAA0D,CAAC,EAC7E,EAAE,EACF,OAAO,EACP,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,UAAU,EACV,OAAO,EACP,YAAY,EACZ,QAAQ,GAAG,KAAK,EACh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AAC,CAAC,KAAK,CAAC,YAEf,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,GACb,CACV,IACI,EACP,KAAC,cAAc,IAAC,SAAS,EAAE,CAAC,QAAQ,YAClC,MAAC,IAAI,IAAC,EAAE,EAAE,2BAA2B,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,aACtE,OAAO,IAAI,KAAC,iBAAiB,OAAK,OAAO,GAAI,EAC9C,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,gBACZ,CAAC,CAAC,UAAU,EAAE,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC,YAEjD,CAAC,CAAC,KAAK,CAAC,GACF,IACJ,GACQ,IACI,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FunctionComponent, useContext, useMemo } from 'react';\n\nimport {\n Button,\n ExpandCollapse,\n Flex,\n ForwardProps,\n Icon,\n Mark,\n registerIcon,\n replaceMatchWithElement,\n StyledLabel,\n Text,\n useDirection,\n useI18n\n} from '@pega/cosmos-react-core';\nimport * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';\nimport * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';\n\nimport { ExpressionItemProps } from './ExpressionBuilder.types';\nimport {\n StyledPrimaryText,\n StyledExpandCollapseContent,\n StyledExpressionSummary,\n StyledExpressionItem\n} from './ExpressionBuilder.styles';\nimport ExpressionDetails from './ExpressionDetails';\nimport ExpressionBuilderContext from './ExpressionBuilderContext';\n\nregisterIcon(caretLeftIcon, caretRightIcon);\n\nconst ExpressionItem: FunctionComponent<ExpressionItemProps & ForwardProps> = ({\n id,\n primary,\n type,\n onAdd,\n onExpand,\n onCollapse,\n details,\n matchedField,\n expanded = false,\n ...restProps\n}) => {\n const { end: caretDirection } = useDirection();\n const t = useI18n();\n\n const { accent } = useContext(ExpressionBuilderContext);\n\n const accentedText = (text: string) => {\n let accentedValue;\n if (accent) {\n const accentRegex = typeof accent === 'function' ? accent(text) : accent;\n const accentedArr = replaceMatchWithElement(text, accentRegex, str => {\n return <Mark>{str}</Mark>;\n });\n\n if (accentedArr.length > 1) accentedValue = accentedArr;\n return accentedValue;\n }\n return null;\n };\n\n const caretIcon = useMemo(() => {\n return expanded ? 'caret-down' : `caret-${caretDirection}`;\n }, [expanded, caretDirection]);\n\n const accentedPrimary = accentedText(primary);\n\n return (\n <StyledExpressionItem expanded={expanded}>\n <Flex\n {...restProps}\n as={StyledExpressionSummary}\n id={id}\n container={{ gap: 1, alignItems: 'start' }}\n >\n <Button\n icon\n variant='simple'\n onClick={\n onCollapse || onExpand\n ? () => {\n if (expanded) {\n onCollapse?.(id);\n } else {\n onExpand?.(id);\n }\n }\n : undefined\n }\n aria-label={`${type}: ${primary}`}\n aria-expanded={expanded}\n label={expanded ? t('collapse') : t('expand')}\n >\n <Icon name={caretIcon} />\n </Button>\n\n <Flex container={{ alignItems: 'start', direction: 'column' }} item={{ grow: 1 }}>\n <StyledPrimaryText variant='primary'>{accentedPrimary || primary}</StyledPrimaryText>\n {!accentedPrimary && matchedField && !expanded ? (\n <div>\n <StyledLabel as='span'>{matchedField.name}:</StyledLabel>\n {accentedText(matchedField.value) || matchedField.value}\n </div>\n ) : (\n <Text variant='secondary'>{type}</Text>\n )}\n </Flex>\n\n {!expanded && (\n <Button\n icon\n variant='simple'\n onClick={() => onAdd(id)}\n aria-label={t('add_noun', [`${type}: ${primary}`])}\n label={t('add')}\n >\n <Icon name='plus' />\n </Button>\n )}\n </Flex>\n <ExpandCollapse collapsed={!expanded}>\n <Flex as={StyledExpandCollapseContent} container={{ direction: 'column' }}>\n {details && <ExpressionDetails {...details} />}\n <Button\n variant='primary'\n onClick={() => onAdd(id)}\n aria-label={t('add_noun', [`${type}: ${primary}`])}\n >\n {t('add')}\n </Button>\n </Flex>\n </ExpandCollapse>\n </StyledExpressionItem>\n );\n};\n\nexport default ExpressionItem;\n"]}
@@ -1,6 +1,7 @@
1
1
  export { default } from './ExpressionBuilder';
2
- export { ExpressionListProps, ExpressionItemProps, ExpressionBuilderProps, HandleValue, InputParams } from './ExpressionBuilder.types';
2
+ export { ExpressionListProps, ExpressionItemProps, ExpressionBuilderProps, HandleValue, InputParams, EditorState } from './ExpressionBuilder.types';
3
3
  export { default as ExpressionItem } from './ExpressionItem';
4
4
  export { default as ExpressionList } from './ExpressionList';
5
5
  export { default as ExpressionDetails } from './ExpressionDetails';
6
+ export { default as CodeEditor } from './CodeEditor/CodeEditor';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,WAAW,EACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
@@ -2,4 +2,5 @@ export { default } from './ExpressionBuilder';
2
2
  export { default as ExpressionItem } from './ExpressionItem';
3
3
  export { default as ExpressionList } from './ExpressionList';
4
4
  export { default as ExpressionDetails } from './ExpressionDetails';
5
+ export { default as CodeEditor } from './CodeEditor/CodeEditor';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAQ9C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export { default } from './ExpressionBuilder';\nexport {\n ExpressionListProps,\n ExpressionItemProps,\n ExpressionBuilderProps,\n HandleValue,\n InputParams\n} from './ExpressionBuilder.types';\nexport { default as ExpressionItem } from './ExpressionItem';\nexport { default as ExpressionList } from './ExpressionList';\nexport { default as ExpressionDetails } from './ExpressionDetails';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAS9C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["export { default } from './ExpressionBuilder';\nexport {\n ExpressionListProps,\n ExpressionItemProps,\n ExpressionBuilderProps,\n HandleValue,\n InputParams,\n EditorState\n} from './ExpressionBuilder.types';\nexport { default as ExpressionItem } from './ExpressionItem';\nexport { default as ExpressionList } from './ExpressionList';\nexport { default as ExpressionDetails } from './ExpressionDetails';\nexport { default as CodeEditor } from './CodeEditor/CodeEditor';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-build",
3
- "version": "3.0.0-dev.27.1",
3
+ "version": "3.0.0-dev.27.2",
4
4
  "author": "Pegasystems",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -20,15 +20,18 @@
20
20
  "build": "tsc -b"
21
21
  },
22
22
  "dependencies": {
23
- "@pega/cosmos-react-core": "3.0.0-dev.27.1",
24
- "@pega/cosmos-react-dnd": "3.0.0-dev.27.1",
23
+ "@pega/cosmos-react-core": "3.0.0-dev.27.2",
24
+ "@pega/cosmos-react-dnd": "3.0.0-dev.27.2",
25
+ "@types/codemirror": "^5.60.5",
25
26
  "@types/dagre": "^0.7.46",
26
27
  "@types/react": "^16.14.24 || ^17.0.38",
27
28
  "@types/react-dom": "^16.9.14 || ^17.0.11",
28
29
  "@types/styled-components": "^5.1.7",
30
+ "codemirror": "^5.54.0",
29
31
  "dagre": "^0.8.5",
30
32
  "polished": "^4.1.0",
31
33
  "react": "^16.14.0 || ^17.0.0",
34
+ "react-codemirror2": "^7.2.1",
32
35
  "react-dom": "^16.14.0 || ^17.0.0",
33
36
  "styled-components": "^5.2.0",
34
37
  "tinymce": "^6.0.3"