@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.
Files changed (24) hide show
  1. package/dist/index.d.ts +261 -1
  2. package/dist/src/components/ContentCard/index.js +1 -1
  3. package/dist/src/components/ContentCardGroup/Card.js +41 -11
  4. package/dist/src/components/EstimateCost/Components/CustomUnitInput.js +48 -0
  5. package/dist/src/components/EstimateCost/Components/Item.js +327 -0
  6. package/dist/src/components/EstimateCost/Components/LineThrough.js +15 -0
  7. package/dist/src/components/EstimateCost/Components/NumberInput.js +41 -0
  8. package/dist/src/components/EstimateCost/Components/Region.js +50 -0
  9. package/dist/src/components/EstimateCost/Components/Regular.js +44 -0
  10. package/dist/src/components/EstimateCost/Components/Strong.js +37 -0
  11. package/dist/src/components/EstimateCost/Components/Unit.js +61 -0
  12. package/dist/src/components/EstimateCost/Components/UnitInput.js +122 -0
  13. package/dist/src/components/EstimateCost/Components/Zone.js +50 -0
  14. package/dist/src/components/EstimateCost/EstimateCost.js +126 -0
  15. package/dist/src/components/EstimateCost/EstimateCostContent.js +299 -0
  16. package/dist/src/components/EstimateCost/EstimateCostProvider.js +39 -0
  17. package/dist/src/components/EstimateCost/OverlayComponent.js +139 -0
  18. package/dist/src/components/EstimateCost/OverlayContext.js +19 -0
  19. package/dist/src/components/EstimateCost/componentStyle.js +196 -0
  20. package/dist/src/components/EstimateCost/constants.js +31 -0
  21. package/dist/src/components/EstimateCost/helper.js +23 -0
  22. package/dist/src/components/EstimateCost/locales/en.js +23 -0
  23. package/dist/src/index.js +1 -0
  24. package/package.json +9 -2
package/dist/index.d.ts CHANGED
@@ -3,6 +3,9 @@ import { ReactNode, MouseEventHandler, ComponentProps } from 'react';
3
3
  import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
4
4
  import { langs } from '@uiw/codemirror-extensions-langs';
5
5
  import CodeMirror from '@uiw/react-codemirror';
6
+ import { Alert } from '@ultraviolet/ui';
7
+ import * as _emotion_styled from '@emotion/styled';
8
+ import * as _emotion_react from '@emotion/react';
6
9
 
