@carbon/ibm-products 2.73.1 → 2.74.0-rc.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 (154) hide show
  1. package/css/index-full-carbon.css +56 -6
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +5 -1
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +56 -6
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +1 -1
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +56 -6
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +1 -1
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/AboutModal/AboutModal.d.ts +17 -23
  18. package/es/components/AboutModal/AboutModal.js +17 -23
  19. package/es/components/AddSelect/AddSelectBody.js +1 -1
  20. package/es/components/Carousel/Carousel.js +1 -1
  21. package/es/components/Coachmark/Coachmark.d.ts +4 -0
  22. package/es/components/Coachmark/Coachmark.js +9 -2
  23. package/es/components/Coachmark/CoachmarkDragbar.d.ts +0 -4
  24. package/es/components/Coachmark/CoachmarkDragbar.js +2 -6
  25. package/es/components/Coachmark/CoachmarkHeader.d.ts +0 -4
  26. package/es/components/Coachmark/CoachmarkHeader.js +2 -2
  27. package/es/components/Coachmark/CoachmarkTagline.js +5 -3
  28. package/es/components/Coachmark/next/Coachmark/Coachmark.d.ts +1 -22
  29. package/es/components/Coachmark/next/Coachmark/Coachmark.js +14 -29
  30. package/es/components/Coachmark/next/Coachmark/CoachmarkBeacon/CoachmarkBeacon.d.ts +1 -0
  31. package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.js +13 -2
  32. package/es/components/Coachmark/next/Coachmark/CoachmarkContent.js +2 -2
  33. package/es/components/Coachmark/next/Coachmark/ContentBody.js +1 -1
  34. package/es/components/Coachmark/next/Coachmark/ContentHeader.js +15 -1
  35. package/es/components/Coachmark/next/Coachmark/context.d.ts +25 -0
  36. package/es/components/Coachmark/next/Coachmark/context.js +28 -0
  37. package/es/components/Coachmark/utils/context.d.ts +2 -2
  38. package/es/components/CoachmarkFixed/CoachmarkFixed.d.ts +4 -0
  39. package/es/components/CoachmarkFixed/CoachmarkFixed.js +6 -1
  40. package/es/components/CoachmarkStack/CoachmarkStack.d.ts +4 -0
  41. package/es/components/CoachmarkStack/CoachmarkStack.js +7 -1
  42. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +11 -7
  43. package/es/components/ConditionBuilder/ConditionBuilder.js +11 -2
  44. package/es/components/ConditionBuilder/ConditionBuilder.types.d.ts +10 -0
  45. package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +10 -5
  46. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +14 -3
  47. package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +2 -2
  48. package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +1 -1
  49. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +5 -4
  50. package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +2 -1
  51. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +8 -2
  52. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +4 -3
  53. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +20 -4
  54. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +1 -1
  55. package/es/components/ConditionBuilder/index.d.ts +1 -0
  56. package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +12 -7
  57. package/es/components/ConditionBuilder/utils/useDataConfigs.d.ts +1 -1
  58. package/es/components/ConditionBuilder/utils/util.d.ts +1 -1
  59. package/es/components/ConditionBuilder/utils/util.js +2 -2
  60. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +1 -1
  61. package/es/components/EmptyStates/EmptyState.js +1 -1
  62. package/es/components/EmptyStates/{EmptyStateV2.js → EmptyStateV2.deprecated.js} +1 -1
  63. package/es/components/EmptyStates/index.d.ts +2 -2
  64. package/es/components/NotificationsPanel/NotificationsPanel.js +1 -1
  65. package/es/components/SidePanel/SidePanel.d.ts +1 -0
  66. package/es/components/SidePanel/SidePanel.js +1 -0
  67. package/es/components/StepFlow/StepContext.d.ts +14 -0
  68. package/es/components/StepFlow/StepGroup.d.ts +10 -0
  69. package/es/components/StepFlow/index.d.ts +9 -0
  70. package/es/components/StepFlow/story-assets/SidePanel/Example.d.ts +8 -0
  71. package/es/components/StepFlow/story-assets/SidePanel/StepSidePanel.d.ts +20 -0
  72. package/es/components/StepFlow/story-assets/StepActions.d.ts +23 -0
  73. package/es/components/StepFlow/story-assets/Tearsheet/Example.d.ts +8 -0
  74. package/es/components/StepFlow/story-assets/Tearsheet/StepTearsheet.d.ts +20 -0
  75. package/es/components/StepFlow/types.d.ts +22 -0
  76. package/es/components/TruncatedText/TruncatedText.js +4 -2
  77. package/es/global/js/utils/makeDraggable/makeDraggable.js +28 -0
  78. package/es/index.js +1 -1
  79. package/lib/components/AboutModal/AboutModal.d.ts +17 -23
  80. package/lib/components/AboutModal/AboutModal.js +17 -23
  81. package/lib/components/AddSelect/AddSelectBody.js +1 -1
  82. package/lib/components/Carousel/Carousel.js +1 -1
  83. package/lib/components/Coachmark/Coachmark.d.ts +4 -0
  84. package/lib/components/Coachmark/Coachmark.js +9 -2
  85. package/lib/components/Coachmark/CoachmarkDragbar.d.ts +0 -4
  86. package/lib/components/Coachmark/CoachmarkDragbar.js +2 -6
  87. package/lib/components/Coachmark/CoachmarkHeader.d.ts +0 -4
  88. package/lib/components/Coachmark/CoachmarkHeader.js +2 -2
  89. package/lib/components/Coachmark/CoachmarkTagline.js +5 -3
  90. package/lib/components/Coachmark/next/Coachmark/Coachmark.d.ts +1 -22
  91. package/lib/components/Coachmark/next/Coachmark/Coachmark.js +16 -33
  92. package/lib/components/Coachmark/next/Coachmark/CoachmarkBeacon/CoachmarkBeacon.d.ts +1 -0
  93. package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.js +13 -2
  94. package/lib/components/Coachmark/next/Coachmark/CoachmarkContent.js +5 -5
  95. package/lib/components/Coachmark/next/Coachmark/ContentBody.js +2 -2
  96. package/lib/components/Coachmark/next/Coachmark/ContentHeader.js +17 -3
  97. package/lib/components/Coachmark/next/Coachmark/context.d.ts +25 -0
  98. package/lib/components/Coachmark/next/Coachmark/context.js +31 -0
  99. package/lib/components/Coachmark/utils/context.d.ts +2 -2
  100. package/lib/components/CoachmarkFixed/CoachmarkFixed.d.ts +4 -0
  101. package/lib/components/CoachmarkFixed/CoachmarkFixed.js +6 -1
  102. package/lib/components/CoachmarkStack/CoachmarkStack.d.ts +4 -0
  103. package/lib/components/CoachmarkStack/CoachmarkStack.js +7 -1
  104. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +11 -7
  105. package/lib/components/ConditionBuilder/ConditionBuilder.js +11 -2
  106. package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +10 -0
  107. package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +10 -5
  108. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +13 -2
  109. package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +2 -2
  110. package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +1 -1
  111. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +5 -4
  112. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +2 -1
  113. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +8 -2
  114. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +4 -3
  115. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +20 -4
  116. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +1 -1
  117. package/lib/components/ConditionBuilder/index.d.ts +1 -0
  118. package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +11 -6
  119. package/lib/components/ConditionBuilder/utils/useDataConfigs.d.ts +1 -1
  120. package/lib/components/ConditionBuilder/utils/util.d.ts +1 -1
  121. package/lib/components/ConditionBuilder/utils/util.js +2 -2
  122. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +1 -1
  123. package/lib/components/EmptyStates/EmptyState.js +2 -2
  124. package/lib/components/EmptyStates/{EmptyStateV2.js → EmptyStateV2.deprecated.js} +2 -2
  125. package/lib/components/EmptyStates/index.d.ts +2 -2
  126. package/lib/components/NotificationsPanel/NotificationsPanel.js +1 -1
  127. package/lib/components/SidePanel/SidePanel.d.ts +1 -0
  128. package/lib/components/SidePanel/SidePanel.js +1 -0
  129. package/lib/components/StepFlow/StepContext.d.ts +14 -0
  130. package/lib/components/StepFlow/StepGroup.d.ts +10 -0
  131. package/lib/components/StepFlow/index.d.ts +9 -0
  132. package/lib/components/StepFlow/story-assets/SidePanel/Example.d.ts +8 -0
  133. package/lib/components/StepFlow/story-assets/SidePanel/StepSidePanel.d.ts +20 -0
  134. package/lib/components/StepFlow/story-assets/StepActions.d.ts +23 -0
  135. package/lib/components/StepFlow/story-assets/Tearsheet/Example.d.ts +8 -0
  136. package/lib/components/StepFlow/story-assets/Tearsheet/StepTearsheet.d.ts +20 -0
  137. package/lib/components/StepFlow/types.d.ts +22 -0
  138. package/lib/components/TruncatedText/TruncatedText.js +4 -2
  139. package/lib/global/js/utils/makeDraggable/makeDraggable.js +28 -0
  140. package/lib/index.js +2 -2
  141. package/package.json +7 -7
  142. package/scss/components/Coachmark/_coachmark.scss +7 -0
  143. package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +24 -0
  144. package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +26 -12
  145. package/scss/components/SidePanel/_side-panel.scss +6 -1
  146. package/scss/components/Tearsheet/_tearsheet.scss +1 -0
  147. package/scss/components/TruncatedText/_truncated-text.scss +1 -0
  148. package/telemetry.yml +1 -1
  149. /package/es/components/EmptyStates/{EmptyStateIllustration.d.ts → EmptyStateIllustration.deprecated.d.ts} +0 -0
  150. /package/es/components/EmptyStates/{EmptyStateIllustration.js → EmptyStateIllustration.deprecated.js} +0 -0
  151. /package/es/components/EmptyStates/{EmptyStateV2.d.ts → EmptyStateV2.deprecated.d.ts} +0 -0
  152. /package/lib/components/EmptyStates/{EmptyStateIllustration.d.ts → EmptyStateIllustration.deprecated.d.ts} +0 -0
  153. /package/lib/components/EmptyStates/{EmptyStateIllustration.js → EmptyStateIllustration.deprecated.js} +0 -0
  154. /package/lib/components/EmptyStates/{EmptyStateV2.d.ts → EmptyStateV2.deprecated.d.ts} +0 -0
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2025
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
+
8
+ import { createContext } from 'react';
9
+ import { pkg } from '../../../../settings.js';
10
+
11
+ const CoachmarkContext = /*#__PURE__*/createContext({
12
+ open: false,
13
+ setOpen: () => {},
14
+ align: 'bottom',
15
+ triggerRef: {
16
+ current: null
17
+ },
18
+ position: {
19
+ x: 0,
20
+ y: 0
21
+ },
22
+ contentRef: null,
23
+ setContentRef: value => {},
24
+ floating: false
25
+ });
26
+ const blockClass = `${pkg.prefix}--coachmark__next`;
27
+
28
+ export { CoachmarkContext, blockClass };
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { PopoverAlignment } from '@carbon/react';
8
8
  import { ButtonProps } from '@carbon/react';
