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,7 @@
export { default as Toolbar } from './toolbar';
export { default as ToolbarButton } from './toolbar-button';
export { default as ToolbarContext } from './toolbar-context';
export { default as ToolbarDropdownMenu } from './toolbar-dropdown-menu';
export { default as ToolbarGroup } from './toolbar-group';
export { default as ToolbarItem } from './toolbar-item';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["default","Toolbar","ToolbarButton","ToolbarContext","ToolbarDropdownMenu","ToolbarGroup","ToolbarItem"],"sources":["@wordpress/components/src/toolbar/index.js"],"sourcesContent":["export { default as Toolbar } from './toolbar';\nexport { default as ToolbarButton } from './toolbar-button';\nexport { default as ToolbarContext } from './toolbar-context';\nexport { default as ToolbarDropdownMenu } from './toolbar-dropdown-menu';\nexport { default as ToolbarGroup } from './toolbar-group';\nexport { default as ToolbarItem } from './toolbar-item';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,OAAO,QAAQ,WAAW;AAC9C,SAASD,OAAO,IAAIE,aAAa,QAAQ,kBAAkB;AAC3D,SAASF,OAAO,IAAIG,cAAc,QAAQ,mBAAmB;AAC7D,SAASH,OAAO,IAAII,mBAAmB,QAAQ,yBAAyB;AACxE,SAASJ,OAAO,IAAIK,YAAY,QAAQ,iBAAiB;AACzD,SAASL,OAAO,IAAIM,WAAW,QAAQ,gBAAgB"}

View File

@@ -0,0 +1,93 @@
import { createElement } from "react";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { useContext, forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import Button from '../../button';
import ToolbarItem from '../toolbar-item';
import ToolbarContext from '../toolbar-context';
import ToolbarButtonContainer from './toolbar-button-container';
function UnforwardedToolbarButton({
children,
className,
containerClassName,
extraProps,
isActive,
isDisabled,
title,
...props
}, ref) {
const accessibleToolbarState = useContext(ToolbarContext);
if (!accessibleToolbarState) {
return createElement(ToolbarButtonContainer, {
className: containerClassName
}, createElement(Button, {
ref: ref,
icon: props.icon,
label: title,
shortcut: props.shortcut,
"data-subscript": props.subscript,
onClick: event => {
event.stopPropagation();
// TODO: Possible bug; maybe use onClick instead of props.onClick.
if (props.onClick) {
props.onClick(event);
}
},
className: classnames('components-toolbar__control', className),
isPressed: isActive,
disabled: isDisabled,
"data-toolbar-item": true,
...extraProps,
...props
}, children));
}
// ToobarItem will pass all props to the render prop child, which will pass
// all props to Button. This means that ToolbarButton has the same API as
// Button.
return createElement(ToolbarItem, {
className: classnames('components-toolbar-button', className),
...extraProps,
...props,
ref: ref
}, toolbarItemProps => createElement(Button, {
label: title,
isPressed: isActive,
disabled: isDisabled,
...toolbarItemProps
}, children));
}
/**
* ToolbarButton can be used to add actions to a toolbar, usually inside a Toolbar
* or ToolbarGroup when used to create general interfaces.
*
* ```jsx
* import { Toolbar, ToolbarButton } from '@wordpress/components';
* import { edit } from '@wordpress/icons';
*
* function MyToolbar() {
* return (
* <Toolbar label="Options">
* <ToolbarButton
* icon={ edit }
* label="Edit"
* onClick={ () => alert( 'Editing' ) }
* />
* </Toolbar>
* );
* }
* ```
*/
export const ToolbarButton = forwardRef(UnforwardedToolbarButton);
export default ToolbarButton;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
import { createElement } from "react";
/**
* Internal dependencies
*/
const ToolbarButtonContainer = ({
children,
className
}) => createElement("div", {
className: className
}, children);
export default ToolbarButtonContainer;
//# sourceMappingURL=toolbar-button-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["ToolbarButtonContainer","children","className","createElement"],"sources":["@wordpress/components/src/toolbar/toolbar-button/toolbar-button-container.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { ToolbarButtonContainerProps } from './types';\n\nconst ToolbarButtonContainer = ( {\n\tchildren,\n\tclassName,\n}: ToolbarButtonContainerProps ) => (\n\t<div className={ className }>{ children }</div>\n);\n\nexport default ToolbarButtonContainer;\n"],"mappings":";AAAA;AACA;AACA;;AAGA,MAAMA,sBAAsB,GAAGA,CAAE;EAChCC,QAAQ;EACRC;AAC4B,CAAC,KAC7BC,aAAA;EAAKD,SAAS,EAAGA;AAAW,GAAGD,QAAe,CAC9C;AAED,eAAeD,sBAAsB"}

View File

@@ -0,0 +1,7 @@
import { createElement } from "react";
/**
* External dependencies
*/
import { View } from 'react-native';
export default (props => createElement(View, null, props.children));
//# sourceMappingURL=toolbar-button-container.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["View","props","createElement","children"],"sources":["@wordpress/components/src/toolbar/toolbar-button/toolbar-button-container.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\nexport default ( props ) => <View>{ props.children }</View>;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,cAAc;AAEnC,gBAAiBC,KAAK,IAAMC,aAAA,CAACF,IAAI,QAAGC,KAAK,CAACE,QAAgB,CAAC"}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/toolbar/toolbar-button/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\nexport type ToolbarButtonProps = {\n\t/**\n\t * Children to be rendered inside the button.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * An optional class name for the button container.\n\t */\n\tcontainerClassName?: string;\n\t/**\n\t * Additional props to be passed alongside props.\n\t */\n\textraProps?: any;\n\t/**\n\t * Indicates if the button is active.\n\t */\n\tisActive?: boolean;\n\t/**\n\t * Indicates if the button is disabled.\n\t */\n\tisDisabled?: boolean;\n\t/**\n\t * An optional subscript for the button.\n\t */\n\tsubscript?: string;\n\t/**\n\t * An optional title/label for the button.\n\t */\n\ttitle?: string;\n};\n\nexport type ToolbarButtonContainerProps = {\n\t/**\n\t * Children to be rendered inside the button container.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * An optional class name for the button container.\n\t */\n\tclassName?: string;\n};\n"],"mappings":""}

View File

@@ -0,0 +1,12 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
/**
* WordPress dependencies
*/
import { createContext } from '@wordpress/element';
const ToolbarContext = createContext(undefined);
export default ToolbarContext;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createContext","ToolbarContext","undefined"],"sources":["@wordpress/components/src/toolbar/toolbar-context/index.ts"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst ToolbarContext = createContext< Ariakit.ToolbarStore | undefined >(\n\tundefined\n);\n\nexport default ToolbarContext;\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,oBAAoB;AAElD,MAAMC,cAAc,GAAGD,aAAa,CACnCE,SACD,CAAC;AAED,eAAeD,cAAc"}

