@pega/cosmos-react-build 3.0.0-dev.20.0 → 3.0.0-dev.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/lib/components/ExpressionBuilder/ExpressionBuilder.d.ts +6 -0
  2. package/lib/components/ExpressionBuilder/ExpressionBuilder.d.ts.map +1 -0
  3. package/lib/components/ExpressionBuilder/ExpressionBuilder.js +77 -0
  4. package/lib/components/ExpressionBuilder/ExpressionBuilder.js.map +1 -0
  5. package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.d.ts +5 -0
  6. package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.d.ts.map +1 -0
  7. package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.js +44 -0
  8. package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.js.map +1 -0
  9. package/lib/components/ExpressionBuilder/ExpressionBuilder.types.d.ts +47 -0
  10. package/lib/components/ExpressionBuilder/ExpressionBuilder.types.d.ts.map +1 -0
  11. package/lib/components/ExpressionBuilder/ExpressionBuilder.types.js +2 -0
  12. package/lib/components/ExpressionBuilder/ExpressionBuilder.types.js.map +1 -0
  13. package/lib/components/ExpressionBuilder/ExpressionItem.d.ts +6 -0
  14. package/lib/components/ExpressionBuilder/ExpressionItem.d.ts.map +1 -0
  15. package/lib/components/ExpressionBuilder/ExpressionItem.js +17 -0
  16. package/lib/components/ExpressionBuilder/ExpressionItem.js.map +1 -0
  17. package/lib/components/ExpressionBuilder/ExpressionList.d.ts +6 -0
  18. package/lib/components/ExpressionBuilder/ExpressionList.d.ts.map +1 -0
  19. package/lib/components/ExpressionBuilder/ExpressionList.js +22 -0
  20. package/lib/components/ExpressionBuilder/ExpressionList.js.map +1 -0
  21. package/lib/components/ExpressionBuilder/index.d.ts +5 -0
  22. package/lib/components/ExpressionBuilder/index.d.ts.map +1 -0
  23. package/lib/components/ExpressionBuilder/index.js +4 -0
  24. package/lib/components/ExpressionBuilder/index.js.map +1 -0
  25. package/lib/index.d.ts +2 -0
  26. package/lib/index.d.ts.map +1 -1
  27. package/lib/index.js +2 -0
  28. package/lib/index.js.map +1 -1
  29. package/package.json +4 -3
