@wix/ditto-codegen-public 1.0.40 → 1.0.41

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 (19) hide show
  1. package/dist/examples-apps/custom-element/src/widgets/custom-elements/countdown-timer/widget.tsx +332 -0
  2. package/dist/out.js +213 -77
  3. package/package.json +2 -2
  4. package/dist/examples-apps/chart-widget/.nvmrc +0 -1
  5. package/dist/examples-apps/chart-widget/README.md +0 -21
  6. package/dist/examples-apps/chart-widget/assets/chart-widget/thumbnail.png +0 -0
  7. package/dist/examples-apps/chart-widget/package-lock.json +0 -6329
  8. package/dist/examples-apps/chart-widget/package.json +0 -30
  9. package/dist/examples-apps/chart-widget/src/env.d.ts +0 -4
  10. package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/common.ts +0 -20
  11. package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/element/bar-chart.tsx +0 -53
  12. package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/element/pie-chart.tsx +0 -40
  13. package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/element.json +0 -20
  14. package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/element.tsx +0 -53
  15. package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/panel/chart-type.tsx +0 -47
  16. package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/panel/slice.tsx +0 -72
  17. package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/panel.tsx +0 -90
  18. package/dist/examples-apps/chart-widget/tsconfig.json +0 -8
  19. package/dist/examples-apps/chart-widget/wix.config.json +0 -5
