@carbon/ibm-products 2.33.0 → 2.34.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. package/css/index-full-carbon.css +303 -11
  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.css +303 -11
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +1 -1
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +303 -11
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +1 -1
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/CreateSidePanel/CreateSidePanel.d.ts +81 -2
  14. package/es/components/CreateSidePanel/CreateSidePanel.js +5 -2
  15. package/es/components/DataSpreadsheet/DataSpreadsheet.js +5 -117
  16. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +12 -111
  17. package/es/components/DataSpreadsheet/utils/commonEventHandlers.d.ts +4 -0
  18. package/es/components/DataSpreadsheet/utils/commonEventHandlers.js +304 -0
  19. package/es/components/Datagrid/Datagrid/DatagridContent.js +2 -1
  20. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +4 -1
  21. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
  22. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +4 -1
  23. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +6 -2
  24. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.d.ts +1 -1
  25. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +4 -0
  26. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.d.ts +2 -1
  27. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +4 -3
  28. package/es/components/EditSidePanel/EditSidePanel.d.ts +92 -2
  29. package/es/components/EditSidePanel/EditSidePanel.js +8 -10
  30. package/es/components/FilterPanel/FilterPanelAccordion/FilterPanelAccordion.d.ts +5 -0
  31. package/es/components/FilterPanel/FilterPanelAccordion/FilterPanelAccordion.js +83 -0
  32. package/es/components/FilterPanel/FilterPanelAccordionItem/FilterPanelAccordionItem.d.ts +5 -0
  33. package/es/components/FilterPanel/FilterPanelAccordionItem/FilterPanelAccordionItem.js +94 -0
  34. package/es/components/FilterPanel/FilterPanelCheckbox/FilterPanelCheckbox.js +3 -1
  35. package/es/components/FilterPanel/FilterPanelCheckbox/index.d.ts +1 -0
  36. package/es/components/FilterPanel/FilterPanelCheckboxWithOverflow/FilterPanelCheckboxWithOverflow.d.ts +10 -0
  37. package/es/components/FilterPanel/FilterPanelCheckboxWithOverflow/FilterPanelCheckboxWithOverflow.js +157 -0
  38. package/es/components/FilterPanel/FilterPanelGroup/FilterPanelGroup.d.ts +5 -0
  39. package/es/components/FilterPanel/FilterPanelGroup/FilterPanelGroup.js +72 -0
  40. package/es/components/FilterPanel/FilterPanelLabel/FilterPanelLabel.js +2 -2
  41. package/es/components/FilterPanel/index.d.ts +4 -0
  42. package/es/components/OptionsTile/OptionsTile.d.ts +77 -3
  43. package/es/components/OptionsTile/OptionsTile.js +9 -20
  44. package/es/components/RemoveModal/RemoveModal.d.ts +81 -7
  45. package/es/components/RemoveModal/RemoveModal.js +1 -0
  46. package/es/components/ScrollGradient/ScrollGradient.d.ts +5 -0
  47. package/es/components/ScrollGradient/ScrollGradient.js +156 -0
  48. package/es/components/ScrollGradient/constants.d.ts +15 -0
  49. package/es/components/ScrollGradient/constants.js +121 -0
  50. package/es/components/ScrollGradient/index.d.ts +1 -0
  51. package/es/components/SidePanel/SidePanel.d.ts +144 -2
  52. package/es/components/SidePanel/SidePanel.js +57 -48
  53. package/es/components/StatusIcon/StatusIcon.d.ts +34 -2
  54. package/es/components/StatusIcon/StatusIcon.js +97 -95
  55. package/es/components/TruncatedList/TruncatedList.js +5 -3
  56. package/es/components/UserAvatar/UserAvatar.js +3 -2
  57. package/es/components/index.d.ts +2 -1
  58. package/es/global/js/package-settings.d.ts +5 -0
  59. package/es/global/js/package-settings.js +5 -0
  60. package/es/index.js +5 -0
  61. package/es/settings.d.ts +5 -0
  62. package/lib/components/CreateSidePanel/CreateSidePanel.d.ts +81 -2
  63. package/lib/components/CreateSidePanel/CreateSidePanel.js +5 -2
  64. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +5 -117
  65. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +12 -111
  66. package/lib/components/DataSpreadsheet/utils/commonEventHandlers.d.ts +4 -0
  67. package/lib/components/DataSpreadsheet/utils/commonEventHandlers.js +311 -0
  68. package/lib/components/Datagrid/Datagrid/DatagridContent.js +2 -1
  69. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +4 -1
  70. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
  71. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +4 -1
  72. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +5 -1
  73. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.d.ts +1 -1
  74. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +4 -0
  75. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.d.ts +2 -1
  76. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +4 -3
  77. package/lib/components/EditSidePanel/EditSidePanel.d.ts +92 -2
  78. package/lib/components/EditSidePanel/EditSidePanel.js +8 -10
  79. package/lib/components/FilterPanel/FilterPanelAccordion/FilterPanelAccordion.d.ts +5 -0
  80. package/lib/components/FilterPanel/FilterPanelAccordion/FilterPanelAccordion.js +90 -0
  81. package/lib/components/FilterPanel/FilterPanelAccordionItem/FilterPanelAccordionItem.d.ts +5 -0
  82. package/lib/components/FilterPanel/FilterPanelAccordionItem/FilterPanelAccordionItem.js +101 -0
  83. package/lib/components/FilterPanel/FilterPanelCheckbox/FilterPanelCheckbox.js +3 -1
  84. package/lib/components/FilterPanel/FilterPanelCheckbox/index.d.ts +1 -0
  85. package/lib/components/FilterPanel/FilterPanelCheckboxWithOverflow/FilterPanelCheckboxWithOverflow.d.ts +10 -0
  86. package/lib/components/FilterPanel/FilterPanelCheckboxWithOverflow/FilterPanelCheckboxWithOverflow.js +164 -0
  87. package/lib/components/FilterPanel/FilterPanelGroup/FilterPanelGroup.d.ts +5 -0
  88. package/lib/components/FilterPanel/FilterPanelGroup/FilterPanelGroup.js +79 -0
  89. package/lib/components/FilterPanel/FilterPanelLabel/FilterPanelLabel.js +2 -2
  90. package/lib/components/FilterPanel/index.d.ts +4 -0
  91. package/lib/components/OptionsTile/OptionsTile.d.ts +77 -3
  92. package/lib/components/OptionsTile/OptionsTile.js +9 -20
  93. package/lib/components/RemoveModal/RemoveModal.d.ts +81 -7
  94. package/lib/components/RemoveModal/RemoveModal.js +1 -0
  95. package/lib/components/ScrollGradient/ScrollGradient.d.ts +5 -0
  96. package/lib/components/ScrollGradient/ScrollGradient.js +163 -0
  97. package/lib/components/ScrollGradient/constants.d.ts +15 -0
  98. package/lib/components/ScrollGradient/constants.js +128 -0
  99. package/lib/components/ScrollGradient/index.d.ts +1 -0
  100. package/lib/components/SidePanel/SidePanel.d.ts +144 -2
  101. package/lib/components/SidePanel/SidePanel.js +57 -48
  102. package/lib/components/StatusIcon/StatusIcon.d.ts +34 -2
  103. package/lib/components/StatusIcon/StatusIcon.js +97 -95
  104. package/lib/components/TruncatedList/TruncatedList.js +5 -3
  105. package/lib/components/UserAvatar/UserAvatar.js +3 -2
  106. package/lib/components/index.d.ts +2 -1
  107. package/lib/global/js/package-settings.d.ts +5 -0
  108. package/lib/global/js/package-settings.js +5 -0
  109. package/lib/index.js +25 -0
  110. package/lib/settings.d.ts +5 -0
  111. package/package.json +3 -3
  112. package/scss/components/FilterPanel/_filter-panel-accordion-item.scss +56 -0
  113. package/scss/components/FilterPanel/_filter-panel-accordion.scss +6 -0
  114. package/scss/components/FilterPanel/_filter-panel-checkbox-with-overflow.scss +62 -0
  115. package/scss/components/FilterPanel/_filter-panel-checkbox.scss +25 -3
  116. package/scss/components/FilterPanel/_filter-panel-group.scss +39 -0
  117. package/scss/components/FilterPanel/_filter-panel-label.scss +0 -8
  118. package/scss/components/FilterPanel/_filter-panel.scss +2 -0
  119. package/scss/components/FilterPanel/_index-with-carbon.scss +4 -0
  120. package/scss/components/FilterPanel/_index.scss +4 -0
  121. package/scss/components/ScrollGradient/_carbon-imports.scss +9 -0
  122. package/scss/components/ScrollGradient/_index-with-carbon.scss +9 -0
  123. package/scss/components/ScrollGradient/_index.scss +8 -0
  124. package/scss/components/ScrollGradient/_scroll-gradient.scss +102 -0
  125. package/scss/components/UserAvatar/_user-avatar.scss +37 -4
  126. package/scss/components/_index-with-carbon.scss +1 -0
  127. package/scss/components/_index.scss +1 -0
