@ultraviolet/ui 1.27.3 → 1.28.0

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 CHANGED
@@ -1368,19 +1368,23 @@ type CheckboxProps = {
1368
1368
  declare const Checkbox: react.ForwardRefExoticComponent<CheckboxProps & react.RefAttributes<HTMLInputElement>>;
1369
1369
 
1370
1370
  type CopyButtonProps = {
1371
- size?: 'small' | 'large';
1371
+ size?: 'xsmall' | 'small' | 'medium' | 'large';
1372
1372
  value: string;
1373
1373
  copyText?: string;
1374
1374
  copiedText?: string;
1375
1375
  sentiment?: 'primary' | 'neutral';
1376
+ /**
1377
+ * @deprecated Use `bordered` instead
1378
+ */
1376
1379
  noBorder?: boolean;
1380
+ bordered?: boolean;
1377
1381
  className?: string;
1378
1382
  'data-testid'?: string;
1379
1383
  };
1380
1384
  /**
1381
1385
  * CopyButton is a button that copies a given value to the clipboard.
1382
1386
  */
1383
- declare const CopyButton: ({ size, value, copyText, copiedText, sentiment, noBorder, className, "data-testid": dataTestId, }: CopyButtonProps) => _emotion_react_jsx_runtime.JSX.Element;
1387
+ declare const CopyButton: ({ size, value, copyText, copiedText, sentiment, noBorder, bordered, className, "data-testid": dataTestId, }: CopyButtonProps) => _emotion_react_jsx_runtime.JSX.Element;
1384
1388
 
1385
1389
  type DateInputProps = Pick<ReactDatePickerProps<string, boolean>, 'locale' | 'onChange'> & {
1386
1390
  autoFocus?: boolean;
@@ -3,7 +3,6 @@ import { useTheme } from '@emotion/react';
3
3
  import { Icon } from '@ultraviolet/icons';
4
4
  import { forwardRef, useState, useId, useEffect, useCallback } from 'react';
5
5
  import { Loader } from '../Loader/index.js';
6
- import { Row } from '../Row/index.js';
7
6
  import { Stack } from '../Stack/index.js';
8
7
  import { Text } from '../Text/index.js';
9
8
  import { Tooltip } from '../Tooltip/index.js';
@@ -85,7 +84,14 @@ const StyledIcon = /*#__PURE__*/_styled('svg', {
85
84
  }, ";transform:translate(2px, 2px);transform:scale(0);}");
86
85
  const StyledLabel = /*#__PURE__*/_styled('label', {
87
86
  target: "eqr7bqq3"
88
- })();
87
+ })(process.env.NODE_ENV === "production" ? {
88
+ name: "1d3w5wq",
89
+ styles: "width:100%"
90
+ } : {
91
+ name: "1d3w5wq",
92
+ styles: "width:100%",
93
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
94
+ });
89
95
  const CheckboxInput = /*#__PURE__*/_styled('input', {
90
96
  shouldForwardProp: prop => !['size'].includes(prop),
91
97
  target: "eqr7bqq2"
@@ -177,7 +183,7 @@ const CheckboxContainer = /*#__PURE__*/_styled("div", {
177
183
  theme
178
184
  } = _ref27;
179
185
  return theme.space['1'];
180
- }, ";", StyledLabel, "{cursor:pointer;}&[aria-disabled='true']{cursor:not-allowed;color:", _ref28 => {
186
+ }, ";width:100%;", StyledLabel, "{cursor:pointer;}&[aria-disabled='true']{cursor:not-allowed;color:", _ref28 => {
181
187
  let {
182
188
  theme
183
189
  } = _ref28;
@@ -459,9 +465,12 @@ const Checkbox = /*#__PURE__*/forwardRef((_ref64, ref) => {
459
465
  })
460
466
  }) : null, jsxs(Stack, {
461
467
  gap: 0.25,
462
- children: [jsxs(Row, {
463
- templateColumns: "11fr 1fr",
468
+ flex: 1,
469
+ children: [jsxs(Stack, {
470
+ gap: 0.5,
471
+ direction: "row",
464
472
  alignItems: "center",
473
+ flex: 1,
465
474
  children: [children ? jsx(StyledLabel, {
466
475
  htmlFor: computedName,
467
476
  children: children
@@ -14,6 +14,7 @@ const CopyButton = _ref => {
14
14
  copiedText = 'Copied!',
15
15
  sentiment = 'primary',
16
16
  noBorder,
17
+ bordered,
17
18
  className,
18
19
  'data-testid': dataTestId
19
20
  } = _ref;
@@ -25,7 +26,7 @@ const CopyButton = _ref => {
25
26
  onClick: setCopied,
26
27
  size: size,
27
28
  sentiment: sentiment,
28
- variant: noBorder ? 'ghost' : 'outlined',
29
+ variant: noBorder || !bordered ? 'ghost' : 'outlined',
29
30
  className: className,
30
31
  "data-testid": dataTestId,
31
32
  "aria-label": "Copy",
@@ -24,17 +24,17 @@ const computePlacement = _ref => {
24
24
  const {
25
25
  top: childrenTop,
26
26
  left: childrenLeft,
27
- right: childrenRight
27
+ right: childrenRight,
28
+ width: childrenWidth
28
29
  } = childrenStructuredRef;
29
30
  const {
30
31
  top: parentTop,
31
- left: parentLeft,
32
- right: parentRight
32
+ left: parentLeft
33
33
  } = offsetParentRect;
34
34
  const isPopupPortalTargetBody = popupPortalTarget === document.body || offsetParent === document.body;
35
35
  const overloadedChildrenLeft = isPopupPortalTargetBody ? childrenLeft : childrenLeft - parentLeft;
36
36
  const overloadedChildrenTop = isPopupPortalTargetBody ? childrenTop : childrenTop - parentTop;
37
- const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenRight - parentRight;
37
+ const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenLeft - parentLeft + childrenWidth;
38
38
  const {
39
39
  width: popupWidth,
40
40
  height: popupHeight
@@ -113,8 +113,7 @@ const computePositions = _ref2 => {
113
113
  } = childrenRect;
114
114
  const {
115
115
  top: parentTop,
116
- left: parentLeft,
117
- right: parentRight
116
+ left: parentLeft
118
117
  } = offsetParentRect;
119
118
  const {
120
119
  width: popupWidth,
@@ -130,7 +129,7 @@ const computePositions = _ref2 => {
130
129
  // We need to compute the position of the popup based on the parent element in the case the popup is not in the body
131
130
  const overloadedChildrenLeft = isPopupPortalTargetBody ? childrenLeft : childrenLeft - parentLeft;
132
131
  const overloadedChildrenTop = isPopupPortalTargetBody ? childrenTop : childrenTop - parentTop;
133
- const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenRight + childrenWidth + ARROW_WIDTH + SPACE - parentRight / 2;
132
+ const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenLeft - parentLeft + childrenWidth;
134
133
  switch (placementBasedOnWindowSize) {
135
134
  case 'bottom':
136
135
  {
@@ -244,8 +244,8 @@ const Popup = /*#__PURE__*/forwardRef((_ref15, ref) => {
244
244
  // We want to detect scroll and resize in order to recompute positions of popup
245
245
  // Adding true as third parameter to event listener will detect nested scrolls.
246
246
  window.addEventListener('scroll', onWindowChangeDetected, true);
247
- window.addEventListener('resize', onWindowChangeDetected, true);
248
247
  }
248
+ window.addEventListener('resize', onWindowChangeDetected, true);
249
249
  }
250
250
  return () => {
251
251
  window.removeEventListener('scroll', onWindowChangeDetected, true);
@@ -5,12 +5,13 @@ import { Text } from '../Text/index.js';
5
5
  import { Tooltip } from '../Tooltip/index.js';
6
6
  import { jsx, jsxs } from '@emotion/react/jsx-runtime';
7
7
 
8
+ 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
9
  const SIZE = 24;
9
10
  const InnerCircleRing = /*#__PURE__*/_styled("circle", {
10
- target: "ehkrmld5"
11
+ target: "ehkrmld6"
11
12
  })();
12
13
  const RadioMark = /*#__PURE__*/_styled("circle", {
13
- target: "ehkrmld4"
14
+ target: "ehkrmld5"
14
15
  })();
15
16
  const RadioMarkedIcon = () => jsxs("g", {
16
17
  children: [jsx("circle", {
@@ -29,7 +30,7 @@ const RadioMarkedIcon = () => jsxs("g", {
29
30
  })]
30
31
  });
31
32
  const Ring = /*#__PURE__*/_styled("svg", {
32
- target: "ehkrmld3"
33
+ target: "ehkrmld4"
33
34
  })("height:", SIZE, "px;width:", SIZE, "px;min-width:", SIZE, "px;min-height:", SIZE, "px;border-radius:", _ref => {
34
35
  let {
35
36
  theme
@@ -47,7 +48,7 @@ const Ring = /*#__PURE__*/_styled("svg", {
47
48
  return theme.colors.neutral.background;
48
49
  }, ";}");
49
50
  const RadioInput = /*#__PURE__*/_styled("input", {
50
- target: "ehkrmld2"
51
+ target: "ehkrmld3"
51
52
  })("cursor:pointer;position:absolute;height:", SIZE, "px;width:", SIZE, "px;opacity:0;white-space:nowrap;border-width:0;&+", Ring, "{", RadioMark, "{transform-origin:center;transition:200ms transform ease-in-out;transform:scale(0);}}&:checked+svg{", RadioMark, "{transform:scale(1);}}&:checked[aria-disabled='false'][aria-invalid='false']+", Ring, "{fill:", _ref4 => {
52
53
  let {
53
54
  theme
@@ -80,8 +81,8 @@ const RadioInput = /*#__PURE__*/_styled("input", {
80
81
  return theme.colors.danger.background;
81
82
  }, ";}}");
82
83
  const RadioContainer = /*#__PURE__*/_styled("div", {
83
- target: "ehkrmld1"
84
- })("position:relative;display:flex;align-items:flex-start;gap:", _ref10 => {
84
+ target: "ehkrmld2"
85
+ })("position:relative;display:flex;flex:1;align-items:flex-start;gap:", _ref10 => {
85
86
  let {
86
87
  theme
87
88
  } = _ref10;
@@ -122,6 +123,16 @@ const RadioContainer = /*#__PURE__*/_styled("div", {
122
123
  } = _ref17;
123
124
  return theme.colors.neutral.backgroundDisabled;
124
125
  }, ";}}}");
126
+ const StyledLabel = /*#__PURE__*/_styled("label", {
127
+ target: "ehkrmld1"
128
+ })(process.env.NODE_ENV === "production" ? {
129
+ name: "82a6rk",
130
+ styles: "flex:1"
131
+ } : {
132
+ name: "82a6rk",
133
+ styles: "flex:1",
134
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
135
+ });
125
136
  const MargedText = /*#__PURE__*/_styled(Text, {
126
137
  target: "ehkrmld0"
127
138
  })("margin-left:", _ref18 => {
@@ -158,6 +169,7 @@ const Radio = /*#__PURE__*/forwardRef((_ref19, ref) => {
158
169
  text: tooltip,
159
170
  children: jsxs(Stack, {
160
171
  gap: 0.5,
172
+ width: "100%",
161
173
  children: [jsxs(RadioContainer, {
162
174
  "aria-disabled": disabled,
163
175
  className: className,
@@ -183,7 +195,7 @@ const Radio = /*#__PURE__*/forwardRef((_ref19, ref) => {
183
195
  }), jsx(Ring, {
184
196
  viewBox: "0 0 24 24",
185
197
  children: jsx(RadioMarkedIcon, {})
186
- }), label ? jsx("label", {
198
+ }), label ? jsx(StyledLabel, {
187
199
  htmlFor: `${computedName}-${value}`,
188
200
  children: label
189
201
  }) : null]
@@ -5,8 +5,9 @@ import { Radio } from '../Radio/index.js';
5
5
  import { Tooltip } from '../Tooltip/index.js';
6
6
  import { jsx, jsxs } from '@emotion/react/jsx-runtime';
7
7
 
8
+ 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
9
  const Container = /*#__PURE__*/_styled("div", {
9
- target: "e1s5n3hj1"
10
+ target: "e1s5n3hj2"
10
11
  })("display:inline-flex;flex-direction:column;align-items:start;padding:", _ref => {
11
12
  let {
12
13
  theme
@@ -70,7 +71,7 @@ const Container = /*#__PURE__*/_styled("div", {
70
71
  }, ";}}}");
71
72
  const StyledElement = /*#__PURE__*/_styled('div', {
72
73
  shouldForwardProp: prop => !['showTick', 'hasLabel'].includes(prop),
73
- target: "e1s5n3hj0"
74
+ target: "e1s5n3hj1"
74
75
  })("display:inline-flex;align-items:start;&[data-checked='true']{color:", _ref13 => {
75
76
  let {
76
77
  theme
@@ -99,11 +100,21 @@ const StyledElement = /*#__PURE__*/_styled('div', {
99
100
  return !showTick && !hasLabel ? `display: none;` : null;
100
101
  }, ";}");
101
102
  const StyledRadio = /*#__PURE__*/StyledElement.withComponent(Radio, {
102
- target: "e1s5n3hj2"
103
- });
104
- const StyledCheckbox = /*#__PURE__*/StyledElement.withComponent(Checkbox, {
105
103
  target: "e1s5n3hj3"
106
104
  });
105
+ const OverloadedCheckbox = /*#__PURE__*/StyledElement.withComponent(Checkbox, {
106
+ target: "e1s5n3hj4"
107
+ });
108
+ const StyledCheckbox = /*#__PURE__*/_styled(OverloadedCheckbox, {
109
+ target: "e1s5n3hj0"
110
+ })(process.env.NODE_ENV === "production" ? {
111
+ name: "qxc5j0",
112
+ styles: "label{width:100%;}"
113
+ } : {
114
+ name: "qxc5j0",
115
+ styles: "label{width:100%;}",
116
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
117
+ });
107
118
  /**
108
119
  * SelectableCard is a component that can be used to create a radio or checkbox card.
109
120
  * It can be used to create a list of selectable items or a single selectable item.
@@ -5,7 +5,7 @@ import _styled from '@emotion/styled/base';
5
5
  * it accepts few props to deal with spacing and align.
6
6
  */
7
7
  const Stack = /*#__PURE__*/_styled('div', {
8
- shouldForwardProp: prop => !['gap', 'direction', 'alignItems', 'justifyContent', 'wrap'].includes(prop),
8
+ shouldForwardProp: prop => !['gap', 'direction', 'alignItems', 'justifyContent', 'wrap', 'width'].includes(prop),
9
9
  target: "ehpbis70"
10
10
  })("display:flex;", _ref => {
11
11
  let {
@@ -1,21 +1,34 @@
1
1
  import _styled from '@emotion/styled/base';
2
2
  import { Icon } from '@ultraviolet/icons';
3
3
  import { forwardRef } from 'react';
4
- import { Menu } from '../Menu/index.js';
4
+ import { MenuV2 } from '../MenuV2/index.js';
5
5
  import { StyledTabButton } from './Tab.js';
6
6
  import { jsx, jsxs } from '@emotion/react/jsx-runtime';
7
7
 
8
+ 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
9
  const ArrowIcon = /*#__PURE__*/_styled(Icon, {
9
- target: "edb1sh91"
10
+ target: "edb1sh92"
10
11
  })();
11
12
  const StyledMenu = /*#__PURE__*/_styled(StyledTabButton, {
12
- target: "edb1sh90"
13
+ target: "edb1sh91"
13
14
  })(ArrowIcon, "{color:inherit;margin-left:", _ref => {
14
15
  let {
15
16
  theme
16
17
  } = _ref;
17
18
  return theme.space['1'];
18
19
  }, ";transition:300ms transform ease-out;}&[aria-expanded='true'] ", ArrowIcon, "{transform:rotate(-180deg);}");
20
+
21
+ // This will wrap and give the positioning to the popup div that is added onto the disclosure
22
+ const StyledPositioningWrapper = /*#__PURE__*/_styled("div", {
23
+ target: "edb1sh90"
24
+ })(process.env.NODE_ENV === "production" ? {
25
+ name: "1hlymjl",
26
+ styles: "display:flex;position:sticky;top:0;bottom:0;right:0"
27
+ } : {
28
+ name: "1hlymjl",
29
+ styles: "display:flex;position:sticky;top:0;bottom:0;right:0",
30
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
31
+ });
19
32
  const TabMenu = /*#__PURE__*/forwardRef((_ref2, ref) => {
20
33
  let {
21
34
  children,
@@ -26,22 +39,26 @@ const TabMenu = /*#__PURE__*/forwardRef((_ref2, ref) => {
26
39
  className,
27
40
  ...props
28
41
  } = _ref2;
29
- return jsx(Menu, {
30
- visible: visible,
31
- id: id,
32
- ref: ref,
33
- disclosure: jsxs(StyledMenu, {
34
- role: "tab",
35
- "aria-disabled": disabled ?? 'false',
36
- disabled: disabled,
37
- "aria-haspopup": "menu",
38
- className: className,
39
- ...props,
40
- children: [disclosure, jsx(ArrowIcon, {
41
- name: "arrow-down"
42
- })]
43
- }),
44
- children: children
42
+ return jsx(StyledPositioningWrapper, {
43
+ children: jsx(MenuV2, {
44
+ visible: visible,
45
+ id: id,
46
+ ref: ref,
47
+ portalTarget: document.body // We need to attach it to the body to avoid overflow issues
48
+ ,
49
+ disclosure: jsxs(StyledMenu, {
50
+ role: "tab",
51
+ "aria-disabled": disabled ?? 'false',
52
+ disabled: disabled,
53
+ "aria-haspopup": "menu",
54
+ className: className,
55
+ ...props,
56
+ children: [disclosure, jsx(ArrowIcon, {
57
+ name: "arrow-down"
58
+ })]
59
+ }),
60
+ children: children
61
+ })
45
62
  });
46
63
  });
47
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/ui",
3
- "version": "1.27.3",
3
+ "version": "1.28.0",
4
4
  "description": "Ultraviolet UI",
5
5
  "homepage": "https://github.com/scaleway/ultraviolet#readme",
6
6
  "repository": {
@@ -39,13 +39,13 @@
39
39
  "react-dom": "18.2.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@babel/core": "7.23.3",
42
+ "@babel/core": "7.23.5",
43
43
  "@emotion/babel-plugin": "11.11.0",
44
44
  "@emotion/react": "11.11.1",
45
45
  "@emotion/styled": "11.11.0",
46
- "@types/react": "18.2.37",
46
+ "@types/react": "18.2.43",
47
47
  "@types/react-datepicker": "4.19.3",
48
- "@types/react-dom": "18.2.15",
48
+ "@types/react-dom": "18.2.17",
49
49
  "react": "18.2.0",
50
50
  "react-dom": "18.2.0"
51
51
  },
@@ -67,7 +67,7 @@
67
67
  "react-use-clipboard": "1.0.9",
68
68
  "reakit": "1.3.11",
69
69
  "@ultraviolet/themes": "1.5.0",
70
- "@ultraviolet/icons": "2.6.0"
70
+ "@ultraviolet/icons": "2.7.0"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "rollup -c ../../rollup.config.mjs"