@carbon-labs/react-ui-shell 0.87.0 → 0.89.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 (103) hide show
  1. package/es/components/HeaderContainer.js +2 -2
  2. package/es/components/HeaderDivider.js +2 -2
  3. package/es/components/HeaderOverflowPanel.js +5 -5
  4. package/es/components/HeaderPopover.js +6 -6
  5. package/es/components/Link.js +2 -2
  6. package/es/components/Profile.js +17 -17
  7. package/es/components/SharkFinIcon.js +6 -6
  8. package/es/components/SideNav.js +10 -10
  9. package/es/components/SideNavFlyoutMenu.js +9 -9
  10. package/es/components/SideNavItems.js +5 -5
  11. package/es/components/SideNavLink.js +7 -7
  12. package/es/components/SideNavLinkPopover.js +2 -2
  13. package/es/components/SideNavMenu.js +24 -24
  14. package/es/components/SideNavMenuItem.js +7 -7
  15. package/es/components/SideNavSlot.js +4 -4
  16. package/es/components/SideNavTitle.js +3 -3
  17. package/es/components/SideNavToggle.js +7 -7
  18. package/es/components/TrialCountdown.js +3 -3
  19. package/es/internal/useId.js +2 -2
  20. package/es/internal/useIdPrefix.js +3 -3
  21. package/es/internal/usePrefix.js +3 -3
  22. package/lib/components/HeaderContainer.js +10 -10
  23. package/lib/components/HeaderDivider.js +2 -2
  24. package/lib/components/HeaderOverflowPanel.js +5 -5
  25. package/lib/components/HeaderPopover.js +9 -9
  26. package/lib/components/Link.js +3 -3
  27. package/lib/components/Profile.js +17 -17
  28. package/lib/components/SharkFinIcon.js +6 -6
  29. package/lib/components/SideNav.js +23 -23
  30. package/lib/components/SideNavFlyoutMenu.js +22 -22
  31. package/lib/components/SideNavItems.js +8 -8
  32. package/lib/components/SideNavLink.js +9 -9
  33. package/lib/components/SideNavLinkPopover.js +2 -2
  34. package/lib/components/SideNavMenu.js +42 -42
  35. package/lib/components/SideNavMenuItem.js +8 -8
  36. package/lib/components/SideNavSlot.js +4 -4
  37. package/lib/components/SideNavTitle.js +3 -3
  38. package/lib/components/SideNavToggle.js +9 -9
  39. package/lib/components/TrialCountdown.js +3 -3
  40. package/lib/es/components/HeaderContainer.d.ts +2 -2
  41. package/lib/es/components/HeaderDivider.d.ts +2 -2
  42. package/lib/es/components/HeaderOverflowPanel.d.ts +2 -2
  43. package/lib/es/components/HeaderPopover.d.ts +4 -4
  44. package/lib/es/components/Link.d.ts +3 -3
  45. package/lib/es/components/Profile.d.ts +7 -7
  46. package/lib/es/components/SharkFinIcon.d.ts +2 -2
  47. package/lib/es/components/SideNav.d.ts +4 -4
  48. package/lib/es/components/SideNavFlyoutMenu.d.ts +2 -2
  49. package/lib/es/components/SideNavItems.d.ts +2 -2
  50. package/lib/es/components/SideNavLink.d.ts +2 -2
  51. package/lib/es/components/SideNavLinkPopover.d.ts +2 -2
  52. package/lib/es/components/SideNavMenu.d.ts +2 -2
  53. package/lib/es/components/SideNavMenuItem.d.ts +2 -2
  54. package/lib/es/components/SideNavSlot.d.ts +2 -2
  55. package/lib/es/components/SideNavTitle.d.ts +3 -3
  56. package/lib/es/components/SideNavToggle.d.ts +2 -2
  57. package/lib/es/components/TrialCountdown.d.ts +2 -2
  58. package/lib/es/internal/useIdPrefix.d.ts +2 -2
  59. package/lib/es/internal/usePrefix.d.ts +2 -2
  60. package/lib/internal/useDelayedState.js +5 -5
  61. package/lib/internal/useEvent.js +4 -4
  62. package/lib/internal/useId.js +5 -5
  63. package/lib/internal/useIdPrefix.js +3 -3
  64. package/lib/internal/useMatchMedia.js +3 -3
  65. package/lib/internal/useMergedRefs.js +2 -2
  66. package/lib/internal/usePrefix.js +3 -3
  67. package/package.json +3 -3
  68. package/es/node_modules/@carbon/ibm-products/es/_virtual/_commonjsHelpers.js +0 -12
  69. package/es/node_modules/@carbon/ibm-products/es/_virtual/_rollupPluginBabelHelpers.js +0 -18
  70. package/es/node_modules/@carbon/ibm-products/es/_virtual/index.js +0 -14
  71. package/es/node_modules/@carbon/ibm-products/es/_virtual/index2.js +0 -12
  72. package/es/node_modules/@carbon/ibm-products/es/components/TooltipTrigger/TooltipTrigger.js +0 -62
  73. package/es/node_modules/@carbon/ibm-products/es/components/UserAvatar/UserAvatar.js +0 -161
  74. package/es/node_modules/@carbon/ibm-products/es/components/_Canary/Canary.js +0 -49
  75. package/es/node_modules/@carbon/ibm-products/es/global/js/package-settings.js +0 -246
  76. package/es/node_modules/@carbon/ibm-products/es/global/js/utils/devtools.js +0 -16
  77. package/es/node_modules/@carbon/ibm-products/es/global/js/utils/pconsole.js +0 -35
  78. package/es/node_modules/@carbon/ibm-products/es/node_modules/object-assign/index.js +0 -89
  79. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/checkPropTypes.js +0 -95
  80. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/factoryWithThrowingShims.js +0 -64
  81. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/factoryWithTypeCheckers.js +0 -561
  82. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/index.js +0 -32
  83. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/lib/ReactPropTypesSecret.js +0 -18
  84. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/lib/has.js +0 -17
  85. package/es/node_modules/@carbon/ibm-products/es/settings.js +0 -84
  86. package/lib/node_modules/@carbon/ibm-products/es/_virtual/_commonjsHelpers.js +0 -14
  87. package/lib/node_modules/@carbon/ibm-products/es/_virtual/_rollupPluginBabelHelpers.js +0 -20
  88. package/lib/node_modules/@carbon/ibm-products/es/_virtual/index.js +0 -19
  89. package/lib/node_modules/@carbon/ibm-products/es/_virtual/index2.js +0 -14
  90. package/lib/node_modules/@carbon/ibm-products/es/components/TooltipTrigger/TooltipTrigger.js +0 -64
  91. package/lib/node_modules/@carbon/ibm-products/es/components/UserAvatar/UserAvatar.js +0 -163
  92. package/lib/node_modules/@carbon/ibm-products/es/components/_Canary/Canary.js +0 -51
  93. package/lib/node_modules/@carbon/ibm-products/es/global/js/package-settings.js +0 -252
  94. package/lib/node_modules/@carbon/ibm-products/es/global/js/utils/devtools.js +0 -20
  95. package/lib/node_modules/@carbon/ibm-products/es/global/js/utils/pconsole.js +0 -45
  96. package/lib/node_modules/@carbon/ibm-products/es/node_modules/object-assign/index.js +0 -91
  97. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/checkPropTypes.js +0 -97
  98. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/factoryWithThrowingShims.js +0 -66
  99. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/factoryWithTypeCheckers.js +0 -563
  100. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/index.js +0 -34
  101. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/lib/ReactPropTypesSecret.js +0 -20
  102. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/lib/has.js +0 -19
  103. package/lib/node_modules/@carbon/ibm-products/es/settings.js +0 -86