View File

@@ -0,0 +1,40 @@
import { createElement } from "react";
/**
* WordPress dependencies
*/
import { forwardRef, useContext } from '@wordpress/element';
/**
* External dependencies
*/
/**
* Internal dependencies
*/
import ToolbarItem from '../toolbar-item';
import ToolbarContext from '../toolbar-context';
import DropdownMenu from '../../dropdown-menu';
function ToolbarDropdownMenu(props, ref) {
const accessibleToolbarState = useContext(ToolbarContext);
if (!accessibleToolbarState) {
return createElement(DropdownMenu, {
...props
});
}
// ToolbarItem will pass all props to the render prop child, which will pass
// all props to the toggle of DropdownMenu. This means that ToolbarDropdownMenu
// has the same API as DropdownMenu.
return createElement(ToolbarItem, {
ref: ref,
...props.toggleProps
}, toolbarItemProps => createElement(DropdownMenu, {
...props,
popoverProps: {
...props.popoverProps
},
toggleProps: toolbarItemProps
}));
}
export default forwardRef(ToolbarDropdownMenu);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["forwardRef","useContext","ToolbarItem","ToolbarContext","DropdownMenu","ToolbarDropdownMenu","props","ref","accessibleToolbarState","createElement","toggleProps","toolbarItemProps","popoverProps"],"sources":["@wordpress/components/src/toolbar/toolbar-dropdown-menu/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\n\n/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport ToolbarItem from '../toolbar-item';\nimport ToolbarContext from '../toolbar-context';\nimport DropdownMenu from '../../dropdown-menu';\nimport type { DropdownMenuProps } from '../../dropdown-menu/types';\n\nfunction ToolbarDropdownMenu(\n\tprops: DropdownMenuProps,\n\tref: ForwardedRef< any >\n) {\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tif ( ! accessibleToolbarState ) {\n\t\treturn <DropdownMenu { ...props } />;\n\t}\n\n\t// ToolbarItem will pass all props to the render prop child, which will pass\n\t// all props to the toggle of DropdownMenu. This means that ToolbarDropdownMenu\n\t// has the same API as DropdownMenu.\n\treturn (\n\t\t<ToolbarItem ref={ ref } { ...props.toggleProps }>\n\t\t\t{ ( toolbarItemProps ) => (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t...props.popoverProps,\n\t\t\t\t\t} }\n\t\t\t\t\ttoggleProps={ toolbarItemProps }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</ToolbarItem>\n\t);\n}\n\nexport default forwardRef( ToolbarDropdownMenu );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,UAAU,QAAQ,oBAAoB;;AAE3D;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOC,WAAW,MAAM,iBAAiB;AACzC,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,OAAOC,YAAY,MAAM,qBAAqB;AAG9C,SAASC,mBAAmBA,CAC3BC,KAAwB,EACxBC,GAAwB,EACvB;EACD,MAAMC,sBAAsB,GAAGP,UAAU,CAAEE,cAAe,CAAC;EAE3D,IAAK,CAAEK,sBAAsB,EAAG;IAC/B,OAAOC,aAAA,CAACL,YAAY;MAAA,GAAME;IAAK,CAAI,CAAC;EACrC;;EAEA;EACA;EACA;EACA,OACCG,aAAA,CAACP,WAAW;IAACK,GAAG,EAAGA,GAAK;IAAA,GAAMD,KAAK,CAACI;EAAW,GAC1CC,gBAAgB,IACnBF,aAAA,CAACL,YAAY;IAAA,GACPE,KAAK;IACVM,YAAY,EAAG;MACd,GAAGN,KAAK,CAACM;IACV,CAAG;IACHF,WAAW,EAAGC;EAAkB,CAChC,CAEU,CAAC;AAEhB;AAEA,eAAeX,UAAU,CAAEK,mBAAoB,CAAC"}

View File

