UNPKG

carbon-react

Version:

A library of reusable React components for easily building user interfaces.

2 lines (1 loc) 455 B
import{jsx as r}from"react/jsx-runtime";import{createContext as o,useState as e,useCallback as i}from"react";const t=o({isSubRow:!1,firstRowId:"",addRow:()=>{},removeRow:()=>{}}),d=({children:o})=>{const[d,a]=e([]),s=i((r=>{a((o=>[...o,r]))}),[]),w=i((r=>{a((o=>o.filter((o=>o!==r))))}),[]);return r(t.Provider,{value:{isSubRow:!0,firstRowId:d[0],addRow:s,removeRow:w},children:o})};d.displayName="SubRowProvider";export{t as SubRowContext,d as default};