@@ -7,7 +7,7 @@
7
7
 
8
8
  'use strict';
9
9
 
10
- var React__default = require('react');
10
+ var React = require('react');
11
11
 
12
12
  /* eslint-disable jsdoc/require-jsdoc */
13
13
  /**
@@ -17,7 +17,7 @@ var React__default = require('react');
17
17
  * LICENSE file in the root directory of this source tree.
18
18
  */
19
19
 
20
- const PrefixContext = /*#__PURE__*/React__default.createContext('cds');
20
+ const PrefixContext = /*#__PURE__*/React.createContext('cds');
21
21
 
22
22
  /**
23
23
  * An internal function to return the prefix used in components and styles.
@@ -25,7 +25,7 @@ const PrefixContext = /*#__PURE__*/React__default.createContext('cds');
25
25
  * @returns a react context including the prefix
26
26
  */
27
27
  function usePrefix() {
28
- return React__default.useContext(PrefixContext);
28
+ return React.useContext(PrefixContext);
29
29
  }
30
30
 
31
31
  exports.PrefixContext = PrefixContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbon-labs/react-ui-shell",
3
- "version": "0.87.0",
3
+ "version": "0.89.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -36,11 +36,11 @@
36
36
  "telemetry:config": "npx -y @ibm/telemetry-js-config-generator generate --id 5b9dce15-eeda-4b53-8683-3e3aeb599fd1 --endpoint https://www-api.ibm.com/ibm-telemetry/v1/metrics --files ./components/**/*.(tsx|js|jsx)"