@@ -0,0 +1,98 @@
import { createElement } from "react";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { useContext } from '@wordpress/element';
/**
* Internal dependencies
*/
import ToolbarButton from '../toolbar-button';
import ToolbarGroupContainer from './toolbar-group-container';
import ToolbarGroupCollapsed from './toolbar-group-collapsed';
import ToolbarContext from '../toolbar-context';
function isNestedArray(arr) {
return Array.isArray(arr) && Array.isArray(arr[0]);
}
/**
* Renders a collapsible group of controls
*
* The `controls` prop accepts an array of sets. A set is an array of controls.
* Controls have the following shape:
*
* ```
* {
* icon: string,
* title: string,
* subscript: string,
* onClick: Function,
* isActive: boolean,
* isDisabled: boolean
* }
* ```
*
* For convenience it is also possible to pass only an array of controls. It is
* then assumed this is the only set.
*
* Either `controls` or `children` is required, otherwise this components
* renders nothing.
*
* @param props Component props.
* @param [props.controls] The controls to render in this toolbar.
* @param [props.children] Any other things to render inside the toolbar besides the controls.
* @param [props.className] Class to set on the container div.
* @param [props.isCollapsed] Turns ToolbarGroup into a dropdown menu.
* @param [props.title] ARIA label for dropdown menu if is collapsed.
*/
function ToolbarGroup({
controls = [],
children,
className,
isCollapsed,
title,
...props
}) {
// It'll contain state if `ToolbarGroup` is being used within
// `<Toolbar label="label" />`
const accessibleToolbarState = useContext(ToolbarContext);
if ((!controls || !controls.length) && !children) {
return null;
}
const finalClassName = classnames(
// Unfortunately, there's legacy code referencing to `.components-toolbar`
// So we can't get rid of it
accessibleToolbarState ? 'components-toolbar-group' : 'components-toolbar', className);
// Normalize controls to nested array of objects (sets of controls)
let controlSets;
if (isNestedArray(controls)) {
controlSets = controls;
} else {
controlSets = [controls];
}
if (isCollapsed) {
return createElement(ToolbarGroupCollapsed, {
label: title,
controls: controlSets,
className: finalClassName,
children: children,
...props
});
}
return createElement(ToolbarGroupContainer, {
className: finalClassName,
...props
}, controlSets?.flatMap((controlSet, indexOfSet) => controlSet.map((control, indexOfControl) => createElement(ToolbarButton, {
key: [indexOfSet, indexOfControl].join(),
containerClassName: indexOfSet > 0 && indexOfControl === 0 ? 'has-left-divider' : undefined,
...control
}))), children);
}
export default ToolbarGroup;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,37 @@
import { createElement } from "react";
/**
* WordPress dependencies
*/
import { useContext } from '@wordpress/element';
/**
* Internal dependencies
*/
import DropdownMenu from '../../dropdown-menu';
import ToolbarContext from '../toolbar-context';
import ToolbarItem from '../toolbar-item';
function ToolbarGroupCollapsed({
controls = [],
toggleProps,
...props
}) {
// It'll contain state if `ToolbarGroup` is being used within
// `<Toolbar label="label" />`
const accessibleToolbarState = useContext(ToolbarContext);
const renderDropdownMenu = internalToggleProps => createElement(DropdownMenu, {
controls: controls,
toggleProps: {
...internalToggleProps,
'data-toolbar-item': true
},
...props
});
if (accessibleToolbarState) {
return createElement(ToolbarItem, {
...toggleProps
}, renderDropdownMenu);
}
return renderDropdownMenu(toggleProps);
}
export default ToolbarGroupCollapsed;
//# sourceMappingURL=toolbar-group-collapsed.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useContext","DropdownMenu","ToolbarContext","ToolbarItem","ToolbarGroupCollapsed","controls","toggleProps","props","accessibleToolbarState","renderDropdownMenu","internalToggleProps","createElement"],"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-collapsed.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport ToolbarContext from '../toolbar-context';\nimport ToolbarItem from '../toolbar-item';\nimport type { ToolbarGroupCollapsedProps } from './types';\nimport type { DropdownMenuProps } from '../../dropdown-menu/types';\n\nfunction ToolbarGroupCollapsed( {\n\tcontrols = [],\n\ttoggleProps,\n\t...props\n}: ToolbarGroupCollapsedProps ) {\n\t// It'll contain state if `ToolbarGroup` is being used within\n\t// `<Toolbar label=\"label\" />`\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tconst renderDropdownMenu = (\n\t\tinternalToggleProps?: DropdownMenuProps[ 'toggleProps' ]\n\t) => (\n\t\t<DropdownMenu\n\t\t\tcontrols={ controls }\n\t\t\ttoggleProps={ {\n\t\t\t\t...internalToggleProps,\n\t\t\t\t'data-toolbar-item': true,\n\t\t\t} }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n\n\tif ( accessibleToolbarState ) {\n\t\treturn (\n\t\t\t<ToolbarItem { ...toggleProps }>{ renderDropdownMenu }</ToolbarItem>\n\t\t);\n\t}\n\n\treturn renderDropdownMenu( toggleProps );\n}\n\nexport default ToolbarGroupCollapsed;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,qBAAqB;AAC9C,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,OAAOC,WAAW,MAAM,iBAAiB;AAIzC,SAASC,qBAAqBA,CAAE;EAC/BC,QAAQ,GAAG,EAAE;EACbC,WAAW;EACX,GAAGC;AACwB,CAAC,EAAG;EAC/B;EACA;EACA,MAAMC,sBAAsB,GAAGR,UAAU,CAAEE,cAAe,CAAC;EAE3D,MAAMO,kBAAkB,GACvBC,mBAAwD,IAExDC,aAAA,CAACV,YAAY;IACZI,QAAQ,EAAGA,QAAU;IACrBC,WAAW,EAAG;MACb,GAAGI,mBAAmB;MACtB,mBAAmB,EAAE;IACtB,CAAG;IAAA,GACEH;EAAK,CACV,CACD;EAED,IAAKC,sBAAsB,EAAG;IAC7B,OACCG,aAAA,CAACR,WAAW;MAAA,GAAMG;IAAW,GAAKG,kBAAiC,CAAC;EAEtE;EAEA,OAAOA,kBAAkB,CAAEH,WAAY,CAAC;AACzC;AAEA,eAAeF,qBAAqB"}

View File

