@wix/ditto-codegen-public 1.0.136 → 1.0.137

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.
Files changed (58) hide show
  1. package/dist/examples-apps/ai-chatbot/src/dashboard/pages/product/ProductChat.tsx +26 -20
  2. package/dist/examples-apps/ai-chatbot/src/dashboard/pages/product/page.tsx +12 -11
  3. package/dist/out.js +213 -170
  4. package/package.json +2 -2
  5. package/dist/examples-apps/ai-chatbot/src/backend/api/chat/api.ts +0 -62
  6. package/dist/examples-apps/ai-chatbot/src/backend/api/settings/api.ts +0 -39
  7. package/dist/examples-apps/ai-chatbot/src/backend/database.ts +0 -86
  8. package/dist/examples-apps/ai-chatbot/src/dashboard/pages/product/page.json +0 -6
  9. package/dist/examples-apps/ai-chatbot/src/dashboard/pages/settings/page.json +0 -6
  10. package/dist/examples-apps/ai-chatbot/src/dashboard/pages/settings/page.tsx +0 -105
  11. package/dist/examples-apps/ai-chatbot/src/dashboard/pages/wix_logo.svg +0 -18
  12. package/dist/examples-apps/ai-chatbot/src/dashboard/utils.ts +0 -27
  13. package/dist/examples-apps/custom-products-catalog/.nvmrc +0 -1
  14. package/dist/examples-apps/custom-products-catalog/README.md +0 -21
  15. package/dist/examples-apps/custom-products-catalog/package-lock.json +0 -8694
  16. package/dist/examples-apps/custom-products-catalog/package.json +0 -33
  17. package/dist/examples-apps/custom-products-catalog/src/dashboard/components/create-product.tsx +0 -54
  18. package/dist/examples-apps/custom-products-catalog/src/dashboard/hooks/stores.ts +0 -60
  19. package/dist/examples-apps/custom-products-catalog/src/dashboard/pages/page.json +0 -5
  20. package/dist/examples-apps/custom-products-catalog/src/dashboard/pages/page.tsx +0 -297
  21. package/dist/examples-apps/custom-products-catalog/src/dashboard/pages/wix_logo.svg +0 -18
  22. package/dist/examples-apps/custom-products-catalog/src/dashboard/withProviders.tsx +0 -16
  23. package/dist/examples-apps/custom-products-catalog/src/env.d.ts +0 -4
  24. package/dist/examples-apps/custom-products-catalog/tsconfig.json +0 -8
  25. package/dist/examples-apps/custom-products-catalog/wix.config.json +0 -5
  26. package/dist/examples-apps/site-popup/.nvmrc +0 -1
  27. package/dist/examples-apps/site-popup/README.md +0 -21
  28. package/dist/examples-apps/site-popup/package.json +0 -51
  29. package/dist/examples-apps/site-popup/src/components/activation-configuration.tsx +0 -49
  30. package/dist/examples-apps/site-popup/src/components/close-button.css +0 -33
  31. package/dist/examples-apps/site-popup/src/components/close-button.tsx +0 -31
  32. package/dist/examples-apps/site-popup/src/components/date-range-picker.tsx +0 -49
  33. package/dist/examples-apps/site-popup/src/components/image-picker.tsx +0 -33
  34. package/dist/examples-apps/site-popup/src/components/popup/index.css +0 -133
  35. package/dist/examples-apps/site-popup/src/components/popup/index.tsx +0 -71
  36. package/dist/examples-apps/site-popup/src/components/site-popup-settings.tsx +0 -120
  37. package/dist/examples-apps/site-popup/src/dashboard/hooks/wix-embeds.ts +0 -33
  38. package/dist/examples-apps/site-popup/src/dashboard/pages/page.tsx +0 -78
  39. package/dist/examples-apps/site-popup/src/dashboard/withProviders.tsx +0 -22
  40. package/dist/examples-apps/site-popup/src/extensions.ts +0 -20
  41. package/dist/examples-apps/site-popup/src/site/embedded-scripts/site-popup/embedded.html +0 -13
  42. package/dist/examples-apps/site-popup/src/site/embedded-scripts/site-popup/popup-overlay/index.css +0 -21
  43. package/dist/examples-apps/site-popup/src/site/embedded-scripts/site-popup/popup-overlay/index.tsx +0 -57
  44. package/dist/examples-apps/site-popup/src/types.ts +0 -14
  45. package/dist/examples-apps/site-popup/tsconfig.json +0 -9
  46. package/dist/examples-apps/site-popup/wix.config.json +0 -5
  47. package/dist/examples-apps/spis-examples/src/dashboard/pages/page.tsx +0 -59
  48. package/dist/examples-apps/spis-examples/src/dashboard/pages/wix_logo.svg +0 -18
  49. package/dist/examples-apps/top-blog-posts/.nvmrc +0 -1
  50. package/dist/examples-apps/top-blog-posts/README.md +0 -21
  51. package/dist/examples-apps/top-blog-posts/package-lock.json +0 -6406
  52. package/dist/examples-apps/top-blog-posts/package.json +0 -31
  53. package/dist/examples-apps/top-blog-posts/src/dashboard/pages/blog-utils.ts +0 -44
  54. package/dist/examples-apps/top-blog-posts/src/dashboard/pages/page.tsx +0 -129
  55. package/dist/examples-apps/top-blog-posts/src/dashboard/pages/wix_logo.svg +0 -18
  56. package/dist/examples-apps/top-blog-posts/src/env.d.ts +0 -4
  57. package/dist/examples-apps/top-blog-posts/tsconfig.json +0 -8
  58. package/dist/examples-apps/top-blog-posts/wix.config.json +0 -5