@@ -0,0 +1,6 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { ExpressionBuilderProps } from './ExpressionBuilder.types';
4
+ declare const ExpressionBuilder: FunctionComponent<ExpressionBuilderProps & ForwardProps>;
5
+ export default ExpressionBuilder;
6
+ //# sourceMappingURL=ExpressionBuilder.d.ts.map
@@ -0,0 +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,EAAQ,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAE7F,OAAO,EAAuB,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAIxF,QAAA,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,sBAAsB,GAAG,YAAY,CA+H/E,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,77 @@
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 } from '@pega/cosmos-react-core';
4
+ import ExpressionList from './ExpressionList';
5
+ import { StyledExpressionBuilder, StyledExpressionEditor } from './ExpressionBuilder.styles';
6
+ const ExpressionBuilder = forwardRef(({ list, search, errors, defaultValue, handle, ...restProps }, ref) => {
7
+ const t = useI18n();
8
+ const textArea = useRef();
9
+ const [selection, setSelection] = useState({
10
+ start: 0,
11
+ end: 0
12
+ });
13
+ const getExpression = () => {
14
+ return textArea.current?.value || '';
15
+ };
16
+ useImperativeHandle(handle, () => ({
17
+ getExpression
18
+ }), [getExpression]);
19
+ const insertExpression = (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
+ textArea.current.focus();
29
+ };
30
+ const onBlur = () => {
31
+ if (!textArea.current)
32
+ return;
33
+ const lastIndex = textArea.current.value.length >= 0 ? textArea.current.value.length : 0;
34
+ const selectionStart = textArea.current.selectionStart === null ? lastIndex : textArea.current.selectionStart;
35
+ const selectionEnd = textArea.current.selectionEnd === null ? lastIndex : textArea.current.selectionEnd;
36
+ const currentSelection = {
37
+ start: selectionStart,
38
+ end: selectionEnd
39
+ };
40
+ if (selectionStart > selectionEnd) {
41
+ currentSelection.start = selectionEnd;
42
+ currentSelection.end = selectionStart;
43
+ }
44
+ setSelection(currentSelection);
45
+ };
46
+ const onItemInsert = (id) => {
47
+ list.onItemInsert(id, insertExpression);
48
+ };
49
+ useEffect(() => {
50
+ if (defaultValue && textArea.current) {
51
+ setSelection({ start: defaultValue.length, end: defaultValue.length });
52
+ textArea.current.value = defaultValue;
53
+ }
54
+ }, []);
55
+ return (_jsxs(Flex, { ...restProps, as: StyledExpressionBuilder, ref: ref, container: {
56
+ justify: 'between',
57
+ colGap: 2,
58
+ pad: 1
59
+ }, item: {
60
+ grow: 1
61
+ }, children: [_jsxs(Flex, { container: {
62
+ direction: 'column',
63
+ justify: 'between',
64
+ gap: 1
65
+ }, item: {
66
+ grow: 1,
67
+ basis: '50%'
68
+ }, children: [_jsx(SearchInput, { ...search }), _jsx(ExpressionList, { ...list, onItemInsert: onItemInsert })] }), _jsx(Flex, { as: StyledExpressionEditor, container: {
69
+ direction: 'column',
70
+ justify: 'between'
71
+ }, item: {
72
+ grow: 1,
73
+ basis: '50%'
74
+ }, children: _jsx(TextArea, { status: errors ? 'error' : undefined, ref: textArea, onBlur: onBlur, label: t('expression_editor'), labelHidden: true, info: errors }) })] }));
75
+ });
76
+ export default ExpressionBuilder;
77
+ //# sourceMappingURL=ExpressionBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressionBuilder.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,IAAI,EAAgB,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAG7F,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAE7F,MAAM,iBAAiB,GAA6D,UAAU,CAC5F,CACE,EACE,IAAI,EACJ,MAAM,EACN,MAAM,EACN,YAAY,EACZ,MAAM,EACN,GAAG,SAAS,EAC4B,EAC1C,GAAkC,EAClC,EAAE;IACF,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,QAAQ,GAAG,MAAM,EAAoB,CAAC;IAC5C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAiC;QACzE,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,CAAC;KACP,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,OAAO,QAAQ,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;IACvC,CAAC,CAAC;IAEF,mBAAmB,CACjB,MAAM,EACN,GAAG,EAAE,CAAC,CAAC;QACL,aAAa;KACd,CAAC,EACF,CAAC,aAAa,CAAC,CAChB,CAAC;IAEF,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAE,EAAE;QAC9C,IAAI,CAAC,QAAQ,CAAC,OAAO;YAAE,OAAO;QAC9B,MAAM,YAAY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ACP,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 { Flex, ForwardProps, SearchInput, TextArea, useI18n } 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 insertExpression = (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 textArea.current.focus();\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 onItemInsert = (id: ExpressionItemProps['id']) => {\n list.onItemInsert(id, insertExpression);\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 {/* 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} onItemInsert={onItemInsert} />\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"]}
@@ -0,0 +1,5 @@
1
+ export declare const StyledExpressionItem: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, {}, never>;
2
+ export declare const StyledExpressionList: import("styled-components").StyledComponent<"ul", import("styled-components").DefaultTheme, {}, never>;
3
+ export declare const StyledExpressionBuilder: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const StyledExpressionEditor: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
5
+ //# sourceMappingURL=ExpressionBuilder.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressionBuilder.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.styles.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,oBAAoB,wGAY/B,CAAC;AAIH,eAAO,MAAM,oBAAoB,wGAGhC,CAAC;AAEF,eAAO,MAAM,uBAAuB,yGAYlC,CAAC;AAIH,eAAO,MAAM,sBAAsB,yGAMjC,CAAC"}
@@ -0,0 +1,44 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { defaultThemeProp } from '@pega/cosmos-react-core';
3
+ 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 StyledExpressionItem = styled.li(({ theme }) => {
6
+ return css `
7
+ background-color: ${theme.base.palette['primary-background']};
8
+ padding-block: ${theme.base.spacing};
9
+ padding-inline: calc(0.5 * ${theme.base.spacing});
10
+ :not(:last-child) {
11
+ border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};
12
+ }
13
+ & + & {
14
+ margin-inline-start: 0;
15
+ }
16
+ `;
17
+ });
18
+ StyledExpressionItem.defaultProps = defaultThemeProp;
19
+ export const StyledExpressionList = styled.ul `
20
+ overflow-y: auto;
21
+ flex-grow: 1;
22
+ `;
23
+ export const StyledExpressionBuilder = styled.div(({ theme }) => {
24
+ return css `
25
+ background-color: ${theme.base.palette['primary-background']};
26
+ min-height: calc(30 * ${theme.base.spacing});
27
+ max-height: 100%;
28
+ max-width: calc(2 * ${theme.base['content-width'].lg} + 4 * ${theme.base.spacing});
29
+ min-width: calc(${theme.base['content-width'].lg} + 4 * ${theme.base.spacing});
30
+
31
+ ${StyledTextArea} {
32
+ flex-grow: 1;
33
+ }
34
+ `;
35
+ });
36
+ StyledExpressionBuilder.defaultProps = defaultThemeProp;
37
+ export const StyledExpressionEditor = styled.div(() => {
38
+ return css `
39
+ ${StyledFormField} {
40
+ flex-grow: 1;
41
+ }
42
+ `;
43
+ });
44
+ //# sourceMappingURL=ExpressionBuilder.styles.js.map
@@ -0,0 +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,MAAM,yBAAyB,CAAC;AAC3D,OAAO,cAAc,MAAM,iEAAiE,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,4DAA4D,CAAC;AAE7F,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC1D,OAAO,GAAG,CAAA;wBACY,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;qBAC3C,KAAK,CAAC,IAAI,CAAC,OAAO;iCACN,KAAK,CAAC,IAAI,CAAC,OAAO;;uCAEZ,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;;;;;GAKrE,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAErD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,EAAE,CAAA;;;CAG5C,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,CAAC;AAExD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE;IACpD,OAAO,GAAG,CAAA;MACN,eAAe;;;GAGlB,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } 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\nexport const StyledExpressionItem = styled.li(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['primary-background']};\n padding-block: ${theme.base.spacing};\n padding-inline: calc(0.5 * ${theme.base.spacing});\n :not(:last-child) {\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n }\n & + & {\n margin-inline-start: 0;\n }\n `;\n});\n\nStyledExpressionItem.defaultProps = defaultThemeProp;\n\nexport const StyledExpressionList = styled.ul`\n overflow-y: auto;\n flex-grow: 1;\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"]}
@@ -0,0 +1,47 @@
1
+ import { Ref } from 'react';
2
+ import { BaseProps, EmptyStateProps, OmitStrict, SearchInputProps, TextAreaProps } from '@pega/cosmos-react-core';
3
+ export interface ExpressionItemProps {
4
+ /** Id of the item */
5
+ id: string;
6
+ /** Item name to be displayed as rule name */
7
+ primary: string;
8
+ /** Type of expression item. Eg: Decision, When, Automation etc. */
9
+ type: string;
10
+ /** Click on the plus button to add it in the expression input */
11
+ onInsert: (id: ExpressionItemProps['id']) => void;
12
+ /** Display the React node for parameters */
13
+ onExpand?: (id: ExpressionItemProps['id']) => void;
14
+ /** show the expanded */
15
+ isExpanded?: boolean;
16
+ }
17
+ export interface ExpressionListProps extends BaseProps {
18
+ ref?: Ref<HTMLDivElement>;
19
+ /** Expression builder items */
20
+ items?: OmitStrict<ExpressionItemProps, 'onInsert' | 'onExpand'>[];
21
+ /** Handler for plus button on ExpressionItem */
22
+ onItemInsert: ExpressionItemProps['onInsert'];
23
+ /** Handler for expand button on ExpressionItem */
24
+ onItemExpand?: ExpressionItemProps['onExpand'];
25
+ /** No items */
26
+ emptyText?: EmptyStateProps['message'];
27
+ }
28
+ export interface HandleValue {
29
+ /** Returns the expression value */
30
+ getExpression: () => string;
31
+ }
32
+ export interface ExpressionBuilderProps extends BaseProps {
33
+ ref?: Ref<HTMLDivElement>;
34
+ /** Expression items list */
35
+ list: OmitStrict<ExpressionListProps, 'ref' | 'onItemInsert'> & {
36
+ onItemInsert: (id: ExpressionItemProps['id'], insertExpression: (expression: string) => void) => void;
37
+ };
38
+ /** Search input props */
39
+ search: Pick<Required<SearchInputProps>, 'filters' | 'onFilterChange' | 'onSearchChange' | 'value'> & Pick<SearchInputProps, 'defaultFilter'>;
40
+ /** Default expression to set in the text area */
41
+ defaultValue?: string;
42
+ /** Compiled error message */
43
+ errors?: TextAreaProps['info'];
44
+ /** Imperative handle */
45
+ handle?: Ref<HandleValue>;
46
+ }
47
+ //# sourceMappingURL=ExpressionBuilder.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressionBuilder.types.d.ts","sourceRo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EAAE,UAAU,CAAC,mBAAmB,EAAE,KAAK,GAAG,cAAc,CAAC,GAAG;QAC9D,YAAY,EAAE,CACZ,EAAE,EAAE,mBAAmB,CAAC,IAAI,CAAC,EAC7B,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,KAC3C,IAAI,CAAC;KACX,CAAC;IACF,yBAAyB;IACzB,MAAM,EAAE,IAAI,CACV,QAAQ,CAAC,gBAAgB,CAAC,EAC1B,SAAS,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,OAAO,CAC1D,GACC,IAAI,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;IAE1C,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC/B,wBAAwB;IACxB,MAAM,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAC3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ExpressionBuilder.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressionBuilder.types.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref } from 'react';\n\nimport {\n BaseProps,\n EmptyStateProps,\n OmitStrict,\n SearchInputProps,\n TextAreaProps\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 /** Click on the plus button to add it in the expression input */\n onInsert: (id: ExpressionItemProps['id']) => void;\n /** Display the React node for parameters */\n onExpand?: (id: ExpressionItemProps['id']) => void;\n /** show the expanded */\n isExpanded?: boolean;\n}\n\nexport interface ExpressionListProps extends BaseProps {\n ref?: Ref<HTMLDivElement>;\n /** Expression builder items */\n items?: OmitStrict<ExpressionItemProps, 'onInsert' | 'onExpand'>[];\n /** Handler for plus button on ExpressionItem */\n onItemInsert: ExpressionItemProps['onInsert'];\n /** Handler for expand button on ExpressionItem */\n onItemExpand?: ExpressionItemProps['onExpand'];\n /** No items */\n emptyText?: EmptyStateProps['message'];\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' | 'onItemInsert'> & {\n onItemInsert: (\n id: ExpressionItemProps['id'],\n insertExpression: (expression: string) => void\n ) => 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"]}
@@ -0,0 +1,6 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { ExpressionItemProps } from './ExpressionBuilder.types';
4
+ declare const ExpressionItem: FunctionComponent<ExpressionItemProps & ForwardProps>;
5
+ export default ExpressionItem;
6
+ //# sourceMappingURL=ExpressionItem.d.ts.map
@@ -0,0 +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,EAGL,YAAY,EAMb,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAKhE,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CA+CzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { Button, Flex, Icon, registerIcon, Text, useDirection, useI18n } from '@pega/cosmos-react-core';
4
+ import * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';
5
+ import * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';
6
+ import { StyledExpressionItem } from './ExpressionBuilder.styles';
7
+ registerIcon(caretLeftIcon, caretRightIcon);
8
+ const ExpressionItem = ({ id, primary, type, onInsert, onExpand, isExpanded = false, ...restProps }) => {
9
+ const { end: caretDirection } = useDirection();
10
+ const t = useI18n();
11
+ const caretIcon = useMemo(() => {
12
+ return isExpanded ? 'caret-down' : `caret-${caretDirection}`;
13
+ }, [isExpanded, caretDirection]);
14
+ return (_jsxs(Flex, { ...restProps, as: StyledExpressionItem, id: id, container: { alignItems: 'center', justify: 'between' }, children: [_jsxs(Flex, { container: { gap: 1, alignItems: 'center' }, children: [_jsx(Button, { icon: true, variant: 'simple', onClick: onExpand ? () => onExpand(id) : undefined, "aria-label": t('expand_noun', [`${type}: ${primary}`]), children: _jsx(Icon, { name: caretIcon }) }), _jsx(Text, { variant: 'primary', children: primary })] }), _jsxs(Flex, { container: { gap: 1, alignItems: 'center' }, children: [_jsx(Text, { variant: 'secondary', children: type }), _jsx(Button, { icon: true, variant: 'simple', onClick: () => onInsert(id), "aria-label": t('insert_noun', [`${type}: ${primary}`]), children: _jsx(Icon, { name: 'plus' }) })] })] }));
15
+ };
16
+ export default ExpressionItem;
17
+ //# sourceMappingURL=ExpressionItem.js.map
@@ -0,0 +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,OAAO,EACL,MAAM,EACN,IAAI,EAEJ,IAAI,EACJ,YA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AC,IAAI,EAAE,SAAS,GAAI,GAClB,EACT,KAAC,IAAI,IAAC,OAAO,EAAC,SAAS,YAAE,OAAO,GAAQ,IACnC,EACP,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,aAC/C,KAAC,IAAI,IAAC,OAAO,EAAC,WAAW,YAAE,IAAI,GAAQ,EACvC,KAAC,MAAM,IACL,IAAI,QACJ,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,gBACf,CAAC,CAAC,aAAa,EAAE,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC,YAErD,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,GACb,IACJ,IACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FunctionComponent, useMemo } from 'react';\n\nimport {\n Button,\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 { StyledExpressionItem } from './ExpressionBuilder.styles';\n\nregisterIcon(caretLeftIcon, caretRightIcon);\n\nconst ExpressionItem: FunctionComponent<ExpressionItemProps & ForwardProps> = ({\n id,\n primary,\n type,\n onInsert,\n onExpand,\n isExpanded = false,\n ...restProps\n}) => {\n const { end: caretDirection } = useDirection();\n const t = useI18n();\n\n const caretIcon = useMemo(() => {\n return isExpanded ? 'caret-down' : `caret-${caretDirection}`;\n }, [isExpanded, caretDirection]);\n\n return (\n <Flex\n {...restProps}\n as={StyledExpressionItem}\n id={id}\n container={{ alignItems: 'center', justify: 'between' }}\n >\n <Flex container={{ gap: 1, alignItems: 'center' }}>\n <Button\n icon\n variant='simple'\n onClick={onExpand ? () => onExpand(id) : undefined}\n aria-label={t('expand_noun', [`${type}: ${primary}`])}\n >\n <Icon name={caretIcon} />\n </Button>\n <Text variant='primary'>{primary}</Text>\n </Flex>\n <Flex container={{ gap: 1, alignItems: 'center' }}>\n <Text variant='secondary'>{type}</Text>\n <Button\n icon\n variant='simple'\n onClick={() => onInsert(id)}\n aria-label={t('insert_noun', [`${type}: ${primary}`])}\n >\n <Icon name='plus' />\n </Button>\n </Flex>\n </Flex>\n );\n};\n\nexport default ExpressionItem;\n"]}
@@ -0,0 +1,6 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { ExpressionListProps } from './ExpressionBuilder.types';
4
+ declare const ExpressionList: FunctionComponent<ExpressionListProps & ForwardProps>;
5
+ export default ExpressionList;
6
+ //# sourceMappingURL=ExpressionList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressionList.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAoB,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAuB,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAIrF,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CAmCzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createElement as _createElement } from "react";
3
+ import { forwardRef, useState } from 'react';
4
+ import { EmptyState, Flex } from '@pega/cosmos-react-core';
5
+ import ExpressionItem from './ExpressionItem';
6
+ import { StyledExpressionList } from './ExpressionBuilder.styles';
7
+ const ExpressionList = forwardRef(({ items, emptyText, onItemInsert, onItemExpand, ...restProps }, ref) => {
8
+ const [expandedItem, setExpandedItem] = useState(null);
9
+ const handleItemExpand = (id) => {
10
+ setExpandedItem(prev => {
11
+ if (prev === id)
12
+ return null;
13
+ onItemExpand?.(id);
14
+ return id;
15
+ });
16
+ };
17
+ return (_jsx(Flex, { ...restProps, as: StyledExpressionList, ref: ref, children: items && items.length > 0 ? (items.map(item => {
18
+ return (_createElement(ExpressionItem, { ...item, onInsert: onItemInsert, onExpand: handleItemExpand, isExpanded: expandedItem === item.id, key: item.id }));
19
+ })) : (_jsx(EmptyState, { message: emptyText })) }));
20
+ });
21
+ export default ExpressionList;
22
+ //# sourceMappingURL=ExpressionList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressionList.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionList.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAgB,MAAM,yBAAyB,CAAC;AAGzE,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,cAAc,GAA0D,UAAU,CACtF,CACE,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,SAAS,EAAE,EAC9D,GAA+B,EAC/B,EAAE;IACF,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAmC,IAAI,CAAC,CAAC;IAEzF,MAAM,gBAAgB,GAAG,CAAC,EAA6B,EAAE,EAAE;QACzD,eAAe,CAAC,IAAI,CAAC,EAAE;YACrB,IAAI,IAAI,KAAK,EAAE;gBAAE,OAAO,IAAI,CAAC;YAC7B,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC;YACnB,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,IAAI,OAAK,SAAS,EAAE,EAAE,EAAE,oBAAoB,EAAE,GAAG,EAAE,GAAG,YACpD,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC3B,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACf,OAAO,CACL,eAAC,cAAc,OACT,IAAI,EACR,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,YAAY,KAAK,IAAI,CAAC,EAAE,EACpC,GAAG,EAAE,IAAI,CAAC,EAAE,GACZ,CACH,CAAC;QACJ,CAAC,CAAC,CACH,CAAC,CAAC,CAAC,CACF,KAAC,UAAU,IAAC,OAAO,EAAE,SAAS,GAAI,CACnC,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, useState } from 'react';\n\nimport { EmptyState, Flex, ForwardProps } from '@pega/cosmos-react-core';\n\nimport { ExpressionItemProps, ExpressionListProps } from './ExpressionBuilder.types';\nimport ExpressionItem from './ExpressionItem';\nimport { StyledExpressionList } from './ExpressionBuilder.styles';\n\nconst ExpressionList: FunctionComponent<ExpressionListProps & ForwardProps> = forwardRef(\n (\n { items, emptyText, onItemInsert, onItemExpand, ...restProps },\n ref: ExpressionListProps['ref']\n ) => {\n const [expandedItem, setExpandedItem] = useState<ExpressionItemProps['id'] | null>(null);\n\n const handleItemExpand = (id: ExpressionItemProps['id']) => {\n setExpandedItem(prev => {\n if (prev === id) return null;\n onItemExpand?.(id);\n return id;\n });\n };\n\n return (\n <Flex {...restProps} as={StyledExpressionList} ref={ref}>\n {items && items.length > 0 ? (\n items.map(item => {\n return (\n <ExpressionItem\n {...item}\n onInsert={onItemInsert}\n onExpand={handleItemExpand}\n isExpanded={expandedItem === item.id}\n key={item.id}\n />\n );\n })\n ) : (\n <EmptyState message={emptyText} />\n )}\n </Flex>\n );\n }\n);\n\nexport default ExpressionList;\n"]}
@@ -0,0 +1,5 @@
1
+ export { default } from './ExpressionBuilder';
2
+ export { ExpressionListProps, ExpressionItemProps, ExpressionBuilderProps, HandleValue } from './ExpressionBuilder.types';
3
+ export { default as ExpressionItem } from './ExpressionItem';
4
+ export { default as ExpressionList } from './ExpressionList';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,EACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default } from './ExpressionBuilder';
2
+ export { default as ExpressionItem } from './ExpressionItem';
3
+ export { default as ExpressionList } from './ExpressionList';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAO9C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["export { default } from './ExpressionBuilder';\nexport {\n ExpressionListProps,\n ExpressionItemProps,\n ExpressionBuilderProps,\n HandleValue\n} from './ExpressionBuilder.types';\nexport { default as ExpressionItem } from './ExpressionItem';\n\nexport { default as ExpressionList } from './ExpressionList';\n"]}
package/lib/index.d.ts CHANGED
@@ -4,6 +4,8 @@ export { default as AppShell } from './components/AppShell';
4
4
  export * from './components/AppShell';