37
37
  },
38
38
  "devDependencies": {
39
- "@carbon-labs/utilities": "canary",
39
+ "@carbon-labs/utilities": "0.21.0",
40
40
  "@carbon/ibm-products": "^2.76.0"
41
41
  },
42
42
  "dependencies": {
43
43
  "@ibm/telemetry-js": "^1.10.2"
44
44
  },
45
- "gitHead": "68b4b10b88ccd2c993eae3b172358c840a590808"
45
+ "gitHead": "5ea24fc7a8a62a1d2bc90a52cde2ce1478c29eb2"
46
46
  }
@@ -1,12 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- function getDefaultExportFromCjs(x) {
9
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
10
- }
11
-
12
- export { getDefaultExportFromCjs };
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- function _extends() {
9
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
10
- for (var e = 1; e < arguments.length; e++) {
11
- var t = arguments[e];
12
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
13
- }
14
- return n;
15
- }, _extends.apply(null, arguments);
16
- }
17
-
18
- export { _extends as extends };
@@ -1,14 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import { getDefaultExportFromCjs } from './_commonjsHelpers.js';
9
- import { __require as requirePropTypes } from '../node_modules/prop-types/index.js';
10
-
11
- var propTypesExports = /*@__PURE__*/requirePropTypes();
12
- var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
13
-
14
- export { PropTypes as default, propTypesExports as p };
@@ -1,12 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- var propTypes = {
9
- exports: {}
10
- };
11
-
12
- export { propTypes as __module };
@@ -1,62 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default from 'react';
10
- import PropTypes from '../../_virtual/index.js';
11
- import cx from 'classnames';
12
- import { pkg } from '../../settings.js';
13
-
14
- // The block part of our conventional BEM class names (blockClass__E--M).
15
- const blockClass = `${pkg.prefix}--tooltip-trigger`;
16
- const componentName = 'TooltipTrigger';
17
-
18
- // NOTE: the component SCSS is not imported here: it is rolled up separately.
19
-
20
- /**
21
- * This is an tooltip trigger as Carbon Tooltip requires an active element to work but provides
22
- * no blanked button.
23
- */
24
- const TooltipTrigger = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
25
- let {
26
- children,
27
- className,
28
- // Collect any other property values passed in.
29
- ...rest
30
- } = _ref;
31
- return /*#__PURE__*/React__default.createElement("button", _extends({
32
- type: "button",
33
- ref: ref
34
- }, rest, {
35
- className: cx(blockClass,
36
- // Apply the block class to the main HTML element
37
- className // Apply any supplied class names to the main HTML element.
38
- )
39
- }), children);
40
- });
41
-
42
- // Return a placeholder if not released and not enabled by feature flag.
43
-
44
- // The display name of the component, used by React. Note that displayName
45
- // is used in preference to relying on function.name.
46
- TooltipTrigger.displayName = componentName;
47
-
48
- // The types and DocGen commentary for the component props,
49
- // in alphabetical order (for consistency).
50
- // See https://www.npmjs.com/package/prop-types#usage.
51
- TooltipTrigger.propTypes = {
52
- /**
53
- * Child content of tooltip trigger
54
- */
55
- children: PropTypes.node,
56
- /**
57
- * Provide an optional class to be applied to the containing node.
58
- */
59
- className: PropTypes.string
60
- };
61
-
62
- export { TooltipTrigger };
@@ -1,161 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default from 'react';
10
- import PropTypes from '../../_virtual/index.js';
11
- import cx from 'classnames';
12
- import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
13
- import { pkg } from '../../settings.js';
14
- import { usePrefix, Tooltip } from '@carbon/react';
15
- import { User } from '@carbon/react/icons';
16
- import { TooltipTrigger } from '../TooltipTrigger/TooltipTrigger.js';
17
-
18
- // Carbon and package components we use.
19
- /* TODO: @import(s) of carbon components and other package components. */
20
-
21
- // The block part of our conventional BEM class names (blockClass__E--M).
22
- const blockClass = `${pkg.prefix}--user-avatar`;
23
- const componentName = 'UserAvatar';
24
-
25
- // NOTE: the component SCSS is not imported here: it is rolled up separately.
26
-
27
- /**
28
- * TODO: A description of the component.
29
- */
30
-
31
- const UserAvatar = /*#__PURE__*/React__default.forwardRef((props, ref) => {
32
- const {
33
- backgroundColor = 'order-1-cyan',
34
- className,
35
- image,
36
- imageDescription,
37
- name,
38
- /* TODO: add other props for UserAvatar, with default values if needed */
39
- renderIcon: RenderIcon,
40
- size = 'md',
41
- tooltipText,
42
- tooltipAlignment = 'bottom',
43
- ...rest
44
- } = props;
45
- const carbonPrefix = usePrefix();
46
- const iconSize = {
47
- sm: 16,
48
- md: 20,
49
- lg: 24,
50
- xl: 32
51
- };
52
- const formatInitials = () => {
53
- const parts = name?.split(' ') || [];
54
- const firstChar = parts[0].charAt(0).toUpperCase();
55
- const secondChar = parts[0].charAt(1).toUpperCase();
56
- if (parts.length === 1) {
57
- return firstChar + secondChar;
58
- }
59
- const lastChar = parts[parts.length - 1].charAt(0).toUpperCase();
60
- const initials = [firstChar];
61
- if (lastChar) {
62
- initials.push(lastChar);
63
- }
64
- return ''.concat(...initials);
65
- };
66
- const getItem = () => {
67
- const iconProps = {
68
- size: iconSize[size]
69
- };
70
- if (image) {
71
- return /*#__PURE__*/React__default.createElement("img", {
72
- alt: imageDescription,
73
- src: image,
74
- className: `${blockClass}__photo ${blockClass}__photo--${size}`
75
- });
76
- }
77
- if (RenderIcon) {
78
- return /*#__PURE__*/React__default.createElement(RenderIcon, iconProps);
79
- }
80
- if (name) {
81
- return formatInitials();
82
- }
83
- return /*#__PURE__*/React__default.createElement(User, iconProps);
84
- };
85
- const Avatar = () => /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
86
- className: cx(blockClass,
87
- // Apply the block class to the main HTML element
88
- className,
89
- // Apply any supplied class names to the main HTML element.
90
- `${blockClass}--${backgroundColor}`, `${blockClass}--${size}`,
91
- // example: `${blockClass}__template-string-class-${kind}-n-${size}`,
92
- {
93
- // switched classes dependant on props or state
94
- // example: [`${blockClass}__here-if-small`]: size === 'sm',
95
- }),
96
- ref: ref
97
- }, getDevtoolsProps(componentName)), getItem());
98
- if (tooltipText) {
99
- return /*#__PURE__*/React__default.createElement(Tooltip, {
100
- align: tooltipAlignment,
101
- label: tooltipText,
102
- className: `${blockClass}__tooltip ${carbonPrefix}--icon-tooltip`
103
- }, /*#__PURE__*/React__default.createElement(TooltipTrigger, null, /*#__PURE__*/React__default.createElement(Avatar, null)));
104
- }
105
- return /*#__PURE__*/React__default.createElement(Avatar, null);
106
- });
107
-
108
- // Return a placeholder if not released and not enabled by feature flag
109
-
110
- // The display name of the component, used by React. Note that displayName
111
- // is used in preference to relying on function.name.
112
- UserAvatar.displayName = componentName;
113
-
114
- // The types and DocGen commentary for the component props,
115
- // in alphabetical order (for consistency).
116
- // See https://www.npmjs.com/package/prop-types#usage.
117
- UserAvatar.propTypes = {
118
- /**
119
- * Provide the background color need to be set for UserAvatar. Background color will be set based on lighter or darker theme.
120
- * For example: if you select order-5-purple, it will take $purple-60 for lighter theme and $purple-50 for darker theme.
121
- */
122
- backgroundColor: PropTypes.oneOf(['order-1-cyan', 'order-2-gray', 'order-3-green', 'order-4-magenta', 'order-5-purple', 'order-6-teal', 'order-7-cyan', 'order-8-gray', 'order-9-green', 'order-10-magenta', 'order-11-purple', 'order-12-teal']),
123
- /**
124
- * Provide an optional class to be applied to the containing node.
125
- */
126
- className: PropTypes.string,
127
- /**
128
- * When passing the image prop, supply a full path to the image to be displayed.
129
- */
130
- /**@ts-ignore */
131
- image: PropTypes.string,
132
- /**
133
- * When passing the image prop use the imageDescription prop to describe the image for screen reader.
134
- */
135
- /**@ts-ignore */
136
- imageDescription: PropTypes.string,
137
- /**
138
- * When passing the name prop, either send the initials to be used or the user's full name. The first two capital letters of the user's name will be used as the name.
139
- */
140
- name: PropTypes.string,
141
- /**
142
- * Provide a custom icon to use if you need to use an icon other than the default one
143
- */
144
- /**@ts-ignore */
145
- renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.string]),
146
- /**
147
- * Set the size of the avatar circle
148
- */
149
- size: PropTypes.oneOf(['xl', 'lg', 'md', 'sm']),
150
- /**
151
- * Specify how the trigger should align with the tooltip
152
- */
153
- tooltipAlignment: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
154
- /**
155
- * Pass in the display name to have it shown on hover
156
- */
157
- tooltipText: PropTypes.string
158
- /* TODO: add types and DocGen for all props. */
159
- };
160
-
161
- export { UserAvatar };
@@ -1,49 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default from 'react';
10
- import PropTypes from '../../_virtual/index.js';
11
- import cx from 'classnames';
12
- import pkg from '../../global/js/package-settings.js';
13
- import { CodeSnippet } from '@carbon/react';
14
-
15
- var _p, _br, _p2, _br2, _p3;
16
-
17
- // The block part of our conventional BEM class names (blockClass__E--M).
18
- const blockClass = `${pkg.prefix}--canary`;
19
-
20
- /**
21
- * Canary component used when the component requested is not yet production
22
- */
23
- const Canary = (_ref /*, originalArgs*/) => {
24
- let {
25
- className,
26
- componentName,
27
- ...rest
28
- } = _ref;
29
- const instructions = `
30
- import { pkg } from '@carbon/ibm-products';
31
- // NOTE: must happen before component is first used
32
- pkg.component.${componentName} = true;
33
- `;
34
- return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
35
- className: cx(blockClass, className)
36
- }), /*#__PURE__*/React__default.createElement("h2", null, "This component ", /*#__PURE__*/React__default.createElement("strong", null, componentName), " is not ready yet."), _p || (_p = /*#__PURE__*/React__default.createElement("p", null, "To enable it, initialize package flags before the component is first used.")), _br || (_br = /*#__PURE__*/React__default.createElement("br", null)), _p2 || (_p2 = /*#__PURE__*/React__default.createElement("p", null, "e.g. in main.js")), /*#__PURE__*/React__default.createElement(CodeSnippet, {
37
- type: "multi"
38
- }, instructions), _br2 || (_br2 = /*#__PURE__*/React__default.createElement("br", null)), _p3 || (_p3 = /*#__PURE__*/React__default.createElement("p", null, "View a live example on", ' ', /*#__PURE__*/React__default.createElement("a", {
39
- href: "https://codesandbox.io/s/example-component-olif5?file=/src/config.js"
40
- }, "codesandbox"), ".")));
41
- };
42
- Canary.propTypes = {
43
- /** Provide an optional class to be applied to the containing node */
44
- className: PropTypes.string,
45
- /** Name of the component that is not ready yet */
46
- componentName: PropTypes.string.isRequired
47
- };
48
-
49
- export { Canary };
@@ -1,246 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- // Copyright IBM Corp. 2020, 2025
9
- //
10
- // This source code is licensed under the Apache-2.0 license found in the
11
- // LICENSE file in the root directory of this source tree.
12
- //
13
-
14
- const defaults = {
15
- prefix: 'c4p',
16
- // by default only released components are set to true
17
- component: {
18
- // reviewed and released components:
19
- AboutModal: true,
20
- APIKeyModal: true,
21
- Cascade: true,
22
- Checklist: true,
23
- CreateModal: true,
24
- CreateFullPage: true,
25
- CreateFullPageStep: true,
26
- CreateSidePanel: true,
27
- CreateTearsheetNarrow: true,
28
- CreateTearsheet: true,
29
- CreateTearsheetStep: true,
30
- CreateTearsheetDivider: true,
31
- Datagrid: true,
32
- EditInPlace: true,
33
- EmptyState: true,
34
- ErrorEmptyState: true,
35
- ExportModal: true,
36
- ExpressiveCard: true,
37
- FullPageError: true,
38
- HTTPError403: true,
39
- HTTPError404: true,
40
- HTTPErrorOther: true,
41
- ImportModal: true,
42
- MultiAddSelect: true,
43
- NotificationsPanel: true,
44
- NoDataEmptyState: true,
45
- NoTagsEmptyState: true,
46
- NotFoundEmptyState: true,
47
- NotificationsEmptyState: true,
48
- OptionsTile: true,
49
- PageHeader: true,
50
- ProductiveCard: true,
51
- RemoveModal: true,
52
- Saving: true,
53
- SidePanel: true,
54
- SingleAddSelect: true,
55
- StatusIcon: true,
56
- TagSet: true,
57
- Tearsheet: true,
58
- TearsheetNarrow: true,
59
- UnauthorizedEmptyState: true,
60
- UserProfileImage: true,
61
- WebTerminal: true,
62
- WebTerminalContentWrapper: true,
63
- WebTerminalProvider: true,
64
- UserAvatar: true,
65
- // other public components not yet reviewed and released:
66
- Toolbar: false,
67
- ToolbarButton: false,
68
- ToolbarGroup: false,
69
- EditSidePanel: false,
70
- CancelableTextEdit: false,
71
- DataSpreadsheet: false,
72
- EditTearsheet: false,
73
- EditTearsheetForm: false,
74
- EditTearsheetNarrow: false,
75
- EditFullPage: false,
76
- EditUpdateCards: false,
77
- Nav: false,
78
- NavItem: false,
79
- NavList: false,
80
- BigNumber: false,
81
- TruncatedList: false,
82
- TruncatedText: false,
83
- DelimitedList: false,
84
- ScrollGradient: false,
85
- StringFormatter: false,
86
- StatusIndicator: false,
87
- StatusIndicatorStep: false,
88
- TagOverflow: false,
89
- ActionBar: false,
90
- FilterPanel: false,
91
- FilterPanelAccordion: false,
92
- FilterPanelAccordionItem: false,
93
- FilterPanelCheckbox: false,
94
- FilterPanelCheckboxWithOverflow: false,
95
- FilterPanelGroup: false,
96
- FilterPanelLabel: false,
97
- FilterPanelSearch: false,
98
- ConditionBuilder: false,
99
- GetStartedCard: false,
100
- /* new component flags here - comment used by generate CLI */
101
-
102
- // Onboarding components not yet reviewed and released:
103
- Coachmark: false,
104
- CoachmarkBeacon: false,
105
- CoachmarkButton: false,
106
- CoachmarkFixed: false,
107
- CoachmarkOverlayElement: false,
108
- CoachmarkOverlayElements: false,
109
- CoachmarkStack: false,
110
- Decorator: false,
111
- DecoratorLink: false,
112
- DecoratorSingleButton: false,
113
- DecoratorDualButton: false,
114
- DescriptionList: false,
115
- DescriptionListBody: false,
116
- DescriptionListCell: false,
117
- DescriptionListRow: false,
118
- SearchBar: false,
119
- /* new component flags here - comment used by generate CLI */
120
-
121
- // Onboarding components not yet reviewed and released:
122
- EmptyStateV2: false,
123
- Guidebanner: false,
124
- GuidebannerElement: false,
125
- GuidebannerElementButton: false,
126
- GuidebannerElementLink: false,
127
- InlineTip: false,
128
- InlineTipButton: false,
129
- InlineTipLink: false,
130
- InterstitialScreen: true,
131
- NonLinearReading: false
132
- },
133
- // feature level flags
134
- feature: {
135
- 'default-portal-target-body': true,
136
- 'Datagrid.useInlineEdit': false,
137
- 'Datagrid.useEditableCell': false,
138
- 'Datagrid.useCustomizeColumns': false,
139
- 'ExampleComponent.secondaryIcon': false,
140
- 'ExampleComponent.useExample': false
141
- }
142
- };
143
- const warningMessageComponent = property => `Carbon for IBM Products (WARNING): Component "${property}" enabled via feature flags. This component has not yet completed its review process.`;
144
- const warningMessageFeature = property => `Carbon for IBM Products (WARNING): Feature "${property}" enabled via feature flags.`;
145
- const errorMessageFeature = property => `Carbon for IBM Products (Error): Feature "${property}" not enabled. To enable see the notes on feature flags in the README.`;
146
- const warningMessageAllComponents = 'Carbon for IBM Products (WARNING): All components enabled through use of setAllComponents. This includes components that have not yet completed their review process.';
147
- const warningMessageAllFeatures = 'Carbon for IBM Products (WARNING): All features enabled through use of setAllFeatures';
148
-
149
- // Values to represent overrides for component or feature settings.
150
- // Each value maps the initial value to the value that should be returned.
151
- const all = {
152
- INITIAL: v => v,
153
- ON: () => true,
154
- OFF: () => false
155
- };
156
- let allComponents = all.INITIAL;
157
- let allFeatures = all.INITIAL;
158
- let silent = false;
159
- const component = new Proxy({
160
- ...defaults.component
161
- }, {
162
- set(target, property, value) {
163
- if (target[property] !== true && !silent && value) {
164
- // not already true, not silent, and now true
165
- console.warn(warningMessageComponent(property));
166
- }
167
- target[property] = value;
168
- return true; // value set
169
- },
170
- get(target, property) {
171
- return allComponents(target[property] ?? false);
172
- }
173
- });
174
- const feature = new Proxy({
175
- ...defaults.feature
176
- }, {
177
- set(target, property, value) {
178
- // If we receive a feature flag that doesn't exist in our defaults we should not log
179
- // a warning message and instead just return
180
- if (!Object.getOwnPropertyDescriptor(defaults.feature, property)) {
181
- return true;
182
- }
183
- if (target[property] !== true && !silent && value) {
184
- // not already true, not silent, and now true
185
- console.warn(warningMessageFeature(property));
186
- }
187
- target[property] = value;
188
- return true; // value set
189
- },
190
- get(target, property) {
191
- return allFeatures(target[property] ?? false);
192
- }
193
- });
194
- const devtoolsAttribute = 'data-carbon-devtools-id';
195
- function getDevtoolsId(componentName) {
196
- return `${defaults.prefix}--${componentName}`;
197
- }
198
- var pkg = {
199
- devtoolsAttribute,
200
- getDevtoolsId,
201
- prefix: defaults.prefix,
202
- component: component,
203
- feature: feature,
204
- isComponentEnabled: function (componentOrName) {
205
- let byDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
206
- const componentName = componentOrName?.displayName || componentOrName?.name || componentOrName;
207
- return byDefault ? defaults.component[componentName] : component[componentName];
208
- },
209
- isComponentPublic: function (componentOrName) {
210
- let byDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
211
- const componentName = componentOrName?.displayName || componentOrName?.name || componentOrName;
212
- return Object.prototype.hasOwnProperty.call(byDefault ? defaults.component : component, componentName);
213
- },
214
- isFeatureEnabled: function (featureName) {
215
- let byDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
216
- return byDefault ? defaults.feature[featureName] : feature[featureName];
217
- },
218
- checkReportFeatureEnabled(featureName) {
219
- if (feature[featureName]) {
220
- // NOTE: Warning emitted if feature flag is enabled (see Proxy above)
221
- return true;
222
- } else {
223
- console.error(errorMessageFeature(featureName));
224
- }
225
- },
226
- isFeaturePublic: function (featureName) {
227
- let byDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
228
- return Object.prototype.hasOwnProperty.call(byDefault ? defaults.feature : feature, featureName);
229
- },
230
- setAllComponents: enabled => {
231
- enabled === true && !silent && console.warn(warningMessageAllComponents);
232
- allComponents = enabled === true ? all.ON : enabled === false ? all.OFF : all.INITIAL;
233
- },
234
- setAllFeatures: enabled => {
235
- enabled === true && !silent && console.warn(warningMessageAllFeatures);
236
- allFeatures = enabled === true ? all.ON : enabled === false ? all.OFF : all.INITIAL;
237
- },
238
- _silenceWarnings: value => {
239
- // This will suppress console warnings when components or feature flags
240
- // are enabled, and should only be used when this is not an issue, such
241
- // as in internal test suites and storybook builds.
242
- silent = value;
243
- }
244
- };
245
-
246
- export { pkg as default, devtoolsAttribute, getDevtoolsId };
@@ -1,16 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import { getDevtoolsId, devtoolsAttribute } from '../package-settings.js';
9
-
10
- function getDevtoolsProps(componentName) {
11
- return {
12
- [devtoolsAttribute]: getDevtoolsId(componentName)
13
- };
14
- }
15
-
16
- export { devtoolsAttribute, getDevtoolsId, getDevtoolsProps };
@@ -1,35 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- // Copyright IBM Corp. 2020, 2021
9
- //
10
- // This source code is licensed under the Apache-2.0 license found in the
11
- // LICENSE file in the root directory of this source tree.
12
- //
13
-
14
- const isProduction = process.env.NODE_ENV === 'production';
15
- const noop = () => undefined;
16
- const shimIfProduction = fn => isProduction ? noop : fn;
17
- const log = shimIfProduction(function () {
18
- return console.log(...arguments);
19
- });
20
- const warn = shimIfProduction(function () {
21
- return console.warn(...arguments);
22
- });
23
- const error = shimIfProduction(function () {
24
- return console.error(...arguments);
25
- });
26
- var pconsole = {
27
- isProduction,
28
- noop,
29
- shimIfProduction,
30
- log,
31
- warn,
32
- error
33
- };
34
-
35
- export { pconsole as default, error, isProduction, log, noop, shimIfProduction, warn };