@finsweet/webflow-apps-utils 1.0.2 → 1.0.4
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/README.md +162 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/providers/GlobalProvider.mdx +322 -0
- package/dist/providers/GlobalProvider.svelte +58 -0
- package/dist/providers/GlobalProvider.svelte.d.ts +4 -0
- package/dist/providers/configuratorUtils.d.ts +37 -0
- package/dist/providers/configuratorUtils.js +219 -0
- package/dist/providers/globalContext.svelte.d.ts +18 -0
- package/dist/providers/globalContext.svelte.js +439 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.js +7 -0
- package/dist/providers/types.d.ts +103 -0
- package/dist/providers/types.js +6 -0
- package/dist/router/Router.mdx +958 -0
- package/dist/router/Router.stories.d.ts +6 -0
- package/dist/router/Router.stories.js +47 -0
- package/dist/router/examples/RouterExample.svelte +271 -0
- package/dist/{ui/components/NoSettingsNeeded.svelte.d.ts → router/examples/RouterExample.svelte.d.ts} +3 -3
- package/dist/router/examples/index.d.ts +4 -0
- package/dist/router/examples/index.js +4 -0
- package/dist/router/examples/pages/AboutPage.svelte +568 -0
- package/dist/router/examples/pages/AboutPage.svelte.d.ts +13 -0
- package/dist/router/examples/pages/HomePage.svelte +200 -0
- package/dist/router/examples/pages/HomePage.svelte.d.ts +14 -0
- package/dist/router/examples/pages/NotFoundPage.svelte +307 -0
- package/dist/router/examples/pages/NotFoundPage.svelte.d.ts +17 -0
- package/dist/router/hooks.svelte.d.ts +2 -2
- package/dist/router/index.d.ts +3 -0
- package/dist/router/index.js +3 -0
- package/dist/router/{Link.svelte → providers/Link.svelte} +1 -1
- package/dist/router/{Route.svelte → providers/Route.svelte} +1 -1
- package/dist/router/{Route.svelte.d.ts → providers/Route.svelte.d.ts} +1 -1
- package/dist/router/{Router.svelte → providers/RouterProvider.svelte} +22 -5
- package/dist/router/{Router.svelte.d.ts → providers/RouterProvider.svelte.d.ts} +8 -4
- package/dist/router/providers/index.d.ts +3 -0
- package/dist/router/providers/index.js +3 -0
- package/dist/router/{index.svelte.d.ts → router.svelte.d.ts} +1 -3
- package/dist/router/{index.svelte.js → router.svelte.js} +1 -4
- package/dist/stores/docs/Form.mdx +542 -0
- package/dist/stores/forms.d.ts +41 -4
- package/dist/stores/forms.js +86 -32
- package/dist/stores/index.d.ts +0 -1
- package/dist/stores/index.js +0 -1
- package/dist/types/customCode.d.ts +1 -1
- package/dist/types/webflow.d.ts +31 -47
- package/dist/types/window.d.ts +1 -0
- package/dist/ui/components/LoadingScreen.svelte +2 -1
- package/dist/ui/components/button/Button.svelte +1 -1
- package/dist/ui/components/button-group/ButtonGroup.stories.js +112 -0
- package/dist/ui/components/{ButtonGroup.svelte → button-group/ButtonGroup.svelte} +20 -33
- package/dist/ui/components/button-group/ButtonGroup.svelte.d.ts +13 -0
- package/dist/ui/components/button-group/index.d.ts +2 -0
- package/dist/ui/components/button-group/index.js +1 -0
- package/dist/ui/components/button-group/types.d.ts +32 -0
- package/dist/ui/components/checkbox/Checkbox.stories.d.ts +55 -0
- package/dist/ui/components/checkbox/Checkbox.stories.js +162 -0
- package/dist/ui/components/checkbox/Checkbox.svelte +141 -0
- package/dist/ui/components/checkbox/Checkbox.svelte.d.ts +4 -0
- package/dist/ui/components/checkbox/index.d.ts +2 -0
- package/dist/ui/components/checkbox/index.js +1 -0
- package/dist/ui/components/checkbox/types.d.ts +32 -0
- package/dist/ui/components/controlled-buttons/ControlledButtons.stories.d.ts +32 -0
- package/dist/ui/components/controlled-buttons/ControlledButtons.stories.js +152 -0
- package/dist/ui/components/{buttons/FooterButton.svelte → controlled-buttons/ControlledButtons.svelte} +18 -67
- package/dist/ui/components/controlled-buttons/ControlledButtons.svelte.d.ts +4 -0
- package/dist/ui/components/controlled-buttons/index.d.ts +2 -0
- package/dist/ui/components/controlled-buttons/index.js +1 -0
- package/dist/ui/components/{buttons → controlled-buttons}/types.d.ts +11 -4
- package/dist/ui/components/copy-text/CopyText.stories.d.ts +70 -0
- package/dist/ui/components/copy-text/CopyText.stories.js +241 -0
- package/dist/ui/components/copy-text/CopyText.svelte +249 -0
- package/dist/ui/components/copy-text/CopyText.svelte.d.ts +4 -0
- package/dist/ui/components/copy-text/index.d.ts +2 -0
- package/dist/ui/components/copy-text/index.js +1 -0
- package/dist/ui/components/copy-text/types.d.ts +52 -0
- package/dist/ui/components/copy-text/types.js +1 -0
- package/dist/ui/components/divider/Divider.stories.svelte +134 -0
- package/dist/ui/components/{clickable/Clickable.stories.svelte.d.ts → divider/Divider.stories.svelte.d.ts} +4 -4
- package/dist/ui/components/divider/Divider.svelte +30 -0
- package/dist/ui/components/divider/Divider.svelte.d.ts +4 -0
- package/dist/ui/components/divider/index.d.ts +2 -0
- package/dist/ui/components/divider/index.js +1 -0
- package/dist/ui/components/divider/types.d.ts +23 -0
- package/dist/ui/components/divider/types.js +1 -0
- package/dist/ui/components/iframe/Iframe.stories.svelte +122 -0
- package/dist/ui/components/{ToggleItem.svelte.d.ts → iframe/Iframe.stories.svelte.d.ts} +7 -8
- package/dist/ui/components/iframe/Iframe.svelte +75 -0
- package/dist/ui/components/iframe/Iframe.svelte.d.ts +4 -0
- package/dist/ui/components/iframe/index.d.ts +2 -0
- package/dist/ui/components/iframe/index.js +1 -0
- package/dist/ui/components/iframe/types.d.ts +38 -0
- package/dist/ui/components/iframe/types.js +1 -0
- package/dist/ui/components/index.d.ts +13 -39
- package/dist/ui/components/index.js +13 -39
- package/dist/ui/components/input/Input.stories.d.ts +33 -0
- package/dist/ui/components/input/Input.stories.js +176 -0
- package/dist/ui/components/input/Input.svelte +358 -81
- package/dist/ui/components/input/types.d.ts +33 -1
- package/dist/ui/components/layout/Layout.stories.svelte +3 -3
- package/dist/ui/components/layout/Layout.svelte +10 -64
- package/dist/ui/components/layout/Layout.svelte.d.ts +2 -2
- package/dist/ui/components/layout/common/EditModeMessage.svelte +24 -12
- package/dist/ui/components/layout/{ExampleLayout.svelte → examples/ExampleLayout.svelte} +56 -39
- package/dist/ui/components/layout/examples/Wrapper.svelte +9 -0
- package/dist/ui/components/{Header.svelte.d.ts → layout/examples/Wrapper.svelte.d.ts} +4 -6
- package/dist/ui/components/layout/examples/index.d.ts +2 -0
- package/dist/ui/components/layout/examples/index.js +2 -0
- package/dist/ui/components/layout/index.d.ts +3 -2
- package/dist/ui/components/layout/index.js +2 -1
- package/dist/ui/components/layout/test-helpers/TestLayoutWithFooter.svelte +20 -0
- package/dist/ui/components/layout/test-helpers/TestLayoutWithFooter.svelte.d.ts +7 -0
- package/dist/ui/components/layout/types.d.ts +1 -10
- package/dist/ui/components/modal/Example.svelte +320 -0
- package/dist/ui/components/modal/Example.svelte.d.ts +3 -0
- package/dist/ui/components/modal/Modal.stories.svelte +18 -0
- package/dist/ui/components/modal/Modal.stories.svelte.d.ts +26 -0
- package/dist/ui/components/modal/Modal.svelte +490 -0
- package/dist/ui/components/modal/Modal.svelte.d.ts +130 -0
- package/dist/ui/components/modal/index.d.ts +2 -0
- package/dist/ui/components/modal/index.js +1 -0
- package/dist/ui/components/modal/types.d.ts +75 -0
- package/dist/ui/components/modal/types.js +1 -0
- package/dist/ui/components/notification/Notification.stories.svelte +239 -0
- package/dist/ui/components/{ToggleList.svelte.d.ts → notification/Notification.stories.svelte.d.ts} +9 -21
- package/dist/ui/components/notification/Notification.svelte +294 -0
- package/dist/ui/components/notification/Notification.svelte.d.ts +67 -0
- package/dist/ui/components/notification/index.d.ts +2 -0
- package/dist/ui/components/notification/index.js +1 -0
- package/dist/ui/components/notification/types.d.ts +68 -0
- package/dist/ui/components/notification/types.js +1 -0
- package/dist/ui/components/section/Section.stories.svelte +263 -0
- package/dist/ui/components/section/Section.stories.svelte.d.ts +27 -0
- package/dist/ui/components/section/Section.svelte +326 -0
- package/dist/ui/components/section/Section.svelte.d.ts +5 -0
- package/dist/ui/components/section/index.d.ts +2 -0
- package/dist/ui/components/section/index.js +1 -0
- package/dist/ui/components/section/types.d.ts +114 -0
- package/dist/ui/components/section/types.js +1 -0
- package/dist/ui/components/{ImageUpload.svelte → shared/ImageUpload.svelte} +3 -3
- package/dist/ui/components/{SelectBodyOrDivBlock.svelte → shared/SelectBodyOrDivBlock.svelte} +1 -1
- package/dist/ui/components/shared/index.d.ts +2 -0
- package/dist/ui/components/shared/index.js +2 -0
- package/dist/ui/components/text/Text.stories.svelte +67 -1
- package/dist/ui/components/text/Text.svelte +209 -8
- package/dist/ui/components/text/types.d.ts +4 -0
- package/dist/ui/index.css +33 -5
- package/dist/utils/animations/factory.d.ts +7 -0
- package/dist/utils/animations/factory.js +101 -0
- package/dist/utils/animations/index.d.ts +7 -0
- package/dist/utils/animations/index.js +62 -0
- package/dist/utils/animations/types.d.ts +39 -0
- package/dist/utils/animations/types.js +1 -0
- package/dist/utils/api/checkIfAppModeIsDesign.d.ts +1 -2
- package/dist/utils/api/checkIfAppModeIsDesign.js +1 -2
- package/dist/utils/api/clipboard/handlePaste.d.ts +6 -37
- package/dist/utils/api/clipboard/handlePaste.js +2 -6
- package/dist/utils/api/getAllAssets.d.ts +1 -2
- package/dist/utils/api/getAllAssets.js +1 -2
- package/dist/utils/api/getFinsweetComponentsEnvironment.d.ts +1 -2
- package/dist/utils/api/getFinsweetComponentsEnvironment.js +3 -6
- package/dist/utils/api/index.d.ts +0 -1
- package/dist/utils/api/index.js +0 -1
- package/dist/utils/api/insertWithXSCP.d.ts +1 -2
- package/dist/utils/api/insertWithXSCP.js +1 -2
- package/dist/utils/auth/crossWindowLogin.d.ts +3 -0
- package/dist/utils/auth/crossWindowLogin.js +3 -0
- package/dist/utils/auth/index.d.ts +9 -25
- package/dist/utils/auth/index.js +9 -25
- package/dist/utils/browser-storage/localStorage.d.ts +4 -12
- package/dist/utils/browser-storage/localStorage.js +4 -12
- package/dist/utils/browser-storage/sessionStorage.d.ts +4 -12
- package/dist/utils/browser-storage/sessionStorage.js +4 -12
- package/dist/utils/custom-code/api.d.ts +3 -7
- package/dist/utils/custom-code/api.js +3 -7
- package/dist/utils/custom-code/configs.d.ts +22 -0
- package/dist/utils/custom-code/configs.js +40 -0
- package/dist/utils/custom-code/index.d.ts +1 -0
- package/dist/utils/custom-code/index.js +1 -0
- package/dist/utils/helpers/capitalizeFirstLetter.d.ts +4 -0
- package/dist/utils/helpers/capitalizeFirstLetter.js +9 -0
- package/dist/utils/helpers/cleanupTooltipMessage.d.ts +1 -2
- package/dist/utils/helpers/cleanupTooltipMessage.js +1 -2
- package/dist/utils/helpers/getTimeNow.d.ts +4 -0
- package/dist/utils/helpers/getTimeNow.js +8 -0
- package/dist/utils/helpers/goto.d.ts +1 -4
- package/dist/utils/helpers/goto.js +2 -7
- package/dist/utils/helpers/index.d.ts +5 -0
- package/dist/utils/helpers/index.js +5 -0
- package/dist/utils/helpers/minifyCode.d.ts +10 -0
- package/dist/utils/helpers/minifyCode.js +73 -0
- package/dist/utils/helpers/noop.d.ts +1 -1
- package/dist/utils/helpers/noop.js +1 -1
- package/dist/utils/helpers/numbers.d.ts +4 -14
- package/dist/utils/helpers/numbers.js +4 -14
- package/dist/utils/helpers/objectsToModuleExports.d.ts +2 -4
- package/dist/utils/helpers/objectsToModuleExports.js +2 -3
- package/dist/utils/helpers/toHumanReadableList.d.ts +4 -0
- package/dist/utils/helpers/toHumanReadableList.js +11 -0
- package/dist/utils/helpers/trimText.d.ts +1 -8
- package/dist/utils/helpers/trimText.js +1 -8
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/logger/index.d.ts +0 -2
- package/dist/utils/logger/index.js +0 -2
- package/dist/utils/webflow-canvas/attributes/getAllWebflowElementAttributes.d.ts +1 -3
- package/dist/utils/webflow-canvas/attributes/getAllWebflowElementAttributes.js +1 -3
- package/dist/utils/webflow-canvas/attributes/getInstanceNamesFromObject.d.ts +1 -5
- package/dist/utils/webflow-canvas/attributes/getInstanceNamesFromObject.js +1 -5
- package/dist/utils/webflow-canvas/attributes/getWebflowElementAttribute.d.ts +1 -4
- package/dist/utils/webflow-canvas/attributes/getWebflowElementAttribute.js +1 -4
- package/dist/utils/webflow-canvas/attributes/getWebflowElementTextContent.d.ts +1 -3
- package/dist/utils/webflow-canvas/attributes/getWebflowElementTextContent.js +1 -3
- package/dist/utils/webflow-canvas/attributes/removeWebflowElementAttribute.d.ts +1 -4
- package/dist/utils/webflow-canvas/attributes/removeWebflowElementAttribute.js +1 -4
- package/dist/utils/webflow-canvas/attributes/setStyles.d.ts +1 -3
- package/dist/utils/webflow-canvas/attributes/setStyles.js +1 -3
- package/dist/utils/webflow-canvas/attributes/setWebflowElementAttribute.d.ts +1 -8
- package/dist/utils/webflow-canvas/attributes/setWebflowElementAttribute.js +1 -13
- package/dist/utils/webflow-canvas/findInstanceElement.d.ts +0 -6
- package/dist/utils/webflow-canvas/findInstanceElement.js +1 -7
- package/dist/utils/webflow-canvas/getAllChildren.d.ts +16 -0
- package/dist/utils/webflow-canvas/getAllChildren.js +65 -0
- package/dist/utils/webflow-canvas/getAllPages.d.ts +3 -10
- package/dist/utils/webflow-canvas/getAllPages.js +3 -10
- package/dist/utils/webflow-canvas/getElementClassList.d.ts +9 -0
- package/dist/utils/webflow-canvas/getElementClassList.js +19 -0
- package/dist/utils/webflow-canvas/getSiteStagingUrl.d.ts +1 -4
- package/dist/utils/webflow-canvas/getSiteStagingUrl.js +1 -4
- package/dist/utils/webflow-canvas/index.d.ts +3 -0
- package/dist/utils/webflow-canvas/index.js +3 -0
- package/package.json +14 -2
- package/dist/router/README.md +0 -397
- package/dist/stores/globalStore.d.ts +0 -10
- package/dist/stores/globalStore.js +0 -10
- package/dist/ui/components/ButtonGroup.svelte.d.ts +0 -28
- package/dist/ui/components/Checkbox.svelte +0 -94
- package/dist/ui/components/Checkbox.svelte.d.ts +0 -36
- package/dist/ui/components/Copy.svelte +0 -329
- package/dist/ui/components/Copy.svelte.d.ts +0 -35
- package/dist/ui/components/CustomModal.svelte +0 -192
- package/dist/ui/components/CustomModal.svelte.d.ts +0 -45
- package/dist/ui/components/DisableInEditMode.svelte +0 -66
- package/dist/ui/components/DisableInEditMode.svelte.d.ts +0 -33
- package/dist/ui/components/Divider.svelte +0 -31
- package/dist/ui/components/Divider.svelte.d.ts +0 -31
- package/dist/ui/components/Header.svelte +0 -30
- package/dist/ui/components/Iframe.svelte +0 -89
- package/dist/ui/components/Iframe.svelte.d.ts +0 -40
- package/dist/ui/components/InjectComponent.svelte +0 -297
- package/dist/ui/components/InjectComponent.svelte.d.ts +0 -27
- package/dist/ui/components/Modal.svelte +0 -139
- package/dist/ui/components/Modal.svelte.d.ts +0 -42
- package/dist/ui/components/Navbar.svelte +0 -132
- package/dist/ui/components/Navbar.svelte.d.ts +0 -29
- package/dist/ui/components/NoSettingsNeeded.svelte +0 -31
- package/dist/ui/components/Notification.svelte +0 -193
- package/dist/ui/components/Notification.svelte.d.ts +0 -64
- package/dist/ui/components/PlusMinusButton.svelte +0 -91
- package/dist/ui/components/PlusMinusButton.svelte.d.ts +0 -22
- package/dist/ui/components/PreviewBar.svelte +0 -40
- package/dist/ui/components/PreviewBar.svelte.d.ts +0 -20
- package/dist/ui/components/ScrollableContent.svelte +0 -18
- package/dist/ui/components/ScrollableContent.svelte.d.ts +0 -31
- package/dist/ui/components/Section.svelte +0 -97
- package/dist/ui/components/Section.svelte.d.ts +0 -50
- package/dist/ui/components/Spacer.svelte +0 -9
- package/dist/ui/components/Spacer.svelte.d.ts +0 -22
- package/dist/ui/components/SpinnerPlusMinus.svelte +0 -75
- package/dist/ui/components/SpinnerPlusMinus.svelte.d.ts +0 -23
- package/dist/ui/components/SpinnerUpDown.svelte +0 -194
- package/dist/ui/components/SpinnerUpDown.svelte.d.ts +0 -31
- package/dist/ui/components/Tabs.svelte +0 -71
- package/dist/ui/components/Tabs.svelte.d.ts +0 -26
- package/dist/ui/components/ToggleItem.svelte +0 -29
- package/dist/ui/components/ToggleList.svelte +0 -57
- package/dist/ui/components/buttons/FooterButton.svelte.d.ts +0 -10
- package/dist/ui/components/buttons/index.d.ts +0 -5
- package/dist/ui/components/buttons/index.js +0 -5
- package/dist/ui/components/clickable/Clickable.stories.svelte +0 -213
- package/dist/ui/components/clickable/Clickable.svelte +0 -93
- package/dist/ui/components/clickable/Clickable.svelte.d.ts +0 -4
- package/dist/ui/components/clickable/index.d.ts +0 -2
- package/dist/ui/components/clickable/index.js +0 -1
- package/dist/ui/components/clickable/types.d.ts +0 -17
- package/dist/utils/api/copyPaste/index.d.ts +0 -18
- /package/dist/router/{Link.svelte.d.ts → providers/Link.svelte.d.ts} +0 -0
- /package/dist/ui/components/{buttons → button-group}/types.js +0 -0
- /package/dist/ui/components/{clickable → checkbox}/types.js +0 -0
- /package/dist/{utils/api/copyPaste/index.js → ui/components/controlled-buttons/types.js} +0 -0
- /package/dist/ui/components/layout/{ExampleLayout.svelte.d.ts → examples/ExampleLayout.svelte.d.ts} +0 -0
- /package/dist/ui/components/{ImageUpload.svelte.d.ts → shared/ImageUpload.svelte.d.ts} +0 -0
- /package/dist/ui/components/{SelectBodyOrDivBlock.svelte.d.ts → shared/SelectBodyOrDivBlock.svelte.d.ts} +0 -0
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param obj - The object to get the instance names from
|
|
5
|
-
* @param component - The component key
|
|
6
|
-
* @param hasInstances - Whether the object has instances
|
|
7
|
-
* @returns The instance names
|
|
3
|
+
* Gets instance names from an object based on component configuration.
|
|
8
4
|
*/
|
|
9
5
|
export const getInstanceNamesFromObject = (obj, component, hasInstances) => {
|
|
10
6
|
if (!obj || typeof obj !== 'object')
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {AnyElement} params.element - The data object of the element.
|
|
4
|
-
* @param {String} params.attributeName - The name of the custom attribute to set.
|
|
5
|
-
* @returns
|
|
2
|
+
* Gets the value of a custom attribute from a Webflow element.
|
|
6
3
|
*/
|
|
7
4
|
export declare const getWebflowElementAttribute: (element: AnyElement, attributeName: string) => Promise<string | null>;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { getLogger } from '../../logger';
|
|
2
2
|
const logger = getLogger('webflow-apps-ui-utils');
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {AnyElement} params.element - The data object of the element.
|
|
6
|
-
* @param {String} params.attributeName - The name of the custom attribute to set.
|
|
7
|
-
* @returns
|
|
4
|
+
* Gets the value of a custom attribute from a Webflow element.
|
|
8
5
|
*/
|
|
9
6
|
export const getWebflowElementAttribute = async (element, attributeName) => {
|
|
10
7
|
try {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {AnyElement} params.element - The data object of the element.
|
|
4
|
-
* @param {String} params.attributeName - The name of the custom attribute to remove.
|
|
5
|
-
* @param {Boolean} params.notify - Whether to show a notification after the attribute is removed.
|
|
2
|
+
* Removes a custom attribute from a Webflow element.
|
|
6
3
|
*/
|
|
7
4
|
export declare const removeWebflowElementAttribute: (element: AnyElement, attributeName: string, notify?: boolean) => Promise<null | undefined>;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { getLogger } from '../../logger';
|
|
2
2
|
const logger = getLogger('webflow-apps-ui-utils');
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {AnyElement} params.element - The data object of the element.
|
|
6
|
-
* @param {String} params.attributeName - The name of the custom attribute to remove.
|
|
7
|
-
* @param {Boolean} params.notify - Whether to show a notification after the attribute is removed.
|
|
4
|
+
* Removes a custom attribute from a Webflow element.
|
|
8
5
|
*/
|
|
9
6
|
export const removeWebflowElementAttribute = async (element, attributeName, notify = true) => {
|
|
10
7
|
try {
|
|
@@ -3,8 +3,6 @@ export interface StyleProps {
|
|
|
3
3
|
style: PropertyMap;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @param styles
|
|
8
|
-
* @param element
|
|
6
|
+
* Creates or updates styles and applies them to the selected element.
|
|
9
7
|
*/
|
|
10
8
|
export declare const setStyles: (styles: StyleProps[], element: AnyElement) => Promise<void>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param styles
|
|
4
|
-
* @param element
|
|
2
|
+
* Creates or updates styles and applies them to the selected element.
|
|
5
3
|
*/
|
|
6
4
|
export const setStyles = async (styles, element) => {
|
|
7
5
|
const promises = styles.map(async ({ name, style }) => {
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Sets
|
|
3
|
-
* If the attribute already exists, it will not be updated by default.
|
|
4
|
-
* To update the attribute, the existing value must be different from the new value.
|
|
5
|
-
* @param {AnyElement} params.element - The data object of the element.
|
|
6
|
-
* @param {String} params.attributeName - The name of the custom attribute to set.
|
|
7
|
-
* @param {String} params.attributeValue - The value of the custom attribute to set.
|
|
8
|
-
* @param {Boolean} params.notify - Whether to show a notification after the attribute is removed.
|
|
9
|
-
* @returns
|
|
2
|
+
* Sets a custom attribute value on a Webflow element.
|
|
10
3
|
*/
|
|
11
4
|
export declare const setWebflowElementAttribute: (element: AnyElement, attributeName: string, attributeValue: string, notify?: boolean) => Promise<void>;
|
|
@@ -2,14 +2,7 @@ import { getLogger } from '../../logger';
|
|
|
2
2
|
import { getWebflowElementAttribute } from './getWebflowElementAttribute';
|
|
3
3
|
const logger = getLogger('webflow-apps-ui-utils');
|
|
4
4
|
/**
|
|
5
|
-
* Sets
|
|
6
|
-
* If the attribute already exists, it will not be updated by default.
|
|
7
|
-
* To update the attribute, the existing value must be different from the new value.
|
|
8
|
-
* @param {AnyElement} params.element - The data object of the element.
|
|
9
|
-
* @param {String} params.attributeName - The name of the custom attribute to set.
|
|
10
|
-
* @param {String} params.attributeValue - The value of the custom attribute to set.
|
|
11
|
-
* @param {Boolean} params.notify - Whether to show a notification after the attribute is removed.
|
|
12
|
-
* @returns
|
|
5
|
+
* Sets a custom attribute value on a Webflow element.
|
|
13
6
|
*/
|
|
14
7
|
export const setWebflowElementAttribute = async (element, attributeName, attributeValue, notify = true) => {
|
|
15
8
|
try {
|
|
@@ -47,11 +40,6 @@ export const setWebflowElementAttribute = async (element, attributeName, attribu
|
|
|
47
40
|
};
|
|
48
41
|
/**
|
|
49
42
|
* Checks if the specified attribute exists on a Webflow element and matches the provided value.
|
|
50
|
-
*
|
|
51
|
-
* @param {AnyElement} element - The Webflow element to check.
|
|
52
|
-
* @param {string} attributeName - The name of the attribute to find.
|
|
53
|
-
* @param {string} attributeValue - The value to compare against the found attribute.
|
|
54
|
-
* @return {boolean} - Returns true if the attribute exists and matches the provided value, otherwise false.
|
|
55
43
|
*/
|
|
56
44
|
const checkAttribute = async (element, attributeName, attributeValue) => {
|
|
57
45
|
const elementAttribute = await getWebflowElementAttribute(element, attributeName);
|
|
@@ -22,11 +22,5 @@ export interface FindElementByReferenceProps {
|
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Searches for an instance inside or outside a component by its index.
|
|
25
|
-
* @param targetIndex - The index of the instance to get.
|
|
26
|
-
* @param instance - The instance to search for.
|
|
27
|
-
* @param allElements - The elements to search through.
|
|
28
|
-
* @param signal - AbortSignal for cancelling the operation.
|
|
29
|
-
* @param selectElement - Whether to select the element when found.
|
|
30
|
-
* @returns The element match with its component if applicable.
|
|
31
25
|
*/
|
|
32
26
|
export declare const findInstanceElement: ({ targetIndex, instance, component, allElements, signal, selectElement }: GetElementFromComponentProps) => Promise<ElementFromComponentMatch | null>;
|
|
@@ -3,7 +3,7 @@ import { getLogger } from '../logger';
|
|
|
3
3
|
import { getWebflowElementAttribute } from './attributes';
|
|
4
4
|
const logger = getLogger('utils');
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Exits the current component context.
|
|
7
7
|
*/
|
|
8
8
|
const exitComponent = async () => {
|
|
9
9
|
try {
|
|
@@ -15,12 +15,6 @@ const exitComponent = async () => {
|
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* Searches for an instance inside or outside a component by its index.
|
|
18
|
-
* @param targetIndex - The index of the instance to get.
|
|
19
|
-
* @param instance - The instance to search for.
|
|
20
|
-
* @param allElements - The elements to search through.
|
|
21
|
-
* @param signal - AbortSignal for cancelling the operation.
|
|
22
|
-
* @param selectElement - Whether to select the element when found.
|
|
23
|
-
* @returns The element match with its component if applicable.
|
|
24
18
|
*/
|
|
25
19
|
export const findInstanceElement = async ({ targetIndex, instance, component, allElements, signal, selectElement = false }) => {
|
|
26
20
|
if (signal?.aborted)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ElementChildren {
|
|
2
|
+
attribute: string | null;
|
|
3
|
+
customAttributes: NamedValue[] | null;
|
|
4
|
+
element: AnyElement;
|
|
5
|
+
parent: AnyElement | null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Recursively fetches children elements and attributes.
|
|
9
|
+
*
|
|
10
|
+
* @param element - The root element.
|
|
11
|
+
* @param attributeName - The attribute name to fetch.
|
|
12
|
+
* @param parent - The parent of the current element.
|
|
13
|
+
* @param className - The class name to fetch.
|
|
14
|
+
* @returns - Promise of array containing elements and their children recursively.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getAllChildren: (element: AnyElement, attributeName?: string, parent?: AnyElement | null, className?: string) => Promise<ElementChildren[]>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { getWebflowElementAttribute } from './attributes';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively fetches children elements and attributes.
|
|
4
|
+
*
|
|
5
|
+
* @param element - The root element.
|
|
6
|
+
* @param attributeName - The attribute name to fetch.
|
|
7
|
+
* @param parent - The parent of the current element.
|
|
8
|
+
* @param className - The class name to fetch.
|
|
9
|
+
* @returns - Promise of array containing elements and their children recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const getAllChildren = async (element, attributeName, parent, className = 'fs-consent') => {
|
|
12
|
+
let attribute = '';
|
|
13
|
+
let customAttributes = [];
|
|
14
|
+
if (attributeName) {
|
|
15
|
+
if (attributeName === 'wized' || attributeName === 'w-el') {
|
|
16
|
+
// wized may have old attribute name "w-el" so we check for both
|
|
17
|
+
attribute =
|
|
18
|
+
(await getWebflowElementAttribute(element, 'wized')) ||
|
|
19
|
+
(await getWebflowElementAttribute(element, 'w-el')) ||
|
|
20
|
+
null;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
attribute = (await getWebflowElementAttribute(element, attributeName)) || null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (element?.customAttributes) {
|
|
27
|
+
// Get All Custom Attributes
|
|
28
|
+
const attributesList = await element.getAllCustomAttributes();
|
|
29
|
+
if (attributesList) {
|
|
30
|
+
customAttributes = attributesList;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const children = element?.children ? await element?.getChildren() : [];
|
|
34
|
+
// const styles: ElementChildren['styles'] = [];
|
|
35
|
+
// if (element?.styles) {
|
|
36
|
+
// const stylesData = await element?.getStyles();
|
|
37
|
+
// const isArray = Array.isArray(stylesData);
|
|
38
|
+
// if (isArray && stylesData.length > 0) {
|
|
39
|
+
// for (const style of stylesData) {
|
|
40
|
+
// try {
|
|
41
|
+
// const name = (await style?.getName()) || undefined;
|
|
42
|
+
// const properties = (await style?.getProperties()) || undefined;
|
|
43
|
+
// if (name && properties && style) {
|
|
44
|
+
// styles.push({ style, name, properties });
|
|
45
|
+
// }
|
|
46
|
+
// } catch (error) {
|
|
47
|
+
// }
|
|
48
|
+
// }
|
|
49
|
+
// }
|
|
50
|
+
// }
|
|
51
|
+
const current = {
|
|
52
|
+
element,
|
|
53
|
+
parent: parent,
|
|
54
|
+
attribute,
|
|
55
|
+
customAttributes
|
|
56
|
+
// styles,
|
|
57
|
+
// defaultClassName: styles?.find((style) => style?.name?.includes(className))?.name || '',
|
|
58
|
+
};
|
|
59
|
+
if (children.length === 0) {
|
|
60
|
+
return [current];
|
|
61
|
+
}
|
|
62
|
+
const childrenArrays = await Promise.all(children.map((child) => getAllChildren(child, attributeName, element, className)));
|
|
63
|
+
const flattenedChildren = childrenArrays.flat();
|
|
64
|
+
return [current, ...flattenedChildren];
|
|
65
|
+
};
|
|
@@ -9,21 +9,14 @@ export type PageWithProps = {
|
|
|
9
9
|
isPasswordProtected: boolean;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
* Generates a slug for a page or folder
|
|
13
|
-
* @param page - The page or folder to generate a slug for
|
|
14
|
-
* @returns The slug for the page or folder
|
|
12
|
+
* Generates a slug for a page or folder.
|
|
15
13
|
*/
|
|
16
14
|
export declare const getPathname: (page: Page | Folder) => Promise<string>;
|
|
17
15
|
/**
|
|
18
|
-
* Returns a single page with all its properties
|
|
19
|
-
* @param page - The page to get
|
|
20
|
-
* @param stagingUrl - The staging URL
|
|
21
|
-
* @returns The page with all its properties
|
|
16
|
+
* Returns a single page with all its properties.
|
|
22
17
|
*/
|
|
23
18
|
export declare const getPageMetadata: (page: Page) => Promise<PageWithProps>;
|
|
24
19
|
/**
|
|
25
|
-
* Returns all pages and folders from the Webflow project
|
|
26
|
-
* @param pagesAndFolders - If true, returns both pages and folders, else only pages
|
|
27
|
-
* @param kind - Filter pages by kind
|
|
20
|
+
* Returns all pages and folders from the Webflow project.
|
|
28
21
|
*/
|
|
29
22
|
export declare const getAllPages: (pagesAndFolders?: boolean, kind?: PageWithProps["kind"]) => Promise<PageWithProps[]>;
|
|
@@ -2,9 +2,7 @@ import { getLogger } from '../logger';
|
|
|
2
2
|
const logger = getLogger('webflow-apps-ui-utils');
|
|
3
3
|
let pageStagingUrl;
|
|
4
4
|
/**
|
|
5
|
-
* Generates a slug for a page or folder
|
|
6
|
-
* @param page - The page or folder to generate a slug for
|
|
7
|
-
* @returns The slug for the page or folder
|
|
5
|
+
* Generates a slug for a page or folder.
|
|
8
6
|
*/
|
|
9
7
|
export const getPathname = async (page) => {
|
|
10
8
|
const parent = await page.getParent();
|
|
@@ -20,10 +18,7 @@ export const getPathname = async (page) => {
|
|
|
20
18
|
return fullSlug.startsWith('/') ? fullSlug : `/${fullSlug}`;
|
|
21
19
|
};
|
|
22
20
|
/**
|
|
23
|
-
* Returns a single page with all its properties
|
|
24
|
-
* @param page - The page to get
|
|
25
|
-
* @param stagingUrl - The staging URL
|
|
26
|
-
* @returns The page with all its properties
|
|
21
|
+
* Returns a single page with all its properties.
|
|
27
22
|
*/
|
|
28
23
|
export const getPageMetadata = async (page) => {
|
|
29
24
|
if (!pageStagingUrl) {
|
|
@@ -55,9 +50,7 @@ export const getPageMetadata = async (page) => {
|
|
|
55
50
|
};
|
|
56
51
|
};
|
|
57
52
|
/**
|
|
58
|
-
* Returns all pages and folders from the Webflow project
|
|
59
|
-
* @param pagesAndFolders - If true, returns both pages and folders, else only pages
|
|
60
|
-
* @param kind - Filter pages by kind
|
|
53
|
+
* Returns all pages and folders from the Webflow project.
|
|
61
54
|
*/
|
|
62
55
|
export const getAllPages = async (pagesAndFolders, kind) => {
|
|
63
56
|
try {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the class list of the element
|
|
3
|
+
*/
|
|
4
|
+
export const getElementClassList = async (element) => {
|
|
5
|
+
const classList = [];
|
|
6
|
+
if (element?.styles) {
|
|
7
|
+
const stylesData = await element.getStyles();
|
|
8
|
+
const isArray = Array.isArray(stylesData);
|
|
9
|
+
if (isArray) {
|
|
10
|
+
for (const style of stylesData) {
|
|
11
|
+
const clsName = await style?.getName();
|
|
12
|
+
if (style && clsName) {
|
|
13
|
+
classList.push({ name: clsName, style });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return classList?.filter(Boolean);
|
|
19
|
+
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns a valid
|
|
3
|
-
* @param {boolean} origin - If true, returns the origin URL (without https:// and without trailing slash).
|
|
4
|
-
* @param {boolean} stagingName - If true, returns the staging name (without .webflow.io).
|
|
5
|
-
* @returns {string}
|
|
2
|
+
* Returns a valid Webflow project staging URL.
|
|
6
3
|
*/
|
|
7
4
|
export declare const getSiteStagingUrl: (origin?: boolean, stagingName?: boolean) => Promise<string>;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns a valid
|
|
3
|
-
* @param {boolean} origin - If true, returns the origin URL (without https:// and without trailing slash).
|
|
4
|
-
* @param {boolean} stagingName - If true, returns the staging name (without .webflow.io).
|
|
5
|
-
* @returns {string}
|
|
2
|
+
* Returns a valid Webflow project staging URL.
|
|
6
3
|
*/
|
|
7
4
|
export const getSiteStagingUrl = async (origin, stagingName) => {
|
|
8
5
|
const { shortName } = await webflow.getSiteInfo();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finsweet/webflow-apps-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Shared utilities for Webflow apps",
|
|
5
5
|
"homepage": "https://github.com/finsweet/webflow-apps-utils",
|
|
6
6
|
"repository": {
|
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
"@testing-library/svelte": "^5.2.4",
|
|
49
49
|
"@testing-library/user-event": "^14.6.1",
|
|
50
50
|
"@types/js-cookie": "^3.0.6",
|
|
51
|
+
"@types/lodash": "^4.17.18",
|
|
52
|
+
"@types/lodash-es": "^4.17.12",
|
|
53
|
+
"@types/lodash.isequal": "^4.5.8",
|
|
54
|
+
"@types/luxon": "^3.6.2",
|
|
51
55
|
"@types/node": "^22",
|
|
52
56
|
"@vitest/browser": "3.2.3",
|
|
53
57
|
"@vitest/coverage-v8": "3.2.3",
|
|
@@ -78,10 +82,17 @@
|
|
|
78
82
|
"clipboard": "^2.0.11",
|
|
79
83
|
"js-cookie": "^3.0.5",
|
|
80
84
|
"just-debounce": "^1.1.0",
|
|
85
|
+
"lodash": "^4.17.21",
|
|
86
|
+
"lodash-es": "^4.17.21",
|
|
87
|
+
"lodash.isequal": "^4.5.0",
|
|
81
88
|
"logrocket": "^10.1.0",
|
|
82
|
-
"
|
|
89
|
+
"luxon": "^3.6.1",
|
|
90
|
+
"motion": "^10.18.0",
|
|
91
|
+
"overlayscrollbars": "^2.11.4",
|
|
92
|
+
"overlayscrollbars-svelte": "^0.5.5",
|
|
83
93
|
"svelte-routing": "^2.13.0",
|
|
84
94
|
"swiper": "^11.2.8",
|
|
95
|
+
"terser": "^5.43.1",
|
|
85
96
|
"uuid": "^11.1.0",
|
|
86
97
|
"zod": "^3.25.64"
|
|
87
98
|
},
|
|
@@ -89,6 +100,7 @@
|
|
|
89
100
|
"dev": "vite dev",
|
|
90
101
|
"build": "vite build && npm run prepack",
|
|
91
102
|
"preview": "vite preview",
|
|
103
|
+
"watch": "svelte-kit sync && svelte-package --watch",
|
|
92
104
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
93
105
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
94
106
|
"format": "prettier --write .",
|