@@ -1,7 +1,81 @@
1
- /**
2
- The `RemoveModal` covers what is known as high impact and medium impact deleting.
3
- Enabling `textConfirmation` enables what would be considered the high impact state of the modal.
4
- For additional information on differentiating between delete / remove and low / medium / high impact please refer to the usage guidelines.
5
- */
6
- export let RemoveModal: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
7
- import React from 'react';
1
+ /// <reference path="../../../src/custom-typings/index.d.ts" />
2
+ import React, { ReactNode } from 'react';
3
+ import { ComposedModal } from '@carbon/react';
4
+ interface RemoveModalProps extends React.ComponentProps<typeof ComposedModal> {
5
+ /**
6
+ * The content to be displayed in the body of the modal
7
+ */
8
+ body: string;
9
+ /**
10
+ * Optional classname
11
+ */
12
+ className?: string;
13
+ /**
14
+ * Provide a description for "close" icon that can be read by screen readers
15
+ */
16
+ iconDescription: string;
17
+ /**
18
+ * Message showed when user input fails validation
19
+ */
20
+ inputInvalidText?: string;
21
+ /**
22
+ * Label for text box
23
+ */
24
+ inputLabelText?: ReactNode;
25
+ /**
26
+ * Placeholder for text box
27
+ */
28
+ inputPlaceholderText?: string;
29
+ /**
30
+ * Specify the modal label texts
31
+ */
32
+ label?: string;
33
+ /**
34
+ * Callback function that runs when user closes the modal
35
+ */
36
+ onClose?: () => void;
37
+ /**
38
+ * Callback function that runs when user submits the modal
39
+ */
40
+ onRequestSubmit?: () => void;
41
+ /**
42
+ * Specify whether the Modal is currently open
43
+ */
44
+ open: boolean;
45
+ /**
46
+ * The DOM node the tearsheet should be rendered within. Defaults to document.body.
47
+ */
48
+ portalTarget?: ReactNode;
49
+ /**
50
+ * Prevent closing on click outside of modal
51
+ */
52
+ preventCloseOnClickOutside?: boolean;
53
+ /**
54
+ * Specify whether the primary button should be disabled. This value will override textConfirmation
55
+ */
56
+ primaryButtonDisabled?: boolean;
57
+ /**
58
+ * Specify the text for the primary button
59
+ */
60
+ primaryButtonText?: string;
61
+ /**
62
+ * The name of the resource being acted upon
63
+ */
64
+ resourceName: string;
65
+ /**
66
+ * Specify the text for the secondary button
67
+ */
68
+ secondaryButtonText?: string;
69
+ /**
70
+ * Specify whether or not to show the text confirmation input
71
+ */
72
+ textConfirmation?: boolean;
73
+ /**
74
+ * The text displayed at the top of the modal
75
+ */
76
+ title: string;
77
+ }
78
+ export declare let RemoveModal: React.ForwardRefExoticComponent<RemoveModalProps & {
79
+ children?: React.ReactNode;
80
+ } & React.RefAttributes<unknown>>;
81
+ export {};
@@ -24,6 +24,7 @@ The `RemoveModal` covers what is known as high impact and medium impact deleting
24
24
  Enabling `textConfirmation` enables what would be considered the high impact state of the modal.
