@carbon/ibm-products 2.43.2-canary.81 → 2.43.2-canary.87

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 (41) hide show
  1. package/css/index-full-carbon.css +16 -66
  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 +7 -0
  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 +16 -66
  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 +16 -66
  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/Coachmark/Coachmark.d.ts +6 -1
  18. package/es/components/Coachmark/Coachmark.js +37 -6
  19. package/es/components/Coachmark/CoachmarkOverlay.js +2 -4
  20. package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +1 -7
  21. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +22 -20
  22. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +1 -0
  23. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +2 -1
  24. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +13 -3
  25. package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -2
  26. package/es/components/ConditionBuilder/utils/util.d.ts +0 -1
  27. package/lib/components/Coachmark/Coachmark.d.ts +6 -1
  28. package/lib/components/Coachmark/Coachmark.js +36 -5
  29. package/lib/components/Coachmark/CoachmarkOverlay.js +2 -4
  30. package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +1 -7
  31. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +21 -19
  32. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +1 -0
  33. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +2 -1
  34. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +13 -3
  35. package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -2
  36. package/lib/components/ConditionBuilder/utils/util.d.ts +0 -1
  37. package/package.json +4 -4
  38. package/scss/components/Coachmark/_coachmark-overlay.scss +6 -70
  39. package/scss/components/Coachmark/_coachmark.scss +5 -4
  40. package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +1 -3
  41. package/scss/components/CreateFullPage/_create-full-page.scss +7 -0
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, objectSpread2 as _objectSpread2, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { forwardRef, useState, useRef, useCallback, useEffect } from 'react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from '../../node_modules/prop-types/index.js';
@@ -17,9 +17,11 @@ import { useClickOutsideElement, useWindowEvent } from './utils/hooks.js';
17
17
  import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
18
18
  import { pkg } from '../../settings.js';
19
19
  import { throttle } from 'lodash';
20
+ import { Popover, PopoverContent } from '@carbon/react';
20
21
  import { useIsomorphicEffect } from '../../global/js/hooks/useIsomorphicEffect.js';
21
22
 
22
- var _excluded = ["align", "children", "className", "onClose", "overlayClassName", "overlayKind", "overlayRef", "portalTarget", "positionTune", "target", "theme"];
23
+ var _excluded = ["align", "autoAlign", "children", "className", "onClose", "overlayClassName", "overlayKind", "overlayRef", "positionTune", "portalTarget", "target", "theme"];
24
+
23
25
  // The block part of our conventional BEM class names (blockClass__E--M).
24
26
  var blockClass = "".concat(pkg.prefix, "--coachmark");
25
27
  var overlayBlockClass = "".concat(blockClass, "-overlay");
