baseui 10.7.2 → 10.9.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/a11y/a11y.js +2 -2
- package/a11y/a11y.js.flow +3 -3
- package/button/styled-components.js +47 -18
- package/button/styled-components.js.flow +25 -5
- package/combobox/combobox.js +6 -3
- package/combobox/combobox.js.flow +4 -2
- package/combobox/types.js.flow +2 -0
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +2 -2
- package/data-table/column-numerical.js +307 -355
- package/data-table/column-numerical.js.flow +273 -287
- package/data-table/constants.js +17 -11
- package/data-table/constants.js.flow +11 -8
- package/data-table/data-table.js +53 -50
- package/data-table/data-table.js.flow +18 -13
- package/data-table/filter-shell.js +27 -4
- package/data-table/filter-shell.js.flow +33 -9
- package/data-table/locale.js +4 -2
- package/data-table/locale.js.flow +6 -2
- package/data-table/measure-column-widths.js +83 -121
- package/data-table/measure-column-widths.js.flow +87 -109
- package/datepicker/styled-components.js +1 -1
- package/datepicker/styled-components.js.flow +4 -1
- package/drawer/drawer.js +3 -1
- package/drawer/drawer.js.flow +7 -1
- package/es/a11y/a11y.js +2 -2
- package/es/button/styled-components.js +32 -2
- package/es/combobox/combobox.js +6 -3
- package/es/data-table/column-categorical.js +2 -2
- package/es/data-table/column-numerical.js +245 -317
- package/es/data-table/constants.js +12 -8
- package/es/data-table/data-table.js +18 -16
- package/es/data-table/filter-shell.js +26 -4
- package/es/data-table/locale.js +4 -2
- package/es/data-table/measure-column-widths.js +75 -86
- package/es/datepicker/styled-components.js +1 -1
- package/es/drawer/drawer.js +3 -1
- package/es/index.js +1 -1
- package/es/map-marker/badge-enhancer.js +61 -0
- package/es/map-marker/constants.js +146 -2
- package/es/map-marker/drag-shadow.js +32 -0
- package/es/map-marker/fixed-marker.js +54 -48
- package/es/map-marker/floating-marker.js +21 -12
- package/es/map-marker/index.js +1 -1
- package/es/map-marker/label-enhancer.js +39 -0
- package/es/map-marker/needle.js +26 -0
- package/es/map-marker/pin-head.js +42 -40
- package/es/map-marker/styled-components.js +177 -32
- package/es/map-marker/types.js +1 -1
- package/es/menu/maybe-child-menu.js +0 -2
- package/es/menu/nested-menus.js +49 -3
- package/es/menu/stateful-container.js +13 -12
- package/es/modal/modal.js +3 -1
- package/es/popover/popover.js +7 -3
- package/es/progress-bar/index.js +1 -1
- package/es/progress-bar/progressbar.js +25 -10
- package/es/progress-bar/styled-components.js +9 -5
- package/es/select/select-component.js +2 -10
- package/es/spinner/styled-components.js +34 -16
- package/es/table/filter.js +3 -1
- package/es/themes/dark-theme/color-component-tokens.js +19 -10
- package/es/themes/light-theme/color-component-tokens.js +19 -10
- package/es/timezonepicker/timezone-picker.js +53 -36
- package/es/timezonepicker/tzdata.js +2 -0
- package/es/timezonepicker/update-tzdata.js +69 -0
- package/es/toast/styled-components.js +18 -7
- package/esm/a11y/a11y.js +3 -3
- package/esm/button/styled-components.js +47 -18
- package/esm/combobox/combobox.js +6 -3
- package/esm/data-table/column-categorical.js +2 -2
- package/esm/data-table/column-numerical.js +304 -353
- package/esm/data-table/constants.js +12 -8
- package/esm/data-table/data-table.js +53 -50
- package/esm/data-table/filter-shell.js +26 -4
- package/esm/data-table/locale.js +4 -2
- package/esm/data-table/measure-column-widths.js +83 -121
- package/esm/datepicker/styled-components.js +1 -1
- package/esm/drawer/drawer.js +3 -1
- package/esm/index.js +1 -1
- package/esm/map-marker/badge-enhancer.js +79 -0
- package/esm/map-marker/constants.js +94 -4
- package/esm/map-marker/drag-shadow.js +53 -0
- package/esm/map-marker/fixed-marker.js +84 -80
- package/esm/map-marker/floating-marker.js +22 -13
- package/esm/map-marker/index.js +1 -1
- package/esm/map-marker/label-enhancer.js +60 -0
- package/esm/map-marker/needle.js +43 -0
- package/esm/map-marker/pin-head.js +77 -66
- package/esm/map-marker/styled-components.js +182 -51
- package/esm/map-marker/types.js +1 -1
- package/esm/menu/maybe-child-menu.js +0 -2
- package/esm/menu/nested-menus.js +66 -5
- package/esm/menu/stateful-container.js +15 -13
- package/esm/modal/modal.js +3 -1
- package/esm/popover/popover.js +7 -3
- package/esm/progress-bar/index.js +1 -1
- package/esm/progress-bar/progressbar.js +32 -10
- package/esm/progress-bar/styled-components.js +9 -4
- package/esm/select/select-component.js +2 -11
- package/esm/spinner/styled-components.js +35 -16
- package/esm/table/filter.js +3 -1
- package/esm/themes/dark-theme/color-component-tokens.js +19 -10
- package/esm/themes/light-theme/color-component-tokens.js +19 -10
- package/esm/timezonepicker/timezone-picker.js +64 -36
- package/esm/timezonepicker/tzdata.js +2 -0
- package/esm/timezonepicker/update-tzdata.js +160 -0
- package/esm/toast/styled-components.js +13 -5
- package/index.js +6 -0
- package/index.js.flow +1 -1
- package/map-marker/badge-enhancer.js +90 -0
- package/map-marker/badge-enhancer.js.flow +86 -0
- package/map-marker/constants.js +103 -5
- package/map-marker/constants.js.flow +152 -0
- package/map-marker/drag-shadow.js +64 -0
- package/map-marker/drag-shadow.js.flow +52 -0
- package/map-marker/fixed-marker.js +84 -78
- package/map-marker/fixed-marker.js.flow +78 -66
- package/map-marker/floating-marker.js +22 -13
- package/map-marker/floating-marker.js.flow +30 -17
- package/map-marker/index.d.ts +125 -24
- package/map-marker/index.js +18 -0
- package/map-marker/index.js.flow +3 -0
- package/map-marker/label-enhancer.js +71 -0
- package/map-marker/label-enhancer.js.flow +63 -0
- package/map-marker/needle.js +54 -0
- package/map-marker/needle.js.flow +29 -0
- package/map-marker/pin-head.js +80 -69
- package/map-marker/pin-head.js.flow +122 -84
- package/map-marker/styled-components.js +200 -62
- package/map-marker/styled-components.js.flow +172 -22
- package/map-marker/types.js.flow +69 -20
- package/menu/index.d.ts +9 -4
- package/menu/maybe-child-menu.js +0 -2
- package/menu/maybe-child-menu.js.flow +0 -2
- package/menu/nested-menus.js +66 -5
- package/menu/nested-menus.js.flow +50 -5
- package/menu/stateful-container.js +15 -13
- package/menu/stateful-container.js.flow +19 -13
- package/menu/types.js.flow +7 -1
- package/modal/modal.js +3 -1
- package/modal/modal.js.flow +2 -0
- package/package.json +5 -4
- package/popover/popover.js +7 -3
- package/popover/popover.js.flow +23 -17
- package/progress-bar/index.d.ts +2 -0
- package/progress-bar/index.js +6 -0
- package/progress-bar/index.js.flow +1 -0
- package/progress-bar/progressbar.js +32 -10
- package/progress-bar/progressbar.js.flow +35 -9
- package/progress-bar/styled-components.js +9 -4
- package/progress-bar/styled-components.js.flow +15 -4
- package/progress-bar/types.js.flow +12 -2
- package/select/select-component.js +2 -11
- package/select/select-component.js.flow +5 -7
- package/spinner/styled-components.js +35 -16
- package/spinner/styled-components.js.flow +37 -19
- package/spinner/types.js.flow +10 -0
- package/styles/index.js.flow +1 -1
- package/table/filter.js +3 -1
- package/table/filter.js.flow +5 -1
- package/themes/dark-theme/color-component-tokens.js +19 -10
- package/themes/dark-theme/color-component-tokens.js.flow +19 -10
- package/themes/light-theme/color-component-tokens.js +19 -10
- package/themes/light-theme/color-component-tokens.js.flow +19 -10
- package/themes/types.js.flow +9 -0
- package/timezonepicker/timezone-picker.js +69 -41
- package/timezonepicker/timezone-picker.js.flow +52 -46
- package/timezonepicker/types.js.flow +1 -1
- package/timezonepicker/tzdata.js +10 -0
- package/timezonepicker/tzdata.js.flow +347 -0
- package/timezonepicker/update-tzdata.js +164 -0
- package/timezonepicker/update-tzdata.js.flow +70 -0
- package/toast/styled-components.js +13 -5
- package/toast/styled-components.js.flow +17 -7
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Copyright (c) Uber Technologies, Inc.
|
|
5
|
+
|
|
6
|
+
This source code is licensed under the MIT license found in the
|
|
7
|
+
LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { getOverrides } from '../helpers/overrides.js';
|
|
11
|
+
import { dragShadowWidth } from './constants.js';
|
|
12
|
+
import { StyledDragShadow, StyledDragShadowContainer } from './styled-components.js';
|
|
13
|
+
|
|
14
|
+
const DragShadow = ({
|
|
15
|
+
background,
|
|
16
|
+
dragging,
|
|
17
|
+
height,
|
|
18
|
+
overrides = {}
|
|
19
|
+
}) => {
|
|
20
|
+
const [DragShadowContainer, dragShadowContainerProps] = getOverrides(overrides.DragShadowContainer, StyledDragShadowContainer);
|
|
21
|
+
const [DragShadow, dragShadowProps] = getOverrides(overrides.DragShadow, StyledDragShadow);
|
|
22
|
+
return /*#__PURE__*/React.createElement(DragShadowContainer, _extends({
|
|
23
|
+
$width: dragShadowWidth,
|
|
24
|
+
$height: height,
|
|
25
|
+
$dragging: dragging
|
|
26
|
+
}, dragShadowContainerProps), /*#__PURE__*/React.createElement(DragShadow, _extends({
|
|
27
|
+
$width: dragShadowWidth,
|
|
28
|
+
$background: background
|
|
29
|
+
}, dragShadowProps)));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default DragShadow;
|
|
@@ -9,39 +9,32 @@ LICENSE file in the root directory of this source tree.
|
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
import { useStyletron } from '../styles/index.js';
|
|
11
11
|
import { getOverrides } from '../helpers/overrides.js';
|
|
12
|
-
import { PINHEAD_TYPES, NEEDLE_SIZES,
|
|
12
|
+
import { PINHEAD_TYPES, NEEDLE_SIZES, PINHEAD_SIZES_SHAPES, LABEL_ENHANCER_POSITIONS, KIND, dragShadowHeight, dragShadowMarginTop } from './constants.js';
|
|
13
13
|
import PinHead from './pin-head.js';
|
|
14
|
-
import
|
|
14
|
+
import Needle from './needle.js';
|
|
15
|
+
import DragShadow from './drag-shadow.js';
|
|
16
|
+
import { StyledFixedMarkerDragContainer, StyledFixedMarkerRoot } from './styled-components.js';
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
$background: background,
|
|
24
|
-
$height: NEEDLE_HEIGHTS[size]
|
|
25
|
-
}, needleProps));
|
|
26
|
-
};
|
|
18
|
+
function getColors(kind, theme) {
|
|
19
|
+
if (kind === KIND.accent) {
|
|
20
|
+
return {
|
|
21
|
+
color: theme.colors.contentInversePrimary,
|
|
22
|
+
backgroundColor: theme.colors.backgroundAccent
|
|
23
|
+
};
|
|
24
|
+
}
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}, dragShadowContainerProps), /*#__PURE__*/React.createElement(DragShadow, _extends({
|
|
41
|
-
$width: dragShadowWidth,
|
|
42
|
-
$background: background
|
|
43
|
-
}, dragShadowProps)));
|
|
44
|
-
};
|
|
26
|
+
if (kind === KIND.negative) {
|
|
27
|
+
return {
|
|
28
|
+
color: theme.colors.contentInversePrimary,
|
|
29
|
+
backgroundColor: theme.colors.backgroundNegative
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
color: theme.colors.contentInversePrimary,
|
|
35
|
+
backgroundColor: theme.colors.backgroundInversePrimary
|
|
36
|
+
};
|
|
37
|
+
}
|
|
45
38
|
|
|
46
39
|
const FixedMarker = ({
|
|
47
40
|
size = PINHEAD_SIZES_SHAPES.medium,
|
|
@@ -49,28 +42,36 @@ const FixedMarker = ({
|
|
|
49
42
|
label,
|
|
50
43
|
startEnhancer,
|
|
51
44
|
endEnhancer,
|
|
52
|
-
|
|
53
|
-
background,
|
|
45
|
+
kind = KIND.default,
|
|
54
46
|
dragging = false,
|
|
55
|
-
overrides = {}
|
|
47
|
+
overrides = {},
|
|
48
|
+
labelEnhancerContent = null,
|
|
49
|
+
labelEnhancerPosition = LABEL_ENHANCER_POSITIONS.bottom,
|
|
50
|
+
badgeEnhancerSize = null,
|
|
51
|
+
badgeEnhancerContent = null,
|
|
52
|
+
...restProps
|
|
56
53
|
}) => {
|
|
57
54
|
const [, theme] = useStyletron();
|
|
58
55
|
const {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
color = color || primaryB;
|
|
65
|
-
background = background || backgroundInversePrimary;
|
|
66
|
-
const doesPinHeadTransformOnDrag = needle !== NEEDLE_SIZES.none;
|
|
67
|
-
const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
|
|
56
|
+
color,
|
|
57
|
+
backgroundColor
|
|
58
|
+
} = getColors(kind, theme);
|
|
59
|
+
const doesPinHeadTransformOnDrag = needle !== NEEDLE_SIZES.none && size !== PINHEAD_SIZES_SHAPES.xxSmallCircle && size !== PINHEAD_SIZES_SHAPES.xxSmallSquare;
|
|
60
|
+
const [Root, rootProps] = getOverrides(overrides.Root, StyledFixedMarkerRoot);
|
|
68
61
|
const [FixedMarkerDragContainer, fixedMarkerDragContainerProps] = getOverrides(overrides.DragContainer, StyledFixedMarkerDragContainer);
|
|
62
|
+
const renderNeedle = needle !== NEEDLE_SIZES.none && ![PINHEAD_SIZES_SHAPES.xxSmallCircle, PINHEAD_SIZES_SHAPES.xxSmallSquare].includes(size);
|
|
63
|
+
|
|
64
|
+
if (process.env.NODE_ENV !== "production") {
|
|
65
|
+
if (needle !== NEEDLE_SIZES.none && [PINHEAD_SIZES_SHAPES.xxSmallCircle, PINHEAD_SIZES_SHAPES.xxSmallSquare].includes(size)) {
|
|
66
|
+
console.warn(`Needles cannot be rendered with ${PINHEAD_SIZES_SHAPES.xxSmallCircle} or ${PINHEAD_SIZES_SHAPES.xxSmallSquare} pin heads`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
69
70
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
70
71
|
"data-baseweb": "fixed-map-marker"
|
|
71
72
|
}, rootProps), /*#__PURE__*/React.createElement(FixedMarkerDragContainer, _extends({
|
|
72
73
|
$translateAmount: dragShadowMarginTop + dragShadowHeight,
|
|
73
|
-
$performTranslate: doesPinHeadTransformOnDrag && dragging
|
|
74
|
+
$performTranslate: doesPinHeadTransformOnDrag && !dragging
|
|
74
75
|
}, fixedMarkerDragContainerProps), /*#__PURE__*/React.createElement(PinHead, _extends({
|
|
75
76
|
size: size,
|
|
76
77
|
label: label
|
|
@@ -80,15 +81,20 @@ const FixedMarker = ({
|
|
|
80
81
|
endEnhancer
|
|
81
82
|
} : {}, {
|
|
82
83
|
color: color,
|
|
83
|
-
background:
|
|
84
|
+
background: backgroundColor,
|
|
84
85
|
type: PINHEAD_TYPES.fixed,
|
|
85
|
-
overrides: overrides
|
|
86
|
-
|
|
86
|
+
overrides: overrides,
|
|
87
|
+
badgeEnhancerSize: badgeEnhancerSize,
|
|
88
|
+
badgeEnhancerContent: badgeEnhancerContent,
|
|
89
|
+
labelEnhancerContent: labelEnhancerContent,
|
|
90
|
+
labelEnhancerPosition: labelEnhancerPosition,
|
|
91
|
+
needle: needle
|
|
92
|
+
})), renderNeedle && /*#__PURE__*/React.createElement(Needle, {
|
|
87
93
|
size: needle,
|
|
88
|
-
background:
|
|
94
|
+
background: backgroundColor,
|
|
89
95
|
overrides: overrides
|
|
90
96
|
})), doesPinHeadTransformOnDrag && /*#__PURE__*/React.createElement(DragShadow, {
|
|
91
|
-
background:
|
|
97
|
+
background: backgroundColor,
|
|
92
98
|
dragging: dragging,
|
|
93
99
|
height: dragShadowMarginTop + dragShadowHeight,
|
|
94
100
|
overrides: overrides
|
|
@@ -10,12 +10,22 @@ import * as React from 'react';
|
|
|
10
10
|
import { useStyletron } from '../styles/index.js';
|
|
11
11
|
import PinHead from './pin-head.js';
|
|
12
12
|
import { getOverrides } from '../helpers/overrides.js';
|
|
13
|
-
import {
|
|
14
|
-
import { FLOATING_MARKER_ANCHOR_POSITIONS, PINHEAD_SIZES_SHAPES, PINHEAD_TYPES, FLOATING_MARKER_ANCHOR_TYPES,
|
|
13
|
+
import { StyledFloatingMarkerRoot, StyledFloatingMarkerAnchorContainer, StyledFloatingMarkerPinHeadContainer } from './styled-components.js';
|
|
14
|
+
import { FLOATING_MARKER_ANCHOR_POSITIONS, PINHEAD_SIZES_SHAPES, PINHEAD_TYPES, FLOATING_MARKER_ANCHOR_TYPES, PINHEAD_DIMENSIONS } from './constants.js';
|
|
15
|
+
|
|
16
|
+
function getAnchorPinHeadSize(anchorType) {
|
|
17
|
+
if (anchorType === FLOATING_MARKER_ANCHOR_TYPES.circle) {
|
|
18
|
+
return PINHEAD_SIZES_SHAPES.xSmallCircle;
|
|
19
|
+
} else if (anchorType === FLOATING_MARKER_ANCHOR_TYPES.square) {
|
|
20
|
+
return PINHEAD_SIZES_SHAPES.xSmallSquare;
|
|
21
|
+
} else if (anchorType === FLOATING_MARKER_ANCHOR_TYPES.xxSmallSquare) {
|
|
22
|
+
return PINHEAD_SIZES_SHAPES.xxSmallSquare;
|
|
23
|
+
} else {
|
|
24
|
+
return PINHEAD_SIZES_SHAPES.xxSmallCircle;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
15
27
|
|
|
16
28
|
const FloatingMarker = ({
|
|
17
|
-
color,
|
|
18
|
-
background,
|
|
19
29
|
label,
|
|
20
30
|
size = PINHEAD_SIZES_SHAPES.medium,
|
|
21
31
|
anchor = FLOATING_MARKER_ANCHOR_POSITIONS.bottomLeft,
|
|
@@ -33,21 +43,20 @@ const FloatingMarker = ({
|
|
|
33
43
|
primaryB
|
|
34
44
|
}
|
|
35
45
|
} = theme;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const anchorPinHeadSize = anchorType === FLOATING_MARKER_ANCHOR_TYPES.circle ? PINHEAD_SIZES_SHAPES.xSmallCircle : PINHEAD_SIZES_SHAPES.xSmallSquare;
|
|
39
|
-
const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
|
|
46
|
+
const anchorPinHeadSize = getAnchorPinHeadSize(anchorType);
|
|
47
|
+
const [Root, rootProps] = getOverrides(overrides.Root, StyledFloatingMarkerRoot);
|
|
40
48
|
const [FloatingMarkerPinHeadContainer, floatingMarkerPinHeadContainerProps] = getOverrides(overrides.PinHeadContainer, StyledFloatingMarkerPinHeadContainer);
|
|
41
49
|
const [FloatingMarkerAnchorContainer, floatingMarkerAnchorContainerProps] = getOverrides(overrides.AnchorContainer, StyledFloatingMarkerAnchorContainer);
|
|
42
50
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
43
|
-
"data-baseweb": "floating-map-marker"
|
|
51
|
+
"data-baseweb": "floating-map-marker",
|
|
52
|
+
$size: PINHEAD_DIMENSIONS[anchorPinHeadSize].height
|
|
44
53
|
}, rootProps), /*#__PURE__*/React.createElement(FloatingMarkerPinHeadContainer, _extends({
|
|
45
54
|
$anchor: anchor,
|
|
46
|
-
$anchorSize:
|
|
55
|
+
$anchorSize: PINHEAD_DIMENSIONS[anchorPinHeadSize].height
|
|
47
56
|
}, floatingMarkerPinHeadContainerProps), /*#__PURE__*/React.createElement(PinHead, {
|
|
48
57
|
size: size,
|
|
49
|
-
color:
|
|
50
|
-
background:
|
|
58
|
+
color: primaryA,
|
|
59
|
+
background: backgroundPrimary,
|
|
51
60
|
type: PINHEAD_TYPES.floating,
|
|
52
61
|
label: label,
|
|
53
62
|
startEnhancer: startEnhancer,
|
package/es/map-marker/index.js
CHANGED
|
@@ -6,4 +6,4 @@ LICENSE file in the root directory of this source tree.
|
|
|
6
6
|
*/
|
|
7
7
|
export { default as FixedMarker } from './fixed-marker.js';
|
|
8
8
|
export { default as FloatingMarker } from './floating-marker.js';
|
|
9
|
-
export { FLOATING_MARKER_ANCHOR_POSITIONS, FLOATING_MARKER_SIZES, FLOATING_MARKER_ANCHOR_TYPES, NEEDLE_SIZES, PINHEAD_SIZES_SHAPES } from './constants.js';
|
|
9
|
+
export { FLOATING_MARKER_ANCHOR_POSITIONS, FLOATING_MARKER_SIZES, FLOATING_MARKER_ANCHOR_TYPES, NEEDLE_SIZES, PINHEAD_SIZES_SHAPES, BADGE_ENHANCER_SIZES, LABEL_ENHANCER_POSITIONS, KIND } from './constants.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Copyright (c) Uber Technologies, Inc.
|
|
5
|
+
|
|
6
|
+
This source code is licensed under the MIT license found in the
|
|
7
|
+
LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { getOverrides } from '../helpers/overrides.js';
|
|
11
|
+
import { RelativeContainer, StyledStrokedLabel, StyledStrokedLabelContainer } from './styled-components.js';
|
|
12
|
+
import { LABEL_ENHANCER_POSITIONS } from './constants.js';
|
|
13
|
+
|
|
14
|
+
const LabelEnhancer = ({
|
|
15
|
+
labelEnhancerContent,
|
|
16
|
+
labelEnhancerPosition,
|
|
17
|
+
needleHeight,
|
|
18
|
+
size,
|
|
19
|
+
overrides = {}
|
|
20
|
+
}) => {
|
|
21
|
+
if (!labelEnhancerPosition || labelEnhancerPosition === LABEL_ENHANCER_POSITIONS.none) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!labelEnhancerContent) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const [StrokedLabelContainer, strokedLabelContainerProps] = getOverrides(overrides.LabelEnhancerContainer, StyledStrokedLabelContainer);
|
|
30
|
+
const [StrokedLabel, strokedLabelProps] = getOverrides(overrides.LabelEnhancer, StyledStrokedLabel);
|
|
31
|
+
return /*#__PURE__*/React.createElement(StrokedLabelContainer, _extends({
|
|
32
|
+
$position: labelEnhancerPosition,
|
|
33
|
+
$labelOffset: needleHeight
|
|
34
|
+
}, strokedLabelContainerProps), /*#__PURE__*/React.createElement(RelativeContainer, null, /*#__PURE__*/React.createElement(StrokedLabel, _extends({
|
|
35
|
+
$size: size
|
|
36
|
+
}, strokedLabelProps), labelEnhancerContent)));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default LabelEnhancer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Copyright (c) Uber Technologies, Inc.
|
|
5
|
+
|
|
6
|
+
This source code is licensed under the MIT license found in the
|
|
7
|
+
LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { getOverrides } from '../helpers/overrides.js';
|
|
11
|
+
import { NEEDLE_HEIGHTS } from './constants.js';
|
|
12
|
+
import { StyledNeedle } from './styled-components.js';
|
|
13
|
+
|
|
14
|
+
const Needle = ({
|
|
15
|
+
size,
|
|
16
|
+
background,
|
|
17
|
+
overrides = {}
|
|
18
|
+
}) => {
|
|
19
|
+
const [Needle, needleProps] = getOverrides(overrides.Needle, StyledNeedle);
|
|
20
|
+
return /*#__PURE__*/React.createElement(Needle, _extends({
|
|
21
|
+
$background: background,
|
|
22
|
+
$height: NEEDLE_HEIGHTS[size]
|
|
23
|
+
}, needleProps));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default Needle;
|
|
@@ -7,33 +7,11 @@ This source code is licensed under the MIT license found in the
|
|
|
7
7
|
LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
import * as React from 'react';
|
|
10
|
-
import { useStyletron, styled } from '../styles/index.js';
|
|
11
10
|
import { getOverrides } from '../helpers/overrides.js';
|
|
12
|
-
import {
|
|
13
|
-
import { PINHEAD_DIMENSIONS, PINHEAD_TYPES, PINHEAD_SIZES_SHAPES } from './constants.js';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
$color,
|
|
17
|
-
$height,
|
|
18
|
-
$size
|
|
19
|
-
}) => {
|
|
20
|
-
const match = {
|
|
21
|
-
[PINHEAD_SIZES_SHAPES.xSmallCircle]: 'LabelSmall',
|
|
22
|
-
[PINHEAD_SIZES_SHAPES.xSmallSquare]: 'LabelSmall',
|
|
23
|
-
[PINHEAD_SIZES_SHAPES.small]: 'LabelSmall',
|
|
24
|
-
[PINHEAD_SIZES_SHAPES.medium]: 'LabelMedium',
|
|
25
|
-
[PINHEAD_SIZES_SHAPES.large]: 'LabelLarge'
|
|
26
|
-
};
|
|
27
|
-
return { ...$theme.typography[match[$size]],
|
|
28
|
-
display: 'flex',
|
|
29
|
-
alignItems: 'center',
|
|
30
|
-
textAlign: 'center',
|
|
31
|
-
lineHeight: `${$height}px`,
|
|
32
|
-
height: `${$height}px`,
|
|
33
|
-
color: $color
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
_ContentItem.displayName = "_ContentItem";
|
|
11
|
+
import { StyledInnerXXSmallAnchor, StyledOuterXXSmallAnchor, StyledInnerXSmallAnchor, StyledOuterXSmallAnchor, StyledPinHead, RelativeContainer, StyledContentItem } from './styled-components.js';
|
|
12
|
+
import { PINHEAD_DIMENSIONS, PINHEAD_TYPES, PINHEAD_SIZES_SHAPES, NEEDLE_HEIGHTS, NEEDLE_SIZES } from './constants.js';
|
|
13
|
+
import BadgeEnhancer from './badge-enhancer.js';
|
|
14
|
+
import LabelEnhancer from './label-enhancer.js';
|
|
37
15
|
|
|
38
16
|
const PinHead = ({
|
|
39
17
|
size = PINHEAD_SIZES_SHAPES.medium,
|
|
@@ -44,17 +22,13 @@ const PinHead = ({
|
|
|
44
22
|
background,
|
|
45
23
|
type = PINHEAD_TYPES.fixed,
|
|
46
24
|
anchorType,
|
|
25
|
+
needle = NEEDLE_SIZES.none,
|
|
26
|
+
labelEnhancerContent,
|
|
27
|
+
labelEnhancerPosition,
|
|
28
|
+
badgeEnhancerSize,
|
|
29
|
+
badgeEnhancerContent,
|
|
47
30
|
overrides = {}
|
|
48
31
|
}) => {
|
|
49
|
-
const [, theme] = useStyletron();
|
|
50
|
-
const {
|
|
51
|
-
colors: {
|
|
52
|
-
backgroundPrimary,
|
|
53
|
-
primaryA
|
|
54
|
-
}
|
|
55
|
-
} = theme;
|
|
56
|
-
color = color || backgroundPrimary;
|
|
57
|
-
background = background || primaryA;
|
|
58
32
|
const activeElements = [label, StartEnhancer, EndEnhancer].filter(x => x);
|
|
59
33
|
const gridTemplateColumns = activeElements.map(() => 'auto').join(' ');
|
|
60
34
|
const forceCircle = activeElements.length === 1 && !label;
|
|
@@ -63,13 +37,35 @@ const PinHead = ({
|
|
|
63
37
|
icon
|
|
64
38
|
} = PINHEAD_DIMENSIONS[size];
|
|
65
39
|
const [PinHead, pinHeadProps] = getOverrides(overrides.PinHead, StyledPinHead);
|
|
66
|
-
const [ContentItem, contentItemProps] = getOverrides(overrides.PinHeadContent,
|
|
40
|
+
const [ContentItem, contentItemProps] = getOverrides(overrides.PinHeadContent, StyledContentItem);
|
|
41
|
+
const [InnerXXSmallAnchor, innerXXSmallAnchorProps] = getOverrides(overrides.InnerAnchor, StyledInnerXXSmallAnchor);
|
|
42
|
+
const [OuterXXSmallAnchor, outerXXSmallAnchorProps] = getOverrides(overrides.OuterAnchor, StyledOuterXXSmallAnchor);
|
|
67
43
|
const [InnerXSmallAnchor, innerXSmallAnchorProps] = getOverrides(overrides.InnerAnchor, StyledInnerXSmallAnchor);
|
|
68
44
|
const [OuterXSmallAnchor, outerXSmallAnchorProps] = getOverrides(overrides.OuterAnchor, StyledOuterXSmallAnchor);
|
|
45
|
+
const badge = /*#__PURE__*/React.createElement(BadgeEnhancer, {
|
|
46
|
+
markerType: type,
|
|
47
|
+
pinHeadSize: size,
|
|
48
|
+
badgeEnhancerSize: badgeEnhancerSize,
|
|
49
|
+
badgeEnhancerContent: badgeEnhancerContent,
|
|
50
|
+
overrides: overrides
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (type === PINHEAD_TYPES.fixed && (size === PINHEAD_SIZES_SHAPES.xxSmallCircle || size === PINHEAD_SIZES_SHAPES.xxSmallSquare)) {
|
|
54
|
+
const round = size === PINHEAD_SIZES_SHAPES.xxSmallCircle;
|
|
55
|
+
return /*#__PURE__*/React.createElement(OuterXXSmallAnchor, _extends({
|
|
56
|
+
$round: round,
|
|
57
|
+
$background: background,
|
|
58
|
+
$size: height
|
|
59
|
+
}, outerXXSmallAnchorProps), /*#__PURE__*/React.createElement(InnerXXSmallAnchor, _extends({
|
|
60
|
+
$color: color,
|
|
61
|
+
$round: round,
|
|
62
|
+
$size: icon
|
|
63
|
+
}, innerXXSmallAnchorProps)));
|
|
64
|
+
}
|
|
69
65
|
|
|
70
66
|
if (type === PINHEAD_TYPES.fixed && (size === PINHEAD_SIZES_SHAPES.xSmallSquare || size === PINHEAD_SIZES_SHAPES.xSmallCircle)) {
|
|
71
67
|
const round = size === PINHEAD_SIZES_SHAPES.xSmallCircle;
|
|
72
|
-
return /*#__PURE__*/React.createElement(OuterXSmallAnchor, _extends({
|
|
68
|
+
return /*#__PURE__*/React.createElement(RelativeContainer, null, badge, /*#__PURE__*/React.createElement(OuterXSmallAnchor, _extends({
|
|
73
69
|
$round: round,
|
|
74
70
|
$background: background,
|
|
75
71
|
$size: height
|
|
@@ -77,10 +73,16 @@ const PinHead = ({
|
|
|
77
73
|
$color: color,
|
|
78
74
|
$round: round,
|
|
79
75
|
$size: icon
|
|
80
|
-
}, innerXSmallAnchorProps)));
|
|
76
|
+
}, innerXSmallAnchorProps))));
|
|
81
77
|
}
|
|
82
78
|
|
|
83
|
-
return /*#__PURE__*/React.createElement(
|
|
79
|
+
return /*#__PURE__*/React.createElement(RelativeContainer, null, /*#__PURE__*/React.createElement(LabelEnhancer, {
|
|
80
|
+
labelEnhancerContent: labelEnhancerContent,
|
|
81
|
+
labelEnhancerPosition: labelEnhancerPosition,
|
|
82
|
+
needleHeight: NEEDLE_HEIGHTS[needle],
|
|
83
|
+
size: size,
|
|
84
|
+
overrides: overrides
|
|
85
|
+
}), badge, /*#__PURE__*/React.createElement(PinHead, _extends({
|
|
84
86
|
$background: background,
|
|
85
87
|
$height: height,
|
|
86
88
|
$gridTemplateColumns: gridTemplateColumns,
|
|
@@ -102,7 +104,7 @@ const PinHead = ({
|
|
|
102
104
|
$size: size
|
|
103
105
|
}, contentItemProps), /*#__PURE__*/React.createElement(EndEnhancer, {
|
|
104
106
|
size: icon
|
|
105
|
-
})));
|
|
107
|
+
}))));
|
|
106
108
|
};
|
|
107
109
|
|
|
108
110
|
export default PinHead;
|