@@ -0,0 +1,29 @@
import { createElement } from "react";
/**
* External dependencies
*/
import { View } from 'react-native';
/**
* WordPress dependencies
*/
import { withPreferredColorScheme } from '@wordpress/compose';
/**
* Internal dependencies
*/
import DropdownMenu from '../../dropdown-menu';
import styles from './style.scss';
function ToolbarGroupCollapsed({
controls = [],
getStylesFromColorScheme,
passedStyle,
...props
}) {
return createElement(View, {
style: [getStylesFromColorScheme(styles.container, styles.containerDark), passedStyle]
}, createElement(DropdownMenu, {
controls: controls,
...props
}));
}
export default withPreferredColorScheme(ToolbarGroupCollapsed);
//# sourceMappingURL=toolbar-group-collapsed.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["View","withPreferredColorScheme","DropdownMenu","styles","ToolbarGroupCollapsed","controls","getStylesFromColorScheme","passedStyle","props","createElement","style","container","containerDark"],"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-collapsed.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n/**\n * WordPress dependencies\n */\nimport { withPreferredColorScheme } from '@wordpress/compose';\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport styles from './style.scss';\n\nfunction ToolbarGroupCollapsed( {\n\tcontrols = [],\n\tgetStylesFromColorScheme,\n\tpassedStyle,\n\t...props\n} ) {\n\treturn (\n\t\t<View\n\t\t\tstyle={ [\n\t\t\t\tgetStylesFromColorScheme(\n\t\t\t\t\tstyles.container,\n\t\t\t\t\tstyles.containerDark\n\t\t\t\t),\n\t\t\t\tpassedStyle,\n\t\t\t] }\n\t\t>\n\t\t\t<DropdownMenu controls={ controls } { ...props } />\n\t\t</View>\n\t);\n}\n\nexport default withPreferredColorScheme( ToolbarGroupCollapsed );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,cAAc;AACnC;AACA;AACA;AACA,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D;AACA;AACA;AACA,OAAOC,YAAY,MAAM,qBAAqB;AAC9C,OAAOC,MAAM,MAAM,cAAc;AAEjC,SAASC,qBAAqBA,CAAE;EAC/BC,QAAQ,GAAG,EAAE;EACbC,wBAAwB;EACxBC,WAAW;EACX,GAAGC;AACJ,CAAC,EAAG;EACH,OACCC,aAAA,CAACT,IAAI;IACJU,KAAK,EAAG,CACPJ,wBAAwB,CACvBH,MAAM,CAACQ,SAAS,EAChBR,MAAM,CAACS,aACR,CAAC,EACDL,WAAW;EACT,GAEHE,aAAA,CAACP,YAAY;IAACG,QAAQ,EAAGA,QAAU;IAAA,GAAMG;EAAK,CAAI,CAC7C,CAAC;AAET;AAEA,eAAeP,wBAAwB,CAAEG,qBAAsB,CAAC"}

View File

@@ -0,0 +1,15 @@
import { createElement } from "react";
/**
* Internal dependencies
*/
const ToolbarGroupContainer = ({
className,
children,
...props
}) => createElement("div", {
className: className,
...props
}, children);
export default ToolbarGroupContainer;
//# sourceMappingURL=toolbar-group-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["ToolbarGroupContainer","className","children","props","createElement"],"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-container.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport type { ToolbarGroupContainerProps } from './types';\n\nconst ToolbarGroupContainer = ( {\n\tclassName,\n\tchildren,\n\t...props\n}: WordPressComponentProps< ToolbarGroupContainerProps, 'div', false > ) => (\n\t<div className={ className } { ...props }>\n\t\t{ children }\n\t</div>\n);\nexport default ToolbarGroupContainer;\n"],"mappings":";AAAA;AACA;AACA;;AAIA,MAAMA,qBAAqB,GAAGA,CAAE;EAC/BC,SAAS;EACTC,QAAQ;EACR,GAAGC;AACiE,CAAC,KACrEC,aAAA;EAAKH,SAAS,EAAGA,SAAW;EAAA,GAAME;AAAK,GACpCD,QACE,CACL;AACD,eAAeF,qBAAqB"}

View File