@@ -37,8 +39,10 @@ var defaults = {
37
39
  */
38
40
 
39
41
  var Coachmark = /*#__PURE__*/forwardRef(function (_ref, ref) {
42
+ var _positionTune$y, _positionTune$x;
40
43
  var _ref$align = _ref.align,
41
44
  align = _ref$align === void 0 ? defaults.align : _ref$align,
45
+ autoAlign = _ref.autoAlign,
42
46
  children = _ref.children,
43
47
  className = _ref.className,
44
48
  _ref$onClose = _ref.onClose,
@@ -47,8 +51,8 @@ var Coachmark = /*#__PURE__*/forwardRef(function (_ref, ref) {
47
51
  _ref$overlayKind = _ref.overlayKind,
48
52
  overlayKind = _ref$overlayKind === void 0 ? defaults.overlayKind : _ref$overlayKind,
49
53
  overlayRef = _ref.overlayRef,
50
- portalTarget = _ref.portalTarget,
51
54
  positionTune = _ref.positionTune,
55
+ portalTarget = _ref.portalTarget,
52
56
  target = _ref.target,
53
57
  _ref$theme = _ref.theme,
54
58
  theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
@@ -124,6 +128,10 @@ var Coachmark = /*#__PURE__*/forwardRef(function (_ref, ref) {
124
128
  setShouldResetPosition(true);
125
129
  }
126
130
  };
131
+ var overlayPositionStyle = {
132
+ top: ((_positionTune$y = positionTune === null || positionTune === void 0 ? void 0 : positionTune.y) !== null && _positionTune$y !== void 0 ? _positionTune$y : 0) - 16,
133
+ left: ((_positionTune$x = positionTune === null || positionTune === void 0 ? void 0 : positionTune.x) !== null && _positionTune$x !== void 0 ? _positionTune$x : 0) - 16
134
+ };
127
135
  var contextValue = {
128
136
  buttonProps: {
129
137
  'aria-expanded': isOpen,
@@ -139,7 +147,8 @@ var Coachmark = /*#__PURE__*/forwardRef(function (_ref, ref) {
139
147
  targetRect: targetRect,
140
148
  targetOffset: targetOffset,
141
149
  align: align,
142
- positionTune: positionTune
150
+ positionTune: positionTune,
151
+ isOpen: isOpen
143
152
  };
144
153
  var handleResize = throttle(function () {
145
154
  closeOverlay();
@@ -173,7 +182,7 @@ var Coachmark = /*#__PURE__*/forwardRef(function (_ref, ref) {
173
182
  }, /*#__PURE__*/React__default.createElement("div", _extends({
174
183
  className: cx(blockClass, "".concat(blockClass, "__").concat(theme), className),
175
184
  ref: _coachmarkRef
176
- }, rest, getDevtoolsProps(componentName)), target, isOpen && (portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) && /*#__PURE__*/createPortal( /*#__PURE__*/React__default.createElement(CoachmarkOverlay, {
185
+ }, rest, getDevtoolsProps(componentName)), overlayKind !== 'tooltip' ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, target, isOpen && (portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) && /*#__PURE__*/createPortal( /*#__PURE__*/React__default.createElement(CoachmarkOverlay, {
177
186
  ref: _overlayRef,
178
187
  fixedIsVisible: false,
179
188
  kind: overlayKind,
@@ -181,7 +190,23 @@ var Coachmark = /*#__PURE__*/forwardRef(function (_ref, ref) {
181
190
  theme: theme,
182
191
  className: cx(overlayClassName, "".concat(overlayBlockClass, "--is-visible"))
183
192
  }, children), // Default to `document.body` when `portalNode` is `null`
184
- portalNode === null || portalNode === void 0 ? void 0 : portalNode.current)));
193
+ portalNode === null || portalNode === void 0 ? void 0 : portalNode.current)) : /*#__PURE__*/React__default.createElement(Popover, {
194
+ highContrast: true,
195
+ caret: true,
196
+ style: _objectSpread2({
197
+ position: 'absolute'
198
+ }, overlayPositionStyle),
199
+ align: align,
200
+ autoAlign: autoAlign,
201
+ open: isOpen
202
+ }, target, /*#__PURE__*/React__default.createElement(PopoverContent, null, isOpen && /*#__PURE__*/React__default.createElement(CoachmarkOverlay, {
203
+ ref: _overlayRef,
204
+ fixedIsVisible: false,
205
+ kind: overlayKind,
206
+ onClose: handleClose,
207
+ theme: theme,
208
+ className: cx(overlayClassName, _defineProperty({}, "".concat(overlayBlockClass, "--is-visible"), isOpen))
209
+ }, children)))));
185
210
  });
186
211
  var overlayRefType = typeof HTMLElement === 'undefined' ? PropTypes.object :
187
212
  // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
@@ -204,6 +229,11 @@ Coachmark.propTypes = {
204
229
  * @see COACHMARK_ALIGNMENT
205
230
  */
206
231
  align: PropTypes.oneOf(['bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom', 'right', 'right-top', 'right-bottom', 'top', 'top-left', 'top-right']),
232
+ /**
233
+ * Auto aligns the coachmark based on screen boundaries
234
+ * Applies only to Tooltip Coachmarks.
235
+ */
236
+ autoAlign: PropTypes.bool,
207
237
  /**
208
238
  * Coachmark should use a single CoachmarkOverlayElements component as a child.
209
239
  * @see CoachmarkOverlayElements
@@ -242,6 +272,7 @@ Coachmark.propTypes = {
242
272
  /**
243
273
  * Fine tune the position of the target in pixels. Applies only to Beacons.
244
274
  */
275
+ // @ts-ignore
245
276
  positionTune: PropTypes.shape({
246
277
  x: PropTypes.number,
247
278
  y: PropTypes.number
@@ -55,7 +55,7 @@ var CoachmarkOverlay = /*#__PURE__*/forwardRef(function (_ref, ref) {
55
55
  var coachmark = useCoachmark();
56
56
  var isBeacon = kind === COACHMARK_OVERLAY_KIND.TOOLTIP;
57
57
  var isDraggable = kind === COACHMARK_OVERLAY_KIND.FLOATING;
58
- var isVisible = className && className.includes('is-visible');
58
+ var isVisible = className === null || className === void 0 ? void 0 : className.includes('is-visible');
59
59
  var handleKeyPress = function handleKeyPress(event) {
60
60
  var shiftKey = event.shiftKey,
61
61
  key = event.key;
@@ -163,9 +163,7 @@ var CoachmarkOverlay = /*#__PURE__*/forwardRef(function (_ref, ref) {
163
163
  return /*#__PURE__*/React__default.cloneElement(child, {
164
164
  isVisible: isVisible
165
165
  });
166
- })), isBeacon && /*#__PURE__*/React__default.createElement("span", {
167
- className: "".concat(blockClass, "__caret")
168
- }));
166
+ })));
169
167
  });
170
168
  function getWindowDimensions() {
171
169
  var _window = window,
@@ -26,7 +26,6 @@ var defaults = {
26
26
  * Use beacon for the target prop of a Coachmark component.
27
27
  */
28
28
  var CoachmarkBeacon = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
29
- var _coachmark$positionTu, _coachmark$positionTu2, _coachmark$positionTu3, _coachmark$positionTu4;
30
29
  var label = _ref.label,
31
30
  className = _ref.className,
32
31
  _ref$kind = _ref.kind,
@@ -36,14 +35,9 @@ var CoachmarkBeacon = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
36
35
  if (!coachmark) {
37
36
  return _div || (_div = /*#__PURE__*/React__default.createElement("div", null, "CoachmarkBeacon is to be use exclusively within the target prop of Coachmark"));
38
37
  }
39
- var overlayPositionStyle = {
40
- top: (_coachmark$positionTu = (_coachmark$positionTu2 = coachmark.positionTune) === null || _coachmark$positionTu2 === void 0 ? void 0 : _coachmark$positionTu2.y) !== null && _coachmark$positionTu !== void 0 ? _coachmark$positionTu : 0,
41
- left: (_coachmark$positionTu3 = (_coachmark$positionTu4 = coachmark.positionTune) === null || _coachmark$positionTu4 === void 0 ? void 0 : _coachmark$positionTu4.x) !== null && _coachmark$positionTu3 !== void 0 ? _coachmark$positionTu3 : 0
42
- };
43
38
  return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, {
44
39
  className: cx(blockClass, "".concat(blockClass, "-").concat(kind), className),
45
- ref: ref,
46
- style: overlayPositionStyle
40
+ ref: ref
47
41
  }, getDevtoolsProps(componentName), {
48
42
  role: "tooltip"
49
43
  }), /*#__PURE__*/React__default.createElement("button", _extends({
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, extends as _extends, toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { useContext, useState, useEffect, useCallback } from 'react';
10
10
  import PropTypes from '../../../node_modules/prop-types/index.js';
11
11
  import { Button, Section, Heading } from '@carbon/react';
@@ -20,7 +20,7 @@ import GroupConnector from '../ConditionBuilderConnector/GroupConnector.js';
20
20
  import ConditionBuilderActions from '../ConditionBuilderActions/ConditionBuilderActions.js';
21
21
  import { useTranslations } from '../utils/useTranslations.js';
22
22
 
23
- var _Heading, _GroupConnector;
23
+ var _GroupConnector;
24
24
  var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
25
25
  var _rootState$groups2;
26
26
  var startConditionLabel = _ref.startConditionLabel,
@@ -41,9 +41,10 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
41
41
  _useState4 = _slicedToArray(_useState3, 2),
42
42
  showConditionGroupPreview = _useState4[0],
43
43
  setShowConditionGroupPreview = _useState4[1];
44
- var _useTranslations = useTranslations(['addConditionGroupText']),
45
- _useTranslations2 = _slicedToArray(_useTranslations, 1),
46
- addConditionGroupText = _useTranslations2[0];
44
+ var _useTranslations = useTranslations(['addConditionGroupText', 'conditionHeadingText']),
45
+ _useTranslations2 = _slicedToArray(_useTranslations, 2),
46
+ addConditionGroupText = _useTranslations2[0],
47
+ conditionHeadingText = _useTranslations2[1];
47
48
  var showConditionGroupPreviewHandler = function showConditionGroupPreviewHandler() {
48
49
  setShowConditionGroupPreview(true);
49
50
  };
@@ -109,21 +110,22 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
109
110
  groups: [].concat(_toConsumableArray(rootState.groups), [newGroup])
110
111
  }));
111
112
  };
112
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, !isConditionBuilderActive && /*#__PURE__*/React__default.createElement(Button, {
113
- className: "".concat(blockClass, "__addConditionText-button"),
114
- renderIcon: function renderIcon(props) {
115
- return /*#__PURE__*/React__default.createElement(Add, _extends({
116
- size: 16
117
- }, props));
118
- },
119
- iconDescription: startConditionLabel,
120
- kind: "ghost",
121
- size: "sm",
122
- onClick: onStartConditionBuilder
123
- }, startConditionLabel), isConditionBuilderActive && /*#__PURE__*/React__default.createElement(Section, {
113
+ if (!isConditionBuilderActive) {
114
+ return /*#__PURE__*/React__default.createElement(Button, {
115
+ className: "".concat(blockClass, "__addConditionText-button"),
116
+ renderIcon: function renderIcon(props) {
117
+ return /*#__PURE__*/React__default.createElement(Add, props);
118
+ },
119
+ iconDescription: startConditionLabel,
120
+ kind: "ghost",
121
+ size: "sm",
122
+ onClick: onStartConditionBuilder
123
+ }, startConditionLabel);
124
+ }
125
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Section, {
124
126
  className: "".concat(blockClass, "__heading"),
125
127
  level: 4
126
- }, _Heading || (_Heading = /*#__PURE__*/React__default.createElement(Heading, null, "Condition"))), /*#__PURE__*/React__default.createElement("div", {
128
+ }, /*#__PURE__*/React__default.createElement(Heading, null, conditionHeadingText)), /*#__PURE__*/React__default.createElement("div", {
127
129
  className: "".concat(blockClass, "__content-container"),
128
130
  role: "treegrid",
129
131
  "aria-label": "condition builder tree"
@@ -146,7 +148,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
146
148
  onChangeHandler(updatedGroup, groupIndex);
147
149
  }
148
150
  }), groupIndex < rootState.groups.length - 1 && (_GroupConnector || (_GroupConnector = /*#__PURE__*/React__default.createElement(GroupConnector, null))));
149
- })), isConditionBuilderActive && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, variant == 'tree' && /*#__PURE__*/React__default.createElement("div", {
151
+ })), variant == 'tree' && /*#__PURE__*/React__default.createElement("div", {
150
152
  role: "row",
151
153
  tabIndex: -1,
152
154
  "aria-level": 1,
@@ -170,7 +172,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
170
172
  group: {
171
173
  groupOperator: rootState.operator
172
174
  }
173
- }))), isConditionBuilderActive && actions && /*#__PURE__*/React__default.createElement(ConditionBuilderActions, {
175
+ })), actions && /*#__PURE__*/React__default.createElement(ConditionBuilderActions, {
174
176
  actions: actions,
175
177
  className: "".concat(blockClass, "__actions-container"),
176
178
  variant: variant
@@ -38,4 +38,5 @@ export namespace translationsObject {
38
38
  let invalidNumberWarnText: string;
39
39
  let conditionBuilderText: string;
40
40
  let actionSectionText: string;
41
+ let conditionHeadingText: string;
41
42
  }
@@ -44,7 +44,8 @@ var translationsObject = {
44
44
  invalidText: 'Incomplete',
45
45
  invalidNumberWarnText: 'Invalid number, must be 0 or greater',
46
46
  conditionBuilderText: 'Condition Builder',
47
- actionSectionText: 'Action Section'
47
+ actionSectionText: 'Action Section',
48
+ conditionHeadingText: 'Condition'
48
49
  };
49
50
 
50
51
  export { translationsObject };
@@ -54,10 +54,12 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
54
54
  var onRemoveHandler = function onRemoveHandler(conditionId, evt, conditionIndex) {
55
55
  if (group.conditions.length > 1) {
56
56
  variant == 'tree' ? handleFocusOnCloseTree(evt) : handleFocusOnClose(evt, conditionIndex);
57
- if (group.conditions[1].conditions) {
57
+ if (group.conditions[1].conditions && group.conditions[1].id !== conditionId) {
58
58
  //when we remove every plain conditions of a group without deleting the subgroup, we need to restructure the group
59
59
  //the inner group become outer group and same level subgroups become plain conditions
60
60
 
61
+ //ensure we are deleting last condition , not the subgroup
62
+
61
63
  //spreading out the condition inside the subgroup
62
64
  var allConditions = group.conditions.reduce(function (acc, item) {
63
65
  if (item.conditions) {
@@ -145,9 +147,17 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
145
147
  var prevRows = (_conditionBuilderCont3 = conditionBuilderContentRef.current) === null || _conditionBuilderCont3 === void 0 ? void 0 : _conditionBuilderCont3.querySelectorAll("[aria-level=\"".concat(Number(currentLevel) - 1, "\"][role=\"row\"]"));
146
148
  var nextRow = (_conditionBuilderCont4 = conditionBuilderContentRef.current) === null || _conditionBuilderCont4 === void 0 ? void 0 : _conditionBuilderCont4.querySelector("[aria-level=\"".concat(Number(currentLevel) + 1, "\"][role=\"row\"]"));
147
149
  if (nextRow) {
148
- manageTabIndexAndFocus(nextRow, conditionBuilderRef);
150
+ //since there are no condition in current group, this group will move one level up
151
+
152
+ var rowIdentity = {
153
+ ariaLevel: Number(nextRow.ariaLevel) - 1,
154
+ ariaPosInSet: nextRow.ariaPosInSet
155
+ };
156
+ setTimeout(function () {
157
+ var currentRowToFocus = conditionBuilderContentRef.current.querySelector("[role=\"row\"][aria-level=\"".concat(rowIdentity.ariaLevel, "\"][aria-posinset=\"").concat(rowIdentity.ariaPosInSet, "\"]"));
158
+ manageTabIndexAndFocus(currentRowToFocus, conditionBuilderRef);
159
+ }, 0);
149
160
  } else if ((prevRows === null || prevRows === void 0 ? void 0 : prevRows.length) > 1) {
150
- // prevRows[prevRows.length - 2].setAttribute('tabindex', '0');
151
161
  manageTabIndexAndFocus(prevRows[prevRows.length - 2], conditionBuilderRef);
152
162
  }
153
163
  }
@@ -203,8 +203,7 @@ var navigateToNextRowCell = function navigateToNextRowCell(evt, currentRowIndex,
203
203
  var nextRow = rows[nextRowIndex];
204
204
  var itemName = evt.target.dataset.name;
205
205
  if (nextRow !== null && nextRow !== void 0 && nextRow.querySelector("[data-name=\"".concat(itemName, "\"]"))) {
206
- var _nextRow$querySelecto;
207
- nextRow === null || nextRow === void 0 || (_nextRow$querySelecto = nextRow.querySelector("[data-name=\"".concat(itemName, "\"]"))) === null || _nextRow$querySelecto === void 0 || _nextRow$querySelecto.focus();
206
+ manageTabIndexAndFocus(nextRow === null || nextRow === void 0 ? void 0 : nextRow.querySelector("[data-name=\"".concat(itemName, "\"]")), conditionBuilderRef);
208
207
  } else if (variant === 'tree') {
209
208
  //when the next row is a if statement , then that row is focused. From any cell of last row of an group , arrow down select the next row (if)
210
209
  manageTabIndexAndFocus(nextRow, conditionBuilderRef);
@@ -3,6 +3,5 @@ export function focusThisItem(currentElement: any, conditionBuilderRef: any): vo
3
3
  export function traverseClockVise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any, conditionBuilderRef: any): void;
4
4
  export function traverseReverse(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any, conditionBuilderRef: any): void;
5
5
  export function checkForHoldingKey(evt: any, key: any): any;
6
- export function checkDuplicateAction(actionState: any, selectedId: any, currentActionId: any): boolean;
7
6
  export function checkIsValid(item: any): any;
8
7
  export function manageTabIndexAndFocus(currentElement: any, conditionBuilderRef: any): void;
@@ -12,6 +12,11 @@ interface CoachmarkProps {
12
12
  * @see COACHMARK_ALIGNMENT
13
13
  */
14
14
  align?: 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-top' | 'left-bottom' | 'right' | 'right-top' | 'right-bottom' | 'top' | 'top-left' | 'top-right';
15
+ /**
16
+ * Auto aligns the coachmark based on screen boundaries
17
+ * Applies only to Tooltip Coachmarks.
18
+ */
19
+ autoAlign?: boolean;
15
20
  /**
16
21
  * Coachmark should use a single CoachmarkOverlayElements component as a child.
17
22
  * @see CoachmarkOverlayElements
@@ -51,7 +56,7 @@ interface CoachmarkProps {
51
56
  positionTune?: {
52
57
  x: number;
53
58
  y: number;
54
- } | object;
59
+ };
55
60
  /**
56
61
  * The optional button or beacon that the user will click to show the Coachmark.
57
62
  */
@@ -21,6 +21,7 @@ var hooks = require('./utils/hooks.js');
21
21
  var devtools = require('../../global/js/utils/devtools.js');
22
22
  var settings = require('../../settings.js');
23
23
  var lodash = require('lodash');
24
+ var react = require('@carbon/react');
24
25
  var useIsomorphicEffect = require('../../global/js/hooks/useIsomorphicEffect.js');
25
26
 
26
27
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -28,7 +29,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
28
29
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
29
30
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
30
31
 
31
- var _excluded = ["align", "children", "className", "onClose", "overlayClassName", "overlayKind", "overlayRef", "portalTarget", "positionTune", "target", "theme"];
32
+ var _excluded = ["align", "autoAlign", "children", "className", "onClose", "overlayClassName", "overlayKind", "overlayRef", "positionTune", "portalTarget", "target", "theme"];
33
+
32
34
  // The block part of our conventional BEM class names (blockClass__E--M).
33
35
  var blockClass = "".concat(settings.pkg.prefix, "--coachmark");
34
36
  var overlayBlockClass = "".concat(blockClass, "-overlay");
@@ -46,8 +48,10 @@ var defaults = {
46
48
  */
47
49
 
48
50
  exports.Coachmark = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
51
+ var _positionTune$y, _positionTune$x;
49
52
  var _ref$align = _ref.align,
50
53
  align = _ref$align === void 0 ? defaults.align : _ref$align,
54
+ autoAlign = _ref.autoAlign,
51
55
  children = _ref.children,
52
56
  className = _ref.className,
53
57
  _ref$onClose = _ref.onClose,
@@ -56,8 +60,8 @@ exports.Coachmark = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
56
60
  _ref$overlayKind = _ref.overlayKind,
57
61
  overlayKind = _ref$overlayKind === void 0 ? defaults.overlayKind : _ref$overlayKind,
58
62
  overlayRef = _ref.overlayRef,
59
- portalTarget = _ref.portalTarget,
60
63
  positionTune = _ref.positionTune,
64
+ portalTarget = _ref.portalTarget,
61
65
  target = _ref.target,
62
66
  _ref$theme = _ref.theme,
63
67
  theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
@@ -133,6 +137,10 @@ exports.Coachmark = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
133
137
  setShouldResetPosition(true);
134
138
  }
135
139
  };
140
+ var overlayPositionStyle = {
141
+ top: ((_positionTune$y = positionTune === null || positionTune === void 0 ? void 0 : positionTune.y) !== null && _positionTune$y !== void 0 ? _positionTune$y : 0) - 16,
142
+ left: ((_positionTune$x = positionTune === null || positionTune === void 0 ? void 0 : positionTune.x) !== null && _positionTune$x !== void 0 ? _positionTune$x : 0) - 16
143
+ };
136
144
  var contextValue = {
137
145
  buttonProps: {
138
146
  'aria-expanded': isOpen,
@@ -148,7 +156,8 @@ exports.Coachmark = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
148
156
  targetRect: targetRect,
149
157
  targetOffset: targetOffset,
150
158
  align: align,
151
- positionTune: positionTune
159
+ positionTune: positionTune,
160
+ isOpen: isOpen
152
161
  };
153
162
  var handleResize = lodash.throttle(function () {
154
163
  closeOverlay();
@@ -182,7 +191,7 @@ exports.Coachmark = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
182
191
  }, /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
183
192
  className: cx__default["default"](blockClass, "".concat(blockClass, "__").concat(theme), className),
184
193
  ref: _coachmarkRef
185
- }, rest, devtools.getDevtoolsProps(componentName)), target, isOpen && (portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) && /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement(CoachmarkOverlay.CoachmarkOverlay, {
194
+ }, rest, devtools.getDevtoolsProps(componentName)), overlayKind !== 'tooltip' ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, target, isOpen && (portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) && /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement(CoachmarkOverlay.CoachmarkOverlay, {
186
195
  ref: _overlayRef,
187
196
  fixedIsVisible: false,
188
197
  kind: overlayKind,
@@ -190,7 +199,23 @@ exports.Coachmark = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
190
199
  theme: theme,
191
200
  className: cx__default["default"](overlayClassName, "".concat(overlayBlockClass, "--is-visible"))
192
201
  }, children), // Default to `document.body` when `portalNode` is `null`
193
- portalNode === null || portalNode === void 0 ? void 0 : portalNode.current)));
202
+ portalNode === null || portalNode === void 0 ? void 0 : portalNode.current)) : /*#__PURE__*/React__default["default"].createElement(react.Popover, {
203
+ highContrast: true,
204
+ caret: true,
205
+ style: _rollupPluginBabelHelpers.objectSpread2({
206
+ position: 'absolute'
207
+ }, overlayPositionStyle),
208
+ align: align,
209
+ autoAlign: autoAlign,
210
+ open: isOpen
211
+ }, target, /*#__PURE__*/React__default["default"].createElement(react.PopoverContent, null, isOpen && /*#__PURE__*/React__default["default"].createElement(CoachmarkOverlay.CoachmarkOverlay, {
212
+ ref: _overlayRef,
213
+ fixedIsVisible: false,
214
+ kind: overlayKind,
215
+ onClose: handleClose,
216
+ theme: theme,
217
+ className: cx__default["default"](overlayClassName, _rollupPluginBabelHelpers.defineProperty({}, "".concat(overlayBlockClass, "--is-visible"), isOpen))
218
+ }, children)))));
194
219
  });