25
25
  For additional information on differentiating between delete / remove and low / medium / high impact please refer to the usage guidelines.
26
26
  */
27
+
27
28
  var RemoveModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
28
29
  var body = _ref.body,
29
30
  className = _ref.className,
@@ -0,0 +1,5 @@
1
+ /**
2
+ * TODO: A description of the component.
3
+ */
4
+ export let ScrollGradient: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
+ import React from 'react';
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 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
+
8
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default, { useState, useRef, useCallback, useEffect } from 'react';
10
+ import PropTypes from '../../node_modules/prop-types/index.js';
11
+ import cx from 'classnames';
12
+ import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
13
+ import { pkg, carbon } from '../../settings.js';
14
+ import { throttle } from 'lodash';
15
+ import { ScrollStates, getScrollState, ScrollDirection, useIsOverflow } from './constants.js';
16
+
17
+ var _excluded = ["children", "className", "color", "onScroll", "scrollElementClassName", "getScrollElementRef", "hideStartGradient"];
18
+ var blockClass = "".concat(pkg.prefix, "--scroll-gradient");
19
+ var componentName = 'ScrollGradient';
20
+
21
+ // Default values for props
22
+ var defaults = {
23
+ color: "var(--".concat(carbon.prefix, "-layer-01)"),
24
+ hideStartGradient: false,
25
+ onScroll: function onScroll() {},
26
+ getScrollElementRef: function getScrollElementRef() {}
27
+ };
28
+
29
+ /**
30
+ * TODO: A description of the component.
31
+ */
32
+ var ScrollGradient = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
33
+ var children = _ref.children,
34
+ className = _ref.className,
35
+ _ref$color = _ref.color,
36
+ color = _ref$color === void 0 ? defaults.color : _ref$color,
37
+ _ref$onScroll = _ref.onScroll,
38
+ onScroll = _ref$onScroll === void 0 ? defaults.onScroll : _ref$onScroll,
39
+ scrollElementClassName = _ref.scrollElementClassName,
40
+ _ref$getScrollElement = _ref.getScrollElementRef,
41
+ getScrollElementRef = _ref$getScrollElement === void 0 ? defaults.getScrollElementRef : _ref$getScrollElement,
42
+ _ref$hideStartGradien = _ref.hideStartGradient,
43
+ hideStartGradient = _ref$hideStartGradien === void 0 ? defaults.hideStartGradient : _ref$hideStartGradien,
44
+ rest = _objectWithoutProperties(_ref, _excluded);
45
+ var _useState = useState(ScrollStates.NONE),
46
+ _useState2 = _slicedToArray(_useState, 2),
47
+ verticalPosition = _useState2[0],
48
+ setVerticalPosition = _useState2[1];
49
+ var _useState3 = useState(ScrollStates.NONE),
50
+ _useState4 = _slicedToArray(_useState3, 2),
51
+ horizontalPosition = _useState4[0],
52
+ setHorizontalPosition = _useState4[1];
53
+ var scrollContainer = useRef();
54
+ var contentChildrenContainer = useRef();
55
+ var updateScrollState = throttle(function () {
56
+ var updatedVerticalVal = getScrollState(scrollContainer.current, ScrollDirection.Y);
57
+ var updatedHorizontalVal = getScrollState(scrollContainer.current, ScrollDirection.X);
58
+ setVerticalPosition(updatedVerticalVal);
59
+ setHorizontalPosition(updatedHorizontalVal);
60
+ }, 150);
61
+ var scrollHandler = useCallback(function (event) {
62
+ onScroll(event);
63
+ updateScrollState();
64
+ }, [onScroll, updateScrollState]);
65
+ var setRefs = function setRefs(element) {
66
+ scrollContainer.current = element;
67
+ getScrollElementRef(element);
68
+ };
69
+ useEffect(function () {
70
+ scrollHandler();
71
+ }, [scrollHandler]);
72
+ var _useIsOverflow = useIsOverflow(scrollContainer),
73
+ xScrollable = _useIsOverflow.xScrollable,
74
+ yScrollable = _useIsOverflow.yScrollable;
75
+ var gradientRight = yScrollable && scrollContainer.current && contentChildrenContainer.current ? scrollContainer.current.offsetWidth - contentChildrenContainer.current.offsetWidth : 0;
76
+ var gradientBottom = xScrollable && scrollContainer.current && contentChildrenContainer.current ? scrollContainer.current.offsetHeight - contentChildrenContainer.current.offsetHeight : 0;
77
+ return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
78
+ className: cx(blockClass, "".concat(blockClass, "--x-").concat(horizontalPosition.toLowerCase()), "".concat(blockClass, "--y-").concat(verticalPosition.toLowerCase()), _defineProperty(_defineProperty({}, "".concat(blockClass, "--x-scrollable"), xScrollable), "".concat(blockClass, "--y-scrollable"), yScrollable), className),
79
+ ref: ref,
80
+ role: "presentation"
81
+ }, getDevtoolsProps(componentName)), /*#__PURE__*/React__default.createElement("div", {
82
+ onScroll: scrollHandler,
83
+ ref: setRefs,
84
+ className: cx("".concat(blockClass, "__content"), scrollElementClassName)
85
+ }, /*#__PURE__*/React__default.createElement("div", {
86
+ ref: contentChildrenContainer,
87
+ className: "".concat(blockClass, "__content-children")
88
+ }, children)), !hideStartGradient && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
89
+ className: "".concat(blockClass, "__start-vertical"),
90
+ style: {
91
+ right: gradientRight,
92
+ backgroundImage: "linear-gradient(0deg, transparent, ".concat(color, " 90%)")
93
+ },
94
+ role: "presentation",
95
+ "aria-hidden": true
96
+ }), /*#__PURE__*/React__default.createElement("div", {
97
+ className: "".concat(blockClass, "__start-horizontal"),
98
+ style: {
99
+ backgroundImage: "linear-gradient(-90deg, transparent, ".concat(color, " 90%)"),
100
+ bottom: gradientBottom
101
+ },
102
+ role: "presentation",
103
+ "aria-hidden": true
104
+ })), /*#__PURE__*/React__default.createElement("div", {
105
+ className: "".concat(blockClass, "__end-vertical"),
106
+ style: {
107
+ right: gradientRight,
108
+ bottom: gradientBottom,
109
+ backgroundImage: "linear-gradient(0deg, ".concat(color, " 10%, transparent)")
110
+ },
111
+ role: "presentation",
112
+ "aria-hidden": true
113
+ }), /*#__PURE__*/React__default.createElement("div", {
114
+ className: "".concat(blockClass, "__end-horizontal"),
115
+ style: {
116
+ right: gradientRight,
117
+ bottom: gradientBottom,
118
+ backgroundImage: "linear-gradient(-90deg, ".concat(color, " 10%, transparent)")
119
+ },
120
+ role: "presentation",
121
+ "aria-hidden": true
122
+ }));
123
+ });
124
+
125
+ // Return a placeholder if not released and not enabled by feature flag
126
+ ScrollGradient = pkg.checkComponentEnabled(ScrollGradient, componentName);
127
+
128
+ // The display name of the component, used by React. Note that displayName
129
+ // is used in preference to relying on function.name.
130
+ ScrollGradient.displayName = componentName;
131
+
132
+ // The types and DocGen commentary for the component props,
133
+ // in alphabetical order (for consistency).
134
+ // See https://www.npmjs.com/package/prop-types#usage.
135
+ ScrollGradient.propTypes = {
136
+ /**
137
+ * Provide the contents of the ScrollGradient.
138
+ */
139
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
140
+ /**
141
+ * Provide an optional class to be applied to the containing node.
142
+ */
143
+ className: PropTypes.string,
144
+ /** @type {string} Fade out color. Any valid CSS color value works */
145
+ color: PropTypes.string,
146
+ /** @type {(element: HTMLElement) => {}} Optional function to get reference to scrollable DOM element */
147
+ getScrollElementRef: PropTypes.func,
148
+ /** @type {boolean} Set to true if you want to hide gradient on the start side (top or left) of scrollable element. */
149
+ hideStartGradient: PropTypes.bool,
150
+ /** @type {Function} Optional scroll handler */
151
+ onScroll: PropTypes.func,
152
+ /** @type {string} Optional classname for scroll element. */
153
+ scrollElementClassName: PropTypes.string
154
+ };
155
+
156
+ export { ScrollGradient };
@@ -0,0 +1,15 @@
1
+ export namespace ScrollDirection {
2
+ let X: string;
3
+ let Y: string;
4
+ }
5
+ export namespace ScrollStates {
6
+ let NONE: string;
7
+ let INITIAL: string;
8
+ let STARTED: string;
9
+ let END: string;
10
+ }
11
+ export function getScrollState(element: any, scrollDirection: any): string;
12
+ export function useIsOverflow(ref: any): {
13
+ xScrollable: undefined;
14
+ yScrollable: undefined;
15
+ };
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 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
+
8
+ import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import { useState, useCallback, useEffect, useLayoutEffect } from 'react';
10
+
11
+ var ScrollDirection = {
12
+ X: 'X',
13
+ Y: 'Y'
14
+ };
15
+ var ScrollStates = {
16
+ // No scrolling required because content fits within container.
17
+ NONE: 'NONE',
18
+ // Scroll position is a the start of the scrollable content.
19
+ INITIAL: 'INITIAL',
20
+ // Scroll position is neither at start or end of scrollable content.
21
+ STARTED: 'STARTED',
22
+ // Scroll position is a the end of the scrollable content.
23
+ END: 'END'
24
+ };
25
+
26
+ // FUNCTIONS
27
+
28
+ var getScrollState = function getScrollState(element, scrollDirection) {
29
+ // console.log('getScrollState - element: ', element);
30
+ // console.log('getScrollState - scrollDirection: ', scrollDirection);
31
+ // console.log('-------------------------------------------------');
32
+ switch (scrollDirection) {
33
+ case ScrollDirection.X:
34
+ {
35
+ if (element.scrollWidth === element.clientWidth) {
36
+ return ScrollStates.NONE;
37
+ }
38
+ if (element.scrollLeft === 0) {
39
+ return ScrollStates.INITIAL;
40
+ }
41
+ if (element.scrollLeft + element.clientWidth === element.scrollWidth) {
42
+ return ScrollStates.END;
43
+ }
44
+ return ScrollStates.STARTED;
45
+ }
46
+ case ScrollDirection.Y:
47
+ default:
48
+ {
49
+ if (element.scrollHeight === element.clientHeight) {
50
+ return ScrollStates.NONE;
51
+ }
52
+ if (element.scrollTop === 0) {
53
+ return ScrollStates.INITIAL;
54
+ }
55
+ if (element.scrollTop + element.clientHeight === element.scrollHeight) {
56
+ return ScrollStates.END;
57
+ }
58
+ return ScrollStates.STARTED;
59
+ }
60
+ }
61
+ };
62
+ var useIsOverflow = function useIsOverflow(ref) {
63
+ var _useState = useState(),
64
+ _useState2 = _slicedToArray(_useState, 2),
65
+ isHorizontallyScrollable = _useState2[0],
66
+ setIsHorizontallyScrollable = _useState2[1];
67
+ var _useState3 = useState(),
68
+ _useState4 = _slicedToArray(_useState3, 2),
69
+ isVerticallyScrollable = _useState4[0],
70
+ setIsVerticallyScrollable = _useState4[1];
71
+ var _useState5 = useState(),
72
+ _useState6 = _slicedToArray(_useState5, 2),
73
+ mutationObserver = _useState6[0],
74
+ setMutationObserver = _useState6[1];
75
+ var _useState7 = useState(),
76
+ _useState8 = _slicedToArray(_useState7, 2),
77
+ resizeObserver = _useState8[0],
78
+ setResizeObserver = _useState8[1];
79
+ var checkOverflow = useCallback(function () {
80
+ if (!ref.current) {
81
+ return;
82
+ }
83
+ setIsHorizontallyScrollable(ref.current.scrollWidth > ref.current.clientWidth);
84
+ setIsVerticallyScrollable(ref.current.scrollHeight > ref.current.clientHeight);
85
+ }, [ref]);
86
+ useEffect(function () {
87
+ if (!mutationObserver) {
88
+ return;
89
+ }
90
+ return function () {
91
+ if (mutationObserver) {
92
+ mutationObserver.disconnect();
93
+ }
94
+ if (resizeObserver) {
95
+ resizeObserver.disconnect();
96
+ }
97
+ };
98
+ });
99
+ useLayoutEffect(function () {
100
+ var current = ref.current;
101
+ if (current) {
102
+ if ('ResizeObserver' in window && !resizeObserver) {
103
+ setResizeObserver(new ResizeObserver(checkOverflow).observe(current));
104
+ }
105
+ if ('MutationObserver' in window && !mutationObserver) {
106
+ setMutationObserver(new MutationObserver(checkOverflow).observe(current, {
107
+ attributes: false,
108
+ childList: true,
109
+ subtree: false
110
+ }));
111
+ }
112
+ checkOverflow();
113
+ }
114
+ }, [ref, checkOverflow, mutationObserver, resizeObserver]);
115
+ return {
116
+ xScrollable: isHorizontallyScrollable,
117
+ yScrollable: isVerticallyScrollable
118
+ };
119
+ };
120
+
121
+ export { ScrollDirection, ScrollStates, getScrollState, useIsOverflow };
@@ -0,0 +1 @@
1
+ export { ScrollGradient } from "./ScrollGradient";
@@ -1,5 +1,147 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 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
+ /// <reference path="../../../src/custom-typings/index.d.ts" />
8
+ import React, { ReactNode } from 'react';
9
+ import { ButtonProps } from '@carbon/react';
10
+ type SidePanelBaseProps = {
11
+ /**
12
+ * Sets the action toolbar buttons
13
+ */
14
+ actionToolbarButtons?: ButtonProps[];
15
+ /**
16
+ * The primary actions to be shown in the side panel. Each action is
17
+ * specified as an object that will render expressive Buttons. Any Button
18
+ * props can be passed in and any other fields in the object will be
19
+ * passed through to the button element as HTML attributes.
20
+ *
21
+ * See https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
22
+ */
23
+ actions?: ButtonProps[];
24
+ /**
25
+ * Determines if the title will animate on scroll
26
+ */
27
+ animateTitle?: boolean;
28
+ /**
29
+ * Sets the body content of the side panel
30
+ */
31
+ children: ReactNode;
32
+ /**
33
+ * Sets an optional className to be added to the side panel outermost element
34
+ */
35
+ className?: string;
36
+ /**
37
+ * Sets the close button icon description
38
+ */
39
+ closeIconDescription?: string;
40
+ /**
41
+ * Determines whether the side panel should render the condensed version (affects action buttons primarily)
42
+ */
43
+ condensedActions?: boolean;
44
+ /**
45
+ * Sets the current step of the side panel
46
+ */
47
+ currentStep?: number;
48
+ /**
49
+ * Unique identifier
50
+ */
51
+ id?: string;
52
+ /**
53
+ * Determines whether the side panel should render with an overlay
54
+ */
55
+ includeOverlay?: boolean;
56
+ /**
57
+ * Sets the label text which will display above the title text
58
+ */
59
+ labelText?: string;
60
+ /**
61
+ * Sets the icon description for the navigation back icon button
62
+ */
63
+ navigationBackIconDescription?: string;
64
+ /**
65
+ * Changes the current side panel page to the previous page
66
+ */
67
+ onNavigationBack?(): void;
68
+ /**
69
+ * Specify a handler for closing the side panel.
70
+ * This handler closes the modal, e.g. changing `open` prop.
71
+ */
72
+ onRequestClose?(): void;
73
+ /**
74
+ * Optional function called when the side panel exit animation is complete.
75
+ * This handler can be used for any state cleanup needed before the panel is removed from the DOM.
76
+ */
77
+ onUnmount?(): void;
78
+ /**
79
+ * Determines whether the side panel should render or not
80
+ */
81
+ open: boolean;
82
+ /**
83
+ * Determines if the side panel is on the right or left
84
+ */
85
+ placement?: 'left' | 'right';
86
+ /**
87
+ * Prevent closing on click outside of the panel
88
+ */
89
+ preventCloseOnClickOutside?: boolean;
90
+ /**
91
+ * This is the selector to the element that contains all of the page content that will shrink if the panel is a slide in.
92
+ * This prop is required when using the `slideIn` variant of the side panel.
93
+ */
94
+ selectorPageContent?: string;
95
+ /**
96
+ * Specify a CSS selector that matches the DOM element that should
97
+ * be focused when the side panel opens
98
+ */
99
+ selectorPrimaryFocus?: string;
100
+ /**
101
+ * Sets the size of the side panel
102
+ */
103
+ size: 'xs' | 'sm' | 'md' | 'lg' | '2xl';
104
+ /**
105
+ * Determines if this panel slides in
106
+ */
107
+ slideIn?: boolean;
108
+ /**
109
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `SidePanel` component
110
+ */
111
+ slug?: ReactNode;
112
+ /**
113
+ * Sets the subtitle text
114
+ */
115
+ subtitle?: ReactNode;
116
+ /**
117
+ * Sets the title text
118
+ */
119
+ title?: string;
120
+ };
121
+ type SidePanelSlideInProps = {
122
+ /**
123
+ * Determines if this panel slides in
124
+ */
125
+ slideIn?: false;
126
+ /**
127
+ * This is the selector to the element that contains all of the page content that will shrink if the panel is a slide in.
128
+ * This prop is required when using the `slideIn` variant of the side panel.
129
+ */
130
+ selectorPageContent?: string;
131
+ } | {
132
+ /**
133
+ * Determines if this panel slides in
134
+ */
135
+ slideIn: true;
136
+ /**
137
+ * This is the selector to the element that contains all of the page content that will shrink if the panel is a slide in.
138
+ * This prop is required when using the `slideIn` variant of the side panel. Required for slideIn panels.
139
+ */
140
+ selectorPageContent: string;
141
+ };
142
+ type SidePanelProps = SidePanelBaseProps & SidePanelSlideInProps;
1
143
  /**
2
144
  * Side panels keep users in-context of a page while performing tasks like navigating, editing, viewing details, or configuring something new.
3
145
  */
4
- export let SidePanel: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
- import React from 'react';
146
+ export declare let SidePanel: React.ForwardRefExoticComponent<SidePanelProps & React.RefAttributes<HTMLDivElement>>;
147
+ export {};