@carbon/upgrade 11.39.0-rc.0 → 11.40.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.js CHANGED
@@ -4910,8 +4910,8 @@ var require_color_convert = /* @__PURE__ */ __commonJSMin(((exports, module) =>
4910
4910
  module.exports = convert;
4911
4911
  }));
4912
4912
  //#endregion
4913
- //#region ../../node_modules/ansi-styles/index.js
4914
- var require_ansi_styles$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4913
+ //#region ../../node_modules/@inquirer/core/node_modules/ansi-styles/index.js
4914
+ var require_ansi_styles$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4915
4915
  const wrapAnsi16 = (fn, offset) => (...args) => {
4916
4916
  return `\u001B[${fn(...args) + offset}m`;
4917
4917
  };
@@ -5049,7 +5049,7 @@ var require_ansi_styles$1 = /* @__PURE__ */ __commonJSMin(((exports, module) =>
5049
5049
  var require_wrap_ansi$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5050
5050
  const stringWidth = require_string_width();
5051
5051
  const stripAnsi = require_strip_ansi();
5052
- const ansiStyles = require_ansi_styles$1();
5052
+ const ansiStyles = require_ansi_styles$3();
5053
5053
  const ESCAPES = new Set(["\x1B", "›"]);
5054
5054
  const END_CODE = 39;
5055
5055
  const wrapAnsi = (code) => `${ESCAPES.values().next().value}[${code}m`;
@@ -40767,6 +40767,141 @@ var require_build$7 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40767
40767
  })();
40768
40768
  }));
40769
40769
  //#endregion
40770
+ //#region ../../node_modules/jest-diff/node_modules/ansi-styles/index.js
40771
+ var require_ansi_styles$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40772
+ const wrapAnsi16 = (fn, offset) => (...args) => {
40773
+ return `\u001B[${fn(...args) + offset}m`;
40774
+ };
40775
+ const wrapAnsi256 = (fn, offset) => (...args) => {
40776
+ const code = fn(...args);
40777
+ return `\u001B[${38 + offset};5;${code}m`;
40778
+ };
40779
+ const wrapAnsi16m = (fn, offset) => (...args) => {
40780
+ const rgb = fn(...args);
40781
+ return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
40782
+ };
40783
+ const ansi2ansi = (n) => n;
40784
+ const rgb2rgb = (r, g, b) => [
40785
+ r,
40786
+ g,
40787
+ b
40788
+ ];
40789
+ const setLazyProperty = (object, property, get) => {
40790
+ Object.defineProperty(object, property, {
40791
+ get: () => {
40792
+ const value = get();
40793
+ Object.defineProperty(object, property, {
40794
+ value,
40795
+ enumerable: true,
40796
+ configurable: true
40797
+ });
40798
+ return value;
40799
+ },
40800
+ enumerable: true,
40801
+ configurable: true
40802
+ });
40803
+ };
40804
+ /** @type {typeof import('color-convert')} */
40805
+ let colorConvert;
40806
+ const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
40807
+ if (colorConvert === void 0) colorConvert = require_color_convert();
40808
+ const offset = isBackground ? 10 : 0;
40809
+ const styles = {};
40810
+ for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
40811
+ const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
40812
+ if (sourceSpace === targetSpace) styles[name] = wrap(identity, offset);
40813
+ else if (typeof suite === "object") styles[name] = wrap(suite[targetSpace], offset);
40814
+ }
40815
+ return styles;
40816
+ };
40817
+ function assembleStyles() {
40818
+ const codes = /* @__PURE__ */ new Map();
40819
+ const styles = {
40820
+ modifier: {
40821
+ reset: [0, 0],
40822
+ bold: [1, 22],
40823
+ dim: [2, 22],
40824
+ italic: [3, 23],
40825
+ underline: [4, 24],
40826
+ inverse: [7, 27],
40827
+ hidden: [8, 28],
40828
+ strikethrough: [9, 29]
40829
+ },
40830
+ color: {
40831
+ black: [30, 39],
40832
+ red: [31, 39],
40833
+ green: [32, 39],
40834
+ yellow: [33, 39],
40835
+ blue: [34, 39],
40836
+ magenta: [35, 39],
40837
+ cyan: [36, 39],
40838
+ white: [37, 39],
40839
+ blackBright: [90, 39],
40840
+ redBright: [91, 39],
40841
+ greenBright: [92, 39],
40842
+ yellowBright: [93, 39],
40843
+ blueBright: [94, 39],
40844
+ magentaBright: [95, 39],
40845
+ cyanBright: [96, 39],
40846
+ whiteBright: [97, 39]
40847
+ },
40848
+ bgColor: {
40849
+ bgBlack: [40, 49],
40850
+ bgRed: [41, 49],
40851
+ bgGreen: [42, 49],
40852
+ bgYellow: [43, 49],
40853
+ bgBlue: [44, 49],
40854
+ bgMagenta: [45, 49],
40855
+ bgCyan: [46, 49],
40856
+ bgWhite: [47, 49],
40857
+ bgBlackBright: [100, 49],
40858
+ bgRedBright: [101, 49],
40859
+ bgGreenBright: [102, 49],
40860
+ bgYellowBright: [103, 49],
40861
+ bgBlueBright: [104, 49],
40862
+ bgMagentaBright: [105, 49],
40863
+ bgCyanBright: [106, 49],
40864
+ bgWhiteBright: [107, 49]
40865
+ }
40866
+ };
40867
+ styles.color.gray = styles.color.blackBright;
40868
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
40869
+ styles.color.grey = styles.color.blackBright;
40870
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
40871
+ for (const [groupName, group] of Object.entries(styles)) {
40872
+ for (const [styleName, style] of Object.entries(group)) {
40873
+ styles[styleName] = {
40874
+ open: `\u001B[${style[0]}m`,
40875
+ close: `\u001B[${style[1]}m`
40876
+ };
40877
+ group[styleName] = styles[styleName];
40878
+ codes.set(style[0], style[1]);
40879
+ }
40880
+ Object.defineProperty(styles, groupName, {
40881
+ value: group,
40882
+ enumerable: false
40883
+ });
40884
+ }
40885
+ Object.defineProperty(styles, "codes", {
40886
+ value: codes,
40887
+ enumerable: false
40888
+ });
40889
+ styles.color.close = "\x1B[39m";
40890
+ styles.bgColor.close = "\x1B[49m";
40891
+ setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
40892
+ setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
40893
+ setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
40894
+ setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
40895
+ setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
40896
+ setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
40897
+ return styles;
40898
+ }
40899
+ Object.defineProperty(module, "exports", {
40900
+ enumerable: true,
40901
+ get: assembleStyles
40902
+ });
40903
+ }));
40904
+ //#endregion
40770
40905
  //#region ../../node_modules/has-flag/index.js
