@wireapp/react-ui-kit 9.1.0 → 9.2.1
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.
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, HTMLProps, PropsWithRef } from 'react';
|
|
2
2
|
import { CSSObject } from '@emotion/react';
|
|
3
|
-
import { TextProps } from '../Text';
|
|
4
3
|
type DataListOptions = {
|
|
5
4
|
value: number;
|
|
6
5
|
label: string;
|
|
7
6
|
heading?: string;
|
|
8
7
|
};
|
|
9
|
-
export interface IndicatorRangeInputProps<T = HTMLInputElement> extends
|
|
8
|
+
export interface IndicatorRangeInputProps<T = HTMLInputElement> extends PropsWithRef<HTMLProps<T>> {
|
|
10
9
|
label?: string;
|
|
11
10
|
wrapperCSS?: CSSObject;
|
|
11
|
+
onOptionClick?: (value: number) => void;
|
|
12
12
|
dataListOptions: DataListOptions[];
|
|
13
13
|
}
|
|
14
14
|
export declare const IndicatorRangeInput: FC<IndicatorRangeInputProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndicatorRangeInput.d.ts","sourceRoot":"","sources":["../../src/Form/IndicatorRangeInput.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"IndicatorRangeInput.d.ts","sourceRoot":"","sources":["../../src/Form/IndicatorRangeInput.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAC,EAAE,EAAE,SAAS,EAAE,YAAY,EAAsB,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAOzC,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,wBAAwB,CAAC,CAAC,GAAG,gBAAgB,CAAE,SAAQ,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAChG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,eAAe,EAAE,eAAe,EAAE,CAAC;CACpC;AAED,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CAkG5D,CAAC"}
|
|
@@ -35,7 +35,8 @@ const react_1 = require("react");
|
|
|
35
35
|
const IndicatorRangeInput_styles_1 = require("./IndicatorRangeInput.styles");
|
|
36
36
|
const InputLabel_1 = require("./InputLabel");
|
|
37
37
|
exports.IndicatorRangeInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
38
|
-
var
|
|
38
|
+
var _b;
|
|
39
|
+
var { id = Math.random().toString(), label, min = '0', max = '100', value = '0', onChange, onOptionClick, wrapperCSS, dataListOptions = [] } = _a, inputProps = __rest(_a, ["id", "label", "min", "max", "value", "onChange", "onOptionClick", "wrapperCSS", "dataListOptions"]);
|
|
39
40
|
const minNum = Number(min);
|
|
40
41
|
const isCustomSlider = !!dataListOptions.length;
|
|
41
42
|
const listLength = dataListOptions.length - 1;
|
|
@@ -48,6 +49,15 @@ exports.IndicatorRangeInput = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
48
49
|
}
|
|
49
50
|
return `${((valueNum - minNum) * 100) / (maxNum - minNum)}% 100%`;
|
|
50
51
|
}, [isCustomSlider, valueNum, minNum, maxNum, listLength]);
|
|
51
|
-
|
|
52
|
+
const valueText = ((_b = dataListOptions[valueNum]) === null || _b === void 0 ? void 0 : _b.heading)
|
|
53
|
+
? `${dataListOptions[valueNum].label} (${dataListOptions[valueNum].heading})`
|
|
54
|
+
: dataListOptions[valueNum].label;
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: { wrapperCSS, width: '100%' } }, { children: [label && (0, jsx_runtime_1.jsx)(InputLabel_1.InputLabel, Object.assign({ htmlFor: id }, { children: label })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: IndicatorRangeInput_styles_1.containerStyles }, { children: [isCustomSlider && ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: { position: 'relative', display: 'flex', marginBottom: '20px' } }, { children: dataListOptions.map((dataListOption, index) => ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: (theme) => (0, IndicatorRangeInput_styles_1.headingStyle)(listLength, theme), onClick: () => {
|
|
56
|
+
if (dataListOption === null || dataListOption === void 0 ? void 0 : dataListOption.heading) {
|
|
57
|
+
onOptionClick(index);
|
|
58
|
+
}
|
|
59
|
+
} }, { children: dataListOption === null || dataListOption === void 0 ? void 0 : dataListOption.heading }), dataListOption.value))) }))), (0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref, css: (theme) => (0, IndicatorRangeInput_styles_1.rangeStyles)(backgroundSize, valueNum, listLength, isCustomSlider, theme), id: id, name: id, min: minNum, max: maxNum, value: value, onChange: onChange, type: "range", list: "tickMarks" }, (isCustomSlider && {
|
|
60
|
+
'aria-valuetext': valueText,
|
|
61
|
+
}), inputProps)), isCustomSlider && ((0, jsx_runtime_1.jsx)("datalist", Object.assign({ id: "tickMarks", css: (theme) => (0, IndicatorRangeInput_styles_1.dataListOption)(listLength, theme) }, { children: dataListOptions.map((dataListOption, index) => ((0, jsx_runtime_1.jsx)("option", { value: dataListOption.value, label: dataListOption.label, onClick: () => onOptionClick(index) }, index))) })))] }))] })));
|
|
52
62
|
});
|
|
53
63
|
exports.IndicatorRangeInput.displayName = 'IndicatorRangeInput';
|
package/package.json
CHANGED
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"@types/color": "3.0.3",
|
|
12
12
|
"color": "4.2.3",
|
|
13
13
|
"emotion-normalize": "11.0.1",
|
|
14
|
-
"react-select": "5.
|
|
14
|
+
"react-select": "5.7.0",
|
|
15
15
|
"react-transition-group": "4.4.5"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@babel/cli": "7.19.3",
|
|
19
|
-
"@babel/core": "7.20.
|
|
19
|
+
"@babel/core": "7.20.5",
|
|
20
20
|
"@babel/preset-env": "7.20.2",
|
|
21
21
|
"@babel/preset-react": "7.18.6",
|
|
22
22
|
"@babel/preset-typescript": "7.18.6",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"@types/react-dom": "^18.0.8",
|
|
35
35
|
"@types/rimraf": "^3.0.2",
|
|
36
36
|
"@types/webpack-env": "1.18.0",
|
|
37
|
-
"babel-jest": "29.
|
|
37
|
+
"babel-jest": "29.3.1",
|
|
38
38
|
"babel-loader": "9.1.0",
|
|
39
39
|
"jest": "^29.2.1",
|
|
40
40
|
"react": "18.2.0",
|
|
41
41
|
"react-dom": "18.2.0",
|
|
42
42
|
"react-helmet": "6.1.0",
|
|
43
|
-
"react-hot-loader": "4.13.
|
|
43
|
+
"react-hot-loader": "4.13.1",
|
|
44
44
|
"react-styleguidist": "13.0.0",
|
|
45
45
|
"react-test-renderer": "18.2.0",
|
|
46
46
|
"rimraf": "^3.0.2",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"test:watch": "jest --watch",
|
|
70
70
|
"test:update": "jest --updateSnapshot"
|
|
71
71
|
},
|
|
72
|
-
"version": "9.1
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "9.2.1",
|
|
73
|
+
"gitHead": "073ba4e4894358c2ebc85719ffac6982bd517d60"
|
|
74
74
|
}
|