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.
Files changed (174) hide show
  1. package/a11y/a11y.js +2 -2
  2. package/a11y/a11y.js.flow +3 -3
  3. package/button/styled-components.js +47 -18
  4. package/button/styled-components.js.flow +25 -5
  5. package/combobox/combobox.js +6 -3
  6. package/combobox/combobox.js.flow +4 -2
  7. package/combobox/types.js.flow +2 -0
  8. package/data-table/column-categorical.js +1 -1
  9. package/data-table/column-categorical.js.flow +2 -2
  10. package/data-table/column-numerical.js +307 -355
  11. package/data-table/column-numerical.js.flow +273 -287
  12. package/data-table/constants.js +17 -11
  13. package/data-table/constants.js.flow +11 -8
  14. package/data-table/data-table.js +53 -50
  15. package/data-table/data-table.js.flow +18 -13
  16. package/data-table/filter-shell.js +27 -4
  17. package/data-table/filter-shell.js.flow +33 -9
  18. package/data-table/locale.js +4 -2
  19. package/data-table/locale.js.flow +6 -2
  20. package/data-table/measure-column-widths.js +83 -121
  21. package/data-table/measure-column-widths.js.flow +87 -109
  22. package/datepicker/styled-components.js +1 -1
  23. package/datepicker/styled-components.js.flow +4 -1
  24. package/drawer/drawer.js +3 -1
  25. package/drawer/drawer.js.flow +7 -1
  26. package/es/a11y/a11y.js +2 -2
  27. package/es/button/styled-components.js +32 -2
  28. package/es/combobox/combobox.js +6 -3
  29. package/es/data-table/column-categorical.js +2 -2
  30. package/es/data-table/column-numerical.js +245 -317
  31. package/es/data-table/constants.js +12 -8
  32. package/es/data-table/data-table.js +18 -16
  33. package/es/data-table/filter-shell.js +26 -4
  34. package/es/data-table/locale.js +4 -2
  35. package/es/data-table/measure-column-widths.js +75 -86
  36. package/es/datepicker/styled-components.js +1 -1
  37. package/es/drawer/drawer.js +3 -1
  38. package/es/index.js +1 -1
  39. package/es/map-marker/badge-enhancer.js +61 -0
  40. package/es/map-marker/constants.js +146 -2
  41. package/es/map-marker/drag-shadow.js +32 -0
  42. package/es/map-marker/fixed-marker.js +54 -48
  43. package/es/map-marker/floating-marker.js +21 -12
  44. package/es/map-marker/index.js +1 -1
  45. package/es/map-marker/label-enhancer.js +39 -0
  46. package/es/map-marker/needle.js +26 -0
  47. package/es/map-marker/pin-head.js +42 -40
  48. package/es/map-marker/styled-components.js +177 -32
  49. package/es/map-marker/types.js +1 -1
  50. package/es/menu/maybe-child-menu.js +0 -2
  51. package/es/menu/nested-menus.js +49 -3
  52. package/es/menu/stateful-container.js +13 -12
  53. package/es/modal/modal.js +3 -1
  54. package/es/popover/popover.js +7 -3
  55. package/es/progress-bar/index.js +1 -1
  56. package/es/progress-bar/progressbar.js +25 -10
  57. package/es/progress-bar/styled-components.js +9 -5
  58. package/es/select/select-component.js +2 -10
  59. package/es/spinner/styled-components.js +34 -16
  60. package/es/table/filter.js +3 -1
  61. package/es/themes/dark-theme/color-component-tokens.js +19 -10
  62. package/es/themes/light-theme/color-component-tokens.js +19 -10
  63. package/es/timezonepicker/timezone-picker.js +53 -36
  64. package/es/timezonepicker/tzdata.js +2 -0
  65. package/es/timezonepicker/update-tzdata.js +69 -0
  66. package/es/toast/styled-components.js +18 -7
  67. package/esm/a11y/a11y.js +3 -3
  68. package/esm/button/styled-components.js +47 -18
  69. package/esm/combobox/combobox.js +6 -3
  70. package/esm/data-table/column-categorical.js +2 -2
  71. package/esm/data-table/column-numerical.js +304 -353
  72. package/esm/data-table/constants.js +12 -8
  73. package/esm/data-table/data-table.js +53 -50
  74. package/esm/data-table/filter-shell.js +26 -4
  75. package/esm/data-table/locale.js +4 -2
  76. package/esm/data-table/measure-column-widths.js +83 -121
  77. package/esm/datepicker/styled-components.js +1 -1
  78. package/esm/drawer/drawer.js +3 -1
  79. package/esm/index.js +1 -1
  80. package/esm/map-marker/badge-enhancer.js +79 -0
  81. package/esm/map-marker/constants.js +94 -4
  82. package/esm/map-marker/drag-shadow.js +53 -0
  83. package/esm/map-marker/fixed-marker.js +84 -80
  84. package/esm/map-marker/floating-marker.js +22 -13
  85. package/esm/map-marker/index.js +1 -1
  86. package/esm/map-marker/label-enhancer.js +60 -0
  87. package/esm/map-marker/needle.js +43 -0
  88. package/esm/map-marker/pin-head.js +77 -66
  89. package/esm/map-marker/styled-components.js +182 -51
  90. package/esm/map-marker/types.js +1 -1
  91. package/esm/menu/maybe-child-menu.js +0 -2
  92. package/esm/menu/nested-menus.js +66 -5
  93. package/esm/menu/stateful-container.js +15 -13
  94. package/esm/modal/modal.js +3 -1
  95. package/esm/popover/popover.js +7 -3
  96. package/esm/progress-bar/index.js +1 -1
  97. package/esm/progress-bar/progressbar.js +32 -10
  98. package/esm/progress-bar/styled-components.js +9 -4
  99. package/esm/select/select-component.js +2 -11
  100. package/esm/spinner/styled-components.js +35 -16
  101. package/esm/table/filter.js +3 -1
  102. package/esm/themes/dark-theme/color-component-tokens.js +19 -10
  103. package/esm/themes/light-theme/color-component-tokens.js +19 -10
  104. package/esm/timezonepicker/timezone-picker.js +64 -36
  105. package/esm/timezonepicker/tzdata.js +2 -0
  106. package/esm/timezonepicker/update-tzdata.js +160 -0
  107. package/esm/toast/styled-components.js +13 -5
  108. package/index.js +6 -0
  109. package/index.js.flow +1 -1
  110. package/map-marker/badge-enhancer.js +90 -0
  111. package/map-marker/badge-enhancer.js.flow +86 -0
  112. package/map-marker/constants.js +103 -5
  113. package/map-marker/constants.js.flow +152 -0
  114. package/map-marker/drag-shadow.js +64 -0
  115. package/map-marker/drag-shadow.js.flow +52 -0
  116. package/map-marker/fixed-marker.js +84 -78
  117. package/map-marker/fixed-marker.js.flow +78 -66
  118. package/map-marker/floating-marker.js +22 -13
  119. package/map-marker/floating-marker.js.flow +30 -17
  120. package/map-marker/index.d.ts +125 -24
  121. package/map-marker/index.js +18 -0
  122. package/map-marker/index.js.flow +3 -0
  123. package/map-marker/label-enhancer.js +71 -0
  124. package/map-marker/label-enhancer.js.flow +63 -0
  125. package/map-marker/needle.js +54 -0
  126. package/map-marker/needle.js.flow +29 -0
  127. package/map-marker/pin-head.js +80 -69
  128. package/map-marker/pin-head.js.flow +122 -84
  129. package/map-marker/styled-components.js +200 -62
  130. package/map-marker/styled-components.js.flow +172 -22
  131. package/map-marker/types.js.flow +69 -20
  132. package/menu/index.d.ts +9 -4
  133. package/menu/maybe-child-menu.js +0 -2
  134. package/menu/maybe-child-menu.js.flow +0 -2
  135. package/menu/nested-menus.js +66 -5
  136. package/menu/nested-menus.js.flow +50 -5
  137. package/menu/stateful-container.js +15 -13
  138. package/menu/stateful-container.js.flow +19 -13
  139. package/menu/types.js.flow +7 -1
  140. package/modal/modal.js +3 -1
  141. package/modal/modal.js.flow +2 -0
  142. package/package.json +5 -4
  143. package/popover/popover.js +7 -3
  144. package/popover/popover.js.flow +23 -17
  145. package/progress-bar/index.d.ts +2 -0
  146. package/progress-bar/index.js +6 -0
  147. package/progress-bar/index.js.flow +1 -0
  148. package/progress-bar/progressbar.js +32 -10
  149. package/progress-bar/progressbar.js.flow +35 -9
  150. package/progress-bar/styled-components.js +9 -4
  151. package/progress-bar/styled-components.js.flow +15 -4
  152. package/progress-bar/types.js.flow +12 -2
  153. package/select/select-component.js +2 -11
  154. package/select/select-component.js.flow +5 -7
  155. package/spinner/styled-components.js +35 -16
  156. package/spinner/styled-components.js.flow +37 -19
  157. package/spinner/types.js.flow +10 -0
  158. package/styles/index.js.flow +1 -1
  159. package/table/filter.js +3 -1
  160. package/table/filter.js.flow +5 -1
  161. package/themes/dark-theme/color-component-tokens.js +19 -10
  162. package/themes/dark-theme/color-component-tokens.js.flow +19 -10
  163. package/themes/light-theme/color-component-tokens.js +19 -10
  164. package/themes/light-theme/color-component-tokens.js.flow +19 -10
  165. package/themes/types.js.flow +9 -0
  166. package/timezonepicker/timezone-picker.js +69 -41
  167. package/timezonepicker/timezone-picker.js.flow +52 -46
  168. package/timezonepicker/types.js.flow +1 -1
  169. package/timezonepicker/tzdata.js +10 -0
  170. package/timezonepicker/tzdata.js.flow +347 -0
  171. package/timezonepicker/update-tzdata.js +164 -0
  172. package/timezonepicker/update-tzdata.js.flow +70 -0
  173. package/toast/styled-components.js +13 -5
  174. 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, NEEDLE_HEIGHTS, PINHEAD_SIZES_SHAPES, dragShadowHeight, dragShadowMarginTop, dragShadowWidth } from './constants.js';
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 { FixedMarkerDragContainer as StyledFixedMarkerDragContainer, FixedMarkerRoot as StyledRoot, Needle as StyledNeedle, DragShadow as StyledDragShadow, DragShadowContainer as StyledDragShadowContainer } from './styled-components.js';
14
+ import Needle from './needle.js';
15
+ import DragShadow from './drag-shadow.js';
16
+ import { StyledFixedMarkerDragContainer, StyledFixedMarkerRoot } from './styled-components.js';
15
17
 
