baseui 10.2.1 → 10.6.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 (142) hide show
  1. package/button/styled-components.js +1 -1
  2. package/button/styled-components.js.flow +4 -1
  3. package/data-table/data-table.js +13 -3
  4. package/data-table/data-table.js.flow +20 -4
  5. package/data-table/types.js.flow +2 -1
  6. package/datepicker/calendar-header.js +227 -95
  7. package/datepicker/calendar-header.js.flow +270 -139
  8. package/datepicker/constants.js +4 -2
  9. package/datepicker/constants.js.flow +2 -0
  10. package/datepicker/day.js +1 -0
  11. package/datepicker/day.js.flow +1 -0
  12. package/datepicker/index.d.ts +1 -0
  13. package/datepicker/types.js.flow +1 -0
  14. package/datepicker/utils/calendar-header-helpers.js +51 -0
  15. package/datepicker/utils/calendar-header-helpers.js.flow +53 -0
  16. package/dnd-list/index.js.flow +2 -1
  17. package/drawer/close-icon.js +3 -2
  18. package/drawer/close-icon.js.flow +2 -2
  19. package/drawer/drawer.js +5 -2
  20. package/drawer/drawer.js.flow +2 -2
  21. package/es/button/styled-components.js +1 -1
  22. package/es/data-table/data-table.js +13 -3
  23. package/es/datepicker/calendar-header.js +184 -84
  24. package/es/datepicker/constants.js +2 -1
  25. package/es/datepicker/day.js +1 -0
  26. package/es/datepicker/utils/calendar-header-helpers.js +34 -0
  27. package/es/dnd-list/index.js +2 -1
  28. package/es/drawer/close-icon.js +3 -2
  29. package/es/drawer/drawer.js +5 -2
  30. package/es/list/list-heading.js +17 -6
  31. package/es/map-marker/constants.js +69 -0
  32. package/es/map-marker/fixed-marker.js +98 -0
  33. package/es/map-marker/floating-marker.js +65 -0
  34. package/es/map-marker/index.js +9 -0
  35. package/es/map-marker/pin-head.js +108 -0
  36. package/es/map-marker/styled-components.js +156 -0
  37. package/es/map-marker/types.js +8 -0
  38. package/es/popover/stateful-container.js +4 -0
  39. package/es/rating/emoticon-rating.js +3 -1
  40. package/es/rating/star-rating.js +3 -1
  41. package/es/select/select-component.js +20 -6
  42. package/es/select/styled-components.js +34 -4
  43. package/es/snackbar/snackbar-context.js +16 -4
  44. package/es/spinner/styled-components.js +1 -1
  45. package/es/table-semantic/styled-components.js +6 -4
  46. package/es/table-semantic/table-builder.js +3 -0
  47. package/es/themes/dark-theme/color-component-tokens.js +1 -1
  48. package/es/themes/dark-theme/color-semantic-tokens.js +8 -7
  49. package/es/themes/light-theme/color-component-tokens.js +9 -9
  50. package/es/themes/light-theme/color-semantic-tokens.js +3 -2
  51. package/es/tokens/colors.js +2 -2
  52. package/es/tooltip/styled-components.js +8 -0
  53. package/esm/button/styled-components.js +1 -1
  54. package/esm/data-table/data-table.js +13 -3
  55. package/esm/datepicker/calendar-header.js +226 -95
  56. package/esm/datepicker/constants.js +2 -1
  57. package/esm/datepicker/day.js +1 -0
  58. package/esm/datepicker/utils/calendar-header-helpers.js +45 -0
  59. package/esm/dnd-list/index.js +2 -1
  60. package/esm/drawer/close-icon.js +3 -2
  61. package/esm/drawer/drawer.js +5 -2
  62. package/esm/list/list-heading.js +17 -6
  63. package/esm/map-marker/constants.js +62 -0
  64. package/esm/map-marker/fixed-marker.js +137 -0
  65. package/esm/map-marker/floating-marker.js +94 -0
  66. package/esm/map-marker/index.js +9 -0
  67. package/esm/map-marker/pin-head.js +144 -0
  68. package/esm/map-marker/styled-components.js +168 -0
  69. package/esm/map-marker/types.js +8 -0
  70. package/esm/popover/stateful-container.js +4 -0
  71. package/esm/rating/emoticon-rating.js +2 -2
  72. package/esm/rating/star-rating.js +2 -2
  73. package/esm/select/select-component.js +19 -6
  74. package/esm/select/styled-components.js +28 -4
  75. package/esm/snackbar/snackbar-context.js +16 -4
  76. package/esm/spinner/styled-components.js +1 -1
  77. package/esm/table-semantic/styled-components.js +6 -4
  78. package/esm/table-semantic/table-builder.js +3 -0
  79. package/esm/themes/dark-theme/color-component-tokens.js +1 -1
  80. package/esm/themes/dark-theme/color-semantic-tokens.js +8 -7
  81. package/esm/themes/light-theme/color-component-tokens.js +9 -9
  82. package/esm/themes/light-theme/color-semantic-tokens.js +3 -2
  83. package/esm/tokens/colors.js +2 -2
  84. package/esm/tooltip/styled-components.js +8 -0
  85. package/index.d.ts +1 -0
  86. package/link/index.d.ts +1 -0
  87. package/list/index.d.ts +36 -0
  88. package/list/list-heading.js +24 -7
  89. package/list/list-heading.js.flow +17 -8
  90. package/map-marker/constants.js +82 -0
  91. package/map-marker/constants.js.flow +74 -0
  92. package/map-marker/fixed-marker.js +152 -0
  93. package/map-marker/fixed-marker.js.flow +137 -0
  94. package/map-marker/floating-marker.js +109 -0
  95. package/map-marker/floating-marker.js.flow +102 -0
  96. package/map-marker/index.d.ts +104 -0
  97. package/map-marker/index.js +55 -0
  98. package/map-marker/index.js.flow +23 -0
  99. package/map-marker/package.json +4 -0
  100. package/map-marker/pin-head.js +159 -0
  101. package/map-marker/pin-head.js.flow +155 -0
  102. package/map-marker/styled-components.js +184 -0
  103. package/map-marker/styled-components.js.flow +177 -0
  104. package/map-marker/types.js +11 -0
  105. package/map-marker/types.js.flow +114 -0
  106. package/menu/index.d.ts +7 -0
  107. package/menu/types.js.flow +12 -0
  108. package/package.json +3 -2
  109. package/popover/stateful-container.js +4 -0
  110. package/popover/stateful-container.js.flow +3 -0
  111. package/rating/emoticon-rating.js +2 -2
  112. package/rating/emoticon-rating.js.flow +4 -1
  113. package/rating/star-rating.js +2 -2
  114. package/rating/star-rating.js.flow +4 -1
  115. package/select/select-component.js +19 -6
  116. package/select/select-component.js.flow +19 -6
  117. package/select/styled-components.js +28 -4
  118. package/select/styled-components.js.flow +30 -2
  119. package/select/types.js.flow +9 -0
  120. package/snackbar/snackbar-context.js +15 -4
  121. package/snackbar/snackbar-context.js.flow +15 -3
  122. package/spinner/styled-components.js +1 -1
  123. package/spinner/styled-components.js.flow +1 -1
  124. package/table-semantic/index.d.ts +1 -0
  125. package/table-semantic/styled-components.js +6 -4
  126. package/table-semantic/styled-components.js.flow +6 -4
  127. package/table-semantic/table-builder.js +3 -0
  128. package/table-semantic/table-builder.js.flow +3 -0
  129. package/theme.ts +2 -0
  130. package/themes/dark-theme/color-component-tokens.js +1 -1
  131. package/themes/dark-theme/color-component-tokens.js.flow +1 -1
  132. package/themes/dark-theme/color-semantic-tokens.js +8 -7
  133. package/themes/dark-theme/color-semantic-tokens.js.flow +7 -6
  134. package/themes/light-theme/color-component-tokens.js +9 -9
  135. package/themes/light-theme/color-component-tokens.js.flow +9 -9
  136. package/themes/light-theme/color-semantic-tokens.js +3 -2
  137. package/themes/light-theme/color-semantic-tokens.js.flow +2 -1
  138. package/themes/types.js.flow +1 -0
  139. package/tokens/colors.js +2 -2
  140. package/tokens/colors.js.flow +2 -2
  141. package/tooltip/styled-components.js +8 -0
  142. package/tooltip/styled-components.js.flow +8 -0
