baseui 10.4.0 → 10.7.1

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 (195) hide show
  1. package/app-nav-bar/user-menu.js +1 -0
  2. package/app-nav-bar/user-menu.js.flow +1 -0
  3. package/button/styled-components.js +1 -1
  4. package/button/styled-components.js.flow +4 -1
  5. package/card/styled-components.js +0 -1
  6. package/card/styled-components.js.flow +0 -1
  7. package/combobox/combobox.js +5 -1
  8. package/combobox/combobox.js.flow +4 -0
  9. package/combobox/index.d.ts +6 -3
  10. package/data-table/column-datetime.js +2 -0
  11. package/data-table/column-datetime.js.flow +2 -0
  12. package/datepicker/calendar-header.js +255 -109
  13. package/datepicker/calendar-header.js.flow +282 -145
  14. package/datepicker/calendar.js +6 -1
  15. package/datepicker/calendar.js.flow +5 -1
  16. package/datepicker/constants.js +9 -2
  17. package/datepicker/constants.js.flow +7 -0
  18. package/datepicker/datepicker.js +135 -73
  19. package/datepicker/datepicker.js.flow +161 -62
  20. package/datepicker/day.js +2 -0
  21. package/datepicker/day.js.flow +2 -0
  22. package/datepicker/index.d.ts +8 -0
  23. package/datepicker/month.js +4 -0
  24. package/datepicker/month.js.flow +3 -0
  25. package/datepicker/styled-components.js +116 -56
  26. package/datepicker/styled-components.js.flow +101 -36
  27. package/datepicker/types.js.flow +18 -1
  28. package/datepicker/utils/calendar-header-helpers.js +51 -0
  29. package/datepicker/utils/calendar-header-helpers.js.flow +53 -0
  30. package/datepicker/utils/date-helpers.js +1 -1
  31. package/datepicker/utils/date-helpers.js.flow +1 -1
  32. package/datepicker/week.js +1 -0
  33. package/datepicker/week.js.flow +1 -0
  34. package/dnd-list/index.js.flow +2 -1
  35. package/dnd-list/list.js +1 -2
  36. package/dnd-list/list.js.flow +1 -1
  37. package/dnd-list/styled-components.js +1 -1
  38. package/dnd-list/styled-components.js.flow +1 -0
  39. package/drawer/drawer.js +2 -1
  40. package/drawer/drawer.js.flow +1 -1
  41. package/es/app-nav-bar/user-menu.js +1 -0
  42. package/es/button/styled-components.js +1 -1
  43. package/es/card/styled-components.js +0 -1
  44. package/es/combobox/combobox.js +5 -1
  45. package/es/data-table/column-datetime.js +2 -0
  46. package/es/datepicker/calendar-header.js +204 -93
  47. package/es/datepicker/calendar.js +7 -2
  48. package/es/datepicker/constants.js +6 -1
  49. package/es/datepicker/datepicker.js +70 -42
  50. package/es/datepicker/day.js +2 -0
  51. package/es/datepicker/month.js +3 -0
  52. package/es/datepicker/styled-components.js +98 -37
  53. package/es/datepicker/types.js +1 -1
  54. package/es/datepicker/utils/calendar-header-helpers.js +34 -0
  55. package/es/datepicker/utils/date-helpers.js +1 -1
  56. package/es/datepicker/week.js +1 -0
  57. package/es/dnd-list/index.js +2 -1
  58. package/es/dnd-list/list.js +1 -2
  59. package/es/dnd-list/styled-components.js +1 -0
  60. package/es/drawer/drawer.js +2 -1
  61. package/es/helper/helper.js +1 -0
  62. package/es/layer/layer.js +8 -0
  63. package/es/map-marker/constants.js +69 -0
  64. package/es/map-marker/fixed-marker.js +98 -0
  65. package/es/map-marker/floating-marker.js +65 -0
  66. package/es/map-marker/index.js +9 -0
  67. package/es/map-marker/pin-head.js +108 -0
  68. package/es/map-marker/styled-components.js +156 -0
  69. package/es/map-marker/types.js +8 -0
  70. package/es/menu/maybe-child-menu.js +1 -0
  71. package/es/popover/popover.js +6 -5
  72. package/es/popover/stateful-container.js +8 -2
  73. package/es/rating/emoticon-rating.js +3 -1
  74. package/es/rating/star-rating.js +3 -1
  75. package/es/select/select-component.js +20 -5
  76. package/es/select/styled-components.js +34 -4
  77. package/es/snackbar/snackbar-context.js +16 -4
  78. package/es/table-semantic/styled-components.js +6 -4
  79. package/es/table-semantic/table-builder.js +3 -0
  80. package/es/themes/dark-theme/color-component-tokens.js +1 -1
  81. package/es/themes/light-theme/color-component-tokens.js +9 -9
  82. package/es/themes/shared/lighting.js +5 -1
  83. package/es/timepicker/timepicker.js +16 -11
  84. package/es/tooltip/styled-components.js +8 -0
  85. package/es/tooltip/tooltip.js +1 -0
  86. package/esm/app-nav-bar/user-menu.js +1 -0
  87. package/esm/button/styled-components.js +1 -1
  88. package/esm/card/styled-components.js +0 -1
  89. package/esm/combobox/combobox.js +5 -1
  90. package/esm/data-table/column-datetime.js +2 -0
  91. package/esm/datepicker/calendar-header.js +255 -110
  92. package/esm/datepicker/calendar.js +7 -2
  93. package/esm/datepicker/constants.js +6 -1
  94. package/esm/datepicker/datepicker.js +136 -74
  95. package/esm/datepicker/day.js +2 -0
  96. package/esm/datepicker/month.js +3 -0
  97. package/esm/datepicker/styled-components.js +112 -55
  98. package/esm/datepicker/types.js +1 -1
  99. package/esm/datepicker/utils/calendar-header-helpers.js +45 -0
  100. package/esm/datepicker/utils/date-helpers.js +1 -1
  101. package/esm/datepicker/week.js +1 -0
  102. package/esm/dnd-list/index.js +2 -1
  103. package/esm/dnd-list/list.js +1 -2
  104. package/esm/dnd-list/styled-components.js +1 -1
  105. package/esm/drawer/drawer.js +2 -1
  106. package/esm/helper/helper.js +1 -0
  107. package/esm/layer/layer.js +8 -0
  108. package/esm/map-marker/constants.js +62 -0
  109. package/esm/map-marker/fixed-marker.js +137 -0
  110. package/esm/map-marker/floating-marker.js +94 -0
  111. package/esm/map-marker/index.js +9 -0
  112. package/esm/map-marker/pin-head.js +144 -0
  113. package/esm/map-marker/styled-components.js +168 -0
  114. package/esm/map-marker/types.js +8 -0
  115. package/esm/menu/maybe-child-menu.js +1 -0
  116. package/esm/popover/popover.js +6 -5
  117. package/esm/popover/stateful-container.js +8 -2
  118. package/esm/rating/emoticon-rating.js +2 -2
  119. package/esm/rating/star-rating.js +2 -2
  120. package/esm/select/select-component.js +19 -5
  121. package/esm/select/styled-components.js +28 -4
  122. package/esm/snackbar/snackbar-context.js +16 -4
  123. package/esm/table-semantic/styled-components.js +6 -4
  124. package/esm/table-semantic/table-builder.js +3 -0
  125. package/esm/themes/dark-theme/color-component-tokens.js +1 -1
  126. package/esm/themes/light-theme/color-component-tokens.js +9 -9
  127. package/esm/themes/shared/lighting.js +5 -1
  128. package/esm/timepicker/timepicker.js +17 -11
  129. package/esm/tooltip/styled-components.js +8 -0
  130. package/esm/tooltip/tooltip.js +1 -0
  131. package/helper/helper.js +1 -0
  132. package/helper/helper.js.flow +1 -0
  133. package/layer/layer.js +8 -0
  134. package/layer/layer.js.flow +9 -0
  135. package/link/index.d.ts +1 -0
  136. package/map-marker/constants.js +82 -0
  137. package/map-marker/constants.js.flow +74 -0
  138. package/map-marker/fixed-marker.js +152 -0
  139. package/map-marker/fixed-marker.js.flow +137 -0
  140. package/map-marker/floating-marker.js +109 -0
  141. package/map-marker/floating-marker.js.flow +102 -0
  142. package/map-marker/index.d.ts +105 -0
  143. package/map-marker/index.js +55 -0
  144. package/map-marker/index.js.flow +23 -0
  145. package/map-marker/package.json +4 -0
  146. package/map-marker/pin-head.js +159 -0
  147. package/map-marker/pin-head.js.flow +155 -0
  148. package/map-marker/styled-components.js +184 -0
  149. package/map-marker/styled-components.js.flow +177 -0
  150. package/map-marker/types.js +11 -0
  151. package/map-marker/types.js.flow +114 -0
  152. package/menu/index.d.ts +7 -0
  153. package/menu/maybe-child-menu.js +1 -0
  154. package/menu/maybe-child-menu.js.flow +1 -0
  155. package/menu/types.js.flow +12 -0
  156. package/modal/index.d.ts +1 -1
  157. package/modal/types.js.flow +4 -1
  158. package/package.json +5 -3
  159. package/popover/index.d.ts +2 -1
  160. package/popover/popover.js +6 -5
  161. package/popover/popover.js.flow +11 -4
  162. package/popover/stateful-container.js +8 -2
  163. package/popover/stateful-container.js.flow +5 -0
  164. package/popover/types.js.flow +6 -1
  165. package/rating/emoticon-rating.js +2 -2
  166. package/rating/emoticon-rating.js.flow +4 -1
  167. package/rating/star-rating.js +2 -2
  168. package/rating/star-rating.js.flow +4 -1
  169. package/select/select-component.js +19 -5
  170. package/select/select-component.js.flow +19 -5
  171. package/select/styled-components.js +28 -4
  172. package/select/styled-components.js.flow +30 -2
  173. package/select/types.js.flow +9 -0
  174. package/snackbar/index.d.ts +21 -16
  175. package/snackbar/snackbar-context.js +15 -4
  176. package/snackbar/snackbar-context.js.flow +15 -3
  177. package/table-semantic/styled-components.js +6 -4
  178. package/table-semantic/styled-components.js.flow +6 -4
  179. package/table-semantic/table-builder.js +3 -0
  180. package/table-semantic/table-builder.js.flow +3 -0
  181. package/themes/dark-theme/color-component-tokens.js +1 -1
  182. package/themes/dark-theme/color-component-tokens.js.flow +1 -1
  183. package/themes/light-theme/color-component-tokens.js +9 -9
  184. package/themes/light-theme/color-component-tokens.js.flow +9 -9
  185. package/themes/shared/lighting.js +5 -1
  186. package/themes/shared/lighting.js.flow +4 -0
  187. package/themes/types.js.flow +4 -0
  188. package/timepicker/index.d.ts +1 -0
  189. package/timepicker/timepicker.js +17 -11
  190. package/timepicker/timepicker.js.flow +31 -12
  191. package/timepicker/types.js.flow +10 -0
  192. package/tooltip/styled-components.js +8 -0
  193. package/tooltip/styled-components.js.flow +8 -0
  194. package/tooltip/tooltip.js +1 -0
  195. package/tooltip/tooltip.js.flow +6 -1
