@plaudit/gutenberg-api-extensions 2.89.0 → 2.90.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.
- package/CHANGELOG.md +4 -0
- package/dist/blocks/SNPFlexibleItemsListComponent.d.ts +2 -2
- package/dist/blocks/SNPFlexibleItemsListComponent.js +1 -1
- package/dist/blocks/SNPFlexibleItemsListComponent.js.map +1 -1
- package/dist/blocks/SNPGroupComponent.js +2 -2
- package/dist/blocks/SNPGroupComponent.js.map +1 -1
- package/dist/blocks/SNPListComponent.js +1 -1
- package/dist/blocks/SNPListComponent.js.map +1 -1
- package/dist/blocks/basic-custom-block-bindings-support.js +6 -6
- package/dist/blocks/basic-custom-block-bindings-support.js.map +1 -1
- package/dist/blocks/common-native-property-constructors.js +21 -14
- package/dist/blocks/common-native-property-constructors.js.map +1 -1
- package/dist/blocks/conditions.js +1 -1
- package/dist/blocks/conditions.js.map +1 -1
- package/dist/blocks/layout/LaidOutPropertyRow.d.ts +5 -2
- package/dist/blocks/layout/LaidOutPropertyRow.js +5 -0
- package/dist/blocks/layout/LaidOutPropertyRow.js.map +1 -1
- package/dist/blocks/layout/PanelRoot.js +1 -4
- package/dist/blocks/layout/PanelRoot.js.map +1 -1
- package/dist/blocks/layout/TabsRoot.js +1 -1
- package/dist/blocks/layout/TabsRoot.js.map +1 -1
- package/dist/blocks/simple-block.d.ts +2 -2
- package/dist/blocks/simple-native-property-impl.js +5 -5
- package/dist/blocks/simple-native-property-impl.js.map +1 -1
- package/dist/controls/AsynchronousFormTokenField.js +1 -1
- package/dist/controls/AsynchronousFormTokenField.js.map +1 -1
- package/dist/controls/BaseSortableItemsControl.d.ts +1 -1
- package/dist/controls/BaseSortableItemsControl.js +2 -2
- package/dist/controls/BaseSortableItemsControl.js.map +1 -1
- package/dist/controls/ExtendedFormTokenField.js +1 -1
- package/dist/controls/ExtendedFormTokenField.js.map +1 -1
- package/dist/controls/ExtendedRadioControl.js +1 -1
- package/dist/controls/ExtendedRadioControl.js.map +1 -1
- package/dist/controls/ExtendedTextareaControl.js +1 -1
- package/dist/controls/ExtendedTextareaControl.js.map +1 -1
- package/dist/controls/FileControl.js +3 -3
- package/dist/controls/FileControl.js.map +1 -1
- package/dist/controls/FullSizeToggleControl.js +1 -0
- package/dist/controls/FullSizeToggleControl.js.map +1 -1
- package/dist/controls/ImageControl.js +5 -5
- package/dist/controls/ImageControl.js.map +1 -1
- package/dist/controls/LazySuggestionsComboboxControl.js +4 -4
- package/dist/controls/LazySuggestionsComboboxControl.js.map +1 -1
- package/dist/controls/PickOne.js +2 -2
- package/dist/controls/PickOne.js.map +1 -1
- package/dist/controls/ProperLinkControl.js +3 -3
- package/dist/controls/ProperLinkControl.js.map +1 -1
- package/dist/controls/SimpleToggle.js +1 -1
- package/dist/controls/SimpleToggle.js.map +1 -1
- package/dist/controls/SortableFlexibleItemsControl.d.ts +2 -2
- package/dist/controls/SortableFlexibleItemsControl.js +1 -1
- package/dist/controls/SortableFlexibleItemsControl.js.map +1 -1
- package/dist/controls/SortableItemsControl.js +1 -1
- package/dist/controls/SortableItemsControl.js.map +1 -1
- package/package.json +12 -12
- package/src/blocks/SNPFlexibleItemsListComponent.tsx +4 -4
- package/src/blocks/SNPGroupComponent.tsx +3 -3
- package/src/blocks/SNPListComponent.tsx +2 -2
- package/src/blocks/basic-custom-block-bindings-support.tsx +11 -6
- package/src/blocks/common-native-property-constructors.tsx +48 -34
- package/src/blocks/conditions.ts +1 -1
- package/src/blocks/layout/LaidOutPropertyRow.tsx +7 -1
- package/src/blocks/layout/PanelRoot.tsx +2 -5
- package/src/blocks/layout/TabsRoot.tsx +2 -2
- package/src/blocks/simple-block.tsx +2 -2
- package/src/blocks/simple-native-property-impl.tsx +5 -5
- package/src/controls/AsynchronousFormTokenField.tsx +1 -0
- package/src/controls/BaseSortableItemsControl.tsx +8 -8
- package/src/controls/ExtendedFormTokenField.tsx +2 -0
- package/src/controls/ExtendedRadioControl.tsx +2 -2
- package/src/controls/ExtendedTextareaControl.tsx +1 -1
- package/src/controls/FileControl.tsx +4 -4
- package/src/controls/FullSizeToggleControl.tsx +1 -0
- package/src/controls/ImageControl.tsx +5 -5
- package/src/controls/LazySuggestionsComboboxControl.tsx +11 -9
- package/src/controls/PickOne.tsx +2 -1
- package/src/controls/ProperLinkControl.tsx +11 -6
- package/src/controls/SimpleToggle.tsx +1 -1
- package/src/controls/SortableFlexibleItemsControl.tsx +5 -3
- package/src/controls/SortableItemsControl.tsx +5 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {store as blockEditorStore} from "@wordpress/block-editor";
|
|
1
2
|
import {createHigherOrderComponent} from "@wordpress/compose";
|
|
2
3
|
import {dispatch, select} from "@wordpress/data";
|
|
3
4
|
import {useEffect, useMemo} from "@wordpress/element";
|
|
@@ -86,14 +87,13 @@ export function installSimpleNativePropertiesSupport() {
|
|
|
86
87
|
});
|
|
87
88
|
|
|
88
89
|
addFilter('editor.BlockEdit', 'plaudit/gutenberg-api-extensions/simple-native-properties',
|
|
89
|
-
createHigherOrderComponent(BlockEdit => (blockEditProps: ActualBlockEditProps)
|
|
90
|
+
createHigherOrderComponent(BlockEdit => function SNPBlockEdit(blockEditProps: ActualBlockEditProps) {
|
|
90
91
|
const blockSimpleNativePanelsAndTabs = select(gutenbergApiExtensionsStore).preppedProperties(blockEditProps.name);
|
|
91
92
|
if (!blockSimpleNativePanelsAndTabs) {
|
|
92
93
|
return <BlockEdit {...blockEditProps} />;
|
|
93
94
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
// If we have a core/block ancestor, then we can't be edited and attempting to self-edit will cause a crash
|
|
95
|
+
if (select(blockEditorStore).getBlockParentsByBlockName(blockEditProps.clientId, "core/block")?.length) {
|
|
96
|
+
// If we have a core/block ancestor, then we can't be edited, and attempting to self-edit will cause a crash
|
|
97
97
|
return <BlockEdit {...blockEditProps} />;
|
|
98
98
|
}
|
|
99
99
|
return <DataControllerInitializationIsolator bep={blockEditProps} dcm={dataControllerManager} BlockEdit={BlockEdit} snpPanelsAndTabs={blockSimpleNativePanelsAndTabs} />;
|
|
@@ -120,7 +120,7 @@ export function installSimpleNativePropertiesSupport() {
|
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
addFilter('editor.BlockListBlock', 'plaudit/gutenberg-api-extensions/simple-native-properties',
|
|
123
|
-
createHigherOrderComponent(BlockListBlock => (props: ActualBlockListBlockProps)
|
|
123
|
+
createHigherOrderComponent(BlockListBlock => function SNPBlockListBlock(props: ActualBlockListBlockProps) {
|
|
124
124
|
const wrapperProps: {className?: string, style?: Record<string, unknown>} = {...props.wrapperProps};
|
|
125
125
|
const extraPropTransforms = select(gutenbergApiExtensionsStore).computedExtraPropTransforms(props.name);
|
|
126
126
|
if (!extraPropTransforms || !extraPropTransforms.appliesInEditor) {
|
|
@@ -63,6 +63,7 @@ export function AsynchronousFormTokenField(props: AsynchronousFormTokenFieldProp
|
|
|
63
63
|
//TODO: If focus is in field but user hasn't started typing, show a message telling them to start typing
|
|
64
64
|
return <>
|
|
65
65
|
<FormTokenField
|
|
66
|
+
__next40pxDefaultSize
|
|
66
67
|
value={currentTokens}
|
|
67
68
|
label={props.label}
|
|
68
69
|
placeholder="Start typing to see suggestions"
|
|
@@ -2,10 +2,10 @@ import {BaseControl, Button, useBaseControlProps} from "@wordpress/components";
|
|
|
2
2
|
import {useCallback} from "@wordpress/element";
|
|
3
3
|
import {dragHandle, Icon} from "@wordpress/icons";
|
|
4
4
|
|
|
5
|
-
import {ProvidedSlot} from "../blocks";
|
|
6
|
-
|
|
7
5
|
import {Reorder, useDragControls} from "framer-motion";
|
|
8
|
-
import type {ReactNode} from "react";
|
|
6
|
+
import type {PointerEvent, ReactNode} from "react";
|
|
7
|
+
|
|
8
|
+
import {ProvidedSlot} from "../blocks";
|
|
9
9
|
import {IndexedItemActionsMaker, KeyedValue, useSortableItemsModel} from "./hooks/useSortableItemsModel";
|
|
10
10
|
|
|
11
11
|
export type BaseSortableItemsControlProps<D> = Omit<Parameters<typeof useBaseControlProps>[0], 'children'|'id'>&{
|
|
@@ -33,7 +33,7 @@ export function BaseSortableItemsControl<D>({
|
|
|
33
33
|
const removeDisabled = min !== undefined && listLength <= min;
|
|
34
34
|
const {baseControlProps, controlProps} = useBaseControlProps({...wrapperProps, label: Label ? <Label /> : label});
|
|
35
35
|
|
|
36
|
-
return <BaseControl {...baseControlProps}>
|
|
36
|
+
return <BaseControl {...baseControlProps} __nextHasNoMarginBottom>
|
|
37
37
|
<div {...controlProps} className="plaudit-sortable-items-container">
|
|
38
38
|
<Reorder.Group
|
|
39
39
|
axis="y" onReorder={commit} values={keyedValues}
|
|
@@ -58,7 +58,7 @@ function SortableItemsListNode<D>({datum, index, listLength, makeChild, makeInde
|
|
|
58
58
|
//TODO: If used, implement addBefore and addAfter the same way as moveUp and moveDown
|
|
59
59
|
|
|
60
60
|
const dragControls = useDragControls();
|
|
61
|
-
const dragStartHandler = useCallback((event:
|
|
61
|
+
const dragStartHandler = useCallback((event: PointerEvent) => dragControls.start(event), [dragControls]);
|
|
62
62
|
|
|
63
63
|
return <Reorder.Item className="plaudit-sortable-items-row" data-index={index} dragListener={false} dragControls={dragControls} layout="position" value={datum}>
|
|
64
64
|
<div className="plaudit-sortable-items-ordering-controls">
|
|
@@ -66,8 +66,8 @@ function SortableItemsListNode<D>({datum, index, listLength, makeChild, makeInde
|
|
|
66
66
|
<Icon icon={dragHandle} onPointerDown={dragStartHandler} />
|
|
67
67
|
</div>
|
|
68
68
|
<div className="plaudit-sortable-items-ordering-control">
|
|
69
|
-
<Button icon="arrow-up" aria-label="Move Up" disabled={index < 1} onClick={moveUp} />
|
|
70
|
-
<Button icon="arrow-down" aria-label="Move Down" disabled={index >= listLength - 1} onClick={moveDown} />
|
|
69
|
+
<Button icon="arrow-up" aria-label="Move Up" disabled={index < 1} onClick={moveUp} __next40pxDefaultSize accessibleWhenDisabled />
|
|
70
|
+
<Button icon="arrow-down" aria-label="Move Down" disabled={index >= listLength - 1} onClick={moveDown} __next40pxDefaultSize accessibleWhenDisabled />
|
|
71
71
|
</div>
|
|
72
72
|
</div>
|
|
73
73
|
<div className="plaudit-sortable-items-inputs plaudit-sortable-items-padded">
|
|
@@ -76,7 +76,7 @@ function SortableItemsListNode<D>({datum, index, listLength, makeChild, makeInde
|
|
|
76
76
|
<div className="plaudit-sortable-items-presence-controls plaudit-sortable-items-padded">
|
|
77
77
|
{/*addEmptyHandlers && index === 0 &&
|
|
78
78
|
<Button icon="insert" className="insert-before" disabled={addDisabled} onClick={addEmptyHandlers[0]} aria-label="Insert Before"/>*/}
|
|
79
|
-
<Button icon="remove" disabled={removeDisabled} onClick={remove} aria-label="Remove"/>
|
|
79
|
+
<Button icon="remove" disabled={removeDisabled} onClick={remove} aria-label="Remove" __next40pxDefaultSize accessibleWhenDisabled />
|
|
80
80
|
{/*addEmptyHandlers && <Button icon="insert" className="insert-after" disabled={addDisabled} onClick={addEmptyHandlers[1]}
|
|
81
81
|
aria-label={index < listLength - 1 ? "Insert Between" : "Insert After"}/>*/}
|
|
82
82
|
</div>
|
|
@@ -97,6 +97,8 @@ export function ExtendedFormTokenField(props: ExtendedFormTokenFieldProps) {
|
|
|
97
97
|
__experimentalShowHowTo={props.multiple !== false}
|
|
98
98
|
onInputChange={setDebouncedInput}
|
|
99
99
|
onFocus={useCallback(() => setImmediateInput(input), [input])}
|
|
100
|
+
__next40pxDefaultSize
|
|
101
|
+
__nextHasNoMarginBottom
|
|
100
102
|
/>
|
|
101
103
|
{help && <div><span className="components-form-token-field__help">{help}</span></div>}
|
|
102
104
|
{hasLoadingError && <div><Spinner /><span className="components-form-token-field__help">{__("An Error Occurred While Loading Suggestions")}</span></div>}
|
|
@@ -71,7 +71,7 @@ export function ExtendedRadioControl(props: ExtendedRadioControlProps) {
|
|
|
71
71
|
value={option.value}
|
|
72
72
|
onChange={onChangeValue}
|
|
73
73
|
checked={option.value === selected}
|
|
74
|
-
aria-describedby={
|
|
74
|
+
aria-describedby={help ? `${id}__help` : undefined}
|
|
75
75
|
{...additionalProps}
|
|
76
76
|
/>
|
|
77
77
|
<label
|
|
@@ -94,7 +94,7 @@ export function ExtendedRadioControl(props: ExtendedRadioControlProps) {
|
|
|
94
94
|
value={customValue ?? ''}
|
|
95
95
|
onChange={onChangeValue}
|
|
96
96
|
checked={valueIsCustom}
|
|
97
|
-
aria-describedby={
|
|
97
|
+
aria-describedby={help ? `${id}__help` : undefined}
|
|
98
98
|
{...additionalProps}
|
|
99
99
|
/>
|
|
100
100
|
<label id={`${id}-custom-label`} className="components-radio-control__label" htmlFor={`${id}-${options.length}`}>Custom:</label>
|
|
@@ -58,7 +58,7 @@ export const ExtendedTextareaControl = (() => {
|
|
|
58
58
|
}, [rich, debouncedUpdate, textareaRef.current]);
|
|
59
59
|
|
|
60
60
|
return <>
|
|
61
|
-
<TextareaControl ref={textareaRef}
|
|
61
|
+
<TextareaControl {...forwardedProps} ref={textareaRef} value={v} onChange={safeOnChange} __nextHasNoMarginBottom />
|
|
62
62
|
{Messages && <Messages/>}
|
|
63
63
|
</>;
|
|
64
64
|
})
|
|
@@ -24,7 +24,7 @@ export function FileControl(props: FileControlProps) {
|
|
|
24
24
|
|
|
25
25
|
const attachment = useSuspenseSelect(select => value !== undefined ? select(coreStore).getMedia(value) : undefined, [value]);
|
|
26
26
|
const {baseControlProps, controlProps} = useBaseControlProps({label, help});
|
|
27
|
-
return <BaseControl {...baseControlProps}>
|
|
27
|
+
return <BaseControl {...baseControlProps} __nextHasNoMarginBottom>
|
|
28
28
|
<MediaUploadCheck>
|
|
29
29
|
<MediaUpload
|
|
30
30
|
onSelect={onSelect}
|
|
@@ -32,13 +32,13 @@ export function FileControl(props: FileControlProps) {
|
|
|
32
32
|
allowedTypes={allowedTypes}
|
|
33
33
|
render={useCallback(({open}) => {
|
|
34
34
|
if (!attachment?.id) {
|
|
35
|
-
return <div {...controlProps}><Button onClick={open} children={__('Select a File', 'plaudit')}/></div>
|
|
35
|
+
return <div {...controlProps}><Button onClick={open} children={__('Select a File', 'plaudit')} __next40pxDefaultSize /></div>
|
|
36
36
|
}
|
|
37
37
|
return <div {...controlProps}>
|
|
38
38
|
<p>{__('Selected File', 'plaudit')}: <a href={attachment.source_url} target="_blank" rel="noopener noreferrer">{attachment.title.rendered}</a></p>
|
|
39
39
|
<div className="selected-file-control-buttons">
|
|
40
|
-
<Button onClick={open} variant="secondary" children="Replace File" />
|
|
41
|
-
<Button onClick={() => onChange(undefined)} isDestructive children={__('Remove File', 'plaudit')} />
|
|
40
|
+
<Button onClick={open} variant="secondary" children="Replace File" __next40pxDefaultSize />
|
|
41
|
+
<Button onClick={() => onChange(undefined)} isDestructive children={__('Remove File', 'plaudit')} __next40pxDefaultSize />
|
|
42
42
|
</div>
|
|
43
43
|
</div>;
|
|
44
44
|
}, [attachment, onChange, controlProps])}
|
|
@@ -77,6 +77,7 @@ export const ToggleGroupControlOptionWithOptionalIcon
|
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
function i18nSwitchLabel(label: NonNullable<OptionalLabel>): typeof label {
|
|
80
|
+
// eslint-disable-next-line @wordpress/i18n-no-variables -- There's nothing we can do about this - it's a requirement for being able to pass arbitrary labels
|
|
80
81
|
return typeof label === 'string' ? __(label) : {...label, text: __(label.text)};
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -27,7 +27,7 @@ export function ImageControl(props: ImageControlProps) {
|
|
|
27
27
|
|
|
28
28
|
const media = useSelect(select => value?.media?.id ? select(coreStore).getMedia(value.media.id) : undefined, [value]);
|
|
29
29
|
const {baseControlProps, controlProps} = useBaseControlProps({label: Label ? <Label /> : label, help});
|
|
30
|
-
return <BaseControl {...baseControlProps}>
|
|
30
|
+
return <BaseControl {...baseControlProps} __nextHasNoMarginBottom>
|
|
31
31
|
<div {...controlProps} className="editor-post-featured-image">
|
|
32
32
|
{media
|
|
33
33
|
? <ImageControlWithUploadedImage {...props} media={media} />
|
|
@@ -52,7 +52,7 @@ function ImageControlWithUploadedImage(props: ImageControlProps&{media: Attachme
|
|
|
52
52
|
const {includeFocalPointPicker, media, storage, onChange, value} = props;
|
|
53
53
|
const onFPPChange = useCallback((pos: FocalPoint) => onChange(mergeInUpdatedValuePart(value, 'pos', {x: pos.x * 100, y: pos.y * 100}, storage)), [onChange, value]);
|
|
54
54
|
const onSelect = useCallback((media: {id: number}&{[k: string]: any}) => onChange(mergeInUpdatedValuePart(value, 'media', media, storage)), [onChange, value]);
|
|
55
|
-
const renderOpenButton = useCallback(({open}: {open(): void}) => <Button onClick={open} variant="secondary">{__('Replace image', 'plaudit')}</Button>, []);
|
|
55
|
+
const renderOpenButton = useCallback(({open}: {open(): void}) => <Button onClick={open} variant="secondary" __next40pxDefaultSize>{__('Replace image', 'plaudit')}</Button>, []);
|
|
56
56
|
const clear = useCallback(() => onChange(undefined), [onChange]);
|
|
57
57
|
|
|
58
58
|
const fppValue = useMemo(() => ({
|
|
@@ -66,6 +66,7 @@ function ImageControlWithUploadedImage(props: ImageControlProps&{media: Attachme
|
|
|
66
66
|
onChange={onFPPChange}
|
|
67
67
|
url={value?.media?.url ?? ''}
|
|
68
68
|
value={fppValue}
|
|
69
|
+
__nextHasNoMarginBottom
|
|
69
70
|
/>;
|
|
70
71
|
} else {
|
|
71
72
|
fppOrMedia = <ResponsiveWrapper
|
|
@@ -85,7 +86,7 @@ function ImageControlWithUploadedImage(props: ImageControlProps&{media: Attachme
|
|
|
85
86
|
allowedTypes={ALLOWED_TYPES}
|
|
86
87
|
render={renderOpenButton}
|
|
87
88
|
/>
|
|
88
|
-
<Button onClick={clear} isDestructive>{__('Remove image', 'plaudit')}</Button>
|
|
89
|
+
<Button onClick={clear} isDestructive __next40pxDefaultSize>{__('Remove image', 'plaudit')}</Button>
|
|
89
90
|
</MediaUploadCheck>
|
|
90
91
|
</>;
|
|
91
92
|
}
|
|
@@ -94,8 +95,7 @@ function ImageControlWithoutUploadedImage(props: ImageControlProps&{media: Attac
|
|
|
94
95
|
const onSelect = useCallback((media: {id: number}&{[k: string]: any}) => onChange(mergeInUpdatedValuePart(value, 'media', media, storage)), [onChange, value]);
|
|
95
96
|
const renderOpenButton = useCallback(({open}: {open(): void}) => (
|
|
96
97
|
<Button
|
|
97
|
-
className={
|
|
98
|
-
onClick={open}
|
|
98
|
+
className={value?.media?.id ? 'editor-post-featured-image__preview' : 'editor-post-featured-image__toggle'} onClick={open} __next40pxDefaultSize
|
|
99
99
|
>
|
|
100
100
|
{!value?.media?.id && __('Choose an image', 'plaudit')}
|
|
101
101
|
{media &&
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {BaseControl, ComboboxControl, Spinner} from "@wordpress/components";
|
|
2
2
|
import {useCallback, useMemo, useState} from "@wordpress/element";
|
|
3
|
-
import {__} from "@wordpress/i18n";
|
|
3
|
+
import {__, sprintf} from "@wordpress/i18n";
|
|
4
4
|
|
|
5
5
|
import {useSuggestions} from "./hooks/useSuggestions";
|
|
6
6
|
|
|
7
|
-
import type {ComponentProps} from "react";
|
|
7
|
+
import type {ComponentProps, FocusEvent} from "react";
|
|
8
8
|
|
|
9
9
|
type ComboboxControlProps = ComponentProps<typeof ComboboxControl>;
|
|
10
10
|
type ComboboxControlOption = ComboboxControlProps['options'][number];
|
|
@@ -24,8 +24,8 @@ export function LazySuggestionsComboboxControl(props: LazySuggestionsComboboxCon
|
|
|
24
24
|
() => hasFocus && input.length < 2 || (isLoading && !suggestions.length) ? [{label: input, value: "", disabled: true}] : suggestions,
|
|
25
25
|
[hasFocus, input, isLoading, suggestions]);
|
|
26
26
|
|
|
27
|
-
const onFocus = useCallback((e:
|
|
28
|
-
const onBlur = useCallback((e:
|
|
27
|
+
const onFocus = useCallback((e: FocusEvent<HTMLElement>) => setHasFocus(e.currentTarget.contains(e.target)), [setHasFocus]);
|
|
28
|
+
const onBlur = useCallback((e: FocusEvent<HTMLElement>) => setHasFocus(e.currentTarget.contains(e.relatedTarget)), [setHasFocus]);
|
|
29
29
|
|
|
30
30
|
const onFilterValueChange = useCallback((value: string) => {
|
|
31
31
|
if (props.onFilterValueChange) {
|
|
@@ -35,13 +35,13 @@ export function LazySuggestionsComboboxControl(props: LazySuggestionsComboboxCon
|
|
|
35
35
|
}, [props.onFilterValueChange, setInput]);
|
|
36
36
|
|
|
37
37
|
const __experimentalRenderItem = useMemo(() => {
|
|
38
|
-
return hasFocus && input.length < 2 ? () => __("Start typing to see suggestions")
|
|
39
|
-
: (isLoading && !suggestions.length ? () => __("Loading suggestions") : undefined);
|
|
38
|
+
return hasFocus && input.length < 2 ? () => __("Start typing to see suggestions", 'plaudit')
|
|
39
|
+
: (isLoading && !suggestions.length ? () => __("Loading suggestions", 'plaudit') : undefined);
|
|
40
40
|
}, [hasFocus, input, isLoading, suggestions])
|
|
41
41
|
|
|
42
42
|
if (isInitializing) {
|
|
43
|
-
return <BaseControl {...props}>
|
|
44
|
-
<Spinner /><span>{__(
|
|
43
|
+
return <BaseControl {...props} __nextHasNoMarginBottom>
|
|
44
|
+
<Spinner /><span>{/* translators: %s is replaced with the label of the property */ sprintf(__("Initializing %s", 'plaudit'), props.label)}</span>
|
|
45
45
|
</BaseControl>
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -56,7 +56,9 @@ export function LazySuggestionsComboboxControl(props: LazySuggestionsComboboxCon
|
|
|
56
56
|
onFilterValueChange={onFilterValueChange}
|
|
57
57
|
__experimentalRenderItem={__experimentalRenderItem}
|
|
58
58
|
allowReset={allowReset !== false}
|
|
59
|
+
__next40pxDefaultSize
|
|
60
|
+
__nextHasNoMarginBottom
|
|
59
61
|
/>
|
|
60
|
-
{hasLoadingError && <div><span className="components-base-control__help">{__("An error occurred while updating suggestions")}</span></div>}
|
|
62
|
+
{hasLoadingError && <div><span className="components-base-control__help">{__("An error occurred while updating suggestions", 'plaudit')}</span></div>}
|
|
61
63
|
</div>;
|
|
62
64
|
}
|
package/src/controls/PickOne.tsx
CHANGED
|
@@ -42,6 +42,7 @@ export function PickOneFromSelect<T extends string>(props: SimpleBlockControlPro
|
|
|
42
42
|
return <SelectControl
|
|
43
43
|
{...makeSharedRadioAndSelectProps(props)}
|
|
44
44
|
value={props.attributes[props.attribute]}
|
|
45
|
+
__next40pxDefaultSize __nextHasNoMarginBottom
|
|
45
46
|
/>;
|
|
46
47
|
}
|
|
47
48
|
export function PickOneFromRadios<T extends string>(props: SimpleBlockControlProps<T, string>& { options: PickableOptions<string> }) {
|
|
@@ -71,7 +72,7 @@ export function PickOneFromColors<T extends string>(props: SimpleBlockControlPro
|
|
|
71
72
|
|
|
72
73
|
const currentColor = valueToColorMap.get(props.attributes[props.attribute]) ?? props.attributes[props.attribute];
|
|
73
74
|
const {baseControlProps, controlProps} = useBaseControlProps({label: props.label, help: props.help});
|
|
74
|
-
return <BaseControl {...baseControlProps}>
|
|
75
|
+
return <BaseControl {...baseControlProps} __nextHasNoMarginBottom>
|
|
75
76
|
<ColorPalette
|
|
76
77
|
{...controlProps}
|
|
77
78
|
disableCustomColors={true}
|
|
@@ -52,15 +52,17 @@ export function ProperLinkControl(props: ProperLinkControlProps) {
|
|
|
52
52
|
|
|
53
53
|
const renderableSettings = settings === false ? [] : settings;
|
|
54
54
|
const renderControlBottom = useCallback(() => (value?.url && renderableSettings?.length && <>
|
|
55
|
-
<Button
|
|
56
|
-
|
|
55
|
+
<Button
|
|
56
|
+
variant="tertiary" onClick={() => setAreAdvancedSettingsVisible(!areAdvancedSettingsVisible)}
|
|
57
|
+
icon={areAdvancedSettingsVisible ? chevronUp : chevronDown} iconPosition="right" text="Advanced"
|
|
58
|
+
__next40pxDefaultSize accessibleWhenDisabled
|
|
57
59
|
/>
|
|
58
60
|
<div ref={advancedSettingsRef} style={{display: "none", transition: "max-height 200ms ease-in-out", overflow: "hidden"}}>
|
|
59
|
-
{...renderableSettings.map(setting => <ProperLinkControlSetting setting={setting} onChange={onChange} value={value} />)}
|
|
61
|
+
{...renderableSettings.map(setting => <ProperLinkControlSetting key={setting.id} setting={setting} onChange={onChange} value={value} />)}
|
|
60
62
|
</div>
|
|
61
63
|
</>) || "", [value, settings, areAdvancedSettingsVisible, onChange]);
|
|
62
64
|
|
|
63
|
-
return <BaseControl id="" label={props.label} help={props.help}>
|
|
65
|
+
return <BaseControl __nextHasNoMarginBottom id="" label={props.label} help={props.help}>
|
|
64
66
|
<LinkControl
|
|
65
67
|
{...linkControlProps}
|
|
66
68
|
value={value}
|
|
@@ -84,8 +86,11 @@ type ProperLinkControlSettingProps = {value?: LinkControl.Value, onChange?: (nex
|
|
|
84
86
|
function ProperLinkControlSetting({value, onChange, setting}: ProperLinkControlSettingProps) {
|
|
85
87
|
return <div style={{marginTop: "8px"}}>
|
|
86
88
|
{setting.type === 'text'
|
|
87
|
-
? <TextControl
|
|
88
|
-
|
|
89
|
+
? <TextControl
|
|
90
|
+
style={{marginTop: "8px"}} value={value?.[setting.id] ?? setting.default ?? ''} label={setting.title}
|
|
91
|
+
onChange={v => onChange?.({...value, [setting.id]: v})}
|
|
92
|
+
__next40pxDefaultSize __nextHasNoMarginBottom
|
|
93
|
+
/>
|
|
89
94
|
: <ToggleControl style={{marginTop: "8px"}} checked={value?.[setting.id] ?? setting.default ?? false} label={setting.title}
|
|
90
95
|
onChange={v => onChange?.({...value, [setting.id]: v})} />
|
|
91
96
|
}
|
|
@@ -5,5 +5,5 @@ import type {SimpleBlockControlProps} from "./types";
|
|
|
5
5
|
|
|
6
6
|
export function SimpleToggle<T extends string>(props: SimpleBlockControlProps<T, boolean>) {
|
|
7
7
|
const onChange = useCallback((checked: boolean) => props.setAttributes({[props.attribute]: checked}), [props.setAttributes, props.attribute]);
|
|
8
|
-
return <ToggleControl checked={props.attributes[props.attribute]} label={props.label} onChange={onChange} />;
|
|
8
|
+
return <ToggleControl __nextHasNoMarginBottom checked={props.attributes[props.attribute]} label={props.label} onChange={onChange} />;
|
|
9
9
|
}
|
|
@@ -11,8 +11,8 @@ type SortableFlexibleItemsControlSpecificProps<T extends string> = {
|
|
|
11
11
|
availableTypes: NonEmptyArray<{label: string, value: T}>,
|
|
12
12
|
emptyValueBuilder: (type: T) => FlexibleItem<T>
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
15
|
-
export function SortableFlexibleItemsControl<T extends string>({availableTypes, emptyValueBuilder, ...baseProps}:
|
|
14
|
+
export type SortableFlexibleItemsControlProps<T extends string> = Omit<BaseSortableItemsControlProps<FlexibleItem<T>>, 'buttonsArea'>&SortableFlexibleItemsControlSpecificProps<T>;
|
|
15
|
+
export function SortableFlexibleItemsControl<T extends string>({availableTypes, emptyValueBuilder, ...baseProps}: SortableFlexibleItemsControlProps<T>) {
|
|
16
16
|
const buttonsArea = useCallback<BaseSortableItemsControlProps<FlexibleItem<T>>['buttonsArea']>(
|
|
17
17
|
// Unfortunately, the typedefs for React memo components don't allow us to properly check the emptyValueBuilder function
|
|
18
18
|
args => <ButtonsArea {...args} availableTypes={availableTypes} emptyValueBuilder={emptyValueBuilder} />, [availableTypes, emptyValueBuilder]);
|
|
@@ -23,8 +23,10 @@ type ButtonsAreaProps<T extends string> = Parameters<BaseSortableItemsControlPro
|
|
|
23
23
|
function ButtonsArea<T extends string>({addHandler, disabled, availableTypes, emptyValueBuilder}: ButtonsAreaProps<T>): ReactNode {
|
|
24
24
|
const [selectedType, setSelectedType] = useState(availableTypes[0].value);
|
|
25
25
|
return <div className="plaudit-sortable-items-buttons flexible-items">
|
|
26
|
-
<Button icon="insert" disabled={disabled} onClick={() => addHandler(emptyValueBuilder(selectedType))}>Add</Button>
|
|
26
|
+
<Button icon="insert" disabled={disabled} onClick={() => addHandler(emptyValueBuilder(selectedType))} __next40pxDefaultSize accessibleWhenDisabled>Add</Button>
|
|
27
27
|
<SelectControl
|
|
28
|
+
__next40pxDefaultSize
|
|
29
|
+
__nextHasNoMarginBottom
|
|
28
30
|
label="Type"
|
|
29
31
|
hideLabelFromVision={true}
|
|
30
32
|
value={selectedType}
|
|
@@ -13,6 +13,10 @@ export function SortableItemsControl<D>({emptyValue, addRowText, ...baseProps}:
|
|
|
13
13
|
type ButtonsAreaProps<D = any> = Parameters<BaseSortableItemsControlProps<D>['buttonsArea']>[0]&{emptyValue: D, addRowText?: string};
|
|
14
14
|
function ButtonsArea<D>({addHandler, disabled, emptyValue, addRowText}: ButtonsAreaProps<D>) {
|
|
15
15
|
return <div className="plaudit-sortable-items-buttons">
|
|
16
|
-
<Button
|
|
16
|
+
<Button
|
|
17
|
+
icon="insert" disabled={disabled}
|
|
18
|
+
onClick={() => addHandler(typeof emptyValue === 'object' ? {...emptyValue} : emptyValue)}
|
|
19
|
+
__next40pxDefaultSize accessibleWhenDisabled
|
|
20
|
+
>{addRowText ?? "Add Row"}</Button>
|
|
17
21
|
</div>
|
|
18
22
|
}
|