@ultraviolet/plus 0.5.0 → 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.
@@ -0,0 +1,41 @@
1
+ import { NumberInput as NumberInput$1 } from '@ultraviolet/ui';
2
+ import { useEffect } from 'react';
3
+ import { useOverlay } from '../OverlayContext.js';
4
+ import { ItemResourceName } from '../componentStyle.js';
5
+ import { Regular } from './Regular.js';
6
+ import { jsx } from '@emotion/react/jsx-runtime';
7
+
8
+ const NumberInput = _ref => {
9
+ let {
10
+ amount,
11
+ minValue = 0,
12
+ maxValue = 100,
13
+ getAmountValue,
14
+ itemCallback
15
+ } = _ref;
16
+ const {
17
+ isOverlay
18
+ } = useOverlay();
19
+ useEffect(() => {
20
+ getAmountValue?.(amount);
21
+ }, [getAmountValue, amount]);
22
+ return isOverlay ? jsx(ItemResourceName, {
23
+ animated: false,
24
+ children: jsx(Regular, {
25
+ children: amount
26
+ })
27
+ }) : jsx(NumberInput$1, {
28
+ minValue: minValue,
29
+ maxValue: maxValue,
30
+ size: "small",
31
+ onChange: value => {
32
+ if (typeof value === 'number' && itemCallback) {
33
+ itemCallback(value, true);
34
+ getAmountValue?.(value);
35
+ }
36
+ },
37
+ value: amount
38
+ });
39
+ };
40
+
41
+ export { NumberInput };
@@ -0,0 +1,50 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { useEstimateCost } from '../EstimateCostProvider.js';
3
+ import { Item } from './Item.js';
4
+ import { Strong } from './Strong.js';
5
+ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
6
+
7
+ const StyledImage = /*#__PURE__*/_styled("img", {
8
+ target: "exu7lwu0"
9
+ })("width:15px;margin-right:", _ref => {
10
+ let {
11
+ theme
12
+ } = _ref;
13
+ return theme.space['1'];
14
+ }, ";");
15
+ const Region = _ref2 => {
16
+ let {
17
+ label,
18
+ image,
19
+ shouldBeHidden = false,
20
+ priceText,
21
+ animated = false,
22
+ isFirstElement,
23
+ isLastElement,
24
+ productsCallback,
25
+ iteration,
26
+ discount
27
+ } = _ref2;
28
+ const {
29
+ locales
30
+ } = useEstimateCost();
31
+ return jsx(Item, {
32
+ label: locales['estimate.cost.region.label'],
33
+ shouldBeHidden: shouldBeHidden,
34
+ priceText: priceText,
35
+ animated: animated,
36
+ isFirstElement: isFirstElement,
37
+ isLastElement: isLastElement,
38
+ productsCallback: productsCallback,
39
+ iteration: iteration,
40
+ discount: discount,
41
+ children: jsxs(Strong, {
42
+ children: [jsx(StyledImage, {
43
+ alt: label,
44
+ src: image
45
+ }), label]
46
+ })
47
+ });
48
+ };
49
+
50
+ export { Region };
@@ -0,0 +1,44 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { css } from '@emotion/react';
3
+ import { useOverlay } from '../OverlayContext.js';
4
+ import { jsx } from '@emotion/react/jsx-runtime';
5
+
6
+ const StyledRegular = /*#__PURE__*/_styled('div', {
7
+ shouldForwardProp: prop => !['variant', 'isOverlay'].includes(prop),
8
+ target: "e1l9k4qo0"
9
+ })("display:", _ref => {
10
+ let {
11
+ isOverlay
12
+ } = _ref;
13
+ return isOverlay ? 'flex' : 'inline-flex';
14
+ }, ";max-width:500px;align-items:center;font-size:16px;color:", _ref2 => {
15
+ let {
16
+ theme
17
+ } = _ref2;
18
+ return theme.colors.neutral.textStrong;
19
+ }, ";margin-right:4px;", _ref3 => {
20
+ let {
21
+ theme,
22
+ variant
23
+ } = _ref3;
24
+ return variant === 'small' && /*#__PURE__*/css("display:block;font-size:14px;line-height:8px;color:", theme.colors.neutral.text, ";");
25
+ }, ";");
26
+ const Regular = _ref4 => {
27
+ let {
28
+ variant = 'normal',
29
+ isDisabledOnOverlay = false,
30
+ children = null,
31
+ className
32
+ } = _ref4;
33
+ const {
34
+ isOverlay
35
+ } = useOverlay();
36
+ return !isDisabledOnOverlay || !isOverlay ? jsx(StyledRegular, {
37
+ className: className,
38
+ variant: variant,
39
+ isOverlay: isOverlay,
40
+ children: children
41
+ }) : null;
42
+ };
43
+
44
+ export { Regular };
@@ -0,0 +1,37 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { Regular } from './Regular.js';
3
+ import { jsx } from '@emotion/react/jsx-runtime';
4
+
5
+ const StyledStrong = /*#__PURE__*/_styled(Regular, {
6
+ shouldForwardProp: prop => !['variant'].includes(prop),
7
+ target: "e1bhvxf60"
8
+ })("display:inline-flex;align-items:center;font-size:", _ref => {
9
+ let {
10
+ variant
11
+ } = _ref;
12
+ return variant === 'big' ? 24 : 16;
13
+ }, "px;", _ref2 => {
14
+ let {
15
+ variant
16
+ } = _ref2;
17
+ return variant === 'capitalized' ? `text-transform: capitalize;` : '';
18
+ }, " color:", _ref3 => {
19
+ let {
20
+ theme
21
+ } = _ref3;
22
+ return theme.colors.neutral.textStrong;
23
+ }, ";font-weight:500;margin-right:4px;");
24
+ const Strong = _ref4 => {
25
+ let {
26
+ variant = 'normal',
27
+ children = null,
28
+ isDisabledOnOverlay = false
29
+ } = _ref4;
30
+ return jsx(StyledStrong, {
31
+ variant: variant,
32
+ isDisabledOnOverlay: isDisabledOnOverlay,
33
+ children: children
34
+ });
35
+ };
36
+
37
+ export { Strong, StyledStrong };
@@ -0,0 +1,61 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { TextInput } from '@ultraviolet/ui';
3
+ import { useState, useEffect } from 'react';
4
+ import { useOverlay } from '../OverlayContext.js';
5
+ import { ItemResourceName } from '../componentStyle.js';
6
+ import { Regular } from './Regular.js';
7
+ import { jsx } from '@emotion/react/jsx-runtime';
8
+
9
+ 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)."; }
10
+ const StyledTextInput = /*#__PURE__*/_styled(TextInput, {
11
+ target: "e1pr25uw0"
12
+ })(process.env.NODE_ENV === "production" ? {
13
+ name: "l1y63n",
14
+ styles: "input[type='number']::-webkit-inner-spin-button,input[type='number']::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}input[type='number']{-moz-appearance:textfield;}"
15
+ } : {
16
+ name: "l1y63n",
17
+ styles: "input[type='number']::-webkit-inner-spin-button,input[type='number']::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}input[type='number']{-moz-appearance:textfield;}",
18
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
19
+ });
20
+ const Unit = _ref => {
21
+ let {
22
+ amount,
23
+ itemCallback,
24
+ getAmountValue,
25
+ unit
26
+ } = _ref;
27
+ const {
28
+ isOverlay
29
+ } = useOverlay();
30
+ const [capacity, setCapacity] = useState(amount === 0 ? undefined : amount);
31
+ useEffect(() => {
32
+ itemCallback?.(capacity, true);
33
+ getAmountValue?.(capacity);
34
+ }, [getAmountValue, itemCallback, capacity]);
35
+ return isOverlay ? jsx(ItemResourceName, {
36
+ animated: false,
37
+ children: jsx(Regular, {
38
+ children: capacity
39
+ })
40
+ }) :
41
+ // 120px is arbitrary, just to avoid full width input (ugly) nor too small input.
42
+ jsx("div", {
43
+ style: {
44
+ width: '120px'
45
+ },
46
+ children: jsx(StyledTextInput, {
47
+ type: "number",
48
+ size: "small",
49
+ unit: unit,
50
+ placeholder: "00",
51
+ name: "capacity",
52
+ value: capacity?.toString(),
53
+ onChange: capacityText => {
54
+ setCapacity(Number(capacityText) < 0 ? 0 : Number(capacityText));
55
+ getAmountValue?.(capacity);
56
+ }
57
+ })
58
+ });
59
+ };
60
+
61
+ export { Unit };
@@ -0,0 +1,122 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { Stack, TextInput, SelectInput } from '@ultraviolet/ui';
3
+ import { jsxs, jsx } from '@emotion/react/jsx-runtime';
4
+
5
+ const sizesHeight = {
6
+ large: 48,
7
+ medium: 40,
8
+ small: 32
9
+ };
10
+ const CustomTextInput = /*#__PURE__*/_styled(TextInput, {
11
+ target: "epio27v1"
12
+ })("input{border-radius:", _ref => {
13
+ let {
14
+ theme
15
+ } = _ref;
16
+ return theme.radii.default;
17
+ }, " 0 0 ", _ref2 => {
18
+ let {
19
+ theme
20
+ } = _ref2;
21
+ return theme.radii.default;
22
+ }, ";min-width:60px;border-right:0;&:hover,&:focus{text-decoration:none;border-right-width:1px;border-right-style:solid;border-color:", _ref3 => {
23
+ let {
24
+ theme
25
+ } = _ref3;
26
+ return theme.colors.primary.borderWeak;
27
+ }, ";}}input[type='number']::-webkit-inner-spin-button,input[type='number']::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}input[type='number']{-moz-appearance:textfield;}");
28
+ const CustomSelectInput = /*#__PURE__*/_styled(SelectInput, {
29
+ target: "epio27v0"
30
+ })(_ref4 => {
31
+ let {
32
+ width
33
+ } = _ref4;
34
+ return width && `width: ${width}px;`;
35
+ }, " ", _ref5 => {
36
+ let {
37
+ height
38
+ } = _ref5;
39
+ return height && `height: ${height}px;`;
40
+ }, " &:hover,&:focus{text-decoration:none;border-color:", _ref6 => {
41
+ let {
42
+ theme
43
+ } = _ref6;
44
+ return theme.colors.primary.borderWeak;
45
+ }, ";box-shadow:none;}");
46
+ const customSelectStyle = height => () => ({
47
+ control: {
48
+ borderBottomLeftRadius: 0,
49
+ borderTopLeftRadius: 0,
50
+ boxShadow: 'none',
51
+ height,
52
+ minHeight: height
53
+ },
54
+ singleValue: {
55
+ marginTop: 0
56
+ }
57
+ });
58
+ const UnitInput = _ref7 => {
59
+ let {
60
+ name = '',
61
+ maxValue = 99999,
62
+ minValue = 1,
63
+ size = 'medium',
64
+ placeholder = '0',
65
+ onChange,
66
+ onChangeUnitValue,
67
+ value,
68
+ unitValue,
69
+ textBoxWidth = 100,
70
+ selectInputWidth = 200,
71
+ disabled = false,
72
+ options,
73
+ className,
74
+ notice,
75
+ label,
76
+ required,
77
+ valueError,
78
+ unitError,
79
+ type = 'number',
80
+ 'data-testid': dataTestId
81
+ } = _ref7;
82
+ return jsxs(Stack, {
83
+ direction: "row",
84
+ "data-testid": dataTestId,
85
+ children: [jsx(CustomTextInput, {
86
+ height: sizesHeight[size],
87
+ width: textBoxWidth,
88
+ type: type,
89
+ name: `${name}-value`,
90
+ max: maxValue,
91
+ min: minValue,
92
+ required: required,
93
+ value: value,
94
+ placeholder: placeholder,
95
+ onChange: input => {
96
+ const numericValue = input ? parseInt(input, 10) : minValue;
97
+ onChange(numericValue);
98
+ },
99
+ className: className,
100
+ disabled: disabled,
101
+ notice: notice,
102
+ label: label,
103
+ error: valueError
104
+ }), jsx(CustomSelectInput, {
105
+ width: selectInputWidth,
106
+ noTopLabel: true,
107
+ height: sizesHeight[size],
108
+ id: `${name}-unit`,
109
+ name: `${name}-unit`,
110
+ onChange: newValue => {
111
+ onChangeUnitValue(newValue.value);
112
+ },
113
+ error: unitError,
114
+ value: options.find(option => option.value === unitValue) || options[0],
115
+ options: options,
116
+ customStyle: customSelectStyle(sizesHeight[size]),
117
+ disabled: disabled || options.length === 1
118
+ })]
119
+ });
120
+ };
121
+
122
+ export { UnitInput, sizesHeight };
@@ -0,0 +1,50 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { useEstimateCost } from '../EstimateCostProvider.js';
3
+ import { Item } from './Item.js';
4
+ import { Strong } from './Strong.js';
5
+ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
6
+
7
+ const StyledImage = /*#__PURE__*/_styled("img", {
8
+ target: "e24b3x10"
9
+ })("width:15px;margin-right:", _ref => {
10
+ let {
11
+ theme
12
+ } = _ref;
13
+ return theme.space['1'];
14
+ }, ";");
15
+ const Zone = _ref2 => {
16
+ let {
17
+ label,
18
+ image,
19
+ shouldBeHidden = false,
20
+ priceText,
21
+ animated = false,
22
+ isFirstElement,
23
+ isLastElement,
24
+ productsCallback,
25
+ iteration,
26
+ discount
27
+ } = _ref2;
28
+ const {
29
+ locales
30
+ } = useEstimateCost();
31
+ return jsx(Item, {
32
+ label: locales['estimate.cost.az.label'],
33
+ shouldBeHidden: shouldBeHidden,
34
+ priceText: priceText,
35
+ animated: animated,
36
+ isFirstElement: isFirstElement,
37
+ isLastElement: isLastElement,
38
+ productsCallback: productsCallback,
39
+ iteration: iteration,
40
+ discount: discount,
41
+ children: jsxs(Strong, {
42
+ children: [jsx(StyledImage, {
43
+ alt: label,
44
+ src: image
45
+ }), label]
46
+ })
47
+ });
48
+ };
49
+
50
+ export { Zone };
@@ -0,0 +1,126 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { Text } from '@ultraviolet/ui';
3
+ import { Children } from 'react';
4
+ import { Item } from './Components/Item.js';
5
+ import { LineThrough } from './Components/LineThrough.js';
6
+ import { NumberInput } from './Components/NumberInput.js';
7
+ import { Region } from './Components/Region.js';
8
+ import { Regular } from './Components/Regular.js';
9
+ import { Strong } from './Components/Strong.js';
10
+ import { Unit } from './Components/Unit.js';
11
+ import { Zone } from './Components/Zone.js';
12
+ import { EstimateCostContent } from './EstimateCostContent.js';
13
+ import { EstimateCostProvider } from './EstimateCostProvider.js';
14
+ import { useOverlay } from './OverlayContext.js';
15
+ import EstimateCostLocales from './locales/en.js';
16
+ import { jsx } from '@emotion/react/jsx-runtime';
17
+
18
+ const MaxWidthText = /*#__PURE__*/_styled(Text, {
19
+ target: "e13v5qur1"
20
+ })("max-width:", _ref => {
21
+ let {
22
+ maxWidth
23
+ } = _ref;
24
+ return maxWidth;
25
+ }, "px;");
26
+ const DEFAULT_UNIT_LIST = ['hours', 'days', 'months'];
27
+ const EstimateCost = _ref2 => {
28
+ let {
29
+ description,
30
+ alert,
31
+ alertVariant = 'warning',
32
+ defaultTimeUnit = 'hours',
33
+ timeUnits = DEFAULT_UNIT_LIST,
34
+ hideOverlay = false,
35
+ disableOverlayLeft = false,
36
+ disableOverlayRight = false,
37
+ hideTimeUnit = false,
38
+ hideTotal = false,
39
+ discount = 0,
40
+ OverlayRight,
41
+ OverlayLeft,
42
+ isBeta = false,
43
+ commitmentFees,
44
+ commitmentFeesContent,
45
+ monthlyFees,
46
+ monthlyFeesLabel,
47
+ monthlyFeesContent,
48
+ overlayUnit = 'hours',
49
+ children = null,
50
+ locales = EstimateCostLocales,
51
+ numberLocales = 'en-EN',
52
+ currency = 'EUR'
53
+ } = _ref2;
54
+ return jsx(EstimateCostProvider, {
55
+ locales: locales,
56
+ currency: currency,
57
+ numberLocales: numberLocales,
58
+ children: jsx(EstimateCostContent, {
59
+ description: description,
60
+ alert: alert,
61
+ alertVariant: alertVariant,
62
+ defaultTimeUnit: defaultTimeUnit,
63
+ timeUnits: timeUnits,
64
+ hideOverlay: hideOverlay,
65
+ disableOverlayLeft: disableOverlayLeft,
66
+ disableOverlayRight: disableOverlayRight,
67
+ hideTimeUnit: hideTimeUnit,
68
+ hideTotal: hideTotal,
69
+ discount: discount,
70
+ OverlayRight: OverlayRight,
71
+ OverlayLeft: OverlayLeft,
72
+ isBeta: isBeta,
73
+ commitmentFees: commitmentFees,
74
+ commitmentFeesContent: commitmentFeesContent,
75
+ monthlyFees: monthlyFees,
76
+ monthlyFeesLabel: monthlyFeesLabel,
77
+ monthlyFeesContent: monthlyFeesContent,
78
+ overlayUnit: overlayUnit,
79
+ locales: locales,
80
+ children: children
81
+ })
82
+ });
83
+ };
84
+ EstimateCost.LineThrough = LineThrough;
85
+ EstimateCost.Item = Item;
86
+ EstimateCost.NumberInput = NumberInput;
87
+ EstimateCost.Unit = Unit;
88
+ EstimateCost.Strong = Strong;
89
+ EstimateCost.Regular = Regular;
90
+ EstimateCost.Image = /*#__PURE__*/_styled("img", {
91
+ target: "e13v5qur0"
92
+ })("width:15px;margin-right:", _ref3 => {
93
+ let {
94
+ theme
95
+ } = _ref3;
96
+ return theme.space['1'];
97
+ }, ";");
98
+ EstimateCost.Region = Region;
99
+ EstimateCost.Zone = Zone;
100
+ const Ellipsis = _ref4 => {
101
+ let {
102
+ children,
103
+ maxWidth = 350,
104
+ 'data-testid': dataTestId
105
+ } = _ref4;
106
+ const {
107
+ isOverlay
108
+ } = useOverlay();
109
+ const text = Children.toArray(children).join('').toString();
110
+ return jsx("div", {
111
+ style: {
112
+ display: !isOverlay ? 'inline-flex' : undefined
113
+ },
114
+ "data-testid": dataTestId,
115
+ children: jsx(MaxWidthText, {
116
+ as: "p",
117
+ oneLine: true,
118
+ variant: "bodyStrong",
119
+ maxWidth: isOverlay ? 200 : maxWidth,
120
+ children: text
121
+ })
122
+ });
123
+ };
124
+ EstimateCost.Ellipsis = Ellipsis;
125
+
126
+ export { EstimateCost };