@wonderflow/react-components 12.5.2 → 12.7.0

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.
@@ -15,7 +15,7 @@ const story = {
15
15
  control: { type: 'radio' },
16
16
  },
17
17
  color: {
18
- options: ['gray', 'cyan', 'green', 'purple', 'yellow', 'red', 'blue'],
18
+ options: ['blue', 'cyan', 'dipsy', 'gray', 'green', 'indigo', 'magenta', 'purple', 'red', 'salmon', 'violet', 'yellow'],
19
19
  control: { type: 'select' },
20
20
  },
21
21
  },
@@ -14,10 +14,9 @@ export const ProductCardKpis = forwardRef(({ rating, feedbackCount, votesCount,
14
14
  iconColor: isGreaterThan(3.99, rating) ? `hsl(${tkns.color.yellow['30']})` : undefined,
15
15
  },
16
16
  {
17
- property: 'sentiment',
18
- value: formatKpiValue(sentiment, { decimal: 2, minRange: -1, maxRange: 1 }),
19
- icon: 'hearts-suit',
20
- iconColor: isGreaterThan(0.5, sentiment) ? 'var(--highlight-red-foreground)' : undefined,
17
+ property: 'nps',
18
+ value: formatKpiValue(nps, { decimal: 0, minRange: -100, maxRange: 100 }),
19
+ icon: 'nps',
21
20
  },
22
21
  {
23
22
  property: 'feedback-count',
@@ -36,14 +35,10 @@ export const ProductCardKpis = forwardRef(({ rating, feedbackCount, votesCount,
36
35
  icon: 'votes-count',
37
36
  },
38
37
  {
39
- property: 'nps',
40
- value: formatKpiValue(nps, { decimal: 0, minRange: -100, maxRange: 100 }),
41
- icon: 'nps',
42
- },
43
- {
44
- property: 'groups',
45
- value: formatKpiValue(groups),
46
- icon: 'grid',
38
+ property: 'sentiment',
39
+ value: formatKpiValue(sentiment, { decimal: 2, minRange: -1, maxRange: 1 }),
40
+ icon: 'hearts-suit',
41
+ iconColor: isGreaterThan(0.5, sentiment) ? 'var(--highlight-red-foreground)' : undefined,
47
42
  },
48
43
  {
49
44
  property: 'tgw',
@@ -55,6 +50,11 @@ export const ProductCardKpis = forwardRef(({ rating, feedbackCount, votesCount,
55
50
  value: formatPriceRangeValues(priceMin, priceMax, { currency, decimals: currencyDecimals }),
56
51
  icon: 'tags',
57
52
  },
53
+ {
54
+ property: 'groups',
55
+ value: formatKpiValue(groups),
56
+ icon: 'grid',
57
+ },
58
58
  {
59
59
  property: 'users',
60
60
  value: formatKpiValue(users, { decimal: 0, minRange: 0, cap: usersCap }),
@@ -3,6 +3,7 @@ import { ProductCard } from './product-card';
3
3
  declare const story: ComponentMeta<typeof ProductCard>;
4
4
  export default story;
5
5
  export declare const Default: ComponentStory<import("./product-card").ProductCardComponent>;
6
+ export declare const withFewKpis: ComponentStory<import("./product-card").ProductCardComponent>;
6
7
  export declare const withOverlayActions: ComponentStory<import("./product-card").ProductCardComponent>;
7
8
  export declare const withMenuActions: ComponentStory<import("./product-card").ProductCardComponent>;
8
9
  export declare const clickable: ComponentStory<import("./product-card").ProductCardComponent>;
@@ -1 +1 @@
1
- {"version":3,"file":"product-card.stories.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA4C7C,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,WAAW,CAwD5C,CAAC;AAEF,eAAe,KAAK,CAAC;AAQrB,eAAO,MAAM,OAAO,+DAAoB,CAAC;AAGzC,eAAO,MAAM,kBAAkB,+DAAoB,CAAC;AAKpD,eAAO,MAAM,eAAe,+DAAoB,CAAC;AAKjD,eAAO,MAAM,SAAS,+DAAoB,CAAC;AAK3C,eAAO,MAAM,oBAAoB,+DAAoB,CAAC;AAKtD,eAAO,MAAM,eAAe,+DAAoB,CAAC;AAKjD,eAAO,MAAM,WAAW,+DAAoB,CAAC"}
1
+ {"version":3,"file":"product-card.stories.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA4C7C,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,WAAW,CAwD5C,CAAC;AAEF,eAAe,KAAK,CAAC;AAQrB,eAAO,MAAM,OAAO,+DAAoB,CAAC;AAGzC,eAAO,MAAM,WAAW,+DAAoB,CAAC;AAkB7C,eAAO,MAAM,kBAAkB,+DAAoB,CAAC;AAKpD,eAAO,MAAM,eAAe,+DAAoB,CAAC;AAKjD,eAAO,MAAM,SAAS,+DAAoB,CAAC;AAK3C,eAAO,MAAM,oBAAoB,+DAAoB,CAAC;AAKtD,eAAO,MAAM,eAAe,+DAAoB,CAAC;AAKjD,eAAO,MAAM,WAAW,+DAAoB,CAAC"}
@@ -20,17 +20,17 @@ const story = {
20
20
  titleRows: 3,
21
21
  subtitle: 'subtitle',
22
22
  rating: 4.3,
23
- sentiment: 0.48,
23
+ nps: 23,
24
24
  feedbackCount: 123,
25
- votesCount: 3456,
26
25
  votesRating: 2.3,
27
- nps: 23,
28
- groups: 4,
26
+ votesCount: 3456,
27
+ sentiment: 0.54,
29
28
  tgw: 0.75,
30
29
  priceMin: 33,
31
30
  priceMax: 45,
32
31
  currency: 'EUR',
33
32
  currencyDecimals: 0,
33
+ groups: 4,
34
34
  users: 789,
35
35
  usersCap: 1000,
36
36
  skus: 2,
@@ -73,6 +73,23 @@ const Template = (args) => {
73
73
  };
74
74
  export const Default = Template.bind({});
75
75
  Default.args = {};
76
+ export const withFewKpis = Template.bind({});
77
+ withFewKpis.args = {
78
+ rating: 4.3,
79
+ nps: undefined,
80
+ feedbackCount: 123,
81
+ votesRating: undefined,
82
+ votesCount: undefined,
83
+ sentiment: 0.54,
84
+ tgw: undefined,
85
+ priceMin: undefined,
86
+ priceMax: undefined,
87
+ groups: undefined,
88
+ users: undefined,
89
+ usersCap: undefined,
90
+ skus: undefined,
91
+ skusCap: undefined,
92
+ };
76
93
  export const withOverlayActions = Template.bind({});
77
94
  withOverlayActions.args = {
78
95
  overlayActions: OverlayButtons,
@@ -19,4 +19,5 @@ export declare const ChangeEvent: ComponentStory<{
19
19
  export declare const ConditionalTab: () => JSX.Element;
20
20
  export declare const DisabledTab: ComponentStory<typeof Tab>;
21
21
  export declare const WithIcons: ComponentStory<typeof Tab>;
22
+ export declare const WithTables: ComponentStory<typeof Tab>;
22
23
  //# sourceMappingURL=tab.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tab.stories.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tab.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIjE,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,GAAG,CAapC,CAAC;AACF,eAAe,KAAK,CAAC;AAarB,eAAO,MAAM,OAAO;;;EAAoB,CAAC;AAEzC,eAAO,MAAM,UAAU;;;EAAoB,CAAC;AAK5C,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,OAAO,GAAG,CAqBtD,CAAC;AAEF,eAAO,MAAM,WAAW;;;EAAoB,CAAC;AAM7C,eAAO,MAAM,cAAc,mBAc1B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,cAAc,CAAC,OAAO,GAAG,CASlD,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,OAAO,GAAG,CAShD,CAAC"}
1
+ {"version":3,"file":"tab.stories.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tab.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKjE,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,GAAG,CAapC,CAAC;AACF,eAAe,KAAK,CAAC;AAarB,eAAO,MAAM,OAAO;;;EAAoB,CAAC;AAEzC,eAAO,MAAM,UAAU;;;EAAoB,CAAC;AAK5C,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,OAAO,GAAG,CAqBtD,CAAC;AAEF,eAAO,MAAM,WAAW;;;EAAoB,CAAC;AAM7C,eAAO,MAAM,cAAc,mBAc1B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,cAAc,CAAC,OAAO,GAAG,CASlD,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,OAAO,GAAG,CAShD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,OAAO,GAAG,CA8EjD,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
- import { Button } from '../..';
2
+ import { useMemo, useState } from 'react';
3
+ import { Button, Table } from '../..';
4
+ import { mockedColumns, mockedData } from '../table/mocked-data';
4
5
  import { Tab } from './tab';
5
6
  const story = {
6
7
  title: 'Navigation/Tab',
@@ -37,3 +38,39 @@ export const ConditionalTab = () => {
37
38
  };
38
39
  export const DisabledTab = args => (_jsxs(Tab, { defaultValue: "1", ...args, children: [_jsx(Tab.Panel, { value: "1", label: "Tab 1", children: "Panel 1" }), _jsx(Tab.Panel, { value: "2", label: "Tab mid long 2", children: "Panel 2" }), _jsx(Tab.Panel, { value: "3", label: "Tab short 3", children: "Panel 3" }), _jsx(Tab.Panel, { disabled: true, value: "4", label: "Tab veryy long 4", children: "Panel 4" }), _jsx(Tab.Panel, { value: "5", label: "Tab 5", children: "Panel 5" }), _jsx(Tab.Panel, { value: "6", label: "Tab 6", children: "Panel 6" })] }));
39
40
  export const WithIcons = args => (_jsxs(Tab, { defaultValue: "1", ...args, children: [_jsx(Tab.Panel, { icon: "star", value: "1", label: "Tab 1", children: "Panel 1" }), _jsx(Tab.Panel, { icon: "eye", value: "2", label: "Tab mid long 2", children: "Panel 2" }), _jsx(Tab.Panel, { icon: "sun-bright", value: "3", label: "Tab short 3", children: "Panel 3" }), _jsx(Tab.Panel, { icon: "moon", disabled: true, value: "4", label: "Tab veryy long 4", children: "Panel 4" }), _jsx(Tab.Panel, { icon: "magnifying-glass", value: "5", label: "Tab 5", children: "Panel 5" }), _jsx(Tab.Panel, { icon: "check", value: "6", label: "Tab 6", children: "Panel 6" })] }));
41
+ export const WithTables = () => {
42
+ const [activeTab, setActiveTab] = useState('Table1');
43
+ const [pagination, setPagination] = useState({
44
+ Table1: {
45
+ pageSize: 5,
46
+ pageIndex: 0,
47
+ },
48
+ Table2: {
49
+ pageSize: 10,
50
+ pageIndex: 0,
51
+ },
52
+ });
53
+ const handleTab = (tab) => {
54
+ setActiveTab(tab);
55
+ };
56
+ const handlePagination = ({ pageIndex, pageSize }) => {
57
+ if (pageIndex !== pagination[activeTab].pageIndex
58
+ || pageSize !== pagination[activeTab].pageSize) {
59
+ const newPagination = { ...pagination, [activeTab]: { pageIndex, pageSize } };
60
+ setPagination(newPagination);
61
+ }
62
+ };
63
+ const pageData1 = useMemo(() => {
64
+ const { pageIndex, pageSize } = pagination.Table1;
65
+ const newIndexStart = pageIndex * pageSize;
66
+ const newIndexEnd = (pageIndex * pageSize) + pageSize;
67
+ return mockedData.slice(newIndexStart, newIndexEnd);
68
+ }, [pagination]);
69
+ const pageData2 = useMemo(() => {
70
+ const { pageIndex, pageSize } = pagination.Table2;
71
+ const newIndexStart = pageIndex * pageSize;
72
+ const newIndexEnd = (pageIndex * pageSize) + pageSize;
73
+ return mockedData.slice(newIndexStart, newIndexEnd);
74
+ }, [pagination]);
75
+ return (_jsxs(Tab, { defaultValue: activeTab, onValueChange: handleTab, children: [_jsx(Tab.Panel, { value: "Table1", label: "Table 1", children: _jsx(Table, { background: "seashell", stripes: true, showSeparators: true, columns: mockedColumns, data: pageData1, showPagination: true, itemsPerPage: pagination.Table1.pageSize, initialPageIndex: pagination.Table1.pageIndex, onPaginationChange: handlePagination, totalRows: mockedData.length }) }), _jsx(Tab.Panel, { value: "Table2", label: "Table 2", children: _jsx(Table, { background: "honeydew", stripes: true, showSeparators: true, columns: mockedColumns, data: pageData2, showPagination: true, itemsPerPage: pagination.Table2.pageSize, initialPageIndex: pagination.Table2.pageIndex, onPaginationChange: handlePagination, totalRows: mockedData.length }) })] }));
76
+ };
@@ -0,0 +1,233 @@
1
+ /// <reference types="react" />
2
+ import { CustomColumnsType, OptionalDataTypes } from './types';
3
+ export declare const mockedColumns: CustomColumnsType<Record<string, unknown>>;
4
+ export declare const mockedData: Array<Record<string, unknown> & OptionalDataTypes<Record<string, unknown>>>;
5
+ export declare const mockedDataWithIds: ({
6
+ id: string;
7
+ subRows: {
8
+ id: string;
9
+ firstName: string;
10
+ lastName: string;
11
+ address: string;
12
+ uid: number;
13
+ info: number;
14
+ subRows: ({
15
+ id: string;
16
+ firstName: string;
17
+ lastName: string;
18
+ address: string;
19
+ uid: number;
20
+ info: number;
21
+ subRows: ({
22
+ id: string;
23
+ firstName: string;
24
+ lastName: string;
25
+ address: string;
26
+ uid: number;
27
+ info: number;
28
+ subRows: ({
29
+ id: string;
30
+ firstName: string;
31
+ lastName: string;
32
+ address: string;
33
+ uid: number;
34
+ info: number;
35
+ subRows: ({
36
+ id: string;
37
+ firstName: string;
38
+ lastName: string;
39
+ address: string;
40
+ uid: number;
41
+ info: number;
42
+ subRows: ({
43
+ id: string;
44
+ firstName: string;
45
+ lastName: string;
46
+ address: string;
47
+ uid: number;
48
+ info: number;
49
+ subRows: ({
50
+ id: string;
51
+ firstName: string;
52
+ lastName: string;
53
+ address: string;
54
+ uid: number;
55
+ info: number;
56
+ subRows: ({
57
+ id: string;
58
+ firstName: string;
59
+ lastName: string;
60
+ address: string;
61
+ uid: number;
62
+ info: number;
63
+ subRows: {
64
+ id: string;
65
+ firstName: string;
66
+ lastName: string;
67
+ address: string;
68
+ uid: number;
69
+ info: number;
70
+ }[];
71
+ } | {
72
+ id: string;
73
+ firstName: string;
74
+ lastName: string;
75
+ address: string;
76
+ uid: number;
77
+ info: number;
78
+ subRows?: undefined;
79
+ })[];
80
+ } | {
81
+ id: string;
82
+ firstName: string;
83
+ lastName: string;
84
+ address: string;
85
+ uid: number;
86
+ info: number;
87
+ subRows?: undefined;
88
+ })[];
89
+ } | {
90
+ id: string;
91
+ firstName: string;
92
+ lastName: string;
93
+ address: string;
94
+ uid: number;
95
+ info: number;
96
+ subRows?: undefined;
97
+ })[];
98
+ } | {
99
+ id: string;
100
+ firstName: string;
101
+ lastName: string;
102
+ address: string;
103
+ uid: number;
104
+ info: number;
105
+ subRows?: undefined;
106
+ })[];
107
+ } | {
108
+ id: string;
109
+ firstName: string;
110
+ lastName: string;
111
+ address: string;
112
+ uid: number;
113
+ info: number;
114
+ subRows?: undefined;
115
+ })[];
116
+ } | {
117
+ id: string;
118
+ firstName: string;
119
+ lastName: string;
120
+ address: string;
121
+ uid: number;
122
+ info: number;
123
+ subRows?: undefined;
124
+ })[];
125
+ } | {
126
+ id: string;
127
+ firstName: string;
128
+ lastName: string;
129
+ address: string;
130
+ uid: number;
131
+ info: number;
132
+ subRows?: undefined;
133
+ })[];
134
+ }[];
135
+ firstName: string;
136
+ lastName: string;
137
+ address: string;
138
+ uid: number;
139
+ info: number;
140
+ canBeDeleted?: undefined;
141
+ } | {
142
+ id: string;
143
+ firstName: string;
144
+ lastName: string;
145
+ address: string;
146
+ uid: string;
147
+ canBeDeleted: boolean;
148
+ info: number;
149
+ subRows?: undefined;
150
+ } | {
151
+ id: string;
152
+ firstName: string;
153
+ lastName: string;
154
+ address: string;
155
+ uid: number;
156
+ info: JSX.Element;
157
+ subRows: ({
158
+ id: string;
159
+ firstName: string;
160
+ lastName: string;
161
+ address: string;
162
+ uid: number;
163
+ info: number;
164
+ subRows?: undefined;
165
+ } | {
166
+ id: string;
167
+ firstName: string;
168
+ lastName: string;
169
+ address: string;
170
+ uid: number;
171
+ info: number;
172
+ subRows: ({
173
+ id: string;
174
+ firstName: string;
175
+ lastName: string;
176
+ address: string;
177
+ uid: number;
178
+ info: number;
179
+ subRows: {
180
+ id: string;
181
+ firstName: string;
182
+ lastName: string;
183
+ address: string;
184
+ uid: number;
185
+ info: number;
186
+ }[];
187
+ } | {
188
+ id: string;
189
+ firstName: string;
190
+ lastName: string;
191
+ address: string;
192
+ uid: number;
193
+ info: number;
194
+ subRows?: undefined;
195
+ })[];
196
+ })[];
197
+ canBeDeleted?: undefined;
198
+ } | {
199
+ id: string;
200
+ firstName: string;
201
+ lastName: string;
202
+ address: string;
203
+ uid: string;
204
+ info: number;
205
+ canBeDeleted?: undefined;
206
+ subRows?: undefined;
207
+ } | {
208
+ id: string;
209
+ firstName: string;
210
+ lastName: string;
211
+ address: string;
212
+ uid: number;
213
+ info: number;
214
+ subRows: {
215
+ id: string;
216
+ firstName: string;
217
+ lastName: string;
218
+ address: string;
219
+ uid: number;
220
+ info: number;
221
+ }[];
222
+ canBeDeleted?: undefined;
223
+ } | {
224
+ id: string;
225
+ firstName: string;
226
+ lastName: string;
227
+ address: string;
228
+ uid: number;
229
+ info: number;
230
+ canBeDeleted?: undefined;
231
+ subRows?: undefined;
232
+ })[];
233
+ //# sourceMappingURL=mocked-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocked-data.d.ts","sourceRoot":"","sources":["../../../src/components/table/mocked-data.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAU/D,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA+BpE,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA6ZlG,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAod7B,CAAC"}