@pega/cosmos-react-condition-builder 4.0.0-dev.9.1 → 4.0.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.
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts +1 -3
- package/lib/components/ConditionBuilder/AtomicCondition.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/AtomicCondition.js +5 -5
- package/lib/components/ConditionBuilder/AtomicCondition.js.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.js +55 -23
- package/lib/components/ConditionBuilder/ConditionBuilder.js.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts +2 -0
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.js +18 -3
- package/lib/components/ConditionBuilder/ConditionBuilder.styles.js.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +5 -5
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.types.js.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts +1 -3
- package/lib/components/ConditionBuilder/FieldCondition.types.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/FieldCondition.types.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js +3 -3
- package/lib/components/ConditionBuilder/RhsControls/DateFunctionMenu.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts +5 -3
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js +2 -2
- package/lib/components/ConditionBuilder/RhsControls/FieldSelector.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.js +1 -1
- package/lib/components/ConditionBuilder/RhsControls/NumericInput.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js +1 -1
- package/lib/components/ConditionBuilder/RhsControls/RelativeDateMenu.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js +2 -2
- package/lib/components/ConditionBuilder/RhsControls/RhsModeSwitch.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts +0 -2
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js +81 -69
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodInput.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js +2 -1
- package/lib/components/ConditionBuilder/RhsControls/TimePeriodMenu.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts +2 -0
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js +4 -4
- package/lib/components/ConditionBuilder/RhsControls/ValueSelector.js.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts +1 -3
- package/lib/components/ConditionBuilder/RhsControls/index.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/RhsControls/index.js +34 -15
- package/lib/components/ConditionBuilder/RhsControls/index.js.map +1 -1
- package/lib/components/ConditionBuilder/core/evaluator.js +1 -1
- package/lib/components/ConditionBuilder/core/evaluator.js.map +1 -1
- package/lib/components/ConditionBuilder/core/formatter.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/formatter.js +6 -7
- package/lib/components/ConditionBuilder/core/formatter.js.map +1 -1
- package/lib/components/ConditionBuilder/core/rows-reducer.d.ts +1 -1
- package/lib/components/ConditionBuilder/core/rows-reducer.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/transformer.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/transformer.js +3 -2
- package/lib/components/ConditionBuilder/core/transformer.js.map +1 -1
- package/lib/components/ConditionBuilder/core/types.d.ts +17 -17
- package/lib/components/ConditionBuilder/core/types.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/utils.d.ts +2 -6
- package/lib/components/ConditionBuilder/core/utils.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/core/utils.js +4 -7
- package/lib/components/ConditionBuilder/core/utils.js.map +1 -1
- package/lib/components/ConditionBuilder/index.d.ts +3 -3
- package/lib/components/ConditionBuilder/index.d.ts.map +1 -1
- package/lib/components/ConditionBuilder/index.js.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.d.ts.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.js +57 -19
- package/lib/components/ConditionInput/ConditionInput.js.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.styles.js +1 -1
- package/lib/components/ConditionInput/ConditionInput.styles.js.map +1 -1
- package/lib/components/ConditionInput/ConditionInput.types.d.ts +2 -2
- package/lib/components/ConditionInput/ConditionInput.types.d.ts.map +1 -1
- package/lib/components/ConditionInput/index.d.ts +1 -1
- package/lib/components/ConditionInput/index.d.ts.map +1 -1
- package/lib/components/ConditionInput/index.js.map +1 -1
- package/lib/components/ConditionInput/utils.d.ts +7 -5
- package/lib/components/ConditionInput/utils.d.ts.map +1 -1
- package/lib/components/ConditionInput/utils.js +48 -6
- package/lib/components/ConditionInput/utils.js.map +1 -1
- package/lib/components/PromotedFilters/ConditionSelector.d.ts.map +1 -1
- package/lib/components/PromotedFilters/ConditionSelector.js +3 -31
- package/lib/components/PromotedFilters/ConditionSelector.js.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.d.ts.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.js +43 -13
- package/lib/components/PromotedFilters/PromotedFilters.js.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.styles.d.ts.map +1 -1
- package/lib/components/PromotedFilters/PromotedFilters.styles.js +1 -0
- package/lib/components/PromotedFilters/PromotedFilters.styles.js.map +1 -1
- package/lib/components/PromotedFilters/index.d.ts +1 -1
- package/lib/components/PromotedFilters/index.d.ts.map +1 -1
- package/lib/components/PromotedFilters/index.js.map +1 -1
- package/package.json +15 -16
- package/lib/components/ConditionBuilder/HelpButton.d.ts +0 -10
- package/lib/components/ConditionBuilder/HelpButton.d.ts.map +0 -1
- package/lib/components/ConditionBuilder/HelpButton.js +0 -11
- package/lib/components/ConditionBuilder/HelpButton.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useRef, useState, useImperativeHandle } from 'react';
|
|
3
3
|
import { Button, Flex, Icon, Modal, useModalManager, useBreakpoint, useI18n, useModalContext } from '@pega/cosmos-react-core';
|
|
4
4
|
import { splitConditionForBuilder } from '../ConditionBuilder/core/utils';
|
|
5
5
|
import ConditionInput from '../ConditionInput';
|
|
@@ -7,10 +7,11 @@ import { StyledVerticalFieldGroup } from '../ConditionInput/ConditionInput.style
|
|
|
7
7
|
import { basicFieldMap } from '../ConditionInput/utils';
|
|
8
8
|
import ConditionSelector from './ConditionSelector';
|
|
9
9
|
import { StyledPromotedFilters, StyledClearAllButton, StyledTextWithEllipsis } from './PromotedFilters.styles';
|
|
10
|
-
const PromotedFiltersContent = forwardRef(({ filters, condition, onChange, orientation: orientationProp = 'horizontal', handle }, ref)
|
|
10
|
+
const PromotedFiltersContent = forwardRef(function PromotedFiltersContent({ filters, condition, onChange, orientation: orientationProp = 'horizontal', handle }, ref) {
|
|
11
11
|
const t = useI18n();
|
|
12
12
|
const isSmallOrAbove = useBreakpoint('sm');
|
|
13
13
|
const orientation = isSmallOrAbove && orientationProp === 'horizontal' ? 'horizontal' : 'vertical';
|
|
14
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
14
15
|
// map of Conditions indexed by field name
|
|
15
16
|
const conditionsMap = condition
|
|
16
17
|
? splitConditionForBuilder(condition).rows.reduce((result, item) => {
|
|
@@ -34,16 +35,46 @@ const PromotedFiltersContent = forwardRef(({ filters, condition, onChange, orien
|
|
|
34
35
|
})
|
|
35
36
|
};
|
|
36
37
|
};
|
|
38
|
+
// list of fields names used to count down onChange callbacks when Clear All action is invoked
|
|
39
|
+
// if undefined - Clear All was not triggered
|
|
40
|
+
// if stores any values - Clear All is in progress, waiting for all onChange callbacks to be invoked
|
|
41
|
+
const fieldsToClear = useRef(undefined);
|
|
42
|
+
const handleOnChange = (fieldName, newCondition) => {
|
|
43
|
+
// single onChange was invoked
|
|
44
|
+
if (fieldsToClear.current === undefined) {
|
|
45
|
+
onChange(createUpdatedCondition(fieldName, newCondition));
|
|
46
|
+
}
|
|
47
|
+
// prevent main onChange from being called for every onChange invoked from ConditionInput, when Clear All action was run
|
|
48
|
+
// counting down onChange callbacks, to wait when all are done
|
|
49
|
+
else {
|
|
50
|
+
fieldsToClear.current.delete(fieldName);
|
|
51
|
+
if (fieldsToClear.current.size === 0)
|
|
52
|
+
fieldsToClear.current = undefined;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
// ref to store clear handles for all filters
|
|
56
|
+
const handlesRef = useRef([]);
|
|
57
|
+
useImperativeHandle(handle, () => ({
|
|
58
|
+
clear: () => {
|
|
59
|
+
// initialize array with all fields, which trigger onChange callbacks
|
|
60
|
+
fieldsToClear.current = new Set(handlesRef.current.filter(Boolean).map(c => {
|
|
61
|
+
return c.id;
|
|
62
|
+
}));
|
|
63
|
+
handlesRef.current.forEach(item => item.handle.clear());
|
|
64
|
+
onChange();
|
|
65
|
+
}
|
|
66
|
+
}), [onChange]);
|
|
37
67
|
return (_jsx(Flex, { container: {
|
|
38
|
-
|
|
68
|
+
rowGap: 1,
|
|
69
|
+
colGap: 2,
|
|
39
70
|
direction: orientation === 'vertical' ? 'column' : 'row',
|
|
40
71
|
wrap: 'wrap',
|
|
41
72
|
alignItems: orientation === 'vertical' ? 'stretch' : 'start'
|
|
42
|
-
}, ref: ref, children: filters.map(({ field, mode, label, predefinedConditions }) => {
|
|
73
|
+
}, ref: ref, children: filters.map(({ field, mode, label, predefinedConditions }, i) => {
|
|
43
74
|
if (mode !== 'predefined')
|
|
44
|
-
return (_jsx(ConditionInput, { field: field, mode: mode, label: label ?? field.name, condition: conditionsMap[field.name], flat: orientation === 'vertical', onChange: (newCondition) => {
|
|
45
|
-
|
|
46
|
-
}
|
|
75
|
+
return (_jsx(ConditionInput, { field: field, mode: mode, label: label ?? field.name, condition: conditionsMap[field.name], flat: orientation === 'vertical', onChange: newCondition => handleOnChange(field.name, newCondition), handle: (handleItem) => {
|
|
76
|
+
handlesRef.current[i] = { id: field.name, handle: handleItem };
|
|
77
|
+
} }, field.name));
|
|
47
78
|
const selector = (_jsx(ConditionSelector, { label: label ?? field.name, labelHidden: orientation === 'vertical', fields: [
|
|
48
79
|
{
|
|
49
80
|
id: field.name,
|
|
@@ -55,7 +86,7 @@ const PromotedFiltersContent = forwardRef(({ filters, condition, onChange, orien
|
|
|
55
86
|
}, onClear: orientation === 'horizontal'
|
|
56
87
|
? () => onChange(createUpdatedCondition(field.name, undefined))
|
|
57
88
|
: undefined }, field.name));
|
|
58
|
-
return orientation === 'vertical' ? (_jsx(StyledVerticalFieldGroup, { name: label ?? field.name,
|
|
89
|
+
return orientation === 'vertical' ? (_jsx(StyledVerticalFieldGroup, { name: label ?? field.name, collapsed: collapsed, onToggleCollapsed: () => setCollapsed(cur => !cur), actions: [
|
|
59
90
|
{
|
|
60
91
|
id: 'clear',
|
|
61
92
|
text: t('clear'),
|
|
@@ -72,12 +103,14 @@ const FilterModal = ({ filters, condition, onApply }) => {
|
|
|
72
103
|
onApply?.(newCondition);
|
|
73
104
|
dismiss();
|
|
74
105
|
}, [newCondition, onApply]);
|
|
106
|
+
const clearHandle = useRef(null);
|
|
75
107
|
const actions = (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: dismiss, children: t('cancel') }), _jsx(Button, { variant: 'primary', onClick: onApplyClick, children: t('apply') })] }));
|
|
76
108
|
return (_jsxs(Modal, { heading: t('filters'), actions: actions, stretch: true, children: [_jsx(Flex, { container: { justify: 'end' }, children: _jsx(StyledClearAllButton, { variant: 'simple', onClick: () => {
|
|
77
109
|
setNewCondition(undefined);
|
|
78
|
-
|
|
110
|
+
clearHandle.current?.clear();
|
|
111
|
+
}, children: t('clear_all') }) }), _jsx(PromotedFiltersContent, { filters: filters, condition: newCondition, onChange: setNewCondition, orientation: 'vertical', handle: clearHandle })] }));
|
|
79
112
|
};
|
|
80
|
-
export const PromotedFilters = forwardRef(({ filters, condition, onChange, orientation = 'horizontal' }, ref)
|
|
113
|
+
export const PromotedFilters = forwardRef(function PromotedFilters({ filters, condition, onChange, orientation = 'horizontal' }, ref) {
|
|
81
114
|
const t = useI18n();
|
|
82
115
|
const isSmallOrAbove = useBreakpoint('sm');
|
|
83
116
|
const { create } = useModalManager();
|
|
@@ -109,14 +142,11 @@ export const PromotedFilters = forwardRef(({ filters, condition, onChange, orien
|
|
|
109
142
|
alignItems: 'center',
|
|
110
143
|
pad: [0, 0, 1, 0]
|
|
111
144
|
}, children: [_jsx(StyledTextWithEllipsis, { variant: 'h3', children: t('filters') }), _jsx(Button, { variant: 'simple', onClick: () => {
|
|
112
|
-
onChange();
|
|
113
145
|
clearHandle.current?.clear();
|
|
114
146
|
}, children: t('clear_all') })] })), _jsx(PromotedFiltersContent, { filters: filters, onChange: onChange, condition: condition, orientation: orientation, ref: ref, handle: clearHandle }), orientation === 'horizontal' && (_jsx("div", { children: _jsx(StyledClearAllButton, { variant: 'simple', onClick: () => {
|
|
115
|
-
onChange();
|
|
116
147
|
clearHandle.current?.clear();
|
|
117
148
|
}, children: t('promoted_filters_clear_all_button_label') }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(Button, { type: 'button', variant: 'text', onClick: openFiltersModal, children: _jsxs(Flex, { container: { alignItems: 'center', gap: 0.5 }, forwardedAs: 'span', children: [_jsx(Icon, { name: 'filter' }), _jsxs("span", { children: [t('filters'), conditionsCount && `\u00a0(${conditionsCount})`] })] }) }), _jsx(Button, { variant: 'simple', onClick: () => {
|
|
118
149
|
onChange();
|
|
119
|
-
clearHandle.current?.clear();
|
|
120
150
|
}, children: t('clear_all') })] })) }));
|
|
121
151
|
});
|
|
122
152
|
export default PromotedFilters;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromotedFilters.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,MAAM,EACN,IAAI,EAEJ,IAAI,EACJ,KAAK,EAEL,eAAe,EACf,aAAa,EACb,OAAO,EACP,eAAe,EAEhB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAOlC,MAAM,sBAAsB,GAA2D,UAAU,CAC/F,CACE,EACE,OAAO,EACP,SAAS,EACT,QAAQ,EACR,WAAW,EAAE,eAAe,GAAG,YAAY,EAC3C,MAAM,EACgC,EACxC,GAAgC,EAChC,EAAE;IACF,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAC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,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,WAAW,GACnB,EAED,WAAW,KAAK,YAAY,IAAI,CAC/B,wBACE,KAAC,oBAAoB,IACnB,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,GAAG,EAAE;4BACZ,QAAQ,EAAE,CAAC;4BACX,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;wBAC/B,CAAC,YAEA,CAAC,CAAC,yCAAyC,CAAC,GACxB,GACnB,CACP,IACA,CACJ,CAAC,CAAC,CAAC,CACF,8BACE,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,gBAAgB,YAC5D,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,WAAW,EAAC,MAAM,aACrE,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,EACtB,2BACG,CAAC,CAAC,SAAS,CAAC,EACZ,eAAe,IAAI,UAAU,eAAe,GAAG,IAC3C,IACF,GACA,EACT,KAAC,MAAM,IACL,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,GAAG,EAAE;wBACZ,QAAQ,EAAE,CAAC;wBACX,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;oBAC/B,CAAC,YAEA,CAAC,CAAC,WAAW,CAAC,GACR,IACR,CACJ,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useCallback,\n useEffect,\n useRef,\n useState\n} from 'react';\n\nimport {\n Button,\n Flex,\n ForwardProps,\n Icon,\n Modal,\n ModalMethods,\n useModalManager,\n useBreakpoint,\n useI18n,\n useModalContext,\n HandleValue\n} from '@pega/cosmos-react-core';\n\nimport { Condition, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';\nimport { splitConditionForBuilder } from '../ConditionBuilder/core/utils';\nimport ConditionInput from '../ConditionInput';\nimport { StyledVerticalFieldGroup } from '../ConditionInput/ConditionInput.styles';\nimport { basicFieldMap } from '../ConditionInput/utils';\n\nimport ConditionSelector from './ConditionSelector';\nimport { PromotedFiltersProps } from './PromotedFilters.types';\nimport {\n StyledPromotedFilters,\n StyledClearAllButton,\n StyledTextWithEllipsis\n} from './PromotedFilters.styles';\n\nexport interface FilterModalProps extends Pick<PromotedFiltersProps, 'filters' | 'condition'> {\n /** Callback fired on apply of any of the filters */\n onApply?: (condition: Condition | undefined) => void;\n}\n\nconst PromotedFiltersContent: FunctionComponent<PromotedFiltersProps & ForwardProps> = forwardRef(\n (\n {\n filters,\n condition,\n onChange,\n orientation: orientationProp = 'horizontal',\n handle\n }: PropsWithoutRef<PromotedFiltersProps>,\n ref: PromotedFiltersProps['ref']\n ) => {\n const t = useI18n();\n const isSmallOrAbove = useBreakpoint('sm');\n const orientation =\n isSmallOrAbove && orientationProp === 'horizontal' ? 'horizontal' : 'vertical';\n\n // map of Conditions indexed by field name\n const conditionsMap = condition\n ? splitConditionForBuilder(condition).rows.reduce(\n (result: { [key: string]: LeafCondition }, item) => {\n const { id, label, ...leaf } = item;\n result[item.lhs.field] = leaf;\n return result;\n },\n {}\n )\n : {};\n\n const createUpdatedCondition = (key: string, newCondition?: LeafCondition) => {\n if (newCondition) {\n conditionsMap[key] = newCondition;\n } else {\n delete conditionsMap[key];\n }\n\n return Object.values(conditionsMap).length === 0\n ? undefined\n : {\n AND: Object.values(conditionsMap).map(c => {\n return { condition: c } as Condition;\n })\n };\n };\n\n return (\n <Flex\n container={{\n gap: 2,\n direction: orientation === 'vertical' ? 'column' : 'row',\n wrap: 'wrap',\n alignItems: orientation === 'vertical' ? 'stretch' : 'start'\n }}\n ref={ref}\n >\n {filters.map(({ field, mode, label, predefinedConditions }) => {\n if (mode !== 'predefined')\n return (\n <ConditionInput\n key={field.name}\n field={field}\n mode={mode}\n label={label ?? field.name}\n condition={conditionsMap[field.name]}\n flat={orientation === 'vertical'}\n onChange={(newCondition?: LeafCondition) => {\n onChange(createUpdatedCondition(field.name, newCondition));\n }}\n handle={handle}\n />\n );\n\n const selector = (\n <ConditionSelector\n key={field.name}\n label={label ?? field.name}\n labelHidden={orientation === 'vertical'}\n fields={[\n {\n id: field.name,\n type: basicFieldMap[field.type],\n primary: label || field.name\n }\n ]}\n condition={conditionsMap[field.name]}\n conditions={predefinedConditions ?? []}\n onChange={(newCondition?: LeafCondition) => {\n onChange(createUpdatedCondition(field.name, newCondition));\n }}\n onClear={\n orientation === 'horizontal'\n ? () => onChange(createUpdatedCondition(field.name, undefined))\n : undefined\n }\n />\n );\n\n return orientation === 'vertical' ? (\n <StyledVerticalFieldGroup\n key={field.name}\n name={label ?? field.name}\n collapsible\n actions={[\n {\n id: 'clear',\n text: t('clear'),\n onClick: () => onChange(createUpdatedCondition(field.name, undefined))\n }\n ]}\n >\n {selector}\n </StyledVerticalFieldGroup>\n ) : (\n selector\n );\n })}\n </Flex>\n );\n }\n);\n\nconst FilterModal = ({ filters, condition, onApply }: FilterModalProps) => {\n const t = useI18n();\n\n const { dismiss } = useModalContext();\n const [newCondition, setNewCondition] = useState<Condition | undefined>(condition);\n\n const onApplyClick = useCallback(() => {\n onApply?.(newCondition);\n dismiss();\n }, [newCondition, onApply]);\n\n const actions = (\n <>\n <Button onClick={dismiss}>{t('cancel')}</Button>\n <Button variant='primary' onClick={onApplyClick}>\n {t('apply')}\n </Button>\n </>\n );\n\n return (\n <Modal heading={t('filters')} actions={actions} stretch>\n <Flex container={{ justify: 'end' }}>\n <StyledClearAllButton\n variant='simple'\n onClick={() => {\n setNewCondition(undefined);\n }}\n >\n {t('clear_all')}\n </StyledClearAllButton>\n </Flex>\n\n <PromotedFiltersContent\n filters={filters}\n condition={newCondition}\n onChange={setNewCondition}\n orientation='vertical'\n />\n </Modal>\n );\n};\n\nexport const PromotedFilters: FunctionComponent<PromotedFiltersProps & ForwardProps> = forwardRef(\n (\n {\n filters,\n condition,\n onChange,\n orientation = 'horizontal'\n }: PropsWithoutRef<PromotedFiltersProps>,\n ref: PromotedFiltersProps['ref']\n ) => {\n const t = useI18n();\n\n const isSmallOrAbove = useBreakpoint('sm');\n\n const { create } = useModalManager();\n const modalMethods = useRef<ModalMethods<FilterModalProps>>();\n\n // map of Conditions indexed by field name\n const conditionsCount = condition ? splitConditionForBuilder(condition).rows.length : undefined;\n\n useEffect(() => {\n modalMethods.current?.update({\n filters,\n condition\n });\n }, [filters, condition]);\n\n const openFiltersModal = () => {\n modalMethods.current = create(FilterModal, {\n filters,\n condition,\n onApply: onChange\n });\n };\n\n const clearHandle = useRef<HandleValue>(null);\n\n return (\n <Flex\n as={StyledPromotedFilters}\n container={{\n alignItems: orientation === 'horizontal' && isSmallOrAbove ? 'start' : undefined,\n justify: 'between',\n direction: !isSmallOrAbove || orientation === 'horizontal' ? 'row' : 'column',\n pad: 2,\n gap: 2\n }}\n ref={ref}\n >\n {isSmallOrAbove ? (\n <>\n {orientation === 'vertical' && (\n <Flex\n container={{\n justify: 'between',\n alignItems: 'center',\n pad: [0, 0, 1, 0]\n }}\n >\n <StyledTextWithEllipsis variant='h3'>{t('filters')}</StyledTextWithEllipsis>\n <Button\n variant='simple'\n onClick={() => {\n onChange();\n clearHandle.current?.clear();\n }}\n >\n {t('clear_all')}\n </Button>\n </Flex>\n )}\n\n <PromotedFiltersContent\n filters={filters}\n onChange={onChange}\n condition={condition}\n orientation={orientation}\n ref={ref}\n handle={clearHandle}\n />\n\n {orientation === 'horizontal' && (\n <div>\n <StyledClearAllButton\n variant='simple'\n onClick={() => {\n onChange();\n clearHandle.current?.clear();\n }}\n >\n {t('promoted_filters_clear_all_button_label')}\n </StyledClearAllButton>\n </div>\n )}\n </>\n ) : (\n <>\n <Button type='button' variant='text' onClick={openFiltersModal}>\n <Flex container={{ alignItems: 'center', gap: 0.5 }} forwardedAs='span'>\n <Icon name='filter' />\n <span>\n {t('filters')}\n {conditionsCount && `\\u00a0(${conditionsCount})`}\n </span>\n </Flex>\n </Button>\n <Button\n variant='simple'\n onClick={() => {\n onChange();\n clearHandle.current?.clear();\n }}\n >\n {t('clear_all')}\n </Button>\n </>\n )}\n </Flex>\n );\n }\n);\n\nexport default PromotedFilters;\n"]}
|
|
1
|
+
{"version":3,"file":"PromotedFilters.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,EACR,mBAAmB,EACpB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,MAAM,EACN,IAAI,EAEJ,IAAI,EACJ,KAAK,EAEL,eAAe,EACf,aAAa,EACb,OAAO,EACP,eAAe,EAEhB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAclC,MAAM,sBAAsB,GAA2D,UAAU,CAC/F,SAAS,sBAAsB,CAC7B,EACE,OAAO,EACP,SAAS,EACT,QAAQ,EACR,WAAW,EAAE,eAAe,GAAG,YAAY,EAC3C,MAAM,EACgC,EACxC,GAAgC;IAEhC,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,WAAW,GACf,cAAc,IAAI,eAAe,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,C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AAK,EAAE,CAAC;4BAC/B,CAAC,YAEA,CAAC,CAAC,WAAW,CAAC,GACR,IACJ,CACR,EAED,KAAC,sBAAsB,IACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,WAAW,GACnB,EAED,WAAW,KAAK,YAAY,IAAI,CAC/B,wBACE,KAAC,oBAAoB,IACnB,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,GAAG,EAAE;4BACZ,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;wBAC/B,CAAC,YAEA,CAAC,CAAC,yCAAyC,CAAC,GACxB,GACnB,CACP,IACA,CACJ,CAAC,CAAC,CAAC,CACF,8BACE,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,gBAAgB,YAC5D,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,WAAW,EAAC,MAAM,aACrE,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,EACtB,2BACG,CAAC,CAAC,SAAS,CAAC,EACZ,eAAe,IAAI,UAAU,eAAe,GAAG,IAC3C,IACF,GACA,EACT,KAAC,MAAM,IACL,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,GAAG,EAAE;wBACZ,QAAQ,EAAE,CAAC;oBACb,CAAC,YAEA,CAAC,CAAC,WAAW,CAAC,GACR,IACR,CACJ,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useCallback,\n useEffect,\n useRef,\n useState,\n useImperativeHandle\n} from 'react';\n\nimport {\n Button,\n Flex,\n ForwardProps,\n Icon,\n Modal,\n ModalMethods,\n useModalManager,\n useBreakpoint,\n useI18n,\n useModalContext,\n HandleValue\n} from '@pega/cosmos-react-core';\n\nimport { Condition, LeafCondition } from '../ConditionBuilder/ConditionBuilder.types';\nimport { splitConditionForBuilder } from '../ConditionBuilder/core/utils';\nimport ConditionInput from '../ConditionInput';\nimport { StyledVerticalFieldGroup } from '../ConditionInput/ConditionInput.styles';\nimport { basicFieldMap } from '../ConditionInput/utils';\n\nimport ConditionSelector from './ConditionSelector';\nimport { PromotedFiltersProps } from './PromotedFilters.types';\nimport {\n StyledPromotedFilters,\n StyledClearAllButton,\n StyledTextWithEllipsis\n} from './PromotedFilters.styles';\n\nexport interface FilterModalProps extends Pick<PromotedFiltersProps, 'filters' | 'condition'> {\n /** Callback fired on apply of any of the filters */\n onApply?: (condition: Condition | undefined) => void;\n}\n\ninterface HandleValueObj {\n /** Identifier for the corresponding field */\n id: string;\n /** Handle value for clear action */\n handle: HandleValue;\n}\n\nconst PromotedFiltersContent: FunctionComponent<PromotedFiltersProps & ForwardProps> = forwardRef(\n function PromotedFiltersContent(\n {\n filters,\n condition,\n onChange,\n orientation: orientationProp = 'horizontal',\n handle\n }: PropsWithoutRef<PromotedFiltersProps>,\n ref: PromotedFiltersProps['ref']\n ) {\n const t = useI18n();\n const isSmallOrAbove = useBreakpoint('sm');\n const orientation =\n isSmallOrAbove && orientationProp === 'horizontal' ? 'horizontal' : 'vertical';\n const [collapsed, setCollapsed] = useState(false);\n\n // map of Conditions indexed by field name\n const conditionsMap = condition\n ? splitConditionForBuilder(condition).rows.reduce(\n (result: { [key: string]: LeafCondition }, item) => {\n const { id, label, ...leaf } = item;\n result[item.lhs.field] = leaf;\n return result;\n },\n {}\n )\n : {};\n\n const createUpdatedCondition = (key: string, newCondition?: LeafCondition) => {\n if (newCondition) {\n conditionsMap[key] = newCondition;\n } else {\n delete conditionsMap[key];\n }\n\n return Object.values(conditionsMap).length === 0\n ? undefined\n : {\n AND: Object.values(conditionsMap).map(c => {\n return { condition: c } as Condition;\n })\n };\n };\n\n // list of fields names used to count down onChange callbacks when Clear All action is invoked\n // if undefined - Clear All was not triggered\n // if stores any values - Clear All is in progress, waiting for all onChange callbacks to be invoked\n const fieldsToClear = useRef<Set<string> | undefined>(undefined);\n\n const handleOnChange = (fieldName: string, newCondition?: LeafCondition) => {\n // single onChange was invoked\n if (fieldsToClear.current === undefined) {\n onChange(createUpdatedCondition(fieldName, newCondition));\n }\n // prevent main onChange from being called for every onChange invoked from ConditionInput, when Clear All action was run\n // counting down onChange callbacks, to wait when all are done\n else {\n fieldsToClear.current.delete(fieldName);\n if (fieldsToClear.current.size === 0) fieldsToClear.current = undefined;\n }\n };\n\n // ref to store clear handles for all filters\n const handlesRef = useRef<HandleValueObj[]>([]);\n\n useImperativeHandle(\n handle,\n () => ({\n clear: () => {\n // initialize array with all fields, which trigger onChange callbacks\n fieldsToClear.current = new Set(\n handlesRef.current.filter(Boolean).map(c => {\n return c.id;\n })\n );\n handlesRef.current.forEach(item => item.handle.clear());\n onChange();\n }\n }),\n [onChange]\n );\n\n return (\n <Flex\n container={{\n rowGap: 1,\n colGap: 2,\n direction: orientation === 'vertical' ? 'column' : 'row',\n wrap: 'wrap',\n alignItems: orientation === 'vertical' ? 'stretch' : 'start'\n }}\n ref={ref}\n >\n {filters.map(({ field, mode, label, predefinedConditions }, i) => {\n if (mode !== 'predefined')\n return (\n <ConditionInput\n key={field.name}\n field={field}\n mode={mode}\n label={label ?? field.name}\n condition={conditionsMap[field.name]}\n flat={orientation === 'vertical'}\n onChange={newCondition => handleOnChange(field.name, newCondition)}\n handle={(handleItem: HandleValue) => {\n handlesRef.current[i] = { id: field.name, handle: handleItem };\n }}\n />\n );\n\n const selector = (\n <ConditionSelector\n key={field.name}\n label={label ?? field.name}\n labelHidden={orientation === 'vertical'}\n fields={[\n {\n id: field.name,\n type: basicFieldMap[field.type],\n primary: label || field.name\n }\n ]}\n condition={conditionsMap[field.name]}\n conditions={predefinedConditions ?? []}\n onChange={(newCondition?: LeafCondition) => {\n onChange(createUpdatedCondition(field.name, newCondition));\n }}\n onClear={\n orientation === 'horizontal'\n ? () => onChange(createUpdatedCondition(field.name, undefined))\n : undefined\n }\n />\n );\n\n return orientation === 'vertical' ? (\n <StyledVerticalFieldGroup\n key={field.name}\n name={label ?? field.name}\n collapsed={collapsed}\n onToggleCollapsed={() => setCollapsed(cur => !cur)}\n actions={[\n {\n id: 'clear',\n text: t('clear'),\n onClick: () => onChange(createUpdatedCondition(field.name, undefined))\n }\n ]}\n >\n {selector}\n </StyledVerticalFieldGroup>\n ) : (\n selector\n );\n })}\n </Flex>\n );\n }\n);\n\nconst FilterModal = ({ filters, condition, onApply }: FilterModalProps) => {\n const t = useI18n();\n\n const { dismiss } = useModalContext();\n const [newCondition, setNewCondition] = useState<Condition | undefined>(condition);\n\n const onApplyClick = useCallback(() => {\n onApply?.(newCondition);\n dismiss();\n }, [newCondition, onApply]);\n\n const clearHandle = useRef<HandleValue>(null);\n\n const actions = (\n <>\n <Button onClick={dismiss}>{t('cancel')}</Button>\n <Button variant='primary' onClick={onApplyClick}>\n {t('apply')}\n </Button>\n </>\n );\n\n return (\n <Modal heading={t('filters')} actions={actions} stretch>\n <Flex container={{ justify: 'end' }}>\n <StyledClearAllButton\n variant='simple'\n onClick={() => {\n setNewCondition(undefined);\n clearHandle.current?.clear();\n }}\n >\n {t('clear_all')}\n </StyledClearAllButton>\n </Flex>\n\n <PromotedFiltersContent\n filters={filters}\n condition={newCondition}\n onChange={setNewCondition}\n orientation='vertical'\n handle={clearHandle}\n />\n </Modal>\n );\n};\n\nexport const PromotedFilters: FunctionComponent<PromotedFiltersProps & ForwardProps> = forwardRef(\n function PromotedFilters(\n {\n filters,\n condition,\n onChange,\n orientation = 'horizontal'\n }: PropsWithoutRef<PromotedFiltersProps>,\n ref: PromotedFiltersProps['ref']\n ) {\n const t = useI18n();\n\n const isSmallOrAbove = useBreakpoint('sm');\n\n const { create } = useModalManager();\n const modalMethods = useRef<ModalMethods<FilterModalProps>>();\n\n // map of Conditions indexed by field name\n const conditionsCount = condition ? splitConditionForBuilder(condition).rows.length : undefined;\n\n useEffect(() => {\n modalMethods.current?.update({\n filters,\n condition\n });\n }, [filters, condition]);\n\n const openFiltersModal = () => {\n modalMethods.current = create(FilterModal, {\n filters,\n condition,\n onApply: onChange\n });\n };\n\n const clearHandle = useRef<HandleValue>(null);\n\n return (\n <Flex\n as={StyledPromotedFilters}\n container={{\n alignItems: orientation === 'horizontal' && isSmallOrAbove ? 'start' : undefined,\n justify: 'between',\n direction: !isSmallOrAbove || orientation === 'horizontal' ? 'row' : 'column',\n pad: 2,\n gap: 2\n }}\n ref={ref}\n >\n {isSmallOrAbove ? (\n <>\n {orientation === 'vertical' && (\n <Flex\n container={{\n justify: 'between',\n alignItems: 'center',\n pad: [0, 0, 1, 0]\n }}\n >\n <StyledTextWithEllipsis variant='h3'>{t('filters')}</StyledTextWithEllipsis>\n <Button\n variant='simple'\n onClick={() => {\n clearHandle.current?.clear();\n }}\n >\n {t('clear_all')}\n </Button>\n </Flex>\n )}\n\n <PromotedFiltersContent\n filters={filters}\n onChange={onChange}\n condition={condition}\n orientation={orientation}\n ref={ref}\n handle={clearHandle}\n />\n\n {orientation === 'horizontal' && (\n <div>\n <StyledClearAllButton\n variant='simple'\n onClick={() => {\n clearHandle.current?.clear();\n }}\n >\n {t('promoted_filters_clear_all_button_label')}\n </StyledClearAllButton>\n </div>\n )}\n </>\n ) : (\n <>\n <Button type='button' variant='text' onClick={openFiltersModal}>\n <Flex container={{ alignItems: 'center', gap: 0.5 }} forwardedAs='span'>\n <Icon name='filter' />\n <span>\n {t('filters')}\n {conditionsCount && `\\u00a0(${conditionsCount})`}\n </span>\n </Flex>\n </Button>\n <Button\n variant='simple'\n onClick={() => {\n onChange();\n }}\n >\n {t('clear_all')}\n </Button>\n </>\n )}\n </Flex>\n );\n }\n);\n\nexport default PromotedFilters;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromotedFilters.styles.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.styles.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"PromotedFilters.styles.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.styles.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,yGAgBhC,CAAC;AAIH,eAAO,MAAM,oBAAoB,qOAOhC,CAAC;AAIF,eAAO,MAAM,sBAAsB,mOAIlC,CAAC"}
|
|
@@ -6,6 +6,7 @@ export const StyledPromotedFilters = styled.div(({ theme }) => {
|
|
|
6
6
|
return css `
|
|
7
7
|
border-radius: ${theme.components.card['border-radius']};
|
|
8
8
|
background-color: ${theme.base.palette['secondary-background']};
|
|
9
|
+
padding-block: ${theme.base.spacing};
|
|
9
10
|
|
|
10
11
|
${StyledSelectInput} {
|
|
11
12
|
min-width: calc(${theme.base['content-width'].xs} + ${theme.base['hit-area']['mouse-min']});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromotedFilters.styles.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/PromotedFilters.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2DAA2D,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iEAAiE,CAAC;AAEpG,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC5D,OAAO,GAAG,CAAA;qBACS,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC;wBACnC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC;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AG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp, Button, Text } from '@pega/cosmos-react-core';\nimport { StyledModalChildrenWrap } from '@pega/cosmos-react-core/lib/components/Modal/Modal.styles';\nimport { StyledSelectInput } from '@pega/cosmos-react-core/lib/components/ComboBox/ComboBox.styles';\n\nexport const StyledPromotedFilters = styled.div(({ theme }) => {\n return css`\n border-radius: ${theme.components.card['border-radius']};\n background-color: ${theme.base.palette['secondary-background']};\n padding-block: ${theme.base.spacing};\n\n ${StyledSelectInput} {\n min-width: calc(${theme.base['content-width'].xs} + ${theme.base['hit-area']['mouse-min']});\n\n @media (pointer: coarse) {\n min-width: calc(\n ${theme.base['content-width'].xs} + ${theme.base['hit-area']['finger-min']}\n );\n }\n }\n `;\n});\n\nStyledPromotedFilters.defaultProps = defaultThemeProp;\n\nexport const StyledClearAllButton = styled(Button)`\n margin: 1.125rem 0 0.625rem;\n white-space: nowrap;\n\n ${StyledModalChildrenWrap} & {\n margin-top: 0;\n }\n`;\n\nStyledClearAllButton.defaultProps = defaultThemeProp;\n\nexport const StyledTextWithEllipsis = styled(Text)`\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n`;\n\nStyledTextWithEllipsis.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PromotedFilters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { default } from './PromotedFilters';\nexport { PromotedFiltersProps, PromotedFilter } from './PromotedFilters.types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/PromotedFilters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { default } from './PromotedFilters';\nexport type { PromotedFiltersProps, PromotedFilter } from './PromotedFilters.types';\n"]}
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-condition-builder",
|
|
3
|
-
"version": "4.0.0
|
|
4
|
-
"author": "Pegasystems",
|
|
5
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
3
|
+
"version": "4.0.0",
|
|
6
4
|
"repository": {
|
|
7
5
|
"type": "git",
|
|
8
6
|
"url": "https://github.com/pegasystems/cosmos-react.git",
|
|
9
7
|
"directory": "packages/cosmos-condition-builder"
|
|
10
8
|
},
|
|
9
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
10
|
+
"author": "Pegasystems",
|
|
11
|
+
"sideEffects": [
|
|
12
|
+
"./src/components/ConditionBuilder/core/extendDayJs.ts",
|
|
13
|
+
"./lib/components/ConditionBuilder/core/extendDayJs.js"
|
|
14
|
+
],
|
|
11
15
|
"main": "lib/index.js",
|
|
12
16
|
"types": "lib/index.d.ts",
|
|
13
17
|
"files": [
|
|
@@ -15,15 +19,11 @@
|
|
|
15
19
|
"README.md",
|
|
16
20
|
"lib"
|
|
17
21
|
],
|
|
18
|
-
"sideEffects": [
|
|
19
|
-
"./src/components/ConditionBuilder/core/extendDayJs.ts",
|
|
20
|
-
"./lib/components/ConditionBuilder/core/extendDayJs.js"
|
|
21
|
-
],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsc -b"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@pega/cosmos-react-core": "4.0.0
|
|
26
|
+
"@pega/cosmos-react-core": "4.0.0",
|
|
27
27
|
"@types/react": "^16.14.24 || ^17.0.38",
|
|
28
28
|
"@types/react-dom": "^16.9.14 || ^17.0.11",
|
|
29
29
|
"@types/styled-components": "^5.1.26",
|
|
@@ -34,15 +34,14 @@
|
|
|
34
34
|
"styled-components": "^5.2.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@storybook/addon-a11y": "^
|
|
38
|
-
"@storybook/addon-actions": "^
|
|
39
|
-
"@storybook/addon-storysource": "^
|
|
40
|
-
"@storybook/addon-toolbars": "^
|
|
41
|
-
"@storybook/
|
|
42
|
-
"@storybook/
|
|
43
|
-
"@storybook/theming": "^6.4.19",
|
|
37
|
+
"@storybook/addon-a11y": "^7.0.24",
|
|
38
|
+
"@storybook/addon-actions": "^7.0.24",
|
|
39
|
+
"@storybook/addon-storysource": "^7.0.24",
|
|
40
|
+
"@storybook/addon-toolbars": "^7.0.24",
|
|
41
|
+
"@storybook/react": "^7.0.24",
|
|
42
|
+
"@storybook/theming": "^7.0.24",
|
|
44
43
|
"@testing-library/react": "^12.1.3",
|
|
45
44
|
"@testing-library/user-event": "^13.5.0",
|
|
46
|
-
"typescript": "~
|
|
45
|
+
"typescript": "~5.0.2"
|
|
47
46
|
}
|
|
48
47
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { BaseProps, ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
interface HelpButtonProps extends BaseProps {
|
|
4
|
-
/** Content to show on hover of the button */
|
|
5
|
-
children: string;
|
|
6
|
-
}
|
|
7
|
-
/** Renders an inline Help icon that shows help content on hover */
|
|
8
|
-
declare const HelpButton: FunctionComponent<HelpButtonProps & ForwardProps>;
|
|
9
|
-
export default HelpButton;
|
|
10
|
-
//# sourceMappingURL=HelpButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HelpButton.d.ts","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/HelpButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAGL,SAAS,EACT,YAAY,EAGb,MAAM,yBAAyB,CAAC;AAEjC,UAAU,eAAgB,SAAQ,SAAS;IACzC,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,mEAAmE;AACnE,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,GAAG,YAAY,CAejE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Icon, Tooltip, useElement, useUID } from '@pega/cosmos-react-core';
|
|
3
|
-
/** Renders an inline Help icon that shows help content on hover */
|
|
4
|
-
const HelpButton = (props) => {
|
|
5
|
-
const { children } = props;
|
|
6
|
-
const [iconEl, setIconEl] = useElement();
|
|
7
|
-
const id = useUID();
|
|
8
|
-
return (_jsxs(_Fragment, { children: [_jsx(Icon, { name: 'information', ref: setIconEl, "aria-describedby": id }), iconEl && (_jsx(Tooltip, { target: iconEl, id: id, children: children }))] }));
|
|
9
|
-
};
|
|
10
|
-
export default HelpButton;
|
|
11
|
-
//# sourceMappingURL=HelpButton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HelpButton.js","sourceRoot":"","sources":["../../../src/components/ConditionBuilder/HelpButton.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,IAAI,EACJ,OAAO,EAGP,UAAU,EACV,MAAM,EACP,MAAM,yBAAyB,CAAC;AAOjC,mEAAmE;AACnE,MAAM,UAAU,GAAsD,CAAC,KAAsB,EAAE,EAAE;IAC/F,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,UAAU,EAAE,CAAC;IACzC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAEpB,OAAO,CACL,8BACE,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,EAAC,GAAG,EAAE,SAAS,sBAAoB,EAAE,GAAI,EAChE,MAAM,IAAI,CACT,KAAC,OAAO,IAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,YAC5B,QAAQ,GACD,CACX,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FunctionComponent } from 'react';\n\nimport {\n Icon,\n Tooltip,\n BaseProps,\n ForwardProps,\n useElement,\n useUID\n} from '@pega/cosmos-react-core';\n\ninterface HelpButtonProps extends BaseProps {\n /** Content to show on hover of the button */\n children: string;\n}\n\n/** Renders an inline Help icon that shows help content on hover */\nconst HelpButton: FunctionComponent<HelpButtonProps & ForwardProps> = (props: HelpButtonProps) => {\n const { children } = props;\n const [iconEl, setIconEl] = useElement();\n const id = useUID();\n\n return (\n <>\n <Icon name='information' ref={setIconEl} aria-describedby={id} />\n {iconEl && (\n <Tooltip target={iconEl} id={id}>\n {children}\n </Tooltip>\n )}\n </>\n );\n};\n\nexport default HelpButton;\n"]}
|