Product Editor API: Add tooltip attribute to woocommerce/product-select-field block (#46447)
This commit is contained in:
parent
ea2becadaf
commit
4ba72b2258
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: add
|
||||||
|
|
||||||
|
Product Editor: Add support for tooltip attribute for woocommerce/product-select-field block
|
|
@ -25,6 +25,13 @@ Property in which the value is stored.
|
||||||
|
|
||||||
Help text that appears below the field.
|
Help text that appears below the field.
|
||||||
|
|
||||||
|
### tooltip
|
||||||
|
|
||||||
|
- **Type:** `String`
|
||||||
|
- **Required:** `No`
|
||||||
|
|
||||||
|
If provided, shows a tooltip next to the label with additional information.
|
||||||
|
|
||||||
### multiple
|
### multiple
|
||||||
|
|
||||||
- **Type:** `Boolean`
|
- **Type:** `Boolean`
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
"help": {
|
"help": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"disabled": {
|
"disabled": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,6 +12,7 @@ import useProductEntityProp from '../../../hooks/use-product-entity-prop';
|
||||||
import { sanitizeHTML } from '../../../utils/sanitize-html';
|
import { sanitizeHTML } from '../../../utils/sanitize-html';
|
||||||
import type { ProductEditorBlockEditProps } from '../../../types';
|
import type { ProductEditorBlockEditProps } from '../../../types';
|
||||||
import type { SelectBlockAttributes } from './types';
|
import type { SelectBlockAttributes } from './types';
|
||||||
|
import { Label } from '../../../components/label/label';
|
||||||
|
|
||||||
export function Edit( {
|
export function Edit( {
|
||||||
attributes,
|
attributes,
|
||||||
|
@ -19,8 +20,17 @@ export function Edit( {
|
||||||
}: ProductEditorBlockEditProps< SelectBlockAttributes > ) {
|
}: ProductEditorBlockEditProps< SelectBlockAttributes > ) {
|
||||||
const blockProps = useWooBlockProps( attributes );
|
const blockProps = useWooBlockProps( attributes );
|
||||||
|
|
||||||
const { property, label, placeholder, help, disabled, options, multiple } =
|
const {
|
||||||
attributes;
|
property,
|
||||||
|
label,
|
||||||
|
note,
|
||||||
|
placeholder,
|
||||||
|
help,
|
||||||
|
tooltip,
|
||||||
|
disabled,
|
||||||
|
options,
|
||||||
|
multiple,
|
||||||
|
} = attributes;
|
||||||
|
|
||||||
const [ value, setValue ] = useProductEntityProp< string | string[] >(
|
const [ value, setValue ] = useProductEntityProp< string | string[] >(
|
||||||
property,
|
property,
|
||||||
|
@ -41,7 +51,9 @@ export function Edit( {
|
||||||
<SelectControl
|
<SelectControl
|
||||||
value={ value }
|
value={ value }
|
||||||
disabled={ disabled }
|
disabled={ disabled }
|
||||||
label={ label }
|
label={
|
||||||
|
<Label label={ label } note={ note } tooltip={ tooltip } />
|
||||||
|
}
|
||||||
onChange={ setValue }
|
onChange={ setValue }
|
||||||
help={ renderHelp() }
|
help={ renderHelp() }
|
||||||
placeholder={ placeholder }
|
placeholder={ placeholder }
|
||||||
|
|
|
@ -7,7 +7,9 @@ import { SelectControl } from '@wordpress/components';
|
||||||
export interface SelectBlockAttributes extends BlockAttributes {
|
export interface SelectBlockAttributes extends BlockAttributes {
|
||||||
property: string;
|
property: string;
|
||||||
label: string;
|
label: string;
|
||||||
|
note?: string;
|
||||||
help?: string;
|
help?: string;
|
||||||
|
tooltip?: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
multiple?: boolean;
|
multiple?: boolean;
|
||||||
|
|
Loading…
Reference in New Issue