195
220
  var overlayRefType = typeof HTMLElement === 'undefined' ? index["default"].object :
196
221
  // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
@@ -213,6 +238,11 @@ exports.Coachmark.propTypes = {
213
238
  * @see COACHMARK_ALIGNMENT
214
239
  */
215
240
  align: index["default"].oneOf(['bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom', 'right', 'right-top', 'right-bottom', 'top', 'top-left', 'top-right']),
241
+ /**
242
+ * Auto aligns the coachmark based on screen boundaries
243
+ * Applies only to Tooltip Coachmarks.
244
+ */
245
+ autoAlign: index["default"].bool,
216
246
  /**
217
247
  * Coachmark should use a single CoachmarkOverlayElements component as a child.
218
248
  * @see CoachmarkOverlayElements
@@ -251,6 +281,7 @@ exports.Coachmark.propTypes = {
251
281
  /**
252
282
  * Fine tune the position of the target in pixels. Applies only to Beacons.
253
283
  */
284
+ // @ts-ignore
254
285
  positionTune: index["default"].shape({
255
286
  x: index["default"].number,
256
287
  y: index["default"].number
@@ -64,7 +64,7 @@ exports.CoachmarkOverlay = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
64
64
  var coachmark = context.useCoachmark();
65
65
  var isBeacon = kind === enums.COACHMARK_OVERLAY_KIND.TOOLTIP;
66
66
  var isDraggable = kind === enums.COACHMARK_OVERLAY_KIND.FLOATING;
67
- var isVisible = className && className.includes('is-visible');
67
+ var isVisible = className === null || className === void 0 ? void 0 : className.includes('is-visible');
68
68
  var handleKeyPress = function handleKeyPress(event) {
69
69
  var shiftKey = event.shiftKey,
70
70
  key = event.key;
@@ -172,9 +172,7 @@ exports.CoachmarkOverlay = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
172
172
  return /*#__PURE__*/React__default["default"].cloneElement(child, {
173
173
  isVisible: isVisible
174
174
  });
175
- })), isBeacon && /*#__PURE__*/React__default["default"].createElement("span", {
176
- className: "".concat(blockClass, "__caret")
177
- }));
175
+ })));
178
176
  });