5
5
  export { default as DynamicContentEditor } from './components/DynamicContentEditor';
6
6
  export * from './components/DynamicContentEditor';
7
+ export { default as ExpressionBuilder } from './components/ExpressionBuilder';
8
+ export * from './components/ExpressionBuilder';
7
9
  export { default as FlowModeller } from './components/FlowModeller';
8
10
  export * from './components/FlowModeller';
9
11
  export * from './components/ItemLibrary';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACpF,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACpF,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,SAAS,CAAC"}
package/lib/index.js CHANGED
@@ -5,6 +5,8 @@ export { default as AppShell } from './components/AppShell';
5
5
  export * from './components/AppShell';
6
6
  export { default as DynamicContentEditor } from './components/DynamicContentEditor';
7
7
  export * from './components/DynamicContentEditor';
8
+ export { default as ExpressionBuilder } from './components/ExpressionBuilder';
9
+ export * from './components/ExpressionBuilder';
8
10
  export { default as FlowModeller } from './components/FlowModeller';
9
11
  export * from './components/FlowModeller';
10
12
  export * from './components/ItemLibrary';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACpF,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,SAAS,CAAC","sourcesContent":["// This file is autogenerated. Any changes will be overwritten.\nexport { default as AppHeader } from './components/AppHeader';\nexport * from './components/AppHeader';\nexport { default as AppShell } from './components/AppShell';\nexport * from './components/AppShell';\nexport { default as DynamicContentEditor } from './components/DynamicContentEditor';\nexport * from './components/DynamicContentEditor';\nexport { default as FlowModeller } from './components/FlowModeller';\nexport * from './components/FlowModeller';\nexport * from './components/ItemLibrary';\nexport { default as LifeCycle } from './components/LifeCycle';\nexport * from './components/LifeCycle';\nexport * from './components/ObjectPreview';\nexport { default as ObjectSelect } from './components/ObjectSelect';\nexport * from './components/ObjectSelect';\nexport * from './components/PageTemplates';\nexport * from './components/SummaryCard';\nexport { default as Workbench } from './components/Workbench';\nexport * from './utils';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACpF,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,SAAS,CAAC","sourcesContent":["// This file is autogenerated. Any changes will be overwritten.\nexport { default as AppHeader } from './components/AppHeader';\nexport * from './components/AppHeader';\nexport { default as AppShell } from './components/AppShell';\nexport * from './components/AppShell';\nexport { default as DynamicContentEditor } from './components/DynamicContentEditor';\nexport * from './components/DynamicContentEditor';\nexport { default as ExpressionBuilder } from './components/ExpressionBuilder';\nexport * from './components/ExpressionBuilder';\nexport { default as FlowModeller } from './components/FlowModeller';\nexport * from './components/FlowModeller';\nexport * from './components/ItemLibrary';\nexport { default as LifeCycle } from './components/LifeCycle';\nexport * from './components/LifeCycle';\nexport * from './components/ObjectPreview';\nexport { default as ObjectSelect } from './components/ObjectSelect';\nexport * from './components/ObjectSelect';\nexport * from './components/PageTemplates';\nexport * from './components/SummaryCard';\nexport { default as Workbench } from './components/Workbench';\nexport * from './utils';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-build",
3
- "version": "3.0.0-dev.20.0",
3
+ "version": "3.0.0-dev.21.0",
4
4
  "author": "Pegasystems",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -20,8 +20,8 @@
20
20
  "build": "tsc -b"
21
21
  },
22
22
  "dependencies": {
23
- "@pega/cosmos-react-core": "3.0.0-dev.20.0",
24
- "@pega/cosmos-react-dnd": "3.0.0-dev.20.0",
23
+ "@pega/cosmos-react-core": "3.0.0-dev.21.0",
24
+ "@pega/cosmos-react-dnd": "3.0.0-dev.21.0",
25
25
  "@types/dagre": "^0.7.46",
26
26
  "@types/react": "^16.14.24 || ^17.0.38",
27
27
  "@types/react-dom": "^16.9.14 || ^17.0.11",
@@ -45,6 +45,7 @@
45
45
  "@storybook/theming": "^6.4.19",
46
46
  "@testing-library/jest-dom": "^5.16.2",
47
47
  "@testing-library/react": "^12.1.3",
48
+ "@testing-library/user-event": "^13.5.0",
48
49
  "enzyme": "^3.11.0",
49
50
  "typescript": "~4.7.2"
50
51
  }