@@ -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';
@@ -28,6 +28,7 @@ export default function MaybeChildMenu(props) {
28
28
  return /*#__PURE__*/React.createElement(NestedMenuContext.Consumer, null, ctx => {
29
29
  return /*#__PURE__*/React.createElement(PopoverOverride, _extends({
30
30
  focusLock: false,
31
+ autoFocus: false,
31
32
  isOpen: props.isOpen,
32
33
  renderAll: props.renderAll,
33
34
  content: ChildMenu,
@@ -13,7 +13,7 @@ LICENSE file in the root directory of this source tree.
13
13
 
14
14
  /* eslint-disable cup/no-undef */
15
15
  import * as React from 'react';
16
- import FocusLock from 'react-focus-lock';
16
+ import FocusLock, { MoveFocusInside } from 'react-focus-lock';
17
17
  import { getOverride, getOverrideProps } from '../helpers/overrides.js';
18
18
  import { ACCESSIBILITY_TYPE, PLACEMENT, TRIGGER_TYPE, ANIMATE_OUT_TIME, ANIMATE_IN_TIME, POPOVER_MARGIN } from './constants.js';
19
19
  import { Layer, TetherBehavior } from '../layer/index.js';
@@ -156,7 +156,7 @@ class PopoverInner extends React.Component {
156
156
  componentDidUpdate(prevProps, prevState) {
157
157
  this.init(prevProps, prevState);
158
158
 
159
- if (this.props.autoFocus && this.props.focusLock && !this.state.autoFocusAfterPositioning && this.popperRef.current !== null && this.popperRef.current.getBoundingClientRect().top > 0) {
159
+ if (this.props.autoFocus && !this.state.autoFocusAfterPositioning && this.popperRef.current !== null && this.popperRef.current.getBoundingClientRect().top > 0) {
160
160
  this.setState({
161
161
  autoFocusAfterPositioning: true
162
162
  });
@@ -451,9 +451,10 @@ class PopoverInner extends React.Component {
451
451
  disabled: !this.props.focusLock,
452
452
  noFocusGuards: false // see popover-focus-loop.scenario.js for why hover cannot return focus
453
453
  ,
454
- returnFocus: this.props.returnFocus && !this.isHoverTrigger(),
455
- autoFocus: this.state.autoFocusAfterPositioning
456
- }, this.renderPopover(renderedContent)))));
454
+ returnFocus: !this.isHoverTrigger() && this.props.returnFocus,
455
+ autoFocus: this.state.autoFocusAfterPositioning,
456
+ focusOptions: this.props.focusOptions
457
+ }, !this.props.focusLock && this.state.autoFocusAfterPositioning ? /*#__PURE__*/React.createElement(MoveFocusInside, null, this.renderPopover(renderedContent)) : this.renderPopover(renderedContent)))));
457
458
  } else {
458
459
  rendered.push( /*#__PURE__*/React.createElement(Hidden, {
459
460
  key: "hidden-layer"
@@ -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
 
@@ -158,7 +162,8 @@ class StatefulContainer extends React.Component {
158
162
  returnFocus,
159
163
  showArrow,
160
164
  triggerType,
161
- popoverMargin
165
+ popoverMargin,
166
+ focusOptions
162
167
  } = this.props;
163
168
  const popoverProps = {
164
169
  accessibilityType,
@@ -182,7 +187,8 @@ class StatefulContainer extends React.Component {
182
187
  returnFocus,
183
188
  showArrow,
184
189
  triggerType,
185
- popoverMargin
190
+ popoverMargin,
191
+ focusOptions
186
192
  };
187
193
 
188
194
  if (dismissOnClickOutside) {
@@ -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,
@@ -956,6 +970,7 @@ class Select extends React.Component {
956
970
  if (!ref) return;
957
971
  this.anchor = ref.anchorRef;
958
972
  },
973
+ autoFocus: false,
959
974
  focusLock: false,
960
975
  mountNode: this.props.mountNode,
961
976
  onEsc: () => this.closeMenu(),