179
177
  function getWindowDimensions() {
180
178
  var _window = window,
@@ -35,7 +35,6 @@ var defaults = {
35
35
  * Use beacon for the target prop of a Coachmark component.
36
36
  */
37
37
  exports.CoachmarkBeacon = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
38
- var _coachmark$positionTu, _coachmark$positionTu2, _coachmark$positionTu3, _coachmark$positionTu4;
39
38
  var label = _ref.label,
40
39
  className = _ref.className,
41
40
  _ref$kind = _ref.kind,
@@ -45,14 +44,9 @@ exports.CoachmarkBeacon = /*#__PURE__*/React__default["default"].forwardRef(func
45
44
  if (!coachmark) {
46
45
  return _div || (_div = /*#__PURE__*/React__default["default"].createElement("div", null, "CoachmarkBeacon is to be use exclusively within the target prop of Coachmark"));
47
46
  }
48
- var overlayPositionStyle = {
49
- top: (_coachmark$positionTu = (_coachmark$positionTu2 = coachmark.positionTune) === null || _coachmark$positionTu2 === void 0 ? void 0 : _coachmark$positionTu2.y) !== null && _coachmark$positionTu !== void 0 ? _coachmark$positionTu : 0,
50
- left: (_coachmark$positionTu3 = (_coachmark$positionTu4 = coachmark.positionTune) === null || _coachmark$positionTu4 === void 0 ? void 0 : _coachmark$positionTu4.x) !== null && _coachmark$positionTu3 !== void 0 ? _coachmark$positionTu3 : 0
51
- };
52
47
  return /*#__PURE__*/React__default["default"].createElement("span", _rollupPluginBabelHelpers["extends"]({}, rest, {
53
48
  className: cx__default["default"](blockClass, "".concat(blockClass, "-").concat(kind), className),
54
- ref: ref,
55
- style: overlayPositionStyle
49
+ ref: ref
56
50
  }, devtools.getDevtoolsProps(componentName), {
57
51
  role: "tooltip"
58
52
  }), /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({
@@ -28,7 +28,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
28
28
 
29
29
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
30
30
 
31
- var _Heading, _GroupConnector;
31
+ var _GroupConnector;
32
32
  var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
33
33
  var _rootState$groups2;
34
34
  var startConditionLabel = _ref.startConditionLabel,
@@ -49,9 +49,10 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
49
49
  _useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
50
50
  showConditionGroupPreview = _useState4[0],
51
51
  setShowConditionGroupPreview = _useState4[1];
52
- var _useTranslations = useTranslations.useTranslations(['addConditionGroupText']),
53
- _useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 1),
54
- addConditionGroupText = _useTranslations2[0];
52
+ var _useTranslations = useTranslations.useTranslations(['addConditionGroupText', 'conditionHeadingText']),
53
+ _useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 2),
54
+ addConditionGroupText = _useTranslations2[0],
55
+ conditionHeadingText = _useTranslations2[1];
55
56
  var showConditionGroupPreviewHandler = function showConditionGroupPreviewHandler() {
56
57
  setShowConditionGroupPreview(true);
57
58
  };
@@ -117,21 +118,22 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
117
118
  groups: [].concat(_rollupPluginBabelHelpers.toConsumableArray(rootState.groups), [newGroup])
118
119
  }));
119
120
  };
