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,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useTabsContext = exports.TabsContext = void 0;
var _element = require("@wordpress/element");
/**
* WordPress dependencies
*/
const TabsContext = (0, _element.createContext)(undefined);
exports.TabsContext = TabsContext;
const useTabsContext = () => (0, _element.useContext)(TabsContext);
exports.useTabsContext = useTabsContext;
//# sourceMappingURL=context.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","TabsContext","createContext","undefined","exports","useTabsContext","useContext"],"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":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAQO,MAAMC,WAAW,GAAG,IAAAC,sBAAa,EAAsBC,SAAU,CAAC;AAACC,OAAA,CAAAH,WAAA,GAAAA,WAAA;AAEnE,MAAMI,cAAc,GAAGA,CAAA,KAAM,IAAAC,mBAAU,EAAEL,WAAY,CAAC;AAACG,OAAA,CAAAC,cAAA,GAAAA,cAAA"}

166
node_modules/@wordpress/components/build/tabs/index.js generated vendored Normal file
View File

@@ -0,0 +1,166 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("react");
var Ariakit = _interopRequireWildcard(require("@ariakit/react"));
var _compose = require("@wordpress/compose");
var _element = require("@wordpress/element");
var _context = require("./context");
var _tab = require("./tab");
var _tablist = require("./tablist");
var _tabpanel = require("./tabpanel");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
/**
* WordPress dependencies
*/
function Tabs({
selectOnMove = true,
initialTabId,
orientation = 'horizontal',
onSelect,
children,
selectedTabId
}) {
const instanceId = (0, _compose.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 = (0, _element.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.
(0, _element.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.
(0, _element.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.
(0, _element.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.
(0, _element.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 = (0, _element.useMemo)(() => ({
store,
instanceId
}), [store, instanceId]);
return (0, _react.createElement)(_context.TabsContext.Provider, {
value: contextValue
}, children);
}
Tabs.TabList = _tablist.TabList;
Tabs.Tab = _tab.Tab;
Tabs.TabPanel = _tabpanel.TabPanel;
Tabs.Context = _context.TabsContext;
var _default = Tabs;
exports.default = _default;
//# 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

File diff suppressed because one or more lines are too long

44
node_modules/@wordpress/components/build/tabs/tab.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Tab = void 0;
var _react = require("react");
var _element = require("@wordpress/element");
var _warning = _interopRequireDefault(require("@wordpress/warning"));
var _context = require("./context");
var _styles = require("./styles");
/**
* WordPress dependencies
*/
const Tab = (0, _element.forwardRef)(function Tab({
children,
tabId,
disabled,
render,
...otherProps
}, ref) {
const context = (0, _context.useTabsContext)();
if (!context) {
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('`Tabs.Tab` must be wrapped in a `Tabs` component.') : void 0;
return null;
}
const {
store,
instanceId
} = context;
const instancedTabId = `${instanceId}-${tabId}`;
return (0, _react.createElement)(_styles.Tab, {
ref: ref,
store: store,
id: instancedTabId,
disabled: disabled,
render: render,
...otherProps
}, children);
});
exports.Tab = Tab;
//# sourceMappingURL=tab.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","_warning","_interopRequireDefault","_context","_styles","Tab","forwardRef","children","tabId","disabled","render","otherProps","ref","context","useTabsContext","SCRIPT_DEBUG","warning","store","instanceId","instancedTabId","_react","createElement","id","exports"],"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":";;;;;;;;AAIA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAZA;AACA;AACA;;AAaO,MAAMK,GAAG,GAAG,IAAAC,mBAAU,EAG1B,SAASD,GAAGA,CAAE;EAAEE,QAAQ;EAAEC,KAAK;EAAEC,QAAQ;EAAEC,MAAM;EAAE,GAAGC;AAAW,CAAC,EAAEC,GAAG,EAAG;EAC5E,MAAMC,OAAO,GAAG,IAAAC,uBAAc,EAAC,CAAC;EAChC,IAAK,CAAED,OAAO,EAAG;IAChB,OAAAE,YAAA,oBAAAA,YAAA,gBAAAC,gBAAO,EAAE,mDAAoD,CAAC;IAC9D,OAAO,IAAI;EACZ;EACA,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGL,OAAO;EACrC,MAAMM,cAAc,GAAI,GAAGD,UAAY,IAAIV,KAAO,EAAC;EACnD,OACC,IAAAY,MAAA,CAAAC,aAAA,EAACjB,OAAA,CAAAC,GAAS;IACTO,GAAG,EAAGA,GAAK;IACXK,KAAK,EAAGA,KAAO;IACfK,EAAE,EAAGH,cAAgB;IACrBV,QAAQ,EAAGA,QAAU;IACrBC,MAAM,EAAGA,MAAQ;IAAA,GACZC;EAAU,GAEbJ,QACQ,CAAC;AAEd,CAAE,CAAC;AAACgB,OAAA,CAAAlB,GAAA,GAAAA,GAAA"}

View File

@@ -0,0 +1,45 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TabList = void 0;
var _react = require("react");
var Ariakit = _interopRequireWildcard(require("@ariakit/react"));
var _warning = _interopRequireDefault(require("@wordpress/warning"));
var _element = require("@wordpress/element");
var _context = require("./context");
var _styles = require("./styles");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
/**
* WordPress dependencies
*/
const TabList = (0, _element.forwardRef)(function TabList({
children,
...otherProps
}, ref) {
const context = (0, _context.useTabsContext)();
if (!context) {
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('`Tabs.TabList` must be wrapped in a `Tabs` component.') : void 0;
return null;
}
const {
store
} = context;
return (0, _react.createElement)(Ariakit.TabList, {
ref: ref,
store: store,
render: (0, _react.createElement)(_styles.TabListWrapper, null),
...otherProps
}, children);
});
exports.TabList = TabList;
//# sourceMappingURL=tablist.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Ariakit","_interopRequireWildcard","require","_warning","_interopRequireDefault","_element","_context","_styles","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TabList","forwardRef","children","otherProps","ref","context","useTabsContext","SCRIPT_DEBUG","warning","store","_react","createElement","render","TabListWrapper","exports"],"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":";;;;;;;;AAIA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAMA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAA0C,SAAAM,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAR,wBAAAY,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAjB1C;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAYO,MAAMW,OAAO,GAAG,IAAAC,mBAAU,EAG9B,SAASD,OAAOA,CAAE;EAAEE,QAAQ;EAAE,GAAGC;AAAW,CAAC,EAAEC,GAAG,EAAG;EACvD,MAAMC,OAAO,GAAG,IAAAC,uBAAc,EAAC,CAAC;EAChC,IAAK,CAAED,OAAO,EAAG;IAChB,OAAAE,YAAA,oBAAAA,YAAA,gBAAAC,gBAAO,EAAE,uDAAwD,CAAC;IAClE,OAAO,IAAI;EACZ;EACA,MAAM;IAAEC;EAAM,CAAC,GAAGJ,OAAO;EACzB,OACC,IAAAK,MAAA,CAAAC,aAAA,EAACzC,OAAO,CAAC8B,OAAO;IACfI,GAAG,EAAGA,GAAK;IACXK,KAAK,EAAGA,KAAO;IACfG,MAAM,EAAG,IAAAF,MAAA,CAAAC,aAAA,EAAClC,OAAA,CAAAoC,cAAc,MAAE,CAAG;IAAA,GACxBV;EAAU,GAEbD,QACc,CAAC;AAEpB,CAAE,CAAC;AAACY,OAAA,CAAAd,OAAA,GAAAA,OAAA"}

View File

@@ -0,0 +1,48 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TabPanel = void 0;
var _react = require("react");
var _element = require("@wordpress/element");
var _styles = require("./styles");
var _warning = _interopRequireDefault(require("@wordpress/warning"));
var _context = require("./context");
/**
* WordPress dependencies
*/
const TabPanel = (0, _element.forwardRef)(function TabPanel({
children,
tabId,
focusable = true,
...otherProps
}, ref) {
const context = (0, _context.useTabsContext)();
if (!context) {
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('`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 (0, _react.createElement)(_styles.TabPanel, {
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);
});
exports.TabPanel = TabPanel;
//# sourceMappingURL=tabpanel.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_element","require","_styles","_warning","_interopRequireDefault","_context","TabPanel","forwardRef","children","tabId","focusable","otherProps","ref","context","useTabsContext","SCRIPT_DEBUG","warning","store","instanceId","instancedTabId","selectedId","useState","state","_react","createElement","id","exports"],"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":";;;;;;;;AAIA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAbA;AACA;AACA;;AAcO,MAAMK,QAAQ,GAAG,IAAAC,mBAAU,EAG/B,SAASD,QAAQA,CACnB;EAAEE,QAAQ;EAAEC,KAAK;EAAEC,SAAS,GAAG,IAAI;EAAE,GAAGC;AAAW,CAAC,EACpDC,GAAG,EACF;EACD,MAAMC,OAAO,GAAG,IAAAC,uBAAc,EAAC,CAAC;EAChC,IAAK,CAAED,OAAO,EAAG;IAChB,OAAAE,YAAA,oBAAAA,YAAA,gBAAAC,gBAAO,EAAE,wDAAyD,CAAC;IACnE,OAAO,IAAI;EACZ;EACA,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGL,OAAO;EACrC,MAAMM,cAAc,GAAI,GAAGD,UAAY,IAAIT,KAAO,EAAC;EACnD,MAAMW,UAAU,GAAGH,KAAK,CAACI,QAAQ,CAAIC,KAAK,IAAMA,KAAK,CAACF,UAAW,CAAC;EAElE,OACC,IAAAG,MAAA,CAAAC,aAAA,EAACtB,OAAA,CAAAI,QAAc;IACdM,GAAG,EAAGA,GAAK;IACXK,KAAK,EAAGA;IACR;IACA;IACA;IAAA;IACAQ,EAAE,EAAI,GAAGN,cAAgB,OAAQ;IACjCV,KAAK,EAAGU,cAAgB;IACxBT,SAAS,EAAGA,SAAW;IAAA,GAClBC;EAAU,GAEbS,UAAU,KAAKD,cAAc,IAAIX,QACpB,CAAC;AAEnB,CAAE,CAAC;AAACkB,OAAA,CAAApB,QAAA,GAAAA,QAAA"}

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# 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":""}