@plaudit/gutenberg-api-extensions 2.7.0 → 2.8.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.
Files changed (88) hide show
  1. package/build/blocks/common-native-property-implementations.js +22 -41
  2. package/build/blocks/common-native-property-implementations.js.map +1 -0
  3. package/build/blocks/index.js +1 -0
  4. package/build/blocks/index.js.map +1 -0
  5. package/build/blocks/layered-styles.js +11 -15
  6. package/build/blocks/layered-styles.js.map +1 -0
  7. package/build/blocks/simple-block.js +21 -21
  8. package/build/blocks/simple-block.js.map +1 -0
  9. package/build/blocks/simple-native-property.js +65 -68
  10. package/build/blocks/simple-native-property.js.map +1 -0
  11. package/build/controls/AsynchronousFormTokenField.js +112 -0
  12. package/build/controls/AsynchronousFormTokenField.js.map +1 -0
  13. package/build/controls/ExtendedPostPicker.js +34 -0
  14. package/build/controls/ExtendedPostPicker.js.map +1 -0
  15. package/build/controls/InspectorPanel.js +3 -3
  16. package/build/controls/InspectorPanel.js.map +1 -0
  17. package/build/controls/PickOne.js +9 -10
  18. package/build/controls/PickOne.js.map +1 -0
  19. package/build/controls/SimpleToggle.js +3 -2
  20. package/build/controls/SimpleToggle.js.map +1 -0
  21. package/build/controls/index.js +3 -0
  22. package/build/controls/index.js.map +1 -0
  23. package/build/controls/types.js +1 -0
  24. package/build/controls/types.js.map +1 -0
  25. package/build/index.js +1 -0
  26. package/build/index.js.map +1 -0
  27. package/build/lib/plaudit-icons/column-1.js +3 -3
  28. package/build/lib/plaudit-icons/column-1.js.map +1 -0
  29. package/build/lib/plaudit-icons/column-2.js +3 -3
  30. package/build/lib/plaudit-icons/column-2.js.map +1 -0
  31. package/build/lib/plaudit-icons/column-3.js +3 -3
  32. package/build/lib/plaudit-icons/column-3.js.map +1 -0
  33. package/build/lib/plaudit-icons/placement-center.js +3 -3
  34. package/build/lib/plaudit-icons/placement-center.js.map +1 -0
  35. package/build/lib/plaudit-icons/placement-end.js +3 -3
  36. package/build/lib/plaudit-icons/placement-end.js.map +1 -0
  37. package/build/lib/plaudit-icons/placement-start.js +3 -3
  38. package/build/lib/plaudit-icons/placement-start.js.map +1 -0
  39. package/build/lib/plaudit-icons/placement-stretch.js +3 -3
  40. package/build/lib/plaudit-icons/placement-stretch.js.map +1 -0
  41. package/build/lib/plaudit-icons/plaudit-icon.js +3 -3
  42. package/build/lib/plaudit-icons/plaudit-icon.js.map +1 -0
  43. package/build/lib/plaudit-icons/reusable-block-marker.js +3 -3
  44. package/build/lib/plaudit-icons/reusable-block-marker.js.map +1 -0
  45. package/build/lib/plaudit-icons.js +1 -0
  46. package/build/lib/plaudit-icons.js.map +1 -0
  47. package/package.json +14 -11
  48. package/src/blocks/common-native-property-implementations.tsx +271 -0
  49. package/src/blocks/index.ts +12 -0
  50. package/src/blocks/layered-styles.tsx +108 -0
  51. package/src/blocks/simple-block.tsx +72 -0
  52. package/src/blocks/simple-native-property.tsx +200 -0
  53. package/src/controls/AsynchronousFormTokenField.tsx +151 -0
  54. package/src/controls/ExtendedPostPicker.tsx +50 -0
  55. package/src/controls/InspectorPanel.tsx +16 -0
  56. package/src/controls/PickOne.tsx +80 -0
  57. package/src/controls/SimpleToggle.tsx +9 -0
  58. package/{build/controls/index.d.ts → src/controls/index.ts} +2 -0
  59. package/src/controls/types.ts +11 -0
  60. package/src/lib/plaudit-icons/column-1.tsx +8 -0
  61. package/src/lib/plaudit-icons/column-2.tsx +8 -0
  62. package/src/lib/plaudit-icons/column-3.tsx +8 -0
  63. package/src/lib/plaudit-icons/placement-center.tsx +5 -0
  64. package/src/lib/plaudit-icons/placement-end.tsx +5 -0
  65. package/src/lib/plaudit-icons/placement-start.tsx +5 -0
  66. package/src/lib/plaudit-icons/placement-stretch.tsx +5 -0
  67. package/src/lib/plaudit-icons/plaudit-icon.tsx +6 -0
  68. package/src/lib/plaudit-icons/reusable-block-marker.tsx +5 -0
  69. package/{build/lib/plaudit-icons.d.ts → src/lib/plaudit-icons.ts} +4 -0
  70. package/build/blocks/common-native-property-implementations.d.ts +0 -60
  71. package/build/blocks/index.d.ts +0 -5
  72. package/build/blocks/layered-styles.d.ts +0 -31
  73. package/build/blocks/simple-block.d.ts +0 -22
  74. package/build/blocks/simple-native-property.d.ts +0 -30
  75. package/build/controls/InspectorPanel.d.ts +0 -6
  76. package/build/controls/PickOne.d.ts +0 -19
  77. package/build/controls/SimpleToggle.d.ts +0 -3
  78. package/build/controls/types.d.ts +0 -12
  79. package/build/lib/plaudit-icons/column-1.d.ts +0 -2
  80. package/build/lib/plaudit-icons/column-2.d.ts +0 -2
  81. package/build/lib/plaudit-icons/column-3.d.ts +0 -2
  82. package/build/lib/plaudit-icons/placement-center.d.ts +0 -2
  83. package/build/lib/plaudit-icons/placement-end.d.ts +0 -2
  84. package/build/lib/plaudit-icons/placement-start.d.ts +0 -2
  85. package/build/lib/plaudit-icons/placement-stretch.d.ts +0 -2
  86. package/build/lib/plaudit-icons/plaudit-icon.d.ts +0 -2
  87. package/build/lib/plaudit-icons/reusable-block-marker.d.ts +0 -2
  88. /package/{build/index.d.ts → src/index.ts} +0 -0