120
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, !isConditionBuilderActive && /*#__PURE__*/React__default["default"].createElement(react.Button, {
121
- className: "".concat(DataConfigs.blockClass, "__addConditionText-button"),
122
- renderIcon: function renderIcon(props) {
123
- return /*#__PURE__*/React__default["default"].createElement(icons.Add, _rollupPluginBabelHelpers["extends"]({
124
- size: 16
125
- }, props));
126
- },
127
- iconDescription: startConditionLabel,
128
- kind: "ghost",
129
- size: "sm",
130
- onClick: onStartConditionBuilder
131
- }, startConditionLabel), isConditionBuilderActive && /*#__PURE__*/React__default["default"].createElement(react.Section, {
121
+ if (!isConditionBuilderActive) {
122
+ return /*#__PURE__*/React__default["default"].createElement(react.Button, {
123
+ className: "".concat(DataConfigs.blockClass, "__addConditionText-button"),
124
+ renderIcon: function renderIcon(props) {
125
+ return /*#__PURE__*/React__default["default"].createElement(icons.Add, props);
126
+ },
127
+ iconDescription: startConditionLabel,
128
+ kind: "ghost",
129
+ size: "sm",
130
+ onClick: onStartConditionBuilder
131
+ }, startConditionLabel);
132
+ }
133
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(react.Section, {
132
134
  className: "".concat(DataConfigs.blockClass, "__heading"),
133
135
  level: 4
134
- }, _Heading || (_Heading = /*#__PURE__*/React__default["default"].createElement(react.Heading, null, "Condition"))), /*#__PURE__*/React__default["default"].createElement("div", {
136
+ }, /*#__PURE__*/React__default["default"].createElement(react.Heading, null, conditionHeadingText)), /*#__PURE__*/React__default["default"].createElement("div", {
135
137
  className: "".concat(DataConfigs.blockClass, "__content-container"),
136
138
  role: "treegrid",
137
139
  "aria-label": "condition builder tree"
@@ -154,7 +156,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
154
156
  onChangeHandler(updatedGroup, groupIndex);
155
157
  }
156
158
  }), groupIndex < rootState.groups.length - 1 && (_GroupConnector || (_GroupConnector = /*#__PURE__*/React__default["default"].createElement(GroupConnector["default"], null))));