@@ -0,0 +1,28 @@
import { createElement } from "react";
/**
* External dependencies
*/
import { StyleSheet, View } from 'react-native';
/**
* WordPress dependencies
*/
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
/**
* Internal dependencies
*/
import styles from './style.scss';
const ToolbarGroupContainer = ({
passedStyle,
children
}) => {
const groupStyles = [usePreferredColorSchemeStyle(styles.container, styles.containerDark), {
borderLeftWidth: StyleSheet.hairlineWidth
}, passedStyle];
return createElement(View, {
style: groupStyles
}, children);
};
export default ToolbarGroupContainer;
//# sourceMappingURL=toolbar-group-container.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["StyleSheet","View","usePreferredColorSchemeStyle","styles","ToolbarGroupContainer","passedStyle","children","groupStyles","container","containerDark","borderLeftWidth","hairlineWidth","createElement","style"],"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-container.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { StyleSheet, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst ToolbarGroupContainer = ( { passedStyle, children } ) => {\n\tconst groupStyles = [\n\t\tusePreferredColorSchemeStyle( styles.container, styles.containerDark ),\n\t\t{ borderLeftWidth: StyleSheet.hairlineWidth },\n\t\tpassedStyle,\n\t];\n\n\treturn <View style={ groupStyles }>{ children }</View>;\n};\n\nexport default ToolbarGroupContainer;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,IAAI,QAAQ,cAAc;;AAE/C;AACA;AACA;AACA,SAASC,4BAA4B,QAAQ,oBAAoB;;AAEjE;AACA;AACA;AACA,OAAOC,MAAM,MAAM,cAAc;AAEjC,MAAMC,qBAAqB,GAAGA,CAAE;EAAEC,WAAW;EAAEC;AAAS,CAAC,KAAM;EAC9D,MAAMC,WAAW,GAAG,CACnBL,4BAA4B,CAAEC,MAAM,CAACK,SAAS,EAAEL,MAAM,CAACM,aAAc,CAAC,EACtE;IAAEC,eAAe,EAAEV,UAAU,CAACW;EAAc,CAAC,EAC7CN,WAAW,CACX;EAED,OAAOO,aAAA,CAACX,IAAI;IAACY,KAAK,EAAGN;EAAa,GAAGD,QAAgB,CAAC;AACvD,CAAC;AAED,eAAeF,qBAAqB"}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/toolbar/toolbar-group/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tDropdownMenuProps,\n\tDropdownOption,\n} from '../../dropdown-menu/types';\n\n/**\n * WordPress dependencies\n */\nimport type { Props as IconProps } from '../../icon';\n\nexport type ToolbarGroupControls = DropdownOption & {\n\t/**\n\t * An optional subscript associated to the control.\n\t */\n\tsubscript?: string;\n};\n\ntype ToolbarGroupPropsBase = {\n\t/**\n\t * The controls to render in this toolbar.\n\t */\n\tcontrols?: ToolbarGroupControls[] | ToolbarGroupControls[][];\n\n\t/**\n\t * Class to set on the container div.\n\t */\n\tclassName?: string;\n\n\t/**\n\t * Any other things to render inside the toolbar besides the controls.\n\t */\n\tchildren?: ReactNode;\n\n\t/**\n\t * The Dashicon icon slug to be shown for the option.\n\t */\n\ticon?: IconProps[ 'icon' ];\n};\n\nexport type ToolbarGroupProps = ToolbarGroupPropsBase &\n\t(\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * When true, turns `ToolbarGroup` into a dropdown menu.\n\t\t\t\t */\n\t\t\t\tisCollapsed?: false;\n\t\t\t\t/**\n\t\t\t\t * Any other things to render inside the toolbar besides the controls.\n\t\t\t\t */\n\t\t\t\tchildren?: ReactNode;\n\t\t\t\ttitle?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * When true, turns `ToolbarGroup` into a dropdown menu.\n\t\t\t\t */\n\t\t\t\tisCollapsed: true;\n\t\t\t\t/**\n\t\t\t\t * Any other things to render inside the toolbar besides the controls.\n\t\t\t\t */\n\t\t\t\tchildren?: ToolbarGroupCollapsedProps[ 'children' ];\n\t\t\t\t/**\n\t\t\t\t * ARIA label for dropdown menu if is collapsed.\n\t\t\t\t */\n\t\t\t\ttitle: string;\n\t\t }\n\t);\n\nexport type ToolbarGroupCollapsedProps = DropdownMenuProps;\n\nexport type ToolbarGroupContainerProps = {\n\t/**\n\t * Children to be rendered inside the toolbar.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * Class to set on the container div.\n\t */\n\tclassName?: string;\n\t/**\n\t * Props to be passed.\n\t */\n\tprops?: any;\n};\n"],"mappings":""}

View File