7
10
  type ContentCardProps = {
8
11
  direction?: 'row' | 'column';
@@ -62,4 +65,261 @@ type CodeEditorProps = {
62
65
  };
63
66
  declare const CodeEditor: ({ title, value, onChange, extensions, onBlur, height, readOnly, }: CodeEditorProps) => _emotion_react_jsx_runtime.JSX.Element;
64
67
 
65
- export { CodeEditor, ContentCard, ContentCardGroup };
68
+ declare const _default: {
69
+ readonly '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.";
70
+ readonly 'estimate.cost.label': "Estimated cost";
71
+ readonly 'estimate.cost.beta.free': "Free During Beta";
72
+ readonly 'estimate.cost.beta.discount': "% off during Beta";
73
+ readonly 'estimate.cost.beta.badge': "Beta Version";
74
+ readonly 'estimate.cost.units.seconds.label': "Second(s)";
75
+ readonly 'estimate.cost.units.minutes.label': "Minute(s)";
76
+ readonly 'estimate.cost.units.hours.label': "Hour(s)";
77
+ readonly 'estimate.cost.units.days.label': "Day(s)";
78
+ readonly 'estimate.cost.units.months.label': "Month(s)";
79
+ readonly 'estimate.cost.units.years.label': "Year(s)";
80
+ readonly 'estimate.cost.fees.oneTime.title': "One time fees";
81
+ readonly 'estimate.cost.fees.monthly.title': "Each month";
82
+ readonly 'estimate.cost.fees.commitment': "Commitment Fees";
83
+ readonly 'estimate.cost.units.gb.label': "GB";
84
+ readonly 'estimate.cost.notDefined': "Not defined";
85
+ readonly 'estimate.cost.submit.label': "Create";
86
+ readonly 'estimate.cost.region.label': "Region";
87
+ readonly 'estimate.cost.az.label': "Availability Zone";
88
+ };
89
+
90
+ type EstimateCostProps = {
91
+ /**
92
+ * Text to display into an alert on the top of the EstimateCost component.
93
+ */
94
+ alert?: ReactNode;
95
+ /**
96
+ * Type of the alert defined by the Scaleway UI Alert component.
97
+ */
98
+ alertVariant?: ComponentProps<typeof Alert>['sentiment'];
99
+ children: ReactNode;
100
+ /**
101
+ * Individual fees to display at the bottom of the EstimateCost component.
102
+ */
103
+ commitmentFees?: number;
104
+ /**
105
+ * Content to display into the fees part, it can be any component but in order to have a consistent design, it is recommended to use `<EstimateCost.Regular>` and `<EstimateCost.Strong>` components.
106
+ */
107
+ commitmentFeesContent?: ReactNode;
108
+ /**
109
+ * By default, a description exists but if you need you can customize it with this prop.
110
+ */
111
+ description?: ReactNode;
112
+ /**
113
+ * Hide the floating estimate cost overlay shown in the bottom of the page.
114
+ */
115
+ hideOverlay?: boolean;
116
+ /**
117
+ * Disable left button on the overlay.
118
+ */
119
+ disableOverlayLeft?: boolean;
120
+ /**
121
+ * Disable right button (submit) on the overlay.
122
+ */
123
+ disableOverlayRight?: boolean;
124
+ /**
125
+ * This is a global discount for all estimate cost, all sub items will be impacted by this discount.
126
+ * The discount is a percentage, so 0.1 means 10% discount. Discount = 1 means 100% so it means free.
127
+ * This is usually associate with beta products and prop `isBeta`.
128
+ */
129
+ discount?: number;
130
+ /**
131
+ * The default time unit to select.
132
+ */
133
+ defaultTimeUnit?: Units;
134
+ /**
135
+ * List of time unit the price can be calculated with. Can only be an array of `seconds`, `minutes`, `hours`, `days` or `months`.
136
+ */
137
+ timeUnits?: Units[];
138
+ /**
139
+ * Hide the selectable time unit on the top of the component.
140
+ */
141
+ hideTimeUnit?: boolean;
142
+ /**
143
+ * Hide the total price at the bottom of the component.
144
+ */
145
+ hideTotal?: boolean;
146
+ /**
147
+ * Show a badge beta on the total price with how much discount is applied.
148
+ */
149
+ isBeta?: boolean;
150
+ /**
151
+ * It will display another individual line at the bottom of the component with a monthly price. It can be used when you display hourly price, but you have one or many items that are billed monthly.
152
+ */
153
+ monthlyFees?: number;
154
+ /**
155
+ * Content to display into monthly fees part, it can be any component but in order to have a consistent design, it is recommended to use `<EstimateCost.Regular>` and `<EstimateCost.Strong>` components.
156
+ */
157
+ monthlyFeesContent?: ReactNode;
158
+ /**
159
+ * Label of the item, it describes what kind of fees is related to. (ex: "Installation fee")
160
+ */
161
+ monthlyFeesLabel?: string;
162
+ /**
163
+ * Content that will be shown on the left side of the overlay.
164
+ */
165
+ OverlayLeft?: (props: {
166
+ children: ReactNode;
167
+ disabled?: boolean;
168
+ }) => JSX.Element;
169
+ /**
170
+ * Content that will be shown on the left side of the overlay.
171
+ */
172
+ OverlayRight?: (props: {
173
+ children?: ReactNode;
174
+ disabled?: boolean;
175
+ }) => JSX.Element;
176
+ /**
177
+ * Time unit to use on the overlay. It can be different from estimate cost.
178
+ */
179
+ overlayUnit?: Units;
180
+ /**
181
+ * Locales for the component. By default, it will use the english locales.
182
+ */
183
+ locales?: typeof _default;
184
+ /**
185
+ * Defines the currency to be shown in the component.
186
+ * To find out all currencies checkout https://en.wikipedia.org/wiki/ISO_4217#List_of_ISO_4217_currency_codes section "Code" of the table.
187
+ */
188
+ currency?: string;
189
+ /**
190
+ * Defines the way we display numbers depending on locale (ex: 1,000.00 or 1 000,00).
191
+ * To understand better please read https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#locales
192
+ */
193
+ numberLocales?: string;
194
+ };
195
+ type Units = 'seconds' | 'minutes' | 'hours' | 'days' | 'months';
196
+ type Iteration = {
197
+ unit: Units;
198
+ value: number;
199
+ };
200
+ type BareEstimateProduct = {
201
+ id: string;
202
+ };
203
+ type EstimateProduct = BareEstimateProduct & {
204
+ amount: number;
205
+ price: number;
206
+ amountFree: number;
207
+ isVariant: boolean;
208
+ maxAmount: number;
209
+ noIteration: boolean;
210
+ longFractionDigits: boolean;
211
+ discount: number;
212
+ };
213
+
214
+ declare const EstimateCost: {
215
+ ({ description, alert, alertVariant, defaultTimeUnit, timeUnits, hideOverlay, disableOverlayLeft, disableOverlayRight, hideTimeUnit, hideTotal, discount, OverlayRight, OverlayLeft, isBeta, commitmentFees, commitmentFeesContent, monthlyFees, monthlyFeesLabel, monthlyFeesContent, overlayUnit, children, locales, numberLocales, currency, }: EstimateCostProps): _emotion_react_jsx_runtime.JSX.Element;
216
+ LineThrough: _emotion_styled.StyledComponent<{
217
+ theme?: _emotion_react.Theme | undefined;
218
+ as?: react.ElementType<any> | undefined;
219
+ } & {
220
+ isActive?: boolean | undefined;
221
+ }, react.DetailedHTMLProps<react.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
222
+ Item: ({ discount, priceText, discountText, label, tooltipInfo, subLabel, price: basePrice, monthlyPrice, unit: baseUnit, amount: currentAmount, onAmountChange, amountFree, maxAmount, longFractionDigits, noIteration, noIterationText, noBorder, noPrice, isDefined, children, isFirstElement, isLastElement, isPrimaryBackground, productsCallback, iteration: receivedIteration, shouldBeHidden, hideFromOverlay, textNotDefined, animated, tabulation, labelTextVariant, labelTextProminence, notice, }: {
223
+ amount?: number | undefined;
224
+ amountFree?: number | undefined;
225
+ animated?: boolean | undefined;
226
+ children?: ReactNode;
227
+ discount?: number | undefined;
228
+ discountText?: string | undefined;
229
+ hideFromOverlay?: boolean | undefined;
230
+ isDefined?: boolean | undefined;
231
+ isFirstElement?: boolean | undefined;
232
+ isLastElement?: boolean | undefined;
233
+ isPrimaryBackground?: boolean | undefined;
234
+ iteration?: Iteration | undefined;
235
+ label?: ReactNode;
236
+ labelTextVariant?: "body" | "caption" | "code" | "heading" | "bodySmall" | "bodySmallStrong" | "bodySmallStronger" | "bodyStrong" | "bodyStronger" | "captionSmall" | "captionSmallStrong" | "captionSmallStronger" | "captionStrong" | "captionStronger" | "headingLarge" | "headingSmall" | undefined;
237
+ labelTextProminence?: "strong" | "default" | "stronger" | "weak" | undefined;
238
+ longFractionDigits?: boolean | undefined;
239
+ maxAmount?: number | undefined;
240
+ monthlyPrice?: number | undefined;
241
+ noBorder?: boolean | undefined;
242
+ noIteration?: boolean | undefined;
243
+ noIterationText?: string | undefined;
244
+ noPrice?: boolean | undefined;
245
+ notice?: string | undefined;
246
+ onAmountChange?: ((amount: number) => void) | undefined;
247
+ price?: number | undefined;
248
+ priceText?: ReactNode;
249
+ productsCallback?: {
250
+ add: (product: EstimateProduct) => void;
251
+ remove: (product: BareEstimateProduct) => void;
252
+ } | undefined;
253
+ shouldBeHidden?: boolean | undefined;
254
+ subLabel?: string | undefined;
255
+ tabulation?: number | undefined;
256
+ textNotDefined?: string | undefined;
257
+ tooltipInfo?: string | undefined;
258
+ unit?: (string & {}) | "seconds" | "minutes" | "hours" | "days" | "months" | "mb" | "gb" | "tb" | "years" | undefined;
259
+ }) => _emotion_react_jsx_runtime.JSX.Element;
260
+ NumberInput: ({ amount, minValue, maxValue, getAmountValue, itemCallback, }: {
261
+ amount?: number | undefined;
262
+ itemCallback?: ((amount?: number | undefined, isVariant?: boolean | undefined) => void) | undefined;
263
+ getAmountValue?: ((amount?: number | undefined) => void) | undefined;
264
+ minValue?: number | undefined;
265
+ maxValue?: number | undefined;
266
+ }) => _emotion_react_jsx_runtime.JSX.Element;
267
+ Unit: ({ amount, itemCallback, getAmountValue, unit, }: {
268
+ amount?: number | undefined;
269
+ itemCallback?: ((amount?: number | undefined, isVariant?: boolean | undefined) => void) | undefined;
270
+ getAmountValue?: ((amount?: number | undefined) => void) | undefined;
271
+ unit?: string | undefined;
272
+ }) => _emotion_react_jsx_runtime.JSX.Element;
273
+ Strong: ({ variant, children, isDisabledOnOverlay, }: {
274
+ variant?: "big" | "small" | "normal" | "capitalized" | undefined;
275
+ children?: ReactNode;
276
+ isDisabledOnOverlay?: boolean | undefined;
277
+ }) => _emotion_react_jsx_runtime.JSX.Element;
278
+ Regular: ({ variant, isDisabledOnOverlay, children, className, }: {
279
+ variant?: "big" | "small" | "normal" | "capitalized" | undefined;
280
+ isDisabledOnOverlay?: boolean | undefined;
281
+ children?: ReactNode;
282
+ className?: string | undefined;
283
+ }) => _emotion_react_jsx_runtime.JSX.Element | null;
284
+ Image: _emotion_styled.StyledComponent<{
285
+ theme?: _emotion_react.Theme | undefined;
286
+ as?: react.ElementType<any> | undefined;
287
+ }, react.DetailedHTMLProps<react.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
288
+ Region: ({ label, image, shouldBeHidden, priceText, animated, isFirstElement, isLastElement, productsCallback, iteration, discount, }: {
289
+ shouldBeHidden?: boolean | undefined;
290
+ priceText?: ReactNode;
291
+ animated?: boolean | undefined;
292
+ isFirstElement?: boolean | undefined;
293
+ isLastElement?: boolean | undefined;
294
+ productsCallback?: {
295
+ add: (product: EstimateProduct) => void;
296
+ remove: (product: BareEstimateProduct) => void;
297
+ } | undefined;
298
+ iteration?: Iteration | undefined;
299
+ discount?: number | undefined;
300
+ label: string;
301
+ image: string;
302
+ }) => _emotion_react_jsx_runtime.JSX.Element;
303
+ Zone: ({ label, image, shouldBeHidden, priceText, animated, isFirstElement, isLastElement, productsCallback, iteration, discount, }: {
304
+ shouldBeHidden?: boolean | undefined;
305
+ priceText?: string | undefined;
306
+ animated?: boolean | undefined;
307
+ isFirstElement?: boolean | undefined;
308
+ isLastElement?: boolean | undefined;
309
+ productsCallback?: {
310
+ add: (product: EstimateProduct) => void;
311
+ remove: (product: BareEstimateProduct) => void;
312
+ } | undefined;
313
+ iteration?: Iteration | undefined;
314
+ discount?: number | undefined;
315
+ label: string;
316
+ image: string;
317
+ }) => _emotion_react_jsx_runtime.JSX.Element;
318
+ Ellipsis: ({ children, maxWidth, "data-testid": dataTestId, }: {
319
+ children: ReactNode;
320
+ maxWidth?: number | undefined;
321
+ 'data-testid'?: string | undefined;
322
+ }) => _emotion_react_jsx_runtime.JSX.Element;
323
+ };
324
+
325
+ export { CodeEditor, ContentCard, ContentCardGroup, EstimateCost };
@@ -184,7 +184,7 @@ const ContentCard = /*#__PURE__*/forwardRef((_ref14, ref) => {
184
184
  children: subtitle
185
185
  }) : null, jsx(Text, {
186
186
  as: "h3",
187
- variant: "bodyStronger",
187
+ variant: "bodyStrong",
188
188
  sentiment: "neutral",
189
189
  children: title
190
190
  })]
