@ultraviolet/ui 1.45.6 → 1.46.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
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import react__default, { ReactNode, ComponentProps, ButtonHTMLAttributes, AriaRole, MouseEventHandler, JSX, MouseEvent, InputHTMLAttributes, FocusEvent, HTMLAttributeAnchorTarget, AnchorHTMLAttributes, ReactElement, Ref, RefObject, KeyboardEventHandler, HTMLAttributes, CSSProperties, ChangeEventHandler, FocusEventHandler, ForwardRefExoticComponent, ForwardedRef, ElementType, DOMAttributes, TextareaHTMLAttributes } from 'react';
2
+ import react__default, { ReactNode, ComponentProps, ButtonHTMLAttributes, AriaRole, MouseEventHandler, JSX, MouseEvent, InputHTMLAttributes, FocusEvent, HTMLAttributeAnchorTarget, AnchorHTMLAttributes, Dispatch, SetStateAction, ReactElement, Ref, RefObject, KeyboardEventHandler, HTMLAttributes, CSSProperties, ChangeEventHandler, FocusEventHandler, ForwardRefExoticComponent, ForwardedRef, ElementType, DOMAttributes, TextareaHTMLAttributes } from 'react';
3
3
  import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
4
4
  import * as _emotion_styled from '@emotion/styled';
5
5
  import * as _emotion_react from '@emotion/react';
@@ -1803,6 +1803,10 @@ type ListProps = {
1803
1803
  * Auto collapse is collapsing expandable row when another is expanding
1804
1804
  * */
1805
1805
  autoCollapse?: boolean;
1806
+ /**
1807
+ * Action when selection changes (get the list of selected rows)
1808
+ */
1809
+ onSelectedChange?: Dispatch<SetStateAction<string[]>>;
1806
1810
  };
1807
1811
  /**
1808
1812
  * List is a component that displays a list of items based on the columns you provide and the data you pass.
@@ -2323,7 +2327,7 @@ type PopupProps = {
2323
2327
  */
2324
2328
  declare const Popup: react.ForwardRefExoticComponent<PopupProps & react.RefAttributes<HTMLDivElement>>;
2325
2329
 
