@secretstache/wordpress-gutenberg 0.5.1 → 0.5.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secretstache/wordpress-gutenberg",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "",
5
5
  "author": "Secret Stache",
6
6
  "license": "GPL-2.0-or-later",
package/src/index.d.ts ADDED
@@ -0,0 +1,152 @@
1
+ declare module '@secretstache/wordpress-gutenberg' {
2
+ import { ReactNode, FC } from 'react';
3
+ import { BlockInstance } from '@wordpress/blocks';
4
+
5
+ // Constants
6
+ export const MEDIA_TYPE: {
7
+ IMAGE: 'image';
8
+ VIDEO: 'video';
9
+ ANIMATION: 'animation';
10
+ };
11
+
12
+ // Components
13
+ export interface ColorPaletteControlProps {
14
+ label?: string;
15
+ value: string;
16
+ attributeName: string;
17
+ setAttributes: (attrs: any) => void;
18
+ allowedColors?: string[];
19
+ }
20
+ export const ColorPaletteControl: FC<ColorPaletteControlProps>;
21
+
22
+ export interface MediaControlProps {
23
+ mediaId: number;
24
+ mediaUrl: string;
25
+ mediaFileName?: string;
26
+ onSelect: (media: any) => void;
27
+ onRemove: () => void;
28
+ type?: 'image' | 'video' | 'animation';
29
+ selectButtonLabel?: string;
30
+ removeButtonLabel?: string;
31
+ }
32
+ export const MediaControl: FC<MediaControlProps>;
33
+
34
+ export interface PreviewControlProps {
35
+ checked: boolean;
36
+ onChange: (value: boolean) => void;
37
+ help?: string;
38
+ label?: string;
39
+ }
40
+ export const PreviewControl: FC<PreviewControlProps>;
41
+
42
+ export interface ResourcesWrapperProps {
43
+ isLoading?: boolean;
44
+ isEmptyResources?: boolean;
45
+ isEmptySelection?: boolean;
46
+ isPlaceholder?: boolean;
47
+ emptyResourcesMessage?: string;
48
+ emptySelectionMessage?: string;
49
+ placeholderProps?: {
50
+ icon?: string;
51
+ instructions?: string;
52
+ [key: string]: any;
53
+ };
54
+ children?: ReactNode;
55
+ }
56
+ export const ResourcesWrapper: FC<ResourcesWrapperProps>;
57
+
58
+ export interface DataQueryControlsProps {
59
+ dataSourceLabel?: string;
60
+ dataSource: string;
61
+ onDataSourceChange: (value: string) => void;
62
+ queryTypeLabel?: string;
63
+ queryType: string;
64
+ onQueryTypeChange: (value: string) => void;
65
+ settings: Array<{
66
+ value: string;
67
+ label: string;
68
+ queries?: Array<{
69
+ value: string;
70
+ label: string;
71
+ }>;
72
+ }>;
73
+ }
74
+ export const DataQueryControls: FC<DataQueryControlsProps>;
75
+
76
+ // Hooks
77
+ export function usePreviewControl(): {
78
+ isPreview: boolean;
79
+ setIsPreview: (value: boolean) => void;
80
+ PreviewControl: FC<PreviewControlProps>;
81
+ };
82
+
83
+ export function useThemeColors(allowedColors?: string[]): Array<{
84
+ name: string;
85
+ slug: string;
86
+ color: string;
87
+ }>;
88
+
89
+ export function useColorChange(
90
+ colors: Array<{ color: string; slug: string }>,
91
+ setAttributes: (attrs: any) => void
92
+ ): (colorValue: string, property: string) => void;
93
+
94
+ export function useDataQuery(config: {
95
+ postType: string | (() => string);
96
+ curatedPostsIds?: number[];
97
+ taxonomySlug?: string;
98
+ curatedTermsIds?: number[];
99
+ numberOfPosts?: number;
100
+ extraQueryArgs?: Record<string, any>;
101
+ }, dependencies?: any[]): {
102
+ postsToShow: any[];
103
+ isResolving: boolean;
104
+ isEmpty: boolean;
105
+ };
106
+
107
+ export function useParentBlock(
108
+ parentBlockName: string,
109
+ blockClientIdToLimitSearch?: string
110
+ ): BlockInstance | null;
111
+
112
+ export function useSlider(
113
+ isEnabled: boolean,
114
+ setupSlider: (element: HTMLElement) => any,
115
+ cleanCallback?: () => void,
116
+ dependencies?: any[]
117
+ ): {
118
+ sliderElRef: React.RefObject<HTMLElement>;
119
+ sliderInstance: React.RefObject<any>;
120
+ };
121
+
122
+ export function useAccordionItem(
123
+ itemId: string,
124
+ activeItemId: string | null,
125
+ setActiveItemId: (id: string | null) => void,
126
+ contentSelector: string,
127
+ heightObserverDeps?: any[]
128
+ ): {
129
+ blockRef: React.RefObject<HTMLElement>;
130
+ toggleItem: () => void;
131
+ openContent: () => void;
132
+ closeContent: () => void;
133
+ isActive: boolean;
134
+ };
135
+
136
+ export function useAllowedBlocks(
137
+ blockName: string,
138
+ excludedBlocks?: string[]
139
+ ): string[];
140
+
141
+ export function useChildBlockPosition(
142
+ childClientId: string
143
+ ): {
144
+ block: BlockInstance | null;
145
+ parentBlock: BlockInstance | null;
146
+ position: number;
147
+ };
148
+
149
+ export function useFilterBlocks(
150
+ filter: (block: BlockInstance) => boolean
151
+ ): string[];
152
+ }
@@ -1,9 +1,3 @@
1
- export const QUERY_TYPE = {
2
- LATEST: 'latest',
3
- CURATED: 'curated',
4
- BY_CATEGORY: 'by_category'
5
- };
6
-
7
1
  export const MEDIA_TYPE = {
8
2
  IMAGE: 'image',
9
3
  VIDEO: 'video',
@@ -3,7 +3,7 @@ import apiFetch from '@wordpress/api-fetch';
3
3
  import slugify from 'slugify';
4
4
  import classNames from 'classnames';
5
5
  import { select, subscribe } from '@wordpress/data';
6
- import { getBlockType, unregisterBlockType } from '@wordpress/blocks';
6
+ import { getBlockType, registerBlockType, unregisterBlockType } from '@wordpress/blocks';
7
7
 
8
8
  /**
9
9
  * Loads select options by fetching posts from WordPress REST API.
@@ -234,4 +234,23 @@ const unsetBlockForPostType = (blockName, postType) => {
234
234
  },
235
235
  'core/editor'
236
236
  );
237
+ };
238
+
239
+ /**
240
+ * Update the API version of a specific block.
241
+ *
242
+ * @param {string} blockName - The name of the block to update (e.g., 'gravityforms/form').
243
+ * @param {number} [apiVersion=3] - The API version to set for the block. Defaults to 3.
244
+ */
245
+ export function updateBlockApiVersion(blockName, apiVersion = 3) {
246
+ const blockSettings = getBlockType(blockName);
247
+
248
+ if (blockSettings) {
249
+ unregisterBlockType(blockName);
250
+
251
+ registerBlockType(blockName, {
252
+ ...blockSettings,
253
+ apiVersion,
254
+ });
255
+ }
237
256
  }