@@ -6,7 +6,7 @@ import { Icon } from '../../../@ultraviolet/icons/dist/components/Icon/index.js'
6
6
 
7
7
  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)."; }
8
8
  const StyledStack = /*#__PURE__*/_styled(Stack, {
9
- target: "eqcw8nr2"
9
+ target: "eqcw8nr3"
10
10
  })(process.env.NODE_ENV === "production" ? {
11
11
  name: "ovk77c",
12
12
  styles: "min-width:0"
@@ -16,7 +16,7 @@ const StyledStack = /*#__PURE__*/_styled(Stack, {
16
16
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
17
17
  });
18
18
  const IconWrapper = /*#__PURE__*/_styled("div", {
19
- target: "eqcw8nr1"
19
+ target: "eqcw8nr2"
20
20
  })("display:inline-flex;background:", _ref => {
21
21
  let {
22
22
  theme
@@ -34,29 +34,59 @@ const IconWrapper = /*#__PURE__*/_styled("div", {
34
34
  return theme.radii.default;
35
35
  }, ";");
36
36
  const StyledWrapper = /*#__PURE__*/_styled("a", {
37
- target: "eqcw8nr0"
38
- })("display:block;padding:", _ref4 => {
37
+ target: "eqcw8nr1"
38
+ })("padding:", _ref4 => {
39
39
  let {
40
40
  theme
41
41
  } = _ref4;
42
42
  return theme.space['3'];
43
- }, ";text-decoration:none;&:not(:first-child){border-top:1px solid ", _ref5 => {
43
+ }, ";text-decoration:none;height:100%;&:not(:first-child){border-top:1px solid ", _ref5 => {
44
44
  let {
45
45
  theme
46
46
  } = _ref5;
47
47
  return theme.colors.neutral.border;
48
- }, ";}& ", IconWrapper, "{background:", _ref6 => {
48
+ }, ";}&:first-child{border-radius:", _ref6 => {
49
49
  let {
50
50
  theme
51
51
  } = _ref6;
52
- return theme.colors.neutral.backgroundWeak;
53
- }, ";}&:hover{background:", _ref7 => {
52
+ return theme.radii.default;
53
+ }, " ", _ref7 => {
54
54
  let {
55
55
  theme
56
56
  } = _ref7;
57
+ return theme.radii.default;
58
+ }, " 0 0;}&:last-child{border-radius:0 0 ", _ref8 => {
59
+ let {
60
+ theme
61
+ } = _ref8;
62
+ return theme.radii.default;
63
+ }, " ", _ref9 => {
64
+ let {
65
+ theme
66
+ } = _ref9;
67
+ return theme.radii.default;
68
+ }, ";}& ", IconWrapper, "{background:", _ref10 => {
69
+ let {
70
+ theme
71
+ } = _ref10;
72
+ return theme.colors.neutral.backgroundWeak;
73
+ }, ";}&:hover{background:", _ref11 => {
74
+ let {
75
+ theme
76
+ } = _ref11;
57
77
  return theme.colors.neutral.backgroundHover;
58
78
  }, ";& ", IconWrapper, "{background:none;}}");
59
- const Card = /*#__PURE__*/forwardRef((_ref8, ref) => {
79
+ const FullHeightStack = /*#__PURE__*/_styled(Stack, {
80
+ target: "eqcw8nr0"
81
+ })(process.env.NODE_ENV === "production" ? {
82
+ name: "13udsys",
83
+ styles: "height:100%"
84
+ } : {
85
+ name: "13udsys",
86
+ styles: "height:100%",
87
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
88
+ });
89
+ const Card = /*#__PURE__*/forwardRef((_ref12, ref) => {
60
90
  let {
61
91
  title,
62
92
  subtitle,
@@ -64,12 +94,12 @@ const Card = /*#__PURE__*/forwardRef((_ref8, ref) => {
64
94
  children,
65
95
  href,
66
96
  target = '_blank'
67
- } = _ref8;
97
+ } = _ref12;
68
98
  return jsx(StyledWrapper, {
69
99
  href: href,
70
100
  target: target,
71
101
  ref: ref,
72
- children: jsxs(Stack, {
102
+ children: jsxs(FullHeightStack, {
73
103
  direction: "row",
74
104
  gap: 2,
75
105
  alignItems: "center",
@@ -0,0 +1,48 @@
1
+ import { useMemo } from 'react';
2
+ import { useEstimateCost } from '../EstimateCostProvider.js';
3
+ import { UnitInput } from './UnitInput.js';
4
+ import { jsx } from '@emotion/react/jsx-runtime';
5
+
6
+ const CustomUnitInput = _ref => {
7
+ let {
8
+ defaultTimeUnit = 'hours',
9
+ setIteration,
10
+ iteration,
11
+ timeUnits
12
+ } = _ref;
13
+ const {
14
+ locales
15
+ } = useEstimateCost();
16
+ const options = useMemo(() => timeUnits.map(unit => ({
17
+ value: unit,
18
+ label: locales[`estimate.cost.units.${unit}.label`]
19
+ })), [timeUnits, locales]);
20
+ const defaultOption = useMemo(() => options.find(_ref2 => {
21
+ let {
22
+ value
23
+ } = _ref2;
24
+ return value === defaultTimeUnit;
25
+ }), [defaultTimeUnit, options]);
26
+ return jsx(UnitInput, {
27
+ name: "iteration",
28
+ onChange: inputValue => setIteration({
29
+ unit: iteration.unit,
30
+ value: inputValue
31
+ }),
32
+ onChangeUnitValue: unitValue => {
33
+ setIteration({
34
+ unit: unitValue,
35
+ value: iteration.value
36
+ });
37
+ },
38
+ placeholder: "0",
39
+ value: iteration.value,
40
+ unitValue: iteration.unit || defaultOption?.value,
41
+ minValue: 1,
42
+ size: "medium",
43
+ options: options,
44
+ selectInputWidth: 300
45
+ });
46
+ };
47
+
48
+ export { CustomUnitInput };