@@ -0,0 +1,52 @@
import { createElement } from "react";
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import * as Ariakit from '@ariakit/react';
/**
* WordPress dependencies
*/
import { forwardRef, useContext } from '@wordpress/element';
import warning from '@wordpress/warning';
/**
* Internal dependencies
*/
import ToolbarContext from '../toolbar-context';
function ToolbarItem({
children,
as: Component,
...props
}, ref) {
const accessibleToolbarStore = useContext(ToolbarContext);
const isRenderProp = typeof children === 'function';
if (!isRenderProp && !Component) {
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? warning('`ToolbarItem` is a generic headless component. You must pass either a `children` prop as a function or an `as` prop as a component. ' + 'See https://developer.wordpress.org/block-editor/components/toolbar-item/') : void 0;
return null;
}
const allProps = {
...props,
ref,
'data-toolbar-item': true
};
if (!accessibleToolbarStore) {
if (Component) {
return createElement(Component, {
...allProps
}, children);
}
if (!isRenderProp) {
return null;
}
return children(allProps);
}
const render = isRenderProp ? children : Component && createElement(Component, null, children);
return createElement(Ariakit.ToolbarItem, {
...allProps,
store: accessibleToolbarStore,
render: render
});
}
export default forwardRef(ToolbarItem);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Ariakit","forwardRef","useContext","warning","ToolbarContext","ToolbarItem","children","as","Component","props","ref","accessibleToolbarStore","isRenderProp","SCRIPT_DEBUG","allProps","createElement","render","store"],"sources":["@wordpress/components/src/toolbar/toolbar-item/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport ToolbarContext from '../toolbar-context';\nimport type { ToolbarItemProps } from './types';\n\nfunction ToolbarItem(\n\t{ children, as: Component, ...props }: ToolbarItemProps,\n\tref: ForwardedRef< any >\n) {\n\tconst accessibleToolbarStore = useContext( ToolbarContext );\n\tconst isRenderProp = typeof children === 'function';\n\n\tif ( ! isRenderProp && ! Component ) {\n\t\twarning(\n\t\t\t'`ToolbarItem` is a generic headless component. You must pass either a `children` prop as a function or an `as` prop as a component. ' +\n\t\t\t\t'See https://developer.wordpress.org/block-editor/components/toolbar-item/'\n\t\t);\n\t\treturn null;\n\t}\n\n\tconst allProps = { ...props, ref, 'data-toolbar-item': true };\n\n\tif ( ! accessibleToolbarStore ) {\n\t\tif ( Component ) {\n\t\t\treturn <Component { ...allProps }>{ children }</Component>;\n\t\t}\n\t\tif ( ! isRenderProp ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn children( allProps );\n\t}\n\n\tconst render = isRenderProp\n\t\t? children\n\t\t: Component && <Component>{ children }</Component>;\n\n\treturn (\n\t\t<Ariakit.ToolbarItem\n\t\t\t{ ...allProps }\n\t\t\tstore={ accessibleToolbarStore }\n\t\t\trender={ render }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( ToolbarItem );\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AAGzC;AACA;AACA;AACA,SAASC,UAAU,EAAEC,UAAU,QAAQ,oBAAoB;AAC3D,OAAOC,OAAO,MAAM,oBAAoB;;AAExC;AACA;AACA;AACA,OAAOC,cAAc,MAAM,oBAAoB;AAG/C,SAASC,WAAWA,CACnB;EAAEC,QAAQ;EAAEC,EAAE,EAAEC,SAAS;EAAE,GAAGC;AAAwB,CAAC,EACvDC,GAAwB,EACvB;EACD,MAAMC,sBAAsB,GAAGT,UAAU,CAAEE,cAAe,CAAC;EAC3D,MAAMQ,YAAY,GAAG,OAAON,QAAQ,KAAK,UAAU;EAEnD,IAAK,CAAEM,YAAY,IAAI,CAAEJ,SAAS,EAAG;IACpC,OAAAK,YAAA,oBAAAA,YAAA,YAAAV,OAAO,CACN,sIAAsI,GACrI,2EACF,CAAC;IACD,OAAO,IAAI;EACZ;EAEA,MAAMW,QAAQ,GAAG;IAAE,GAAGL,KAAK;IAAEC,GAAG;IAAE,mBAAmB,EAAE;EAAK,CAAC;EAE7D,IAAK,CAAEC,sBAAsB,EAAG;IAC/B,IAAKH,SAAS,EAAG;MAChB,OAAOO,aAAA,CAACP,SAAS;QAAA,GAAMM;MAAQ,GAAKR,QAAqB,CAAC;IAC3D;IACA,IAAK,CAAEM,YAAY,EAAG;MACrB,OAAO,IAAI;IACZ;IACA,OAAON,QAAQ,CAAEQ,QAAS,CAAC;EAC5B;EAEA,MAAME,MAAM,GAAGJ,YAAY,GACxBN,QAAQ,GACRE,SAAS,IAAIO,aAAA,CAACP,SAAS,QAAGF,QAAqB,CAAC;EAEnD,OACCS,aAAA,CAACf,OAAO,CAACK,WAAW;IAAA,GACdS,QAAQ;IACbG,KAAK,EAAGN,sBAAwB;IAChCK,MAAM,EAAGA;EAAQ,CACjB,CAAC;AAEJ;AAEA,eAAef,UAAU,CAAEI,WAAY,CAAC"}

View File

@@ -0,0 +1,20 @@
/**
* WordPress dependencies
*/
import { forwardRef } from '@wordpress/element';
import warning from '@wordpress/warning';
function ToolbarItem({
children,
...props
}, ref) {
if (typeof children !== 'function') {
typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? warning('`ToolbarItem` is a generic headless component that accepts only function children props') : void 0;
return null;
}
return children({
...props,
ref
});
}
export default forwardRef(ToolbarItem);
//# sourceMappingURL=index.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["forwardRef","warning","ToolbarItem","children","props","ref","SCRIPT_DEBUG"],"sources":["@wordpress/components/src/toolbar/toolbar-item/index.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\nfunction ToolbarItem( { children, ...props }, ref ) {\n\tif ( typeof children !== 'function' ) {\n\t\twarning(\n\t\t\t'`ToolbarItem` is a generic headless component that accepts only function children props'\n\t\t);\n\t\treturn null;\n\t}\n\treturn children( { ...props, ref } );\n}\n\nexport default forwardRef( ToolbarItem );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,oBAAoB;AAC/C,OAAOC,OAAO,MAAM,oBAAoB;AAExC,SAASC,WAAWA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,EAAG;EACnD,IAAK,OAAOF,QAAQ,KAAK,UAAU,EAAG;IACrC,OAAAG,YAAA,oBAAAA,YAAA,YAAAL,OAAO,CACN,yFACD,CAAC;IACD,OAAO,IAAI;EACZ;EACA,OAAOE,QAAQ,CAAE;IAAE,GAAGC,KAAK;IAAEC;EAAI,CAAE,CAAC;AACrC;AAEA,eAAeL,UAAU,CAAEE,WAAY,CAAC"}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/toolbar/toolbar-item/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tReactElement,\n\tReactNode,\n\tElementType,\n\tHTMLAttributes,\n\tRefAttributes,\n} from 'react';\n\nexport type ToolbarItemProps = Omit< HTMLAttributes< any >, 'children' > & {\n\t/**\n\t * Component type that will be used to render the toolbar item.\n\t */\n\tas?: ElementType;\n\t/**\n\t * A function that receives the props that should be spread onto the element\n\t * that will be rendered as a toolbar item. If the `as` prop is not provided,\n\t * this prop will accept a ReactNode instead.\n\t */\n\tchildren?:\n\t\t| ReactNode\n\t\t| ( (\n\t\t\t\tprops: HTMLAttributes< any > & RefAttributes< any >\n\t\t ) => ReactElement | null );\n};\n"],"mappings":""}

View File

@@ -0,0 +1,89 @@
import { createElement } from "react";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { forwardRef, useMemo } from '@wordpress/element';
import deprecated from '@wordpress/deprecated';
/**
* Internal dependencies
*/
import ToolbarGroup from '../toolbar-group';
import ToolbarContainer from './toolbar-container';
import { ContextSystemProvider } from '../../context';
function UnforwardedToolbar({
className,
label,
variant,
...props
}, ref) {
const isVariantDefined = variant !== undefined;
const contextSystemValue = useMemo(() => {
if (isVariantDefined) {
return {};
}
return {
DropdownMenu: {
variant: 'toolbar'
},
Dropdown: {
variant: 'toolbar'
}
};
}, [isVariantDefined]);
if (!label) {
deprecated('Using Toolbar without label prop', {
since: '5.6',
alternative: 'ToolbarGroup component',
link: 'https://developer.wordpress.org/block-editor/components/toolbar/'
});
// Extracting title from `props` because `ToolbarGroup` doesn't accept it.
const {
title: _title,
...restProps
} = props;
return createElement(ToolbarGroup, {
isCollapsed: false,
...restProps,
className: className
});
}
// `ToolbarGroup` already uses components-toolbar for compatibility reasons.
const finalClassName = classnames('components-accessible-toolbar', className, variant && `is-${variant}`);
return createElement(ContextSystemProvider, {
value: contextSystemValue
}, createElement(ToolbarContainer, {
className: finalClassName,
label: label,
ref: ref,
...props
}));
}
/**
* Renders a toolbar.
*
* To add controls, simply pass `ToolbarButton` components as children.
*
* ```jsx
* import { Toolbar, ToolbarButton } from '@wordpress/components';
* import { formatBold, formatItalic, link } from '@wordpress/icons';
*
* function MyToolbar() {
* return (
* <Toolbar label="Options">
* <ToolbarButton icon={ formatBold } label="Bold" />
* <ToolbarButton icon={ formatItalic } label="Italic" />
* <ToolbarButton icon={ link } label="Link" />
* </Toolbar>
* );
* }
* ```
*/
export const Toolbar = forwardRef(UnforwardedToolbar);
export default Toolbar;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["classnames","forwardRef","useMemo","deprecated","ToolbarGroup","ToolbarContainer","ContextSystemProvider","UnforwardedToolbar","className","label","variant","props","ref","isVariantDefined","undefined","contextSystemValue","DropdownMenu","Dropdown","since","alternative","link","title","_title","restProps","createElement","isCollapsed","finalClassName","value","Toolbar"],"sources":["@wordpress/components/src/toolbar/toolbar/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport ToolbarGroup from '../toolbar-group';\nimport ToolbarContainer from './toolbar-container';\nimport type { ToolbarProps } from './types';\nimport type { WordPressComponentProps } from '../../context';\nimport { ContextSystemProvider } from '../../context';\n\nfunction UnforwardedToolbar(\n\t{\n\t\tclassName,\n\t\tlabel,\n\t\tvariant,\n\t\t...props\n\t}: WordPressComponentProps< ToolbarProps, 'div', false >,\n\tref: ForwardedRef< any >\n) {\n\tconst isVariantDefined = variant !== undefined;\n\tconst contextSystemValue = useMemo( () => {\n\t\tif ( isVariantDefined ) {\n\t\t\treturn {};\n\t\t}\n\t\treturn {\n\t\t\tDropdownMenu: {\n\t\t\t\tvariant: 'toolbar',\n\t\t\t},\n\t\t\tDropdown: {\n\t\t\t\tvariant: 'toolbar',\n\t\t\t},\n\t\t};\n\t}, [ isVariantDefined ] );\n\n\tif ( ! label ) {\n\t\tdeprecated( 'Using Toolbar without label prop', {\n\t\t\tsince: '5.6',\n\t\t\talternative: 'ToolbarGroup component',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/components/toolbar/',\n\t\t} );\n\t\t// Extracting title from `props` because `ToolbarGroup` doesn't accept it.\n\t\tconst { title: _title, ...restProps } = props;\n\t\treturn (\n\t\t\t<ToolbarGroup\n\t\t\t\tisCollapsed={ false }\n\t\t\t\t{ ...restProps }\n\t\t\t\tclassName={ className }\n\t\t\t/>\n\t\t);\n\t}\n\t// `ToolbarGroup` already uses components-toolbar for compatibility reasons.\n\tconst finalClassName = classnames(\n\t\t'components-accessible-toolbar',\n\t\tclassName,\n\t\tvariant && `is-${ variant }`\n\t);\n\n\treturn (\n\t\t<ContextSystemProvider value={ contextSystemValue }>\n\t\t\t<ToolbarContainer\n\t\t\t\tclassName={ finalClassName }\n\t\t\t\tlabel={ label }\n\t\t\t\tref={ ref }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</ContextSystemProvider>\n\t);\n}\n\n/**\n * Renders a toolbar.\n *\n * To add controls, simply pass `ToolbarButton` components as children.\n *\n * ```jsx\n * import { Toolbar, ToolbarButton } from '@wordpress/components';\n * import { formatBold, formatItalic, link } from '@wordpress/icons';\n *\n * function MyToolbar() {\n * return (\n * <Toolbar label=\"Options\">\n * <ToolbarButton icon={ formatBold } label=\"Bold\" />\n * <ToolbarButton icon={ formatItalic } label=\"Italic\" />\n * <ToolbarButton icon={ link } label=\"Link\" />\n * </Toolbar>\n * );\n * }\n * ```\n */\nexport const Toolbar = forwardRef( UnforwardedToolbar );\nexport default Toolbar;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;AAGnC;AACA;AACA;AACA,SAASC,UAAU,EAAEC,OAAO,QAAQ,oBAAoB;AACxD,OAAOC,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,gBAAgB,MAAM,qBAAqB;AAGlD,SAASC,qBAAqB,QAAQ,eAAe;AAErD,SAASC,kBAAkBA,CAC1B;EACCC,SAAS;EACTC,KAAK;EACLC,OAAO;EACP,GAAGC;AACmD,CAAC,EACxDC,GAAwB,EACvB;EACD,MAAMC,gBAAgB,GAAGH,OAAO,KAAKI,SAAS;EAC9C,MAAMC,kBAAkB,GAAGb,OAAO,CAAE,MAAM;IACzC,IAAKW,gBAAgB,EAAG;MACvB,OAAO,CAAC,CAAC;IACV;IACA,OAAO;MACNG,YAAY,EAAE;QACbN,OAAO,EAAE;MACV,CAAC;MACDO,QAAQ,EAAE;QACTP,OAAO,EAAE;MACV;IACD,CAAC;EACF,CAAC,EAAE,CAAEG,gBAAgB,CAAG,CAAC;EAEzB,IAAK,CAAEJ,KAAK,EAAG;IACdN,UAAU,CAAE,kCAAkC,EAAE;MAC/Ce,KAAK,EAAE,KAAK;MACZC,WAAW,EAAE,wBAAwB;MACrCC,IAAI,EAAE;IACP,CAAE,CAAC;IACH;IACA,MAAM;MAAEC,KAAK,EAAEC,MAAM;MAAE,GAAGC;IAAU,CAAC,GAAGZ,KAAK;IAC7C,OACCa,aAAA,CAACpB,YAAY;MACZqB,WAAW,EAAG,KAAO;MAAA,GAChBF,SAAS;MACdf,SAAS,EAAGA;IAAW,CACvB,CAAC;EAEJ;EACA;EACA,MAAMkB,cAAc,GAAG1B,UAAU,CAChC,+BAA+B,EAC/BQ,SAAS,EACTE,OAAO,IAAK,MAAMA,OAAS,EAC5B,CAAC;EAED,OACCc,aAAA,CAAClB,qBAAqB;IAACqB,KAAK,EAAGZ;EAAoB,GAClDS,aAAA,CAACnB,gBAAgB;IAChBG,SAAS,EAAGkB,cAAgB;IAC5BjB,KAAK,EAAGA,KAAO;IACfG,GAAG,EAAGA,GAAK;IAAA,GACND;EAAK,CACV,CACqB,CAAC;AAE1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMiB,OAAO,GAAG3B,UAAU,CAAEM,kBAAmB,CAAC;AACvD,eAAeqB,OAAO"}

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 { forwardRef } from '@wordpress/element';
import { isRTL } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import ToolbarContext from '../toolbar-context';
function UnforwardedToolbarContainer({
label,
...props
}, ref) {
const toolbarStore = Ariakit.useToolbarStore({
focusLoop: true,
rtl: isRTL()
});
return (
// This will provide state for `ToolbarButton`'s
createElement(ToolbarContext.Provider, {
value: toolbarStore
}, createElement(Ariakit.Toolbar, {
ref: ref,
"aria-label": label,
store: toolbarStore,
...props
}))
);
}
export const ToolbarContainer = forwardRef(UnforwardedToolbarContainer);
export default ToolbarContainer;
//# sourceMappingURL=toolbar-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Ariakit","forwardRef","isRTL","ToolbarContext","UnforwardedToolbarContainer","label","props","ref","toolbarStore","useToolbarStore","focusLoop","rtl","createElement","Provider","value","Toolbar","store","ToolbarContainer"],"sources":["@wordpress/components/src/toolbar/toolbar/toolbar-container.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ToolbarContext from '../toolbar-context';\nimport type { ToolbarProps } from './types';\nimport type { WordPressComponentProps } from '../../context';\n\nfunction UnforwardedToolbarContainer(\n\t{ label, ...props }: WordPressComponentProps< ToolbarProps, 'div', false >,\n\tref: ForwardedRef< any >\n) {\n\tconst toolbarStore = Ariakit.useToolbarStore( {\n\t\tfocusLoop: true,\n\t\trtl: isRTL(),\n\t} );\n\n\treturn (\n\t\t// This will provide state for `ToolbarButton`'s\n\t\t<ToolbarContext.Provider value={ toolbarStore }>\n\t\t\t<Ariakit.Toolbar\n\t\t\t\tref={ ref }\n\t\t\t\taria-label={ label }\n\t\t\t\tstore={ toolbarStore }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</ToolbarContext.Provider>\n\t);\n}\n\nexport const ToolbarContainer = forwardRef( UnforwardedToolbarContainer );\nexport default ToolbarContainer;\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AAGzC;AACA;AACA;AACA,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,OAAOC,cAAc,MAAM,oBAAoB;AAI/C,SAASC,2BAA2BA,CACnC;EAAEC,KAAK;EAAE,GAAGC;AAA6D,CAAC,EAC1EC,GAAwB,EACvB;EACD,MAAMC,YAAY,GAAGR,OAAO,CAACS,eAAe,CAAE;IAC7CC,SAAS,EAAE,IAAI;IACfC,GAAG,EAAET,KAAK,CAAC;EACZ,CAAE,CAAC;EAEH;IACC;IACAU,aAAA,CAACT,cAAc,CAACU,QAAQ;MAACC,KAAK,EAAGN;IAAc,GAC9CI,aAAA,CAACZ,OAAO,CAACe,OAAO;MACfR,GAAG,EAAGA,GAAK;MACX,cAAaF,KAAO;MACpBW,KAAK,EAAGR,YAAc;MAAA,GACjBF;IAAK,CACV,CACuB;EAAC;AAE5B;AAEA,OAAO,MAAMW,gBAAgB,GAAGhB,UAAU,CAAEG,2BAA4B,CAAC;AACzE,eAAea,gBAAgB"}

View File

@@ -0,0 +1,10 @@
import { createElement } from "react";
/**
* External dependencies
*/
import { View } from 'react-native';
const ToolbarContainer = ({
children
}) => createElement(View, null, children);
export default ToolbarContainer;
//# sourceMappingURL=toolbar-container.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["View","ToolbarContainer","children","createElement"],"sources":["@wordpress/components/src/toolbar/toolbar/toolbar-container.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\nconst ToolbarContainer = ( { children } ) => <View>{ children }</View>;\n\nexport default ToolbarContainer;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,cAAc;AAEnC,MAAMC,gBAAgB,GAAGA,CAAE;EAAEC;AAAS,CAAC,KAAMC,aAAA,CAACH,IAAI,QAAGE,QAAgB,CAAC;AAEtE,eAAeD,gBAAgB"}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/toolbar/toolbar/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\nexport type ToolbarProps = {\n\t/**\n\t * Children to be rendered inside the toolbar.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * An accessible label for the toolbar.\n\t */\n\tlabel: string;\n\t/**\n\t * Specifies the toolbar's style.\n\t *\n\t * Leave undefined for the default style. Or `'unstyled'` which\n\t * removes the border from the toolbar, but keeps the default\n\t * popover style.\n\t *\n\t * @default undefined\n\t */\n\tvariant?: 'unstyled' | undefined;\n};\n"],"mappings":""}