@blocklet/launcher-workflow 2.3.80 → 2.3.82

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.
@@ -1,443 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import styled from '@emotion/styled';
4
- import { prettyDuration } from '@blocklet/launcher-util/es/util';
5
- import Typography from '@mui/material/Typography';
6
- import MenuItem from '@mui/material/MenuItem';
7
- import FormControl from '@mui/material/FormControl';
8
- import Select from '@mui/material/Select';
9
- import useMobile from '@blocklet/launcher-ux/lib/use-mobile';
10
- import noop from 'lodash.noop';
11
- import { Tooltip } from '@mui/material';
12
- var CheckIcon = function CheckIcon(props) {
13
- return /*#__PURE__*/_jsxs("svg", {
14
- ...props,
15
- children: [/*#__PURE__*/_jsx("path", {
16
- d: "M10 20c5.523 0 10-4.477 10-10S15.523 0 10 0 0 4.477 0 10s4.477 10 10 10Z",
17
- fill: "#1DC1C7"
18
- }), /*#__PURE__*/_jsx("path", {
19
- d: "m5.474 10.646 2.586 2.586 6.465-6.465",
20
- fill: "#1DC1C7"
21
- }), /*#__PURE__*/_jsx("path", {
22
- fillRule: "evenodd",
23
- clipRule: "evenodd",
24
- d: "M15.233 6.06a1 1 0 0 1 0 1.415L8.768 13.94a1 1 0 0 1-1.415 0l-2.586-2.586a1 1 0 1 1 1.415-1.415l1.878 1.88 5.758-5.759a1 1 0 0 1 1.415 0Z",
25
- fill: "#fff"
26
- })]
27
- });
28
- };
29
- CheckIcon.defaultProps = {
30
- width: "20",
31
- height: "20",
32
- fill: "none",
33
- xmlns: "http://www.w3.org/2000/svg"
34
- };
35
- var CheckReverseIcon = function CheckReverseIcon(props) {
36
- return /*#__PURE__*/_jsxs("svg", {
37
- ...props,
38
- children: [/*#__PURE__*/_jsx("path", {
39
- d: "M10.75 20c5.523 0 10-4.477 10-10s-4.477-10-10-10-10 4.477-10 10 4.477 10 10 10Z",
40
- fill: "#fff"
41
- }), /*#__PURE__*/_jsx("path", {
42
- d: "m6.224 10.646 2.586 2.586 6.465-6.465",
43
- fill: "#fff"
44
- }), /*#__PURE__*/_jsx("path", {
45
- d: "m6.224 10.646 2.586 2.586 6.465-6.465",
46
- stroke: "#1DC1C7",
47
- strokeWidth: "2",
48
- strokeLinecap: "round",
49
- strokeLinejoin: "round"
50
- })]
51
- });
52
- };
53
- CheckReverseIcon.defaultProps = {
54
- width: "21",
55
- height: "20",
56
- fill: "none",
57
- xmlns: "http://www.w3.org/2000/svg"
58
- };
59
- var UnCheckIcon = function UnCheckIcon(props) {
60
- return /*#__PURE__*/_jsxs("svg", {
61
- ...props,
62
- children: [/*#__PURE__*/_jsx("path", {
63
- d: "M10.25 20c5.523 0 10-4.477 10-10s-4.477-10-10-10-10 4.477-10 10 4.477 10 10 10Z",
64
- fill: "#1DC1C7"
65
- }), /*#__PURE__*/_jsx("path", {
66
- fillRule: "evenodd",
67
- clipRule: "evenodd",
68
- d: "M14.6 5.029a.872.872 0 0 0-.846.233L10.25 8.769 6.746 5.262A.872.872 0 1 0 5.51 6.497l3.505 3.508-3.506 3.509-.002.002a.874.874 0 0 0 1.235 1.235l3.507-3.51 3.505 3.508.002.002a.872.872 0 0 0 1.235-1.235l-3.508-3.511 3.504-3.508a.874.874 0 0 0-.388-1.468Z",
69
- fill: "#fff"
70
- })]
71
- });
72
- };
73
- UnCheckIcon.defaultProps = {
74
- width: "21",
75
- height: "20",
76
- fill: "none",
77
- xmlns: "http://www.w3.org/2000/svg"
78
- };
79
- var UnCheckReverseIcon = function UnCheckReverseIcon(props) {
80
- return /*#__PURE__*/_jsxs("svg", {
81
- ...props,
82
- children: [/*#__PURE__*/_jsx("path", {
83
- d: "M10.75 20c5.523 0 10-4.477 10-10s-4.477-10-10-10-10 4.477-10 10 4.477 10 10 10Z",
84
- fill: "#fff"
85
- }), /*#__PURE__*/_jsx("path", {
86
- fillRule: "evenodd",
87
- clipRule: "evenodd",
88
- d: "M15.1 5.029a.872.872 0 0 0-.846.233L10.75 8.769 7.246 5.262A.872.872 0 1 0 6.01 6.497l3.505 3.508-3.506 3.509-.002.002a.874.874 0 0 0 1.235 1.235l3.507-3.51 3.505 3.508.002.002a.872.872 0 0 0 1.235-1.235l-3.508-3.511 3.504-3.508a.874.874 0 0 0-.388-1.468Z",
89
- fill: "#1DC1C7"
90
- })]
91
- });
92
- };
93
- UnCheckReverseIcon.defaultProps = {
94
- width: "21",
95
- height: "20",
96
- fill: "none",
97
- xmlns: "http://www.w3.org/2000/svg"
98
- };
99
- import { getPrice } from '../util';
100
- import { useLocaleContext } from '../contexts/locale';
101
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
102
- function Feature({
103
- feature,
104
- locale,
105
- checked,
106
- isMobile
107
- }) {
108
- let valueEle = '';
109
- if (feature.type === 'boolean') {
110
- if (feature.value === true) {
111
- valueEle = checked ? /*#__PURE__*/_jsx(CheckReverseIcon, {}) : /*#__PURE__*/_jsx(CheckIcon, {});
112
- } else {
113
- valueEle = checked ? /*#__PURE__*/_jsx(UnCheckReverseIcon, {}) : /*#__PURE__*/_jsx(UnCheckIcon, {});
114
- }
115
- }
116
- if (feature.type === 'text') {
117
- valueEle = feature.value[locale];
118
- }
119
- if (isMobile) {
120
- return /*#__PURE__*/_jsxs(_Fragment, {
121
- children: [feature.type === 'boolean' && /*#__PURE__*/_jsxs(MobileBooleanItem, {
122
- children: [/*#__PURE__*/_jsx(Typography, {
123
- component: "span",
124
- style: {
125
- display: 'flex'
126
- },
127
- children: valueEle
128
- }), /*#__PURE__*/_jsx(Typography, {
129
- component: "span",
130
- style: {
131
- marginLeft: '8px'
132
- },
133
- children: feature.name[locale]
134
- })]
135
- }), feature.type === 'text' && /*#__PURE__*/_jsx(TextItem, {
136
- children: `${feature.name[locale]}: ${valueEle}`
137
- })]
138
- });
139
- }
140
- return feature.type === 'text' ? /*#__PURE__*/_jsx(TextItem, {
141
- children: valueEle
142
- }) : valueEle;
143
- }
144
- const MobileBooleanItem = styled.div`
145
- display: flex;
146
- justify-content: center;
147
- `;
148
- const TextItem = styled.div`
149
- display: -webkit-box;
150
- white-space: normal;
151
- -webkit-line-clamp: 2;
152
- -webkit-box-orient: vertical;
153
- overflow: hidden;
154
- `;
155
- Feature.propTypes = {
156
- feature: PropTypes.object.isRequired,
157
- locale: PropTypes.string.isRequired,
158
- checked: PropTypes.bool,
159
- isMobile: PropTypes.bool
160
- };
161
- Feature.defaultProps = {
162
- checked: false,
163
- isMobile: false
164
- };
165
- function Plan({
166
- plan,
167
- productFeatures,
168
- toc,
169
- checked,
170
- recommend,
171
- paymentMethods,
172
- paymentMethod,
173
- onChangeMethod,
174
- ...rest
175
- }) {
176
- const {
177
- locale,
178
- t
179
- } = useLocaleContext();
180
- const {
181
- isMobile
182
- } = useMobile();
183
- if (toc) {
184
- return /*#__PURE__*/_jsxs(Container, {
185
- className: "toc",
186
- available: true,
187
- children: [/*#__PURE__*/_jsx("div", {
188
- className: "basic-toc",
189
- children: /*#__PURE__*/_jsx(Typography, {
190
- className: "payment-methods",
191
- component: "div",
192
- children: /*#__PURE__*/_jsx(FormControl, {
193
- style: {
194
- minWidth: 180
195
- },
196
- size: "small",
197
- children: /*#__PURE__*/_jsx(Select, {
198
- id: "payment-method",
199
- value: paymentMethod,
200
- onChange: e => onChangeMethod(e.target.value),
201
- children: paymentMethods.map(({
202
- _id,
203
- currency
204
- }) => /*#__PURE__*/_jsx(MenuItem, {
205
- value: _id,
206
- children: t('common.payWith', {
207
- currency: currency.displayName[locale] || currency.displayName.en
208
- })
209
- }, _id))
210
- })
211
- })
212
- })
213
- }), /*#__PURE__*/_jsx("div", {
214
- className: "features toc__title",
215
- children: (productFeatures || []).map(({
216
- _id,
217
- name
218
- }) => {
219
- return /*#__PURE__*/_jsx("div", {
220
- className: "feature",
221
- children: name[locale]
222
- }, _id);
223
- })
224
- })]
225
- });
226
- }
227
- let features = [];
228
- try {
229
- // TODO: Pricing Table: 临时做法
230
- if (Array.isArray(plan.features) && plan.features.length > 0) {
231
- features = JSON.parse(plan.features[0].en);
232
- }
233
- } catch (error) {
234
- console.error('parse features failed:', error);
235
- }
236
- const providerName = paymentMethods.find(x => x._id === paymentMethod)?.provider.name;
237
- const content = /*#__PURE__*/_jsxs(Container, {
238
- checked: checked,
239
- className: `card-container ${checked ? 'checked' : ''}`,
240
- available: !!plan.available,
241
- ...rest,
242
- children: [recommend && /*#__PURE__*/_jsx("div", {
243
- className: "recommend-tag",
244
- children: t('common.popular')
245
- }), /*#__PURE__*/_jsxs("div", {
246
- className: "basic",
247
- children: [/*#__PURE__*/_jsxs("div", {
248
- className: "header",
249
- children: [/*#__PURE__*/_jsx("div", {
250
- className: "header__title",
251
- children: t('common.space')
252
- }), /*#__PURE__*/_jsx("div", {
253
- className: "header__name",
254
- children: plan?.name[locale]
255
- })]
256
- }), /*#__PURE__*/_jsxs("div", {
257
- className: "price-info",
258
- children: [/*#__PURE__*/_jsx("div", {
259
- className: "price",
260
- children: getPrice(plan.prices, providerName)
261
- }), /*#__PURE__*/_jsx("div", {
262
- className: "period",
263
- children: prettyDuration(plan.duration, locale)
264
- })]
265
- })]
266
- }), /*#__PURE__*/_jsx("div", {
267
- className: "features",
268
- children: features.map(feature => {
269
- return /*#__PURE__*/_jsx("div", {
270
- className: "feature",
271
- children: /*#__PURE__*/_jsx(Feature, {
272
- feature: feature,
273
- locale: locale,
274
- checked: checked,
275
- isMobile: isMobile
276
- })
277
- }, feature._id);
278
- })
279
- })]
280
- });
281
- if (plan.available) {
282
- return content;
283
- }
284
- return /*#__PURE__*/_jsx(Tooltip, {
285
- title: plan.reason,
286
- style: {
287
- cursor: 'not-allowed'
288
- },
289
- children: content
290
- });
291
- }
292
- const Container = styled.div`
293
- display: flex;
294
- position: relative;
295
- align-items: center;
296
- flex-direction: column;
297
- border-radius: 12px;
298
- overflow: hidden;
299
- min-height: 400px;
300
- white-space: nowrap;
301
- padding: 16px;
302
- filter: grayscale(${props => props.available ? 0 : 1});
303
- opacity: ${props => props.available ? 1 : 0.4};
304
-
305
- .recommend-tag {
306
- display: block;
307
- position: absolute;
308
- top: 4px;
309
- right: 32px;
310
- color: #fff;
311
- padding: 4px 100px;
312
- position: absolute;
313
- transform: translate(50%, 50%) rotate(45deg);
314
- white-space: nowrap;
315
- background-color: #fe9344;
316
- transform-origin: center;
317
- }
318
-
319
- .toc__title {
320
- font-weight: bolder;
321
- align-items: flex-start;
322
- }
323
-
324
- &:not(.toc) {
325
- width: 280px;
326
- color: #000;
327
- background-color: #f0fdff;
328
- cursor: pointer;
329
- }
330
-
331
- &:not(.toc, .checked):hover {
332
- color: #000;
333
- background-color: #ddf6f8;
334
- cursor: pointer;
335
- }
336
-
337
- &.checked {
338
- color: #fff;
339
- background-color: ${props => props.theme.palette.primary.main};
340
- cursor: pointer;
341
- }
342
-
343
- .basic-toc {
344
- width: 100%;
345
- height: 8em;
346
- display: flex;
347
- flex-direction: column;
348
- justify-content: center;
349
- align-items: flex-start;
350
-
351
- .payment-methods {
352
- padding-top: 3em;
353
- font-size: 1.1em;
354
- font-weight: bolder;
355
-
356
- select {
357
- margin-left: 1em;
358
- }
359
- }
360
- }
361
-
362
- .basic {
363
- width: 100%;
364
- height: 8em;
365
-
366
- .header {
367
- text-align: center;
368
- .header__title {
369
- color: ${props => props.checked ? '#ffffff' : '#9397a1'};
370
- }
371
-
372
- .header__name {
373
- font-weight: bolder;
374
- }
375
- }
376
-
377
- .price-info {
378
- display: flex;
379
- flex-direction: column;
380
- justify-content: center;
381
- align-items: center;
382
- height: 6.5em;
383
-
384
- .price {
385
- font-size: 1.5em;
386
- font-weight: bolder;
387
- }
388
-
389
- .period {
390
- color: ${props => props.checked ? '#ffffff' : '#9397a1'};
391
- }
392
- }
393
- }
394
-
395
- .features {
396
- display: flex;
397
- flex-direction: column;
398
- width: 100%;
399
- margin-top: auto;
400
-
401
- .feature {
402
- display: flex;
403
- align-items: center;
404
- justify-content: center;
405
- height: 48px;
406
- text-align: center;
407
-
408
- // 移动端不减小
409
- @media (max-height: 960px) and (min-width: 640px) {
410
- height: 36px;
411
- font-size: 0.9rem;
412
- }
413
-
414
- @media (max-width: 900px) {
415
- justify-content: flex-start;
416
- }
417
-
418
- &:not(:last-child) {
419
- border-bottom: 1px solid;
420
- border-bottom-color: ${props => props.checked || props.hovered ? 'rgba(255, 255, 255, 0.2)' : '#f6f6f6'};
421
- }
422
- }
423
- }
424
- `;
425
- Plan.propTypes = {
426
- plan: PropTypes.object.isRequired,
427
- paymentMethod: PropTypes.string.isRequired,
428
- paymentMethods: PropTypes.array,
429
- onChangeMethod: PropTypes.func,
430
- productFeatures: PropTypes.array,
431
- checked: PropTypes.bool,
432
- recommend: PropTypes.bool,
433
- toc: PropTypes.bool
434
- };
435
- Plan.defaultProps = {
436
- paymentMethods: [],
437
- productFeatures: [],
438
- onChangeMethod: noop,
439
- checked: false,
440
- recommend: false,
441
- toc: false
442
- };
443
- export default Plan;