@@ -1,30 +0,0 @@
1
- {
2
- "name": "chart-widget",
3
- "version": "1.0.0",
4
- "dependencies": {
5
- "@wix/design-system": "^1.0.0",
6
- "@wix/editor": "^1.0.0",
7
- "@wix/wix-ui-icons-common": "^3.0.0",
8
- "react-to-webcomponent": "^2.0.0",
9
- "recharts": "^2.0.0"
10
- },
11
- "devDependencies": {
12
- "@types/react": "^16.0.0",
13
- "@types/react-dom": "^16.0.0",
14
- "@wix/cli": "^1.0.0",
15
- "@wix/cli-app": "^1.0.0",
16
- "@wix/sdk-types": "^1.0.0",
17
- "react": "16.14.0",
18
- "react-dom": "16.14.0",
19
- "typescript": "^5.4.0"
20
- },
21
- "scripts": {
22
- "build": "wix app build",
23
- "release": "wix app release",
24
- "dev": "wix app dev",
25
- "preview": "wix app preview",
26
- "logs": "wix app logs",
27
- "generate": "wix app generate",
28
- "typecheck": "tsc --noEmit"
29
- }
30
- }
@@ -1,4 +0,0 @@
1
- /// <reference types="@wix/cli-app/client" />
2
- /// <reference types="@wix/sdk-types/client" />
3
-
4
- // NOTE: This file should not be edited. This is an auto-generated file.
@@ -1,20 +0,0 @@
1
- export type ChartItem = {
2
- name: string;
3
- value: number;
4
- color: string;
5
- };
6
-
7
- export const DEFAULT_TYPE = 'pie';
8
- export const DEFAULT_ITEMS: ChartItem[] = [
9
- { name: 'Yes', value: 20, color: '#F6B4EB' },
10
- { name: 'No', value: 10, color: '#FF5B37' },
11
- ];
12
-
13
- export type LegendStyle = {
14
- font: string;
15
- textDecoration?: string;
16
- };
17
-
18
- export const DEFAULT_LEGEND_STYLE: LegendStyle = {
19
- font: 'var(--wst-font-style-body-small, inherit)',
20
- };
@@ -1,53 +0,0 @@
1
- import React, { type FC } from 'react';
2
- import {
3
- Bar,
4
- BarChart as RechartsBarChart,
5
- CartesianGrid,
6
- Legend,
7
- ResponsiveContainer,
8
- XAxis,
9
- YAxis,
10
- } from 'recharts';
11
- import type { ChartItem, LegendStyle } from '../common.js';
12
-
13
- type Props = {
14
- items: ChartItem[];
15
- legendStyle?: LegendStyle;
16
- };
17
-
18
- export const BarChart: FC<Props> = ({ items, legendStyle }) => {
19
- const data = [
20
- {
21
- name: 'Slices',
22
- [items[0].name]: items[0].value,
23
- [items[1].name]: items[1].value,
24
- },
25
- ];
26
-
27
- return (
28
- <ResponsiveContainer width="100%" height="100%">
29
- <RechartsBarChart
30
- data={data}
31
- margin={{
32
- top: 10,
33
- right: 10,
34
- left: 10,
35
- bottom: 10,
36
- }}
37
- >
38
- <CartesianGrid strokeDasharray="3" />
39
- <XAxis dataKey="name" />
40
- <YAxis />
41
- <Legend layout="horizontal" verticalAlign="bottom" wrapperStyle={legendStyle} />
42
- {items.map((item, index) => (
43
- <Bar
44
- key={index}
45
- dataKey={item.name}
46
- fill={item.color}
47
- legendType="line"
48
- />
49
- ))}
50
- </RechartsBarChart>
51
- </ResponsiveContainer>
52
- );
53
- };
@@ -1,40 +0,0 @@
1
- import React, { type FC } from 'react';
2
- import {
3
- Cell,
4
- Legend,
5
- Pie,
6
- PieChart as RechartsPieChart,
7
- ResponsiveContainer,
8
- } from 'recharts';
9
- import type { ChartItem, LegendStyle } from '../common.js';
10
-
11
- type Props = {
12
- items: ChartItem[];
13
- legendStyle?: LegendStyle;
14
- };
15
-
16
- export const PieChart: FC<Props> = ({ items, legendStyle }) => {
17
- return (
18
- <ResponsiveContainer width="100%" height="100%">
19
- <RechartsPieChart>
20
- <Legend layout="horizontal" verticalAlign="middle" wrapperStyle={legendStyle}/>
21
- <Pie
22
- data={items}
23
- cx="50%"
24
- cy="50%"
25
- legendType="line"
26
- label={true}
27
- innerRadius="60%"
28
- outerRadius="90%"
29
- paddingAngle={1}
30
- animationDuration={0}
31
- dataKey="value"
32
- >
33
- {items.map((entry, index) => (
34
- <Cell key={index} fill={entry.color} />
35
- ))}
36
- </Pie>
37
- </RechartsPieChart>
38
- </ResponsiveContainer>
39
- );
40
- };
@@ -1,20 +0,0 @@
1
- {
2
- "$schema": "https://dev.wix.com/wix-cli/schemas/custom-element.json",
3
- "id": "9f661fe2-899c-45a3-9c30-03d2e3567691",
4
- "name": "Chart Widget",
5
- "width": {
6
- "defaultWidth": 400,
7
- "allowStretch": true
8
- },
9
- "height": {
10
- "defaultHeight": 400
11
- },
12
- "installation": {
13
- "autoAddToSite": true,
14
- "essential": false
15
- },
16
- "presets": [{
17
- "id": "52435da1-87d8-4fbe-aaa0-71723288b16e",
18
- "thumbnailUrl": "../../../../../assets/chart-widget/thumbnail.png"
19
- }]
20
- }
@@ -1,53 +0,0 @@
1
- import React, { type FC, useMemo } from 'react';
2
- import ReactDOM from 'react-dom';
3
- import reactToWebComponent from 'react-to-webcomponent';
4
- import {
5
- DEFAULT_TYPE,
6
- DEFAULT_ITEMS,
7
- type ChartItem,
8
- DEFAULT_LEGEND_STYLE,
9
- type LegendStyle,
10
- } from './common.js';
11
- import { BarChart } from './element/bar-chart.js';
12
- import { PieChart } from './element/pie-chart.js';
13
-
14
- type Props = {
15
- type: 'pie' | 'bar';
16
- items: ChartItem[];
17
- legendStyle?: LegendStyle;
18
- };
19
-
20
- const CustomElement: FC<Props> = ({
21
- type = DEFAULT_TYPE,
22
- items = DEFAULT_ITEMS,
23
- legendStyle = DEFAULT_LEGEND_STYLE,
24
- }) => {
25
- const Chart = useMemo(() => {
26
- const charts = {
27
- pie: PieChart,
28
- bar: BarChart,
29
- };
30
- return charts[type];
31
- }, [type]);
32
-
33
- return <Chart items={items} legendStyle={legendStyle} />;
34
- };
35
-
36
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
- const WrappedCustomElement = (props: any) => <CustomElement {...props} />;
38
-
39
- const customElement = reactToWebComponent(
40
- WrappedCustomElement,
41
- React,
42
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
- ReactDOM as any,
44
- {
45
- props: {
46
- type: 'string',
47
- items: 'json',
48
- legendStyle: 'json',
49
- },
50
- }
51
- );
52
-
53
- export default customElement;
@@ -1,47 +0,0 @@
1
- import React, { type FC } from 'react';
2
- import { Box, FieldSet, SidePanel, Thumbnail } from '@wix/design-system';
3
- import { PieChart, BarChartSplit } from '@wix/wix-ui-icons-common';
4
-
5
- interface Props {
6
- type: string;
7
- onChange: (type: string) => void;
8
- }
9
-
10
- const options = [
11
- { value: 'pie', icon: PieChart },
12
- { value: 'bar', icon: BarChartSplit },
13
- ];
14
-
15
- export const ChartType: FC<Props> = ({ type, onChange }) => {
16
- return (
17
- <SidePanel.Field>
18
- <FieldSet
19
- legend="Chart type"
20
- direction="horizontal"
21
- gap="medium"
22
- columns="min-content"
23
- >
24
- {options.map(({ value, icon: Icon }) => (
25
- <Thumbnail
26
- key={value}
27
- selected={type === value}
28
- onClick={() => onChange(value)}
29
- hideSelectedIcon
30
- noPadding
31
- width="38px"
32
- height="38px"
33
- >
34
- <Box
35
- height="100%"
36
- width="100%"
37
- align="center"
38
- verticalAlign="middle"
39
- >
40
- <Icon />
41
- </Box>
42
- </Thumbnail>
43
- ))}
44
- </FieldSet>
45
- </SidePanel.Field>
46
- );
47
- };
@@ -1,72 +0,0 @@
1
- import React, { type FC } from 'react';
2
- import {
3
- FormField,
4
- FillPreview,
5
- Input,
6
- NumberInput,
7
- SidePanel,
8
- Box,
9
- } from '@wix/design-system';
10
- import { inputs } from '@wix/editor';
11
- import type { ChartItem } from '../common.js';
12
-
13
- interface Props {
14
- title: string;
15
- item: ChartItem;
16
- onChange: (item: ChartItem) => void;
17
- }
18
-
19
- const Slice: FC<Props> = ({ title, item, onChange }) => {
20
- return (
21
- <SidePanel.Section title={title}>
22
- <SidePanel.Field>
23
- <FormField label="Label">
24
- <Input
25
- value={item.name}
26
- type="text"
27
- onChange={(e) => {
28
- const newItem = { ...item, name: e.target.value };
29
- onChange(newItem);
30
- }}
31
- size="small"
32
- />
33
- </FormField>
34
- </SidePanel.Field>
35
- <SidePanel.Field>
36
- <FormField label="Value">
37
- <NumberInput
38
- value={item.value}
39
- min={0}
40
- onChange={(value) => {
41
- const newItem = { ...item, value: value ?? 0 };
42
- onChange(newItem);
43
- }}
44
- size="small"
45
- hideStepper
46
- />
47
- </FormField>
48
- </SidePanel.Field>
49
- <SidePanel.Field>
50
- <FormField label="Color" labelPlacement="left" labelWidth="1fr">
51
- <Box width="30px" height="30px">
52
- <FillPreview
53
- fill={item.color}
54
- onClick={() =>
55
- inputs.selectColor(item.color, {
56
- onChange: (value) => {
57
- if (value) {
58
- const newItem = { ...item, color: value };
59
- onChange(newItem);
60
- }
61
- },
62
- })
63
- }
64
- />
65
- </Box>
66
- </FormField>
67
- </SidePanel.Field>
68
- </SidePanel.Section>
69
- );
70
- };
71
-
72
- export default Slice;
@@ -1,90 +0,0 @@
1
- import React, { type FC, useState, useEffect } from 'react';
2
- import { inputs, widget } from '@wix/editor';
3
- import {
4
- Box,
5
- FormField,
6
- SidePanel,
7
- TextButton,
8
- WixDesignSystemProvider
9
- } from '@wix/design-system';
10
- import '@wix/design-system/styles.global.css';
11
- import {
12
- DEFAULT_TYPE,
13
- DEFAULT_ITEMS,
14
- type ChartItem,
15
- DEFAULT_LEGEND_STYLE,
16
- type LegendStyle
17
- } from './common.js';
18
- import Slice from './panel/slice.js';
19
- import { ChartType } from './panel/chart-type.js';
20
-
21
- const Panel: FC = () => {
22
- const [loaded, setLoaded] = useState(false);
23
- const [type, setType] = useState<string>('');
24
- const [legendStyle, setLegendStyle] = useState<LegendStyle | undefined>(undefined);
25
- const [items, setItems] = useState<ChartItem[]>([]);
26
-
27
- useEffect(() => {
28
- Promise.all([widget.getProp('type'), widget.getProp('items'), widget.getProp('legend-style')])
29
- .then(([type, items, storedLegendStyle]) => {
30
- setType(type ?? DEFAULT_TYPE);
31
- setItems(JSON.parse(items) ?? DEFAULT_ITEMS);
32
- setLegendStyle(JSON.parse(storedLegendStyle) ?? DEFAULT_LEGEND_STYLE);
33
- setLoaded(true);
34
- });
35
- }, []);
36
- useEffect(() => {
37
- if (legendStyle?.font) {
38
- void widget.setPreloadFonts([legendStyle.font])
39
- }
40
- }, [legendStyle]);
41
-
42
- return (
43
- <WixDesignSystemProvider>
44
- <SidePanel width="300">
45
- {loaded && (
46
- <SidePanel.Content noPadding>
47
- <ChartType
48
- type={type}
49
- onChange={(type) => {
50
- setType(type);
51
- widget.setProp('type', type);
52
- }}
53
- />
54
- <SidePanel.Field>
55
- <FormField label="Legend Style" labelPlacement="left" labelWidth="1fr">
56
- <Box>
57
- <TextButton size="small" onClick={() => {
58
- void inputs.selectFont(legendStyle, {
59
- onChange: (value) => {
60
- if (value) {
61
- setLegendStyle(value);
62
- void widget.setProp('legend-style', JSON.stringify(value));
63
- }
64
- }
65
- });
66
- }}>Select</TextButton>
67
- </Box>
68
- </FormField>
69
- </SidePanel.Field>
70
- {items.map((item, index) => (
71
- <Slice
72
- key={index}
73
- title={`Slice ${index + 1}`}
74
- item={item}
75
- onChange={(item) => {
76
- const newItems = [...items];
77
- newItems[index] = item;
78
- setItems(newItems);
79
- widget.setProp('items', JSON.stringify(newItems));
80
- }}
81
- />
82
- ))}
83
- </SidePanel.Content>
84
- )}
85
- </SidePanel>
86
- </WixDesignSystemProvider>
87
- );
88
- };
89
-
90
- export default Panel;
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "@wix/cli-app/tsconfig.app.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "types": ["react"]
6
- },
7
- "include": ["src"]
8
- }
@@ -1,5 +0,0 @@
1
- {
2
- "$schema": "https://dev.wix.com/wix-cli/schemas/wix-config.json",
3
- "appId": "f957774c-d60b-4225-b02a-c44d8e6effd4",
4
- "projectId": "chart-widget"
5
- }