@@ -0,0 +1,151 @@
1
+ import {Spinner, FormTokenField} from '@wordpress/components';
2
+ import type {TokenItem} from "@wordpress/components/build-types/form-token-field/types";
3
+ import {__} from "@wordpress/i18n";
4
+ import {useEffect, useState} from '@wordpress/element';
5
+ import debounce from "debounce";
6
+
7
+ // The strange values correspond to the literals that are expected by TokenItem.status, which allows the assignment code to be cleaner
8
+ export const enum ValidationState {
9
+ Valid = 'success',
10
+ Invalid = 'error',
11
+ Validating = 'validating'
12
+ }
13
+
14
+ export interface AsynchronousFormTokenFieldProps {
15
+ label: string;
16
+ value: string[];
17
+ onChange: (value: string[]) => void;
18
+
19
+ validationQuery(tokens: string[]): Promise<Array<TokenItem>>;
20
+ suggestionQuery(input: string): Promise<Array<string>>;
21
+ makeTokenFromSuggestion(suggestion: string): TokenItem;
22
+ validValues: Map<string, ValidationState>;
23
+ validator?: (value: string) => boolean;
24
+ }
25
+
26
+ export function AsynchronousFormTokenField(props: AsynchronousFormTokenFieldProps) {
27
+ const [isInitializing, setIsInitializing] = useState(true);
28
+ const [isLoading, setIsLoading] = useState(false);
29
+ const [isValidating, setIsValidating] = useState(false);
30
+
31
+ const [currentTokens, setCurrentTokens] = useState<Array<TokenItem>>([]);
32
+ const [suggestions, setSuggestions] = useState<Array<string>>([]);
33
+
34
+ const [myValidationRequestQueue] = useState<{queue: Promise<boolean>, currentRequest: number, trigger: (currentTokens: TokenItem[]) => void}>(() => ({
35
+ queue: Promise.resolve(true), currentRequest: 0,
36
+ trigger(currentTokens) {
37
+ const tokensInNeedOfValidation = currentTokens.filter(token => token.status === ValidationState.Validating);
38
+ if (tokensInNeedOfValidation.length > 0) {
39
+ setIsValidating(true);
40
+ const myNumber = ++myValidationRequestQueue.currentRequest;
41
+ myValidationRequestQueue.queue = myValidationRequestQueue.queue.then(async () => {
42
+ const tokensBeingValidatedList = tokensInNeedOfValidation.map(token => token.value).filter(value => !props.validValues.has(value));
43
+ if (tokensBeingValidatedList.length > 0) {
44
+ const tokensBeingValidated = new Set(tokensBeingValidatedList);
45
+ for (const value of tokensBeingValidatedList) {
46
+ props.validValues.set(value, ValidationState.Validating);
47
+ }
48
+ const validatedTokens = await props.validationQuery(tokensBeingValidatedList);
49
+
50
+ for (const validToken of validatedTokens) {
51
+ tokensBeingValidated.delete(validToken.value);
52
+ props.validValues.set(validToken.value, ValidationState.Valid);
53
+ }
54
+ for (const value of tokensBeingValidated) {
55
+ if (props.validValues.get(value) === ValidationState.Validating) {
56
+ props.validValues.set(value, ValidationState.Invalid);
57
+ }
58
+ }
59
+ }
60
+
61
+ if (myNumber === myValidationRequestQueue.currentRequest) {
62
+ let changed = false;
63
+ for (const token of currentTokens) {
64
+ if (token.status === ValidationState.Validating) {
65
+ const status = props.validValues.get(token.value);
66
+ if (status !== undefined && token.status !== status) {
67
+ changed = true;
68
+ token.status = status;
69
+ }
70
+ }
71
+ }
72
+ if (changed) {
73
+ setCurrentTokens(currentTokens);
74
+ }
75
+ setIsValidating(false);
76
+ }
77
+ return true;
78
+ });
79
+ }
80
+ }
81
+ }));
82
+
83
+ const [mySuggestionRequestQueue] = useState<{
84
+ queue: Promise<boolean>, currentRequest: number, debouncer: (input: string) => void
85
+ }>(() => ({
86
+ queue: Promise.resolve(true),
87
+ currentRequest: 0,
88
+ debouncer: debounce(input => {
89
+ if (input.length < 2) {
90
+ setSuggestions([]);
91
+ } else {
92
+ setIsLoading(true);
93
+ const myNumber = ++mySuggestionRequestQueue.currentRequest;
94
+ mySuggestionRequestQueue.queue = mySuggestionRequestQueue.queue.then(async () => {
95
+ if (myNumber === mySuggestionRequestQueue.currentRequest) {
96
+ setSuggestions(await props.suggestionQuery(input));
97
+ setIsLoading(false);
98
+ }
99
+ return true;
100
+ });
101
+ }
102
+ }, 500)
103
+ }));
104
+
105
+ useEffect(() => {
106
+ props.validationQuery(props.value).then(data => {
107
+ const tokenLabels = new Map<string, string|undefined>();
108
+ for (const rep of data) {
109
+ tokenLabels.set(rep.value, rep.title);
110
+ props.validValues.set(rep.value, ValidationState.Valid);
111
+ }
112
+
113
+ for (const value of props.value) {
114
+ if (!props.validValues.has(value)) {
115
+ props.validValues.set(value, ValidationState.Invalid);
116
+ }
117
+ }
118
+ setCurrentTokens(props.value.map(value => ({value, title: tokenLabels.get(value) ?? value, status: props.validValues.get(value)})));
119
+ setIsInitializing(false);
120
+ });
121
+ }, []);
122
+
123
+ useEffect(() => myValidationRequestQueue.trigger(currentTokens), [currentTokens]);
124
+
125
+ if (isInitializing) {
126
+ return <Spinner />;
127
+ }
128
+
129
+ const tokenTitleMappings = new Map(currentTokens.map(currentToken => [currentToken.value, currentToken.title]));
130
+
131
+ return <>
132
+ <FormTokenField
133
+ value={currentTokens}
134
+ label={props.label}
135
+ placeholder="Start typing to see suggestions"
136
+ suggestions={suggestions}
137
+ onChange={tokens => {
138
+ const tokenItems = tokens.map(token => typeof token === 'string' ? props.makeTokenFromSuggestion(token) : token);
139
+
140
+ props.onChange(tokenItems.map(token => token.value));
141
+ setCurrentTokens(tokenItems);
142
+ }}
143
+ __experimentalValidateInput={props.validator}
144
+ __experimentalAutoSelectFirstMatch={true}
145
+ displayTransform={token => tokenTitleMappings.get(token) ?? token}
146
+ onInputChange={mySuggestionRequestQueue.debouncer}
147
+ />
148
+ {isLoading && <div><Spinner /><span className="components-form-token-field__help">{__("Updating Suggestions")}</span></div>}
149
+ {isValidating && <div><Spinner /><span className="components-form-token-field__help">{__("Validating")}</span></div>}
150
+ </>;
151
+ }
@@ -0,0 +1,50 @@
1
+ import apiFetch from '@wordpress/api-fetch';
2
+ import {AsynchronousFormTokenField, ValidationState} from "./AsynchronousFormTokenField";
3
+ import {useState} from "@wordpress/element";
4
+ import {addQueryArgs} from "@wordpress/url";
5
+
6
+ type ExtendedPostPickerProps = {
7
+ onChange: (value: string[]) => void;
8
+ label: string;
9
+ postTypes: string[];
10
+ placeholder: string;
11
+ value: string[]
12
+ };
13
+
14
+ export type ExtendedPostPickerConstructorProps = Partial<Omit<ExtendedPostPickerProps, 'onChange'|'value'|'label'>> & Pick<ExtendedPostPickerProps, 'onChange'|'value'|'label'>;
15
+
16
+ async function makeAPIRequest(data: {search?: string, ids?: string, postTypes?: string}) {
17
+ return (await apiFetch<Array<{ id: number, title: string }>>({path: addQueryArgs("/plaudit/common/v1/post-table-search", data)}))
18
+ .map(item => ({id: item.id.toString(), title: item.title}));
19
+ }
20
+ export function ExtendedPostPicker(props: ExtendedPostPickerConstructorProps) {
21
+ const [validPostIds, _] = useState(new Map<string, ValidationState>());
22
+ const value = props.value ?? [];
23
+ return <AsynchronousFormTokenField
24
+ {...props}
25
+ value={value}
26
+ makeTokenFromSuggestion={token => {
27
+ if (isNumeric(token)) {
28
+ return {value: token, status: validPostIds.get(token) ?? ValidationState.Validating, title: token};
29
+ } else {
30
+ const tokenId = /\(#([0-9]+)\)$/.exec(token)?.[1];
31
+ if (tokenId) {
32
+ return {value: tokenId, status: validPostIds.get(tokenId) ?? ValidationState.Validating, title: token};
33
+ }
34
+ return {value: token, status: ValidationState.Invalid, title: token};
35
+ }
36
+ }}
37
+ suggestionQuery={input => makeAPIRequest({search: input, postTypes: props.postTypes?.join(',')})
38
+ .then(posts => posts.map(post => `${post.title} (#${post.id})`))}
39
+ validationQuery={idsBeingValidated => makeAPIRequest({ids: idsBeingValidated.join(','), postTypes: props.postTypes?.join(',')})
40
+ .then(posts => posts.map(post => ({value: post.id, title: post.title, status: ValidationState.Valid})))}
41
+ validValues={validPostIds}
42
+ validator={token => /\(#([0-9]+)\)$/.exec(token)?.[1] !== undefined}
43
+ />;
44
+ }
45
+
46
+ function isNumeric(str: string|number) {
47
+ if (typeof str !== "string") return true; // we only process strings!
48
+ return !isNaN(str as any) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
49
+ !isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
50
+ }
@@ -0,0 +1,16 @@
1
+ import type {PanelBodyProps} from "@wordpress/components/build-types/panel/types";
2
+ import {InspectorControls} from "@wordpress/block-editor";
3
+ import {PanelBody} from "@wordpress/components";
4
+
5
+ import React from "react";
6
+
7
+ type InspectorControlsType = {
8
+ // WordPress' types don't declare the group parameter, which is what we use to put the InspectorPanel in the correct spot
9
+ (props: InspectorControls.Props & { group?: string }): ReturnType<typeof InspectorControls>;
10
+ } & (typeof InspectorControls);
11
+ export function InspectorPanel(props: PanelBodyProps&{group?: string, condition?(): boolean}) {
12
+ const FullyTypedInspectorControls = InspectorControls as InspectorControlsType;
13
+ return <FullyTypedInspectorControls group={props.group}>
14
+ <PanelBody {...props} children={props.condition === undefined || props.condition() ? props.children : []} />
15
+ </FullyTypedInspectorControls>;
16
+ }
@@ -0,0 +1,80 @@
1
+ import {
2
+ __experimentalToggleGroupControl as ToggleGroupControl,
3
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
4
+ __experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon, BaseControl,
5
+ ColorPalette, RadioControl, SelectControl, useBaseControlProps
6
+ } from "@wordpress/components";
7
+ import type {ColorObject} from "@wordpress/components/build-types/color-palette/types";
8
+
9
+ import type {PickableOptions, SimpleBlockControlProps} from "./types";
10
+
11
+ import React, {type ReactElement} from "react";
12
+
13
+ function makeSharedRadioAndSelectProps<T extends string>(props: SimpleBlockControlProps<T, string>&{options: PickableOptions<string>}) {
14
+ return {
15
+ label: props.label,
16
+ onChange(value: string) {
17
+ props.setAttributes({[props.attribute]: value});
18
+ },
19
+ options: props.options.map(([value, label]) => ({
20
+ value, label: typeof label === 'string' ? label : label.text
21
+ }))
22
+ } as Pick<Parameters<(typeof SelectControl)|(typeof RadioControl)>[0], 'label'|'options'>&{onChange(value: string): void};
23
+ }
24
+
25
+ export type PickOneFromToggleGroupProps<T extends string> = SimpleBlockControlProps<T, string|number>&{options: PickableOptions<string, {icon: ReactElement}>};
26
+ export function PickOneFromToggleGroup<T extends string>(props: PickOneFromToggleGroupProps<T>) {
27
+ return <ToggleGroupControl
28
+ label={props.label}
29
+ value={props.attributes[props.attribute]}
30
+ onChange={value => props.setAttributes({[props.attribute]: value})}
31
+ children={
32
+ props.options.map(([value, label]) => typeof label === 'string'
33
+ ? <ToggleGroupControlOption key={value} value={value} label={label} />
34
+ : <ToggleGroupControlOptionIcon key={value} value={value} label={label.text} icon={label.icon} />)
35
+ }
36
+ />;
37
+ }
38
+
39
+ export function PickOneFromSelect<T extends string>(props: SimpleBlockControlProps<T, string>& { options: PickableOptions<string> }) {
40
+ return <SelectControl
41
+ {...makeSharedRadioAndSelectProps(props)}
42
+ value={props.attributes[props.attribute]}
43
+ />;
44
+ }
45
+ export function PickOneFromRadios<T extends string>(props: SimpleBlockControlProps<T, string>& { options: PickableOptions<string> }) {
46
+ return <RadioControl
47
+ {...makeSharedRadioAndSelectProps(props)}
48
+ selected={props.attributes[props.attribute]}
49
+ />;
50
+ }
51
+
52
+ export function PickOneFromColors<T extends string>(props: SimpleBlockControlProps<T, string>&{options: PickableOptions<string, {color?: string|undefined}>}) {
53
+ const valueToColorMap = new Map<string, string>();
54
+ const colorToValueMap = new Map<string, string>();
55
+ const colors: ColorObject[] = [];
56
+ for (const [value, display] of props.options) {
57
+ if (typeof display === 'string') {
58
+ colors.push({color: value, name: display});
59
+ } else if (display.color) {
60
+ valueToColorMap.set(value, display.color);
61
+ colorToValueMap.set(display.color, value);
62
+ colors.push({color: display.color, name: display.text});
63
+ } else {
64
+ colors.push({color: value, name: display.text});
65
+ }
66
+ }
67
+
68
+ const currentColor = valueToColorMap.get(props.attributes[props.attribute]) ?? props.attributes[props.attribute];
69
+ const {baseControlProps, controlProps} = useBaseControlProps({label: props.label});
70
+ return <BaseControl {...baseControlProps}>
71
+ <ColorPalette
72
+ {...controlProps}
73
+ disableCustomColors={true}
74
+ onChange={color => props.setAttributes({[props.attribute]: colorToValueMap.get(color ?? currentColor) ?? color ?? currentColor})}
75
+ colors={colors}
76
+ value={currentColor}
77
+ clearable={false}
78
+ />
79
+ </BaseControl>;
80
+ }
@@ -0,0 +1,9 @@
1
+ import {ToggleControl} from "@wordpress/components";
2
+
3
+ import type {SimpleBlockControlProps} from "./types";
4
+
5
+ import React from "react";
6
+
7
+ export function SimpleToggle<T extends string>(props: SimpleBlockControlProps<T, boolean>) {
8
+ return <ToggleControl checked={props.attributes[props.attribute]} label={props.label} onChange={checked => props.setAttributes({[props.attribute]: checked})} />;
9
+ }
@@ -1,3 +1,5 @@
1
+ export * from "./AsynchronousFormTokenField";
2
+ export * from "./ExtendedPostPicker";
1
3
  export * from "./InspectorPanel";
2
4
  export * from "./SimpleToggle";
3
5
  export * from "./PickOne";
@@ -0,0 +1,11 @@
1
+ import type {BlockEditProps} from "@wordpress/blocks";
2
+
3
+ export type SpecificValueBlockProps<T extends string, V> = {
4
+ attribute: T, attributes: BlockEditProps<Record<T, V>&Record<string, unknown>>['attributes'],
5
+ setAttributes: BlockEditProps<any>['setAttributes']
6
+ }
7
+ export type SimpleBlockControlProps<T extends string, V> = SpecificValueBlockProps<T, V>&{
8
+ label: string
9
+ };
10
+
11
+ export type PickableOptions<V extends string|number, T extends object = {}> = Array<[V, string|({text: string}&T)]>;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+
3
+ export const iconColumn1 = <svg width={34} height={24} viewBox="0 0 34 24">
4
+ <path
5
+ d="M32 2H2v20h30V2zM2 0C.9 0 0 .9 0 2v20c0 1.1.9 2 2 2h30c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2H2z"
6
+ fillRule="evenodd" clipRule="evenodd"
7
+ />
8
+ </svg>;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+
3
+ export const iconColumn2 = <svg width={34} height={24} viewBox="0 0 34 24">
4
+ <path
5
+ d="M32 0c1.1 0 2 .9 2 2v20c0 1.1-.9 2-2 2H2c-1.1 0-2-.9-2-2V2C0 .9.9 0 2 0h30zm0 22V2H18v20h14zm-16 0H2V2h14v20z"
6
+ fillRule="evenodd" clipRule="evenodd"
7
+ />
8
+ </svg>;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+
3
+ export const iconColumn3 = <svg width={34} height={24} viewBox="0 0 34 24">
4
+ <path
5
+ d="M34 2c0-1.1-.9-2-2-2H2C.9 0 0 .9 0 2v20c0 1.1.9 2 2 2h30c1.1 0 2-.9 2-2V2zM21.5 22h-9V2h9v20zm2 0V2H32v20h-8.5zm-13 0H2V2h8.5v20z"
6
+ fillRule="evenodd" clipRule="evenodd"
7
+ />
8
+ </svg>;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+
3
+ export const placementCenter = <svg version="1.1" x="0px" y="0px" focusable={false} viewBox="0 0 24 24" enableBackground="new 0 0 24 24" xmlSpace="preserve">
4
+ <path d="M20,11h-5V4H9v7H4v1.5h5V20h6v-7.5h5V11z" />
5
+ </svg>;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+
3
+ export const placementEnd = <svg version="1.1" x="0px" y="0px" focusable={false} viewBox="0 0 24 24" enableBackground="new 0 0 24 24" xmlSpace="preserve">
4
+ <path d="M15,4H9v11h6V4z M4,18.5V20h16v-1.5H4z" />
5
+ </svg>;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+
3
+ export const placementStart = <svg version="1.1" x="0px" y="0px" focusable={false} viewBox="0 0 24 24" enableBackground="new 0 0 24 24" xmlSpace="preserve">
4
+ <path d="M9,20h6V9H9V20z M4,4v1.5h16V4H4z" />
5
+ </svg>;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+
3
+ export const placementStretch = <svg version="1.1" x="0px" y="0px" focusable={false} viewBox="0 0 24 24" enableBackground="new 0 0 24 24" xmlSpace="preserve">
4
+ <path d="M8.8,6.5h6v11h-6V6.5z M4,18.5h16V20H4V18.5z M4,4h16v1.5H4V4z" />
5
+ </svg>;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+
3
+ export const plauditIcon = <svg width={24} height={24} viewBox="0 0 139 157.6">
4
+ <path fill="#d20000"
5
+ d="M83.3 39.1L101.6 9c2-3.2.9-7.1-2.4-8.5s-6.9.4-7.9 4l-9.7 33.9c-1.1 3.6-.3 4 1.7.7zm-43.9 19L9 40.5c-3.3-1.9-7.1-.7-8.5 2.6s.5 6.8 4.2 7.8l34.1 8.9c3.7 1 4 .2.6-1.7zm16.3-19c2 3.2 2.7 2.9 1.7-.7L47.6 4.5C46.5.8 43-1 39.7.5S35.3 5.8 37.3 9l18.4 30.1zm82.8 4c-1.4-3.3-5.2-4.5-8.5-2.6L99.5 58.1c-3.3 1.9-3 2.7.7 1.7l34.1-8.9c3.7-1 5.6-4.5 4.2-7.8zM88.8 57.7c-10.6-18.3-28-18.3-38.7 0l-38.7 66.6c-10.6 18.3-1.9 33.3 19.3 33.3h77.4c21.3 0 30-15 19.3-33.3L88.8 57.7zm-19.3 1c7.1 0 12.8 5.8 12.7 12.9s-5.8 12.8-12.9 12.7c-7 0-12.7-5.8-12.8-12.8.1-7.1 5.8-12.9 13-12.8zm32 91.2h-64c-17.6 0-24.8-8.1-16-18l32-35.9c8.8-9.9 23.2-9.9 32 0l32 35.9c8.8 9.9 1.6 17.9-16 18z" />
6
+ </svg>;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+
3
+ export const reusableBlockMarker = <svg viewBox="0 0 24 24">
4
+ <path d="M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" />
5
+ </svg>
@@ -1,3 +1,7 @@
1
+ // =============================================
2
+ // Allows sharing of assets in block configurations
3
+ // =============================================
4
+
1
5
  export * from './plaudit-icons/column-1';
2
6
  export * from './plaudit-icons/column-2';
3
7
  export * from './plaudit-icons/column-3';
@@ -1,60 +0,0 @@
1
- import type { BlockIcon } from "@wordpress/blocks";
2
- import type { RadioControlProps } from "@wordpress/components/build-types/radio-control/types";
3
- import type { RangeControlProps } from "@wordpress/components/build-types/range-control/types";
4
- import type { TextControlProps } from "@wordpress/components/build-types/text-control/types";
5
- import type { TextareaControlProps } from "@wordpress/components/build-types/textarea-control/types";
6
- import type { ToggleControlProps } from "@wordpress/components/build-types/toggle-control/types";
7
- import type { ToggleGroupControlProps } from "@wordpress/components/build-types/toggle-group-control/types";
8
- import type { PickableOptions } from "../controls/types";
9
- import type { SimpleNativeProperty } from "./simple-native-property";
10
- export type ActualBlockEditProps = {
11
- attributes: Record<string, any>;
12
- setAttributes: (attributes: Record<string, any>) => void;
13
- name: string;
14
- };
15
- type CommonPropertyConfig<T, V> = {
16
- name: string;
17
- label: string;
18
- default: T;
19
- enum?: T[];
20
- component?: Partial<V>;
21
- help?: string;
22
- alwaysStore?: boolean;
23
- condition?(blockEditProps: ActualBlockEditProps): boolean;
24
- };
25
- export declare function rangeProperty(config: CommonPropertyConfig<number, RangeControlProps> & {
26
- min: number;
27
- max: number;
28
- step?: number;
29
- enum?: number[];
30
- }): SimpleNativeProperty;
31
- export declare function radioProperty(config: CommonPropertyConfig<string, RadioControlProps> & {
32
- options: PickableOptions<string>;
33
- }): SimpleNativeProperty;
34
- export declare function selectProperty(config: CommonPropertyConfig<string, never> & {
35
- options: PickableOptions<string>;
36
- }): SimpleNativeProperty;
37
- export declare function toggleProperty(config: CommonPropertyConfig<boolean, ToggleControlProps>): SimpleNativeProperty;
38
- type ToggleGroupPropertyConfigBase<T extends string | number> = CommonPropertyConfig<T, ToggleGroupControlProps> & {
39
- options: PickableOptions<T, {
40
- icon: BlockIcon;
41
- }>;
42
- };
43
- export type ToggleGroupPropertyConfig = ToggleGroupPropertyConfigBase<string> | ToggleGroupPropertyConfigBase<number>;
44
- export declare function toggleGroupProperty(config: ToggleGroupPropertyConfig): SimpleNativeProperty;
45
- export declare function textProperty(config: CommonPropertyConfig<string, TextControlProps>): SimpleNativeProperty;
46
- export declare function textareaProperty(config: CommonPropertyConfig<string, TextareaControlProps>): SimpleNativeProperty;
47
- export type ImagePropertyData = {
48
- media?: {
49
- id?: number;
50
- url?: string;
51
- };
52
- pos?: {
53
- x?: number;
54
- y?: number;
55
- };
56
- };
57
- export declare function imageProperty(config: Omit<CommonPropertyConfig<ImagePropertyData, {}>, 'default'> & Partial<Pick<CommonPropertyConfig<ImagePropertyData, {}>, 'default'>> & {
58
- enableFocalPointPicker?: boolean;
59
- }): SimpleNativeProperty;
60
- export {};
@@ -1,5 +0,0 @@
1
- export * from "./simple-block";
2
- export * from "./layered-styles";
3
- export * from "./simple-native-property";
4
- export * from './common-native-property-implementations';
5
- export declare function installGutenbergBlockExtensions(): void;
@@ -1,31 +0,0 @@
1
- import type { BlockIcon } from "@wordpress/blocks";
2
- import type { PickableOptions } from "../controls/types";
3
- type BaseLayeredBlockStyleLayer = {
4
- name: string;
5
- title: string;
6
- default?: string | undefined;
7
- };
8
- type LayeredBlockStyleColorLayer = BaseLayeredBlockStyleLayer & {
9
- picker: 'color';
10
- options: PickableOptions<string, {
11
- color?: string;
12
- }>;
13
- };
14
- type LayeredBlockStyleToggleLayer = BaseLayeredBlockStyleLayer & {
15
- picker?: 'toggle-control';
16
- options: PickableOptions<string, {
17
- icon: BlockIcon;
18
- }>;
19
- };
20
- type LayeredBlockStyleSelectOrRadioLayer = BaseLayeredBlockStyleLayer & {
21
- picker: 'select' | 'radio';
22
- options: PickableOptions<string>;
23
- };
24
- export type LayeredBlockStyleLayer = LayeredBlockStyleColorLayer | LayeredBlockStyleToggleLayer | LayeredBlockStyleSelectOrRadioLayer;
25
- export interface LayeredBlockStylesConfig {
26
- block: `${string}/${string}`;
27
- layers: LayeredBlockStyleLayer[];
28
- }
29
- export declare function registerLayeredBlockStyles(config: LayeredBlockStylesConfig): void;
30
- export declare function installLayeredBlockStylesSupport(): void;
31
- export {};
@@ -1,22 +0,0 @@
1
- import { type Block, type BlockConfiguration, type BlockSaveProps } from "@wordpress/blocks";
2
- import { InnerBlocks } from "@wordpress/block-editor";
3
- import type { UseBlockProps } from "@wordpress/block-editor/components/use-block-props";
4
- import React, { type ComponentType, type ReactNode } from "react";
5
- export type SimpleBlockTypeConfig<TAttributes extends Record<string, any>> = {
6
- icon?: BlockConfiguration<TAttributes>['icon'] | undefined;
7
- defaults?: Required<TAttributes>;
8
- controls?: NonNullable<Block<TAttributes>['edit']>;
9
- renderer: (attributes: BlockSaveProps<TAttributes>, wrapperProps: UseBlockProps | UseBlockProps['save'], InnerBlocks: () => React.ReactElement, mode: "edit" | "save") => ReactNode;
10
- innerBlocksProps?: InnerBlocks.Props;
11
- settings?: Partial<BlockConfiguration<TAttributes>>;
12
- };
13
- declare function applyDefaults<TAttributes extends Record<string, any>, K extends BlockSaveProps<TAttributes>>(config: Omit<SimpleBlockTypeConfig<TAttributes>, 'renderer'>, props: K): Omit<K, "attributes"> & {
14
- attributes: { [P in keyof K["attributes"]]: K["attributes"][P]; };
15
- };
16
- export declare function registerSimpleBlockType<TAttributes extends Record<string, any> = {}>(metadata: BlockConfiguration<TAttributes>, config: SimpleBlockTypeConfig<TAttributes>): Block<TAttributes> | undefined;
17
- type SimpleContainerTypeConfig<TAttributes extends Record<string, any>> = Omit<SimpleBlockTypeConfig<TAttributes>, 'renderer'> & {
18
- tag?: ComponentType;
19
- attributesFromProps?: (arg: ReturnType<typeof applyDefaults<TAttributes, BlockSaveProps<TAttributes>>>, mode: "edit" | "save") => Parameters<UseBlockProps | UseBlockProps['save']>[0];
20
- };
21
- export declare function registerSimpleContainerBlock<TAttributes extends Record<string, any> = {}>(metadata: BlockConfiguration<TAttributes>, config: SimpleContainerTypeConfig<TAttributes>): Block<TAttributes> | undefined;
22
- export {};
@@ -1,30 +0,0 @@
1
- import type { ActualBlockEditProps } from "./common-native-property-implementations";
2
- import React from "react";
3
- export type InspectorPanelGroup = 'default' | 'advanced' | 'background' | 'border' | 'color' | 'dimensions' | 'effects' | 'filter' | 'list' | 'position' | 'settings' | 'styles' | 'typography';
4
- type GenericSimpleNativeProperty<T, V extends 'string' | 'number' | 'boolean' | 'array' | 'object'> = {
5
- name: string;
6
- type: V;
7
- enum?: T[];
8
- default: T;
9
- alwaysStore?: boolean;
10
- renderer(value: T, onChange: (v: T | undefined) => void): React.JSX.Element;
11
- condition?(blockEditProps: ActualBlockEditProps): boolean;
12
- };
13
- export type SimpleNativeProperty = GenericSimpleNativeProperty<string, 'string'> & {
14
- enum?: string[];
15
- } | GenericSimpleNativeProperty<number, 'number'> & {
16
- enum?: number[];
17
- } | GenericSimpleNativeProperty<boolean, 'boolean'> | GenericSimpleNativeProperty<any[], 'array'> | GenericSimpleNativeProperty<Record<string | number, unknown>, 'object'>;
18
- export type SimpleNativePanel = {
19
- title: string;
20
- group?: InspectorPanelGroup;
21
- initialOpen?: boolean;
22
- properties: SimpleNativeProperty[];
23
- condition?(blockEditProps: ActualBlockEditProps): boolean;
24
- };
25
- export declare function registerSimpleNativeProperties(config: {
26
- block: `${string}/${string}` | Array<`${string}/${string}`>;
27
- panel: SimpleNativePanel | Array<SimpleNativePanel>;
28
- }): void;
29
- export declare function installSimpleNativePropertiesSupport(): void;
30
- export {};
@@ -1,6 +0,0 @@
1
- import type { PanelBodyProps } from "@wordpress/components/build-types/panel/types";
2
- import React from "react";
3
- export declare function InspectorPanel(props: PanelBodyProps & {
4
- group?: string;
5
- condition?(): boolean;
6
- }): React.JSX.Element;
@@ -1,19 +0,0 @@
1
- import type { PickableOptions, SimpleBlockControlProps } from "./types";
2
- import React, { type ReactElement } from "react";
3
- export type PickOneFromToggleGroupProps<T extends string> = SimpleBlockControlProps<T, string | number> & {
4
- options: PickableOptions<string, {
5
- icon: ReactElement;
6
- }>;
7
- };
8
- export declare function PickOneFromToggleGroup<T extends string>(props: PickOneFromToggleGroupProps<T>): React.JSX.Element;
9
- export declare function PickOneFromSelect<T extends string>(props: SimpleBlockControlProps<T, string> & {
10
- options: PickableOptions<string>;
11
- }): React.JSX.Element;
12
- export declare function PickOneFromRadios<T extends string>(props: SimpleBlockControlProps<T, string> & {
13
- options: PickableOptions<string>;
14
- }): React.JSX.Element;
15
- export declare function PickOneFromColors<T extends string>(props: SimpleBlockControlProps<T, string> & {
16
- options: PickableOptions<string, {
17
- color?: string | undefined;
18
- }>;
19
- }): React.JSX.Element;
@@ -1,3 +0,0 @@
1
- import type { SimpleBlockControlProps } from "./types";
2
- import React from "react";
3
- export declare function SimpleToggle<T extends string>(props: SimpleBlockControlProps<T, boolean>): React.JSX.Element;
@@ -1,12 +0,0 @@
1
- import type { BlockEditProps } from "@wordpress/blocks";
2
- export type SpecificValueBlockProps<T extends string, V> = {
3
- attribute: T;
4
- attributes: BlockEditProps<Record<T, V> & Record<string, unknown>>['attributes'];
5
- setAttributes: BlockEditProps<any>['setAttributes'];
6
- };
7
- export type SimpleBlockControlProps<T extends string, V> = SpecificValueBlockProps<T, V> & {
8
- label: string;
9
- };
10
- export type PickableOptions<V extends string | number, T extends object = {}> = Array<[V, string | ({
11
- text: string;
12
- } & T)]>;
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const iconColumn1: React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const iconColumn2: React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const iconColumn3: React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const placementCenter: React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const placementEnd: React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const placementStart: React.JSX.Element;
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const placementStretch: React.JSX.Element;