@carbon/ibm-products 2.43.2-canary.145 → 2.43.2-canary.149
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +4 -6
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon.css +4 -6
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +4 -6
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/Card/Card.js +4 -2
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +100 -24
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +19 -20
- package/es/components/ConditionBuilder/ConditionBuilder.d.ts +9 -2
- package/es/components/ConditionBuilder/ConditionBuilder.js +9 -6
- package/es/components/ConditionBuilder/ConditionBuilder.types.d.ts +150 -0
- package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.d.ts +26 -12
- package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +6 -6
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +62 -27
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +1 -2
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +84 -37
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.d.ts +29 -14
- package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +5 -6
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +40 -20
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +32 -30
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +10 -49
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +20 -29
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +81 -31
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +5 -5
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.d.ts +27 -12
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.d.ts +30 -12
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +11 -6
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +33 -12
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +5 -4
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.d.ts +32 -12
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +3 -3
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.d.ts +35 -14
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +4 -4
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.d.ts +25 -10
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +44 -17
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +39 -32
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +30 -13
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +1 -2
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -1
- package/es/components/Datagrid/useFiltering.d.ts +1 -0
- package/es/components/Datagrid/useFiltering.js +14 -3
- package/lib/components/Card/Card.js +3 -1
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +100 -24
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +19 -20
- package/lib/components/ConditionBuilder/ConditionBuilder.d.ts +9 -2
- package/lib/components/ConditionBuilder/ConditionBuilder.js +9 -6
- package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +150 -0
- package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.d.ts +26 -12
- package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +6 -6
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +62 -27
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +1 -2
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +84 -37
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.d.ts +29 -14
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +5 -6
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +40 -20
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +32 -30
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +10 -49
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +20 -29
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +81 -31
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +5 -5
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.d.ts +27 -12
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.d.ts +30 -12
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +11 -6
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +33 -12
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +5 -4
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.d.ts +32 -12
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.d.ts +35 -14
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +4 -4
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.d.ts +25 -10
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +44 -17
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +39 -32
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +30 -13
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +1 -2
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -1
- package/lib/components/Datagrid/useFiltering.d.ts +1 -0
- package/lib/components/Datagrid/useFiltering.js +13 -1
- package/package.json +3 -3
- package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +21 -19
@@ -1,32 +1,82 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
type: any;
|
9
|
-
showToolTip: any;
|
10
|
-
condition: any;
|
11
|
-
popOverClassName: any;
|
12
|
-
config: any;
|
13
|
-
renderChildren: any;
|
14
|
-
onChange: any;
|
15
|
-
}): import("react/jsx-runtime").JSX.Element;
|
16
|
-
export namespace ConditionBuilderItem {
|
17
|
-
namespace propTypes {
|
18
|
-
let children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
19
|
-
let className: PropTypes.Requireable<string>;
|
20
|
-
let condition: PropTypes.Requireable<object>;
|
21
|
-
let config: PropTypes.Requireable<object>;
|
22
|
-
let label: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
23
|
-
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
24
|
-
let popOverClassName: PropTypes.Requireable<string>;
|
25
|
-
let renderChildren: PropTypes.Requireable<(...args: any[]) => any>;
|
26
|
-
let renderIcon: PropTypes.Requireable<object>;
|
27
|
-
let showToolTip: PropTypes.Requireable<boolean>;
|
28
|
-
let title: PropTypes.Requireable<string>;
|
29
|
-
let type: PropTypes.Requireable<string>;
|
30
|
-
}
|
31
|
-
}
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import React, { PropsWithChildren, ReactNode, RefObject } from 'react';
|
32
8
|
import PropTypes from 'prop-types';
|
9
|
+
import { CarbonIconType } from '@carbon/react/icons';
|
10
|
+
import { Condition, PropertyConfig, Action, Option } from '../ConditionBuilder.types';
|
11
|
+
interface ConditionBuilderItemProps extends PropsWithChildren {
|
12
|
+
className?: string;
|
13
|
+
label?: string | Option | Option[];
|
14
|
+
renderIcon?: CarbonIconType;
|
15
|
+
title?: string;
|
16
|
+
showToolTip?: boolean;
|
17
|
+
popOverClassName?: string;
|
18
|
+
type?: string;
|
19
|
+
condition?: Action & Condition;
|
20
|
+
config?: PropertyConfig;
|
21
|
+
renderChildren?: (ref: RefObject<HTMLDivElement>) => ReactNode;
|
22
|
+
onChange?: (val: string) => void;
|
23
|
+
tabIndex?: number;
|
24
|
+
onMouseEnter?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
25
|
+
onMouseLeave?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
26
|
+
onFocus?: React.FocusEventHandler<HTMLButtonElement>;
|
27
|
+
onBlur?: React.FocusEventHandler<HTMLButtonElement>;
|
28
|
+
}
|
29
|
+
export declare const ConditionBuilderItem: {
|
30
|
+
({ children, className, label, renderIcon, title, type, showToolTip, condition, popOverClassName, config, renderChildren, onChange, ...rest }: ConditionBuilderItemProps): import("react/jsx-runtime").JSX.Element;
|
31
|
+
propTypes: {
|
32
|
+
/**
|
33
|
+
* provide the contents of the popover
|
34
|
+
*/
|
35
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
36
|
+
/**
|
37
|
+
* Provide an optional class to be applied to the containing node.
|
38
|
+
*/
|
39
|
+
className: PropTypes.Requireable<string>;
|
40
|
+
/**
|
41
|
+
* current condition state object
|
42
|
+
*/
|
43
|
+
condition: PropTypes.Requireable<object>;
|
44
|
+
/**
|
45
|
+
* this is the config object again the current property from inputConfig
|
46
|
+
*/
|
47
|
+
config: PropTypes.Requireable<object>;
|
48
|
+
/**
|
49
|
+
* text to be displayed in the field
|
50
|
+
*/
|
51
|
+
label: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
52
|
+
/**
|
53
|
+
* callback to update the current condition of the state tree
|
54
|
+
*/
|
55
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
56
|
+
/**
|
57
|
+
* class name for popover
|
58
|
+
*/
|
59
|
+
popOverClassName: PropTypes.Requireable<string>;
|
60
|
+
/**
|
61
|
+
* callback prop that returns the jsx for children
|
62
|
+
*/
|
63
|
+
renderChildren: PropTypes.Requireable<(...args: any[]) => any>;
|
64
|
+
/**
|
65
|
+
* Optional prop to allow overriding the icon rendering.
|
66
|
+
*/
|
67
|
+
renderIcon: PropTypes.Requireable<object>;
|
68
|
+
/**
|
69
|
+
* show tool tip
|
70
|
+
*/
|
71
|
+
showToolTip: PropTypes.Requireable<boolean>;
|
72
|
+
/**
|
73
|
+
* title of the popover
|
74
|
+
*/
|
75
|
+
title: PropTypes.Requireable<string>;
|
76
|
+
/**
|
77
|
+
* input type
|
78
|
+
*/
|
79
|
+
type: PropTypes.Requireable<string>;
|
80
|
+
};
|
81
|
+
};
|
82
|
+
export {};
|
@@ -76,7 +76,7 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
76
76
|
if (condition.popoverToOpen && currentField !== condition.popoverToOpen) {
|
77
77
|
// close the previous popover
|
78
78
|
closePopover();
|
79
|
-
} else if (currentField == 'valueField' && type == 'option' && condition.operator !== 'oneOf') {
|
79
|
+
} else if (currentField == 'valueField' && type == 'option' && (condition === null || condition === void 0 ? void 0 : condition.operator) !== 'oneOf') {
|
80
80
|
//close the current popover if the field is valueField and is a single select dropdown. For all other inputs ,popover need to be open on value changes.
|
81
81
|
closePopover();
|
82
82
|
}
|
@@ -94,7 +94,8 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
94
94
|
useEffect(function () {
|
95
95
|
//this will focus the first input field in the popover
|
96
96
|
if (open && popoverRef.current) {
|
97
|
-
var
|
97
|
+
var _popoverRef$current;
|
98
|
+
var firstFocusableElement = popoverRef === null || popoverRef === void 0 || (_popoverRef$current = popoverRef.current) === null || _popoverRef$current === void 0 ? void 0 : _popoverRef$current.querySelector('input,textarea');
|
98
99
|
if (firstFocusableElement) {
|
99
100
|
setTimeout(function () {
|
100
101
|
return firstFocusableElement.focus();
|
@@ -155,10 +156,9 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
155
156
|
className: className,
|
156
157
|
"aria-haspopup": true,
|
157
158
|
"aria-expanded": open,
|
158
|
-
renderIcon: renderIcon ? renderIcon : label == undefined ? Add :
|
159
|
+
renderIcon: renderIcon ? renderIcon : label == undefined ? Add : undefined,
|
159
160
|
showToolTip: showToolTip,
|
160
|
-
isInvalid: isInvalid
|
161
|
-
condition: condition
|
161
|
+
isInvalid: isInvalid
|
162
162
|
}, rest)), open && /*#__PURE__*/React__default.createElement(PopoverContent, {
|
163
163
|
className: "".concat(blockClass, "__popover-content-wrapper"),
|
164
164
|
role: "dialog",
|
@@ -1,13 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
namespace propTypes {
|
8
|
-
let conditionState: PropTypes.Requireable<object>;
|
9
|
-
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
10
|
-
let parentRef: PropTypes.Requireable<object>;
|
11
|
-
}
|
12
|
-
}
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
13
7
|
import PropTypes from 'prop-types';
|
8
|
+
export declare const ConditionBuilderItemDate: {
|
9
|
+
({ conditionState, onChange, parentRef, }: {
|
10
|
+
conditionState: any;
|
11
|
+
onChange: any;
|
12
|
+
parentRef: any;
|
13
|
+
}): import("react/jsx-runtime").JSX.Element;
|
14
|
+
propTypes: {
|
15
|
+
/**
|
16
|
+
* current condition object
|
17
|
+
*/
|
18
|
+
conditionState: PropTypes.Requireable<object>;
|
19
|
+
/**
|
20
|
+
* callback to update state oin date change
|
21
|
+
*/
|
22
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
23
|
+
/**
|
24
|
+
* reference to the popover node
|
25
|
+
*/
|
26
|
+
parentRef: PropTypes.Requireable<object>;
|
27
|
+
};
|
28
|
+
};
|
@@ -17,7 +17,7 @@ var ConditionBuilderItemDate = function ConditionBuilderItemDate(_ref) {
|
|
17
17
|
var conditionState = _ref.conditionState,
|
18
18
|
onChange = _ref.onChange,
|
19
19
|
parentRef = _ref.parentRef;
|
20
|
-
var DatePickerInputRef = useRef();
|
20
|
+
var DatePickerInputRef = useRef(null);
|
21
21
|
var _useTranslations = useTranslations(['startText', 'endText']),
|
22
22
|
_useTranslations2 = _slicedToArray(_useTranslations, 2),
|
23
23
|
startText = _useTranslations2[0],
|
@@ -1,13 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
namespace propTypes {
|
8
|
-
let conditionState: PropTypes.Requireable<object>;
|
9
|
-
let config: PropTypes.Requireable<object>;
|
10
|
-
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
11
|
-
}
|
12
|
-
}
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
13
7
|
import PropTypes from 'prop-types';
|
8
|
+
import { Condition, PropertyConfigNumber } from '../../ConditionBuilder.types';
|
9
|
+
interface ConditionBuilderItemNumberProps {
|
10
|
+
conditionState: Condition;
|
11
|
+
config: PropertyConfigNumber['config'];
|
12
|
+
onChange: (value: string) => void;
|
13
|
+
}
|
14
|
+
export declare const ConditionBuilderItemNumber: {
|
15
|
+
({ conditionState, config, onChange, }: ConditionBuilderItemNumberProps): import("react/jsx-runtime").JSX.Element;
|
16
|
+
propTypes: {
|
17
|
+
/**
|
18
|
+
* current condition object
|
19
|
+
*/
|
20
|
+
conditionState: PropTypes.Requireable<object>;
|
21
|
+
/**
|
22
|
+
* current config object that this property is part of
|
23
|
+
*/
|
24
|
+
config: PropTypes.Requireable<object>;
|
25
|
+
/**
|
26
|
+
* callback to update state oin date change
|
27
|
+
*/
|
28
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
29
|
+
};
|
30
|
+
};
|
31
|
+
export {};
|
@@ -30,25 +30,30 @@ var ConditionBuilderItemNumber = function ConditionBuilderItemNumber(_ref) {
|
|
30
30
|
}
|
31
31
|
};
|
32
32
|
var checkIfValid = function checkIfValid(value) {
|
33
|
-
if (
|
33
|
+
if (config.max !== undefined && config.min === undefined && value > config.max) {
|
34
|
+
return false;
|
35
|
+
}
|
36
|
+
if (config.min !== undefined && config.max === undefined && value < config.min) {
|
37
|
+
return false;
|
38
|
+
}
|
39
|
+
if (config.max !== undefined && config.min !== undefined && (value > config.max || value < config.min)) {
|
34
40
|
return false;
|
35
41
|
}
|
36
42
|
return true;
|
37
43
|
};
|
38
44
|
var getDefaultValue = function getDefaultValue() {
|
39
|
-
var _conditionState$value
|
40
|
-
return (
|
45
|
+
var _split$, _conditionState$value;
|
46
|
+
return (_split$ = (_conditionState$value = conditionState.value) === null || _conditionState$value === void 0 || (_conditionState$value = _conditionState$value.split(' ')) === null || _conditionState$value === void 0 ? void 0 : _conditionState$value[0]) !== null && _split$ !== void 0 ? _split$ : '';
|
41
47
|
};
|
42
48
|
return /*#__PURE__*/React__default.createElement("div", {
|
43
49
|
className: "".concat(blockClass, "__item-number")
|
44
|
-
}, /*#__PURE__*/React__default.createElement(NumberInput, _extends({
|
50
|
+
}, /*#__PURE__*/React__default.createElement(NumberInput, _extends({}, config, {
|
45
51
|
label: conditionState.property,
|
46
52
|
hideLabel: true,
|
47
53
|
id: (_conditionState$prope = conditionState.property) === null || _conditionState$prope === void 0 ? void 0 : _conditionState$prope.replace(/\s/g, ''),
|
48
54
|
invalidText: invalidNumberWarnText,
|
49
55
|
allowEmpty: true,
|
50
|
-
onChange: onChangeHandler
|
51
|
-
}, config, {
|
56
|
+
onChange: onChangeHandler,
|
52
57
|
defaultValue: getDefaultValue()
|
53
58
|
})));
|
54
59
|
};
|
@@ -1,13 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
namespace propTypes {
|
8
|
-
let conditionState: PropTypes.Requireable<object>;
|
9
|
-
let config: PropTypes.Requireable<object>;
|
10
|
-
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
11
|
-
}
|
12
|
-
}
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
13
7
|
import PropTypes from 'prop-types';
|
8
|
+
import { PropertyConfigOption } from '../../ConditionBuilder.types';
|
9
|
+
interface ItemOptionProps {
|
10
|
+
conditionState: {
|
11
|
+
label?: string;
|
12
|
+
value?: string;
|
13
|
+
};
|
14
|
+
config: PropertyConfigOption['config'];
|
15
|
+
onChange: (value: string, e: Event) => void;
|
16
|
+
}
|
17
|
+
export declare const ItemOption: {
|
18
|
+
({ conditionState, config, onChange, }: ItemOptionProps): import("react/jsx-runtime").JSX.Element | undefined;
|
19
|
+
propTypes: {
|
20
|
+
/**
|
21
|
+
* current condition object
|
22
|
+
*/
|
23
|
+
conditionState: PropTypes.Requireable<object>;
|
24
|
+
/**
|
25
|
+
* current config object that this property is part of
|
26
|
+
*/
|
27
|
+
config: PropTypes.Requireable<object>;
|
28
|
+
/**
|
29
|
+
* callback to update state oin date change
|
30
|
+
*/
|
31
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
32
|
+
};
|
33
|
+
};
|
34
|
+
export {};
|
package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js
CHANGED
@@ -22,7 +22,7 @@ var ItemOption = function ItemOption(_ref) {
|
|
22
22
|
onChange = _ref.onChange;
|
23
23
|
var _useContext = useContext(ConditionBuilderContext),
|
24
24
|
popOverSearchThreshold = _useContext.popOverSearchThreshold;
|
25
|
-
var contentRef = useRef();
|
25
|
+
var contentRef = useRef(null);
|
26
26
|
var _useTranslations = useTranslations(['propertyText', 'clearSearchText']),
|
27
27
|
_useTranslations2 = _slicedToArray(_useTranslations, 2),
|
28
28
|
propertyText = _useTranslations2[0],
|
@@ -40,7 +40,8 @@ var ItemOption = function ItemOption(_ref) {
|
|
40
40
|
//this will focus the first input field in the popover
|
41
41
|
|
42
42
|
if (contentRef.current) {
|
43
|
-
var
|
43
|
+
var _contentRef$current;
|
44
|
+
var firstFocusableElement = (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.querySelector('input, button,li');
|
44
45
|
if (firstFocusableElement) {
|
45
46
|
firstFocusableElement.focus();
|
46
47
|
}
|
@@ -54,7 +55,7 @@ var ItemOption = function ItemOption(_ref) {
|
|
54
55
|
setSearchValue(value);
|
55
56
|
};
|
56
57
|
var getAriaLabel = function getAriaLabel() {
|
57
|
-
return conditionState.label ? conditionState.label :
|
58
|
+
return conditionState.label ? conditionState.label : propertyText;
|
58
59
|
};
|
59
60
|
if (!allOptions) {
|
60
61
|
return;
|
@@ -62,7 +63,7 @@ var ItemOption = function ItemOption(_ref) {
|
|
62
63
|
return /*#__PURE__*/React__default.createElement("div", {
|
63
64
|
className: "".concat(blockClass, "__item-option"),
|
64
65
|
ref: contentRef
|
65
|
-
}, allOptions.length > popOverSearchThreshold && /*#__PURE__*/React__default.createElement("div", {
|
66
|
+
}, popOverSearchThreshold && allOptions.length > popOverSearchThreshold && /*#__PURE__*/React__default.createElement("div", {
|
66
67
|
className: "".concat(blockClass, "__item-option__search")
|
67
68
|
}, /*#__PURE__*/React__default.createElement(Search, {
|
68
69
|
size: "sm",
|
@@ -1,13 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
namespace propTypes {
|
8
|
-
let conditionState: PropTypes.Requireable<object>;
|
9
|
-
let config: PropTypes.Requireable<object>;
|
10
|
-
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
11
|
-
}
|
12
|
-
}
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
13
7
|
import PropTypes from 'prop-types';
|
8
|
+
import { Condition, PropertyConfigOption } from '../../ConditionBuilder.types';
|
9
|
+
interface ItemOptionForValueFieldProps {
|
10
|
+
conditionState: Condition & {
|
11
|
+
label?: string;
|
12
|
+
};
|
13
|
+
config: PropertyConfigOption['config'];
|
14
|
+
onChange: (value: any, e?: Event) => void;
|
15
|
+
}
|
16
|
+
export declare const ItemOptionForValueField: {
|
17
|
+
({ conditionState, config, onChange, }: ItemOptionForValueFieldProps): import("react/jsx-runtime").JSX.Element;
|
18
|
+
propTypes: {
|
19
|
+
/**
|
20
|
+
* current condition object
|
21
|
+
*/
|
22
|
+
conditionState: PropTypes.Requireable<object>;
|
23
|
+
/**
|
24
|
+
* current config object that this property is part of
|
25
|
+
*/
|
26
|
+
config: PropTypes.Requireable<object>;
|
27
|
+
/**
|
28
|
+
* callback to update state oin date change
|
29
|
+
*/
|
30
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
31
|
+
};
|
32
|
+
};
|
33
|
+
export {};
|
@@ -30,7 +30,7 @@ var ItemOptionForValueField = function ItemOptionForValueField(_ref) {
|
|
30
30
|
_useTranslations2 = _slicedToArray(_useTranslations, 2),
|
31
31
|
propertyText = _useTranslations2[0],
|
32
32
|
clearSearchText = _useTranslations2[1];
|
33
|
-
var contentRef = useRef();
|
33
|
+
var contentRef = useRef(null);
|
34
34
|
var _useState = useState(config.options),
|
35
35
|
_useState2 = _slicedToArray(_useState, 2),
|
36
36
|
allOptions = _useState2[0],
|
@@ -97,7 +97,7 @@ var ItemOptionForValueField = function ItemOptionForValueField(_ref) {
|
|
97
97
|
if (contentRef.current) {
|
98
98
|
var firstFocusableElement = contentRef.current.querySelector('input, button,li');
|
99
99
|
if (firstFocusableElement) {
|
100
|
-
firstFocusableElement.focus();
|
100
|
+
firstFocusableElement === null || firstFocusableElement === void 0 || firstFocusableElement.focus();
|
101
101
|
}
|
102
102
|
}
|
103
103
|
}, [allOptions]);
|
@@ -138,7 +138,7 @@ var ItemOptionForValueField = function ItemOptionForValueField(_ref) {
|
|
138
138
|
return /*#__PURE__*/React__default.createElement("div", {
|
139
139
|
className: "".concat(blockClass, "__item-option"),
|
140
140
|
ref: contentRef
|
141
|
-
}, allOptions.length > popOverSearchThreshold && /*#__PURE__*/React__default.createElement("div", {
|
141
|
+
}, popOverSearchThreshold && allOptions.length > popOverSearchThreshold && /*#__PURE__*/React__default.createElement("div", {
|
142
142
|
className: "".concat(blockClass, "__item-option__search")
|
143
143
|
}, /*#__PURE__*/React__default.createElement(Search, {
|
144
144
|
size: "sm",
|
@@ -1,15 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
export namespace ConditionBuilderItemText {
|
8
|
-
namespace propTypes {
|
9
|
-
let conditionState: PropTypes.Requireable<object>;
|
10
|
-
let config: PropTypes.Requireable<object>;
|
11
|
-
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
12
|
-
let type: PropTypes.Requireable<string>;
|
13
|
-
}
|
14
|
-
}
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
15
7
|
import PropTypes from 'prop-types';
|
8
|
+
import { Condition, PropertyConfigText, PropertyConfigTextArea } from '../../ConditionBuilder.types';
|
9
|
+
interface ConditionBuilderItemTextProps {
|
10
|
+
conditionState: Condition;
|
11
|
+
config: PropertyConfigText | PropertyConfigTextArea;
|
12
|
+
onChange: (value: string) => void;
|
13
|
+
type: 'textarea' | 'text';
|
14
|
+
}
|
15
|
+
export declare const ConditionBuilderItemText: {
|
16
|
+
({ conditionState, onChange, config, type, }: ConditionBuilderItemTextProps): import("react/jsx-runtime").JSX.Element;
|
17
|
+
propTypes: {
|
18
|
+
/**
|
19
|
+
* current condition object
|
20
|
+
*/
|
21
|
+
conditionState: PropTypes.Requireable<object>;
|
22
|
+
/**
|
23
|
+
* config of the current property
|
24
|
+
*/
|
25
|
+
config: PropTypes.Requireable<object>;
|
26
|
+
/**
|
27
|
+
* callback to update state oin date change
|
28
|
+
*/
|
29
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
30
|
+
/**
|
31
|
+
* current input type
|
32
|
+
*/
|
33
|
+
type: PropTypes.Requireable<string>;
|
34
|
+
};
|
35
|
+
};
|
36
|
+
export {};
|
@@ -18,15 +18,15 @@ var ConditionBuilderItemText = function ConditionBuilderItemText(_ref) {
|
|
18
18
|
_onChange = _ref.onChange,
|
19
19
|
config = _ref.config,
|
20
20
|
type = _ref.type;
|
21
|
-
var inputProps = _objectSpread2({
|
22
|
-
labelText: conditionState.property,
|
21
|
+
var inputProps = _objectSpread2(_objectSpread2({}, config), {}, {
|
23
22
|
hideLabel: true,
|
24
23
|
value: checkIsValid(conditionState.value) ? conditionState.value : '',
|
25
24
|
id: (_conditionState$prope = conditionState.property) === null || _conditionState$prope === void 0 ? void 0 : _conditionState$prope.replace(/\s/g, ''),
|
26
25
|
onChange: function onChange(evt) {
|
27
26
|
_onChange(evt.target.value);
|
28
|
-
}
|
29
|
-
|
27
|
+
},
|
28
|
+
labelText: conditionState.property
|
29
|
+
});
|
30
30
|
return /*#__PURE__*/React__default.createElement("div", {
|
31
31
|
className: "".concat(blockClass, "__item-text")
|
32
32
|
}, type == 'textarea' ? /*#__PURE__*/React__default.createElement(TextArea, inputProps) : /*#__PURE__*/React__default.createElement(TextInput, inputProps));
|
@@ -1,11 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
let config: PropTypes.Requireable<object>;
|
8
|
-
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
9
|
-
}
|
10
|
-
}
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
11
7
|
import PropTypes from 'prop-types';
|
8
|
+
import { PropertyConfigTime } from '../../ConditionBuilder.types';
|
9
|
+
interface ConditionBuilderItemTime {
|
10
|
+
onChange: (value: string | undefined) => void;
|
11
|
+
config: PropertyConfigTime['config'];
|
12
|
+
}
|
13
|
+
export declare const ConditionBuilderItemTime: {
|
14
|
+
({ onChange, config, }: ConditionBuilderItemTime): import("react/jsx-runtime").JSX.Element;
|
15
|
+
propTypes: {
|
16
|
+
/**
|
17
|
+
* current config object that this property is part of
|
18
|
+
*/
|
19
|
+
config: PropTypes.Requireable<object>;
|
20
|
+
/**
|
21
|
+
* callback to update state oin date change
|
22
|
+
*/
|
23
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
24
|
+
};
|
25
|
+
};
|
26
|
+
export {};
|
@@ -1,24 +1,51 @@
|
|
1
|
-
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import PropTypes from 'prop-types';
|
8
|
+
import { ConditionGroup } from '../ConditionBuilder.types';
|
2
9
|
/**
|
3
10
|
*
|
4
11
|
* state - this is the current group that is being rendered . This can be a inner group or outer group
|
5
12
|
* All the inner components of group are called from here.
|
6
13
|
* @returns
|
7
14
|
*/
|
8
|
-
|
9
|
-
group:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
let className: PropTypes.Requireable<string>;
|
19
|
-
let group: PropTypes.Requireable<object>;
|
20
|
-
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
21
|
-
let onRemove: PropTypes.Requireable<(...args: any[]) => any>;
|
22
|
-
}
|
15
|
+
interface ConditionGroupBuilderProps {
|
16
|
+
group: ConditionGroup;
|
17
|
+
onRemove: (e: Event) => void;
|
18
|
+
onChange: (group: ConditionGroup) => void;
|
19
|
+
className?: string;
|
20
|
+
aria: {
|
21
|
+
level: number;
|
22
|
+
posinset: number;
|
23
|
+
setsize: number;
|
24
|
+
};
|
23
25
|
}
|
24
|
-
|
26
|
+
declare const ConditionGroupBuilder: {
|
27
|
+
({ group, aria, onRemove, onChange, className, }: ConditionGroupBuilderProps): import("react/jsx-runtime").JSX.Element;
|
28
|
+
propTypes: {
|
29
|
+
/**
|
30
|
+
* object contains the aria attributes
|
31
|
+
*/
|
32
|
+
aria: PropTypes.Requireable<object>;
|
33
|
+
/**
|
34
|
+
* state defines the current group
|
35
|
+
*/
|
36
|
+
/**
|
37
|
+
* Provide an optional class to be applied to the containing node.
|
38
|
+
*/
|
39
|
+
className: PropTypes.Requireable<string>;
|
40
|
+
group: PropTypes.Requireable<object>;
|
41
|
+
/**
|
42
|
+
* callback to update the current condition of the state tree
|
43
|
+
*/
|
44
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
45
|
+
/**
|
46
|
+
* call back to remove the particular group from the state tree
|
47
|
+
*/
|
48
|
+
onRemove: PropTypes.Requireable<(...args: any[]) => any>;
|
49
|
+
};
|
50
|
+
};
|
51
|
+
export default ConditionGroupBuilder;
|