@coinbase/cds-common 8.16.4 → 8.17.1

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/CHANGELOG.md CHANGED
@@ -8,6 +8,16 @@ All notable changes to this project will be documented in this file.
8
8
 
9
9
  <!-- template-start -->
10
10
 
11
+ ## 8.17.1 ((10/16/2025, 01:14 PM PST))
12
+
13
+ This is an artificial version bump with no new change.
14
+
15
+ ## 8.17.0 (10/16/2025 PST)
16
+
17
+ #### 🚀 Updates
18
+
19
+ - Update useStepper to not set initialActiveId if not passed in. [[#109](https://github.com/coinbase/cds/pull/109)]
20
+
11
21
  ## 8.16.4 ((10/15/2025, 07:38 AM PST))
12
22
 
13
23
  This is an artificial version bump with no new change.
@@ -33,7 +33,7 @@ export type StepperApi = {
33
33
  *
34
34
  * @param options - The options for the stepper.
35
35
  * @param options.steps - The array of steps data.
36
- * @param options.defaultActiveStepId - The default active step ID. If not provided, the first step will be used.
36
+ * @param options.defaultActiveStepId - The default active step ID.
37
37
  * @param options.skipParentSteps - If true, steps containing sub-steps will never be made active.
38
38
  * @returns A tuple where the first element is the stepper state and the second element is an API for manipulating the stepper state.
39
39
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useStepper.d.ts","sourceRoot":"","sources":["../../src/stepper/useStepper.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,QAAQ,SAAS,gBAAgB,GAAG,gBAAgB,IAAI;IACjF,+BAA+B;IAC/B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,gIAAgI;IAChI,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,YAA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ACvB,0IAA0I;IAC1I,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,iEAAiE;IACjE,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,SAAS,gBAAgB,GAAG,gBAAgB,EAAE,kDAI9E,cAAc,CAAC,QAAQ,CAAC,KAAG,CAAC,YAAY,EAAE,UAAU,CA4FtD,CAAC"}
@@ -6,7 +6,7 @@ import { flattenSteps } from './utils';
6
6
  *
7
7
  * @param options - The options for the stepper.
8
8
  * @param options.steps - The array of steps data.
9
- * @param options.defaultActiveStepId - The default active step ID. If not provided, the first step will be used.
9
+ * @param options.defaultActiveStepId - The default active step ID.
10
10
  * @param options.skipParentSteps - If true, steps containing sub-steps will never be made active.
11
11
  * @returns A tuple where the first element is the stepper state and the second element is an API for manipulating the stepper state.
12
12
  */
@@ -22,10 +22,8 @@ export const useStepper = _ref => {
22
22
  for (let i = fromIndex; i < flatSteps.length; i++) {
23
23
  const step = flatSteps[i];
24
24
  const isParentStep = step.subSteps && step.subSteps.length > 0;
25
- const canUseStep = !skipParentSteps || !isParentStep;
26
- if (canUseStep) {
27
- return step;
28
- }
25
+ const invalidStep = skipParentSteps && isParentStep;
26
+ if (!invalidStep) return step;
29
27
  }
30
28
  return null;
31
29
  }, [flatSteps, skipParentSteps]);
@@ -33,53 +31,22 @@ export const useStepper = _ref => {
33
31
  for (let i = fromIndex; i >= 0; i--) {
34
32
  const step = flatSteps[i];
35
33
  const isParentStep = step.subSteps && step.subSteps.length > 0;
36
- const canUseStep = !skipParentSteps || !isParentStep;
37
- if (canUseStep) {
38
- return step;
39
- }
34
+ const invalidStep = skipParentSteps && isParentStep;
35
+ if (!invalidStep) return step;
40
36
  }
41
37
  return null;
42
38
  }, [flatSteps, skipParentSteps]);
43
- const getInitialActiveStepId = useCallback(() => {
44
- if (flatSteps.length === 0 || defaultActiveStepId === null) {
45
- return null;
46
- }
47
- if (defaultActiveStepId) {
48
- const defaultStepInFlat = flatSteps.find(step => step.id === defaultActiveStepId);
49
- if (defaultStepInFlat) {
50
- const isParentStep = defaultStepInFlat.subSteps && defaultStepInFlat.subSteps.length > 0;
51
- const canUseStep = !skipParentSteps || !isParentStep;
52
- if (canUseStep) {
53
- return defaultStepInFlat.id;
54
- }
55
-
56
- // If it's a parent step and we skip parent steps, find next valid step from this position
57
- const defaultStepIndex = flatSteps.findIndex(step => step.id === defaultActiveStepId);
58
- const nextValidStep = findNextStep(defaultStepIndex);
59
- if (nextValidStep) {
60
- return nextValidStep.id;
61
- }
62
- }
63
- }
64
-
65
- // Fallback to first valid step
66
- const firstValidStep = findNextStep(0);
67
- return firstValidStep ? firstValidStep.id : null;
68
- }, [defaultActiveStepId, flatSteps, skipParentSteps, findNextStep]);
69
- const [activeStepId, setActiveStepId] = useState(getInitialActiveStepId());
39
+ const [activeStepId, setActiveStepId] = useState(defaultActiveStepId !== null && defaultActiveStepId !== void 0 ? defaultActiveStepId : null);
70
40
  const goToStep = useCallback(stepId => {
71
41
  const targetIndex = flatSteps.findIndex(step => step.id === stepId);
72
- if (targetIndex === -1) {
73
- return;
74
- }
42
+ if (targetIndex === -1) return;
75
43
  const targetStep = flatSteps[targetIndex];
76
-
77
44
  // If skipParentSteps is enabled, don't allow navigation to parent steps
78
45
  if (skipParentSteps && targetStep.subSteps && targetStep.subSteps.length > 0) {
79
46
  return;
80
47
  }
81
48
  setActiveStepId(targetStep.id);
82
- }, [flatSteps, setActiveStepId, skipParentSteps]);
49
+ }, [flatSteps, skipParentSteps]);
83
50
  const goNextStep = useCallback(() => {
84
51
  setActiveStepId(currentActiveStepId => {
85
52
  if (currentActiveStepId === null) {
@@ -88,29 +55,20 @@ export const useStepper = _ref => {
88
55
  }
89
56
  const activeStepIndex = flatSteps.findIndex(step => step.id === currentActiveStepId);
90
57
  const nextStep = findNextStep(activeStepIndex + 1);
91
- if (nextStep) {
92
- return nextStep.id;
93
- } else {
94
- return currentActiveStepId;
95
- }
58
+ if (nextStep) return nextStep.id;
59
+ return currentActiveStepId;
96
60
  });
97
- }, [flatSteps, findNextStep]);
61
+ }, [findNextStep, flatSteps]);
98
62
  const goPreviousStep = useCallback(() => {
99
63
  setActiveStepId(currentActiveStepId => {
100
- if (currentActiveStepId === null) {
101
- return null;
102
- }
64
+ if (currentActiveStepId === null) return null;
103
65
  const activeStepIndex = flatSteps.findIndex(step => step.id === currentActiveStepId);
104
66
  const previousStep = findPreviousStep(activeStepIndex - 1);
105
- if (previousStep) {
106
- return previousStep.id;
107
- }
67
+ if (previousStep) return previousStep.id;
108
68
  return currentActiveStepId;
109
69
  });
110
- }, [flatSteps, findPreviousStep]);
111
- const reset = useCallback(() => {
112
- setActiveStepId(getInitialActiveStepId());
113
- }, [getInitialActiveStepId, setActiveStepId]);
70
+ }, [findPreviousStep, flatSteps]);
71
+ const reset = useCallback(() => setActiveStepId(defaultActiveStepId !== null && defaultActiveStepId !== void 0 ? defaultActiveStepId : null), [defaultActiveStepId, setActiveStepId]);
114
72
  const state = useMemo(() => ({
115
73
  activeStepId
116
74
  }), [activeStepId]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cds-common",
3
- "version": "8.16.4",
3
+ "version": "8.17.1",
4
4
  "description": "Coinbase Design System - Common",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,7 +40,7 @@
40
40
  "dependencies": {
41
41
  "@coinbase/cds-icons": "^5.4.2",
42
42
  "@coinbase/cds-illustrations": "^4.24.0",
43
- "@coinbase/cds-mcp-server": "^8.16.4",
43
+ "@coinbase/cds-mcp-server": "^8.17.1",
44
44
  "@coinbase/cds-utils": "^2.3.3",
45
45
  "@modelcontextprotocol/sdk": "^1.13.1",
46
46
  "d3-array": "^3.2.4",