9
- interface CoachmarkContextType {
9
+ export interface CoachmarkContextType {
10
10
  buttonProps: ButtonProps<React.ElementType>;
11
11
  closeButtonProps: {
12
12
  onClick: () => void;
@@ -22,7 +22,7 @@ interface CoachmarkContextType {
22
22
  y: number;
23
23
  };
24
24
  isOpen: boolean;
25
+ closeIconDescription?: string;
25
26
  }
26
27
  export declare const CoachmarkContext: import("react").Context<CoachmarkContextType | null>;
27
28
  export declare const useCoachmark: () => CoachmarkContextType | null;
28
- export {};
@@ -37,6 +37,10 @@ export interface CoachmarkFixedProps {
37
37
  * Determines the theme of the component.
38
38
  */
39
39
  theme?: 'light' | 'dark';
40
+ /**
41
+ * Tooltip text and aria label for the Close button icon.
42
+ */
43
+ closeIconDescription?: string;
40
44
  }
41
45
  /**
42
46
  * Fixed coachmarks are used to call out specific functionality or concepts
@@ -47,6 +47,7 @@ let CoachmarkFixed = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
47
47
  portalTarget,
48
48
  tagline = defaults.tagline,
49
49
  theme = defaults.theme,
50
+ closeIconDescription,
50
51
  // Collect any other property values passed in.
51
52
  ...rest
52
53
  } = _ref;
@@ -113,7 +114,7 @@ let CoachmarkFixed = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
113
114
  targetRect: targetRect,
114
115
  targetOffset: targetOffset,
115
116
  isOpen: isOpen,
116
- tacos: 'tacos'
117
+ closeIconDescription
117
118
  };
118
119
 
119
120
  // instead of toggling on/off,
@@ -182,6 +183,10 @@ CoachmarkFixed.propTypes = {
182
183
  * Optional class name for this component.
183
184
  */
184
185
  className: PropTypes.string,
186
+ /**
187
+ * Tooltip text and aria label for the Close button icon.
188
+ */
189
+ closeIconDescription: PropTypes.string,
185
190
  /**
186
191
  * Function to call when the Coachmark closes.
187
192
  */
@@ -56,6 +56,10 @@ interface CoachmarkStackProps {
56
56
  * Label's tooltip position
57
57
  */
58
58
  tooltipAlign?: TooltipAlignment;
59
+ /**
60
+ * Tooltip text and aria label for the Close button icon.
61
+ */
62
+ closeIconDescription?: string;
59
63
  }
60
64
  /**
61
65
  * Stacked coachmarks are used to call out specific functionality or concepts
@@ -61,6 +61,7 @@ let CoachmarkStack = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
61
61
  theme = defaults.theme,
62
62
  title,
63
63
  tooltipAlign,
64
+ closeIconDescription,
64
65
  ...rest
65
66
  } = _ref;
66
67
  const portalNode = useRef(null);
@@ -133,7 +134,8 @@ let CoachmarkStack = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
133
134
  closeButtonProps: {
134
135
  onClick: () => handleClose(false)
135
136
  },
136
- isOpen: isOpen
137
+ isOpen: isOpen,
138
+ closeIconDescription
137
139
  };
138
140
  useEffect(() => {
139
141
  mountedRef.current = true;
@@ -234,6 +236,10 @@ CoachmarkStack.propTypes = {
234
236
  * The label for the button that will close the Stack
235
237
  */
236
238
  closeButtonLabel: PropTypes.string,
239
+ /**
240
+ * Tooltip text and aria label for the Close button icon.
241
+ */
242
+ closeIconDescription: PropTypes.string,
237
243
  // Pass through to CoachmarkStackHome
238
244
  /**
239
245
  * The description of the Coachmark.
@@ -57,7 +57,8 @@ const ConditionBlock = props => {
57
57
  const {
58
58
  inputConfig,
59
59
  variant,
60
- conditionBuilderRef
60
+ conditionBuilderRef,
61
+ readOnly
61
62
  } = useContext(ConditionBuilderContext);
62
63
  const [showDeletionPreview, setShowDeletionPreview] = useState(false);
63
64
  const [showAllActions, setShowAllActions] = useState(false);
@@ -177,7 +178,8 @@ const ConditionBlock = props => {
177
178
  config: {
178
179
  options: inputConfig?.properties
179
180
  },
180
- closePopover: closePopover
181
+ closePopover: closePopover,
182
+ group: group
181
183
  });
182
184
  };
183
185
  return /*#__PURE__*/React__default.createElement("div", _extends({
@@ -205,7 +207,7 @@ const ConditionBlock = props => {
205
207
  label: group.statement,
206
208
  title: conditionText,
207
209
  "data-name": "connectorField",
208
- popOverClassName: `${blockClass}__gap`,
210
+ popOverClassName: `${blockClass}__gap ${blockClass}__connector`,
209
211
  className: `${blockClass}__statement-button`,
210
212
  tabIndex: 0
211
213
  }, /*#__PURE__*/React__default.createElement(ItemOption, {
@@ -218,7 +220,9 @@ const ConditionBlock = props => {
218
220
  options: statementConfig,
219
221
  isStatement: true
220
222
  }
221
- })), /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
223
+ })), /*#__PURE__*/React__default.createElement("div", {
224
+ className: `${blockClass}__condition-inner-block`
225
+ }, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
222
226
  label: label ?? condition?.property,
223
227
  title: propertyText,
224
228
  renderIcon: icon ?? undefined,
@@ -256,7 +260,7 @@ const ConditionBlock = props => {
256
260
  config: config,
257
261
  onChange: onValueChangeHandler,
258
262
  renderChildren: renderChildren
259
- }), /*#__PURE__*/React__default.createElement("span", {
263
+ })), !readOnly && /*#__PURE__*/React__default.createElement("span", {
260
264
  role: "gridcell",
261
265
  "aria-label": removeConditionText
262
266
  }, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, {
@@ -271,7 +275,7 @@ const ConditionBlock = props => {
271
275
  className: `${blockClass}__close-condition`,
272
276
  "data-name": "closeCondition",
273
277
  wrapperClassName: `${blockClass}__close-condition-wrapper`
274
- })), manageActionButtons(conditionIndex, group.conditions) && /*#__PURE__*/React__default.createElement(ConditionBuilderAdd, {
278
+ })), !readOnly && manageActionButtons(conditionIndex, group.conditions) ? /*#__PURE__*/React__default.createElement(ConditionBuilderAdd, {
275
279
  onClick: () => {
276
280
  addConditionHandler?.(conditionIndex);
277
281
  },
@@ -285,7 +289,7 @@ const ConditionBlock = props => {
285
289
  hideConditionPreviewHandler: hideConditionPreviewHandler,
286
290
  className: `${blockClass}__gap ${blockClass}__gap-left`,
287
291
  group: group
288
- }));
292
+ }) : null);
289
293
  };
