@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,322 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _styled = _interopRequireDefault(require("@emotion/styled"));
10
- var _util = require("@blocklet/launcher-util/es/util");
11
- var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
12
- var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
13
- var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
14
- var _Select = _interopRequireDefault(require("@mui/material/Select"));
15
- var _useMobile = _interopRequireDefault(require("@blocklet/launcher-ux/lib/use-mobile"));
16
- var _lodash = _interopRequireDefault(require("lodash.noop"));
17
- var _material = require("@mui/material");
18
- var _util2 = require("../util");
19
- var _locale = require("../contexts/locale");
20
- var _jsxRuntime = require("react/jsx-runtime");
21
- const _excluded = ["plan", "productFeatures", "toc", "checked", "recommend", "paymentMethods", "paymentMethod", "onChangeMethod"];
22
- var _templateObject, _templateObject2, _templateObject3;
23
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
26
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
27
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
28
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
29
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
30
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
31
- function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
32
- var CheckIcon = function CheckIcon(props) {
33
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", _objectSpread(_objectSpread({}, props), {}, {
34
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
35
- d: "M10 20c5.523 0 10-4.477 10-10S15.523 0 10 0 0 4.477 0 10s4.477 10 10 10Z",
36
- fill: "#1DC1C7"
37
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
38
- d: "m5.474 10.646 2.586 2.586 6.465-6.465",
39
- fill: "#1DC1C7"
40
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
41
- fillRule: "evenodd",
42
- clipRule: "evenodd",
43
- 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",
44
- fill: "#fff"
45
- })]
46
- }));
47
- };
48
- CheckIcon.defaultProps = {
49
- width: "20",
50
- height: "20",
51
- fill: "none",
52
- xmlns: "http://www.w3.org/2000/svg"
53
- };
54
- var CheckReverseIcon = function CheckReverseIcon(props) {
55
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", _objectSpread(_objectSpread({}, props), {}, {
56
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
57
- 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",
58
- fill: "#fff"
59
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
60
- d: "m6.224 10.646 2.586 2.586 6.465-6.465",
61
- fill: "#fff"
62
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
63
- d: "m6.224 10.646 2.586 2.586 6.465-6.465",
64
- stroke: "#1DC1C7",
65
- strokeWidth: "2",
66
- strokeLinecap: "round",
67
- strokeLinejoin: "round"
68
- })]
69
- }));
70
- };
71
- CheckReverseIcon.defaultProps = {
72
- width: "21",
73
- height: "20",
74
- fill: "none",
75
- xmlns: "http://www.w3.org/2000/svg"
76
- };
77
- var UnCheckIcon = function UnCheckIcon(props) {
78
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", _objectSpread(_objectSpread({}, props), {}, {
79
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
80
- 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",
81
- fill: "#1DC1C7"
82
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
83
- fillRule: "evenodd",
84
- clipRule: "evenodd",
85
- 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",
86
- fill: "#fff"
87
- })]
88
- }));
89
- };
90
- UnCheckIcon.defaultProps = {
91
- width: "21",
92
- height: "20",
93
- fill: "none",
94
- xmlns: "http://www.w3.org/2000/svg"
95
- };
96
- var UnCheckReverseIcon = function UnCheckReverseIcon(props) {
97
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", _objectSpread(_objectSpread({}, props), {}, {
98
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
99
- 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",
100
- fill: "#fff"
101
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
102
- fillRule: "evenodd",
103
- clipRule: "evenodd",
104
- 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",
105
- fill: "#1DC1C7"
106
- })]
107
- }));
108
- };
109
- UnCheckReverseIcon.defaultProps = {
110
- width: "21",
111
- height: "20",
112
- fill: "none",
113
- xmlns: "http://www.w3.org/2000/svg"
114
- };
115
- function Feature(_ref) {
116
- let {
117
- feature,
118
- locale,
119
- checked,
120
- isMobile
121
- } = _ref;
122
- let valueEle = '';
123
- if (feature.type === 'boolean') {
124
- if (feature.value === true) {
125
- valueEle = checked ? /*#__PURE__*/(0, _jsxRuntime.jsx)(CheckReverseIcon, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(CheckIcon, {});
126
- } else {
127
- valueEle = checked ? /*#__PURE__*/(0, _jsxRuntime.jsx)(UnCheckReverseIcon, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(UnCheckIcon, {});
128
- }
129
- }
130
- if (feature.type === 'text') {
131
- valueEle = feature.value[locale];
132
- }
133
- if (isMobile) {
134
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
135
- children: [feature.type === 'boolean' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(MobileBooleanItem, {
136
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
137
- component: "span",
138
- style: {
139
- display: 'flex'
140
- },
141
- children: valueEle
142
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
143
- component: "span",
144
- style: {
145
- marginLeft: '8px'
146
- },
147
- children: feature.name[locale]
148
- })]
149
- }), feature.type === 'text' && /*#__PURE__*/(0, _jsxRuntime.jsx)(TextItem, {
150
- children: "".concat(feature.name[locale], ": ").concat(valueEle)
151
- })]
152
- });
153
- }
154
- return feature.type === 'text' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(TextItem, {
155
- children: valueEle
156
- }) : valueEle;
157
- }
158
- const MobileBooleanItem = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n justify-content: center;\n"])));
159
- const TextItem = _styled.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: -webkit-box;\n white-space: normal;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n"])));
160
- Feature.propTypes = {
161
- feature: _propTypes.default.object.isRequired,
162
- locale: _propTypes.default.string.isRequired,
163
- checked: _propTypes.default.bool,
164
- isMobile: _propTypes.default.bool
165
- };
166
- Feature.defaultProps = {
167
- checked: false,
168
- isMobile: false
169
- };
170
- function Plan(_ref2) {
171
- var _paymentMethods$find;
172
- let {
173
- plan,
174
- productFeatures,
175
- toc,
176
- checked,
177
- recommend,
178
- paymentMethods,
179
- paymentMethod,
180
- onChangeMethod
181
- } = _ref2,
182
- rest = _objectWithoutProperties(_ref2, _excluded);
183
- const {
184
- locale,
185
- t
186
- } = (0, _locale.useLocaleContext)();
187
- const {
188
- isMobile
189
- } = (0, _useMobile.default)();
190
- if (toc) {
191
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
192
- className: "toc",
193
- available: true,
194
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
195
- className: "basic-toc",
196
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
197
- className: "payment-methods",
198
- component: "div",
199
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControl.default, {
200
- style: {
201
- minWidth: 180
202
- },
203
- size: "small",
204
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
205
- id: "payment-method",
206
- value: paymentMethod,
207
- onChange: e => onChangeMethod(e.target.value),
208
- children: paymentMethods.map(_ref3 => {
209
- let {
210
- _id,
211
- currency
212
- } = _ref3;
213
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuItem.default, {
214
- value: _id,
215
- children: t('common.payWith', {
216
- currency: currency.displayName[locale] || currency.displayName.en
217
- })
218
- }, _id);
219
- })
220
- })
221
- })
222
- })
223
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
224
- className: "features toc__title",
225
- children: (productFeatures || []).map(_ref4 => {
226
- let {
227
- _id,
228
- name
229
- } = _ref4;
230
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
231
- className: "feature",
232
- children: name[locale]
233
- }, _id);
234
- })
235
- })]
236
- });
237
- }
238
- let features = [];
239
- try {
240
- // TODO: Pricing Table: 临时做法
241
- if (Array.isArray(plan.features) && plan.features.length > 0) {
242
- features = JSON.parse(plan.features[0].en);
243
- }
244
- } catch (error) {
245
- console.error('parse features failed:', error);
246
- }
247
- const providerName = (_paymentMethods$find = paymentMethods.find(x => x._id === paymentMethod)) === null || _paymentMethods$find === void 0 ? void 0 : _paymentMethods$find.provider.name;
248
- const content = /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, _objectSpread(_objectSpread({
249
- checked: checked,
250
- className: "card-container ".concat(checked ? 'checked' : ''),
251
- available: !!plan.available
252
- }, rest), {}, {
253
- children: [recommend && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
254
- className: "recommend-tag",
255
- children: t('common.popular')
256
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
257
- className: "basic",
258
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
259
- className: "header",
260
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
261
- className: "header__title",
262
- children: t('common.space')
263
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
264
- className: "header__name",
265
- children: plan === null || plan === void 0 ? void 0 : plan.name[locale]
266
- })]
267
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
268
- className: "price-info",
269
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
270
- className: "price",
271
- children: (0, _util2.getPrice)(plan.prices, providerName)
272
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
273
- className: "period",
274
- children: (0, _util.prettyDuration)(plan.duration, locale)
275
- })]
276
- })]
277
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
278
- className: "features",
279
- children: features.map(feature => {
280
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
281
- className: "feature",
282
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Feature, {
283
- feature: feature,
284
- locale: locale,
285
- checked: checked,
286
- isMobile: isMobile
287
- })
288
- }, feature._id);
289
- })
290
- })]
291
- }));
292
- if (plan.available) {
293
- return content;
294
- }
295
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
296
- title: plan.reason,
297
- style: {
298
- cursor: 'not-allowed'
299
- },
300
- children: content
301
- });
302
- }
303
- const Container = _styled.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n position: relative;\n align-items: center;\n flex-direction: column;\n border-radius: 12px;\n overflow: hidden;\n min-height: 400px;\n white-space: nowrap;\n padding: 16px;\n filter: grayscale(", ");\n opacity: ", ";\n\n .recommend-tag {\n display: block;\n position: absolute;\n top: 4px;\n right: 32px;\n color: #fff;\n padding: 4px 100px;\n position: absolute;\n transform: translate(50%, 50%) rotate(45deg);\n white-space: nowrap;\n background-color: #fe9344;\n transform-origin: center;\n }\n\n .toc__title {\n font-weight: bolder;\n align-items: flex-start;\n }\n\n &:not(.toc) {\n width: 280px;\n color: #000;\n background-color: #f0fdff;\n cursor: pointer;\n }\n\n &:not(.toc, .checked):hover {\n color: #000;\n background-color: #ddf6f8;\n cursor: pointer;\n }\n\n &.checked {\n color: #fff;\n background-color: ", ";\n cursor: pointer;\n }\n\n .basic-toc {\n width: 100%;\n height: 8em;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n\n .payment-methods {\n padding-top: 3em;\n font-size: 1.1em;\n font-weight: bolder;\n\n select {\n margin-left: 1em;\n }\n }\n }\n\n .basic {\n width: 100%;\n height: 8em;\n\n .header {\n text-align: center;\n .header__title {\n color: ", ";\n }\n\n .header__name {\n font-weight: bolder;\n }\n }\n\n .price-info {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n height: 6.5em;\n\n .price {\n font-size: 1.5em;\n font-weight: bolder;\n }\n\n .period {\n color: ", ";\n }\n }\n }\n\n .features {\n display: flex;\n flex-direction: column;\n width: 100%;\n margin-top: auto;\n\n .feature {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 48px;\n text-align: center;\n\n // \u79FB\u52A8\u7AEF\u4E0D\u51CF\u5C0F\n @media (max-height: 960px) and (min-width: 640px) {\n height: 36px;\n font-size: 0.9rem;\n }\n\n @media (max-width: 900px) {\n justify-content: flex-start;\n }\n\n &:not(:last-child) {\n border-bottom: 1px solid;\n border-bottom-color: ", ";\n }\n }\n }\n"])), props => props.available ? 0 : 1, props => props.available ? 1 : 0.4, props => props.theme.palette.primary.main, props => props.checked ? '#ffffff' : '#9397a1', props => props.checked ? '#ffffff' : '#9397a1', props => props.checked || props.hovered ? 'rgba(255, 255, 255, 0.2)' : '#f6f6f6');
304
- Plan.propTypes = {
305
- plan: _propTypes.default.object.isRequired,
306
- paymentMethod: _propTypes.default.string.isRequired,
307
- paymentMethods: _propTypes.default.array,
308
- onChangeMethod: _propTypes.default.func,
309
- productFeatures: _propTypes.default.array,
310
- checked: _propTypes.default.bool,
311
- recommend: _propTypes.default.bool,
312
- toc: _propTypes.default.bool
313
- };
314
- Plan.defaultProps = {
315
- paymentMethods: [],
316
- productFeatures: [],
317
- onChangeMethod: _lodash.default,
318
- checked: false,
319
- recommend: false,
320
- toc: false
321
- };
322
- var _default = exports.default = Plan;