2326
- declare const progressBarSentiments: readonly ["primary", "success", "warning", "info"];
2330
+ declare const progressBarSentiments: readonly ["primary", "success", "warning", "info", "danger"];
2327
2331
  type ProgressBarProps = {
2328
2332
  sentiment?: (typeof progressBarSentiments)[number];
2329
2333
  value?: number;
@@ -6,7 +6,8 @@ const ListProvider = ({
6
6
  children,
7
7
  autoCollapse,
8
8
  selectable,
9
- expandButton
9
+ expandButton,
10
+ onSelectedChange
10
11
  }) => {
11
12
  const [expandedRowIds, setExpandedRowIds] = useState({});
12
13
  const [selectedRowIds, setSelectedRowIds] = useState({});
@@ -67,29 +68,45 @@ const ListProvider = ({
67
68
  return 'indeterminate';
68
69
  }, [selectedRowIds]);
69
70
  const selectAll = useCallback(() => {
70
- setSelectedRowIds(current => Object.keys(current).reduce((acc, rowId) => ({
71
+ const newSelectedRowIds = Object.keys(selectedRowIds).reduce((acc, rowId) => ({
71
72
  ...acc,
72
73
  [rowId]: true
73
- }), {}));
74
- }, []);
74
+ }), {});
75
+ setSelectedRowIds(newSelectedRowIds);
76
+ if (onSelectedChange) {
77
+ onSelectedChange(Object.keys(newSelectedRowIds).filter(row => newSelectedRowIds[row]));
78
+ }
79
+ }, [onSelectedChange, selectedRowIds]);
75
80
  const unselectAll = useCallback(() => {
76
- setSelectedRowIds(current => Object.keys(current).reduce((acc, rowId) => ({
81
+ const newSelectedRowIds = Object.keys(selectedRowIds).reduce((acc, rowId) => ({
77
82
  ...acc,
78
83
  [rowId]: false
79
- }), {}));
80
- }, []);
84
+ }), {});
85
+ setSelectedRowIds(newSelectedRowIds);
86
+ if (onSelectedChange) {
87
+ onSelectedChange(Object.keys(newSelectedRowIds).filter(row => newSelectedRowIds[row]));
88
+ }
89
+ }, [onSelectedChange, selectedRowIds]);
81
90
  const selectRow = useCallback(rowId => {
82
- setSelectedRowIds(current => ({
83
- ...current,
91
+ const newSelectedRowIds = {
92
+ ...selectedRowIds,
84
93
  [rowId]: true
85
- }));
86
- }, []);
94
+ };
95
+ setSelectedRowIds(newSelectedRowIds);
96
+ if (onSelectedChange) {
97
+ onSelectedChange(Object.keys(newSelectedRowIds).filter(row => newSelectedRowIds[row]));
98
+ }
99
+ }, [onSelectedChange, selectedRowIds]);
87
100
  const unselectRow = useCallback(rowId => {
88
- setSelectedRowIds(current => ({
89
- ...current,
101
+ const newSelectedRowIds = {
102
+ ...selectedRowIds,
90
103
  [rowId]: false
91
- }));
92
- }, []);
104
+ };
105
+ setSelectedRowIds(newSelectedRowIds);
106
+ if (onSelectedChange) {
107
+ onSelectedChange(Object.keys(newSelectedRowIds).filter(row => newSelectedRowIds[row]));
108
+ }
109
+ }, [onSelectedChange, selectedRowIds]);
93
110
  const value = useMemo(() => ({
94
111
  registerExpandableRow,
95
112
  expandedRowIds,
@@ -25,7 +25,8 @@ const BaseList = /*#__PURE__*/forwardRef(({
25
25
  columns,
26
26
  children,
27
27
  loading,
28
- autoCollapse = false
28
+ autoCollapse = false,
29
+ onSelectedChange
29
30
  }, ref) => {
30
31
  const computeTemplate = `${selectable ? `${SELECTABLE_CHECKBOX_SIZE}px ` : ''}${expandable ? `${EXPANDABLE_COLUMN_SIZE}px ` : ''}${columns.map(({
31
32
  width
@@ -34,6 +35,7 @@ const BaseList = /*#__PURE__*/forwardRef(({
34
35
  selectable: selectable,
35
36
  expandButton: expandable,
36
37
  autoCollapse: autoCollapse,
38
+ onSelectedChange: onSelectedChange,
37
39
  children: jsxs(StyledList, {
38
40
  ref: ref,
39
41
  role: "grid",
@@ -58,7 +58,6 @@ const toast = {
58
58
  /**
59
59
  * @deprecated "Deprecated, please use another variant instead"
60
60
  */
61
- // eslint-disable-next-line deprecation/deprecation
62
61
  info: (children, options, containerId) => toast$1.info(jsx(Content, {
63
62
  children: children
64
63
  }), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/ui",
3
- "version": "1.45.6",
3
+ "version": "1.46.0",
4
4
  "description": "Ultraviolet UI",
5
5
  "homepage": "https://github.com/scaleway/ultraviolet#readme",
6
6
  "repository": {
@@ -39,7 +39,7 @@
39
39
  "react-dom": "18.2.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@babel/core": "7.24.3",
42
+ "@babel/core": "7.24.4",
43
43
  "@emotion/babel-plugin": "11.11.0",
44
44
  "@emotion/react": "11.11.4",
45
45
  "@emotion/styled": "11.11.5",
@@ -65,7 +65,7 @@
65
65
  "react-use-clipboard": "1.0.9",
66
66
  "reakit": "1.3.11",
67
67
  "@ultraviolet/themes": "1.10.0",
68
- "@ultraviolet/icons": "2.12.2"
68
+ "@ultraviolet/icons": "2.12.3"
69
69
  },
70
70
  "scripts": {
71
71
  "build": "rollup -c ../../rollup.config.mjs",