@carbon/utilities-react 0.13.0 → 0.14.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/es/StepFlow/StepContext.js +1 -0
- package/es/StepFlow/StepGroup.js +1 -0
- package/es/StepFlow/index.js +1 -0
- package/es/StepFlow/types.js +0 -0
- package/es/index.js +1 -1
- package/lib/StepFlow/StepContext.js +1 -0
- package/lib/StepFlow/StepGroup.js +1 -0
- package/lib/StepFlow/index.js +1 -0
- package/lib/StepFlow/types.js +1 -0
- package/lib/index.js +1 -1
- package/package.json +4 -4
- package/types/StepFlow/StepContext.d.ts +14 -0
- package/types/StepFlow/StepGroup.d.ts +17 -0
- package/types/StepFlow/index.d.ts +9 -0
- package/types/StepFlow/types.d.ts +25 -0
- package/types/index.d.ts +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as x}from"react/jsx-runtime";import{useContext as a,createContext as u,useState as r}from"react";const n=u(void 0),h=({children:t})=>{const[p,d]=r(1),[s,o]=r(1),[S,c]=r({}),i={formState:S,setFormState:c,totalSteps:p,setTotalSteps:d,currentStep:s,handleGoToStep:e=>o(e),handleNext:()=>o(e=>e+1),handlePrevious:()=>o(e=>e-1)};return x(n.Provider,{value:i,children:t})},m=()=>{const t=a(n);if(t===void 0)throw new Error("Context hook used outside of Step provider");return t};export{h as StepProvider,m as useStepContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n,{useEffect as p}from"react";import{useStepContext as c}from".";const a=({children:r})=>{const{setTotalSteps:e,currentStep:o}=c(),t=n.Children.toArray(r);return p(()=>{e(t.length)},[t.length,e]),t[o-1]};export{a as StepGroup};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{StepGroup as p}from"./StepGroup";import{StepProvider as r,useStepContext as x}from"./StepContext";export{p as StepGroup,r as StepProvider,x as useStepContext};
|
|
File without changes
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"@carbon/utilities";export*from"./useNoInteractiveChildren";
|
|
1
|
+
export*from"@carbon/utilities";export*from"./useNoInteractiveChildren";export*from"./StepFlow";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},P=(e,t,n,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of C(t))!f.call(e,o)&&o!==n&&s(e,o,{get:()=>t[o],enumerable:!(d=x(t,o))||d.enumerable});return e};var l=e=>P(s({},"__esModule",{value:!0}),e);var T={};v(T,{StepProvider:()=>h,useStepContext:()=>m});module.exports=l(T);var c=require("react/jsx-runtime"),r=require("react");const S=(0,r.createContext)(void 0),h=({children:e})=>{const[t,n]=(0,r.useState)(1),[d,o]=(0,r.useState)(1),[i,a]=(0,r.useState)({}),u={formState:i,setFormState:a,totalSteps:t,setTotalSteps:n,currentStep:d,handleGoToStep:p=>o(p),handleNext:()=>o(p=>p+1),handlePrevious:()=>o(p=>p-1)};return(0,c.jsx)(S.Provider,{value:u,children:e})},m=()=>{const e=(0,r.useContext)(S);if(e===void 0)throw new Error("Context hook used outside of Step provider");return e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var S=Object.create;var p=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var f=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},s=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!m.call(t,n)&&n!==r&&p(t,n,{get:()=>e[n],enumerable:!(o=a(e,n))||o.enumerable});return t};var h=(t,e,r)=>(r=t!=null?S(l(t)):{},s(e||!t||!t.__esModule?p(r,"default",{value:t,enumerable:!0}):r,t)),d=t=>s(p({},"__esModule",{value:!0}),t);var G={};f(G,{StepGroup:()=>C});module.exports=d(G);var c=h(require("react")),u=require(".");const C=({children:t})=>{const{setTotalSteps:e,currentStep:r}=(0,u.useStepContext)(),o=c.default.Children.toArray(t);return(0,c.useEffect)(()=>{e(o.length)},[o.length,e]),o[r-1]};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var x=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var s=(t,e)=>{for(var o in e)x(t,o,{get:e[o],enumerable:!0})},u=(t,e,o,S)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of y(e))!n.call(t,p)&&p!==o&&x(t,p,{get:()=>e[p],enumerable:!(S=m(e,p))||S.enumerable});return t};var C=t=>u(x({},"__esModule",{value:!0}),t);var d={};s(d,{StepGroup:()=>f.StepGroup,StepProvider:()=>r.StepProvider,useStepContext:()=>r.useStepContext});module.exports=C(d);var f=require("./StepGroup"),r=require("./StepContext");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var m=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of p(t))!i.call(e,o)&&o!==r&&n(e,o,{get:()=>t[o],enumerable:!(a=S(t,o))||a.enumerable});return e};var s=e=>m(n({},"__esModule",{value:!0}),e);var c={};module.exports=s(c);
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(r,
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,r,p,x)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of c(r))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>r[m],enumerable:!(x=b(r,m))||x.enumerable});return f},e=(f,r,p)=>(t(f,r,"default"),p&&t(p,r,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);e(o,require("@carbon/utilities"),module.exports);e(o,require("./useNoInteractiveChildren"),module.exports);e(o,require("./StepFlow"),module.exports);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/utilities-react",
|
|
3
3
|
"description": "Utilities and helpers to drive consistency across software products using the Carbon Design System with React",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"esbuild": "^0.25.0",
|
|
46
46
|
"rimraf": "^6.0.1",
|
|
47
47
|
"typescript": "^5.7.3",
|
|
48
|
-
"typescript-config-carbon": "^0.
|
|
48
|
+
"typescript-config-carbon": "^0.8.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@carbon/utilities": "^0.
|
|
51
|
+
"@carbon/utilities": "^0.11.0",
|
|
52
52
|
"@ibm/telemetry-js": "^1.6.1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "c17cce753e36124e6e8e02daba97ae9d4decbcc3"
|
|
55
55
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025, 2025
|
|
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
|
+
import { ReactNode } from 'react';
|
|
8
|
+
import { StepContextType } from './types';
|
|
9
|
+
interface StepProviderProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare const StepProvider: ({ children }: StepProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const useStepContext: () => StepContextType;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025, 2025
|
|
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
|
+
import React from 'react';
|
|
8
|
+
interface StepGroupProps {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Container for steps. The children are filtered for only truthy values (via Children.toArray)
|
|
13
|
+
* and only the current step is returned from this component based on the `currentStep` value
|
|
14
|
+
* from `useStepContext`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const StepGroup: ({ children }: StepGroupProps) => string | number | bigint | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025, 2025
|
|
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
|
+
export { StepGroup } from './StepGroup';
|
|
8
|
+
export { StepProvider, useStepContext } from './StepContext';
|
|
9
|
+
export type { StepContextType } from './types';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025, 2025
|
|
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
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* This interface should be extended by the consumer to match their own unique
|
|
10
|
+
* use case given the fields within their own stepped experience.
|
|
11
|
+
*/
|
|
12
|
+
interface formStateType {
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface StepContextType {
|
|
16
|
+
formState: formStateType;
|
|
17
|
+
setFormState: Dispatch<SetStateAction<formStateType>>;
|
|
18
|
+
totalSteps: number;
|
|
19
|
+
setTotalSteps: Dispatch<SetStateAction<number>>;
|
|
20
|
+
currentStep: number;
|
|
21
|
+
handleGoToStep: (step: number) => void;
|
|
22
|
+
handleNext: () => void;
|
|
23
|
+
handlePrevious: () => void;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
package/types/index.d.ts
CHANGED