40771
40906
  var require_has_flag = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40772
40907
  module.exports = (flag, argv = process.argv) => {
@@ -40971,7 +41106,7 @@ var require_templates = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40971
41106
  //#endregion
40972
41107
  //#region ../../node_modules/jest-diff/node_modules/chalk/source/index.js
40973
41108
  var require_source = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40974
- const ansiStyles = require_ansi_styles$1();
41109
+ const ansiStyles = require_ansi_styles$2();
40975
41110
  const { stdout: stdoutColor, stderr: stderrColor } = require_supports_color();
40976
41111
  const { stringReplaceAll, stringEncaseCRLFWithFirstIndex } = require_util();
40977
41112
  const { isArray } = Array;
@@ -41354,7 +41489,7 @@ var require_react_is = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41354
41489
  }));
41355
41490
  //#endregion
41356
41491
  //#region ../../node_modules/jest-diff/node_modules/pretty-format/node_modules/ansi-styles/index.js
41357
- var require_ansi_styles = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41492
+ var require_ansi_styles$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41358
41493
  const ANSI_BACKGROUND_OFFSET = 10;
41359
41494
  const wrapAnsi256 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`;
41360
41495
  const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
@@ -41992,7 +42127,7 @@ var require_build$5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41992
42127
  exports$20["default"] = exports$20.DEFAULT_OPTIONS = void 0;
41993
42128
  exports$20.format = format;
41994
42129
  exports$20.plugins = void 0;
41995
- var _ansiStyles = _interopRequireDefault(require_ansi_styles());
42130
+ var _ansiStyles = _interopRequireDefault(require_ansi_styles$1());
41996
42131
  var _collections = __webpack_require__("./src/collections.ts");
41997
42132
  var _AsymmetricMatcher = _interopRequireDefault(__webpack_require__("./src/plugins/AsymmetricMatcher.ts"));
41998
42133
  var _DOMCollection = _interopRequireDefault(__webpack_require__("./src/plugins/DOMCollection.ts"));
@@ -44455,6 +44590,34 @@ const upgrades = [
44455
44590
  });
44456
44591
  }
44457
44592
  },
44593
+ {
44594
+ name: "ibm-products-update-coachmark",
44595
+ description: "Rewrites old Coachmark to new composable Coachmark",
44596
+ migrate: async (options) => {
44597
+ const transform = path.default.join(TRANSFORM_DIR, "ibm-products-update-coachmark.js");
44598
+ const paths = Array.isArray(options.paths) && options.paths.length > 0 ? options.paths : await (0, import_out.default)([
44599
+ "**/*.js",
44600
+ "**/*.jsx",
44601
+ "**/*.ts",
44602
+ "**/*.tsx"
44603
+ ], {
44604
+ cwd: options.workspaceDir,
44605
+ ignore: [
44606
+ "**/es/**",
44607
+ "**/lib/**",
44608
+ "**/umd/**",
44609
+ "**/node_modules/**",
44610
+ "**/storybook-static/**"
44611
+ ]
44612
+ });
44613
+ await runCodemod(options, {
44614
+ dry: !options.write,
44615
+ transform,
44616
+ paths,
44617
+ verbose: options.verbose
44618
+ });
44619
+ }
44620
+ },
44458
44621
  {
44459
44622
  name: "rename-ibm-products-imports-to-preview",
44460
44623
  description: "Update imports after PDLC status integration",
@@ -44630,7 +44793,7 @@ const upgrades = [
44630
44793
  //#endregion
44631
44794
  //#region package.json
44632
44795
  var name = "@carbon/upgrade";
44633
- var version = "11.39.0-rc.0";
44796
+ var version = "11.40.0-rc.0";
44634
44797
  //#endregion
44635
44798
  //#region ../../node_modules/y18n/build/index.cjs
44636
44799
  var require_build$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -45547,11 +45710,146 @@ var require_build$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45547
45710
  module.exports = yargsParser;
45548
45711
  }));
45549
45712
  //#endregion
45550
- //#region ../../node_modules/cliui/node_modules/wrap-ansi/index.js
45713
+ //#region ../../node_modules/wrap-ansi/node_modules/ansi-styles/index.js
45714
+ var require_ansi_styles = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45715
+ const wrapAnsi16 = (fn, offset) => (...args) => {
45716
+ return `\u001B[${fn(...args) + offset}m`;
45717
+ };
45718
+ const wrapAnsi256 = (fn, offset) => (...args) => {
45719
+ const code = fn(...args);
45720
+ return `\u001B[${38 + offset};5;${code}m`;
45721
+ };
45722
+ const wrapAnsi16m = (fn, offset) => (...args) => {
45723
+ const rgb = fn(...args);
45724
+ return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
45725
+ };
45726
+ const ansi2ansi = (n) => n;
45727
+ const rgb2rgb = (r, g, b) => [
45728
+ r,
45729
+ g,
45730
+ b
45731
+ ];
45732
+ const setLazyProperty = (object, property, get) => {
45733
+ Object.defineProperty(object, property, {
45734
+ get: () => {
45735
+ const value = get();
45736
+ Object.defineProperty(object, property, {
45737
+ value,
45738
+ enumerable: true,
45739
+ configurable: true
45740
+ });
45741
+ return value;
45742
+ },
45743
+ enumerable: true,
45744
+ configurable: true
45745
+ });
45746
+ };
45747
+ /** @type {typeof import('color-convert')} */
45748
+ let colorConvert;
45749
+ const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
45750
+ if (colorConvert === void 0) colorConvert = require_color_convert();
45751
+ const offset = isBackground ? 10 : 0;
45752
+ const styles = {};
45753
+ for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
45754
+ const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
45755
+ if (sourceSpace === targetSpace) styles[name] = wrap(identity, offset);
45756
+ else if (typeof suite === "object") styles[name] = wrap(suite[targetSpace], offset);
45757
+ }
45758
+ return styles;
45759
+ };
45760
+ function assembleStyles() {
45761
+ const codes = /* @__PURE__ */ new Map();
45762
+ const styles = {
45763
+ modifier: {
45764
+ reset: [0, 0],
45765
+ bold: [1, 22],
45766
+ dim: [2, 22],
45767
+ italic: [3, 23],
45768
+ underline: [4, 24],
45769
+ inverse: [7, 27],
45770
+ hidden: [8, 28],
45771
+ strikethrough: [9, 29]
45772
+ },
45773
+ color: {
45774
+ black: [30, 39],
45775
+ red: [31, 39],
45776
+ green: [32, 39],
45777
+ yellow: [33, 39],
45778
+ blue: [34, 39],
45779
+ magenta: [35, 39],
45780
+ cyan: [36, 39],
45781
+ white: [37, 39],
45782
+ blackBright: [90, 39],
45783
+ redBright: [91, 39],
45784
+ greenBright: [92, 39],
45785
+ yellowBright: [93, 39],
45786
+ blueBright: [94, 39],
45787
+ magentaBright: [95, 39],
45788
+ cyanBright: [96, 39],
45789
+ whiteBright: [97, 39]
45790
+ },
45791
+ bgColor: {
45792
+ bgBlack: [40, 49],
45793
+ bgRed: [41, 49],
45794
+ bgGreen: [42, 49],
45795
+ bgYellow: [43, 49],
45796
+ bgBlue: [44, 49],
45797
+ bgMagenta: [45, 49],
45798
+ bgCyan: [46, 49],
45799
+ bgWhite: [47, 49],
45800
+ bgBlackBright: [100, 49],
45801
+ bgRedBright: [101, 49],
45802
+ bgGreenBright: [102, 49],
45803
+ bgYellowBright: [103, 49],
45804
+ bgBlueBright: [104, 49],
45805
+ bgMagentaBright: [105, 49],
45806
+ bgCyanBright: [106, 49],
45807
+ bgWhiteBright: [107, 49]
45808
+ }
45809
+ };
45810
+ styles.color.gray = styles.color.blackBright;
45811
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
45812
+ styles.color.grey = styles.color.blackBright;
45813
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
45814
+ for (const [groupName, group] of Object.entries(styles)) {
45815
+ for (const [styleName, style] of Object.entries(group)) {
45816
+ styles[styleName] = {
45817
+ open: `\u001B[${style[0]}m`,
45818
+ close: `\u001B[${style[1]}m`
45819
+ };
45820
+ group[styleName] = styles[styleName];
45821
+ codes.set(style[0], style[1]);
45822
+ }
45823
+ Object.defineProperty(styles, groupName, {
45824
+ value: group,
45825
+ enumerable: false
45826
+ });
45827
+ }
45828
+ Object.defineProperty(styles, "codes", {
45829
+ value: codes,
45830
+ enumerable: false
45831
+ });
45832
+ styles.color.close = "\x1B[39m";
45833
+ styles.bgColor.close = "\x1B[49m";
45834
+ setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
45835
+ setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
45836
+ setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
45837
+ setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
45838
+ setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
45839
+ setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
45840
+ return styles;
45841
+ }
45842
+ Object.defineProperty(module, "exports", {
45843
+ enumerable: true,
45844
+ get: assembleStyles
45845
+ });
45846
+ }));
45847
+ //#endregion
45848
+ //#region ../../node_modules/wrap-ansi/index.js
45551
45849
  var require_wrap_ansi = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45552
45850
  const stringWidth = require_string_width();
45553
45851
  const stripAnsi = require_strip_ansi();
45554
- const ansiStyles = require_ansi_styles$1();
45852
+ const ansiStyles = require_ansi_styles();
45555
45853
  const ESCAPES = new Set(["\x1B", "›"]);
45556
45854
  const END_CODE = 39;
45557
45855
  const ANSI_ESCAPE_BELL = "\x07";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/upgrade",
3
3
  "description": "A tool for upgrading Carbon versions",
4
- "version": "11.39.0-rc.0",
4
+ "version": "11.40.0-rc.0",
5
5
  "license": "Apache-2.0",
6
6
  "bin": {
7
7
  "carbon-upgrade": "./bin/carbon-upgrade.js"
@@ -60,5 +60,5 @@
60
60
  "@ibm/telemetry-js": "^1.5.0",
61
61
  "jscodeshift": "^17.0.0"
62
62
  },
63
- "gitHead": "3d219dfcc2a3da515016f7ce0e769d013c3a6c03"
63
+ "gitHead": "b23ca747c33b76557a54aa88b6df70bc76f55da9"
64
64
  }
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import {
3
+ Coachmark,
4
+ CoachmarkBeacon,
5
+ CoachmarkButton,
6
+ CoachmarkOverlayElements,
7
+ CoachmarkOverlayElement,
8
+ BEACON_KIND,
9
+ COACHMARK_OVERLAY_KIND,
10
+ } from '@carbon/ibm-products';
11
+ import { Crossroads } from '@carbon/react/icons';
12
+
13
+ // Example 1: Basic Coachmark with Beacon and dark theme
14
+ export const Example1 = () => (
15
+ <Coachmark
16
+ align="bottom"
17
+ closeIconDescription="Close"
18
+ positionTune={{ x: 0, y: 0 }}
19
+ target={
20
+ <CoachmarkBeacon label="Show information" kind={BEACON_KIND.DEFAULT} />
21
+ }
22
+ theme="light">
23
+ <CoachmarkOverlayElements closeButtonLabel="Done">
24
+ <CoachmarkOverlayElement
25
+ title="Hello World"
26
+ description="this is a description test"
27
+ />
28
+ </CoachmarkOverlayElements>
29
+ </Coachmark>
30
+ );
31
+
32
+ // Example 2: Coachmark with Button target and light theme
33
+ export const Example2 = () => (
34
+ <Coachmark
35
+ align="top"
36
+ closeIconDescription="Close"
37
+ positionTune={{ x: 10, y: 20 }}
38
+ target={
39
+ <CoachmarkButton
40
+ kind="tertiary"
41
+ size="md"
42
+ label="Show information"
43
+ renderIcon={Crossroads}>
44
+ Click Me
45
+ </CoachmarkButton>
46
+ }
47
+ theme="light">
48
+ <CoachmarkOverlayElements closeButtonLabel="Got it">
49
+ <CoachmarkOverlayElement
50
+ title="Welcome"
51
+ description="This is your dashboard"
52
+ />
53
+ </CoachmarkOverlayElements>
54
+ </Coachmark>
55
+ );
56
+
57
+ // Example 3: Floating Coachmark
58
+ export const Example3 = () => (
59
+ <Coachmark
60
+ align="bottom-left"
61
+ closeIconDescription="Dismiss"
62
+ positionTune={{ x: 5, y: 5 }}
63
+ overlayKind={COACHMARK_OVERLAY_KIND.FLOATING}
64
+ target={<CoachmarkBeacon label="Learn more" kind={BEACON_KIND.DEFAULT} />}
65
+ theme="dark">
66
+ <CoachmarkOverlayElements closeButtonLabel="Close">
67
+ <CoachmarkOverlayElement
68
+ title="New Feature"
69
+ description="Check out this new feature"
70
+ />
71
+ </CoachmarkOverlayElements>
72
+ </Coachmark>
73
+ );
@@ -0,0 +1,66 @@
1
+ import { Theme, Button } from "@carbon/react";
2
+ import React, { useState } from 'react';
3
+ import {
4
+ preview__Coachmark as Coachmark,
5
+ preview__CoachmarkBeacon as CoachmarkBeacon,
6
+ } from '@carbon/ibm-products';
7
+ import { Crossroads } from '@carbon/react/icons';
8
+
9
+ // Example 1: Basic Coachmark with Beacon and dark theme
10
+ export const Example1 = () => {
11
+ const [isOpen, setIsOpen] = useState(true);
12
+
13
+ const handleBeaconClick = () => {
14
+ setIsOpen(isOpen => !isOpen);
15
+ };
16
+
17
+ return (
18
+ <Theme theme="white"><Coachmark align="bottom" position={{ x: 0, y: 0 }} open={isOpen}><CoachmarkBeacon
19
+ label="Show information"
20
+ buttonProps={{
21
+ onClick: handleBeaconClick,
22
+ id: "CoachmarkBtn"
23
+ }} /><Coachmark.Content><Coachmark.Content.Header closeIconDescription="Close" /><Coachmark.Content.Body><h2>Hello World</h2><p>this is a description test</p><Button size="sm">Done</Button></Coachmark.Content.Body></Coachmark.Content></Coachmark></Theme>
24
+ );
25
+ };
26
+
27
+ // Example 2: Coachmark with Button target and light theme
28
+ export const Example2 = () => {
29
+ const [isOpen, setIsOpen] = useState(true);
30
+
31
+ const handleButtonClick = () => {
32
+ setIsOpen(isOpen => !isOpen);
33
+ };
34
+
35
+ return (
36
+ <Theme theme="white"><Coachmark align="top" position={{ x: 10, y: 20 }} open={isOpen}><Button
37
+ id="CoachmarkTriggerRefBtn"
38
+ onClick={handleButtonClick}
39
+ kind="tertiary"
40
+ size="md"
41
+ renderIcon={Crossroads}>Click Me
42
+ </Button><Coachmark.Content><Coachmark.Content.Header closeIconDescription="Close" /><Coachmark.Content.Body><h2>Welcome</h2><p>This is your dashboard</p><Button size="sm">Got it</Button></Coachmark.Content.Body></Coachmark.Content></Coachmark></Theme>
43
+ );
44
+ };
45
+
46
+ // Example 3: Floating Coachmark
47
+ export const Example3 = () => {
48
+ const [isOpen, setIsOpen] = useState(true);
49
+
50
+ const handleBeaconClick = () => {
51
+ setIsOpen(isOpen => !isOpen);
52
+ };
53
+
54
+ return (
55
+ <Theme theme="g90"><Coachmark
56
+ align="bottom-left"
57
+ position={{ x: 5, y: 5 }}
58
+ open={isOpen}
59
+ floating={true}><CoachmarkBeacon
60
+ label="Learn more"
61
+ buttonProps={{
62
+ onClick: handleBeaconClick,
63
+ id: "CoachmarkBtn"
64
+ }} /><Coachmark.Content><Coachmark.Content.Header closeIconDescription="Dismiss" /><Coachmark.Content.Body><h2>New Feature</h2><p>Check out this new feature</p><Button size="sm">Close</Button></Coachmark.Content.Body></Coachmark.Content></Coachmark></Theme>
65
+ );
66
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
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
+ 'use strict';
9
+
10
+ const { defineTest } = require('jscodeshift/dist/testUtils');
11
+
12
+ defineTest(__dirname, 'ibm-products-update-coachmark');
@@ -0,0 +1,504 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
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
+ /**
9
+ * Rewrites old Coachmark to new composable Coachmark
10
+ *
11
+ * Transforms:
12
+ *
13
+ * <Coachmark align='bottom' closeIconDescription='Close' positionTune={{ x: 0, y: 0 }}
14
+ * target={<CoachmarkBeacon label="Show information" kind={BEACON_KIND.DEFAULT} />} theme='dark'>
15
+ * <CoachmarkOverlayElements closeButtonLabel="Done">
16
+ * <CoachmarkOverlayElement title="Hello World" description="this is a description test" />
17
+ * </CoachmarkOverlayElements>
18
+ * </Coachmark>
19
+ *
20
+ * Into:
21
+ *
22
+ * <Theme theme={g90}>
23
+ * <Coachmark align='bottom' position={{ x: 0, y: 0 }}>
24
+ * <CoachmarkBeacon label="Show information" buttonProps={{ onClick: handleBeaconClick, id: 'CoachmarkBtn', ref: beaconButtonRef }} />
25
+ * <Coachmark.Content>
26
+ * <Coachmark.Content.Header closeIconDescription="Close" />
27
+ * <Coachmark.Content.Body>
28
+ * <h2>Hello World</h2>
29
+ * <p>this is a description test</p>
30
+ * <Button size="sm">Done</Button>
31
+ * </Coachmark.Content.Body>
32
+ * </Coachmark.Content>
33
+ * </Coachmark>
34
+ * </Theme>
35
+ */
36
+
37
+ 'use strict';
38
+
39
+ const transform = (fileInfo, api) => {
40
+ const j = api.jscodeshift;
41
+ const root = j(fileInfo.source);
42
+ let shouldImportTheme = false;
43
+ let shouldImportButton = false;
44
+ let shouldImportUseState = false;
45
+
46
+ // Helper to add imports to existing or create new import declarations
47
+ const ensureImport = (source, identifierName) => {
48
+ const existingImport = root
49
+ .find(j.ImportDeclaration, { source: { value: source } })
50
+ .filter((path) =>
51
+ path.node.specifiers.some((s) => s.imported?.name === identifierName)
52
+ );
53
+
54
+ if (existingImport.size() === 0) {
55
+ const reactImport = root.find(j.ImportDeclaration, {
56
+ source: { value: source },
57
+ });
58
+ if (reactImport.size() > 0) {
59
+ reactImport.forEach((path) =>
60
+ path.node.specifiers.push(
61
+ j.importSpecifier(j.identifier(identifierName))
62
+ )
63
+ );
64
+ } else {
65
+ root
66
+ .find(j.Program)
67
+ .get('body', 0)
68
+ .insertBefore(
69
+ j.importDeclaration(
70
+ [j.importSpecifier(j.identifier(identifierName))],
71
+ j.literal(source)
72
+ )
73
+ );
74
+ }
75
+ }
76
+ };
77
+
78
+ const createJSXElement = (name, attributes, children) => {
79
+ const openingElement = j.jsxOpeningElement(
80
+ j.jsxIdentifier(name),
81
+ attributes,
82
+ children.length === 0
83
+ );
84
+ return children.length === 0
85
+ ? j.jsxElement(openingElement, null, [])
86
+ : j.jsxElement(
87
+ openingElement,
88
+ j.jsxClosingElement(j.jsxIdentifier(name)),
89
+ children
90
+ );
91
+ };
92
+
93
+ const createMemberJSXElement = (object, property, attributes, children) => {
94
+ const memberExpression = j.jsxMemberExpression(
95
+ j.jsxIdentifier(object),
96
+ j.jsxIdentifier(property)
97
+ );
98
+ const openingElement = j.jsxOpeningElement(
99
+ memberExpression,
100
+ attributes,
101
+ children.length === 0
102
+ );
103
+ return children.length === 0
104
+ ? j.jsxElement(openingElement, null, [])
105
+ : j.jsxElement(
106
+ openingElement,
107
+ j.jsxClosingElement(memberExpression),
108
+ children
109
+ );
110
+ };
111
+
112
+ const createNestedMemberJSXElement = (
113
+ obj1,
114
+ obj2,
115
+ property,
116
+ attributes,
117
+ children
118
+ ) => {
119
+ const outerMember = j.jsxMemberExpression(
120
+ j.jsxMemberExpression(j.jsxIdentifier(obj1), j.jsxIdentifier(obj2)),
121
+ j.jsxIdentifier(property)
122
+ );
123
+ const openingElement = j.jsxOpeningElement(
124
+ outerMember,
125
+ attributes,
126
+ children.length === 0
127
+ );
128
+ return children.length === 0
129
+ ? j.jsxElement(openingElement, null, [])
130
+ : j.jsxElement(
131
+ openingElement,
132
+ j.jsxClosingElement(outerMember),
133
+ children
134
+ );
135
+ };
136
+
137
+ // Transform target elements (CoachmarkBeacon or CoachmarkButton)
138
+ const processTargetElement = (targetValue) => {
139
+ if (
140
+ targetValue.type !== 'JSXExpressionContainer' ||
141
+ targetValue.expression.type !== 'JSXElement'
142
+ )
143
+ return null;
144
+
145
+ const expression = targetValue.expression;
146
+ const elementName = expression.openingElement.name.name;
147
+
148
+ // Transform CoachmarkBeacon with buttonProps
149
+ if (elementName === 'CoachmarkBeacon') {
150
+ shouldImportUseState = true;
151
+ const label = expression.openingElement.attributes.find(
152
+ (a) => a.name?.name === 'label'
153
+ )?.value;
154
+ const newAttributes = [
155
+ j.jsxAttribute(
156
+ j.jsxIdentifier('buttonProps'),
157
+ j.jsxExpressionContainer(
158
+ j.objectExpression([
159
+ j.property(
160
+ 'init',
161
+ j.identifier('onClick'),
162
+ j.identifier('handleBeaconClick')
163
+ ),
164
+ j.property('init', j.identifier('id'), j.literal('CoachmarkBtn')),
165
+ ])
166
+ )
167
+ ),
168
+ ];
169
+ if (label)
170
+ newAttributes.unshift(j.jsxAttribute(j.jsxIdentifier('label'), label));
171
+ return createJSXElement('CoachmarkBeacon', newAttributes, []);
172
+ }
173
+
174
+ // Transform CoachmarkButton to regular Button
175
+ if (elementName === 'CoachmarkButton') {
176
+ shouldImportButton = true;
177
+ shouldImportUseState = true;
178
+ const attrs = expression.openingElement.attributes;
179
+ const buttonAttributes = [
180
+ j.jsxAttribute(
181
+ j.jsxIdentifier('id'),
182
+ j.literal('CoachmarkTriggerRefBtn')
183
+ ),
184
+ j.jsxAttribute(
185
+ j.jsxIdentifier('onClick'),
186
+ j.jsxExpressionContainer(j.identifier('handleButtonClick'))
187
+ ),
188
+ ];
189
+ ['kind', 'size', 'renderIcon'].forEach((name) => {
190
+ const attr = attrs.find((a) => a.name?.name === name);
191
+ if (attr)
192
+ buttonAttributes.push(
193
+ j.jsxAttribute(j.jsxIdentifier(name), attr.value)
194
+ );
195
+ });
196
+ return createJSXElement(
197
+ 'Button',
198
+ buttonAttributes,
199
+ expression.children || []
200
+ );
201
+ }
202
+ return null;
203
+ };
204
+
205
+ // Transform Coachmark components
206
+ root
207
+ .find(j.JSXElement, { openingElement: { name: { name: 'Coachmark' } } })
208
+ .forEach((path) => {
209
+ const attributes = path.node.openingElement.attributes;
210
+ const newAttributes = [];
211
+ let themeValue = null,
212
+ closeIconDescription = null,
213
+ targetElement = null,
214
+ overlayKind = null;
215
+ let closeButtonLabel = null,
216
+ overlayElements = [];
217
+
218
+ // Process and transform attributes
219
+ attributes.forEach((attr) => {
220
+ if (attr.type !== 'JSXAttribute') {
221
+ newAttributes.push(attr);
222
+ return;
223
+ }
224
+ const attrName = attr.name.name;
225
+
226
+ if (attrName === 'theme') {
227
+ if (attr.value.type === 'Literal') {
228
+ themeValue =
229
+ attr.value.value === 'dark'
230
+ ? 'g90'
231
+ : attr.value.value === 'light'
232
+ ? 'white'
233
+ : null;
234
+ }
235
+ shouldImportTheme = true;
236
+ } else if (attrName === 'positionTune') {
237
+ attr.name.name = 'position';
238
+ newAttributes.push(attr);
239
+ } else if (attrName === 'closeIconDescription') {
240
+ closeIconDescription = attr.value;
241
+ } else if (attrName === 'target') {
242
+ targetElement = attr.value;
243
+ } else if (attrName === 'overlayKind') {
244
+ overlayKind = attr.value;
245
+ } else {
246
+ newAttributes.push(attr);
247
+ }
248
+ });
249
+
250
+ newAttributes.push(
251
+ j.jsxAttribute(
252
+ j.jsxIdentifier('open'),
253
+ j.jsxExpressionContainer(j.identifier('isOpen'))
254
+ )
255
+ );
256
+ if (overlayKind) {
257
+ newAttributes.push(
258
+ j.jsxAttribute(
259
+ j.jsxIdentifier('floating'),
260
+ j.jsxExpressionContainer(j.literal(true))
261
+ )
262
+ );
263
+ }
264
+
265
+ const newChildren = [];
266
+ if (targetElement) {
267
+ const targetChild = processTargetElement(targetElement);
268
+ if (targetChild) newChildren.push(targetChild);
269
+ }
270
+
271
+ if (path.node.children) {
272
+ path.node.children.forEach((child) => {
273
+ if (
274
+ child.type === 'JSXElement' &&
275
+ child.openingElement.name.name === 'CoachmarkOverlayElements'
276
+ ) {
277
+ child.openingElement.attributes.forEach((attr) => {
278
+ if (attr.name?.name === 'closeButtonLabel')
279
+ closeButtonLabel = attr.value;
280
+ });
281
+ child.children.forEach((overlayChild) => {
282
+ if (
283
+ overlayChild.type === 'JSXElement' &&
284
+ overlayChild.openingElement.name.name ===
285
+ 'CoachmarkOverlayElement'
286
+ ) {
287
+ overlayElements.push(overlayChild);
288
+ }
289
+ });
290
+ }
291
+ });
292
+ }
293
+
294
+ // Build content body from overlay elements
295
+ const contentBodyChildren = [];
296
+ overlayElements.forEach((element) => {
297
+ const attrs = element.openingElement.attributes;
298
+ const title = attrs.find((a) => a.name?.name === 'title')?.value;
299
+ const description = attrs.find(
300
+ (a) => a.name?.name === 'description'
301
+ )?.value;
302
+
303
+ if (title) {
304
+ const titleValue = title.type === 'Literal' ? title.value : title;
305
+ contentBodyChildren.push(
306
+ j.jsxElement(
307
+ j.jsxOpeningElement(j.jsxIdentifier('h2'), []),
308
+ j.jsxClosingElement(j.jsxIdentifier('h2')),
309
+ [j.jsxText(typeof titleValue === 'string' ? titleValue : '')]
310
+ )
311
+ );
312
+ }
313
+ if (description) {
314
+ const descValue =
315
+ description.type === 'Literal' ? description.value : description;
316
+ contentBodyChildren.push(
317
+ j.jsxElement(
318
+ j.jsxOpeningElement(j.jsxIdentifier('p'), []),
319
+ j.jsxClosingElement(j.jsxIdentifier('p')),
320
+ [j.jsxText(typeof descValue === 'string' ? descValue : '')]
321
+ )
322
+ );
323
+ }
324
+ });
325
+
326
+ if (closeButtonLabel) {
327
+ shouldImportButton = true;
328
+ const buttonLabel =
329
+ closeButtonLabel.type === 'Literal' ? closeButtonLabel.value : 'Done';
330
+ contentBodyChildren.push(
331
+ j.jsxElement(
332
+ j.jsxOpeningElement(j.jsxIdentifier('Button'), [
333
+ j.jsxAttribute(j.jsxIdentifier('size'), j.literal('sm')),
334
+ ]),
335
+ j.jsxClosingElement(j.jsxIdentifier('Button')),
336
+ [j.jsxText(buttonLabel)]
337
+ )
338
+ );
339
+ }
340
+
341
+ const contentBody = createNestedMemberJSXElement(
342
+ 'Coachmark',
343
+ 'Content',
344
+ 'Body',
345
+ [],
346
+ contentBodyChildren
347
+ );
348
+ const headerAttributes = closeIconDescription
349
+ ? [
350
+ j.jsxAttribute(
351
+ j.jsxIdentifier('closeIconDescription'),
352
+ closeIconDescription
353
+ ),
354
+ ]
355
+ : [];
356
+ const contentHeader = createNestedMemberJSXElement(
357
+ 'Coachmark',
358
+ 'Content',
359
+ 'Header',
360
+ headerAttributes,
361
+ []
362
+ );
363
+ const content = createMemberJSXElement(
364
+ 'Coachmark',
365
+ 'Content',
366
+ [],
367
+ [contentHeader, contentBody]
368
+ );
369
+
370
+ newChildren.push(content);
371
+ path.node.openingElement.attributes = newAttributes;
372
+ path.node.children = newChildren;
373
+
374
+ if (themeValue) {
375
+ const themeElement = j.jsxElement(
376
+ j.jsxOpeningElement(j.jsxIdentifier('Theme'), [
377
+ j.jsxAttribute(j.jsxIdentifier('theme'), j.literal(themeValue)),
378
+ ]),
379
+ j.jsxClosingElement(j.jsxIdentifier('Theme')),
380
+ [
381
+ j.jsxElement(
382
+ path.node.openingElement,
383
+ path.node.closingElement,
384
+ path.node.children
385
+ ),
386
+ ]
387
+ );
388
+ j(path).replaceWith(themeElement);
389
+ }
390
+ });
391
+
392
+ // Update @carbon/ibm-products imports to preview versions
393
+ root
394
+ .find(j.ImportDeclaration)
395
+ .filter((path) => path.node.source.value === '@carbon/ibm-products')
396
+ .forEach((path) => {
397
+ const removedImports = [
398
+ 'CoachmarkOverlayElements',
399
+ 'CoachmarkOverlayElement',
400
+ 'CoachmarkButton',
401
+ 'BEACON_KIND',
402
+ 'COACHMARK_OVERLAY_KIND',
403
+ ];
404
+ const newSpecifiers = [];
405
+
406
+ path.node.specifiers.forEach((specifier) => {
407
+ if (!specifier.imported) {
408
+ newSpecifiers.push(specifier);
409
+ return;
410
+ }
411
+
412
+ const importedName = specifier.imported.name;
413
+ if (removedImports.includes(importedName)) return;
414
+
415
+ if (importedName === 'Coachmark') {
416
+ newSpecifiers.push(
417
+ j.importSpecifier(
418
+ j.identifier('preview__Coachmark'),
419
+ j.identifier('Coachmark')
420
+ )
421
+ );
422
+ } else if (importedName === 'CoachmarkBeacon') {
423
+ newSpecifiers.push(
424
+ j.importSpecifier(
425
+ j.identifier('preview__CoachmarkBeacon'),
426
+ j.identifier('CoachmarkBeacon')
427
+ )
428
+ );
429
+ } else {
430
+ newSpecifiers.push(specifier);
431
+ }
432
+ });
433
+
434
+ path.node.specifiers = newSpecifiers;
435
+ });
436
+
437
+ // Add required imports
438
+ if (shouldImportTheme) ensureImport('@carbon/react', 'Theme');
439
+ if (shouldImportButton) ensureImport('@carbon/react', 'Button');
440
+ if (shouldImportUseState) ensureImport('react', 'useState');
441
+
442
+ // Inject state management into component functions
443
+ root.find(j.VariableDeclarator).forEach((path) => {
444
+ const init = path.node.init;
445
+ if (
446
+ !init ||
447
+ init.type !== 'ArrowFunctionExpression' ||
448
+ init.body.type !== 'JSXElement'
449
+ )
450
+ return;
451
+
452
+ const jsx = init.body;
453
+ const containsTheme = jsx.openingElement?.name?.name === 'Theme';
454
+ const containsCoachmark = jsx.openingElement?.name?.name === 'Coachmark';
455
+ if (!containsTheme && !containsCoachmark) return;
456
+
457
+ const jsxSource = j(jsx).toSource();
458
+ const usesBeaconHandler = jsxSource.includes('handleBeaconClick');
459
+ const usesButtonHandler = jsxSource.includes('handleButtonClick');
460
+ if (!usesBeaconHandler && !usesButtonHandler) return;
461
+
462
+ shouldImportUseState = true;
463
+ const bodyStatements = [
464
+ j.variableDeclaration('const', [
465
+ j.variableDeclarator(
466
+ j.arrayPattern([j.identifier('isOpen'), j.identifier('setIsOpen')]),
467
+ j.callExpression(j.identifier('useState'), [j.literal(true)])
468
+ ),
469
+ ]),
470
+ ];
471
+
472
+ const createHandler = (name) =>
473
+ j.variableDeclaration('const', [
474
+ j.variableDeclarator(
475
+ j.identifier(name),
476
+ j.arrowFunctionExpression(
477
+ [],
478
+ j.blockStatement([
479
+ j.expressionStatement(
480
+ j.callExpression(j.identifier('setIsOpen'), [
481
+ j.arrowFunctionExpression(
482
+ [j.identifier('isOpen')],
483
+ j.unaryExpression('!', j.identifier('isOpen'))
484
+ ),
485
+ ])
486
+ ),
487
+ ])
488
+ )
489
+ ),
490
+ ]);
491
+
492
+ if (usesBeaconHandler)
493
+ bodyStatements.push(createHandler('handleBeaconClick'));
494
+ if (usesButtonHandler)
495
+ bodyStatements.push(createHandler('handleButtonClick'));
496
+ bodyStatements.push(j.returnStatement(jsx));
497
+
498
+ init.body = j.blockStatement(bodyStatements);
499
+ });
500
+
501
+ return root.toSource();
502
+ };
503
+
504
+ module.exports = transform;