@ultraviolet/ui 1.88.1 → 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/Banner/index.cjs +7 -7
- package/dist/components/Banner/index.js +7 -7
- package/dist/components/Chip/index.d.ts +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 +7 -7
- package/dist/components/Dialog/index.d.ts +2 -1
- package/dist/components/Dialog/index.js +7 -7
- 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/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 +19 -31
- package/dist/components/List/Row.js +19 -31
- package/dist/components/List/index.cjs +19 -4
- package/dist/components/List/index.js +20 -5
- package/dist/components/Popup/index.cjs +21 -9
- package/dist/components/Popup/index.js +21 -9
- package/dist/components/Radio/index.cjs +15 -14
- package/dist/components/Radio/index.d.ts +1 -1
- package/dist/components/Radio/index.js +15 -14
- package/dist/components/SelectInputV2/Dropdown.cjs +10 -10
- package/dist/components/SelectInputV2/Dropdown.js +10 -10
- package/dist/components/SelectInputV2/SelectBar.cjs +11 -10
- package/dist/components/SelectInputV2/SelectBar.d.ts +25 -1
- package/dist/components/SelectInputV2/SelectBar.js +12 -11
- package/dist/components/SelectInputV2/index.cjs +3 -3
- package/dist/components/SelectInputV2/index.d.ts +1 -1
- package/dist/components/SelectInputV2/index.js +3 -3
- package/dist/components/SelectableCard/index.cjs +43 -30
- package/dist/components/SelectableCard/index.js +43 -30
- 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 +12 -12
- package/dist/components/Slider/components/DoubleSlider.js +8 -8
- package/dist/components/Slider/components/SingleSlider.cjs +22 -14
- package/dist/components/Slider/components/SingleSlider.js +19 -11
- package/dist/components/Table/Row.cjs +20 -32
- package/dist/components/Table/Row.js +20 -32
- package/dist/components/Table/index.cjs +20 -4
- package/dist/components/Table/index.d.ts +6 -5
- package/dist/components/Table/index.js +21 -5
- 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/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 +2 -2
- 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/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,27 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
|
+
const _styled = require("@emotion/styled/base");
|
|
4
5
|
const index = require("../Stack/index.cjs");
|
|
5
6
|
const index$1 = require("../Text/index.cjs");
|
|
7
|
+
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
8
|
+
const _styled__default = /* @__PURE__ */ _interopDefaultCompat(_styled);
|
|
9
|
+
const TextPointer = /* @__PURE__ */ _styled__default.default(index$1.Text, process.env.NODE_ENV === "production" ? {
|
|
10
|
+
target: "eranz9i0"
|
|
11
|
+
} : {
|
|
12
|
+
target: "eranz9i0",
|
|
13
|
+
label: "TextPointer"
|
|
14
|
+
})("cursor:", ({
|
|
15
|
+
disabled,
|
|
16
|
+
htmlFor
|
|
17
|
+
}) => {
|
|
18
|
+
if (disabled) {
|
|
19
|
+
return "not-allowed";
|
|
20
|
+
}
|
|
21
|
+
if (htmlFor) {
|
|
22
|
+
return "pointer";
|
|
23
|
+
}
|
|
24
|
+
return "text";
|
|
25
|
+
}, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL3J1bm5lci93b3JrL3VsdHJhdmlvbGV0L3VsdHJhdmlvbGV0L3BhY2thZ2VzL3VpL3NyYy9jb21wb25lbnRzL0xhY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2h0bWxGb3J9XG4gICAgICAgIGlkPXtpZH1cbiAgICAgICAgYXM9e2FzfVxuICAgICAgICBzZW50aW1lbnQ9e3NlbnRpbWVudH1cbiAgICAgICAgZGlzYWJsZWQ9e2Rpc2FibGVkfVxuICAgICAgPlxuICAgICAgICB7Y2hpbGRyZW59XG4gICAgICA8L0xhYmVsUmVxdWlyZWRPck5vdD5cbiAgICAgIHt0eXBlb2YgbGFiZWxEZXNjcmlwdGlvbiA9PT0gJ3N0cmluZycgPyAoXG4gICAgICAgIDxUZXh0IGFzPVwic3BhblwiIHZhcmlhbnQ9XCJib2R5U21hbGxcIj5cbiAgICAgICAgICB7bGFiZWxEZXNjcmlwdGlvbn1cbiAgICAgICAgPC9UZXh0PlxuICAgICAgKSA6IChcbiAgICAgICAgbGFiZWxEZXNjcmlwdGlvblxuICAgICAgKX1cbiAgICA8L1N0YWNrPlxuICApIDogKFxuICAgIDxMYWJlbFJlcXVpcmVkT3JOb3RcbiAgICAgIHJlcXVpcmVkPXtyZXF1aXJlZH1cbiAgICAgIHNpemU9e3NpemV9XG4gICAgICBodG1sRm9yPXtodG1sRm9yfVxuICAgICAgaWQ9e2lkfVxuICAgICAgYXM9e2FzfVxuICAgICAgc2VudGltZW50PXtzZW50aW1lbnR9XG4gICAgICBkaXNhYmxlZD17ZGlzYWJsZWR9XG4gICAgPlxuICAgICAge2NoaWxkcmVufVxuICAgIDwvTGFiZWxSZXF1aXJlZE9yTm90PlxuICApXG4iXX0= */"));
|
|
6
26
|
const LabelRequiredOrNot = ({
|
|
7
27
|
children,
|
|
8
28
|
required,
|
|
9
29
|
id,
|
|
10
30
|
size,
|
|
11
|
-
htmlFor
|
|
31
|
+
htmlFor,
|
|
32
|
+
as,
|
|
33
|
+
sentiment,
|
|
34
|
+
disabled
|
|
12
35
|
}) => required ? /* @__PURE__ */ jsxRuntime.jsxs(index.Stack, { direction: "row", gap: "0.5", alignItems: "start", children: [
|
|
13
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
14
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$1.Text, { as: "span", variant: size === "large" ? "bodyStrong" : "bodySmallStrong", sentiment: "danger", "aria-label": "required", children: "*" })
|
|
15
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
36
|
+
/* @__PURE__ */ jsxRuntime.jsx(TextPointer, { as: as === "label" ? "label" : "legend", id, variant: size === "large" ? "bodyStrong" : "bodySmallStrong", sentiment, htmlFor, disabled, children }),
|
|
37
|
+
/* @__PURE__ */ jsxRuntime.jsx(index$1.Text, { as: "span", variant: size === "large" ? "bodyStrong" : "bodySmallStrong", sentiment: "danger", "aria-label": "required", disabled, children: "*" })
|
|
38
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(TextPointer, { as: as === "label" ? "label" : "legend", id, variant: size === "large" ? "bodyStrong" : "bodySmallStrong", sentiment, htmlFor, disabled, children });
|
|
16
39
|
const Label = ({
|
|
40
|
+
as = "label",
|
|
17
41
|
children,
|
|
18
42
|
labelDescription,
|
|
19
43
|
required,
|
|
20
44
|
size = "large",
|
|
21
45
|
htmlFor,
|
|
22
|
-
id
|
|
46
|
+
id,
|
|
47
|
+
sentiment = "neutral",
|
|
48
|
+
disabled
|
|
23
49
|
}) => labelDescription ? /* @__PURE__ */ jsxRuntime.jsxs(index.Stack, { direction: "row", gap: "1", alignItems: "center", children: [
|
|
24
|
-
/* @__PURE__ */ jsxRuntime.jsx(LabelRequiredOrNot, { required, size, htmlFor, id, children }),
|
|
50
|
+
/* @__PURE__ */ jsxRuntime.jsx(LabelRequiredOrNot, { required, size, htmlFor, id, as, sentiment, disabled, children }),
|
|
25
51
|
typeof labelDescription === "string" ? /* @__PURE__ */ jsxRuntime.jsx(index$1.Text, { as: "span", variant: "bodySmall", children: labelDescription }) : labelDescription
|
|
26
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(LabelRequiredOrNot, { required, size, htmlFor, id, children });
|
|
52
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(LabelRequiredOrNot, { required, size, htmlFor, id, as, sentiment, disabled, children });
|
|
27
53
|
exports.Label = Label;
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
import { Text } from '../Text';
|
|
2
3
|
type LabelProps = {
|
|
4
|
+
/**
|
|
5
|
+
* As can help you to define a label or a legend in case you are using it inside a fieldset
|
|
6
|
+
*/
|
|
7
|
+
as?: 'label' | 'legend';
|
|
3
8
|
children?: string;
|
|
4
9
|
labelDescription?: ReactNode;
|
|
5
10
|
required?: boolean;
|
|
6
11
|
size?: 'small' | 'medium' | 'large';
|
|
7
12
|
htmlFor?: string;
|
|
8
13
|
id?: string;
|
|
14
|
+
sentiment?: ComponentProps<typeof Text>['sentiment'];
|
|
15
|
+
disabled?: boolean;
|
|
9
16
|
};
|
|
10
17
|
/**
|
|
11
18
|
* Label is used inside all of our input components, but it can be used outside for design purposes
|
|
12
19
|
*/
|
|
13
|
-
export declare const Label: ({ children, labelDescription, required, size, htmlFor, id, }: LabelProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare const Label: ({ as, children, labelDescription, required, size, htmlFor, id, sentiment, disabled, }: LabelProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
14
21
|
export {};
|
|
@@ -1,27 +1,51 @@
|
|
|
1
1
|
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import _styled from "@emotion/styled/base";
|
|
2
3
|
import { Stack } from "../Stack/index.js";
|
|
3
4
|
import { Text } from "../Text/index.js";
|
|
5
|
+
const TextPointer = /* @__PURE__ */ _styled(Text, process.env.NODE_ENV === "production" ? {
|
|
6
|
+
target: "eranz9i0"
|
|
7
|
+
} : {
|
|
8
|
+
target: "eranz9i0",
|
|
9
|
+
label: "TextPointer"
|
|
10
|
+
})("cursor:", ({
|
|
11
|
+
disabled,
|
|
12
|
+
htmlFor
|
|
13
|
+
}) => {
|
|
14
|
+
if (disabled) {
|
|
15
|
+
return "not-allowed";
|
|
16
|
+
}
|
|
17
|
+
if (htmlFor) {
|
|
18
|
+
return "pointer";
|
|
19
|
+
}
|
|
20
|
+
return "text";
|
|
21
|
+
}, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL3J1bm5lci93b3JrL3VsdHJhdmlvbGV0L3VsdHJhdmlvbGV0L3BhY2thZ2VzL3VpL3NyYy9jb21wb25lbnRzL0xhYmVsL2luZGV4LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLZ0MiLCJmaWxlIjoiL2hvbWUvcnVubmVyL3dvcmsvdWx0cmF2aW9sZXQvdWx0cmF2aW9sZXQvcGFja2FnZXMvdWkvc3JjL2NvbXBvbmVudHMvTGFiZWwvaW5kZXgudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnXG5pbXBvcnQgdHlwZSB7IENvbXBvbmVudFByb3BzLCBSZWFjdE5vZGUgfSBmcm9tICdyZWFjdCdcbmltcG9ydCB7IFN0YWNrIH0gZnJvbSAnLi4vU3RhY2snXG5pbXBvcnQgeyBUZXh0IH0gZnJvbSAnLi4vVGV4dCdcblxuY29uc3QgVGV4dFBvaW50ZXIgPSBzdHlsZWQoVGV4dClgXG4gIGN1cnNvcjogJHsoeyBkaXNhYmxlZCwgaHRtbEZvciB9KSA9PiB7XG4gICAgaWYgKGRpc2FibGVkKSB7XG4gICAgICByZXR1cm4gJ25vdC1hbGxvd2VkJ1xuICAgIH1cblxuICAgIGlmIChodG1sRm9yKSB7XG4gICAgICByZXR1cm4gJ3BvaW50ZXInXG4gICAgfVxuXG4gICAgcmV0dXJuICd0ZXh0J1xuICB9fTtcbmBcblxuY29uc3QgTGFiZWxSZXF1aXJlZ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xkcmVufVxuICAgIDwvTGFiZWxSZXF1aXJlZE9yTm90PlxuICApXG4iXX0= */"));
|
|
4
22
|
const LabelRequiredOrNot = ({
|
|
5
23
|
children,
|
|
6
24
|
required,
|
|
7
25
|
id,
|
|
8
26
|
size,
|
|
9
|
-
htmlFor
|
|
27
|
+
htmlFor,
|
|
28
|
+
as,
|
|
29
|
+
sentiment,
|
|
30
|
+
disabled
|
|
10
31
|
}) => required ? /* @__PURE__ */ jsxs(Stack, { direction: "row", gap: "0.5", alignItems: "start", children: [
|
|
11
|
-
/* @__PURE__ */ jsx(
|
|
12
|
-
/* @__PURE__ */ jsx(Text, { as: "span", variant: size === "large" ? "bodyStrong" : "bodySmallStrong", sentiment: "danger", "aria-label": "required", children: "*" })
|
|
13
|
-
] }) : /* @__PURE__ */ jsx(
|
|
32
|
+
/* @__PURE__ */ jsx(TextPointer, { as: as === "label" ? "label" : "legend", id, variant: size === "large" ? "bodyStrong" : "bodySmallStrong", sentiment, htmlFor, disabled, children }),
|
|
33
|
+
/* @__PURE__ */ jsx(Text, { as: "span", variant: size === "large" ? "bodyStrong" : "bodySmallStrong", sentiment: "danger", "aria-label": "required", disabled, children: "*" })
|
|
34
|
+
] }) : /* @__PURE__ */ jsx(TextPointer, { as: as === "label" ? "label" : "legend", id, variant: size === "large" ? "bodyStrong" : "bodySmallStrong", sentiment, htmlFor, disabled, children });
|
|
14
35
|
const Label = ({
|
|
36
|
+
as = "label",
|
|
15
37
|
children,
|
|
16
38
|
labelDescription,
|
|
17
39
|
required,
|
|
18
40
|
size = "large",
|
|
19
41
|
htmlFor,
|
|
20
|
-
id
|
|
42
|
+
id,
|
|
43
|
+
sentiment = "neutral",
|
|
44
|
+
disabled
|
|
21
45
|
}) => labelDescription ? /* @__PURE__ */ jsxs(Stack, { direction: "row", gap: "1", alignItems: "center", children: [
|
|
22
|
-
/* @__PURE__ */ jsx(LabelRequiredOrNot, { required, size, htmlFor, id, children }),
|
|
46
|
+
/* @__PURE__ */ jsx(LabelRequiredOrNot, { required, size, htmlFor, id, as, sentiment, disabled, children }),
|
|
23
47
|
typeof labelDescription === "string" ? /* @__PURE__ */ jsx(Text, { as: "span", variant: "bodySmall", children: labelDescription }) : labelDescription
|
|
24
|
-
] }) : /* @__PURE__ */ jsx(LabelRequiredOrNot, { required, size, htmlFor, id, children });
|
|
48
|
+
] }) : /* @__PURE__ */ jsx(LabelRequiredOrNot, { required, size, htmlFor, id, as, sentiment, disabled, children });
|
|
25
49
|
export {
|
|
26
50
|
Label
|
|
27
51
|
};
|
|
@@ -24,9 +24,9 @@ const ListProvider = ({
|
|
|
24
24
|
}) => {
|
|
25
25
|
const [expandedRowIds, setExpandedRowIds] = React.useState({});
|
|
26
26
|
const [selectedRowIds, setSelectedRowIds] = React.useState({});
|
|
27
|
-
const [
|
|
28
|
-
const [inRange, setInRange] = React.useState(
|
|
29
|
-
const refList = React.
|
|
27
|
+
const [lastCheckedCheckbox, setLastCheckedCheckbox] = React.useState();
|
|
28
|
+
const [inRange, setInRange] = React.useState([]);
|
|
29
|
+
const [refList, setRefList] = React.useState([]);
|
|
30
30
|
const registerExpandableRow = React.useCallback((rowId, expanded = false) => {
|
|
31
31
|
setExpandedRowIds((current) => ({
|
|
32
32
|
...current,
|
|
@@ -102,77 +102,79 @@ const ListProvider = ({
|
|
|
102
102
|
}, [allRowSelectValue, unselectAll, selectAll]);
|
|
103
103
|
const subscribeHandler = React.useCallback(() => {
|
|
104
104
|
const handlers = [];
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const isClickInsideRange = inRange.has(checkbox.value);
|
|
119
|
-
if (shouldShiftEvent && isClickInsideRange) {
|
|
120
|
-
let checkboxRows = {};
|
|
121
|
-
refList.current.forEach((value2, key) => {
|
|
122
|
-
if (inRange.has(key)) {
|
|
123
|
-
checkboxRows = {
|
|
124
|
-
...checkboxRows,
|
|
125
|
-
// handle the conflict event ( click and onChange in the same time on the last checkbox click)
|
|
126
|
-
[key]: key === checkbox.value ? !value2.checked : value2.checked
|
|
127
|
-
};
|
|
105
|
+
const updatedRefList = [...new Set(refList.filter((checkbox) => document.contains(checkbox.current) && checkbox.current))];
|
|
106
|
+
setRefList(updatedRefList);
|
|
107
|
+
const handleHover = (index, isShiftPressed, leaving) => {
|
|
108
|
+
const newRange = [];
|
|
109
|
+
if (lastCheckedCheckbox) {
|
|
110
|
+
const targetCheckbox = updatedRefList.find((checkbox) => checkbox.current?.value === lastCheckedCheckbox);
|
|
111
|
+
if (isShiftPressed && targetCheckbox && !leaving) {
|
|
112
|
+
const lastCheckedIndex = updatedRefList.indexOf(targetCheckbox);
|
|
113
|
+
const start = Math.min(lastCheckedIndex, index) - (Math.min(lastCheckedIndex, index) === index ? 1 : 0);
|
|
114
|
+
const end = Math.max(lastCheckedIndex, index);
|
|
115
|
+
updatedRefList.forEach((checkbox, i) => {
|
|
116
|
+
if (!checkbox.current?.disabled && i > start && i < end) {
|
|
117
|
+
newRange.push(checkbox.current?.value);
|
|
128
118
|
}
|
|
129
119
|
});
|
|
130
|
-
const state = checkStateOfCheckboxs(checkboxRows);
|
|
131
|
-
const checkboxIds = Object.keys(checkboxRows);
|
|
132
|
-
if (state === true) {
|
|
133
|
-
selectRows(checkboxIds, false);
|
|
134
|
-
}
|
|
135
|
-
if ([false, "indeterminate"].includes(state)) {
|
|
136
|
-
selectRows(checkboxIds, true);
|
|
137
|
-
}
|
|
138
120
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
121
|
+
}
|
|
122
|
+
setInRange(newRange);
|
|
123
|
+
};
|
|
124
|
+
const handleClickRange = (currentCheckbox, index, isShiftPressed) => {
|
|
125
|
+
if (isShiftPressed) {
|
|
126
|
+
const checkboxesInRange = [];
|
|
127
|
+
const targetCheckbox = updatedRefList.find((checkbox) => checkbox.current?.value === lastCheckedCheckbox);
|
|
128
|
+
const lastCheckedIndex = targetCheckbox ? updatedRefList.indexOf(targetCheckbox) : void 0;
|
|
129
|
+
if (lastCheckedIndex !== void 0) {
|
|
130
|
+
const start = Math.min(lastCheckedIndex, index) - (Math.min(lastCheckedIndex, index) === index ? 1 : 0);
|
|
131
|
+
const end = Math.max(lastCheckedIndex, index);
|
|
132
|
+
updatedRefList.forEach((checkbox, key) => {
|
|
133
|
+
if (start < key && key <= end) {
|
|
134
|
+
if (!checkbox.current?.disabled) {
|
|
135
|
+
checkboxesInRange.push(checkbox.current?.value);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
selectRows(checkboxesInRange, currentCheckbox.checked);
|
|
140
|
+
setLastCheckedCheckbox(currentCheckbox.value);
|
|
148
141
|
}
|
|
149
|
-
|
|
142
|
+
} else if (index === 0) setLastCheckedCheckbox(void 0);
|
|
143
|
+
setTimeout(() => {
|
|
144
|
+
setInRange([]);
|
|
145
|
+
setLastCheckedCheckbox(currentCheckbox.value);
|
|
146
|
+
}, 1);
|
|
147
|
+
};
|
|
148
|
+
refList.forEach((checkbox, index) => {
|
|
149
|
+
const clickHandler = function clickHandler2(event) {
|
|
150
|
+
handleClickRange(this, index, event.shiftKey);
|
|
150
151
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
};
|
|
158
|
-
const changeHandler = (event) => {
|
|
159
|
-
handleOnChange(event.currentTarget);
|
|
160
|
-
};
|
|
161
|
-
checkbox.addEventListener("change", changeHandler);
|
|
162
|
-
checkbox.addEventListener("click", clickHandler);
|
|
163
|
-
checkbox.addEventListener("mouseover", hoverHandler);
|
|
152
|
+
const hoverEnteringHandler = (event) => handleHover(index, event.shiftKey, false);
|
|
153
|
+
const hoverLeavingHandler = (event) => handleHover(index, event.shiftKey, true);
|
|
154
|
+
if (checkbox.current) {
|
|
155
|
+
checkbox.current.addEventListener("click", clickHandler);
|
|
156
|
+
checkbox.current.addEventListener("mousemove", hoverEnteringHandler);
|
|
157
|
+
checkbox.current.addEventListener("mouseout", hoverLeavingHandler);
|
|
164
158
|
handlers.push(() => {
|
|
165
|
-
checkbox.
|
|
166
|
-
|
|
167
|
-
|
|
159
|
+
if (checkbox.current) {
|
|
160
|
+
checkbox.current.removeEventListener("click", clickHandler);
|
|
161
|
+
checkbox.current.removeEventListener("mouseout", hoverEnteringHandler);
|
|
162
|
+
checkbox.current.removeEventListener("mousemove", hoverLeavingHandler);
|
|
163
|
+
}
|
|
168
164
|
});
|
|
169
|
-
}
|
|
170
|
-
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
171
167
|
return () => {
|
|
172
168
|
handlers.forEach((cleanup) => cleanup());
|
|
173
169
|
};
|
|
174
|
-
}, [
|
|
175
|
-
React.useEffect(
|
|
170
|
+
}, [lastCheckedCheckbox, selectRows]);
|
|
171
|
+
React.useEffect(() => {
|
|
172
|
+
subscribeHandler();
|
|
173
|
+
}, [subscribeHandler]);
|
|
174
|
+
const handleOnChange = React.useCallback((value2, checked) => {
|
|
175
|
+
selectRows([value2], !checked);
|
|
176
|
+
setLastCheckedCheckbox(value2);
|
|
177
|
+
}, [selectRows]);
|
|
176
178
|
const value = React.useMemo(() => ({
|
|
177
179
|
allRowSelectValue,
|
|
178
180
|
selectAllHandler,
|
|
@@ -183,7 +185,6 @@ const ListProvider = ({
|
|
|
183
185
|
expandedRowIds,
|
|
184
186
|
expandRow,
|
|
185
187
|
inRange,
|
|
186
|
-
mapCheckbox: refList.current,
|
|
187
188
|
registerExpandableRow,
|
|
188
189
|
registerSelectableRow,
|
|
189
190
|
selectable,
|
|
@@ -191,8 +192,11 @@ const ListProvider = ({
|
|
|
191
192
|
selectedRowIds,
|
|
192
193
|
selectRow,
|
|
193
194
|
unselectAll,
|
|
194
|
-
unselectRow
|
|
195
|
-
|
|
195
|
+
unselectRow,
|
|
196
|
+
refList,
|
|
197
|
+
setRefList,
|
|
198
|
+
handleOnChange
|
|
199
|
+
}), [allRowSelectValue, selectAllHandler, subscribeHandler, collapseRow, columns, expandButton, expandedRowIds, expandRow, inRange, refList, registerExpandableRow, registerSelectableRow, selectable, selectAll, selectedRowIds, selectRow, unselectAll, unselectRow, handleOnChange]);
|
|
196
200
|
return /* @__PURE__ */ jsxRuntime.jsx(ListContext.Provider, { value, children });
|
|
197
201
|
};
|
|
198
202
|
const useListContext = () => {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { ComponentProps, Dispatch, ChangeEvent as ReactChangeEvent, ReactNode, SetStateAction } from 'react';
|
|
1
|
+
import type { ComponentProps, Dispatch, ChangeEvent as ReactChangeEvent, ReactNode, RefObject, SetStateAction } from 'react';
|
|
2
2
|
import type { Checkbox } from '../Checkbox';
|
|
3
3
|
import type { ColumnProps } from './types';
|
|
4
4
|
type RowState = Record<string | number, boolean>;
|
|
5
|
-
type MapCheckbox = Map<string | number, HTMLInputElement>;
|
|
6
5
|
export type ListContextValue = {
|
|
7
6
|
/**
|
|
8
7
|
* @returns an unregister function
|
|
@@ -20,14 +19,16 @@ export type ListContextValue = {
|
|
|
20
19
|
selectAllHandler: (event: ReactChangeEvent<HTMLInputElement>) => void;
|
|
21
20
|
subscribeHandler: () => void;
|
|
22
21
|
columns: ColumnProps[];
|
|
23
|
-
inRange:
|
|
24
|
-
mapCheckbox: MapCheckbox;
|
|
22
|
+
inRange: string[];
|
|
25
23
|
selectable: boolean;
|
|
26
24
|
selectAll: () => void;
|
|
27
25
|
selectedRowIds: RowState;
|
|
28
26
|
selectRow: (rowId: string) => void;
|
|
29
27
|
unselectAll: () => void;
|
|
30
28
|
unselectRow: (rowId: string) => void;
|
|
29
|
+
refList: RefObject<HTMLInputElement>[];
|
|
30
|
+
setRefList: Dispatch<SetStateAction<RefObject<HTMLInputElement>[]>>;
|
|
31
|
+
handleOnChange: (value: string, checked: boolean) => void;
|
|
31
32
|
};
|
|
32
33
|
export type ListProviderProps = {
|
|
33
34
|
children: ReactNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useContext, 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 = () => {
|