@terraware/web-components 3.9.9 → 3.9.10
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/components/TimelineSlider/TimelineMarker.d.ts +13 -0
- package/components/TimelineSlider/TimelineMarker.d.ts.map +1 -0
- package/components/TimelineSlider/TimelineMarker.js +33 -0
- package/components/TimelineSlider/TimelineRail.d.ts +5 -0
- package/components/TimelineSlider/TimelineRail.d.ts.map +1 -0
- package/components/TimelineSlider/TimelineRail.js +15 -0
- package/components/TimelineSlider/index.d.ts +19 -0
- package/components/TimelineSlider/index.d.ts.map +1 -0
- package/components/TimelineSlider/index.js +69 -0
- package/components/TimelineSlider/styles.scss +97 -0
- package/package.json +1 -1
- package/stories/TimelineSlider.stories.d.ts +10 -0
- package/stories/TimelineSlider.stories.d.ts.map +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import './styles.scss';
|
|
3
|
+
type TimelineMarkerProps = {
|
|
4
|
+
color: string;
|
|
5
|
+
labelBottom?: string;
|
|
6
|
+
labelTop?: string;
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
size: 'small' | 'medium' | 'large';
|
|
9
|
+
value: number;
|
|
10
|
+
};
|
|
11
|
+
declare const TimelineMarker: ({ color, labelBottom, labelTop, onClick, size, value }: TimelineMarkerProps) => JSX.Element;
|
|
12
|
+
export default TimelineMarker;
|
|
13
|
+
//# sourceMappingURL=TimelineMarker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimelineMarker.d.ts","sourceRoot":"","sources":["../../../src/components/TimelineSlider/TimelineMarker.tsx"],"names":[],"mappings":";AAEA,OAAO,eAAe,CAAC;AAEvB,KAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,QAAA,MAAM,cAAc,2DAA4D,mBAAmB,KAAG,WAgBrG,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
require("./styles.scss");
|
|
10
|
+
const TimelineMarker = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
color,
|
|
13
|
+
labelBottom,
|
|
14
|
+
labelTop,
|
|
15
|
+
onClick,
|
|
16
|
+
size,
|
|
17
|
+
value
|
|
18
|
+
} = _ref;
|
|
19
|
+
const clampedValue = Math.min(1, Math.max(0, value));
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
21
|
+
className: "timeline-marker timeline-marker--".concat(size, " ").concat(onClick ? 'timeline-marker--clickable' : ''),
|
|
22
|
+
style: {
|
|
23
|
+
left: "".concat(clampedValue * 100, "%"),
|
|
24
|
+
backgroundColor: color
|
|
25
|
+
},
|
|
26
|
+
onClick: onClick
|
|
27
|
+
}, labelTop && /*#__PURE__*/_react.default.createElement("div", {
|
|
28
|
+
className: "timeline-marker__label timeline-marker__label--top"
|
|
29
|
+
}, labelTop), labelBottom && /*#__PURE__*/_react.default.createElement("div", {
|
|
30
|
+
className: "timeline-marker__label timeline-marker__label--bottom"
|
|
31
|
+
}, labelBottom));
|
|
32
|
+
};
|
|
33
|
+
var _default = exports.default = TimelineMarker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimelineRail.d.ts","sourceRoot":"","sources":["../../../src/components/TimelineSlider/TimelineRail.tsx"],"names":[],"mappings":";AAEA,OAAO,eAAe,CAAC;AAEvB,QAAA,MAAM,YAAY,QAAO,WAExB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
require("./styles.scss");
|
|
10
|
+
const TimelineRail = () => {
|
|
11
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
12
|
+
className: "timeline-rail"
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var _default = exports.default = TimelineRail;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import './styles.scss';
|
|
3
|
+
export type TimelineSliderMark = {
|
|
4
|
+
color: string;
|
|
5
|
+
labelBottom?: string;
|
|
6
|
+
labelTop?: string;
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
size: 'small' | 'medium' | 'large';
|
|
9
|
+
value: number;
|
|
10
|
+
};
|
|
11
|
+
export type TimelineSliderProps = {
|
|
12
|
+
labelEnd?: string;
|
|
13
|
+
labelSelected?: string;
|
|
14
|
+
labelStart?: string;
|
|
15
|
+
marks: TimelineSliderMark[];
|
|
16
|
+
};
|
|
17
|
+
declare const TimelineSlider: ({ labelEnd, labelSelected, labelStart, marks }: TimelineSliderProps) => JSX.Element;
|
|
18
|
+
export default TimelineSlider;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TimelineSlider/index.tsx"],"names":[],"mappings":";AAMA,OAAO,eAAe,CAAC;AAEvB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,kBAAkB,EAAE,CAAC;CAC7B,CAAC;AAEF,QAAA,MAAM,cAAc,mDAAoD,mBAAmB,KAAG,WAkD7F,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _material = require("@mui/material");
|
|
11
|
+
var _TimelineMarker = _interopRequireDefault(require("./TimelineMarker"));
|
|
12
|
+
var _TimelineRail = _interopRequireDefault(require("./TimelineRail"));
|
|
13
|
+
require("./styles.scss");
|
|
14
|
+
const TimelineSlider = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
labelEnd,
|
|
17
|
+
labelSelected,
|
|
18
|
+
labelStart,
|
|
19
|
+
marks
|
|
20
|
+
} = _ref;
|
|
21
|
+
const theme = (0, _material.useTheme)();
|
|
22
|
+
const {
|
|
23
|
+
minValue,
|
|
24
|
+
maxValue
|
|
25
|
+
} = (0, _react.useMemo)(() => {
|
|
26
|
+
const values = marks.map(mark => mark.value);
|
|
27
|
+
if (values.length > 0) {
|
|
28
|
+
return {
|
|
29
|
+
minValue: Math.min(...values),
|
|
30
|
+
maxValue: Math.max(...values)
|
|
31
|
+
};
|
|
32
|
+
} else {
|
|
33
|
+
return {
|
|
34
|
+
minValue: 0,
|
|
35
|
+
maxValue: 1
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}, [marks]);
|
|
39
|
+
const range = maxValue - minValue;
|
|
40
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
41
|
+
className: 'timeline'
|
|
42
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
43
|
+
className: 'timeline-label',
|
|
44
|
+
style: {
|
|
45
|
+
marginRight: theme.spacing(2)
|
|
46
|
+
}
|
|
47
|
+
}, labelStart), /*#__PURE__*/_react.default.createElement("div", {
|
|
48
|
+
className: "timeline-container"
|
|
49
|
+
}, /*#__PURE__*/_react.default.createElement(_TimelineRail.default, null), marks.map((mark, idx) => {
|
|
50
|
+
const normalizedValue = range === 0 ? 1 : (mark.value - minValue) / range;
|
|
51
|
+
return /*#__PURE__*/_react.default.createElement(_TimelineMarker.default, {
|
|
52
|
+
key: idx,
|
|
53
|
+
color: mark.color,
|
|
54
|
+
labelBottom: mark.labelBottom,
|
|
55
|
+
labelTop: mark.labelTop,
|
|
56
|
+
onClick: mark.onClick,
|
|
57
|
+
size: mark.size,
|
|
58
|
+
value: normalizedValue
|
|
59
|
+
});
|
|
60
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
61
|
+
className: 'timeline-label',
|
|
62
|
+
style: {
|
|
63
|
+
marginLeft: theme.spacing(2)
|
|
64
|
+
}
|
|
65
|
+
}, labelEnd), labelSelected && /*#__PURE__*/_react.default.createElement("div", {
|
|
66
|
+
className: 'timeline-selected-label'
|
|
67
|
+
}, labelSelected));
|
|
68
|
+
};
|
|
69
|
+
var _default = exports.default = TimelineSlider;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
@import '../../style-dictionary-dist/terraware.scss';
|
|
2
|
+
|
|
3
|
+
.timeline {
|
|
4
|
+
align-items: center;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: row;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.timeline-label {
|
|
10
|
+
font-family: $tw-fnt-frm-fld-label-font-family;
|
|
11
|
+
font-size: $tw-fnt-frm-fld-label-font-size;
|
|
12
|
+
font-weight: $tw-fnt-frm-fld-label-font-weight;
|
|
13
|
+
line-height: $tw-fnt-frm-fld-label-line-height;
|
|
14
|
+
color: $tw-clr-txt-secondary;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.timeline-selected-label {
|
|
18
|
+
border-radius: 8px;
|
|
19
|
+
background: $tw-clr-bg-secondary;
|
|
20
|
+
width: 140px;
|
|
21
|
+
padding: 10px;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
align-items: center;
|
|
24
|
+
text-align: center;
|
|
25
|
+
margin-left: 12px;
|
|
26
|
+
font-family: $tw-fnt-btn-label-small-font-family;
|
|
27
|
+
font-size: $tw-fnt-btn-label-small-font-size;
|
|
28
|
+
font-weight: $tw-fnt-mssg-title-font-weight;
|
|
29
|
+
line-height: $tw-fnt-btn-label-small-line-height;
|
|
30
|
+
color: $tw-clr-base-black;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.timeline-container {
|
|
34
|
+
width: 100%;
|
|
35
|
+
max-width: 500px;
|
|
36
|
+
margin: 0 0;
|
|
37
|
+
position: relative;
|
|
38
|
+
height: 40px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.timeline-marker {
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: 50%;
|
|
44
|
+
border-radius: 50%;
|
|
45
|
+
transform: translate(-50%, -50%);
|
|
46
|
+
|
|
47
|
+
&--small {
|
|
48
|
+
width: 12px;
|
|
49
|
+
height: 12px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&--medium {
|
|
53
|
+
width: 18px;
|
|
54
|
+
height: 18px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&--large {
|
|
58
|
+
width: 24px;
|
|
59
|
+
height: 24px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&--clickable {
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&__label {
|
|
67
|
+
position: absolute;
|
|
68
|
+
left: 50%;
|
|
69
|
+
transform: translateX(-50%);
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
font-family: $tw-fnt-frm-fld-label-font-family;
|
|
72
|
+
font-size: $tw-fnt-frm-fld-label-font-size;
|
|
73
|
+
font-weight: $tw-fnt-frm-fld-label-font-weight;
|
|
74
|
+
line-height: $tw-fnt-frm-fld-label-line-height;
|
|
75
|
+
color: $tw-clr-txt-secondary;
|
|
76
|
+
|
|
77
|
+
&--top {
|
|
78
|
+
bottom: 100%;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&--bottom {
|
|
82
|
+
top: 100%;
|
|
83
|
+
transform: translateX(-100%) rotate(-45deg);
|
|
84
|
+
transform-origin: right center;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.timeline-rail {
|
|
90
|
+
position: absolute;
|
|
91
|
+
top: 50%;
|
|
92
|
+
left: 0;
|
|
93
|
+
right: 0;
|
|
94
|
+
height: 5px;
|
|
95
|
+
background-color: $tw-clr-base-gray-200;
|
|
96
|
+
transform: translateY(-50%);
|
|
97
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TimelineSliderProps } from '../components/TimelineSlider';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: ({ labelEnd, labelSelected, labelStart, marks }: TimelineSliderProps) => JSX.Element;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, TimelineSliderProps>;
|
|
9
|
+
export declare const SingleValueMarks: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, TimelineSliderProps>;
|
|
10
|
+
//# sourceMappingURL=TimelineSlider.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimelineSlider.stories.d.ts","sourceRoot":"","sources":["../../src/stories/TimelineSlider.stories.tsx"],"names":[],"mappings":";AAIA,OAAuB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;;;;;AAGnF,wBAGE;AAkCF,eAAO,MAAM,OAAO,4GAAoB,CAAC;AASzC,eAAO,MAAM,gBAAgB,4GAAoB,CAAC"}
|