@ultraviolet/ui 1.88.0 → 1.89.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/components/Alert/index.cjs +6 -6
- package/dist/components/Alert/index.js +1 -1
- package/dist/components/AvatarV2/index.js +1 -1
- package/dist/components/Badge/index.cjs +4 -5
- package/dist/components/Badge/index.js +0 -1
- package/dist/components/Banner/index.cjs +7 -7
- package/dist/components/Banner/index.js +7 -7
- package/dist/components/Bullet/index.cjs +0 -1
- package/dist/components/Bullet/index.js +0 -1
- package/dist/components/Card/index.cjs +8 -8
- package/dist/components/Checkbox/index.cjs +11 -11
- package/dist/components/CheckboxGroup/index.cjs +12 -12
- package/dist/components/CheckboxGroup/index.js +1 -1
- package/dist/components/Chip/index.cjs +4 -4
- package/dist/components/Chip/index.d.ts +1 -1
- package/dist/components/DateInput/components/CalendarContent.cjs +8 -8
- package/dist/components/DateInput/components/CalendarDaily.cjs +4 -4
- package/dist/components/DateInput/components/CalendarDaily.js +1 -1
- package/dist/components/DateInput/components/CalendarMonthly.cjs +4 -4
- package/dist/components/DateInput/index.cjs +9 -9
- package/dist/components/DateInput/index.js +1 -1
- package/dist/components/Dialog/{subComponents → components}/CancelButton.cjs +3 -2
- package/dist/components/Dialog/{subComponents → components}/CancelButton.d.ts +2 -1
- package/dist/components/Dialog/{subComponents → components}/CancelButton.js +3 -2
- package/dist/components/Dialog/index.cjs +13 -13
- package/dist/components/Dialog/index.d.ts +2 -1
- package/dist/components/Dialog/index.js +7 -7
- package/dist/components/Drawer/index.cjs +9 -9
- package/dist/components/EmptyState/index.cjs +11 -11
- package/dist/components/GlobalAlert/index.cjs +8 -8
- package/dist/components/Label/index.cjs +33 -7
- package/dist/components/Label/index.d.ts +9 -2
- package/dist/components/Label/index.js +31 -7
- package/dist/components/LineChart/CustomLegend.cjs +5 -5
- package/dist/components/LineChart/index.js +1 -1
- package/dist/components/Link/index.js +1 -1
- package/dist/components/List/HeaderCell.js +1 -1
- package/dist/components/List/ListContext.cjs +71 -67
- package/dist/components/List/ListContext.d.ts +5 -4
- package/dist/components/List/ListContext.js +72 -68
- package/dist/components/List/Row.cjs +24 -36
- package/dist/components/List/Row.js +19 -31
- package/dist/components/List/index.cjs +19 -4
- package/dist/components/List/index.js +21 -6
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/MenuV2/MenuContent.cjs +4 -4
- package/dist/components/MenuV2/MenuProvider.js +1 -1
- package/dist/components/MenuV2/components/Item.cjs +0 -2
- package/dist/components/MenuV2/components/Item.js +0 -2
- package/dist/components/Notification/index.cjs +6 -10
- package/dist/components/Notification/index.js +8 -12
- package/dist/components/NumberInput/index.cjs +11 -11
- package/dist/components/NumberInputV2/index.cjs +12 -12
- package/dist/components/Pagination/PerPage.cjs +7 -7
- package/dist/components/PieChart/Legends.js +1 -1
- package/dist/components/Popup/index.cjs +21 -9
- package/dist/components/Popup/index.js +22 -10
- package/dist/components/ProgressBar/index.cjs +6 -6
- package/dist/components/Radio/index.cjs +22 -21
- package/dist/components/Radio/index.d.ts +1 -1
- package/dist/components/Radio/index.js +15 -14
- package/dist/components/RadioGroup/index.js +1 -1
- package/dist/components/SelectInput/index.cjs +17 -17
- package/dist/components/SelectInput/index.js +11 -11
- package/dist/components/SelectInputV2/Dropdown.cjs +34 -34
- package/dist/components/SelectInputV2/Dropdown.js +10 -10
- package/dist/components/SelectInputV2/DropdownOption.cjs +11 -11
- package/dist/components/SelectInputV2/SelectBar.cjs +25 -24
- package/dist/components/SelectInputV2/SelectBar.d.ts +25 -1
- package/dist/components/SelectInputV2/SelectBar.js +13 -12
- package/dist/components/SelectInputV2/SelectInputProvider.js +1 -1
- package/dist/components/SelectInputV2/index.cjs +9 -9
- package/dist/components/SelectInputV2/index.d.ts +1 -1
- package/dist/components/SelectInputV2/index.js +3 -3
- package/dist/components/SelectableCard/index.cjs +49 -36
- package/dist/components/SelectableCard/index.js +43 -30
- package/dist/components/SelectableCardGroup/index.js +1 -1
- package/dist/components/SelectableCardOptionGroup/Provider.cjs +24 -0
- package/dist/components/SelectableCardOptionGroup/Provider.d.ts +15 -0
- package/dist/components/SelectableCardOptionGroup/Provider.js +24 -0
- package/dist/components/SelectableCardOptionGroup/components/Image.cjs +39 -0
- package/dist/components/SelectableCardOptionGroup/components/Image.d.ts +9 -0
- package/dist/components/SelectableCardOptionGroup/components/Image.js +37 -0
- package/dist/components/SelectableCardOptionGroup/components/Option.cjs +117 -0
- package/dist/components/SelectableCardOptionGroup/components/Option.d.ts +16 -0
- package/dist/components/SelectableCardOptionGroup/components/Option.js +115 -0
- package/dist/components/SelectableCardOptionGroup/index.cjs +67 -0
- package/dist/components/SelectableCardOptionGroup/index.d.ts +45 -0
- package/dist/components/SelectableCardOptionGroup/index.js +65 -0
- package/dist/components/SelectableCardOptionGroup/types.d.ts +1 -0
- package/dist/components/Slider/components/DoubleSlider.cjs +14 -14
- package/dist/components/Slider/components/DoubleSlider.js +9 -9
- package/dist/components/Slider/components/SingleSlider.cjs +24 -16
- package/dist/components/Slider/components/SingleSlider.js +20 -12
- package/dist/components/Snippet/index.cjs +9 -9
- package/dist/components/Stepper/Step.cjs +6 -6
- package/dist/components/Stepper/StepperProvider.js +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/SwitchButton/index.cjs +4 -4
- package/dist/components/Table/HeaderCell.cjs +4 -4
- package/dist/components/Table/HeaderCell.js +1 -1
- package/dist/components/Table/Row.cjs +25 -37
- package/dist/components/Table/Row.js +20 -32
- package/dist/components/Table/TableContext.js +1 -1
- package/dist/components/Table/index.cjs +20 -4
- package/dist/components/Table/index.d.ts +6 -5
- package/dist/components/Table/index.js +22 -6
- package/dist/components/Tabs/Tab.cjs +4 -4
- package/dist/components/Tag/index.cjs +10 -10
- package/dist/components/Text/index.cjs +4 -3
- package/dist/components/Text/index.d.ts +2 -1
- package/dist/components/Text/index.js +4 -3
- package/dist/components/TextInput/index.cjs +14 -14
- package/dist/components/TimeInputV2/index.cjs +7 -7
- package/dist/components/TimeInputV2/index.js +2 -2
- package/dist/components/Toaster/index.cjs +10 -14
- package/dist/components/Toaster/index.js +7 -11
- package/dist/components/ToggleGroup/index.js +1 -1
- package/dist/components/UnitInput/index.cjs +6 -6
- package/dist/components/index.d.ts +1 -0
- package/dist/index.cjs +61 -59
- package/dist/index.js +2 -0
- package/dist/types.d.ts +6 -0
- package/package.json +5 -5
- package/dist/components/Notification/react-toastify.css.cjs +0 -3
- package/dist/components/Notification/react-toastify.css.js +0 -4
- package/dist/components/Slider/components/Label.cjs +0 -17
- package/dist/components/Slider/components/Label.d.ts +0 -2
- package/dist/components/Slider/components/Label.js +0 -17
- package/dist/components/Toaster/react-toastify.css.cjs +0 -3
- package/dist/components/Toaster/react-toastify.css.js +0 -4
- /package/dist/components/Dialog/{subComponents → components}/Button.cjs +0 -0
- /package/dist/components/Dialog/{subComponents → components}/Button.d.ts +0 -0
- /package/dist/components/Dialog/{subComponents → components}/Button.js +0 -0
- /package/dist/components/Dialog/{subComponents → components}/Buttons.cjs +0 -0
- /package/dist/components/Dialog/{subComponents → components}/Buttons.d.ts +0 -0
- /package/dist/components/Dialog/{subComponents → components}/Buttons.js +0 -0
- /package/dist/components/Dialog/{subComponents → components}/Stack.cjs +0 -0
- /package/dist/components/Dialog/{subComponents → components}/Stack.d.ts +0 -0
- /package/dist/components/Dialog/{subComponents → components}/Stack.js +0 -0
- /package/dist/components/Dialog/{subComponents → components}/Text.cjs +0 -0
- /package/dist/components/Dialog/{subComponents → components}/Text.d.ts +0 -0
- /package/dist/components/Dialog/{subComponents → components}/Text.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { createContext, useState,
|
|
2
|
+
import { useContext, createContext, useState, useCallback, useMemo, useEffect } from "react";
|
|
3
3
|
const ListContext = createContext(void 0);
|
|
4
4
|
const checkStateOfCheckboxs = (ids) => {
|
|
5
5
|
const selectableRowCount = Object.keys(ids).length;
|
|
@@ -22,9 +22,9 @@ const ListProvider = ({
|
|
|
22
22
|
}) => {
|
|
23
23
|
const [expandedRowIds, setExpandedRowIds] = useState({});
|
|
24
24
|
const [selectedRowIds, setSelectedRowIds] = useState({});
|
|
25
|
-
const [
|
|
26
|
-
const [inRange, setInRange] = useState(
|
|
27
|
-
const refList =
|
|
25
|
+
const [lastCheckedCheckbox, setLastCheckedCheckbox] = useState();
|
|
26
|
+
const [inRange, setInRange] = useState([]);
|
|
27
|
+
const [refList, setRefList] = useState([]);
|
|
28
28
|
const registerExpandableRow = useCallback((rowId, expanded = false) => {
|
|
29
29
|
setExpandedRowIds((current) => ({
|
|
30
30
|
...current,
|
|
@@ -100,77 +100,79 @@ const ListProvider = ({
|
|
|
100
100
|
}, [allRowSelectValue, unselectAll, selectAll]);
|
|
101
101
|
const subscribeHandler = useCallback(() => {
|
|
102
102
|
const handlers = [];
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const isClickInsideRange = inRange.has(checkbox.value);
|
|
117
|
-
if (shouldShiftEvent && isClickInsideRange) {
|
|
118
|
-
let checkboxRows = {};
|
|
119
|
-
refList.current.forEach((value2, key) => {
|
|
120
|
-
if (inRange.has(key)) {
|
|
121
|
-
checkboxRows = {
|
|
122
|
-
...checkboxRows,
|
|
123
|
-
// handle the conflict event ( click and onChange in the same time on the last checkbox click)
|
|
124
|
-
[key]: key === checkbox.value ? !value2.checked : value2.checked
|
|
125
|
-
};
|
|
103
|
+
const updatedRefList = [...new Set(refList.filter((checkbox) => document.contains(checkbox.current) && checkbox.current))];
|
|
104
|
+
setRefList(updatedRefList);
|
|
105
|
+
const handleHover = (index, isShiftPressed, leaving) => {
|
|
106
|
+
const newRange = [];
|
|
107
|
+
if (lastCheckedCheckbox) {
|
|
108
|
+
const targetCheckbox = updatedRefList.find((checkbox) => checkbox.current?.value === lastCheckedCheckbox);
|
|
109
|
+
if (isShiftPressed && targetCheckbox && !leaving) {
|
|
110
|
+
const lastCheckedIndex = updatedRefList.indexOf(targetCheckbox);
|
|
111
|
+
const start = Math.min(lastCheckedIndex, index) - (Math.min(lastCheckedIndex, index) === index ? 1 : 0);
|
|
112
|
+
const end = Math.max(lastCheckedIndex, index);
|
|
113
|
+
updatedRefList.forEach((checkbox, i) => {
|
|
114
|
+
if (!checkbox.current?.disabled && i > start && i < end) {
|
|
115
|
+
newRange.push(checkbox.current?.value);
|
|
126
116
|
}
|
|
127
117
|
});
|
|
128
|
-
const state = checkStateOfCheckboxs(checkboxRows);
|
|
129
|
-
const checkboxIds = Object.keys(checkboxRows);
|
|
130
|
-
if (state === true) {
|
|
131
|
-
selectRows(checkboxIds, false);
|
|
132
|
-
}
|
|
133
|
-
if ([false, "indeterminate"].includes(state)) {
|
|
134
|
-
selectRows(checkboxIds, true);
|
|
135
|
-
}
|
|
136
118
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
119
|
+
}
|
|
120
|
+
setInRange(newRange);
|
|
121
|
+
};
|
|
122
|
+
const handleClickRange = (currentCheckbox, index, isShiftPressed) => {
|
|
123
|
+
if (isShiftPressed) {
|
|
124
|
+
const checkboxesInRange = [];
|
|
125
|
+
const targetCheckbox = updatedRefList.find((checkbox) => checkbox.current?.value === lastCheckedCheckbox);
|
|
126
|
+
const lastCheckedIndex = targetCheckbox ? updatedRefList.indexOf(targetCheckbox) : void 0;
|
|
127
|
+
if (lastCheckedIndex !== void 0) {
|
|
128
|
+
const start = Math.min(lastCheckedIndex, index) - (Math.min(lastCheckedIndex, index) === index ? 1 : 0);
|
|
129
|
+
const end = Math.max(lastCheckedIndex, index);
|
|
130
|
+
updatedRefList.forEach((checkbox, key) => {
|
|
131
|
+
if (start < key && key <= end) {
|
|
132
|
+
if (!checkbox.current?.disabled) {
|
|
133
|
+
checkboxesInRange.push(checkbox.current?.value);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
selectRows(checkboxesInRange, currentCheckbox.checked);
|
|
138
|
+
setLastCheckedCheckbox(currentCheckbox.value);
|
|
146
139
|
}
|
|
147
|
-
|
|
140
|
+
} else if (index === 0) setLastCheckedCheckbox(void 0);
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
setInRange([]);
|
|
143
|
+
setLastCheckedCheckbox(currentCheckbox.value);
|
|
144
|
+
}, 1);
|
|
145
|
+
};
|
|
146
|
+
refList.forEach((checkbox, index) => {
|
|
147
|
+
const clickHandler = function clickHandler2(event) {
|
|
148
|
+
handleClickRange(this, index, event.shiftKey);
|
|
148
149
|
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
};
|
|
156
|
-
const changeHandler = (event) => {
|
|
157
|
-
handleOnChange(event.currentTarget);
|
|
158
|
-
};
|
|
159
|
-
checkbox.addEventListener("change", changeHandler);
|
|
160
|
-
checkbox.addEventListener("click", clickHandler);
|
|
161
|
-
checkbox.addEventListener("mouseover", hoverHandler);
|
|
150
|
+
const hoverEnteringHandler = (event) => handleHover(index, event.shiftKey, false);
|
|
151
|
+
const hoverLeavingHandler = (event) => handleHover(index, event.shiftKey, true);
|
|
152
|
+
if (checkbox.current) {
|
|
153
|
+
checkbox.current.addEventListener("click", clickHandler);
|
|
154
|
+
checkbox.current.addEventListener("mousemove", hoverEnteringHandler);
|
|
155
|
+
checkbox.current.addEventListener("mouseout", hoverLeavingHandler);
|
|
162
156
|
handlers.push(() => {
|
|
163
|
-
checkbox.
|
|
164
|
-
|
|
165
|
-
|
|
157
|
+
if (checkbox.current) {
|
|
158
|
+
checkbox.current.removeEventListener("click", clickHandler);
|
|
159
|
+
checkbox.current.removeEventListener("mouseout", hoverEnteringHandler);
|
|
160
|
+
checkbox.current.removeEventListener("mousemove", hoverLeavingHandler);
|
|
161
|
+
}
|
|
166
162
|
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
169
165
|
return () => {
|
|
170
166
|
handlers.forEach((cleanup) => cleanup());
|
|
171
167
|
};
|
|
172
|
-
}, [
|
|
173
|
-
useEffect(
|
|
168
|
+
}, [lastCheckedCheckbox, selectRows]);
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
subscribeHandler();
|
|
171
|
+
}, [subscribeHandler]);
|
|
172
|
+
const handleOnChange = useCallback((value2, checked) => {
|
|
173
|
+
selectRows([value2], !checked);
|
|
174
|
+
setLastCheckedCheckbox(value2);
|
|
175
|
+
}, [selectRows]);
|
|
174
176
|
const value = useMemo(() => ({
|
|
175
177
|
allRowSelectValue,
|
|
176
178
|
selectAllHandler,
|
|
@@ -181,7 +183,6 @@ const ListProvider = ({
|
|
|
181
183
|
expandedRowIds,
|
|
182
184
|
expandRow,
|
|
183
185
|
inRange,
|
|
184
|
-
mapCheckbox: refList.current,
|
|
185
186
|
registerExpandableRow,
|
|
186
187
|
registerSelectableRow,
|
|
187
188
|
selectable,
|
|
@@ -189,8 +190,11 @@ const ListProvider = ({
|
|
|
189
190
|
selectedRowIds,
|
|
190
191
|
selectRow,
|
|
191
192
|
unselectAll,
|
|
192
|
-
unselectRow
|
|
193
|
-
|
|
193
|
+
unselectRow,
|
|
194
|
+
refList,
|
|
195
|
+
setRefList,
|
|
196
|
+
handleOnChange
|
|
197
|
+
}), [allRowSelectValue, selectAllHandler, subscribeHandler, collapseRow, columns, expandButton, expandedRowIds, expandRow, inRange, refList, registerExpandableRow, registerSelectableRow, selectable, selectAll, selectedRowIds, selectRow, unselectAll, unselectRow, handleOnChange]);
|
|
194
198
|
return /* @__PURE__ */ jsx(ListContext.Provider, { value, children });
|
|
195
199
|
};
|
|
196
200
|
const useListContext = () => {
|