16
- const Needle = ({
17
- size,
18
- background,
19
- overrides = {}
20
- }) => {
21
- const [Needle, needleProps] = getOverrides(overrides.Needle, StyledNeedle);
22
- return /*#__PURE__*/React.createElement(Needle, _extends({
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
- const DragShadow = ({
29
- background,
30
- dragging,
31
- height,
32
- overrides = {}
33
- }) => {
34
- const [DragShadowContainer, dragShadowContainerProps] = getOverrides(overrides.DragShadowContainer, StyledDragShadowContainer);
35
- const [DragShadow, dragShadowProps] = getOverrides(overrides.DragShadow, StyledDragShadow);
36
- return /*#__PURE__*/React.createElement(DragShadowContainer, _extends({
37
- $width: dragShadowWidth,
38
- $height: height,
39
- $dragging: dragging
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
- color,
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
- colors: {
60
- backgroundInversePrimary,
61
- primaryB
62
- }
63
- } = theme;
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: background,
84
+ background: backgroundColor,
84
85
  type: PINHEAD_TYPES.fixed,
85
- overrides: overrides
86
- })), /*#__PURE__*/React.createElement(Needle, {
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: background,
94
+ background: backgroundColor,
89
95
  overrides: overrides
90
96
  })), doesPinHeadTransformOnDrag && /*#__PURE__*/React.createElement(DragShadow, {
91
- background: 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 { FloatingMarkerRoot as StyledRoot, FloatingMarkerAnchorContainer as StyledFloatingMarkerAnchorContainer, FloatingMarkerPinHeadContainer as StyledFloatingMarkerPinHeadContainer } from './styled-components.js';
14
- import { FLOATING_MARKER_ANCHOR_POSITIONS, PINHEAD_SIZES_SHAPES, PINHEAD_TYPES, FLOATING_MARKER_ANCHOR_TYPES, anchorSize } from './constants.js';
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
- color = color || primaryA;
37
- background = background || backgroundPrimary;
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: anchorSize
55
+ $anchorSize: PINHEAD_DIMENSIONS[anchorPinHeadSize].height
47
56
  }, floatingMarkerPinHeadContainerProps), /*#__PURE__*/React.createElement(PinHead, {
48
57
  size: size,
49
- color: color,
50
- background: background,
58
+ color: primaryA,
59
+ background: backgroundPrimary,
51
60
  type: PINHEAD_TYPES.floating,
52
61
  label: label,
53
62
  startEnhancer: startEnhancer,
@@ -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 { InnerXSmallAnchor as StyledInnerXSmallAnchor, OuterXSmallAnchor as StyledOuterXSmallAnchor, PinHead as StyledPinHead } from './styled-components.js';
13
- import { PINHEAD_DIMENSIONS, PINHEAD_TYPES, PINHEAD_SIZES_SHAPES } from './constants.js';
14
- export const _ContentItem = styled('div', ({
15
- $theme,
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, _ContentItem);
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(PinHead, _extends({
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;