@wireapp/react-ui-kit 9.1.0 → 9.2.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.
|
@@ -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