@@ -1,31 +0,0 @@
1
- import React, { type FC } from 'react';
2
- import './close-button.css';
3
-
4
- interface Props {
5
- onClick?: () => void;
6
- }
7
-
8
- export const CloseButton: FC<Props> = ({ onClick }) => {
9
- return (
10
- <div className="close-button-wrapper">
11
- <button
12
- onClick={onClick}
13
- type="button"
14
- className="close-button"
15
- >
16
- <svg
17
- className="close-icon"
18
- fill="currentColor"
19
- viewBox="0 0 20 20"
20
- xmlns="http://www.w3.org/2000/svg"
21
- >
22
- <path
23
- fillRule="evenodd"
24
- d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
25
- clipRule="evenodd"
26
- ></path>
27
- </svg>
28
- </button>
29
- </div>
30
- );
31
- };
@@ -1,49 +0,0 @@
1
- import React, { type FC } from 'react';
2
- import { Box, Cell, DatePicker, FormField, Layout } from '@wix/design-system';
3
-
4
- interface Props {
5
- startDate: number;
6
- endDate: number;
7
- onChange?: (startDate: number, endDate: number) => void;
8
- }
9
-
10
- export const DataRangePicker: FC<Props> = ({
11
- onChange,
12
- startDate,
13
- endDate,
14
- }) => {
15
- return (
16
- <Layout>
17
- <Cell span={6}>
18
- <Box gap={2}>
19
- <FormField label="Start date">
20
- <Box marginTop={1}>
21
- <DatePicker
22
- width="100%"
23
- placeholderText="Select"
24
- value={new Date(startDate)}
25
- onChange={(value: Date) => onChange?.(value.getTime(), endDate)}
26
- />
27
- </Box>
28
- </FormField>
29
- </Box>
30
- </Cell>
31
- <Cell span={6}>
32
- <Box gap={2}>
33
- <FormField label="End date">
34
- <Box marginTop={1}>
35
- <DatePicker
36
- width="100%"
37
- placeholderText="Select"
38
- value={new Date(endDate)}
39
- onChange={(value: Date) =>
40
- onChange?.(startDate, value.getTime())
41
- }
42
- />
43
- </Box>
44
- </FormField>
45
- </Box>
46
- </Cell>
47
- </Layout>
48
- );
49
- };
@@ -1,33 +0,0 @@
1
- import React, { type FC } from 'react';
2
- import { Box, Input, TextButton } from '@wix/design-system';
3
- import { dashboard } from '@wix/dashboard';
4
- import * as Icons from '@wix/wix-ui-icons-common';
5
-
6
- interface Props {
7
- imageUrl: string;
8
- imageTitle: string;
9
- onChange: (imageUrl: string, imageTitle: string) => void;
10
- }
11
-
12
- export const ImagePicker: FC<Props> = ({ onChange, imageTitle }) => {
13
- return (
14
- <Box gap={3} verticalAlign="middle" marginTop={1}>
15
- <Input value={imageTitle} disabled />
16
- <TextButton
17
- prefixIcon={<Icons.Edit />}
18
- onClick={() =>
19
- dashboard.openMediaManager().then((response) => {
20
- if (response?.items[0]) {
21
- onChange(
22
- response?.items[0].url || '',
23
- response?.items[0].displayName || ''
24
- );
25
- }
26
- })
27
- }
28
- >
29
- Change image
30
- </TextButton>
31
- </Box>
32
- );
33
- };
@@ -1,133 +0,0 @@
1
- .popup-card {
2
- border-radius: 0.5rem;
3
- box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
4
- display: grid;
5
- position: relative;
6
- }
7
-
8
- @media (min-width: 768px) {
9
- .popup-card {
10
- grid-template-columns: repeat(2, minmax(0, 1fr));
11
- }
12
- }
13
-
14
- .close-btn-container {
15
- position: absolute;
16
- z-index: 1000;
17
- }
18
-
19
- .popup-content {
20
- padding: 1rem;
21
- text-align: center;
22
- background-color: #1f2937;
23
- display: flex;
24
- flex-direction: column;
25
- justify-content: space-between;
26
- border-top-left-radius: 0.5rem;
27
- border-bottom-left-radius: 0.5rem;
28
- }
29
-
30
- @media (min-width: 640px) {
31
- .popup-content {
32
- padding: 1.5rem;
33
- }
34
- }
35
-
36
- @media (min-width: 768px) {
37
- .popup-content {
38
- grid-column: span 1;
39
- }
40
- }
41
-
42
- @media (min-width: 1024px) {
43
- .popup-content {
44
- padding: 2rem;
45
- }
46
- }
47
-
48
- .popup-text-container {
49
- position: relative;
50
- bottom: 0;
51
- isolation: isolate;
52
- overflow: hidden;
53
- padding: 6rem 1rem;
54
- }
55
-
56
- @media (min-width: 640px) {
57
- .popup-text-container {
58
- padding-left: 3rem;
59
- padding-right: 3rem;
60
- }
61
- }
62
-
63
- @media (min-width: 1280px) {
64
- .popup-text-container {
65
- padding-top: 8rem;
66
- padding-bottom: 8rem;
67
- }
68
- }
69
-
70
- .popup-headline {
71
- margin-left: auto;
72
- margin-right: auto;
73
- max-width: 42rem;
74
- text-align: center;
75
- font-size: 1.875rem;
76
- font-weight: 700;
77
- letter-spacing: -0.025em;
78
- color: white;
79
- }
80
-
81
- @media (min-width: 640px) {
82
- .popup-headline {
83
- font-size: 2.25rem;
84
- }
85
- }
86
-
87
- .popup-text {
88
- margin-left: auto;
89
- margin-right: auto;
90
- margin-top: 0.5rem;
91
- max-width: 36rem;
92
- text-align: center;
93
- font-size: 1.125rem;
94
- line-height: 2rem;
95
- color: #d1d5db;
96
- }
97
-
98
- .popup-button-container {
99
- display: flex;
100
- justify-content: center;
101
- align-items: center;
102
- padding: 1rem;
103
- }
104
-
105
- .popup-dont-show-button {
106
- font-size: 0.875rem;
107
- color: white;
108
- background: transparent;
109
- border: none;
110
- cursor: pointer;
111
- padding: 0.5rem 1rem;
112
- transition: opacity 0.2s ease;
113
- }
114
-
115
- .popup-dont-show-button:hover {
116
- opacity: 0.8;
117
- text-decoration: underline;
118
- }
119
-
120
- .popup-image {
121
- height: 16rem;
122
- object-fit: cover;
123
- width: 100%;
124
- border-top-right-radius: 0.5rem;
125
- border-bottom-right-radius: 0.5rem;
126
- }
127
-
128
- @media (min-width: 768px) {
129
- .popup-image {
130
- height: 100%;
131
- }
132
- }
133
-
@@ -1,71 +0,0 @@
1
- import React, { type FC } from 'react';
2
- import { CloseButton } from '../close-button.js';
3
- import type { SitePopupOptions } from '../../types.js';
4
- import './index.css';
5
-
6
- function formatDateWithLocale(dateInMillis: string, locale: string) {
7
- const date = new Date(Number(dateInMillis));
8
- const formatter = new Intl.DateTimeFormat(locale, {
9
- year: 'numeric',
10
- month: 'long',
11
- day: 'numeric',
12
- });
13
- return formatter.format(date);
14
- }
15
-
16
- export const Popup: FC<
17
- SitePopupOptions & {
18
- locale: string;
19
- onClose?: (hideForever?: boolean) => void;
20
- }
21
- > = ({
22
- headline,
23
- text,
24
- imageUrl,
25
- imageTitle,
26
- onClose,
27
- startDate,
28
- endDate,
29
- locale,
30
- }) => {
31
- let formattedText = text;
32
- if (startDate) {
33
- formattedText = formattedText.replace(/{startDate}/g, formatDateWithLocale(startDate, locale));
34
- }
35
- if (endDate) {
36
- formattedText = formattedText.replace(/{endDate}/g, formatDateWithLocale(endDate, locale));
37
- }
38
- return (
39
- <div className="popup-card">
40
- <div id="close-btn" className="close-btn-container">
41
- <CloseButton onClick={() => onClose?.()} />
42
- </div>
43
- <div className="popup-content">
44
- <div className="popup-text-container">
45
- <h4 className="popup-headline">
46
- <span style={{font: 'var(--wst-font-style-h4)'}}>{headline}</span>
47
- </h4>
48
- <p className="popup-text">
49
- <span style={{font: 'var(--wst-font-style-body-medium)'}}>{formattedText}</span>
50
- </p>
51
- </div>
52
- <div className="popup-button-container">
53
- <button
54
- type="button"
55
- className="popup-dont-show-button"
56
- onClick={() => onClose?.(true)}
57
- >
58
- <span style={{font: 'var(--wst-font-style-body-small)'}}>Don't show this again</span>
59
- </button>
60
- </div>
61
- </div>
62
- <img
63
- width="50vw"
64
- height="50vh"
65
- src={imageUrl}
66
- alt={imageTitle}
67
- className="popup-image"
68
- />
69
- </div>
70
- );
71
- };
@@ -1,120 +0,0 @@
1
- import React, { type FC } from 'react';
2
- import {
3
- Input,
4
- Text,
5
- Box,
6
- InputArea,
7
- Card,
8
- FormField,
9
- type FormFieldProps,
10
- } from '@wix/design-system';
11
- import { ActivationConfiguration } from './activation-configuration.js';
12
- import { ImagePicker } from './image-picker.js';
13
- import type { SitePopupOptions } from '../types.js';
14
-
15
- interface Props {
16
- options: SitePopupOptions;
17
- onChange: (options: SitePopupOptions) => void;
18
- }
19
-
20
- export const SitePopupSettings: FC<Props> = ({ options, onChange }) => {
21
- const getFieldStatus = (
22
- field: keyof SitePopupOptions
23
- ): Partial<FormFieldProps> => {
24
- return !options[field]
25
- ? {
26
- status: 'error',
27
- statusMessage: 'Required.',
28
- }
29
- : {};
30
- };
31
-
32
- return (
33
- <Box direction="vertical">
34
- <Box gap={10} direction="vertical">
35
- <Card>
36
- <Card.Header
37
- title="Settings"
38
- subtitle={
39
- <Box direction="horizontal">
40
- <Text secondary>Customize your site popup appearance.</Text>
41
- </Box>
42
- }
43
- />
44
- <Card.Divider />
45
- <Card.Content>
46
- <Box gap={3} direction="vertical">
47
- <Box gap={3} direction="vertical" width={'50%'}>
48
- <FormField
49
- labelSize="small"
50
- label="Headline"
51
- {...getFieldStatus('headline')}
52
- >
53
- <Input
54
- placeholder="Sale 20% Off"
55
- value={options?.headline}
56
- onChange={(e) =>
57
- onChange({
58
- ...options,
59
- headline: e.currentTarget.value,
60
- })
61
- }
62
- />
63
- </FormField>
64
- <FormField
65
- labelSize="small"
66
- label="Text"
67
- infoContent={
68
- options.activationMode == 'timed'
69
- ? 'Include the placeholders {startDate} and {endDate} to show the start and end dates, formatted according to the site\'s regional settings.'
70
- : undefined
71
- }
72
- {...getFieldStatus('text')}
73
- >
74
- <InputArea
75
- placeholder="Sign up and get 20% off on our Winter Sale"
76
- value={options?.text}
77
- onChange={(e) =>
78
- onChange({
79
- ...options,
80
- text: e.currentTarget.value,
81
- })
82
- }
83
- />
84
- </FormField>
85
- <FormField labelSize="small" label="Popup Activation">
86
- <ActivationConfiguration
87
- activationOptions={{
88
- activationMode: options.activationMode,
89
- ...(options.startDate != null && { startDate: options.startDate }),
90
- ...(options.endDate != null && { endDate: options.endDate }),
91
- }}
92
- onChange={(activationOptions) =>
93
- onChange({
94
- ...options,
95
- ...activationOptions,
96
- })
97
- }
98
- />
99
- </FormField>
100
- <FormField labelSize="small" label="Popup Image">
101
- <ImagePicker
102
- imageTitle={options.imageTitle}
103
- imageUrl={options.imageUrl}
104
- onChange={(imageUrl, imageTitle) =>
105
- onChange({
106
- ...options,
107
- imageUrl,
108
- imageTitle,
109
- })
110
- }
111
- />
112
- </FormField>
113
- </Box>
114
- </Box>
115
- </Card.Content>
116
- </Card>
117
- </Box>
118
- </Box>
119
- );
120
- };
@@ -1,33 +0,0 @@
1
- import { embeddedScripts } from '@wix/app-management';
2
- import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
3
-
4
- export const QUERY_EMBEDS = 'queryEmbeds';
5
- export const MUTATE_EMBEDS = 'mutateEmbeds';
6
-
7
- export const useEmbeds = <T extends Record<string, string>>() => {
8
- const queryClient = useQueryClient();
9
-
10
- const getEmbeddedScript = useQuery<unknown, unknown, T>({
11
- queryKey: [QUERY_EMBEDS],
12
- refetchOnWindowFocus: false,
13
- queryFn: async () => {
14
- // https://dev.wix.com/docs/sdk/backend-modules/app-management/embedded-scripts/get-embedded-script
15
- const embeddedScript = await embeddedScripts.getEmbeddedScript();
16
- return embeddedScript.parameters || {};
17
- },
18
- });
19
-
20
- const embedScript = useMutation<unknown, unknown, T>({
21
- mutationKey: [MUTATE_EMBEDS],
22
- mutationFn: async (parameters) => {
23
- // https://dev.wix.com/docs/sdk/backend-modules/app-management/embedded-scripts/embed-script
24
- await embeddedScripts.embedScript({ parameters });
25
- return parameters;
26
- },
27
- onSuccess: (data) => {
28
- queryClient.setQueryData([QUERY_EMBEDS], data);
29
- },
30
- });
31
-
32
- return { embedScript, getEmbeddedScript };
33
- };
@@ -1,78 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { i18n } from '@wix/essentials';
3
- import { Box, Button, Cell, Layout, Loader, Page } from '@wix/design-system';
4
- import '@wix/design-system/styles.global.css';
5
- import { withProviders } from '../withProviders';
6
- import { SitePopupSettings } from '../../components/site-popup-settings.js';
7
- import { useEmbeds } from '../hooks/wix-embeds.js';
8
- import type { SitePopupOptions } from '../../types.js';
9
- import { Popup } from '../../components/popup/index.js';
10
-
11
- const sitePopupDefaultOptions: SitePopupOptions = {
12
- headline: 'Sale 20% Off',
13
- text: 'Sign up and get 20% off on our Winter Sale',
14
- imageUrl:
15
- 'https://static.wixstatic.com/media/11062b_db81bbf678b641ff9e00b768cb155a49~mv2.jpg',
16
- imageTitle: 'Clothes For Sale',
17
- activationMode: 'active',
18
- };
19
-
20
- function SitePopup() {
21
- const locale = i18n.getLocale();
22
-
23
- const { embedScript, getEmbeddedScript } =
24
- useEmbeds<Partial<SitePopupOptions>>();
25
-
26
- const [sitePopupOptions, setSitePopupOptions] = useState<SitePopupOptions>(
27
- sitePopupDefaultOptions
28
- );
29
-
30
- useEffect(() => {
31
- setSitePopupOptions((prevOptions) => ({
32
- ...prevOptions,
33
- ...getEmbeddedScript.data,
34
- imageUrl: (
35
- getEmbeddedScript.data?.imageUrl || prevOptions.imageUrl
36
- ).replace(/\\/g, ''),
37
- }));
38
- }, [getEmbeddedScript.data]);
39
-
40
- return (
41
- <Page height="100vh">
42
- <Page.Header
43
- title="Site Popup"
44
- subtitle="Configure site popup setting & preview as it will appear on your site."
45
- actionsBar={
46
- <Button
47
- skin="inverted"
48
- disabled={!sitePopupOptions.headline || !sitePopupOptions.text}
49
- onClick={() => embedScript.mutate({ ...sitePopupOptions })}
50
- >
51
- Save
52
- </Button>
53
- }
54
- />
55
- <Page.Content>
56
- {getEmbeddedScript.isLoading ? (
57
- <Box align="center" verticalAlign="middle" height="50vh">
58
- <Loader text="Loading..." />
59
- </Box>
60
- ) : (
61
- <Layout>
62
- <Cell>
63
- <SitePopupSettings
64
- options={sitePopupOptions}
65
- onChange={(options) => setSitePopupOptions(options)}
66
- />
67
- </Cell>
68
- <Cell>
69
- <Popup {...sitePopupOptions} locale={locale} />
70
- </Cell>
71
- </Layout>
72
- )}
73
- </Page.Content>
74
- </Page>
75
- );
76
- }
77
-
78
- export default withProviders(SitePopup);
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
3
- import { WixDesignSystemProvider } from '@wix/design-system';
4
- import { i18n } from '@wix/essentials';
5
-
6
- const queryClient = new QueryClient();
7
-
8
- export default function withProviders<P extends {} = {}>(Component: React.FC<P>) {
9
- return function DashboardProviders(props: P) {
10
- const locale = i18n.getLocale();
11
- return (
12
- <WixDesignSystemProvider locale={locale} features={{ newColorsBranding: true }}>
13
- <QueryClientProvider client={queryClient}>
14
- <Component {...props} />
15
- </QueryClientProvider>
16
- </WixDesignSystemProvider>
17
- );
18
- };
19
- }
20
-
21
- // Also export as named export for backwards compatibility
22
- export { withProviders };
@@ -1,20 +0,0 @@
1
- import { app, extensions } from '@wix/astro/builders';
2
-
3
- export default app()
4
- .use(
5
- extensions.embeddedScript({
6
- id: '2c43c310-939b-451d-b488-805f7ebba6ab',
7
- name: 'Site Popup',
8
- scriptType: 'FUNCTIONAL',
9
- placement: 'BODY_START',
10
- source: './site/embedded-scripts/site-popup/embedded.html',
11
- })
12
- )
13
- .use(
14
- extensions.dashboardPage({
15
- id: '57512654-b94e-460b-91e4-88624b5afea3',
16
- component: './dashboard/pages/page.tsx',
17
- routePath: 'hello',
18
- title: 'Site popup',
19
- })
20
- );
@@ -1,13 +0,0 @@
1
- <div
2
- id="popup-data"
3
- data-headline="{{headline}}"
4
- data-text="{{text}}"
5
- data-activation-mode="{{activationMode}}"
6
- data-start-date="{{startDate}}"
7
- data-end-date="{{endDate}}"
8
- data-image-url="{{imageUrl}}"
9
- data-image-title="{{imageTitle}}"
10
- ></div>
11
- <div id="site-popup"></div>
12
- <script type="module" src="./popup-overlay/index.tsx"></script>
13
-
@@ -1,21 +0,0 @@
1
- .popup-overlay {
2
- position: fixed;
3
- display: flex;
4
- justify-content: center;
5
- align-items: center;
6
- top: 0;
7
- left: 0;
8
- right: 0;
9
- bottom: 0;
10
- z-index: 1000;
11
- background-color: rgba(209, 213, 219, 0.75);
12
- }
13
-
14
- .popup-overlay.hidden {
15
- display: none;
16
- }
17
-
18
- .popup-container {
19
- width: 75%;
20
- }
21
-
@@ -1,57 +0,0 @@
1
- import { createRoot } from 'react-dom/client';
2
- import React, { useEffect, useState } from 'react';
3
- import { site } from '@wix/site-site';
4
- import './index.css';
5
- import type { SitePopupOptions } from '../../../../types';
6
- import { Popup } from '../../../../components/popup';
7
-
8
- const PopupOverlay = () => {
9
- const [shown, setShown] = useState<boolean>(false);
10
- const el = document.querySelector('#popup-data') as HTMLElement;
11
- const popupParams = el?.dataset as SitePopupOptions;
12
-
13
- const [regionalSettings, setRegionalSettings] = useState<string>('en-us');
14
-
15
- useEffect(() => {
16
- site.regionalSettings().then(setRegionalSettings);
17
- }, []);
18
-
19
- useEffect(() => {
20
- const isPopupShownStorage = localStorage.getItem('isPopupShown');
21
- setShown(isPopupShownStorage !== 'false');
22
- }, []);
23
-
24
- const closePopup = (hideForever?: boolean) => {
25
- setShown(false);
26
- if (hideForever) {
27
- localStorage.setItem('isPopupShown', 'false');
28
- }
29
- };
30
-
31
- const shouldShowPopup = () => {
32
- if (popupParams.activationMode === 'timed') {
33
- return (
34
- Date.now() > new Date(Number(popupParams.startDate)).getTime() &&
35
- Date.now() < new Date(Number(popupParams.endDate)).getTime()
36
- );
37
- } else if (popupParams.activationMode === 'active') {
38
- return true;
39
- }
40
- return false;
41
- };
42
-
43
- return (
44
- <div
45
- className={
46
- shown && shouldShowPopup() ? 'popup-overlay' : 'popup-overlay hidden'
47
- }
48
- >
49
- <div className="popup-container">
50
- <Popup {...popupParams} locale={regionalSettings} onClose={closePopup} />
51
- </div>
52
- </div>
53
- );
54
- };
55
-
56
- const root = createRoot(document.getElementById('site-popup')!);
57
- root.render(<PopupOverlay />);