draft-components 2.10.2 → 2.11.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/date-picker/date-range.js +2 -0
- package/dist/components/filtered-search/model/string-filter.js +4 -2
- package/dist/components/filtered-search/model/string-set-filter.js +4 -2
- package/dist/components/slider/range-slider.d.ts +2 -2
- package/dist/components/slider/range-slider.js +15 -15
- package/dist/components/slider/slider-thumb.d.ts +4 -5
- package/dist/components/slider/slider-thumb.js +3 -3
- package/dist/components/slider/slider-tick-marks.js +4 -1
- package/dist/components/slider/slider.d.ts +2 -2
- package/dist/components/slider/slider.js +2 -2
- package/dist/components/toaster/toaster.js +4 -0
- package/package.json +10 -10
|
@@ -7,6 +7,10 @@ const OPERATORS = {
|
|
|
7
7
|
notContain: 'NOT_CONTAIN',
|
|
8
8
|
};
|
|
9
9
|
export class StringFilter extends AbstractFilter {
|
|
10
|
+
static Type = TYPE;
|
|
11
|
+
static Operators = OPERATORS;
|
|
12
|
+
config;
|
|
13
|
+
state;
|
|
10
14
|
constructor(config, state) {
|
|
11
15
|
super();
|
|
12
16
|
this.config = config;
|
|
@@ -37,5 +41,3 @@ export class StringFilter extends AbstractFilter {
|
|
|
37
41
|
return this.value === '';
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
|
-
StringFilter.Type = TYPE;
|
|
41
|
-
StringFilter.Operators = OPERATORS;
|
|
@@ -5,6 +5,10 @@ const OPERATORS = {
|
|
|
5
5
|
notIn: 'NOT_IN',
|
|
6
6
|
};
|
|
7
7
|
export class StringSetFilter extends AbstractFilter {
|
|
8
|
+
static Type = TYPE;
|
|
9
|
+
static Operators = OPERATORS;
|
|
10
|
+
config;
|
|
11
|
+
state;
|
|
8
12
|
constructor(config, state) {
|
|
9
13
|
super();
|
|
10
14
|
this.config = config;
|
|
@@ -35,5 +39,3 @@ export class StringSetFilter extends AbstractFilter {
|
|
|
35
39
|
return this.value.length === 0;
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
|
-
StringSetFilter.Type = TYPE;
|
|
39
|
-
StringSetFilter.Operators = OPERATORS;
|
|
@@ -23,8 +23,8 @@ export type RangeSliderProps = {
|
|
|
23
23
|
max?: number;
|
|
24
24
|
maxThumbName?: string;
|
|
25
25
|
maxThumbAriaLabel?: string;
|
|
26
|
+
format?: (value: number) => ReactNode;
|
|
26
27
|
value: RangeSliderValue;
|
|
27
28
|
onChange: (value: RangeSliderValue) => void;
|
|
28
|
-
formatValue?: (value: number) => ReactNode;
|
|
29
29
|
};
|
|
30
|
-
export declare function RangeSlider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabels, iconLeft, iconRight, tickMarks, step, min, minThumbName, minThumbAriaLabel, max, maxThumbName, maxThumbAriaLabel, name, value
|
|
30
|
+
export declare function RangeSlider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabels, iconLeft, iconRight, tickMarks, step, min, minThumbName, minThumbAriaLabel, max, maxThumbName, maxThumbAriaLabel, name, value, format, onChange, }: RangeSliderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,34 +6,34 @@ import { SliderTrack } from './slider-track.js';
|
|
|
6
6
|
import { SliderThumb } from './slider-thumb.js';
|
|
7
7
|
import { SliderTickMarks } from './slider-tick-marks.js';
|
|
8
8
|
const numberFormatter = new Intl.NumberFormat();
|
|
9
|
-
export function RangeSlider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabels, iconLeft, iconRight, tickMarks, step = 1, min = 0, minThumbName, minThumbAriaLabel, max = 100, maxThumbName, maxThumbAriaLabel, name, value
|
|
9
|
+
export function RangeSlider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabels, iconLeft, iconRight, tickMarks, step = 1, min = 0, minThumbName, minThumbAriaLabel, max = 100, maxThumbName, maxThumbAriaLabel, name, value, format = numberFormatter.format, onChange, }) {
|
|
10
10
|
const defaultId = useId();
|
|
11
|
-
const [
|
|
12
|
-
const positionMin = calcPosition(
|
|
13
|
-
const positionMax = calcPosition(
|
|
11
|
+
const [activeThumb, setActiveThumb] = useState('min');
|
|
12
|
+
const positionMin = calcPosition(value.min, { min, max });
|
|
13
|
+
const positionMax = calcPosition(value.max, { min, max });
|
|
14
14
|
let dataListId;
|
|
15
15
|
let tickMarksElement;
|
|
16
16
|
if (tickMarks && tickMarks.length > 0) {
|
|
17
17
|
dataListId = `${defaultId}slider-datalist`;
|
|
18
18
|
tickMarksElement = (_jsx(SliderTickMarks, { tickMarks: tickMarks, dataListId: dataListId, min: min, max: max }));
|
|
19
19
|
}
|
|
20
|
-
const handleChangeMin = (
|
|
20
|
+
const handleChangeMin = (min) => {
|
|
21
21
|
onChange({
|
|
22
|
-
...
|
|
23
|
-
min: Math.min(
|
|
22
|
+
...value,
|
|
23
|
+
min: Math.min(value.max, min),
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const handlePointerDownOnMinThumb = () => {
|
|
27
|
+
setActiveThumb('min');
|
|
28
28
|
};
|
|
29
|
-
const handleChangeMax = (
|
|
29
|
+
const handleChangeMax = (max) => {
|
|
30
30
|
onChange({
|
|
31
|
-
...
|
|
32
|
-
max: Math.max(
|
|
31
|
+
...value,
|
|
32
|
+
max: Math.max(value.min, max),
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const handlePointerDownOnMaxThumb = () => {
|
|
36
|
+
setActiveThumb('max');
|
|
37
37
|
};
|
|
38
38
|
return (_jsx("fieldset", { id: id, style: style, className: classNames(className, {
|
|
39
39
|
'dc-slider': true,
|
|
@@ -44,5 +44,5 @@ export function RangeSlider({ 'aria-label': ariaLabel, id, style, className, dis
|
|
|
44
44
|
'dc-slider__body': true,
|
|
45
45
|
'dc-slider__body_has_labels': showLabels,
|
|
46
46
|
'dc-slider__body_has_tick-marks': tickMarksElement,
|
|
47
|
-
}), children: [iconLeft, _jsxs(SliderTrack, { positionStart: positionMin, positionEnd: positionMax, children: [tickMarksElement, _jsx(SliderThumb, { name: minThumbName || (name && `${name}[min]`), active:
|
|
47
|
+
}), children: [iconLeft, _jsxs(SliderTrack, { positionStart: positionMin, positionEnd: positionMax, children: [tickMarksElement, _jsx(SliderThumb, { name: minThumbName || (name && `${name}[min]`), active: activeThumb === 'min', "aria-label": minThumbAriaLabel, showLabel: showLabels, dataListId: dataListId, position: positionMin, step: step, min: min, max: max, value: value.min, format: format, onChange: handleChangeMin, onPointerDown: handlePointerDownOnMinThumb }), _jsx(SliderThumb, { name: maxThumbName || (name && `${name}[max]`), active: activeThumb === 'max', "aria-label": maxThumbAriaLabel, showLabel: showLabels, dataListId: dataListId, position: positionMax, step: step, min: min, max: max, value: value.max, format: format, onChange: handleChangeMax, onPointerDown: handlePointerDownOnMaxThumb })] }), iconRight] }) }));
|
|
48
48
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PointerEventHandler, ReactNode } from 'react';
|
|
2
2
|
export type SliderThumbProps = {
|
|
3
3
|
'aria-label'?: string;
|
|
4
4
|
id?: string;
|
|
@@ -12,9 +12,8 @@ export type SliderThumbProps = {
|
|
|
12
12
|
min: number;
|
|
13
13
|
max: number;
|
|
14
14
|
value: number;
|
|
15
|
-
|
|
15
|
+
format: (value: number) => ReactNode;
|
|
16
16
|
onChange: (value: number) => void;
|
|
17
|
-
|
|
18
|
-
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
17
|
+
onPointerDown?: PointerEventHandler<HTMLInputElement>;
|
|
19
18
|
};
|
|
20
|
-
export declare function SliderThumb({ 'aria-label': ariaLabel, id, name, active, disabled, showLabel, dataListId, position, step, min, max, value,
|
|
19
|
+
export declare function SliderThumb({ 'aria-label': ariaLabel, id, name, active, disabled, showLabel, dataListId, position, step, min, max, value, format, onChange, onPointerDown, }: SliderThumbProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { getOffsetRelativeToThumb } from './get-offset-relative-to-thumb.js';
|
|
3
3
|
import { classNames } from '../../lib/index.js';
|
|
4
|
-
export function SliderThumb({ 'aria-label': ariaLabel, id, name, active, disabled, showLabel, dataListId, position, step, min, max, value,
|
|
4
|
+
export function SliderThumb({ 'aria-label': ariaLabel, id, name, active, disabled, showLabel, dataListId, position, step, min, max, value, format, onChange, onPointerDown, }) {
|
|
5
5
|
const handleChange = (event) => {
|
|
6
6
|
onChange(event.target.valueAsNumber);
|
|
7
7
|
};
|
|
8
8
|
return (_jsxs(_Fragment, { children: [_jsx("input", { id: id, className: classNames({
|
|
9
9
|
'dc-slider__input': true,
|
|
10
10
|
'dc-slider__input_active': active,
|
|
11
|
-
}), type: "range", name: name, "aria-label": ariaLabel, list: dataListId, step: step, min: min, max: max, disabled: disabled, value: value, onChange: handleChange,
|
|
11
|
+
}), type: "range", name: name, "aria-label": ariaLabel, list: dataListId, step: step, min: min, max: max, disabled: disabled, value: value, onChange: handleChange, onPointerDown: onPointerDown }), showLabel && (_jsx("output", { style: { left: getOffsetRelativeToThumb(position) }, className: classNames({
|
|
12
12
|
'dc-slider__label': true,
|
|
13
13
|
'dc-slider__label_active': active,
|
|
14
|
-
}), htmlFor: id, children: _jsx("span", { className: "dc-slider__label-text", children:
|
|
14
|
+
}), htmlFor: id, children: _jsx("span", { className: "dc-slider__label-text", children: format(value) }) }))] }));
|
|
15
15
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { getOffsetRelativeToThumb } from './get-offset-relative-to-thumb.js';
|
|
3
|
+
import { calcPosition } from './calc-position.js';
|
|
3
4
|
export function SliderTickMarks({ dataListId, min, max, tickMarks, }) {
|
|
4
5
|
const options = [];
|
|
5
6
|
const listItems = [];
|
|
@@ -7,7 +8,9 @@ export function SliderTickMarks({ dataListId, min, max, tickMarks, }) {
|
|
|
7
8
|
const { value, label } = tickMarks[index];
|
|
8
9
|
const key = `tick-mark-${value}:${index}`;
|
|
9
10
|
options.push(_jsx("option", { value: value, "data-testid": "slider-data-list-option", children: label }, key));
|
|
10
|
-
listItems.push(_jsx("li", { className: "dc-slider__tick-mark", "data-value": value, style: {
|
|
11
|
+
listItems.push(_jsx("li", { className: "dc-slider__tick-mark", "data-value": value, style: {
|
|
12
|
+
left: getOffsetRelativeToThumb(calcPosition(value, { min, max })),
|
|
13
|
+
} }, key));
|
|
11
14
|
}
|
|
12
15
|
return (_jsxs(_Fragment, { children: [_jsx("datalist", { id: dataListId, children: options }), _jsx("ol", { className: "dc-slider__tick-marks", children: listItems })] }));
|
|
13
16
|
}
|
|
@@ -16,7 +16,7 @@ export type SliderProps = {
|
|
|
16
16
|
min?: number;
|
|
17
17
|
max?: number;
|
|
18
18
|
value: number;
|
|
19
|
+
format?: (value: number) => ReactNode;
|
|
19
20
|
onChange: (value: number) => void;
|
|
20
|
-
formatValue?: (value: number) => ReactNode;
|
|
21
21
|
};
|
|
22
|
-
export declare function Slider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabel, iconLeft, iconRight, tickMarks, step, min, max, name, value,
|
|
22
|
+
export declare function Slider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabel, iconLeft, iconRight, tickMarks, step, min, max, name, value, format, onChange, }: SliderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,7 +6,7 @@ import { SliderTrack } from './slider-track.js';
|
|
|
6
6
|
import { SliderThumb } from './slider-thumb.js';
|
|
7
7
|
import { SliderTickMarks } from './slider-tick-marks.js';
|
|
8
8
|
const numberFormatter = new Intl.NumberFormat();
|
|
9
|
-
export function Slider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabel, iconLeft, iconRight, tickMarks, step = 1, min = 0, max = 100, name, value,
|
|
9
|
+
export function Slider({ 'aria-label': ariaLabel, id, style, className, disabled, fullWidth, showLabel, iconLeft, iconRight, tickMarks, step = 1, min = 0, max = 100, name, value, format = numberFormatter.format, onChange, }) {
|
|
10
10
|
const defaultId = useId();
|
|
11
11
|
const thumbId = id || `${defaultId}slider-thumb`;
|
|
12
12
|
const position = calcPosition(value, { min, max });
|
|
@@ -24,5 +24,5 @@ export function Slider({ 'aria-label': ariaLabel, id, style, className, disabled
|
|
|
24
24
|
'dc-slider__body': true,
|
|
25
25
|
'dc-slider__body_has_labels': showLabel,
|
|
26
26
|
'dc-slider__body_has_tick-marks': tickMarksElement,
|
|
27
|
-
}), children: [iconLeft, _jsxs(SliderTrack, { positionStart: 0, positionEnd: position, children: [tickMarksElement, _jsx(SliderThumb, { id: thumbId, name: name, "aria-label": ariaLabel, disabled: disabled, showLabel: showLabel, dataListId: dataListId, position: position, step: step, min: min, max: max, value: value, onChange: onChange,
|
|
27
|
+
}), children: [iconLeft, _jsxs(SliderTrack, { positionStart: 0, positionEnd: position, children: [tickMarksElement, _jsx(SliderThumb, { id: thumbId, name: name, "aria-label": ariaLabel, disabled: disabled, showLabel: showLabel, dataListId: dataListId, position: position, step: step, min: min, max: max, value: value, onChange: onChange, format: format })] }), iconRight] }) }));
|
|
28
28
|
}
|
|
@@ -9,6 +9,10 @@ const isToastShowEvent = (event) => (event instanceof CustomEvent && event.type
|
|
|
9
9
|
const TOAST_HIDE_EVENT = 'toast_hide';
|
|
10
10
|
const isToastHideEvent = (event) => (event instanceof CustomEvent && event.type === TOAST_HIDE_EVENT);
|
|
11
11
|
export class Toaster {
|
|
12
|
+
_id;
|
|
13
|
+
timeoutMs;
|
|
14
|
+
onShow;
|
|
15
|
+
onHide;
|
|
12
16
|
constructor(params) {
|
|
13
17
|
this._id = 0;
|
|
14
18
|
this.timeoutMs = params?.timeoutMs || 10000;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "draft-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "The React based UI components library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"@testing-library/jest-dom": "6.2.0",
|
|
65
65
|
"@testing-library/react": "14.1.2",
|
|
66
66
|
"@testing-library/user-event": "14.5.2",
|
|
67
|
-
"@types/node": "20.10.
|
|
68
|
-
"@types/react": "18.2.
|
|
67
|
+
"@types/node": "20.10.7",
|
|
68
|
+
"@types/react": "18.2.47",
|
|
69
69
|
"@types/react-dom": "18.2.18",
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
71
|
-
"@typescript-eslint/parser": "6.
|
|
72
|
-
"@vitest/coverage-istanbul": "1.1.
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "6.18.0",
|
|
71
|
+
"@typescript-eslint/parser": "6.18.0",
|
|
72
|
+
"@vitest/coverage-istanbul": "1.1.3",
|
|
73
73
|
"autoprefixer": "10.4.16",
|
|
74
74
|
"eslint": "8.56.0",
|
|
75
75
|
"eslint-plugin-jsx-a11y": "6.8.0",
|
|
@@ -78,9 +78,9 @@
|
|
|
78
78
|
"eslint-plugin-storybook": "0.6.15",
|
|
79
79
|
"eslint-plugin-testing-library": "6.2.0",
|
|
80
80
|
"husky": "8.0.3",
|
|
81
|
-
"jsdom": "23.0
|
|
81
|
+
"jsdom": "23.2.0",
|
|
82
82
|
"lint-staged": "15.2.0",
|
|
83
|
-
"postcss": "8.4.
|
|
83
|
+
"postcss": "8.4.33",
|
|
84
84
|
"postcss-import": "16.0.0",
|
|
85
85
|
"react": "18.2.0",
|
|
86
86
|
"react-dom": "18.2.0",
|
|
@@ -89,8 +89,8 @@
|
|
|
89
89
|
"stylelint-config-standard": "36.0.0",
|
|
90
90
|
"stylelint-order": "6.0.4",
|
|
91
91
|
"typescript": "5.3.3",
|
|
92
|
-
"vite": "5.0.
|
|
93
|
-
"vitest": "1.1.
|
|
92
|
+
"vite": "5.0.11",
|
|
93
|
+
"vitest": "1.1.3"
|
|
94
94
|
},
|
|
95
95
|
"lint-staged": {
|
|
96
96
|
"*.ts?(x)": "npm run lint-js",
|