| 1 |
/** |
| 2 |
* Shared type definitions for Sliderberg shared components |
| 3 |
*/ |
| 4 |
|
| 5 |
import { ReactNode } from "react"; |
| 6 |
|
| 7 |
/** |
| 8 |
* Base props interface for most controls |
| 9 |
*/ |
| 10 |
export interface BaseControlProps { |
| 11 |
label: string; |
| 12 |
attrKey: string; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Props for controls that integrate with ToolsPanel |
| 17 |
*/ |
| 18 |
export interface ToolsPanelControlProps extends BaseControlProps { |
| 19 |
showDefault?: boolean; |
| 20 |
isSingle?: boolean; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Props for BorderControl component |
| 25 |
*/ |
| 26 |
export interface BorderControlProps { |
| 27 |
borderLabel: string; |
| 28 |
attrBorderKey: string; |
| 29 |
borderRadiusLabel: string; |
| 30 |
attrBorderRadiusKey: string; |
| 31 |
isShowBorder?: boolean; |
| 32 |
isShowBorderRadius?: boolean; |
| 33 |
showDefaultBorder?: boolean; |
| 34 |
showDefaultBorderRadius?: boolean; |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Props for ColorSettings component |
| 39 |
*/ |
| 40 |
export interface ColorSettingsProps { |
| 41 |
label: string; |
| 42 |
attrKey: string; |
| 43 |
onAttributesUpdate?: (attrs: Record<string, any>) => void; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Props for ColorSettingsWithGradient component |
| 48 |
*/ |
| 49 |
export interface ColorSettingsWithGradientProps { |
| 50 |
label: string; |
| 51 |
attrBackgroundKey: string; |
| 52 |
attrGradientKey: string; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Props for BackgroundImageControl component |
| 57 |
*/ |
| 58 |
export interface BackgroundImageControlProps { |
| 59 |
label?: string; |
| 60 |
panelId?: string; |
| 61 |
hasImage?: boolean; |
| 62 |
onUploadError?: (message: string) => void; |
| 63 |
onImageChange?: (media: any) => void; |
| 64 |
onImageRemove?: () => void; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Props for ToolsPanelWrapper component |
| 69 |
*/ |
| 70 |
export interface ToolsPanelWrapperProps { |
| 71 |
label: string; |
| 72 |
resetAll?: () => void; |
| 73 |
children: React.ReactNode; |
| 74 |
className?: string; |
| 75 |
dropdownMenuProps?: Record<string, any>; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Props for ToolsPanelItemWrapper component |
| 80 |
*/ |
| 81 |
export interface ToolsPanelItemWrapperProps { |
| 82 |
label: string; |
| 83 |
hasValue: () => boolean; |
| 84 |
onDeselect?: () => void; |
| 85 |
isShownByDefault?: boolean; |
| 86 |
children: React.ReactNode; |
| 87 |
className?: string; |
| 88 |
panelId?: string; |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* Props for SelectControl component |
| 93 |
*/ |
| 94 |
export interface SelectControlProps { |
| 95 |
label: string; |
| 96 |
value: any; |
| 97 |
onChange?: (value: any) => void; |
| 98 |
options: Array<{ label: string; value: any }>; |
| 99 |
disabled?: boolean; |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* Props for SpacingControl component |
| 104 |
*/ |
| 105 |
export interface SpacingControlProps extends BaseControlProps { |
| 106 |
minimumCustomValue?: number; |
| 107 |
sides?: string[]; |
| 108 |
} |
| 109 |
|
| 110 |
/** |
| 111 |
* Props for SpacingControlWithToolsPanel component |
| 112 |
*/ |
| 113 |
export interface SpacingControlWithToolsPanelProps extends BaseControlProps { |
| 114 |
showByDefault?: boolean; |
| 115 |
minimumCustomValue?: number; |
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* Tab definition for TabsPanelControl |
| 120 |
*/ |
| 121 |
export interface TabDefinition { |
| 122 |
name: string; |
| 123 |
title: string; |
| 124 |
component: ReactNode; |
| 125 |
} |
| 126 |
|
| 127 |
/** |
| 128 |
* Props for TabsPanelControl component |
| 129 |
*/ |
| 130 |
export interface TabsPanelControlProps { |
| 131 |
tabs: TabDefinition[]; |
| 132 |
} |
| 133 |
|
| 134 |
/** |
| 135 |
* Toggle group option definition |
| 136 |
*/ |
| 137 |
export interface ToggleGroupOption { |
| 138 |
value: any; |
| 139 |
icon?: JSX.Element; |
| 140 |
label: string; |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Props for ToggleGroupControl component |
| 145 |
*/ |
| 146 |
export interface ToggleGroupControlProps { |
| 147 |
label: string; |
| 148 |
options: ToggleGroupOption[]; |
| 149 |
attributeKey: string; |
| 150 |
isBlock?: boolean; |
| 151 |
isAdaptiveWidth?: boolean; |
| 152 |
} |
| 153 |
|
| 154 |
/** |
| 155 |
* Font appearance value structure. |
| 156 |
*/ |
| 157 |
export interface FontAppearanceValue { |
| 158 |
fontStyle?: string; |
| 159 |
fontWeight?: string; |
| 160 |
} |
| 161 |
|
| 162 |
/** |
| 163 |
* Props for shared font appearance control wrapper. |
| 164 |
*/ |
| 165 |
export interface FontAppearanceControlProps { |
| 166 |
attrKey: string; |
| 167 |
label: string; |
| 168 |
showDefault?: boolean; |
| 169 |
defaultValue?: FontAppearanceValue; |
| 170 |
onAttributesUpdate?: (attrs: Record<string, any>) => void; |
| 171 |
hasFontStyles?: boolean; |
| 172 |
hasFontWeights?: boolean; |
| 173 |
fontFamilyFaces?: Array<Record<string, any>>; |
| 174 |
} |
| 175 |
|
| 176 |
/** |
| 177 |
* Props for FontAppearanceControlWithToolsPanel component |
| 178 |
*/ |
| 179 |
export interface FontAppearanceControlWithToolsPanelProps |
| 180 |
extends FontAppearanceControlProps { |
| 181 |
isShownByDefault?: boolean; |
| 182 |
} |
| 183 |
|
| 184 |
/** |
| 185 |
* Props for shared font size picker wrapper. |
| 186 |
*/ |
| 187 |
export interface CustomFontSizePickerProps { |
| 188 |
attrKey: string; |
| 189 |
label: string; |
| 190 |
showDefault?: boolean; |
| 191 |
defaultValue?: number | string; |
| 192 |
onAttributesUpdate?: (attrs: Record<string, any>) => void; |
| 193 |
withSlider?: boolean; |
| 194 |
withReset?: boolean; |
| 195 |
fallbackFontSize?: number; |
| 196 |
} |
| 197 |
|
| 198 |
/** |
| 199 |
* Props for CustomFontSizePickerWithToolsPanel component |
| 200 |
*/ |
| 201 |
export interface CustomFontSizePickerWithToolsPanelProps |
| 202 |
extends CustomFontSizePickerProps { |
| 203 |
label: string; |
| 204 |
isShownByDefault?: boolean; |
| 205 |
} |
| 206 |
|
| 207 |
/** |
| 208 |
* WordPress color palette structure |
| 209 |
*/ |
| 210 |
export interface WordPressColorPalette { |
| 211 |
name: string; |
| 212 |
slug: string; |
| 213 |
colors?: Array<{ name: string; slug: string; color: string }>; |
| 214 |
} |
| 215 |
|
| 216 |
/** |
| 217 |
* Props for BorderControlWithToolsPanel component |
| 218 |
*/ |
| 219 |
export interface BorderControlWithToolsPanelProps { |
| 220 |
borderLabel: string; |
| 221 |
attrBorderKey: string; |
| 222 |
borderRadiusLabel: string; |
| 223 |
attrBorderRadiusKey: string; |
| 224 |
isShowBorder?: boolean; |
| 225 |
isShowBorderRadius?: boolean; |
| 226 |
showDefaultBorder?: boolean; |
| 227 |
showDefaultBorderRadius?: boolean; |
| 228 |
} |
| 229 |
|
| 230 |
/** |
| 231 |
* Props for ColorSettingsWithToolsPanel component |
| 232 |
*/ |
| 233 |
export interface ColorSettingsWithToolsPanelProps { |
| 234 |
label: string; |
| 235 |
attrKey: string; |
| 236 |
onAttributesUpdate?: (attrs: Record<string, any>) => void; |
| 237 |
} |
| 238 |
|
| 239 |
/** |
| 240 |
* Props for ColorSettingsWithGradientWithToolsPanel component |
| 241 |
*/ |
| 242 |
export interface ColorSettingsWithGradientWithToolsPanelProps { |
| 243 |
label: string; |
| 244 |
attrBackgroundKey: string; |
| 245 |
attrGradientKey: string; |
| 246 |
} |
| 247 |
|
| 248 |
/** |
| 249 |
* Props for RangeControlWithToolsPanel component |
| 250 |
*/ |
| 251 |
export interface RangeControlWithToolsPanelProps { |
| 252 |
label: string; |
| 253 |
attrKey: string; |
| 254 |
min?: number; |
| 255 |
max?: number; |
| 256 |
step?: number; |
| 257 |
defaultValue?: number; |
| 258 |
required?: boolean; |
| 259 |
isShownByDefault?: boolean; |
| 260 |
} |
| 261 |
|
| 262 |
/** |
| 263 |
* Props for SelectControlWithToolsPanel component |
| 264 |
*/ |
| 265 |
export interface SelectControlWithToolsPanelProps { |
| 266 |
label: string; |
| 267 |
attrKey: string; |
| 268 |
options: Array<{ label: string; value: any }>; |
| 269 |
defaultValue?: string; |
| 270 |
help?: string; |
| 271 |
isShownByDefault?: boolean; |
| 272 |
} |
| 273 |
|
| 274 |
/** |
| 275 |
* Props for ToggleGroupControlWithToolsPanel component |
| 276 |
*/ |
| 277 |
export interface ToggleGroupControlWithToolsPanelProps { |
| 278 |
label: string; |
| 279 |
attrKey: string; |
| 280 |
options: ToggleGroupOption[]; |
| 281 |
defaultValue?: any; |
| 282 |
isShownByDefault?: boolean; |
| 283 |
} |
| 284 |
|
| 285 |
/** |
| 286 |
* Props for ToggleControlWithToolsPanel component |
| 287 |
*/ |
| 288 |
export interface ToggleControlWithToolsPanelProps { |
| 289 |
label: string; |
| 290 |
attrKey: string; |
| 291 |
defaultValue?: boolean; |
| 292 |
isShownByDefault?: boolean; |
| 293 |
help?: string; |
| 294 |
} |
| 295 |
|