fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

View File

@@ -0,0 +1,12 @@
/**
* WordPress dependencies
*/
import { createContext, useContext } from '@wordpress/element';
/**
* Internal dependencies
*/
export const TabsContext = createContext(undefined);
export const useTabsContext = () => useContext(TabsContext);
//# sourceMappingURL=context.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createContext","useContext","TabsContext","undefined","useTabsContext"],"sources":["@wordpress/components/src/tabs/context.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { TabsContextProps } from './types';\n\nexport const TabsContext = createContext< TabsContextProps >( undefined );\n\nexport const useTabsContext = () => useContext( TabsContext );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;;AAE9D;AACA;AACA;;AAGA,OAAO,MAAMC,WAAW,GAAGF,aAAa,CAAsBG,SAAU,CAAC;AAEzE,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAMH,UAAU,CAAEC,WAAY,CAAC"}

View File

@@ -0,0 +1,161 @@
import { createElement } from "react";
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
/**
* WordPress dependencies
*/
import { useInstanceId } from '@wordpress/compose';
import { useLayoutEffect, useMemo, useRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import { TabsContext } from './context';
import { Tab } from './tab';
import { TabList } from './tablist';
import { TabPanel } from './tabpanel';
function Tabs({
selectOnMove = true,
initialTabId,
orientation = 'horizontal',
onSelect,
children,
selectedTabId
}) {
const instanceId = useInstanceId(Tabs, 'tabs');
const store = Ariakit.useTabStore({
selectOnMove,
orientation,
defaultSelectedId: initialTabId && `${instanceId}-${initialTabId}`,
setSelectedId: selectedId => {
const strippedDownId = typeof selectedId === 'string' ? selectedId.replace(`${instanceId}-`, '') : selectedId;
onSelect?.(strippedDownId);
},
selectedId: selectedTabId && `${instanceId}-${selectedTabId}`
});
const isControlled = selectedTabId !== undefined;
const {
items,
selectedId
} = store.useState();
const {
setSelectedId,
move
} = store;
// Keep track of whether tabs have been populated. This is used to prevent
// certain effects from firing too early while tab data and relevant
// variables are undefined during the initial render.
const tabsHavePopulated = useRef(false);
if (items.length > 0) {
tabsHavePopulated.current = true;
}
const selectedTab = items.find(item => item.id === selectedId);
const firstEnabledTab = items.find(item => {
// Ariakit internally refers to disabled tabs as `dimmed`.
return !item.dimmed;
});
const initialTab = items.find(item => item.id === `${instanceId}-${initialTabId}`);
// Handle selecting the initial tab.
useLayoutEffect(() => {
if (isControlled) {
return;
}
// Wait for the denoted initial tab to be declared before making a
// selection. This ensures that if a tab is declared lazily it can
// still receive initial selection, as well as ensuring no tab is
// selected if an invalid `initialTabId` is provided.
if (initialTabId && !initialTab) {
return;
}
// If the currently selected tab is missing (i.e. removed from the DOM),
// fall back to the initial tab or the first enabled tab if there is
// one. Otherwise, no tab should be selected.
if (!items.find(item => item.id === selectedId)) {
if (initialTab && !initialTab.dimmed) {
setSelectedId(initialTab?.id);
return;
}
if (firstEnabledTab) {
setSelectedId(firstEnabledTab.id);
} else if (tabsHavePopulated.current) {
setSelectedId(null);
}
}
}, [firstEnabledTab, initialTab, initialTabId, isControlled, items, selectedId, setSelectedId]);
// Handle the currently selected tab becoming disabled.
useLayoutEffect(() => {
if (!selectedTab?.dimmed) {
return;
}
// In controlled mode, we trust that disabling tabs is done
// intentionally, and don't select a new tab automatically.
if (isControlled) {
setSelectedId(null);
return;
}
// If the currently selected tab becomes disabled, fall back to the
// `initialTabId` if possible. Otherwise select the first
// enabled tab (if there is one).
if (initialTab && !initialTab.dimmed) {
setSelectedId(initialTab.id);
return;
}
if (firstEnabledTab) {
setSelectedId(firstEnabledTab.id);
}
}, [firstEnabledTab, initialTab, isControlled, selectedTab?.dimmed, setSelectedId]);
// Clear `selectedId` if the active tab is removed from the DOM in controlled mode.
useLayoutEffect(() => {
if (!isControlled) {
return;
}
// Once the tabs have populated, if the `selectedTabId` still can't be
// found, clear the selection.
if (tabsHavePopulated.current && !!selectedTabId && !selectedTab) {
setSelectedId(null);
}
}, [isControlled, selectedId, selectedTab, selectedTabId, setSelectedId]);
// In controlled mode, make sure browser focus follows the selected tab if
// the selection is changed while a tab is already being focused.
useLayoutEffect(() => {
if (!isControlled || !selectOnMove) {
return;
}
const currentItem = items.find(item => item.id === selectedId);
const activeElement = currentItem?.element?.ownerDocument.activeElement;
const tabsHasFocus = items.some(item => {
return activeElement && activeElement === item.element;
});
if (activeElement && tabsHasFocus && selectedId !== activeElement.id) {
move(selectedId);
}
}, [isControlled, items, move, selectOnMove, selectedId]);
const contextValue = useMemo(() => ({
store,
instanceId
}), [store, instanceId]);
return createElement(TabsContext.Provider, {
value: contextValue
}, children);
}
Tabs.TabList = TabList;
Tabs.Tab = Tab;
Tabs.TabPanel = TabPanel;
Tabs.Context = TabsContext;
export default Tabs;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"names":["Ariakit","COLORS","space","reduceMotion","TabListWrapper","_styled","process","env","NODE_ENV","target","label","name","styles","map","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","Tab","theme","accent","TabPanel"],"sources":["@wordpress/components/src/tabs/styles.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * Internal dependencies\n */\nimport { COLORS } from '../utils';\nimport { space } from '../utils/space';\nimport { reduceMotion } from '../utils/reduce-motion';\n\nexport const TabListWrapper = styled.div`\n\tdisplay: flex;\n\talign-items: stretch;\n\tflex-direction: row;\n\t&[aria-orientation='vertical'] {\n\t\tflex-direction: column;\n\t}\n`;\n\nexport const Tab = styled( Ariakit.Tab )`\n\t& {\n\t\tdisplay: inline-flex;\n\t\talign-items: center;\n\t\tposition: relative;\n\t\tborder-radius: 0;\n\t\theight: ${ space( 12 ) };\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tbox-shadow: none;\n\t\tcursor: pointer;\n\t\tpadding: 3px ${ space( 4 ) }; // Use padding to offset the [aria-selected=\"true\"] border, this benefits Windows High Contrast mode\n\t\tmargin-left: 0;\n\t\tfont-weight: 500;\n\n\t\t&[aria-disabled='true'] {\n\t\t\tcursor: default;\n\t\t\topacity: 0.3;\n\t\t}\n\n\t\t&:hover {\n\t\t\tcolor: ${ COLORS.theme.accent };\n\t\t}\n\n\t\t&:focus:not( :disabled ) {\n\t\t\tposition: relative;\n\t\t\tbox-shadow: none;\n\t\t\toutline: none;\n\t\t}\n\n\t\t// Tab indicator\n\t\t&::after {\n\t\t\tcontent: '';\n\t\t\tposition: absolute;\n\t\t\tright: 0;\n\t\t\tbottom: 0;\n\t\t\tleft: 0;\n\t\t\tpointer-events: none;\n\n\t\t\t// Draw the indicator.\n\t\t\tbackground: ${ COLORS.theme.accent };\n\t\t\theight: calc( 0 * var( --wp-admin-border-width-focus ) );\n\t\t\tborder-radius: 0;\n\n\t\t\t// Animation\n\t\t\ttransition: all 0.1s linear;\n\t\t\t${ reduceMotion( 'transition' ) };\n\t\t}\n\n\t\t// Active.\n\t\t&[aria-selected='true']::after {\n\t\t\theight: calc( 1 * var( --wp-admin-border-width-focus ) );\n\n\t\t\t// Windows high contrast mode.\n\t\t\toutline: 2px solid transparent;\n\t\t\toutline-offset: -1px;\n\t\t}\n\n\t\t// Focus.\n\t\t&::before {\n\t\t\tcontent: '';\n\t\t\tposition: absolute;\n\t\t\ttop: ${ space( 3 ) };\n\t\t\tright: ${ space( 3 ) };\n\t\t\tbottom: ${ space( 3 ) };\n\t\t\tleft: ${ space( 3 ) };\n\t\t\tpointer-events: none;\n\n\t\t\t// Draw the indicator.\n\t\t\tbox-shadow: 0 0 0 0 transparent;\n\t\t\tborder-radius: 2px;\n\n\t\t\t// Animation\n\t\t\ttransition: all 0.1s linear;\n\t\t\t${ reduceMotion( 'transition' ) };\n\t\t}\n\n\t\t&:focus-visible::before {\n\t\t\tbox-shadow: 0 0 0 var( --wp-admin-border-width-focus )\n\t\t\t\t${ COLORS.theme.accent };\n\n\t\t\t// Windows high contrast mode.\n\t\t\toutline: 2px solid transparent;\n\t\t}\n\t}\n`;\n\nexport const TabPanel = styled( Ariakit.TabPanel )`\n\t&:focus {\n\t\tbox-shadow: none;\n\t\toutline: none;\n\t}\n\n\t&:focus-visible {\n\t\tborder-radius: 2px;\n\t\tbox-shadow: 0 0 0 var( --wp-admin-border-width-focus )\n\t\t\t${ COLORS.theme.accent };\n\t\t// Windows high contrast mode.\n\t\toutline: 2px solid transparent;\n\t\toutline-offset: 0;\n\t}\n`;\n"],"mappings":";;AAAA;AACA;AACA;;AAEA;AACA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;;AAEzC;AACA;AACA;AACA,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,YAAY,QAAQ,wBAAwB;AAErD,OAAO,MAAMC,cAAc,GAAAC,OAAA,QAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAC,MAAA;AAAA;EAAAA,MAAA;EAAAC,KAAA;AAAA,GAAAJ,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAG,IAAA;EAAAC,MAAA;AAAA;EAAAD,IAAA;EAAAC,MAAA;EAAAC,GAAA;EAAAC,QAAA,EAAAC;AAAA,EAO1B;AAED,OAAO,MAAMC,GAAG,GAAG,aAAAX,OAAA,CAAQL,OAAO,CAACgB,GAAG,EAAAV,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAC,MAAA;AAAA;EAAAA,MAAA;EAAAC,KAAA;AAAA,CAAC,CAAC,uFAM3BR,KAAK,CAAE,EAAG,CAAC,qFAKNA,KAAK,CAAE,CAAE,CAAC,uGAUfD,MAAM,CAACgB,KAAK,CAACC,MAAM,8KAmBdjB,MAAM,CAACgB,KAAK,CAACC,MAAM,0GAM/Bf,YAAY,CAAE,YAAa,CAAC,6LAgBvBD,KAAK,CAAE,CAAE,CAAC,aACRA,KAAK,CAAE,CAAE,CAAC,cACTA,KAAK,CAAE,CAAE,CAAC,YACZA,KAAK,CAAE,CAAE,CAAC,uGAShBC,YAAY,CAAE,YAAa,CAAC,sFAK3BF,MAAM,CAACgB,KAAK,CAACC,MAAM,yCAAAZ,OAAA,CAAAC,GAAA,CAAAC,QAAA,wqIAMzB;AAED,OAAO,MAAMW,QAAQ,GAAG,aAAAd,OAAA,CAAQL,OAAO,CAACmB,QAAQ,EAAAb,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAC,MAAA;AAAA;EAAAA,MAAA;EAAAC,KAAA;AAAA,CAAC,CAAC,mIAS5CT,MAAM,CAACgB,KAAK,CAACC,MAAM,yDAAAZ,OAAA,CAAAC,GAAA,CAAAC,QAAA,wqIAKxB"}

