@grapesjs/studio-sdk-plugins 1.0.33-rc.1 → 1.0.33
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/dist/accordionComponent/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +161 -156
- package/dist/accordionComponent/index.umd.js +9 -9
- package/dist/aiChat/chatManager.d.ts +15 -0
- package/dist/aiChat/clientTools.d.ts +3 -3
- package/dist/aiChat/clientToolsProcessors.d.ts +14 -1
- package/dist/aiChat/components/AiChatEmptyState.d.ts +4 -6
- package/dist/aiChat/components/AiChatError.d.ts +2 -1
- package/dist/aiChat/components/AiChatHeader.d.ts +2 -1
- package/dist/aiChat/components/AiChatInput/AssetsSection.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/AttachButton.d.ts +10 -0
- package/dist/aiChat/components/AiChatInput/ContextSection.d.ts +5 -0
- package/dist/aiChat/components/AiChatInput/DictateButton.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/TextAreaWithAutoResize.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/constants.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/hooks/useSpeechToText.d.ts +15 -0
- package/dist/aiChat/components/AiChatInput/index.d.ts +37 -0
- package/dist/aiChat/components/AiChatLoadingState.d.ts +2 -1
- package/dist/aiChat/components/AiChatMessage.d.ts +21 -9
- package/dist/aiChat/components/AiChatMessages.d.ts +5 -7
- package/dist/aiChat/components/AiChatMessagesStatus.d.ts +5 -0
- package/dist/aiChat/components/AiChatPanel.d.ts +2 -3
- package/dist/aiChat/components/AiChatProvider.d.ts +14 -0
- package/dist/aiChat/components/MemoizedMarkdown.d.ts +9 -0
- package/dist/aiChat/components/index.d.ts +24 -25
- package/dist/aiChat/components/utils.d.ts +12 -4
- package/dist/aiChat/index.cjs.d.ts +5 -0
- package/dist/aiChat/index.cjs.js +453 -0
- package/dist/aiChat/index.d.ts +4 -3
- package/dist/aiChat/index.es.d.ts +5 -0
- package/dist/aiChat/index.es.js +30930 -0
- package/dist/aiChat/index.js +453 -0
- package/dist/aiChat/index.umd.js +453 -0
- package/dist/aiChat/locales/en.d.ts +64 -0
- package/dist/aiChat/server/index.cjs.d.ts +4 -0
- package/dist/aiChat/server/index.cjs.js +309 -0
- package/dist/aiChat/server/index.d.ts +0 -50
- package/dist/aiChat/server/index.es.d.ts +4 -0
- package/dist/aiChat/server/index.es.js +876 -0
- package/dist/aiChat/server/index.js +309 -0
- package/dist/aiChat/server/index.umd.js +309 -0
- package/dist/aiChat/server/stream.d.ts +0 -6
- package/dist/aiChat/server/tools.d.ts +157 -51
- package/dist/aiChat/server/types.d.ts +108 -64
- package/dist/aiChat/types.d.ts +148 -108
- package/dist/aiChat/typesSchema.d.ts +238 -25
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +174 -169
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +161 -156
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +113 -108
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +137 -132
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +4 -4
- package/dist/canvasGridMode/index.es.js +168 -163
- package/dist/canvasGridMode/index.umd.js +8 -8
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +132 -127
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +5 -5
- package/dist/dataSourceEjs/index.es.js +151 -146
- package/dist/dataSourceEjs/index.umd.js +5 -5
- package/dist/dataSourceHandlebars/index.cjs.js +4 -4
- package/dist/dataSourceHandlebars/index.es.js +91 -86
- package/dist/dataSourceHandlebars/index.umd.js +5 -5
- package/dist/dialogComponent/index.cjs.js +16 -16
- package/dist/dialogComponent/index.es.js +117 -112
- package/dist/dialogComponent/index.umd.js +16 -16
- package/dist/flexComponent/index.cjs.js +11 -11
- package/dist/flexComponent/index.es.js +416 -411
- package/dist/flexComponent/index.umd.js +11 -11
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +152 -147
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +127 -122
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +170 -165
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +27 -22
- package/dist/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +156 -151
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +197 -192
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +86 -81
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +121 -116
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +4 -4
- package/dist/presetPrintable/index.es.js +180 -175
- package/dist/presetPrintable/index.umd.js +4 -4
- package/dist/prosemirror/index.cjs.js +6 -6
- package/dist/prosemirror/index.es.js +128 -123
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +127 -122
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +160 -155
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +25 -25
- package/dist/shapeDividerComponent/index.es.js +127 -122
- package/dist/shapeDividerComponent/index.umd.js +25 -25
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +197 -192
- package/dist/swiperComponent/index.umd.js +9 -9
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +227 -222
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +12 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +124 -119
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +5 -2
- package/dist/aiChat/components/AiChatInput.d.ts +0 -17
- package/dist/aiChat/server/stream-utils.d.ts +0 -16
|
@@ -1,41 +1,254 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
export interface AiChatOptions {
|
|
1
|
+
import { SDKPluginOptions } from '../utils';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
export interface AiChatOptions extends SDKPluginOptions {
|
|
6
4
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* '
|
|
5
|
+
* Custom endpoint for the chat API
|
|
6
|
+
* @examples
|
|
7
|
+
* chatApi: '/my/ai/chat'
|
|
8
|
+
* chatApi: () => '/my/ai/chat'
|
|
11
9
|
*/
|
|
12
|
-
|
|
10
|
+
chatApi?: string | '__fn__';
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
12
|
+
* Customize or extend the default client-side tools
|
|
13
|
+
* @examples
|
|
14
|
+
* tools: ({ defaultTools, editor }) => ({
|
|
15
|
+
* ...defaultTools,
|
|
16
|
+
* getUserLocation: {
|
|
17
|
+
* async execute() {
|
|
18
|
+
* const location = await getLocationViaBrowserAPI();
|
|
19
|
+
* return `User location: ${location.city}`;
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* })
|
|
23
|
+
*/
|
|
24
|
+
tools?: '__fn__';
|
|
25
|
+
/**
|
|
26
|
+
* Callback when a client tool call is made
|
|
27
|
+
* @examples
|
|
28
|
+
* onTool: ({ toolCall }) => {
|
|
29
|
+
* console.log('Tool call:', toolCall);
|
|
30
|
+
* }
|
|
31
|
+
*/
|
|
32
|
+
onTool?: '__fn__';
|
|
33
|
+
/**
|
|
34
|
+
* Customize UI layout component props
|
|
35
|
+
* @examples
|
|
36
|
+
* layoutComponents: {
|
|
37
|
+
* aiChatInput: () => ({
|
|
38
|
+
* maxImages: 3,
|
|
39
|
+
* }),
|
|
40
|
+
* }
|
|
16
41
|
*/
|
|
17
|
-
|
|
42
|
+
layoutComponents?: object;
|
|
18
43
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
44
|
+
* Initial messages or async function to load messages
|
|
45
|
+
* @examples
|
|
46
|
+
* // Static messages
|
|
47
|
+
* messages: [{ id: '1', role: 'user', ... }]
|
|
48
|
+
* // Dynamic loading
|
|
49
|
+
* messages: async () => {
|
|
50
|
+
* return await loadFromDatabase();
|
|
51
|
+
* }
|
|
21
52
|
*/
|
|
22
|
-
|
|
53
|
+
messages?: object | '__fn__';
|
|
23
54
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
55
|
+
* Callback when messages are updated (for persistence)
|
|
56
|
+
* @examples
|
|
57
|
+
* onMessagesUpdate: async ({ messages }) => {
|
|
58
|
+
* await saveToDatabase(messages);
|
|
59
|
+
* }
|
|
26
60
|
*/
|
|
27
|
-
|
|
61
|
+
onMessagesUpdate?: '__fn__';
|
|
28
62
|
/**
|
|
29
|
-
*
|
|
63
|
+
* Request body for API calls (merged with default body)
|
|
64
|
+
* @examples
|
|
65
|
+
* body: ({ body }) => ({
|
|
66
|
+
* ...body,
|
|
67
|
+
* projectId: 'my-project'
|
|
68
|
+
* })
|
|
69
|
+
* body: { projectId: 'my-project' }
|
|
70
|
+
*/
|
|
71
|
+
body?: object | '__fn__';
|
|
72
|
+
/**
|
|
73
|
+
* Function to get the access token
|
|
74
|
+
* @examples
|
|
75
|
+
* getAccessToken: async () => {
|
|
76
|
+
* const result = await fetch('/api/access-tokens', {
|
|
77
|
+
* method: 'POST',
|
|
78
|
+
* }).then(response => response.json());
|
|
79
|
+
* return result;
|
|
80
|
+
* }
|
|
81
|
+
*/
|
|
82
|
+
getAccessToken?: '__fn__';
|
|
83
|
+
/**
|
|
84
|
+
* Additional [chat options](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat).
|
|
85
|
+
* @examples
|
|
86
|
+
* chatOptions: {
|
|
87
|
+
* onData: data => console.log('onData:', data),
|
|
88
|
+
* onError: error => console.log('onError:', error),
|
|
89
|
+
* onFinish: result => console.log('onFinish:', result)
|
|
90
|
+
* }
|
|
91
|
+
*/
|
|
92
|
+
chatOptions?: object;
|
|
93
|
+
}
|
|
94
|
+
export interface CommonComponentPropsSchema {
|
|
95
|
+
/**
|
|
96
|
+
* Custom class name.
|
|
97
|
+
*/
|
|
98
|
+
className?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Custom styles.
|
|
101
|
+
*/
|
|
102
|
+
style?: CSSProperties;
|
|
103
|
+
}
|
|
104
|
+
export interface AiChatPanelPropsSchema extends CommonComponentPropsSchema {
|
|
105
|
+
/**
|
|
106
|
+
* GrapesJS editor instance
|
|
107
|
+
*/
|
|
108
|
+
editor: object;
|
|
109
|
+
/**
|
|
110
|
+
* AI Chat plugin options
|
|
111
|
+
*/
|
|
112
|
+
pluginOptions: object;
|
|
113
|
+
}
|
|
114
|
+
export interface AiChatHeaderPropsSchema {
|
|
115
|
+
}
|
|
116
|
+
export interface AiChatErrorPropsSchema {
|
|
117
|
+
}
|
|
118
|
+
export interface AiChatLoadingStatePropsSchema {
|
|
119
|
+
}
|
|
120
|
+
export interface AiChatInputPropsSchema {
|
|
121
|
+
/**
|
|
122
|
+
* Maximum number of assets per message. Set to 0 to disable asset attachments.
|
|
30
123
|
* @default 5
|
|
31
124
|
*/
|
|
32
|
-
|
|
125
|
+
maxAssets?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Accepted file types for attachments.
|
|
128
|
+
* @default 'image/jpeg,image/png,image/gif,image/webp,application/pdf'
|
|
129
|
+
*/
|
|
130
|
+
acceptAssetType?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Custom upload function for assets.
|
|
133
|
+
* If not provided, the upload from AssetManager will be used.
|
|
134
|
+
* @examples
|
|
135
|
+
* uploadProjectAssets: async ({ files }) => {
|
|
136
|
+
* const uploaded = await uploadToServer(files);
|
|
137
|
+
* return uploaded.map(asset => ({ id: asset.id, src: asset.url, ... }));
|
|
138
|
+
* }
|
|
139
|
+
*/
|
|
140
|
+
uploadProjectAssets?: '__fn__';
|
|
141
|
+
/**
|
|
142
|
+
* Custom layout rendered before the main input container.
|
|
143
|
+
*/
|
|
144
|
+
layoutBefore?: '__fn__';
|
|
145
|
+
/**
|
|
146
|
+
* Custom layout rendered after the main input container.
|
|
147
|
+
*/
|
|
148
|
+
layoutAfter?: '__fn__';
|
|
149
|
+
/**
|
|
150
|
+
* Custom submit handler. When provided, the default submit is skipped.
|
|
151
|
+
* Receives the form event, a `submit` callback to trigger the original submit, and the current input state.
|
|
152
|
+
*/
|
|
153
|
+
onSubmit?: '__fn__';
|
|
154
|
+
/**
|
|
155
|
+
* Props forwarded to the context section (selected components indicator).
|
|
156
|
+
*/
|
|
157
|
+
contextSectionProps?: object;
|
|
158
|
+
/**
|
|
159
|
+
* Props forwarded to the textarea element.
|
|
160
|
+
*/
|
|
161
|
+
textareaProps?: object;
|
|
162
|
+
/**
|
|
163
|
+
* Props forwarded to the assets section.
|
|
164
|
+
*/
|
|
165
|
+
assetsSectionProps?: object;
|
|
166
|
+
/**
|
|
167
|
+
* Props forwarded to the attach button.
|
|
168
|
+
*/
|
|
169
|
+
attachButtonProps?: object;
|
|
170
|
+
/**
|
|
171
|
+
* Props forwarded to the dictate button.
|
|
172
|
+
*/
|
|
173
|
+
dictateButtonProps?: object;
|
|
174
|
+
/**
|
|
175
|
+
* Props forwarded to the submit button.
|
|
176
|
+
*/
|
|
177
|
+
submitButtonProps?: object;
|
|
178
|
+
/**
|
|
179
|
+
* Default value for the text input.
|
|
180
|
+
*/
|
|
181
|
+
value?: string;
|
|
182
|
+
}
|
|
183
|
+
export interface AiChatEmptyStatePropsSchema {
|
|
184
|
+
/**
|
|
185
|
+
* Suggestions to show in the empty state.
|
|
186
|
+
* @examples
|
|
187
|
+
* suggestions: [{ id: 'webHero', label: 'Create hero', prompt: 'Create a hero section' }]
|
|
188
|
+
*/
|
|
189
|
+
suggestions?: object[];
|
|
190
|
+
}
|
|
191
|
+
export interface AiChatMessagePropsSchema {
|
|
192
|
+
/**
|
|
193
|
+
* Chat message to render
|
|
194
|
+
*/
|
|
195
|
+
message: object;
|
|
196
|
+
/**
|
|
197
|
+
* Indicates if the message is currently streaming
|
|
198
|
+
*/
|
|
199
|
+
isStreaming?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Custom layout before the message
|
|
202
|
+
*/
|
|
203
|
+
layoutBeforeMessage?: '__fn__';
|
|
204
|
+
/**
|
|
205
|
+
* Custom layout after the message
|
|
206
|
+
*/
|
|
207
|
+
layoutAfterMessage?: '__fn__';
|
|
208
|
+
/**
|
|
209
|
+
* Custom layout for message parts
|
|
210
|
+
*/
|
|
211
|
+
layoutPart?: '__fn__';
|
|
212
|
+
/**
|
|
213
|
+
* Custom layout for tool label parts
|
|
214
|
+
*/
|
|
215
|
+
layoutPartToolLabel?: '__fn__';
|
|
216
|
+
/**
|
|
217
|
+
* Custom layout for tool detail parts
|
|
218
|
+
*/
|
|
219
|
+
layoutPartToolDetail?: '__fn__';
|
|
220
|
+
/**
|
|
221
|
+
* Custom layout for tool result parts
|
|
222
|
+
*/
|
|
223
|
+
layoutPartToolResult?: '__fn__';
|
|
224
|
+
}
|
|
225
|
+
export interface AiChatMessagesPropsSchema {
|
|
226
|
+
/**
|
|
227
|
+
* GrapesJS editor instance
|
|
228
|
+
*/
|
|
229
|
+
editor: object;
|
|
230
|
+
/**
|
|
231
|
+
* Chat context
|
|
232
|
+
*/
|
|
233
|
+
chatContext: object;
|
|
234
|
+
/**
|
|
235
|
+
* Messages to render
|
|
236
|
+
*/
|
|
237
|
+
messages: object[];
|
|
238
|
+
/**
|
|
239
|
+
* AI Chat plugin options
|
|
240
|
+
*/
|
|
241
|
+
pluginOptions: object;
|
|
242
|
+
}
|
|
243
|
+
export interface AiChatMessagesStatusPropsSchema {
|
|
244
|
+
}
|
|
245
|
+
export interface AiChatProviderPropsSchema {
|
|
33
246
|
/**
|
|
34
|
-
*
|
|
247
|
+
* Chat manager instance
|
|
35
248
|
*/
|
|
36
|
-
|
|
249
|
+
chatManager: object;
|
|
37
250
|
/**
|
|
38
|
-
*
|
|
251
|
+
* Provider children
|
|
39
252
|
*/
|
|
40
|
-
|
|
253
|
+
children: object;
|
|
41
254
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
`)},init(){const{em:
|
|
1
|
+
"use strict";const P="app.grapesjs.com",z="app-stage.grapesjs.com",O="app2.grapesjs.com",V="app-stage2.grapesjs.com",A=[P,O,z,V,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],B="license:check:start",F="license:check:end",X=()=>typeof window<"u",M=({isDev:t,isStage:n,isPlatform:a})=>`${t?"":`https://${n?z:P}`}/${a?"platform-api":"api"}`,j=()=>{const t=X()&&window.location.hostname;return!!t&&(A.includes(t)||A.some(n=>t.endsWith(n)))};async function _({path:t,baseApiUrl:n,method:a="GET",headers:s={},params:o,body:i}){const m=`${n||M({isDev:!1,isStage:!1})}${t}`,l={method:a,headers:{"Content-Type":"application/json",...s}};i&&(l.body=JSON.stringify(i));const p=o?new URLSearchParams(o).toString():"",u=p?`?${p}`:"",e=await fetch(`${m}${u}`,l);if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.json()}var b=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(b||{});const C={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function $(t){const n=t;return n.init=a=>s=>t(s,a),n}const W=t=>$(t);async function Y({editor:t,plan:n,pluginName:a,licenseKey:s,onLicenseCheckResponse:o,cleanup:i}){let r="",m=!1;const l=j(),p=e=>{console.warn("Cleanup plugin:",a,"Reason:",e),i()},u=(e={})=>{var k;const{error:c,sdkLicense:d}=e,h=(k=e.plan)==null?void 0:k.category;if(!(d||e.license)||c)p(c||"Invalid license");else if(h){const U=C[n],G=C[h];U>G&&p({pluginRequiredPlan:n,licensePlan:h})}};t.on(B,e=>{r=e==null?void 0:e.baseApiUrl,m=!0}),t.on(F,e=>{o==null||o(e),u(e)}),setTimeout(async()=>{if(!m){if(l)return;if(s){const e=await H({licenseKey:s,pluginName:a,baseApiUrl:r});o==null||o(e),e&&u(e)}else p("The `licenseKey` option not provided")}},2e3)}async function H(t){const{licenseKey:n,pluginName:a,baseApiUrl:s}=t;try{return(await _({baseApiUrl:s,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const K=(...t)=>n=>t.some(a=>n.is(a));var f=(t=>(t.name="animation-name",t.duration="animation-duration",t.delay="animation-delay",t.iterationCount="animation-iteration-count",t.timingFunction="animation-timing-function",t.fillMode="animation-fill-mode",t))(f||{}),v=(t=>(t.onScroll="--animation-on-scroll",t.threshold="--animation-threshold",t.repeat="--animation-repeat",t))(v||{});const g="animation",I="animation-group",D="animation:update",E="animation-group:update",Z={category:{id:"animations",label:"Animations"},select:!0},w=t=>(t==null?void 0:t.getType())===g,x=t=>(t==null?void 0:t.getType())===I,R=t=>w(t)||x(t),S={isVisible:({component:t})=>w(t)},q={isVisible:({component:t})=>x(t)},J={isVisible:({component:t})=>w(t)&&x(t==null?void 0:t.parent())?!1:R(t)},L={isVisible:({component:t,sector:n})=>{var a;return w(t)&&x(t==null?void 0:t.parent())?!1:R(t)&&((a=n.getProperty(v.onScroll))==null?void 0:a.getValue())==="true"}},N={animation:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M16.5 14a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13"/><path fill="currentColor" d="M17.14 15.98a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/><path fill="currentColor" d="M12.64 20.48a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/></svg>',animationGroup:'<svg viewBox="0 0 24 24"><path d="M4 2a2 2 0 0 0-2 2v10h2V4h10V2H4m4 4a2 2 0 0 0-2 2v10h2V8h10V6H8m4 4a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2h-8Z"/></svg>'},Q=function(t){const n=this;let a=null;const s=()=>{a==null||a.disconnect(),a=null},o=()=>{s();const i=n.style;i.animationName="",requestAnimationFrame(()=>{const r=getComputedStyle(n),m=r.getPropertyValue("animation-name").trim(),l=r.getPropertyValue("--animation-on-scroll").trim()!=="false",p=parseFloat(r.getPropertyValue("--animation-threshold").trim())||.2,u=r.getPropertyValue("--animation-repeat").trim()==="true",e=()=>{i.animationName="none",n.offsetWidth,i.animationName=m,i.animationPlayState="running"};if(!m||m==="none"){i.animationName="none",i.animationPlayState="paused";return}if(!l){e();return}i.animationPlayState="paused",a=new IntersectionObserver(c=>{c.forEach(d=>{d.isIntersecting&&(e(),!u&&s())})},{threshold:p}),a.observe(n)})};n.addEventListener(t.animationUpdateEvent,o),o()},tt=(t,n)=>{const{Components:a,Blocks:s,Canvas:o}=t,{block:i={},animationList:r=[]}=n,m=t.Components.events,l="Animation",p=Object.values(v),u=Object.values(f);return a.addType(g,{block:i?{label:l,media:N.animation,content:{type:g},...Z,...i}:void 0,model:{defaults:{emptyState:!0,name:l,traits:[],script:Q,animationUpdateEvent:D,"script-props":["animationUpdateEvent"],styles:r.map(e=>e.css).join(`
|
|
2
|
+
`)},init(){const{em:e}=this;this.addStyle({[f.name]:"fadeIn",[f.duration]:"1s",[f.fillMode]:"both",...n.animationStyle,...this.getStyle()}),this.listenTo(e,m.mount,c=>{var h;if(c!==this)return;((h=this.parent())==null?void 0:h.get("type"))!==I||p.forEach(y=>this.removeStyle(y))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:e}=this;this.listenTo(e,m.styleUpdate,this.handleStyleChange)},onAnimationStart(){var c;if((c=this.cmpSpots)!=null&&c.length)return;const e=o.getSpots({component:this.model});this.cmpSpots=e,o.removeSpots(e),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const e=this.cmpSpots||[];o.spots.add(e),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(D))},handleStyleChange(e,c){Object.keys((c==null?void 0:c.style)||{}).some(y=>u.includes(y)||p.includes(y))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{s.remove(g),a.removeType(g)}},nt=function(t){const n=this,a="--animation-on-scroll",s="--animation-threshold",o="--animation-repeat";let i=null;const r=()=>{i==null||i.disconnect(),i=null},m=()=>{r();const l=getComputedStyle(n),p=l.getPropertyValue(a).trim()!=="false",u=parseFloat(l.getPropertyValue(s).trim())||.2,e=l.getPropertyValue(o).trim()==="true",c=()=>{Array.from(n.children).forEach(d=>{d instanceof HTMLElement&&typeof d.dispatchEvent=="function"&&d.dispatchEvent(new CustomEvent(E,{bubbles:!1}))})};if(!p){c();return}i=new IntersectionObserver(d=>{d.forEach(h=>{h.isIntersecting?(c(),!e&&r()):e&&Array.from(n.children).forEach(y=>{y instanceof HTMLElement&&getComputedStyle(y).getPropertyValue(a).trim()!=="false"&&(y.style.opacity="0",y.style.animationPlayState="paused")})})},{threshold:u}),i.observe(n)};n.addEventListener(t.animationGroupUpdateEvent,m),m()},et=(t,n)=>{const{Components:a,Blocks:s}=t,{blockGroup:o={}}=n,i="Animation Group";return a.addType(I,{block:o?{label:i,media:N.animationGroup,content:{type:I,components:[{type:g},{type:g},{type:g}]},...Z,...o}:void 0,model:{defaults:{name:i,emptyState:!0,traits:[],script:nt,animationGroupUpdateEvent:E,"script-props":["animationGroupUpdateEvent"],droppable:K(g)},init(){this.addStyle({...n.animationGroupStyle,...this.getStyle()});const r=this.components();this.listenTo(r,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((r,m)=>{r.is(g)&&r.addStyle({"--stagger-index":m.toString(),[f.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0.3s))"},{partial:!0})})}},view:{init(){const{model:r}=this;this.listenTo(r,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(E))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{s.remove(I),a.removeType(I)}},at="animationComponent",ot=b.startup,T=[{id:"flash",name:"Flash",css:`@keyframes flash {
|
|
3
3
|
0%, 50%, to {
|
|
4
4
|
opacity:1
|
|
5
5
|
}
|
|
@@ -516,4 +516,4 @@
|
|
|
516
516
|
transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
|
|
517
517
|
animation-timing-function:cubic-bezier(.175, .885, .32, 1)
|
|
518
518
|
}
|
|
519
|
-
}`}],
|
|
519
|
+
}`}],it=function(t,n={}){var o;const a=((o=n.animations)==null?void 0:o.call(n,{items:T}))||T,s=[tt(t,{...n,animationList:a}),et(t,n)];t.Styles.addSector("animation",{name:"Animation",properties:[{...S,name:"Type",property:f.name,type:"select",full:!0,default:"fadeIn",options:a},{...S,name:"Duration",property:f.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...S,name:"Delay",property:f.delay,type:"number",units:["s"],min:0,max:10,step:.1,default:"1s"},{...S,name:"Iteration Count",property:f.iterationCount,type:"select",default:"1",options:[{id:"1",name:"One time"},{id:"infinite",name:"Infinite"}]},{...S,name:"Timing",property:f.timingFunction,type:"select",default:"ease",options:[{id:"ease",name:"Ease"},{id:"ease-in",name:"Ease in"},{id:"ease-out",name:"Ease out"},{id:"ease-in-out",name:"Ease in out"},{id:"linear",name:"Linear"}]},{...q,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.3s"},{...J,name:"Animate on Scroll",property:v.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...L,name:"Scroll Threshold",property:v.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...L,name:"Repeat on Scroll",property:v.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),Y({editor:t,licenseKey:n.licenseKey,plan:ot,pluginName:at,cleanup:()=>{s.forEach(i=>i())}})},st=W(it);module.exports=st;
|