@@ -7,7 +7,7 @@ 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 React from 'react';
10
- import ReactIs from 'react-is';
10
+ import * as ReactIs from 'react-is';
11
11
  import { getOverrides } from '../helpers/overrides.js';
12
12
  import { StyledHeadingRoot, StyledHeadingContent, StyledHeadingContentRow, StyledHeadingEndEnhancerContainer, StyledHeadingEndEnhancerDescriptionContainer, StyledHeadingMainHeading, StyledHeadingSubHeading } from './styled-components.js';
13
13
 
@@ -35,9 +35,14 @@ function RenderNode(props) {
35
35
  return Component;
36
36
  }
37
37
 
38
+ function isMaxLinesValid(maxLines) {
39
+ return maxLines === 1 || maxLines === 2;
40
+ }
41
+
38
42
  const ListHeading = /*#__PURE__*/React.forwardRef((props, ref) => {
39
43
  const {
40
- overrides = {}
44
+ overrides = {},
45
+ maxLines
41
46
  } = props;
42
47
  const EndEnhancer = props.endEnhancer;
43
48
  const EndEnhancerDescription = props.endEnhancerDescription;
@@ -50,15 +55,21 @@ const ListHeading = /*#__PURE__*/React.forwardRef((props, ref) => {
50
55
  const [EndEnhancerDescriptionContainer, endEnhancerDescriptionContainerProps] = getOverrides(overrides.EndEnhancerDescriptionContainer, StyledHeadingEndEnhancerDescriptionContainer);
51
56
  const isEndEnhancerString = typeof EndEnhancer === 'string';
52
57
 
53
- if (isEndEnhancerString && EndEnhancerDescription) {
54
- console.warn('endEnhancerDescription will not be rendered if endEnhancer is not a string');
58
+ if (process.env.NODE_ENV !== "production") {
59
+ if (isEndEnhancerString && EndEnhancerDescription) {
60
+ console.warn('endEnhancerDescription will not be rendered if endEnhancer is not a string');
61
+ }
62
+
63
+ if (maxLines && !isMaxLinesValid(maxLines)) {
64
+ console.warn('maxLines must be 1 or 2.');
65
+ }
55
66
  }
56
67
 
57
68
  return /*#__PURE__*/React.createElement(Root // eslint-disable-next-line flowtype/no-weak-types
58
69
  , _extends({
59
70
  ref: ref
60
71
  }, rootProps), /*#__PURE__*/React.createElement(Content, contentProps, /*#__PURE__*/React.createElement(StyledHeadingContentRow, null, /*#__PURE__*/React.createElement(HeadingContainer, _extends({
61
- $maxLines: props.maxLines
72
+ $maxLines: isMaxLinesValid(maxLines) ? maxLines : 1
62
73
  }, headingContainerProps), /*#__PURE__*/React.createElement(RenderNode, {
63
74
  component: props.heading
64
75
  })), EndEnhancer && /*#__PURE__*/React.createElement(EndEnhancerContainer, _extends({
@@ -66,7 +77,7 @@ const ListHeading = /*#__PURE__*/React.forwardRef((props, ref) => {
66
77
  }, endEnhancerContainerProps), /*#__PURE__*/React.createElement(RenderNode, {
67
78
  component: EndEnhancer
68
79
  }))), (SubHeading || EndEnhancerDescription) && /*#__PURE__*/React.createElement(StyledHeadingContentRow, null, /*#__PURE__*/React.createElement(SubHeadingContainer, _extends({
69
- $maxLines: props.maxLines
80
+ $maxLines: isMaxLinesValid(maxLines) ? maxLines : 1
70
81
  }, subHeadingContainerProps), /*#__PURE__*/React.createElement(RenderNode, {
71
82
  component: SubHeading
72
83
  })), EndEnhancerDescription && isEndEnhancerString && /*#__PURE__*/React.createElement(EndEnhancerDescriptionContainer, endEnhancerDescriptionContainerProps, /*#__PURE__*/React.createElement(RenderNode, {
@@ -0,0 +1,69 @@
1
+ /*
2
+ Copyright (c) Uber Technologies, Inc.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ */
7
+ export const NEEDLE_SIZES = Object.freeze({
8
+ none: 'none',
9
+ short: 'short',
10
+ medium: 'medium',
11
+ tall: 'tall'
12
+ });
13
+ export const NEEDLE_HEIGHTS = Object.freeze({
14
+ [NEEDLE_SIZES.none]: 0,
15
+ [NEEDLE_SIZES.short]: 4,
16
+ [NEEDLE_SIZES.medium]: 12,
17
+ [NEEDLE_SIZES.tall]: 20
18
+ });
19
+ export const PINHEAD_SIZES_SHAPES = Object.freeze({
20
+ xSmallCircle: 'x-small-circle',
21
+ xSmallSquare: 'x-small-square',
22
+ small: 'small',
23
+ medium: 'medium',
24
+ large: 'large'
25
+ });
26
+ export const xSmallPinheadDimension = {
27
+ height: 16,
28
+ icon: 4
29
+ };
30
+ export const PINHEAD_DIMENSIONS = Object.freeze({
31
+ [PINHEAD_SIZES_SHAPES.xSmallSquare]: xSmallPinheadDimension,
32
+ [PINHEAD_SIZES_SHAPES.xSmallCircle]: xSmallPinheadDimension,
33
+ [PINHEAD_SIZES_SHAPES.small]: {
34
+ height: 24,
35
+ icon: 16
36
+ },
37
+ [PINHEAD_SIZES_SHAPES.medium]: {
38
+ height: 36,
39
+ icon: 16
40
+ },
41
+ [PINHEAD_SIZES_SHAPES.large]: {
42
+ height: 48,
43
+ icon: 24
44
+ }
45
+ });
46
+ export const PINHEAD_TYPES = Object.freeze({
47
+ floating: 'floating',
48
+ fixed: 'fixed'
49
+ });
50
+ export const FLOATING_MARKER_SIZES = Object.freeze({
51
+ small: 'small',
52
+ medium: 'medium',
53
+ large: 'large'
54
+ });
55
+ export const FLOATING_MARKER_ANCHOR_POSITIONS = Object.freeze({
56
+ none: 'none',
57
+ topLeft: 'top-left',
58
+ topRight: 'top-right',
59
+ bottomRight: 'bottom-right',
60
+ bottomLeft: 'bottom-left'
61
+ });
62
+ export const FLOATING_MARKER_ANCHOR_TYPES = Object.freeze({
63
+ circle: 'circle',
64
+ square: 'square'
65
+ });
66
+ export const dragShadowHeight = 4;
67
+ export const dragShadowMarginTop = 6;
68
+ export const dragShadowWidth = 6;
69
+ export const anchorSize = 16;
@@ -0,0 +1,98 @@
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 { useStyletron } from '../styles/index.js';
11
+ import { getOverrides } from '../helpers/overrides.js';
12
+ import { PINHEAD_TYPES, NEEDLE_SIZES, NEEDLE_HEIGHTS, PINHEAD_SIZES_SHAPES, dragShadowHeight, dragShadowMarginTop, dragShadowWidth } from './constants.js';
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';
15
+
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
+ };
27
+
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
+ };
45
+
46
+ const FixedMarker = ({
47
+ size = PINHEAD_SIZES_SHAPES.medium,
48
+ needle = NEEDLE_SIZES.medium,
49
+ label,
50
+ startEnhancer,
51
+ endEnhancer,
52
+ color,
53
+ background,
54
+ dragging = false,
55
+ overrides = {}
56
+ }) => {
57
+ const [, theme] = useStyletron();
58
+ 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);
68
+ const [FixedMarkerDragContainer, fixedMarkerDragContainerProps] = getOverrides(overrides.DragContainer, StyledFixedMarkerDragContainer);
69
+ return /*#__PURE__*/React.createElement(Root, _extends({
70
+ "data-baseweb": "fixed-map-marker"
71
+ }, rootProps), /*#__PURE__*/React.createElement(FixedMarkerDragContainer, _extends({
72
+ $translateAmount: dragShadowMarginTop + dragShadowHeight,
73
+ $performTranslate: doesPinHeadTransformOnDrag && dragging
74
+ }, fixedMarkerDragContainerProps), /*#__PURE__*/React.createElement(PinHead, _extends({
75
+ size: size,
76
+ label: label
77
+ }, startEnhancer ? {
78
+ startEnhancer
79
+ } : {}, endEnhancer ? {
80
+ endEnhancer
81
+ } : {}, {
82
+ color: color,
83
+ background: background,
84
+ type: PINHEAD_TYPES.fixed,
85
+ overrides: overrides
86
+ })), /*#__PURE__*/React.createElement(Needle, {
87
+ size: needle,
88
+ background: background,
89
+ overrides: overrides
90
+ })), doesPinHeadTransformOnDrag && /*#__PURE__*/React.createElement(DragShadow, {
91
+ background: background,
92
+ dragging: dragging,
93
+ height: dragShadowMarginTop + dragShadowHeight,
94
+ overrides: overrides
95
+ }));
96
+ };
97
+
98
+ export default FixedMarker;
@@ -0,0 +1,65 @@
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 { useStyletron } from '../styles/index.js';
11
+ import PinHead from './pin-head.js';
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';
15
+
16
+ const FloatingMarker = ({
17
+ color,
18
+ background,
19
+ label,
20
+ size = PINHEAD_SIZES_SHAPES.medium,
21
+ anchor = FLOATING_MARKER_ANCHOR_POSITIONS.bottomLeft,
22
+ endEnhancer,
23
+ startEnhancer,
24
+ anchorType = FLOATING_MARKER_ANCHOR_TYPES.circle,
25
+ overrides = {}
26
+ }) => {
27
+ const [, theme] = useStyletron();
28
+ const {
29
+ colors: {
30
+ backgroundPrimary,
31
+ backgroundInversePrimary,
32
+ primaryA,
33
+ primaryB
34
+ }
35
+ } = 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);
40
+ const [FloatingMarkerPinHeadContainer, floatingMarkerPinHeadContainerProps] = getOverrides(overrides.PinHeadContainer, StyledFloatingMarkerPinHeadContainer);
41
+ const [FloatingMarkerAnchorContainer, floatingMarkerAnchorContainerProps] = getOverrides(overrides.AnchorContainer, StyledFloatingMarkerAnchorContainer);
42
+ return /*#__PURE__*/React.createElement(Root, _extends({
43
+ "data-baseweb": "floating-map-marker"
44
+ }, rootProps), /*#__PURE__*/React.createElement(FloatingMarkerPinHeadContainer, _extends({
45
+ $anchor: anchor,
46
+ $anchorSize: anchorSize
47
+ }, floatingMarkerPinHeadContainerProps), /*#__PURE__*/React.createElement(PinHead, {
48
+ size: size,
49
+ color: color,
50
+ background: background,
51
+ type: PINHEAD_TYPES.floating,
52
+ label: label,
53
+ startEnhancer: startEnhancer,
54
+ endEnhancer: endEnhancer,
55
+ overrides: overrides
56
+ })), anchor !== FLOATING_MARKER_ANCHOR_POSITIONS.none && /*#__PURE__*/React.createElement(FloatingMarkerAnchorContainer, floatingMarkerAnchorContainerProps, /*#__PURE__*/React.createElement(PinHead, {
57
+ size: anchorPinHeadSize,
58
+ color: primaryB,
59
+ background: backgroundInversePrimary,
60
+ type: PINHEAD_TYPES.fixed,
61
+ overrides: overrides
62
+ })));
63
+ };
64
+
65
+ export default FloatingMarker;
@@ -0,0 +1,9 @@
1
+ /*
2
+ Copyright (c) Uber Technologies, Inc.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ */
7
+ export { default as FixedMarker } from './fixed-marker.js';
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';
@@ -0,0 +1,108 @@
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 { useStyletron, styled } from '../styles/index.js';
11
+ 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";
37
+
38
+ const PinHead = ({
39
+ size = PINHEAD_SIZES_SHAPES.medium,
40
+ label = '',
41
+ startEnhancer: StartEnhancer,
42
+ endEnhancer: EndEnhancer,
43
+ color,
44
+ background,
45
+ type = PINHEAD_TYPES.fixed,
46
+ anchorType,
47
+ overrides = {}
48
+ }) => {
49
+ const [, theme] = useStyletron();
50
+ const {
51
+ colors: {
52
+ backgroundPrimary,
53
+ primaryA
54
+ }
55
+ } = theme;
56
+ color = color || backgroundPrimary;
57
+ background = background || primaryA;
58
+ const activeElements = [label, StartEnhancer, EndEnhancer].filter(x => x);
59
+ const gridTemplateColumns = activeElements.map(() => 'auto').join(' ');
60
+ const forceCircle = activeElements.length === 1 && !label;
61
+ const {
62
+ height,
63
+ icon
64
+ } = PINHEAD_DIMENSIONS[size];
65
+ const [PinHead, pinHeadProps] = getOverrides(overrides.PinHead, StyledPinHead);
66
+ const [ContentItem, contentItemProps] = getOverrides(overrides.PinHeadContent, _ContentItem);
67
+ const [InnerXSmallAnchor, innerXSmallAnchorProps] = getOverrides(overrides.InnerAnchor, StyledInnerXSmallAnchor);
68
+ const [OuterXSmallAnchor, outerXSmallAnchorProps] = getOverrides(overrides.OuterAnchor, StyledOuterXSmallAnchor);
69
+
70
+ if (type === PINHEAD_TYPES.fixed && (size === PINHEAD_SIZES_SHAPES.xSmallSquare || size === PINHEAD_SIZES_SHAPES.xSmallCircle)) {
71
+ const round = size === PINHEAD_SIZES_SHAPES.xSmallCircle;
72
+ return /*#__PURE__*/React.createElement(OuterXSmallAnchor, _extends({
73
+ $round: round,
74
+ $background: background,
75
+ $size: height
76
+ }, outerXSmallAnchorProps), /*#__PURE__*/React.createElement(InnerXSmallAnchor, _extends({
77
+ $color: color,
78
+ $round: round,
79
+ $size: icon
80
+ }, innerXSmallAnchorProps)));
81
+ }
82
+
83
+ return /*#__PURE__*/React.createElement(PinHead, _extends({
84
+ $background: background,
85
+ $height: height,
86
+ $gridTemplateColumns: gridTemplateColumns,
87
+ $forceCircle: forceCircle,
88
+ $type: type
89
+ }, pinHeadProps), StartEnhancer && /*#__PURE__*/React.createElement(ContentItem, _extends({
90
+ $height: height,
91
+ $color: color,
92
+ $size: size
93
+ }, contentItemProps), /*#__PURE__*/React.createElement(StartEnhancer, {
94
+ size: icon
95
+ })), label && /*#__PURE__*/React.createElement(ContentItem, _extends({
96
+ $height: height,
97
+ $color: color,
98
+ $size: size
99
+ }, contentItemProps), label), EndEnhancer && /*#__PURE__*/React.createElement(ContentItem, _extends({
100
+ $height: height,
101
+ $color: color,
102
+ $size: size
103
+ }, contentItemProps), /*#__PURE__*/React.createElement(EndEnhancer, {
104
+ size: icon
105
+ })));
106
+ };
107
+
108
+ export default PinHead;
@@ -0,0 +1,156 @@
1
+ /*
2
+ Copyright (c) Uber Technologies, Inc.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { styled } from '../styles/index.js';
8
+ import { FLOATING_MARKER_ANCHOR_POSITIONS, xSmallPinheadDimension } from './constants.js';
9
+ export const getAnchorTransform = (anchor, anchorSize) => ({
10
+ [FLOATING_MARKER_ANCHOR_POSITIONS.none]: ``,
11
+ [FLOATING_MARKER_ANCHOR_POSITIONS.topLeft]: `translate(${anchorSize}px, ${anchorSize}px)`,
12
+ [FLOATING_MARKER_ANCHOR_POSITIONS.topRight]: `translate(-100%, ${anchorSize}px)`,
13
+ [FLOATING_MARKER_ANCHOR_POSITIONS.bottomLeft]: `translate(${anchorSize}px, -100%)`,
14
+ [FLOATING_MARKER_ANCHOR_POSITIONS.bottomRight]: `translate(-100%, -100%)`
15
+ })[anchor];
16
+ export const DragShadowContainer = styled('div', ({
17
+ $theme,
18
+ $height,
19
+ $width,
20
+ $dragging
21
+ }) => ({
22
+ width: `${$width}px`,
23
+ height: `${$height}px`,
24
+ opacity: $dragging ? 1 : 0,
25
+ visibility: $dragging ? 'visible' : 'hidden',
26
+ transition: `${$theme.animation.timing300} ${$theme.animation.easeOutCurve} all`,
27
+ position: 'relative',
28
+ boxShadow: $theme.lighting.shadow600
29
+ }));
30
+ DragShadowContainer.displayName = "DragShadowContainer";
31
+ export const DragShadow = styled('div', ({
32
+ $theme,
33
+ $background,
34
+ $width
35
+ }) => ({
36
+ background: $background,
37
+ borderRadius: '50%',
38
+ width: `${$width}px`,
39
+ height: `${4}px`,
40
+ position: 'absolute',
41
+ bottom: 0
42
+ }));
43
+ DragShadow.displayName = "DragShadow";
44
+ export const Needle = styled('div', ({
45
+ $theme,
46
+ $background,
47
+ $height
48
+ }) => ({
49
+ background: $background,
50
+ width: '4px',
51
+ height: `${$height}px`,
52
+ boxShadow: $theme.lighting.shadow600
53
+ }));
54
+ Needle.displayName = "Needle";
55
+ export const FloatingMarkerRoot = styled('div', () => ({
56
+ position: 'relative',
57
+ height: `${xSmallPinheadDimension.height}px`,
58
+ width: `${xSmallPinheadDimension.height}px`
59
+ }));
60
+ FloatingMarkerRoot.displayName = "FloatingMarkerRoot";
61
+ export const FloatingMarkerPinHeadContainer = styled('div', ({
62
+ $theme,
63
+ $anchor,
64
+ $anchorSize
65
+ }) => ({
66
+ position: 'absolute',
67
+ transition: `${$theme.animation.timing300} ${$theme.animation.easeOutCurve} all`,
68
+ transform: getAnchorTransform($anchor, $anchorSize)
69
+ }));
70
+ FloatingMarkerPinHeadContainer.displayName = "FloatingMarkerPinHeadContainer";
71
+ export const FloatingMarkerAnchorContainer = styled('div', () => ({
72
+ position: 'absolute'
73
+ }));
74
+ FloatingMarkerAnchorContainer.displayName = "FloatingMarkerAnchorContainer";
75
+ export const FixedMarkerRoot = styled('div', () => ({
76
+ display: 'flex',
77
+ alignItems: 'center',
78
+ flexDirection: 'column'
79
+ }));
80
+ FixedMarkerRoot.displayName = "FixedMarkerRoot";
81
+ export const FixedMarkerDragContainer = styled('div', ({
82
+ $theme,
83
+ $translateAmount,
84
+ $performTranslate
85
+ }) => {
86
+ return {
87
+ transform: `translateY(${$performTranslate ? '0px' : `${$translateAmount}px`})`,
88
+ transition: `${$theme.animation.timing300} ${$theme.animation.easeOutCurve} all`,
89
+ display: 'flex',
90
+ alignItems: 'center',
91
+ flexDirection: 'column'
92
+ };
93
+ });
94
+ FixedMarkerDragContainer.displayName = "FixedMarkerDragContainer";
95
+ export const OuterXSmallAnchor = styled('div', ({
96
+ $theme,
97
+ $round,
98
+ $background,
99
+ $size
100
+ }) => ({
101
+ background: $background,
102
+ display: 'flex',
103
+ alignItems: 'center',
104
+ justifyContent: 'center',
105
+ height: `${$size}px`,
106
+ width: `${$size}px`,
107
+ borderRadius: $round ? '50%' : 0,
108
+ boxShadow: $theme.lighting.shadow600
109
+ }));
110
+ OuterXSmallAnchor.displayName = "OuterXSmallAnchor";
111
+ export const InnerXSmallAnchor = styled('div', ({
112
+ $round,
113
+ $color,
114
+ $size
115
+ }) => ({
116
+ background: $color,
117
+ height: `${$size}px`,
118
+ width: `${$size}px`,
119
+ borderRadius: $round ? '50%' : 0
120
+ }));
121
+ InnerXSmallAnchor.displayName = "InnerXSmallAnchor";
122
+ export const PinHead = styled('div', ({
123
+ $theme,
124
+ $height,
125
+ $background,
126
+ $gridTemplateColumns,
127
+ $type,
128
+ $forceCircle
129
+ }) => {
130
+ const sharedStyles = {
131
+ fixed: {
132
+ padding: '0px 12px',
133
+ borderRadius: `${$height}px`
134
+ },
135
+ floating: {
136
+ padding: '0px 8px'
137
+ }
138
+ };
139
+ return {
140
+ background: $background,
141
+ height: `${$height}px`,
142
+ display: 'grid',
143
+ gridTemplateColumns: $gridTemplateColumns,
144
+ gap: '8px',
145
+ boxShadow: $theme.lighting.shadow600,
146
+ whiteSpace: 'nowrap',
147
+ ...sharedStyles[$type],
148
+ ...($forceCircle && {
149
+ width: `${$height}px`,
150
+ display: 'flex',
151
+ justifyContent: 'center',
152
+ boxSizing: 'border-box'
153
+ })
154
+ };
155
+ });
156
+ PinHead.displayName = "PinHead";
@@ -0,0 +1,8 @@
1
+ /*
2
+ Copyright (c) Uber Technologies, Inc.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ */
7
+ import * as React from 'react';
8
+ import { FLOATING_MARKER_ANCHOR_POSITIONS, NEEDLE_SIZES, PINHEAD_SIZES_SHAPES, FLOATING_MARKER_SIZES, PINHEAD_TYPES, FLOATING_MARKER_ANCHOR_TYPES } from './constants.js';
@@ -25,6 +25,10 @@ class StatefulContainer extends React.Component {
25
25
  this.props.onBlur(e);
26
26
  }
27
27
 
28
+ if (this.props.focusLock || this.props.autoFocus) {
29
+ return;
30
+ }
31
+
28
32
  this.close();
29
33
  });
30
34
 
@@ -144,7 +144,9 @@ class EmoticonRating extends React.Component {
144
144
  return /*#__PURE__*/React.createElement(Root, _extends({
145
145
  "data-baseweb": "emoticon-rating",
146
146
  role: "radiogroup",
147
- onBlur: () => this.updatePreview(undefined),
147
+ onBlur: e => {
148
+ if (!e.currentTarget.contains(e.relatedTarget)) this.updatePreview(undefined);
149
+ },
148
150
  onMouseLeave: () => this.updatePreview(undefined)
149
151
  }, rootProps), this.renderRatingContents());
150
152
  }
@@ -147,7 +147,9 @@ class StarRating extends React.Component {
147
147
  return /*#__PURE__*/React.createElement(Root, _extends({
148
148
  "data-baseweb": "star-rating",
149
149
  role: "radiogroup",
150
- onBlur: () => this.updatePreview(undefined),
150
+ onBlur: e => {
151
+ if (!e.currentTarget.contains(e.relatedTarget)) this.updatePreview(undefined);
152
+ },
151
153
  onMouseLeave: () => this.updatePreview(undefined)
152
154
  }, rootProps), this.renderRatingContents());
153
155
  }
@@ -105,7 +105,7 @@ class Select extends React.Component {
105
105
  isPseudoFocused: false
106
106
  });
107
107
 
108
- _defineProperty(this, "isMounted", false);
108
+ _defineProperty(this, "isItMounted", false);
109
109
 
110
110
  _defineProperty(this, "handleTouchOutside", event => {
111
111
  if (containsNode(this.dropdown.current, event.target)) return;
@@ -238,7 +238,7 @@ class Select extends React.Component {
238
238
  this.props.onBlur(event);
239
239
  }
240
240
 
241
- if (this.isMounted) {
241
+ if (this.isItMounted) {
242
242
  this.setState({
243
243
  isFocused: false,
244
244
  isOpen: false,
@@ -565,7 +565,16 @@ class Select extends React.Component {
565
565
  this.focus();
566
566
  }
567
567
 
568
- this.isMounted = true;
568
+ this.isItMounted = true;
569
+
570
+ if (this.props.methodsRef) {
571
+ const {
572
+ methodsRef
573
+ } = this.props;
574
+ methodsRef.current = {
575
+ setDropdownOpen: this.handleDropdownOpen.bind(this)
576
+ };
577
+ }
569
578
  }
570
579
 
571
580
  componentDidUpdate(prevProps, prevState) {
@@ -592,12 +601,18 @@ class Select extends React.Component {
592
601
  document.removeEventListener('click', this.handleClickOutside);
593
602
  }
594
603
 
595
- this.isMounted = false;
604
+ this.isItMounted = false;
596
605
  }
597
606
 
598
607
  focus() {
599
608
  if (!this.input) return;
600
609
  this.input.focus();
610
+ }
611
+
612
+ handleDropdownOpen(nextOpenState) {
613
+ this.setState({
614
+ isOpen: nextOpenState
615
+ });
601
616
  } // Handle touch outside on mobile to dismiss menu, ensures that the
602
617
  // touch target is not within the anchor DOM node.
603
618
 
@@ -782,7 +797,6 @@ class Select extends React.Component {
782
797
  const [ClearIcon, clearIconProps] = getOverrides(overrides.ClearIcon, DeleteAlt);
783
798
  const ariaLabel = this.props.multi ? 'Clear all' : 'Clear value';
784
799
  return /*#__PURE__*/React.createElement(ClearIcon, _extends({
785
- size: 16,
786
800
  title: ariaLabel,
787
801
  "aria-label": ariaLabel,
788
802
  onClick: this.clearValue,
@@ -845,7 +859,7 @@ class Select extends React.Component {
845
859
  }
846
860
 
847
861
  filterOptions(excludeOptions) {
848
- const filterValue = this.state.inputValue; // apply filter function
862
+ const filterValue = this.state.inputValue.trim(); // apply filter function
849
863
 
850
864
  if (this.props.filterOptions) {
851
865
  this.options = this.props.filterOptions(this.options, filterValue, excludeOptions, {