@ultraviolet/plus 0.4.10 → 0.5.1
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.
- package/dist/index.d.ts +261 -1
- package/dist/src/components/ContentCard/index.js +1 -1
- package/dist/src/components/ContentCardGroup/Card.js +41 -11
- package/dist/src/components/EstimateCost/Components/CustomUnitInput.js +48 -0
- package/dist/src/components/EstimateCost/Components/Item.js +327 -0
- package/dist/src/components/EstimateCost/Components/LineThrough.js +15 -0
- package/dist/src/components/EstimateCost/Components/NumberInput.js +41 -0
- package/dist/src/components/EstimateCost/Components/Region.js +50 -0
- package/dist/src/components/EstimateCost/Components/Regular.js +44 -0
- package/dist/src/components/EstimateCost/Components/Strong.js +37 -0
- package/dist/src/components/EstimateCost/Components/Unit.js +61 -0
- package/dist/src/components/EstimateCost/Components/UnitInput.js +122 -0
- package/dist/src/components/EstimateCost/Components/Zone.js +50 -0
- package/dist/src/components/EstimateCost/EstimateCost.js +126 -0
- package/dist/src/components/EstimateCost/EstimateCostContent.js +299 -0
- package/dist/src/components/EstimateCost/EstimateCostProvider.js +39 -0
- package/dist/src/components/EstimateCost/OverlayComponent.js +139 -0
- package/dist/src/components/EstimateCost/OverlayContext.js +19 -0
- package/dist/src/components/EstimateCost/componentStyle.js +196 -0
- package/dist/src/components/EstimateCost/constants.js +31 -0
- package/dist/src/components/EstimateCost/helper.js +23 -0
- package/dist/src/components/EstimateCost/locales/en.js +23 -0
- package/dist/src/index.js +1 -0
- package/package.json +9 -2
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { Badge, zoomIn } from '@ultraviolet/ui';
|
|
4
|
+
import { MAX_CELL_WIDTH } from './constants.js';
|
|
5
|
+
|
|
6
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
7
|
+
const spacedChildren = process.env.NODE_ENV === "production" ? {
|
|
8
|
+
name: "14bpf6g",
|
|
9
|
+
styles: ">*{margin-top:0;}>*+*{margin-top:16px;}"
|
|
10
|
+
} : {
|
|
11
|
+
name: "14bpf6g",
|
|
12
|
+
styles: ">*{margin-top:0;}>*+*{margin-top:16px;}",
|
|
13
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
14
|
+
};
|
|
15
|
+
const StyledDiv = /*#__PURE__*/_styled("div", {
|
|
16
|
+
target: "e1xb5k8j14"
|
|
17
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
18
|
+
name: "158icaa",
|
|
19
|
+
styles: "margin-left:4px"
|
|
20
|
+
} : {
|
|
21
|
+
name: "158icaa",
|
|
22
|
+
styles: "margin-left:4px",
|
|
23
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
24
|
+
});
|
|
25
|
+
const StyledTable = /*#__PURE__*/_styled('table', {
|
|
26
|
+
shouldForwardProp: prop => !['noTotal'].includes(prop),
|
|
27
|
+
target: "e1xb5k8j13"
|
|
28
|
+
})("width:100%;", spacedChildren, ";border:1px solid ", _ref => {
|
|
29
|
+
let {
|
|
30
|
+
theme
|
|
31
|
+
} = _ref;
|
|
32
|
+
return theme.colors.neutral.border;
|
|
33
|
+
}, ";", _ref2 => {
|
|
34
|
+
let {
|
|
35
|
+
noTotal
|
|
36
|
+
} = _ref2;
|
|
37
|
+
return noTotal ? 'border-radius: 4px;' : 'border-radius: 4px 4px 0 4px;';
|
|
38
|
+
}, ";");
|
|
39
|
+
const StyledFeesTable = /*#__PURE__*/_styled('table', {
|
|
40
|
+
target: "e1xb5k8j12"
|
|
41
|
+
})("width:100%;", spacedChildren, ";border:1px solid ", _ref3 => {
|
|
42
|
+
let {
|
|
43
|
+
theme
|
|
44
|
+
} = _ref3;
|
|
45
|
+
return theme.colors.neutral.border;
|
|
46
|
+
}, ";border-radius:4px;margin-top:16px;");
|
|
47
|
+
const PriceCol = /*#__PURE__*/_styled("td", {
|
|
48
|
+
target: "e1xb5k8j11"
|
|
49
|
+
})("background-color:", _ref4 => {
|
|
50
|
+
let {
|
|
51
|
+
theme
|
|
52
|
+
} = _ref4;
|
|
53
|
+
return theme.colors.neutral.background;
|
|
54
|
+
}, ";");
|
|
55
|
+
const PriceCell = theme => /*#__PURE__*/css("border-left:1px solid ", theme.colors.neutral.border, ";background-color:", theme.colors.neutral.backgroundWeak, ";");
|
|
56
|
+
const Cell = /*#__PURE__*/_styled('td', {
|
|
57
|
+
shouldForwardProp: prop => !['tabulation', 'hasBorder', 'primary'].includes(prop),
|
|
58
|
+
target: "e1xb5k8j10"
|
|
59
|
+
})("padding-left:", _ref5 => {
|
|
60
|
+
let {
|
|
61
|
+
tabulation
|
|
62
|
+
} = _ref5;
|
|
63
|
+
return (tabulation ?? 0) * 8 + 16;
|
|
64
|
+
}, "px;padding-right:16px;position:relative;max-width:", MAX_CELL_WIDTH, ";", _ref6 => {
|
|
65
|
+
let {
|
|
66
|
+
theme,
|
|
67
|
+
hasBorder
|
|
68
|
+
} = _ref6;
|
|
69
|
+
return hasBorder && /*#__PURE__*/css("&:before{content:'';position:absolute;left:0;bottom:0;height:1px;width:calc(100% - 32px);margin-left:16px;border-bottom:1px solid ", theme.colors.neutral.border, ";}");
|
|
70
|
+
}, " ", _ref7 => {
|
|
71
|
+
let {
|
|
72
|
+
theme,
|
|
73
|
+
primary
|
|
74
|
+
} = _ref7;
|
|
75
|
+
return primary ? /*#__PURE__*/css("background:", theme.colors.primary.background, ";") : null;
|
|
76
|
+
}, ";");
|
|
77
|
+
const TotalPriceCell = /*#__PURE__*/_styled(Cell, {
|
|
78
|
+
target: "e1xb5k8j9"
|
|
79
|
+
})("border-color:", _ref8 => {
|
|
80
|
+
let {
|
|
81
|
+
theme
|
|
82
|
+
} = _ref8;
|
|
83
|
+
return theme.colors.neutral.border;
|
|
84
|
+
}, ";border-style:solid;border-width:0 1px 1px 1px;border-radius:0 0 4px 4px;min-width:195px;height:56px;background-color:", _ref9 => {
|
|
85
|
+
let {
|
|
86
|
+
theme
|
|
87
|
+
} = _ref9;
|
|
88
|
+
return theme.colors.primary.background;
|
|
89
|
+
}, ";");
|
|
90
|
+
const EmptyTable = /*#__PURE__*/_styled("table", {
|
|
91
|
+
target: "e1xb5k8j8"
|
|
92
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
93
|
+
name: "1bmvmcg",
|
|
94
|
+
styles: "margin:0;width:100%"
|
|
95
|
+
} : {
|
|
96
|
+
name: "1bmvmcg",
|
|
97
|
+
styles: "margin:0;width:100%",
|
|
98
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
99
|
+
});
|
|
100
|
+
const Title = /*#__PURE__*/_styled("h3", {
|
|
101
|
+
target: "e1xb5k8j7"
|
|
102
|
+
})("display:flex;align-items:center;padding:0;margin:0;font-size:18px;color:", _ref10 => {
|
|
103
|
+
let {
|
|
104
|
+
theme
|
|
105
|
+
} = _ref10;
|
|
106
|
+
return theme.colors.neutral.text;
|
|
107
|
+
}, ";font-weight:500;padding:", _ref11 => {
|
|
108
|
+
let {
|
|
109
|
+
theme
|
|
110
|
+
} = _ref11;
|
|
111
|
+
return theme.space['2'];
|
|
112
|
+
}, ";");
|
|
113
|
+
const EmptyCell = /*#__PURE__*/_styled("td", {
|
|
114
|
+
target: "e1xb5k8j6"
|
|
115
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
116
|
+
name: "22sgtr",
|
|
117
|
+
styles: "width:538px"
|
|
118
|
+
} : {
|
|
119
|
+
name: "22sgtr",
|
|
120
|
+
styles: "width:538px",
|
|
121
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
122
|
+
});
|
|
123
|
+
const TimeCell = /*#__PURE__*/_styled("div", {
|
|
124
|
+
target: "e1xb5k8j5"
|
|
125
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
126
|
+
name: "vvsuqs",
|
|
127
|
+
styles: "max-width:220px;padding:16px;align-items:start;text-align:left;float:right"
|
|
128
|
+
} : {
|
|
129
|
+
name: "vvsuqs",
|
|
130
|
+
styles: "max-width:220px;padding:16px;align-items:start;text-align:left;float:right",
|
|
131
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
132
|
+
});
|
|
133
|
+
const BadgeBeta = /*#__PURE__*/_styled(Badge, {
|
|
134
|
+
shouldForwardProp: prop => !['long'].includes(prop),
|
|
135
|
+
target: "e1xb5k8j4"
|
|
136
|
+
})("margin-left:", _ref12 => {
|
|
137
|
+
let {
|
|
138
|
+
long
|
|
139
|
+
} = _ref12;
|
|
140
|
+
return long ? '-185px' : '-115px';
|
|
141
|
+
}, ";position:absolute;top:calc(50% - 16px);");
|
|
142
|
+
const OverlayRow = /*#__PURE__*/_styled('li', {
|
|
143
|
+
shouldForwardProp: prop => !['isFirstElement', 'shouldBeHidden', 'hideFromOverlay'].includes(prop),
|
|
144
|
+
target: "e1xb5k8j3"
|
|
145
|
+
})("min-width:200px;padding:0 24px;border-left:1px solid ", _ref13 => {
|
|
146
|
+
let {
|
|
147
|
+
theme
|
|
148
|
+
} = _ref13;
|
|
149
|
+
return theme.colors.neutral.border;
|
|
150
|
+
}, ";", _ref14 => {
|
|
151
|
+
let {
|
|
152
|
+
isFirstElement
|
|
153
|
+
} = _ref14;
|
|
154
|
+
return isFirstElement && `border: 0;`;
|
|
155
|
+
}, " &:first-of-type,&:last-child{border:0;}@media (max-width: 1420px){", _ref15 => {
|
|
156
|
+
let {
|
|
157
|
+
shouldBeHidden
|
|
158
|
+
} = _ref15;
|
|
159
|
+
return shouldBeHidden && 'display: none;';
|
|
160
|
+
}, ";}", _ref16 => {
|
|
161
|
+
let {
|
|
162
|
+
hideFromOverlay
|
|
163
|
+
} = _ref16;
|
|
164
|
+
return hideFromOverlay && 'display: none;';
|
|
165
|
+
}, ";");
|
|
166
|
+
const StyledLeftSide = /*#__PURE__*/_styled("div", {
|
|
167
|
+
target: "e1xb5k8j2"
|
|
168
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
169
|
+
name: "1x1yonv",
|
|
170
|
+
styles: "display:flex;flex-direction:row;-webkit-box-pack:justify;justify-content:space-between;align-items:center;min-height:56px;padding-top:8px;padding-bottom:8px"
|
|
171
|
+
} : {
|
|
172
|
+
name: "1x1yonv",
|
|
173
|
+
styles: "display:flex;flex-direction:row;-webkit-box-pack:justify;justify-content:space-between;align-items:center;min-height:56px;padding-top:8px;padding-bottom:8px",
|
|
174
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
175
|
+
});
|
|
176
|
+
const ItemResourceName = /*#__PURE__*/_styled('div', {
|
|
177
|
+
shouldForwardProp: prop => !['animated'].includes(prop),
|
|
178
|
+
target: "e1xb5k8j1"
|
|
179
|
+
})("height:48px;display:flex;flex-direction:column;-webkit-box-pack:center;justify-content:center;animation:", _ref17 => {
|
|
180
|
+
let {
|
|
181
|
+
animated
|
|
182
|
+
} = _ref17;
|
|
183
|
+
return animated ? /*#__PURE__*/css("800ms ", zoomIn, ";") : '';
|
|
184
|
+
}, ";");
|
|
185
|
+
const StyledBadge = /*#__PURE__*/_styled(Badge, {
|
|
186
|
+
target: "e1xb5k8j0"
|
|
187
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
188
|
+
name: "72s22w",
|
|
189
|
+
styles: "display:inline-block;height:24px;line-height:18px;font-size:12px;margin-right:8px"
|
|
190
|
+
} : {
|
|
191
|
+
name: "72s22w",
|
|
192
|
+
styles: "display:inline-block;height:24px;line-height:18px;font-size:12px;margin-right:8px",
|
|
193
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
export { BadgeBeta, Cell, EmptyCell, EmptyTable, ItemResourceName, OverlayRow, PriceCell, PriceCol, StyledBadge, StyledDiv, StyledFeesTable, StyledLeftSide, StyledTable, TimeCell, Title, TotalPriceCell };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const APPROXIMATE_HOURS_IN_MONTH = 730;
|
|
2
|
+
|
|
3
|
+
// As we base ou calculation on hours we need to multiply them by a multiplier
|
|
4
|
+
// 1 month = 730 hours
|
|
5
|
+
const multiplier = {
|
|
6
|
+
seconds: 1 / 60 / 60,
|
|
7
|
+
minutes: 1 / 60,
|
|
8
|
+
hours: 1,
|
|
9
|
+
days: 24,
|
|
10
|
+
months: APPROXIMATE_HOURS_IN_MONTH
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// This is used to tell how many decimals depending on time unit
|
|
14
|
+
// "hours": 5 === 5 decimals on hour unit
|
|
15
|
+
const maximumFractionDigits = {
|
|
16
|
+
seconds: 10,
|
|
17
|
+
minutes: 8,
|
|
18
|
+
hours: 5,
|
|
19
|
+
days: 3,
|
|
20
|
+
months: 2
|
|
21
|
+
};
|
|
22
|
+
const maximumFractionDigitsLong = {
|
|
23
|
+
seconds: 12,
|
|
24
|
+
minutes: 10,
|
|
25
|
+
hours: 8,
|
|
26
|
+
days: 4,
|
|
27
|
+
months: 2
|
|
28
|
+
};
|
|
29
|
+
const MAX_CELL_WIDTH = '537px';
|
|
30
|
+
|
|
31
|
+
export { APPROXIMATE_HOURS_IN_MONTH, MAX_CELL_WIDTH, maximumFractionDigits, maximumFractionDigitsLong, multiplier };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { multiplier } from './constants.js';
|
|
2
|
+
|
|
3
|
+
// time unit = hours, days, months
|
|
4
|
+
// timeAmount = number of hours / days / months
|
|
5
|
+
const calculatePrice = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
price,
|
|
8
|
+
amount,
|
|
9
|
+
amountFree = 0,
|
|
10
|
+
timeUnit,
|
|
11
|
+
timeAmount,
|
|
12
|
+
discount = 0
|
|
13
|
+
} = _ref;
|
|
14
|
+
const value = (price - price * discount) * (timeAmount * multiplier[`${timeUnit}`]) * Math.max(amount - amountFree, 0);
|
|
15
|
+
|
|
16
|
+
// Avoid having negative price in any cases
|
|
17
|
+
if (value < 0) {
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { calculatePrice };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var EstimateCostLocales = {
|
|
2
|
+
'estimate.cost.description': 'This summary provides a cost estimation based on your configuration, the amount of time you expect to use the resource for, and the scale of your expected usage. For the purposes of this calculation, we consider that 1 month equals to 730 hours.',
|
|
3
|
+
'estimate.cost.label': 'Estimated cost',
|
|
4
|
+
'estimate.cost.beta.free': 'Free During Beta',
|
|
5
|
+
'estimate.cost.beta.discount': '% off during Beta',
|
|
6
|
+
'estimate.cost.beta.badge': 'Beta Version',
|
|
7
|
+
'estimate.cost.units.seconds.label': 'Second(s)',
|
|
8
|
+
'estimate.cost.units.minutes.label': 'Minute(s)',
|
|
9
|
+
'estimate.cost.units.hours.label': 'Hour(s)',
|
|
10
|
+
'estimate.cost.units.days.label': 'Day(s)',
|
|
11
|
+
'estimate.cost.units.months.label': 'Month(s)',
|
|
12
|
+
'estimate.cost.units.years.label': 'Year(s)',
|
|
13
|
+
'estimate.cost.fees.oneTime.title': 'One time fees',
|
|
14
|
+
'estimate.cost.fees.monthly.title': 'Each month',
|
|
15
|
+
'estimate.cost.fees.commitment': 'Commitment Fees',
|
|
16
|
+
'estimate.cost.units.gb.label': 'GB',
|
|
17
|
+
'estimate.cost.notDefined': 'Not defined',
|
|
18
|
+
'estimate.cost.submit.label': 'Create',
|
|
19
|
+
'estimate.cost.region.label': 'Region',
|
|
20
|
+
'estimate.cost.az.label': 'Availability Zone'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { EstimateCostLocales as default };
|
package/dist/src/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ContentCard } from './components/ContentCard/index.js';
|
|
2
2
|
export { ContentCardGroup } from './components/ContentCardGroup/index.js';
|
|
3
3
|
export { CodeEditor } from './components/CodeEditor/CodeEditor.js';
|
|
4
|
+
export { EstimateCost } from './components/EstimateCost/EstimateCost.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/plus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Ultraviolet Plus",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"type": "module",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
30
31
|
"exports": {
|
|
31
32
|
"types": "./dist/index.d.ts",
|
|
32
33
|
"default": "./dist/src/index.js"
|
|
@@ -40,16 +41,22 @@
|
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@babel/core": "7.23.3",
|
|
42
43
|
"@emotion/babel-plugin": "11.11.0",
|
|
44
|
+
"@emotion/react": "11.11.1",
|
|
45
|
+
"@emotion/styled": "11.11.0",
|
|
43
46
|
"@types/react": "18.2.37",
|
|
44
47
|
"@types/react-dom": "18.2.15",
|
|
48
|
+
"react": "18.2.0",
|
|
49
|
+
"react-dom": "18.2.0",
|
|
45
50
|
"@ultraviolet/icons": "2.5.5"
|
|
46
51
|
},
|
|
47
52
|
"dependencies": {
|
|
48
53
|
"@uiw/codemirror-extensions-langs": "4.21.20",
|
|
49
54
|
"@uiw/codemirror-theme-material": "4.21.20",
|
|
50
55
|
"@uiw/react-codemirror": "4.21.20",
|
|
56
|
+
"react-flatten-children": "1.1.2",
|
|
57
|
+
"react-intersection-observer": "9.5.3",
|
|
51
58
|
"@ultraviolet/themes": "1.5.0",
|
|
52
|
-
"@ultraviolet/ui": "1.
|
|
59
|
+
"@ultraviolet/ui": "1.27.1"
|
|
53
60
|
},
|
|
54
61
|
"scripts": {
|
|
55
62
|
"build": "rollup -c ../../rollup.config.mjs"
|