290
294
  ConditionBlock.propTypes = {
291
295
  /**
@@ -57,6 +57,7 @@ let ConditionBuilder = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
57
57
  translateWithId,
58
58
  statementConfigCustom,
59
59
  onAddItem,
60
+ readOnly,
60
61
  ...rest
61
62
  } = _ref;
62
63
  const localRef = useRef(null);
@@ -72,14 +73,16 @@ let ConditionBuilder = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
72
73
  translateWithId: translateWithId,
73
74
  conditionBuilderRef: conditionBuilderRef,
74
75
  statementConfigCustom: statementConfigCustom,
75
- onAddItem: onAddItem
76
+ onAddItem: onAddItem,
77
+ readOnly: !!readOnly
76
78
  }, /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
77
79
  className: cx(blockClass,
78
80
  // Apply the block class to the main HTML element
79
81
  className,
80
82
  // Apply any supplied class names to the main HTML element.
81
- // example: `${blockClass}__template-string-class-${kind}-n-${size}`,
82
83
  {
84
+ [`${blockClass}__readonly`]: readOnly
85
+ }, {
83
86
  // switched classes dependant on props or state
84
87
  // example: [`${blockClass}__here-if-small`]: size === 'sm',
85
88
  }),
@@ -173,6 +176,8 @@ ConditionBuilder.propTypes = {
173
176
  type: PropTypes.oneOf(['text', 'textarea', 'number', 'date', 'option', 'time', 'custom']).isRequired,
174
177
  description: PropTypes.string,
175
178
  //will be displayed on hover of property field
179
+ getIsDisabled: PropTypes.func,
180
+ getIsHidden: PropTypes.func,
176
181
  config: PropTypes.shape({
177
182
  options: PropTypes.arrayOf(PropTypes.shape({
178
183
  id: PropTypes.string.isRequired,
@@ -197,6 +202,10 @@ ConditionBuilder.propTypes = {
197
202
  * Provide an mandatory numeric value that will be used to enable search option in the popovers with list.
198
203
  */
199
204
  popOverSearchThreshold: PropTypes.number.isRequired,
205
+ /**
206
+ * Whether the conditionBuilder should be readOnly
207
+ */
208
+ readOnly: PropTypes.bool,
200
209
  /**
201
210
  * Provide a label to the button that starts condition builder
202
211
  */
@@ -93,6 +93,14 @@ export type Property = Item & {
93
93
  description?: string;
94
94
  type?: any;
95
95
  config?: any;
96
+ getIsDisabled?: (args: {
97
+ conditionState: Condition;
98
+ group?: ConditionGroup;
99
+ }) => boolean;
100
+ getIsHidden?: (args: {
101
+ conditionState: Condition;
102
+ group?: ConditionGroup;
103
+ }) => boolean;
96
104
  } & ConfigType;
97
105
  export type inputConfig = {
98
106
  properties: Property[];
@@ -149,6 +157,7 @@ export type ConditionBuilderProps = {
149
157
  onAddItem?: (config: AddItemConfig) => {
150
158
  preventAdd: boolean;
151
159
  };
160
+ readOnly?: boolean;
152
161
  };
153
162
  export type InitialState = {
154
163
  state: ConditionBuilderState;
@@ -163,6 +172,7 @@ export interface ConditionBuilderContextInputProps extends PropsWithChildren {
163
172
  translateWithId?: (id: ConditionBuilderTextKeys) => string;
164
173
  statementConfigCustom?: statementConfig[];
165
174
  conditionBuilderRef?: ForwardedRef<HTMLDivElement>;
175
+ readOnly?: boolean;
166
176
  }
167
177
  export type ConditionBuilderContextProps = {
168
178
  rootState?: ConditionBuilderState;
@@ -26,11 +26,15 @@ const ConditionBuilderActions = _ref => {
26
26
  } = _ref;
27
27
  const {
28
28
  actionState = [],
29
- setActionState
29
+ setActionState,
30
+ readOnly
30
31
  } = useContext(ConditionBuilderContext);
31
32
  const [showDeletionPreview, setShowDeletionPreview] = useState(-1);
32
33
  const [actionsText, thenText, andText, removeActionText, addActionText, actionSectionText] = useTranslations(['actionsText', 'then', 'and', 'removeActionText', 'addActionText', 'actionSectionText']);
33
34
  const addActionHandler = () => {
35
+ if (readOnly) {
36
+ return;
37
+ }
34
38
  const action = {
35
39
  id: uuidv4(),
36
40
  label: undefined,
@@ -75,14 +79,15 @@ const ConditionBuilderActions = _ref => {
75
79
  }, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
76
80
  className: `${blockClass}__statement-button`,
77
81
  tabIndex: 0,
78
- popOverClassName: `${blockClass}__gap`,
82
+ popOverClassName: `${blockClass}__gap ${blockClass}__connector`,
79
83
  label: index === 0 ? thenText : andText
80
84
  }), /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
81
85
  label: action.label,
82
86
  title: actionsText,
83
87
  condition: action,
84
88
  "data-name": "valueField",
85
- type: "option"
89
+ type: "option",
90
+ popOverClassName: `${blockClass}__action-block`
86
91
  }, /*#__PURE__*/React__default.createElement(ItemOptionForValueField, {
87
92
  conditionState: {
88
93
  value: action.label
@@ -91,7 +96,7 @@ const ConditionBuilderActions = _ref => {
91
96
  config: {
92
97
  options: actions
93
98
  }
94
- })), /*#__PURE__*/React__default.createElement("span", {
99
+ })), !readOnly && /*#__PURE__*/React__default.createElement("span", {
95
100
  role: "gridcell",
96
101
  "aria-label": removeActionText
97
102
  }, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, {
@@ -105,7 +110,7 @@ const ConditionBuilderActions = _ref => {
105
110
  renderIcon: Close,
106
111
  className: `${blockClass}__close-condition`,
107
112
  "data-name": "closeCondition"
108
- })), actionState.length === index + 1 && /*#__PURE__*/React__default.createElement(ConditionBuilderAdd, {
113
+ })), !readOnly && actionState.length === index + 1 && /*#__PURE__*/React__default.createElement(ConditionBuilderAdd, {
109
114
  onClick: addActionHandler,
110
115
  className: `${blockClass}__gap ${blockClass}__gap-left`,
111
116
  buttonLabel: addActionText,
@@ -6,12 +6,13 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default from 'react';
9
+ import React__default, { useContext } from 'react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from '../../../_virtual/index.js';
12
12
  import { usePrefix, Tooltip } from '@carbon/react';
13
13
  import { WarningAltFilled } from '@carbon/react/icons';
14
14
  import { blockClass } from '../utils/util.js';
15
+ import { ConditionBuilderContext } from '../ConditionBuilderContext/ConditionBuilderProvider.js';
15
16
 
16
17
  var _WarningAltFilled;
17
18
  const ConditionBuilderButton = _ref => {
@@ -39,6 +40,15 @@ const ConditionBuilderButton = _ref => {
39
40
  const carbonPrefix = usePrefix();
40
41
  const Button = () => {
41
42
  const dataName = rest['data-name'] ?? '';
43
+ const {
44
+ readOnly
45
+ } = useContext(ConditionBuilderContext);
46
+ const handleClick = e => {
47
+ if (readOnly) {
48
+ return;
49
+ }
50
+ onClick?.(e);
51
+ };
42
52
  return /*#__PURE__*/React__default.createElement("button", _extends({
43
53
  tabIndex: tabIndex !== undefined ? tabIndex : -1,
44
54
  className: cx([className, `${blockClass}__button`, {
@@ -47,12 +57,13 @@ const ConditionBuilderButton = _ref => {
47
57
  [`${blockClass}__invalid-input`]: isInvalid
48
58
  }]),
49
59
  type: "button",
50
- onClick: onClick,
60
+ onClick: handleClick,
51
61
  onBlur: onBlur,
52
62
  onFocus: onFocus,
53
63
  onMouseEnter: onMouseEnter,
54
64
  onMouseLeave: onMouseLeave,
55
- "data-name": dataName
65
+ "data-name": dataName,
66
+ "aria-disabled": readOnly
56
67
  }, rest), Icon && (_Icon || (_Icon = /*#__PURE__*/React__default.createElement(Icon, null))), !hideLabel && (_span || (_span = /*#__PURE__*/React__default.createElement("span", null, label))), isInvalid && (_WarningAltFilled || (_WarningAltFilled = /*#__PURE__*/React__default.createElement(WarningAltFilled, null))));
57
68
  };
58
69
  return hideLabel || showToolTip || description ? /*#__PURE__*/React__default.createElement(Tooltip, _extends({
@@ -51,7 +51,7 @@ const ConditionConnector = _ref => {
51
51
  focusThisField(evt, conditionBuilderRef);
52
52
  };
53
53
  return variant == HIERARCHICAL_VARIANT ? /*#__PURE__*/React__default.createElement("span", {
54
- className: `${className} ${blockClass}__connector--disabled`
54
+ className: `${className} ${blockClass}__connector ${blockClass}__connector--disabled`
55
55
  }, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, {
56
56
  label: operator
57
57
  })) : /*#__PURE__*/React__default.createElement(ConditionBuilderItem, _extends({
@@ -63,7 +63,7 @@ const ConditionConnector = _ref => {
63
63
  onFocus: activeConnectorHandler,
64
64
  onBlur: inActiveConnectorHandler
65
65
  }, rest, {
66
- popOverClassName: className,
66
+ popOverClassName: `${className} ${blockClass}__connector`,
67
67
  className: `${blockClass}__connector-button`
68
68
  }), /*#__PURE__*/React__default.createElement(ItemOption, {
69
69
  config: {
@@ -37,7 +37,7 @@ const GroupConnector = () => {
37
37
  label: rootState.operator,
38
38
  title: conditionText,
39
39
  "data-name": "connectorField",
40
- popOverClassName: `${blockClass}__gap`,
40
+ popOverClassName: `${blockClass}__gap ${blockClass}__groupConnector`,
41
41
  className: `${blockClass}__statement-button`
42
42
  }, /*#__PURE__*/React__default.createElement(ItemOption, {
43
43
  conditionState: {
@@ -34,7 +34,8 @@ const ConditionBuilderContent = _ref => {
34
34
  setRootState,
35
35
  variant,
36
36
  actionState,
37
- onAddItem
37
+ onAddItem,
38
+ readOnly
38
39
  } = useContext(ConditionBuilderContext);
39
40
  const initialConditionState = useRef(initialState?.state ? JSON.parse(JSON.stringify(initialState?.state)) : null);
40
41
  const [isConditionBuilderActive, setIsConditionBuilderActive] = useState(false);
@@ -170,7 +171,7 @@ const ConditionBuilderContent = _ref => {
170
171
  onChange: updatedGroup => {
171
172
  onChangeHandler(updatedGroup, groupIndex);
172
173
  }
173
- }), rootState.groups && groupIndex < rootState.groups.length - 1 && (_GroupConnector || (_GroupConnector = /*#__PURE__*/React__default.createElement(GroupConnector, null))))), variant == HIERARCHICAL_VARIANT && /*#__PURE__*/React__default.createElement("div", {
174
+ }), rootState.groups && groupIndex < rootState.groups.length - 1 && (_GroupConnector || (_GroupConnector = /*#__PURE__*/React__default.createElement(GroupConnector, null))))), !readOnly && variant == HIERARCHICAL_VARIANT && /*#__PURE__*/React__default.createElement("div", {
174
175
  role: "row",
175
176
  tabIndex: -1,
176
177
  "aria-level": 1,
@@ -189,7 +190,7 @@ const ConditionBuilderContent = _ref => {
189
190
  role: 'gridcell',
190
191
  'aria-label': addConditionGroupText
191
192
  }
192
- })), /*#__PURE__*/React__default.createElement(ConditionPreview, {
193
+ })), variant === HIERARCHICAL_VARIANT ? /*#__PURE__*/React__default.createElement(ConditionPreview, {
193
194
  previewType: "newGroup",
194
195
  colorIndex: getColorIndex(),
195
196
  className: showConditionGroupPreview ? `${blockClass}__visible` : `${blockClass}__hidden`,
@@ -197,7 +198,7 @@ const ConditionBuilderContent = _ref => {
197
198
  groupOperator: rootState?.operator,
198
199
  id: uuidv4()
199
200
  }
200
- })), actions && /*#__PURE__*/React__default.createElement(ConditionBuilderActions, {
201
+ }) : null), actions && /*#__PURE__*/React__default.createElement(ConditionBuilderActions, {
201
202
  actions: actions,
202
203
  className: `${blockClass}__actions-container`
203
204
  }));
@@ -46,7 +46,8 @@ const ConditionBuilderProvider = props => {
46
46
  translateWithId: props.translateWithId,
47
47
  conditionBuilderRef: props.conditionBuilderRef,
48
48
  statementConfigCustom: props.statementConfigCustom,
49
- onAddItem: props.onAddItem
49
+ onAddItem: props.onAddItem,
50
+ readOnly: props.readOnly
50
51
  };
51
52
  return /*#__PURE__*/React__default.createElement(ConditionBuilderContext.Provider, {
52
53
  value: contextValue
@@ -39,7 +39,8 @@ const ConditionBuilderItem = _ref => {
39
39
  const [open, setOpen] = useState(false);
40
40
  const {
41
41
  conditionBuilderRef,
42
- statementConfigCustom
42
+ statementConfigCustom,
43
+ readOnly
43
44
  } = useContext(ConditionBuilderContext);
44
45
  const statementIdMap = {
45
46
  ifAll: translationsObject.ifText,
@@ -151,7 +152,12 @@ const ConditionBuilderItem = _ref => {
151
152
  }
152
153
  setOpen(false);
153
154
  };
154
- const openPopOver = () => setOpen(true);
155
+ const openPopOver = () => {
156
+ if (readOnly) {
157
+ return;
158
+ }
159
+ setOpen(true);
160
+ };
155
161
  const togglePopover = () => {
156
162
  if (children || renderChildren) {
157
163
  setOpen(!open);
@@ -5,22 +5,23 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import { option, statementConfig } from '../../ConditionBuilder.types';
8
+ import { ConditionGroup, option, Property, statementConfig } from '../../ConditionBuilder.types';
9
9
  interface ItemOptionProps {
10
10
  conditionState: {
11
11
  label?: string;
12
12
  value?: string;
13
13
  };
14
14
  config: {
15
- options?: option[] | statementConfig[];
15
+ options?: option[] | statementConfig[] | Property[];
16
16
  } & {
17
17
  isStatement?: boolean;
18
18
  };
19
19
  onChange: (value: string, e: Event) => void;
20
20
  closePopover?: () => void;
21
+ group?: ConditionGroup;
21
22
  }
22
23
  export declare const ItemOption: {
23
- ({ conditionState, config, onChange, closePopover, }: ItemOptionProps): React.JSX.Element | undefined;
24
+ ({ conditionState, config, onChange, closePopover, group, }: ItemOptionProps): React.JSX.Element | undefined;
24
25
  propTypes: {
25
26
  /**
26
27
  * current condition object
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ import { extends as _extends } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
8
9
  import React__default, { useContext, useRef, useState, useEffect } from 'react';
9
10
  import { Search } from '@carbon/react';
10
11
  import { Checkmark } from '@carbon/react/icons';
@@ -18,7 +19,8 @@ const ItemOption = _ref => {
18
19
  conditionState = {},
19
20
  config = {},
20
21
  onChange,
21
- closePopover
22
+ closePopover,
23
+ group
22
24
  } = _ref;
23
25
  const {
24
26
  popOverSearchThreshold
@@ -43,7 +45,9 @@ const ItemOption = _ref => {
43
45
  }
44
46
  }, [allOptions]);
45
47
  const onClickHandler = (evt, option) => {
46
- onChange(option.id, evt);
48
+ if (!evt.currentTarget.hasAttribute('aria-disabled')) {
49
+ onChange(option.id, evt);
50
+ }
47
51
  };
48
52
  const onSearchChangeHandler = evt => {
49
53
  const {
@@ -81,7 +85,15 @@ const ItemOption = _ref => {
81
85
  }, filteredItems?.map(option => {
82
86
  const isSelected = selection === option.id;
83
87
  const Icon = option.icon;
84
- return /*#__PURE__*/React__default.createElement("li", {
88
+ const disabled = option?.getIsDisabled?.({
89
+ conditionState,
90
+ group
91
+ });
92
+ const hidden = option?.getIsHidden?.({
93
+ conditionState,
94
+ group
95
+ });
96
+ return /*#__PURE__*/React__default.createElement("li", _extends({
85
97
  tabIndex: 0,
86
98
  key: option.id,
87
99
  role: "option",
@@ -91,7 +103,11 @@ const ItemOption = _ref => {
91
103
  return false;
92
104
  },
93
105
  onClick: evt => onClickHandler(evt, option)
94
- }, /*#__PURE__*/React__default.createElement("div", {
106
+ }, disabled ? {
107
+ 'aria-disabled': 'true'
108
+ } : {}, hidden ? {
109
+ 'aria-hidden': 'true'
110
+ } : {}), /*#__PURE__*/React__default.createElement("div", {
95
111
  className: `${blockClass}__item-option__option-content`
96
112
  }, /*#__PURE__*/React__default.createElement("span", {
97
113
  className: `${blockClass}__item-option__option-label`
@@ -297,7 +297,7 @@ const ConditionGroupBuilder = _ref => {
297
297
  label: group.statement,
298
298
  title: conditionText,
299
299
  "data-name": "connectorField",
300
- popOverClassName: `${blockClass}__gap`,
300
+ popOverClassName: `${blockClass}__gap ${blockClass}__connector`,
301
301
  className: `${blockClass}__statement-button`
302
302
  }, /*#__PURE__*/React__default.createElement(ItemOption, {
303
303
  conditionState: {
@@ -1 +1,2 @@
1
1
  export { ConditionBuilder } from "./ConditionBuilder";
2
+ export * from "./ConditionBuilder.types";
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { blockClass, HIERARCHICAL_VARIANT, focusThisItem, manageTabIndexAndFocus, traverseClockVise, traverseReverse, checkForHoldingKey, focusThisField } from './util.js';
8
+ import { blockClass, HIERARCHICAL_VARIANT, focusThisItem, manageTabIndexAndFocus, traverseClockwise, traverseReverse, checkForHoldingKey, focusThisField } from './util.js';
9
9
 
10
10
  const handleKeyDown = (evt, conditionBuilderRef, variant) => {
11
11
  const activeElement = document.activeElement;
@@ -24,6 +24,9 @@ const handleKeyDownForPopover = (evt, conditionBuilderRef, popoverRef, closePopo
24
24
  const excludeKeyPress = evt => {
25
25
  return !['Escape'].includes(evt.key) && evt.target.closest(`.${blockClass}__item-date`);
26
26
  };
27
+ const getVisibleOptions = parentContainer => {
28
+ return Array.from(parentContainer.querySelectorAll(`[role="option"]`)).filter(el => !el.hasAttribute('aria-disabled') && !el.hasAttribute('aria-hidden'));
29
+ };
27
30
  const handleKeyPressForPopover = (evt, parentContainer, conditionBuilderRef, closePopover) => {
28
31
  const key = evt.key;
29
32
  const isHoldingShiftKey = checkForHoldingKey(evt, 'shiftKey');
@@ -43,7 +46,8 @@ const handleKeyPressForPopover = (evt, parentContainer, conditionBuilderRef, clo
43
46
  case 'ArrowUp':
44
47
  evt.preventDefault();
45
48
  //traverse through the popover options, search box, selectAll button
46
- parentContainer.querySelectorAll(`[role="option"]`).forEach((eachElem, index, allElements) => {
49
+ allItems = getVisibleOptions(parentContainer);
50
+ allItems.forEach((eachElem, index, allElements) => {
47
51
  traverseReverse(eachElem, index, allElements, null, null, conditionBuilderRef);
48
52
  });
49
53
  //scroll to top when we reach a the top of the list to make search box visible
@@ -54,17 +58,18 @@ const handleKeyPressForPopover = (evt, parentContainer, conditionBuilderRef, clo
54
58
  case 'ArrowDown':
55
59
  evt.preventDefault();
56
60
  //traverse through the popover options, search box, selectAll button
57
- parentContainer.querySelectorAll(`[role="option"]`).forEach((eachElem, index, allElements) => {
58
- traverseClockVise(eachElem, index, allElements, null, null, conditionBuilderRef);
61
+ allItems = getVisibleOptions(parentContainer);
62
+ allItems.forEach((eachElem, index, allElements) => {
63
+ traverseClockwise(eachElem, index, allElements, null, null, conditionBuilderRef);
59
64
  });
60
65
  break;
61
66
  case 'Tab':
62
- allItems = [...Array.from(parentContainer.querySelectorAll(`.${blockClass}__selectAll-button,[role="searchbox"]`)), parentContainer.querySelector(`[role="option"]`)];
67
+ allItems = [...Array.from(parentContainer.querySelectorAll(`.${blockClass}__selectAll-button,[role="searchbox"]`)), getVisibleOptions(parentContainer)?.[0]];
63
68
  allItems.forEach((eachElem, index, allElements) => {
64
69
  if (isHoldingShiftKey) {
65
70
  traverseReverse(eachElem, index, allElements, true, true, conditionBuilderRef);
66
71
  } else {
67
- traverseClockVise(eachElem, index, allElements, true, true, conditionBuilderRef);
72
+ traverseClockwise(eachElem, index, allElements, true, true, conditionBuilderRef);
68
73
  }
69
74
  });
70
75
  evt.preventDefault();
@@ -218,7 +223,7 @@ const navigateToNextRowCell = (evt, currentRowIndex, rows, variant, conditionBui
218
223
  const handleCellNavigation = (evt, conditionBuilderRef) => {
219
224
  conditionBuilderRef.current.querySelectorAll(`[role="gridcell"] button`).forEach((eachElem, index, allElements) => {
220
225
  if (evt.key === 'ArrowRight') {
221
- traverseClockVise(eachElem, index, allElements, null, null, conditionBuilderRef);
226
+ traverseClockwise(eachElem, index, allElements, null, null, conditionBuilderRef);
222
227
  } else {
223
228
  traverseReverse(eachElem, index, allElements, null, null, conditionBuilderRef);
224
229
  }
@@ -1,5 +1,5 @@
1
1
  export function useDataConfigs(): {
2
- statementConfig: import("../ConditionBuilder.types").statementConfig[] | {
2
+ statementConfig: import("..").statementConfig[] | {
3
3
  id: string;
4
4
  connector: string;
5
5
  label: any;
@@ -3,7 +3,7 @@ export const NON_HIERARCHICAL_VARIANT: "Non-Hierarchical";
3
3
  export const HIERARCHICAL_VARIANT: "Hierarchical";
4
4
  export function focusThisField(evt: any, conditionBuilderRef: any): void;
5
5
  export function focusThisItem(currentElement: any, conditionBuilderRef: any): void;
6
- export function traverseClockVise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any, conditionBuilderRef: any): void;
6
+ export function traverseClockwise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any, conditionBuilderRef: any): void;
7
7
  export function traverseReverse(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any, conditionBuilderRef: any): void;
8
8
  export function checkForHoldingKey(evt: any, key: any): any;
9
9
  export function checkIsValid(item: any): any;