157
- })), isConditionBuilderActive && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, variant == 'tree' && /*#__PURE__*/React__default["default"].createElement("div", {
159
+ })), variant == 'tree' && /*#__PURE__*/React__default["default"].createElement("div", {
158
160
  role: "row",
159
161
  tabIndex: -1,
160
162
  "aria-level": 1,
@@ -178,7 +180,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
178
180
  group: {
179
181
  groupOperator: rootState.operator
180
182
  }
181
- }))), isConditionBuilderActive && actions && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderActions["default"], {
183
+ })), actions && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderActions["default"], {
182
184
  actions: actions,
183
185
  className: "".concat(DataConfigs.blockClass, "__actions-container"),
184
186
  variant: variant
@@ -38,4 +38,5 @@ export namespace translationsObject {
38
38
  let invalidNumberWarnText: string;
39
39
  let conditionBuilderText: string;
40
40
  let actionSectionText: string;
41
+ let conditionHeadingText: string;
41
42
  }
@@ -48,7 +48,8 @@ var translationsObject = {
48
48
  invalidText: 'Incomplete',
49
49
  invalidNumberWarnText: 'Invalid number, must be 0 or greater',
50
50
  conditionBuilderText: 'Condition Builder',
51
- actionSectionText: 'Action Section'
51
+ actionSectionText: 'Action Section',
52
+ conditionHeadingText: 'Condition'
52
53
  };
53
54
 
54
55
  exports.translationsObject = translationsObject;
@@ -63,10 +63,12 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
63
63
  var onRemoveHandler = function onRemoveHandler(conditionId, evt, conditionIndex) {
64
64
  if (group.conditions.length > 1) {
65
65
  variant == 'tree' ? handleFocusOnCloseTree(evt) : handleFocusOnClose(evt, conditionIndex);
66
- if (group.conditions[1].conditions) {
66
+ if (group.conditions[1].conditions && group.conditions[1].id !== conditionId) {
67
67
  //when we remove every plain conditions of a group without deleting the subgroup, we need to restructure the group
68
68
  //the inner group become outer group and same level subgroups become plain conditions
69
69
 
70
+ //ensure we are deleting last condition , not the subgroup
71
+
70
72
  //spreading out the condition inside the subgroup
71
73
  var allConditions = group.conditions.reduce(function (acc, item) {
72
74
  if (item.conditions) {
@@ -154,9 +156,17 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
154
156
  var prevRows = (_conditionBuilderCont3 = conditionBuilderContentRef.current) === null || _conditionBuilderCont3 === void 0 ? void 0 : _conditionBuilderCont3.querySelectorAll("[aria-level=\"".concat(Number(currentLevel) - 1, "\"][role=\"row\"]"));
155
157
  var nextRow = (_conditionBuilderCont4 = conditionBuilderContentRef.current) === null || _conditionBuilderCont4 === void 0 ? void 0 : _conditionBuilderCont4.querySelector("[aria-level=\"".concat(Number(currentLevel) + 1, "\"][role=\"row\"]"));
156
158
  if (nextRow) {
157
- util.manageTabIndexAndFocus(nextRow, conditionBuilderRef);
159
+ //since there are no condition in current group, this group will move one level up
160
+
161
+ var rowIdentity = {
162
+ ariaLevel: Number(nextRow.ariaLevel) - 1,
163
+ ariaPosInSet: nextRow.ariaPosInSet
164
+ };
165
+ setTimeout(function () {
166
+ var currentRowToFocus = conditionBuilderContentRef.current.querySelector("[role=\"row\"][aria-level=\"".concat(rowIdentity.ariaLevel, "\"][aria-posinset=\"").concat(rowIdentity.ariaPosInSet, "\"]"));
167
+ util.manageTabIndexAndFocus(currentRowToFocus, conditionBuilderRef);
168
+ }, 0);
158
169
  } else if ((prevRows === null || prevRows === void 0 ? void 0 : prevRows.length) > 1) {
159
- // prevRows[prevRows.length - 2].setAttribute('tabindex', '0');
160
170
  util.manageTabIndexAndFocus(prevRows[prevRows.length - 2], conditionBuilderRef);
161
171
  }
162
172
  }