@plaudit/gutenberg-api-extensions 2.54.1 → 2.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,17 +5,18 @@ import { type ReactNode } from "react";
|
|
|
5
5
|
type Tab = TabPanelProps['tabs'][number] & {
|
|
6
6
|
items: ReactNode;
|
|
7
7
|
};
|
|
8
|
+
type GroupAndCondition = {
|
|
9
|
+
group?: string;
|
|
10
|
+
condition?(): boolean;
|
|
11
|
+
};
|
|
8
12
|
type NormalPanelInspectorPanelProps = {
|
|
9
13
|
tabbed?: false | undefined;
|
|
10
14
|
raw?: boolean | undefined;
|
|
11
|
-
} & Omit<PanelBodyProps, 'children'> & Pick<InspectorControls.Props, 'children'
|
|
15
|
+
} & Omit<PanelBodyProps, 'children'> & Pick<InspectorControls.Props, 'children'> & GroupAndCondition;
|
|
12
16
|
type TabbedPanelInspectorPanelProps = {
|
|
13
17
|
tabbed: true;
|
|
14
18
|
tabs: Tab[];
|
|
15
|
-
} & Omit<TabPanelProps, 'children' | 'tabs'
|
|
16
|
-
export type InspectorPanelProps = (NormalPanelInspectorPanelProps | TabbedPanelInspectorPanelProps)
|
|
17
|
-
group?: string;
|
|
18
|
-
condition?(): boolean;
|
|
19
|
-
};
|
|
19
|
+
} & Omit<TabPanelProps, 'children' | 'tabs'> & GroupAndCondition;
|
|
20
|
+
export type InspectorPanelProps = (NormalPanelInspectorPanelProps | TabbedPanelInspectorPanelProps);
|
|
20
21
|
export declare function InspectorPanel(props: InspectorPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
21
22
|
export {};
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { InspectorControls } from "@wordpress/block-editor";
|
|
3
3
|
import { Panel, PanelBody, TabPanel } from "@wordpress/components";
|
|
4
|
+
import { useState } from "@wordpress/element";
|
|
5
|
+
import { useCallback } from "react";
|
|
4
6
|
export function InspectorPanel(props) {
|
|
5
7
|
if (props["tabbed"]) {
|
|
6
8
|
const { tabbed, tabs, group, condition, ...tabPanelProps } = props;
|
|
7
9
|
return _jsx(InspectorControls, { group: group, children: _jsx(TabPanel, { ...tabPanelProps, tabs: condition === undefined || condition() ? tabs : [], children: tab => _jsx(Panel, { children: tab.items }) }) });
|
|
8
10
|
}
|
|
9
11
|
else {
|
|
10
|
-
|
|
11
|
-
return _jsx(InspectorControls, { group: group, children: raw
|
|
12
|
-
? (condition === undefined || condition() ? children : [])
|
|
13
|
-
: _jsx(PanelBody, { ...panelBodyProps, children: condition === undefined || condition() ? children : [] }) });
|
|
12
|
+
return _jsx(InspectorPanelPanel, { ...props });
|
|
14
13
|
}
|
|
15
14
|
}
|
|
15
|
+
function InspectorPanelPanel(props) {
|
|
16
|
+
const { tabbed, raw, group, condition, children, onToggle, initialOpen, ...panelBodyProps } = props;
|
|
17
|
+
const [wasOpened, setWasOpened] = useState(initialOpen);
|
|
18
|
+
const memoOnToggle = useCallback((value) => {
|
|
19
|
+
onToggle?.(value);
|
|
20
|
+
setWasOpened(value);
|
|
21
|
+
}, [onToggle, setWasOpened]);
|
|
22
|
+
return _jsx(InspectorControls, { group: group, children: raw
|
|
23
|
+
? (condition === undefined || condition() ? children : [])
|
|
24
|
+
: _jsx(PanelBody, { ...panelBodyProps, children: condition === undefined || condition() ? children : [], onToggle: memoOnToggle, initialOpen: wasOpened }) });
|
|
25
|
+
}
|
|
16
26
|
//# sourceMappingURL=InspectorPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InspectorPanel.js","sourceRoot":"","sources":["../../src/controls/InspectorPanel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"InspectorPanel.js","sourceRoot":"","sources":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