@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,10 @@
|
|
|
1
1
|
import type { Placement } from '@floating-ui/dom';
|
|
2
2
|
import type { Component } from 'svelte';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Controlled button item properties
|
|
5
5
|
*/
|
|
6
|
-
export interface
|
|
7
|
-
id?:
|
|
6
|
+
export interface ControlledButtonItem {
|
|
7
|
+
id?: string;
|
|
8
8
|
text: string;
|
|
9
9
|
escapeValidation?: boolean;
|
|
10
10
|
variant?: 'primary' | 'secondary' | 'cms';
|
|
@@ -13,7 +13,7 @@ export interface ButtonItem {
|
|
|
13
13
|
type?: 'library' | 'component' | 'popup';
|
|
14
14
|
onClick?: () => void;
|
|
15
15
|
show?: boolean;
|
|
16
|
-
popupButtons?:
|
|
16
|
+
popupButtons?: ControlledButtonItem[];
|
|
17
17
|
popupTrigger?: 'click' | 'hover';
|
|
18
18
|
icon?: Component;
|
|
19
19
|
description?: string;
|
|
@@ -26,3 +26,10 @@ export interface ButtonItem {
|
|
|
26
26
|
icon?: Component;
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Controlled buttons props
|
|
31
|
+
*/
|
|
32
|
+
export interface ControlledButtonsProps {
|
|
33
|
+
buttons: ControlledButtonItem[];
|
|
34
|
+
class?: string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/sveltekit';
|
|
2
|
+
import type { CopyTextProps } from './types.js';
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: import("svelte").Component<CopyTextProps, {}, "">;
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: string;
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
tags: string[];
|
|
15
|
+
argTypes: {
|
|
16
|
+
content: {
|
|
17
|
+
control: "text";
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
title: {
|
|
21
|
+
control: "text";
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
disabled: {
|
|
25
|
+
control: "boolean";
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
raw: {
|
|
29
|
+
control: "boolean";
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
hidden: {
|
|
33
|
+
control: "boolean";
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
comment: {
|
|
37
|
+
control: "text";
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
tooltip: {
|
|
41
|
+
control: "text";
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
class: {
|
|
45
|
+
control: "text";
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export default meta;
|
|
51
|
+
type Story = StoryObj<typeof meta>;
|
|
52
|
+
export declare const Default: Story;
|
|
53
|
+
export declare const WithTitle: Story;
|
|
54
|
+
export declare const Disabled: Story;
|
|
55
|
+
export declare const RawContent: Story;
|
|
56
|
+
export declare const RawContentWithComment: Story;
|
|
57
|
+
export declare const MultilineContent: Story;
|
|
58
|
+
export declare const LongContent: Story;
|
|
59
|
+
export declare const CustomTooltip: Story;
|
|
60
|
+
export declare const WithNotifications: Story;
|
|
61
|
+
export declare const HTMLSnippet: Story;
|
|
62
|
+
export declare const CSSCode: Story;
|
|
63
|
+
export declare const JSONData: Story;
|
|
64
|
+
export declare const CopiedState: Story;
|
|
65
|
+
export declare const WithCustomStyles: Story;
|
|
66
|
+
export declare const EmptyContent: Story;
|
|
67
|
+
export declare const SpecialCharacters: Story;
|
|
68
|
+
export declare const InstallCommand: Story;
|
|
69
|
+
export declare const GitClone: Story;
|
|
70
|
+
export declare const APIEndpoint: Story;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import CopyText from './CopyText.svelte';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Components/CopyText',
|
|
4
|
+
component: CopyText,
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: 'centered',
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: 'A reusable copy-to-clipboard component that handles text copying with visual feedback and optional notifications. Built with Svelte 5 runes and proper TypeScript support.'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
argTypes: {
|
|
15
|
+
content: {
|
|
16
|
+
control: 'text',
|
|
17
|
+
description: 'The content to be copied to clipboard'
|
|
18
|
+
},
|
|
19
|
+
title: {
|
|
20
|
+
control: 'text',
|
|
21
|
+
description: 'Optional title/heading text to display above the copy area'
|
|
22
|
+
},
|
|
23
|
+
disabled: {
|
|
24
|
+
control: 'boolean',
|
|
25
|
+
description: 'Whether the copy functionality is disabled'
|
|
26
|
+
},
|
|
27
|
+
raw: {
|
|
28
|
+
control: 'boolean',
|
|
29
|
+
description: 'Whether to show the content in raw format (with HTML) or cleaned'
|
|
30
|
+
},
|
|
31
|
+
hidden: {
|
|
32
|
+
control: 'boolean',
|
|
33
|
+
description: 'Whether the component is in a hidden state'
|
|
34
|
+
},
|
|
35
|
+
comment: {
|
|
36
|
+
control: 'text',
|
|
37
|
+
description: 'Optional comment to prepend to copied content when in raw mode'
|
|
38
|
+
},
|
|
39
|
+
tooltip: {
|
|
40
|
+
control: 'text',
|
|
41
|
+
description: 'Custom tooltip text for the copy button'
|
|
42
|
+
},
|
|
43
|
+
class: {
|
|
44
|
+
control: 'text',
|
|
45
|
+
description: 'Custom CSS classes'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export default meta;
|
|
50
|
+
// Basic stories
|
|
51
|
+
export const Default = {
|
|
52
|
+
args: {
|
|
53
|
+
content: 'console.log("Hello, World!");'
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export const WithTitle = {
|
|
57
|
+
args: {
|
|
58
|
+
content: 'npm install @your-org/ui-library',
|
|
59
|
+
title: 'Installation Command'
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export const Disabled = {
|
|
63
|
+
args: {
|
|
64
|
+
content: 'This content cannot be copied',
|
|
65
|
+
title: 'Disabled Copy',
|
|
66
|
+
disabled: true
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export const RawContent = {
|
|
70
|
+
args: {
|
|
71
|
+
content: '<script>\n console.log("Raw HTML/JS content");\n</script>',
|
|
72
|
+
title: 'Raw HTML/JavaScript',
|
|
73
|
+
raw: true
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export const RawContentWithComment = {
|
|
77
|
+
args: {
|
|
78
|
+
content: '<script>\n // Your custom code here\n console.log("Hello from script!");\n</script>',
|
|
79
|
+
title: 'Script with Comment',
|
|
80
|
+
raw: true,
|
|
81
|
+
comment: 'Add this script to your site'
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export const MultilineContent = {
|
|
85
|
+
args: {
|
|
86
|
+
content: `function greetUser(name) {
|
|
87
|
+
return \`Hello, \${name}! Welcome to our app.\`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Usage example
|
|
91
|
+
const greeting = greetUser('Alice');
|
|
92
|
+
console.log(greeting);`,
|
|
93
|
+
title: 'JavaScript Function',
|
|
94
|
+
tooltip: 'Copy this function to your clipboard'
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
export const LongContent = {
|
|
98
|
+
args: {
|
|
99
|
+
content: `// This is a very long line of code that demonstrates how the component handles content that exceeds the maximum width of the container and needs to wrap or scroll horizontally for better user experience and readability.
|
|
100
|
+
const veryLongVariableName = "This is a demonstration of very long content that might need horizontal scrolling";`,
|
|
101
|
+
title: 'Long Content Example'
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
export const CustomTooltip = {
|
|
105
|
+
args: {
|
|
106
|
+
content: 'secret-api-key-12345',
|
|
107
|
+
title: 'API Key',
|
|
108
|
+
tooltip: 'Click to copy your API key'
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
// Interactive examples with callbacks
|
|
112
|
+
export const WithNotifications = {
|
|
113
|
+
args: {
|
|
114
|
+
content: 'Content with notification feedback',
|
|
115
|
+
title: 'Copy with Notifications',
|
|
116
|
+
onNotify: (options) => {
|
|
117
|
+
// Simulate webflow.notify or any notification system
|
|
118
|
+
console.log(`${options.type}: ${options.message}`);
|
|
119
|
+
alert(`${options.type}: ${options.message}`);
|
|
120
|
+
},
|
|
121
|
+
onCopy: (content) => {
|
|
122
|
+
console.log('Copied:', content);
|
|
123
|
+
},
|
|
124
|
+
onError: (error) => {
|
|
125
|
+
console.error('Copy failed:', error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
// Different content types
|
|
130
|
+
export const HTMLSnippet = {
|
|
131
|
+
args: {
|
|
132
|
+
content: `<div class="banner">
|
|
133
|
+
<h1>Welcome to our site!</h1>
|
|
134
|
+
<p>This is a sample HTML snippet.</p>
|
|
135
|
+
</div>`,
|
|
136
|
+
title: 'HTML Snippet',
|
|
137
|
+
raw: true
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
export const CSSCode = {
|
|
141
|
+
args: {
|
|
142
|
+
content: `.button {
|
|
143
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
144
|
+
border: none;
|
|
145
|
+
border-radius: 8px;
|
|
146
|
+
padding: 12px 24px;
|
|
147
|
+
color: white;
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
transition: transform 0.2s ease;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.button:hover {
|
|
153
|
+
transform: translateY(-2px);
|
|
154
|
+
}`,
|
|
155
|
+
title: 'CSS Styles'
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
export const JSONData = {
|
|
159
|
+
args: {
|
|
160
|
+
content: `{
|
|
161
|
+
"name": "CopyText Component",
|
|
162
|
+
"version": "1.0.0",
|
|
163
|
+
"description": "A reusable copy-to-clipboard component",
|
|
164
|
+
"features": [
|
|
165
|
+
"Svelte 5 runes",
|
|
166
|
+
"TypeScript support",
|
|
167
|
+
"Accessibility compliant",
|
|
168
|
+
"Customizable styling"
|
|
169
|
+
]
|
|
170
|
+
}`,
|
|
171
|
+
title: 'JSON Configuration'
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
// State demonstrations
|
|
175
|
+
export const CopiedState = {
|
|
176
|
+
args: {
|
|
177
|
+
content: 'Content with callback notifications instead of visual styling',
|
|
178
|
+
title: 'Copy State Demo',
|
|
179
|
+
onNotify: (options) => {
|
|
180
|
+
alert(`${options.type}: ${options.message}`);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
parameters: {
|
|
184
|
+
docs: {
|
|
185
|
+
description: {
|
|
186
|
+
story: 'After clicking copy, notifications are handled via callbacks rather than visual styling changes.'
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
export const WithCustomStyles = {
|
|
192
|
+
args: {
|
|
193
|
+
content: 'Styled copy text component',
|
|
194
|
+
title: 'Custom Styled',
|
|
195
|
+
class: 'custom-copy-text'
|
|
196
|
+
},
|
|
197
|
+
parameters: {
|
|
198
|
+
docs: {
|
|
199
|
+
description: {
|
|
200
|
+
story: 'The component accepts custom CSS classes for styling customization.'
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
// Edge cases
|
|
206
|
+
export const EmptyContent = {
|
|
207
|
+
args: {
|
|
208
|
+
content: '',
|
|
209
|
+
title: 'Empty Content'
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
export const SpecialCharacters = {
|
|
213
|
+
args: {
|
|
214
|
+
content: `Special chars: !@#$%^&*()_+-=[]{}|;':",./<>?
|
|
215
|
+
Unicode: 🚀 💻 🎉 ✨ 🔥
|
|
216
|
+
Escaped: "quotes" 'apostrophes' \\backslashes\\`,
|
|
217
|
+
title: 'Special Characters'
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
// Real-world examples
|
|
221
|
+
export const InstallCommand = {
|
|
222
|
+
args: {
|
|
223
|
+
content: 'npm install clipboard svelte @types/node',
|
|
224
|
+
title: 'Installation',
|
|
225
|
+
tooltip: 'Copy install command'
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
export const GitClone = {
|
|
229
|
+
args: {
|
|
230
|
+
content: 'git clone https://github.com/your-org/your-repo.git',
|
|
231
|
+
title: 'Clone Repository',
|
|
232
|
+
tooltip: 'Copy git clone command'
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
export const APIEndpoint = {
|
|
236
|
+
args: {
|
|
237
|
+
content: 'https://api.yourservice.com/v1/users',
|
|
238
|
+
title: 'API Endpoint',
|
|
239
|
+
tooltip: 'Copy API endpoint URL'
|
|
240
|
+
}
|
|
241
|
+
};
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
import { CopyIcon, EyeIcon } from '../../icons';
|
|
6
|
+
import { trimExtraSpaces } from '../../../utils/helpers';
|
|
7
|
+
|
|
8
|
+
import type { CopyTextProps } from './types';
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
content,
|
|
12
|
+
title,
|
|
13
|
+
disabled = false,
|
|
14
|
+
raw = false,
|
|
15
|
+
hidden = false,
|
|
16
|
+
comment = '',
|
|
17
|
+
tooltip = 'Click to copy',
|
|
18
|
+
onNotify,
|
|
19
|
+
onCopy,
|
|
20
|
+
onError,
|
|
21
|
+
header,
|
|
22
|
+
footer,
|
|
23
|
+
class: className = '',
|
|
24
|
+
...restProps
|
|
25
|
+
}: CopyTextProps = $props();
|
|
26
|
+
|
|
27
|
+
// Component state
|
|
28
|
+
let isCopied = $state(false);
|
|
29
|
+
let isCooldown = $state(false);
|
|
30
|
+
|
|
31
|
+
// Simple computed values to avoid infinite loops
|
|
32
|
+
function getProcessedContent() {
|
|
33
|
+
if (raw) {
|
|
34
|
+
return comment ? `<!-- ${comment} -->\n${content}` : content;
|
|
35
|
+
}
|
|
36
|
+
return trimExtraSpaces(content) ?? '';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getCopyButtonClasses() {
|
|
40
|
+
return [
|
|
41
|
+
'copy-button',
|
|
42
|
+
disabled ? 'copy-button--disabled' : '',
|
|
43
|
+
isCopied ? 'copy-button--copied' : '',
|
|
44
|
+
className || ''
|
|
45
|
+
]
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.join(' ');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Handles notifications with cooldown to prevent spam
|
|
52
|
+
*/
|
|
53
|
+
const handleNotification = (type: 'Success' | 'Error', message: string) => {
|
|
54
|
+
if (!isCooldown) {
|
|
55
|
+
onNotify?.({ type, message });
|
|
56
|
+
isCooldown = true;
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
isCooldown = false;
|
|
59
|
+
}, 1000);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Simple click handler without reactive effects to avoid infinite loops
|
|
64
|
+
function handleClick() {
|
|
65
|
+
if (disabled) return;
|
|
66
|
+
|
|
67
|
+
// Use modern clipboard API instead of ClipboardJS to avoid issues
|
|
68
|
+
const textToCopy = getProcessedContent();
|
|
69
|
+
|
|
70
|
+
if (navigator.clipboard) {
|
|
71
|
+
navigator.clipboard
|
|
72
|
+
.writeText(textToCopy)
|
|
73
|
+
.then(() => {
|
|
74
|
+
isCopied = true;
|
|
75
|
+
handleNotification('Success', 'Copied to clipboard!');
|
|
76
|
+
onCopy?.(textToCopy);
|
|
77
|
+
|
|
78
|
+
// Reset copied state after 2 seconds
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
isCopied = false;
|
|
81
|
+
}, 2000);
|
|
82
|
+
})
|
|
83
|
+
.catch(() => {
|
|
84
|
+
const errorMessage = 'Failed to copy. Please try again.';
|
|
85
|
+
handleNotification('Error', errorMessage);
|
|
86
|
+
onError?.(errorMessage);
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
// Fallback for browsers that don't support navigator.clipboard
|
|
90
|
+
const errorMessage = 'Clipboard not supported in this browser';
|
|
91
|
+
handleNotification('Error', errorMessage);
|
|
92
|
+
onError?.(errorMessage);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
{#if !hidden}
|
|
98
|
+
<div class="copy-text" {...restProps}>
|
|
99
|
+
{#if header}
|
|
100
|
+
<div class="copy-text__header">
|
|
101
|
+
{@render header()}
|
|
102
|
+
</div>
|
|
103
|
+
{:else if title}
|
|
104
|
+
<div class="copy-text__header">
|
|
105
|
+
<h3 class="copy-text__title">{title}</h3>
|
|
106
|
+
</div>
|
|
107
|
+
{/if}
|
|
108
|
+
|
|
109
|
+
<div
|
|
110
|
+
class={getCopyButtonClasses()}
|
|
111
|
+
role="button"
|
|
112
|
+
tabindex="0"
|
|
113
|
+
aria-label={disabled ? 'Copy disabled' : tooltip}
|
|
114
|
+
title={tooltip}
|
|
115
|
+
onclick={handleClick}
|
|
116
|
+
onkeydown={(e) => {
|
|
117
|
+
if ((e.key === 'Enter' || e.key === ' ') && !disabled) {
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
handleClick();
|
|
120
|
+
}
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<div class="copy-button__content" id="copy-content">
|
|
124
|
+
{getProcessedContent()}
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<div class="copy-button__icon" aria-hidden="true">
|
|
128
|
+
{#if disabled}
|
|
129
|
+
<EyeIcon />
|
|
130
|
+
{:else}
|
|
131
|
+
<CopyIcon size={16} />
|
|
132
|
+
{/if}
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
{#if footer}
|
|
137
|
+
<div class="copy-text__footer">
|
|
138
|
+
{@render footer()}
|
|
139
|
+
</div>
|
|
140
|
+
{/if}
|
|
141
|
+
</div>
|
|
142
|
+
{/if}
|
|
143
|
+
|
|
144
|
+
<style>
|
|
145
|
+
.copy-text {
|
|
146
|
+
display: flex;
|
|
147
|
+
flex-direction: column;
|
|
148
|
+
gap: 12px;
|
|
149
|
+
width: 100%;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.copy-text__header {
|
|
153
|
+
display: flex;
|
|
154
|
+
align-items: center;
|
|
155
|
+
gap: 8px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.copy-text__title {
|
|
159
|
+
margin: 0;
|
|
160
|
+
color: var(--text-color-primary, #ffffff);
|
|
161
|
+
font-family: Inter, sans-serif;
|
|
162
|
+
font-size: 12px;
|
|
163
|
+
font-weight: 500;
|
|
164
|
+
line-height: 16px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.copy-button {
|
|
168
|
+
display: flex;
|
|
169
|
+
align-items: flex-start;
|
|
170
|
+
justify-content: space-between;
|
|
171
|
+
gap: 8px;
|
|
172
|
+
padding: 6px 8px;
|
|
173
|
+
border-radius: 4px;
|
|
174
|
+
background: var(
|
|
175
|
+
--button-secondary-background,
|
|
176
|
+
linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.1) 100%),
|
|
177
|
+
rgba(255, 255, 255, 0.08)
|
|
178
|
+
);
|
|
179
|
+
box-shadow:
|
|
180
|
+
0px 0.5px 0.5px 0px rgba(255, 255, 255, 0.12) inset,
|
|
181
|
+
0px 0.5px 1px 0px #000;
|
|
182
|
+
color: var(--text-color-secondary, #d9d9d9);
|
|
183
|
+
font-family: Inter, sans-serif;
|
|
184
|
+
font-size: 11px;
|
|
185
|
+
font-weight: 500;
|
|
186
|
+
line-height: 16px;
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
transition: all 0.2s ease-in-out;
|
|
189
|
+
outline: none;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.copy-button:hover:not(.copy-button--disabled) {
|
|
193
|
+
background: var(
|
|
194
|
+
--button-secondary-background-hover,
|
|
195
|
+
linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.14) 100%),
|
|
196
|
+
rgba(255, 255, 255, 0.12)
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.copy-button:focus-visible {
|
|
201
|
+
outline: 2px solid var(--focus-color, #0066cc);
|
|
202
|
+
outline-offset: 2px;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.copy-button--disabled {
|
|
206
|
+
background: none;
|
|
207
|
+
border: 1px solid var(--border-color-disabled, rgba(255, 255, 255, 0.2));
|
|
208
|
+
box-shadow: none;
|
|
209
|
+
opacity: 0.75;
|
|
210
|
+
cursor: not-allowed;
|
|
211
|
+
color: var(--text-color-disabled, #999999);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.copy-button__content {
|
|
215
|
+
display: flex;
|
|
216
|
+
align-items: flex-start;
|
|
217
|
+
flex: 1;
|
|
218
|
+
overflow: auto;
|
|
219
|
+
white-space: pre-wrap;
|
|
220
|
+
word-wrap: break-word;
|
|
221
|
+
max-width: 600px;
|
|
222
|
+
min-height: max-content;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.copy-button__content:disabled {
|
|
226
|
+
cursor: not-allowed;
|
|
227
|
+
color: var(--text-color-disabled, #999999);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.copy-button__icon {
|
|
231
|
+
display: flex;
|
|
232
|
+
align-items: center;
|
|
233
|
+
height: 16px;
|
|
234
|
+
flex-shrink: 0;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.copy-text__footer {
|
|
238
|
+
display: flex;
|
|
239
|
+
flex-direction: column;
|
|
240
|
+
gap: 8px;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* Responsive design */
|
|
244
|
+
@media (max-width: 768px) {
|
|
245
|
+
.copy-button__content {
|
|
246
|
+
max-width: 300px;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CopyText } from './CopyText.svelte';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
/**
|
|
4
|
+
* Notification function type for copy operations
|
|
5
|
+
*/
|
|
6
|
+
export interface NotificationFunction {
|
|
7
|
+
(options: {
|
|
8
|
+
type: 'Success' | 'Error';
|
|
9
|
+
message: string;
|
|
10
|
+
}): void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Props for the CopyText component
|
|
14
|
+
*/
|
|
15
|
+
export interface CopyTextProps extends HTMLAttributes<HTMLDivElement> {
|
|
16
|
+
/** The content to be copied to clipboard */
|
|
17
|
+
content: string;
|
|
18
|
+
/** Optional title/heading text to display above the copy area */
|
|
19
|
+
title?: string;
|
|
20
|
+
/** Whether the copy functionality is disabled */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** Whether to show the content in raw format (with HTML) or cleaned */
|
|
23
|
+
raw?: boolean;
|
|
24
|
+
/** Whether the component is in a hidden state */
|
|
25
|
+
hidden?: boolean;
|
|
26
|
+
/** Optional comment to prepend to copied content when in raw mode */
|
|
27
|
+
comment?: string;
|
|
28
|
+
/** Custom tooltip text for the copy button */
|
|
29
|
+
tooltip?: string;
|
|
30
|
+
/** Optional notification function to call on copy success/error */
|
|
31
|
+
onNotify?: NotificationFunction;
|
|
32
|
+
/** Callback fired when content is successfully copied */
|
|
33
|
+
onCopy?: (content: string) => void;
|
|
34
|
+
/** Callback fired when copy fails */
|
|
35
|
+
onError?: (error: string) => void;
|
|
36
|
+
/** Optional snippet for custom header content */
|
|
37
|
+
header?: Snippet;
|
|
38
|
+
/** Optional snippet for additional content below the copy area */
|
|
39
|
+
footer?: Snippet;
|
|
40
|
+
/** Custom CSS classes */
|
|
41
|
+
class?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Event types for clipboard operations
|
|
45
|
+
*/
|
|
46
|
+
export interface CopyEvent {
|
|
47
|
+
text: string;
|
|
48
|
+
clearSelection: () => void;
|
|
49
|
+
}
|
|
50
|
+
export interface CopyErrorEvent {
|
|
51
|
+
message: string;
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|