View File

@@ -0,0 +1,41 @@
import { createElement } from "react";
/**
* WordPress dependencies
*/
import { forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import warning from '@wordpress/warning';
import { useTabsContext } from './context';
import { Tab as StyledTab } from './styles';
export const Tab = forwardRef(function Tab({
children,
tabId,
disabled,
render,
...otherProps
}, ref) {
const context = useTabsContext();
if (!context) {
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? warning('`Tabs.Tab` must be wrapped in a `Tabs` component.') : void 0;
return null;
}
const {
store,
instanceId
} = context;
const instancedTabId = `${instanceId}-${tabId}`;
return createElement(StyledTab, {
ref: ref,
store: store,
id: instancedTabId,
disabled: disabled,
render: render,
...otherProps
}, children);
});
//# sourceMappingURL=tab.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["forwardRef","warning","useTabsContext","Tab","StyledTab","children","tabId","disabled","render","otherProps","ref","context","SCRIPT_DEBUG","store","instanceId","instancedTabId","createElement","id"],"sources":["@wordpress/components/src/tabs/tab.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { TabProps } from './types';\nimport warning from '@wordpress/warning';\nimport { useTabsContext } from './context';\nimport { Tab as StyledTab } from './styles';\nimport type { WordPressComponentProps } from '../context';\n\nexport const Tab = forwardRef<\n\tHTMLButtonElement,\n\tOmit< WordPressComponentProps< TabProps, 'button', false >, 'id' >\n>( function Tab( { children, tabId, disabled, render, ...otherProps }, ref ) {\n\tconst context = useTabsContext();\n\tif ( ! context ) {\n\t\twarning( '`Tabs.Tab` must be wrapped in a `Tabs` component.' );\n\t\treturn null;\n\t}\n\tconst { store, instanceId } = context;\n\tconst instancedTabId = `${ instanceId }-${ tabId }`;\n\treturn (\n\t\t<StyledTab\n\t\t\tref={ ref }\n\t\t\tstore={ store }\n\t\t\tid={ instancedTabId }\n\t\t\tdisabled={ disabled }\n\t\t\trender={ render }\n\t\t\t{ ...otherProps }\n\t\t>\n\t\t\t{ children }\n\t\t</StyledTab>\n\t);\n} );\n"],"mappings":";AAAA;AACA;AACA;;AAEA,SAASA,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;;AAEA,OAAOC,OAAO,MAAM,oBAAoB;AACxC,SAASC,cAAc,QAAQ,WAAW;AAC1C,SAASC,GAAG,IAAIC,SAAS,QAAQ,UAAU;AAG3C,OAAO,MAAMD,GAAG,GAAGH,UAAU,CAG1B,SAASG,GAAGA,CAAE;EAAEE,QAAQ;EAAEC,KAAK;EAAEC,QAAQ;EAAEC,MAAM;EAAE,GAAGC;AAAW,CAAC,EAAEC,GAAG,EAAG;EAC5E,MAAMC,OAAO,GAAGT,cAAc,CAAC,CAAC;EAChC,IAAK,CAAES,OAAO,EAAG;IAChB,OAAAC,YAAA,oBAAAA,YAAA,YAAAX,OAAO,CAAE,mDAAoD,CAAC;IAC9D,OAAO,IAAI;EACZ;EACA,MAAM;IAAEY,KAAK;IAAEC;EAAW,CAAC,GAAGH,OAAO;EACrC,MAAMI,cAAc,GAAI,GAAGD,UAAY,IAAIR,KAAO,EAAC;EACnD,OACCU,aAAA,CAACZ,SAAS;IACTM,GAAG,EAAGA,GAAK;IACXG,KAAK,EAAGA,KAAO;IACfI,EAAE,EAAGF,cAAgB;IACrBR,QAAQ,EAAGA,QAAU;IACrBC,MAAM,EAAGA,MAAQ;IAAA,GACZC;EAAU,GAEbJ,QACQ,CAAC;AAEd,CAAE,CAAC"}

View File

@@ -0,0 +1,39 @@
import { createElement } from "react";
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
/**
* WordPress dependencies
*/
import warning from '@wordpress/warning';
import { forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useTabsContext } from './context';
import { TabListWrapper } from './styles';
export const TabList = forwardRef(function TabList({
children,
...otherProps
}, ref) {
const context = useTabsContext();
if (!context) {
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? warning('`Tabs.TabList` must be wrapped in a `Tabs` component.') : void 0;
return null;
}
const {
store
} = context;
return createElement(Ariakit.TabList, {
ref: ref,
store: store,
render: createElement(TabListWrapper, null),
...otherProps
}, children);
});
//# sourceMappingURL=tablist.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Ariakit","warning","forwardRef","useTabsContext","TabListWrapper","TabList","children","otherProps","ref","context","SCRIPT_DEBUG","store","createElement","render"],"sources":["@wordpress/components/src/tabs/tablist.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport warning from '@wordpress/warning';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { TabListProps } from './types';\nimport { useTabsContext } from './context';\nimport { TabListWrapper } from './styles';\nimport type { WordPressComponentProps } from '../context';\n\nexport const TabList = forwardRef<\n\tHTMLDivElement,\n\tWordPressComponentProps< TabListProps, 'div', false >\n>( function TabList( { children, ...otherProps }, ref ) {\n\tconst context = useTabsContext();\n\tif ( ! context ) {\n\t\twarning( '`Tabs.TabList` must be wrapped in a `Tabs` component.' );\n\t\treturn null;\n\t}\n\tconst { store } = context;\n\treturn (\n\t\t<Ariakit.TabList\n\t\t\tref={ ref }\n\t\t\tstore={ store }\n\t\t\trender={ <TabListWrapper /> }\n\t\t\t{ ...otherProps }\n\t\t>\n\t\t\t{ children }\n\t\t</Ariakit.TabList>\n\t);\n} );\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;;AAEzC;AACA;AACA;AACA,OAAOC,OAAO,MAAM,oBAAoB;AACxC,SAASC,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;;AAEA,SAASC,cAAc,QAAQ,WAAW;AAC1C,SAASC,cAAc,QAAQ,UAAU;AAGzC,OAAO,MAAMC,OAAO,GAAGH,UAAU,CAG9B,SAASG,OAAOA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAW,CAAC,EAAEC,GAAG,EAAG;EACvD,MAAMC,OAAO,GAAGN,cAAc,CAAC,CAAC;EAChC,IAAK,CAAEM,OAAO,EAAG;IAChB,OAAAC,YAAA,oBAAAA,YAAA,YAAAT,OAAO,CAAE,uDAAwD,CAAC;IAClE,OAAO,IAAI;EACZ;EACA,MAAM;IAAEU;EAAM,CAAC,GAAGF,OAAO;EACzB,OACCG,aAAA,CAACZ,OAAO,CAACK,OAAO;IACfG,GAAG,EAAGA,GAAK;IACXG,KAAK,EAAGA,KAAO;IACfE,MAAM,EAAGD,aAAA,CAACR,cAAc,MAAE,CAAG;IAAA,GACxBG;EAAU,GAEbD,QACc,CAAC;AAEpB,CAAE,CAAC"}

View File

@@ -0,0 +1,45 @@
import { createElement } from "react";
/**
* WordPress dependencies
*/
import { forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import { TabPanel as StyledTabPanel } from './styles';
import warning from '@wordpress/warning';
import { useTabsContext } from './context';
export const TabPanel = forwardRef(function TabPanel({
children,
tabId,
focusable = true,
...otherProps
}, ref) {
const context = useTabsContext();
if (!context) {
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? warning('`Tabs.TabPanel` must be wrapped in a `Tabs` component.') : void 0;
return null;
}
const {
store,
instanceId
} = context;
const instancedTabId = `${instanceId}-${tabId}`;
const selectedId = store.useState(state => state.selectedId);
return createElement(StyledTabPanel, {
ref: ref,
store: store
// For TabPanel, the id passed here is the id attribute of the DOM
// element.
// `tabId` is the id of the tab that controls this panel.
,
id: `${instancedTabId}-view`,
tabId: instancedTabId,
focusable: focusable,
...otherProps
}, selectedId === instancedTabId && children);
});
//# sourceMappingURL=tabpanel.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["forwardRef","TabPanel","StyledTabPanel","warning","useTabsContext","children","tabId","focusable","otherProps","ref","context","SCRIPT_DEBUG","store","instanceId","instancedTabId","selectedId","useState","state","createElement","id"],"sources":["@wordpress/components/src/tabs/tabpanel.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { TabPanelProps } from './types';\nimport { TabPanel as StyledTabPanel } from './styles';\n\nimport warning from '@wordpress/warning';\nimport { useTabsContext } from './context';\nimport type { WordPressComponentProps } from '../context';\n\nexport const TabPanel = forwardRef<\n\tHTMLDivElement,\n\tOmit< WordPressComponentProps< TabPanelProps, 'div', false >, 'id' >\n>( function TabPanel(\n\t{ children, tabId, focusable = true, ...otherProps },\n\tref\n) {\n\tconst context = useTabsContext();\n\tif ( ! context ) {\n\t\twarning( '`Tabs.TabPanel` must be wrapped in a `Tabs` component.' );\n\t\treturn null;\n\t}\n\tconst { store, instanceId } = context;\n\tconst instancedTabId = `${ instanceId }-${ tabId }`;\n\tconst selectedId = store.useState( ( state ) => state.selectedId );\n\n\treturn (\n\t\t<StyledTabPanel\n\t\t\tref={ ref }\n\t\t\tstore={ store }\n\t\t\t// For TabPanel, the id passed here is the id attribute of the DOM\n\t\t\t// element.\n\t\t\t// `tabId` is the id of the tab that controls this panel.\n\t\t\tid={ `${ instancedTabId }-view` }\n\t\t\ttabId={ instancedTabId }\n\t\t\tfocusable={ focusable }\n\t\t\t{ ...otherProps }\n\t\t>\n\t\t\t{ selectedId === instancedTabId && children }\n\t\t</StyledTabPanel>\n\t);\n} );\n"],"mappings":";AAAA;AACA;AACA;;AAEA,SAASA,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;;AAEA,SAASC,QAAQ,IAAIC,cAAc,QAAQ,UAAU;AAErD,OAAOC,OAAO,MAAM,oBAAoB;AACxC,SAASC,cAAc,QAAQ,WAAW;AAG1C,OAAO,MAAMH,QAAQ,GAAGD,UAAU,CAG/B,SAASC,QAAQA,CACnB;EAAEI,QAAQ;EAAEC,KAAK;EAAEC,SAAS,GAAG,IAAI;EAAE,GAAGC;AAAW,CAAC,EACpDC,GAAG,EACF;EACD,MAAMC,OAAO,GAAGN,cAAc,CAAC,CAAC;EAChC,IAAK,CAAEM,OAAO,EAAG;IAChB,OAAAC,YAAA,oBAAAA,YAAA,YAAAR,OAAO,CAAE,wDAAyD,CAAC;IACnE,OAAO,IAAI;EACZ;EACA,MAAM;IAAES,KAAK;IAAEC;EAAW,CAAC,GAAGH,OAAO;EACrC,MAAMI,cAAc,GAAI,GAAGD,UAAY,IAAIP,KAAO,EAAC;EACnD,MAAMS,UAAU,GAAGH,KAAK,CAACI,QAAQ,CAAIC,KAAK,IAAMA,KAAK,CAACF,UAAW,CAAC;EAElE,OACCG,aAAA,CAAChB,cAAc;IACdO,GAAG,EAAGA,GAAK;IACXG,KAAK,EAAGA;IACR;IACA;IACA;IAAA;IACAO,EAAE,EAAI,GAAGL,cAAgB,OAAQ;IACjCR,KAAK,EAAGQ,cAAgB;IACxBP,SAAS,EAAGA,SAAW;IAAA,GAClBC;EAAU,GAEbO,UAAU,KAAKD,cAAc,IAAIT,QACpB,CAAC;AAEnB,CAAE,CAAC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/tabs/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type * as Ariakit from '@ariakit/react';\n\nexport type TabsContextProps =\n\t| {\n\t\t\t/**\n\t\t\t * The tabStore object returned by Ariakit's `useTabStore` hook.\n\t\t\t */\n\t\t\tstore: Ariakit.TabStore;\n\t\t\t/**\n\t\t\t * The unique id string for this instance of the Tabs component.\n\t\t\t */\n\t\t\tinstanceId: string;\n\t }\n\t| undefined;\n\nexport type TabsProps = {\n\t/**\n\t * The children elements, which should be at least a\n\t * `Tabs.Tablist` component and a series of `Tabs.TabPanel`\n\t * components.\n\t */\n\tchildren: React.ReactNode;\n\t/**\n\t * When `true`, the tab will be selected when receiving focus (automatic tab\n\t * activation). When `false`, the tab will be selected only when clicked\n\t * (manual tab activation). See the official W3C docs for more info.\n\t *\n\t * @default true\n\t *\n\t * @see https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/\n\t */\n\tselectOnMove?: boolean;\n\t/**\n\t * The id of the tab to be selected upon mounting of component.\n\t * If this prop is not set, the first tab will be selected by default.\n\t * The id provided will be internally prefixed with the\n\t * `TabsContextProps.instanceId`.\n\t *\n\t * Note: this prop will be overridden by the `selectedTabId` prop if it is\n\t * provided. (Controlled Mode)\n\t */\n\tinitialTabId?: string;\n\t/**\n\t * The function called when a tab has been selected.\n\t * It is passed the id of the newly selected tab as an argument.\n\t */\n\tonSelect?: ( selectedId: string | null | undefined ) => void;\n\n\t/**\n\t * The orientation of the tablist.\n\t *\n\t * @default `horizontal`\n\t */\n\torientation?: 'horizontal' | 'vertical';\n\t/**\n\t * The Id of the tab to display. This id is prepended with the `Tabs`\n\t * instanceId internally.\n\t *\n\t * If left `undefined`, the component assumes it is being used in\n\t * uncontrolled mode. Consequently, any value different than `undefined`\n\t * will set the component in `controlled` mode.\n\t * When in controlled mode, the `null` value will result in no tab being selected.\n\t */\n\tselectedTabId?: string | null;\n};\n\nexport type TabListProps = {\n\t/**\n\t * The children elements, which should be a series of `Tabs.TabPanel` components.\n\t */\n\tchildren?: React.ReactNode;\n};\n\nexport type TabProps = {\n\t/**\n\t * The id of the tab, which is prepended with the `Tabs` instanceId.\n\t * The value of this prop should match with the value of the `tabId` prop on\n\t * the corresponding `Tabs.TabPanel` component.\n\t */\n\ttabId: string;\n\t/**\n\t * The children elements, generally the text to display on the tab.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * Determines if the tab button should be disabled.\n\t *\n\t * @default false\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * The type of component to render the tab button as. If this prop is not\n\t * provided, the tab button will be rendered as a `button` element.\n\t */\n\trender?: React.ReactElement;\n};\n\nexport type TabPanelProps = {\n\t/**\n\t * The children elements, generally the content to display on the tabpanel.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * A unique identifier for the tabpanel, which is used to generate an\n\t * instanced id for the underlying element.\n\t * The value of this prop should match with the value of the `tabId` prop on\n\t * the corresponding `Tabs.Tab` component.\n\t */\n\ttabId: string;\n\t/**\n\t * Determines whether or not the tabpanel element should be focusable.\n\t * If `false`, pressing the tab key will skip over the tabpanel, and instead\n\t * focus on the first focusable element in the panel (if there is one).\n\t *\n\t * @default true\n\t */\n\tfocusable?: boolean;\n};\n"],"mappings":""}