baseui 11.0.1 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/index.d.ts +1 -1
- package/accordion/index.d.ts +25 -28
- package/app-nav-bar/app-nav-bar.js +33 -40
- package/app-nav-bar/app-nav-bar.js.flow +46 -62
- package/app-nav-bar/index.d.ts +9 -8
- package/app-nav-bar/styled-components.js +49 -29
- package/app-nav-bar/styled-components.js.flow +25 -8
- package/app-nav-bar/types.js.flow +2 -0
- package/aspect-ratio-box/index.d.ts +2 -4
- package/avatar/index.d.ts +6 -12
- package/badge/badge.js +109 -0
- package/badge/badge.js.flow +91 -0
- package/badge/constants.js +54 -0
- package/badge/constants.js.flow +52 -0
- package/badge/hint-dot.js +96 -0
- package/badge/hint-dot.js.flow +68 -0
- package/badge/index.d.ts +97 -0
- package/badge/index.js +80 -0
- package/badge/index.js.flow +20 -0
- package/badge/notification-circle.js +103 -0
- package/badge/notification-circle.js.flow +81 -0
- package/badge/package.json +4 -0
- package/badge/styled-components.js +242 -0
- package/badge/styled-components.js.flow +325 -0
- package/badge/types.js +11 -0
- package/badge/types.js.flow +59 -0
- package/badge/utils.js +33 -0
- package/badge/utils.js.flow +23 -0
- package/banner/banner.js +283 -0
- package/banner/banner.js.flow +253 -0
- package/banner/constants.js +35 -0
- package/banner/constants.js.flow +33 -0
- package/banner/index.d.ts +75 -0
- package/banner/index.js +44 -0
- package/banner/index.js.flow +16 -0
- package/banner/package.json +4 -0
- package/banner/styled-components.js +131 -0
- package/banner/styled-components.js.flow +119 -0
- package/banner/types.js +11 -0
- package/banner/types.js.flow +66 -0
- package/block/index.d.ts +4 -4
- package/breadcrumbs/breadcrumbs.js +5 -1
- package/breadcrumbs/breadcrumbs.js.flow +2 -2
- package/breadcrumbs/index.d.ts +5 -5
- package/button/button.js +2 -1
- package/button/button.js.flow +1 -0
- package/button/index.d.ts +19 -29
- package/button-group/index.d.ts +18 -24
- package/card/index.d.ts +16 -14
- package/checkbox/index.d.ts +17 -21
- package/combobox/index.d.ts +7 -11
- package/data-table/index.d.ts +7 -10
- package/datepicker/calendar.js +16 -11
- package/datepicker/calendar.js.flow +12 -9
- package/datepicker/datepicker.js +58 -58
- package/datepicker/datepicker.js.flow +51 -34
- package/datepicker/index.d.ts +42 -63
- package/datepicker/stateful-calendar.js +6 -1
- package/datepicker/stateful-calendar.js.flow +8 -1
- package/datepicker/stateful-container.js +23 -2
- package/datepicker/stateful-container.js.flow +17 -4
- package/datepicker/stateful-datepicker.js +6 -1
- package/datepicker/stateful-datepicker.js.flow +7 -1
- package/datepicker/types.js.flow +21 -43
- package/datepicker/utils/date-helpers.js +1 -1
- package/datepicker/utils/date-helpers.js.flow +1 -1
- package/dnd-list/index.d.ts +22 -35
- package/drawer/index.d.ts +22 -27
- package/es/app-nav-bar/app-nav-bar.js +9 -19
- package/es/app-nav-bar/styled-components.js +32 -13
- package/es/badge/badge.js +70 -0
- package/es/badge/constants.js +42 -0
- package/es/badge/hint-dot.js +55 -0
- package/es/badge/index.js +11 -0
- package/es/badge/notification-circle.js +65 -0
- package/es/badge/styled-components.js +296 -0
- package/es/badge/types.js +8 -0
- package/es/badge/utils.js +17 -0
- package/es/banner/banner.js +213 -0
- package/es/banner/constants.js +24 -0
- package/es/banner/index.js +9 -0
- package/es/banner/styled-components.js +122 -0
- package/es/banner/types.js +8 -0
- package/es/breadcrumbs/breadcrumbs.js +5 -1
- package/es/button/button.js +1 -0
- package/es/datepicker/calendar.js +15 -10
- package/es/datepicker/datepicker.js +52 -52
- package/es/datepicker/stateful-calendar.js +6 -1
- package/es/datepicker/stateful-container.js +22 -2
- package/es/datepicker/stateful-datepicker.js +6 -1
- package/es/datepicker/utils/date-helpers.js +1 -1
- package/es/helper/helper-steps.js +3 -1
- package/es/input/base-input.js +18 -11
- package/es/input/input.js +15 -10
- package/es/input/masked-input.js +5 -2
- package/es/input/utils.js +4 -2
- package/es/locale/tr_TR.js +115 -0
- package/es/notification/notification.js +16 -1
- package/es/payment-card/custom-cards.config.js +22 -0
- package/es/payment-card/icons/uatp.js +52 -0
- package/es/payment-card/payment-card.js +8 -3
- package/es/popover/popover.js +2 -1
- package/es/popover/stateful-container.js +2 -0
- package/es/popover/styled-components.js +2 -1
- package/es/progress-steps/numbered-step.js +2 -2
- package/es/select/select-component.js +48 -23
- package/es/select/utils/default-filter-options.js +1 -1
- package/es/snackbar/snackbar-context.js +1 -1
- package/es/table-semantic/styled-components.js +14 -0
- package/es/table-semantic/table-builder.js +12 -5
- package/es/textarea/textarea.js +15 -9
- package/es/themes/dark-theme/color-component-tokens.js +8 -0
- package/es/themes/light-theme/color-component-tokens.js +8 -0
- package/es/tree-view/tree-label.js +9 -1
- package/esm/app-nav-bar/app-nav-bar.js +32 -38
- package/esm/app-nav-bar/styled-components.js +46 -28
- package/esm/badge/badge.js +97 -0
- package/esm/badge/constants.js +42 -0
- package/esm/badge/hint-dot.js +83 -0
- package/esm/badge/index.js +11 -0
- package/esm/badge/notification-circle.js +91 -0
- package/esm/badge/styled-components.js +235 -0
- package/esm/badge/types.js +8 -0
- package/esm/badge/utils.js +17 -0
- package/esm/banner/banner.js +271 -0
- package/esm/banner/constants.js +24 -0
- package/esm/banner/index.js +9 -0
- package/esm/banner/styled-components.js +113 -0
- package/esm/banner/types.js +8 -0
- package/esm/breadcrumbs/breadcrumbs.js +5 -1
- package/esm/button/button.js +2 -1
- package/esm/datepicker/calendar.js +16 -11
- package/esm/datepicker/datepicker.js +58 -58
- package/esm/datepicker/stateful-calendar.js +6 -1
- package/esm/datepicker/stateful-container.js +23 -2
- package/esm/datepicker/stateful-datepicker.js +6 -1
- package/esm/datepicker/utils/date-helpers.js +1 -1
- package/esm/helper/helper-steps.js +3 -1
- package/esm/input/base-input.js +18 -11
- package/esm/input/input.js +15 -10
- package/esm/input/masked-input.js +6 -3
- package/esm/input/utils.js +4 -2
- package/esm/locale/tr_TR.js +115 -0
- package/esm/notification/notification.js +17 -1
- package/esm/payment-card/custom-cards.config.js +22 -0
- package/esm/payment-card/icons/uatp.js +53 -0
- package/esm/payment-card/payment-card.js +9 -7
- package/esm/popover/popover.js +2 -1
- package/esm/popover/stateful-container.js +2 -0
- package/esm/popover/styled-components.js +3 -2
- package/esm/progress-steps/numbered-step.js +2 -2
- package/esm/select/select-component.js +85 -59
- package/esm/select/utils/default-filter-options.js +1 -1
- package/esm/snackbar/snackbar-context.js +1 -1
- package/esm/table-semantic/styled-components.js +31 -18
- package/esm/table-semantic/table-builder.js +34 -23
- package/esm/textarea/textarea.js +15 -9
- package/esm/themes/dark-theme/color-component-tokens.js +8 -0
- package/esm/themes/light-theme/color-component-tokens.js +8 -0
- package/esm/tree-view/tree-label.js +10 -2
- package/file-uploader/index.d.ts +11 -11
- package/flex-grid/index.d.ts +3 -3
- package/form-control/index.d.ts +7 -19
- package/header-navigation/index.d.ts +8 -9
- package/heading/index.d.ts +3 -4
- package/helper/helper-steps.js +19 -13
- package/helper/helper-steps.js.flow +3 -1
- package/helper/index.d.ts +7 -7
- package/helpers/base-provider.d.ts +16 -0
- package/helpers/overrides.d.ts +23 -0
- package/icon/index.d.ts +32 -32
- package/index.d.ts +34 -114
- package/input/base-input.js +18 -11
- package/input/base-input.js.flow +18 -6
- package/input/index.d.ts +29 -32
- package/input/input.js +15 -10
- package/input/input.js.flow +10 -5
- package/input/masked-input.js +6 -3
- package/input/masked-input.js.flow +3 -0
- package/input/types.js.flow +4 -0
- package/input/utils.js +4 -2
- package/input/utils.js.flow +2 -1
- package/layer/index.d.ts +6 -11
- package/layout-grid/index.d.ts +25 -7
- package/link/index.d.ts +2 -2
- package/list/index.d.ts +26 -31
- package/{locale.ts → locale/index.d.ts} +8 -0
- package/locale/tr_TR.js +123 -0
- package/locale/tr_TR.js.flow +124 -0
- package/map-marker/index.d.ts +41 -47
- package/menu/index.d.ts +27 -37
- package/modal/index.d.ts +28 -38
- package/notification/index.d.ts +2 -3
- package/notification/notification.js +18 -1
- package/notification/notification.js.flow +15 -1
- package/overrides.ts +2 -22
- package/package.json +26 -17
- package/pagination/index.d.ts +22 -26
- package/payment-card/custom-cards.config.js +30 -0
- package/payment-card/custom-cards.config.js.flow +29 -0
- package/payment-card/icons/uatp.js +67 -0
- package/payment-card/icons/uatp.js.flow +62 -0
- package/payment-card/index.d.ts +8 -8
- package/payment-card/payment-card.js +12 -7
- package/payment-card/payment-card.js.flow +12 -0
- package/phone-input/index.d.ts +261 -269
- package/pin-code/index.d.ts +11 -18
- package/popover/index.d.ts +39 -55
- package/popover/popover.js +2 -1
- package/popover/popover.js.flow +2 -1
- package/popover/stateful-container.js +2 -0
- package/popover/stateful-container.js.flow +2 -0
- package/popover/styled-components.js +3 -2
- package/popover/styled-components.js.flow +2 -1
- package/popover/types.js.flow +1 -0
- package/progress-bar/index.d.ts +11 -12
- package/progress-steps/index.d.ts +16 -16
- package/progress-steps/numbered-step.js.flow +2 -2
- package/radio/index.d.ts +12 -15
- package/rating/index.d.ts +9 -12
- package/select/index.d.ts +34 -36
- package/select/select-component.js +82 -56
- package/select/select-component.js.flow +46 -34
- package/select/types.js.flow +1 -0
- package/select/utils/default-filter-options.js +1 -1
- package/select/utils/default-filter-options.js.flow +1 -1
- package/side-navigation/index.d.ts +11 -13
- package/skeleton/index.d.ts +1 -1
- package/slider/index.d.ts +17 -26
- package/snackbar/index.d.ts +8 -8
- package/snackbar/snackbar-context.js +1 -1
- package/snackbar/snackbar-context.js.flow +1 -1
- package/spinner/index.d.ts +4 -3
- package/styles/index.d.ts +82 -2
- package/table/index.d.ts +16 -16
- package/table-grid/index.d.ts +6 -8
- package/table-semantic/index.d.ts +26 -32
- package/table-semantic/styled-components.js +33 -19
- package/table-semantic/styled-components.js.flow +12 -0
- package/table-semantic/table-builder.js +38 -22
- package/table-semantic/table-builder.js.flow +32 -17
- package/table-semantic/types.js.flow +1 -0
- package/tabs/index.d.ts +20 -23
- package/tabs-motion/index.d.ts +23 -23
- package/tag/index.d.ts +14 -18
- package/tag/types.js.flow +1 -1
- package/textarea/index.d.ts +11 -14
- package/textarea/textarea.js +15 -9
- package/textarea/textarea.js.flow +11 -5
- package/textarea/types.js.flow +1 -0
- package/theme.ts +36 -777
- package/themes/dark-theme/color-component-tokens.js +8 -0
- package/themes/dark-theme/color-component-tokens.js.flow +9 -0
- package/themes/index.d.ts +765 -0
- package/themes/light-theme/color-component-tokens.js +8 -0
- package/themes/light-theme/color-component-tokens.js.flow +9 -0
- package/themes/types.js.flow +9 -0
- package/timepicker/index.d.ts +5 -8
- package/timezonepicker/index.d.ts +5 -8
- package/toast/index.d.ts +26 -40
- package/tokens/index.d.ts +1 -1
- package/tooltip/index.d.ts +7 -9
- package/tree-view/index.d.ts +15 -19
- package/tree-view/tree-label.js +10 -2
- package/tree-view/tree-label.js.flow +4 -4
- package/typography/index.d.ts +37 -37
|
@@ -46,17 +46,10 @@ export const StyledRoot = styled<{}>('div', (props) => {
|
|
|
46
46
|
...$theme.typography.font300,
|
|
47
47
|
boxSizing: 'border-box',
|
|
48
48
|
backgroundColor: $theme.colors.backgroundPrimary,
|
|
49
|
-
boxShadow: '0px 1px 0px rgba(0, 0, 0, 0.08)',
|
|
50
|
-
width: '100%',
|
|
51
49
|
};
|
|
52
50
|
});
|
|
53
51
|
|
|
54
|
-
export const StyledSubnavContainer = styled
|
|
55
|
-
return {
|
|
56
|
-
boxSizing: 'border-box',
|
|
57
|
-
boxShadow: '0px -1px 0px rgba(0, 0, 0, 0.08)',
|
|
58
|
-
};
|
|
59
|
-
});
|
|
52
|
+
export const StyledSubnavContainer = styled('div', {});
|
|
60
53
|
|
|
61
54
|
export const StyledSpacing = styled<{}>('div', (props) => {
|
|
62
55
|
const { $theme } = props;
|
|
@@ -102,9 +95,11 @@ export const StyledPrimaryMenuContainer = styled<{}>('div', ({ $theme }) => {
|
|
|
102
95
|
height: '100%',
|
|
103
96
|
display: 'flex',
|
|
104
97
|
flexDirection: 'row',
|
|
98
|
+
flexGrow: 1,
|
|
105
99
|
flexWrap: 'nowrap',
|
|
106
100
|
justifyContent: 'flex-end',
|
|
107
101
|
alignItems: 'stretch',
|
|
102
|
+
paddingInlineEnd: $theme.sizing.scale1000,
|
|
108
103
|
};
|
|
109
104
|
});
|
|
110
105
|
|
|
@@ -155,6 +150,8 @@ export const StyledSecondaryMenuContainer = styled<{}>('div', ({ $theme }) => {
|
|
|
155
150
|
flexDirection: 'row',
|
|
156
151
|
flexWrap: 'nowrap',
|
|
157
152
|
justifyContent: 'flex-start',
|
|
153
|
+
margin: 'auto',
|
|
154
|
+
maxWidth: `${$theme.breakpoints.large}px`,
|
|
158
155
|
alignItems: 'stretch',
|
|
159
156
|
overflow: 'auto',
|
|
160
157
|
};
|
|
@@ -199,6 +196,26 @@ export const StyledUserProfileInfoContainer = styled<{}>('div', ({ $theme }) =>
|
|
|
199
196
|
};
|
|
200
197
|
});
|
|
201
198
|
|
|
199
|
+
export const StyledDesktopMenuContainer = styled<{}>('div', ({ $theme }) => {
|
|
200
|
+
return {
|
|
201
|
+
borderBottomWidth: '1px',
|
|
202
|
+
borderBottomStyle: 'solid',
|
|
203
|
+
borderBottomColor: `${$theme.colors.borderOpaque}`,
|
|
204
|
+
};
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
export const StyledDesktopMenu = styled<{}>('div', ({ $theme }) => {
|
|
208
|
+
return {
|
|
209
|
+
alignItems: 'center',
|
|
210
|
+
display: 'flex',
|
|
211
|
+
justifyContent: 'space-between',
|
|
212
|
+
margin: 'auto',
|
|
213
|
+
maxWidth: `${$theme.breakpoints.large}px`,
|
|
214
|
+
paddingBlockStart: '18px',
|
|
215
|
+
paddingBlockEnd: '18px',
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
|
|
202
219
|
declare var __DEV__: boolean;
|
|
203
220
|
declare var __NODE__: boolean;
|
|
204
221
|
declare var __BROWSER__: boolean;
|
|
@@ -14,6 +14,8 @@ import type { OverrideT } from '../helpers/overrides.js';
|
|
|
14
14
|
export type OverridesT = {
|
|
15
15
|
Root?: OverrideT,
|
|
16
16
|
AppName?: OverrideT,
|
|
17
|
+
DesktopMenu?: OverrideT,
|
|
18
|
+
DesktopMenuContainer?: OverrideT,
|
|
17
19
|
MainMenuItem?: OverrideT,
|
|
18
20
|
PrimaryMenuContainer?: OverrideT,
|
|
19
21
|
ProfileTileContainer?: OverrideT,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {StyletronComponent} from 'styletron-react';
|
|
3
|
-
import {Override} from '../overrides';
|
|
4
2
|
|
|
5
|
-
import {BlockProps} from '../block';
|
|
3
|
+
import { BlockProps } from '../block';
|
|
6
4
|
|
|
7
5
|
export interface AspectRatioBoxProps extends BlockProps {
|
|
8
6
|
/** Aspect ratio is width divided by height. */
|
|
@@ -10,4 +8,4 @@ export interface AspectRatioBoxProps extends BlockProps {
|
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
export class AspectRatioBox extends React.Component<AspectRatioBoxProps> {}
|
|
13
|
-
export const AspectRatioBoxBody: React.FC<BlockProps>;
|
|
11
|
+
export declare const AspectRatioBoxBody: React.FC<BlockProps>;
|
package/avatar/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {StyletronComponent} from 'styletron-react';
|
|
3
|
-
import {Override} from '../overrides';
|
|
2
|
+
import { StyletronComponent } from 'styletron-react';
|
|
3
|
+
import { Override } from '../overrides';
|
|
4
4
|
|
|
5
5
|
export interface AvatarOverrides<T> {
|
|
6
6
|
Avatar?: Override<T>;
|
|
@@ -20,14 +20,8 @@ export interface AvatarProps {
|
|
|
20
20
|
src?: string;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export
|
|
24
|
-
noImageAvailable: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class Avatar extends React.Component<AvatarProps, AvatarState> {
|
|
28
|
-
handleError(): void;
|
|
29
|
-
}
|
|
23
|
+
export declare const Avatar: React.FC<AvatarProps>;
|
|
30
24
|
|
|
31
|
-
export const StyledAvatar: StyletronComponent<any>;
|
|
32
|
-
export const StyledInitials: StyletronComponent<any>;
|
|
33
|
-
export const StyledRoot: StyletronComponent<any>;
|
|
25
|
+
export declare const StyledAvatar: StyletronComponent<any>;
|
|
26
|
+
export declare const StyledInitials: StyletronComponent<any>;
|
|
27
|
+
export declare const StyledRoot: StyletronComponent<any>;
|
package/badge/badge.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _overrides = require("../helpers/overrides.js");
|
|
13
|
+
|
|
14
|
+
var _styledComponents = require("./styled-components.js");
|
|
15
|
+
|
|
16
|
+
var _constants = require("./constants.js");
|
|
17
|
+
|
|
18
|
+
var _utils = require("./utils.js");
|
|
19
|
+
|
|
20
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
|
|
24
|
+
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); }
|
|
25
|
+
|
|
26
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
27
|
+
|
|
28
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
29
|
+
|
|
30
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
31
|
+
|
|
32
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
33
|
+
|
|
34
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
35
|
+
|
|
36
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
37
|
+
|
|
38
|
+
var Badge = function Badge(_ref) {
|
|
39
|
+
var children = _ref.children,
|
|
40
|
+
content = _ref.content,
|
|
41
|
+
color = _ref.color,
|
|
42
|
+
_ref$shape = _ref.shape,
|
|
43
|
+
shape = _ref$shape === void 0 ? _constants.SHAPE.rectangle : _ref$shape,
|
|
44
|
+
_ref$placement = _ref.placement,
|
|
45
|
+
placement = _ref$placement === void 0 ? _constants.PLACEMENT.topRight : _ref$placement,
|
|
46
|
+
hierarchy = _ref.hierarchy,
|
|
47
|
+
horizontalOffset = _ref.horizontalOffset,
|
|
48
|
+
verticalOffset = _ref.verticalOffset,
|
|
49
|
+
hidden = _ref.hidden,
|
|
50
|
+
_ref$overrides = _ref.overrides,
|
|
51
|
+
overrides = _ref$overrides === void 0 ? {} : _ref$overrides;
|
|
52
|
+
|
|
53
|
+
var _getOverrides = (0, _overrides.getOverrides)(overrides.Badge, _styledComponents.StyledBadge),
|
|
54
|
+
_getOverrides2 = _slicedToArray(_getOverrides, 2),
|
|
55
|
+
Badge = _getOverrides2[0],
|
|
56
|
+
badgeProps = _getOverrides2[1];
|
|
57
|
+
|
|
58
|
+
var _getOverrides3 = (0, _overrides.getOverrides)(overrides.Root, _styledComponents.StyledRoot),
|
|
59
|
+
_getOverrides4 = _slicedToArray(_getOverrides3, 2),
|
|
60
|
+
Root = _getOverrides4[0],
|
|
61
|
+
rootProps = _getOverrides4[1];
|
|
62
|
+
|
|
63
|
+
var _getOverrides5 = (0, _overrides.getOverrides)(overrides.Positioner, _styledComponents.StyledPositioner),
|
|
64
|
+
_getOverrides6 = _slicedToArray(_getOverrides5, 2),
|
|
65
|
+
Positioner = _getOverrides6[0],
|
|
66
|
+
positionerProps = _getOverrides6[1];
|
|
67
|
+
|
|
68
|
+
var anchor = (0, _utils.getAnchorFromChildren)(children);
|
|
69
|
+
var VALID_RECT_PLACEMENTS = [_constants.PLACEMENT.topLeft, _constants.PLACEMENT.topRight, _constants.PLACEMENT.bottomRight, _constants.PLACEMENT.bottomLeft];
|
|
70
|
+
|
|
71
|
+
if (process.env.NODE_ENV !== "production") {
|
|
72
|
+
if (shape === _constants.SHAPE.rectangle && !VALID_RECT_PLACEMENTS.includes(placement)) {
|
|
73
|
+
console.warn('Rectangle badges should only be placed in a corner or used inline');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (shape === _constants.SHAPE.rectangle && hierarchy === _constants.HIERARCHY.secondary && anchor) {
|
|
77
|
+
console.warn('Secondary badges should not be positioned. Use the inline version of this badge instead.');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (shape === _constants.SHAPE.pill && hierarchy === _constants.HIERARCHY.secondary) {
|
|
81
|
+
console.warn('Pill badges should only be used with primary hierarchy');
|
|
82
|
+
}
|
|
83
|
+
} // If there's no anchor, render the badge inline
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if (!anchor) {
|
|
87
|
+
return /*#__PURE__*/React.createElement(Badge, _extends({
|
|
88
|
+
$hierarchy: hierarchy,
|
|
89
|
+
$shape: shape,
|
|
90
|
+
$color: color,
|
|
91
|
+
$hidden: hidden
|
|
92
|
+
}, badgeProps), content);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return /*#__PURE__*/React.createElement(Root, rootProps, anchor, /*#__PURE__*/React.createElement(Positioner, _extends({
|
|
96
|
+
$horizontalOffset: horizontalOffset,
|
|
97
|
+
$verticalOffset: verticalOffset,
|
|
98
|
+
$placement: placement,
|
|
99
|
+
$role: _constants.ROLE.badge
|
|
100
|
+
}, positionerProps), /*#__PURE__*/React.createElement(Badge, _extends({
|
|
101
|
+
$hierarchy: hierarchy,
|
|
102
|
+
$shape: shape,
|
|
103
|
+
$color: color,
|
|
104
|
+
$hidden: hidden
|
|
105
|
+
}, badgeProps), content)));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
var _default = Badge;
|
|
109
|
+
exports.default = _default;
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
// @flow
|
|
8
|
+
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { getOverrides } from '../helpers/overrides.js';
|
|
11
|
+
import { StyledBadge, StyledRoot, StyledPositioner } from './styled-components.js';
|
|
12
|
+
import type { BadgePropsT } from './types.js';
|
|
13
|
+
import { PLACEMENT, ROLE, SHAPE, HIERARCHY } from './constants.js';
|
|
14
|
+
import { getAnchorFromChildren } from './utils.js';
|
|
15
|
+
|
|
16
|
+
const Badge = ({
|
|
17
|
+
children,
|
|
18
|
+
content,
|
|
19
|
+
color,
|
|
20
|
+
shape = SHAPE.rectangle,
|
|
21
|
+
placement = PLACEMENT.topRight,
|
|
22
|
+
hierarchy,
|
|
23
|
+
horizontalOffset,
|
|
24
|
+
verticalOffset,
|
|
25
|
+
hidden,
|
|
26
|
+
overrides = {},
|
|
27
|
+
}: BadgePropsT) => {
|
|
28
|
+
const [Badge, badgeProps] = getOverrides(overrides.Badge, StyledBadge);
|
|
29
|
+
const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
|
|
30
|
+
const [Positioner, positionerProps] = getOverrides(overrides.Positioner, StyledPositioner);
|
|
31
|
+
|
|
32
|
+
const anchor = getAnchorFromChildren(children);
|
|
33
|
+
|
|
34
|
+
const VALID_RECT_PLACEMENTS = [
|
|
35
|
+
PLACEMENT.topLeft,
|
|
36
|
+
PLACEMENT.topRight,
|
|
37
|
+
PLACEMENT.bottomRight,
|
|
38
|
+
PLACEMENT.bottomLeft,
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
if (__DEV__) {
|
|
42
|
+
if (shape === SHAPE.rectangle && !VALID_RECT_PLACEMENTS.includes(placement)) {
|
|
43
|
+
console.warn('Rectangle badges should only be placed in a corner or used inline');
|
|
44
|
+
}
|
|
45
|
+
if (shape === SHAPE.rectangle && hierarchy === HIERARCHY.secondary && anchor) {
|
|
46
|
+
console.warn(
|
|
47
|
+
'Secondary badges should not be positioned. Use the inline version of this badge instead.'
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
if (shape === SHAPE.pill && hierarchy === HIERARCHY.secondary) {
|
|
51
|
+
console.warn('Pill badges should only be used with primary hierarchy');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// If there's no anchor, render the badge inline
|
|
56
|
+
if (!anchor) {
|
|
57
|
+
return (
|
|
58
|
+
<Badge $hierarchy={hierarchy} $shape={shape} $color={color} $hidden={hidden} {...badgeProps}>
|
|
59
|
+
{content}
|
|
60
|
+
</Badge>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<Root {...rootProps}>
|
|
66
|
+
{anchor}
|
|
67
|
+
<Positioner
|
|
68
|
+
$horizontalOffset={horizontalOffset}
|
|
69
|
+
$verticalOffset={verticalOffset}
|
|
70
|
+
$placement={placement}
|
|
71
|
+
$role={ROLE.badge}
|
|
72
|
+
{...positionerProps}
|
|
73
|
+
>
|
|
74
|
+
<Badge
|
|
75
|
+
$hierarchy={hierarchy}
|
|
76
|
+
$shape={shape}
|
|
77
|
+
$color={color}
|
|
78
|
+
$hidden={hidden}
|
|
79
|
+
{...badgeProps}
|
|
80
|
+
>
|
|
81
|
+
{content}
|
|
82
|
+
</Badge>
|
|
83
|
+
</Positioner>
|
|
84
|
+
</Root>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
export default Badge;
|
|
88
|
+
|
|
89
|
+
declare var __DEV__: boolean;
|
|
90
|
+
declare var __NODE__: boolean;
|
|
91
|
+
declare var __BROWSER__: boolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ROLE = exports.PLACEMENT = exports.COLOR = exports.SHAPE = exports.HIERARCHY = void 0;
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
Copyright (c) Uber Technologies, Inc.
|
|
10
|
+
|
|
11
|
+
This source code is licensed under the MIT license found in the
|
|
12
|
+
LICENSE file in the root directory of this source tree.
|
|
13
|
+
*/
|
|
14
|
+
var HIERARCHY = Object.freeze({
|
|
15
|
+
primary: 'primary',
|
|
16
|
+
secondary: 'secondary'
|
|
17
|
+
});
|
|
18
|
+
exports.HIERARCHY = HIERARCHY;
|
|
19
|
+
var SHAPE = Object.freeze({
|
|
20
|
+
pill: 'pill',
|
|
21
|
+
rectangle: 'rectangle'
|
|
22
|
+
});
|
|
23
|
+
exports.SHAPE = SHAPE;
|
|
24
|
+
var COLOR = Object.freeze({
|
|
25
|
+
accent: 'accent',
|
|
26
|
+
primary: 'primary',
|
|
27
|
+
positive: 'positive',
|
|
28
|
+
negative: 'negative',
|
|
29
|
+
warning: 'warning'
|
|
30
|
+
});
|
|
31
|
+
exports.COLOR = COLOR;
|
|
32
|
+
var PLACEMENT = Object.freeze({
|
|
33
|
+
topLeft: 'topLeft',
|
|
34
|
+
topRight: 'topRight',
|
|
35
|
+
bottomRight: 'bottomRight',
|
|
36
|
+
bottomLeft: 'bottomLeft',
|
|
37
|
+
topLeftEdge: 'topLeftEdge',
|
|
38
|
+
topEdge: 'topEdge',
|
|
39
|
+
topRightEdge: 'topRightEdge',
|
|
40
|
+
bottomRightEdge: 'bottomRightEdge',
|
|
41
|
+
bottomEdge: 'bottomEdge',
|
|
42
|
+
bottomLeftEdge: 'bottomLeftEdge',
|
|
43
|
+
leftTopEdge: 'leftTopEdge',
|
|
44
|
+
rightTopEdge: 'rightTopEdge',
|
|
45
|
+
rightBottomEdge: 'rightBottomEdge',
|
|
46
|
+
leftBottomEdge: 'leftBottomEdge'
|
|
47
|
+
});
|
|
48
|
+
exports.PLACEMENT = PLACEMENT;
|
|
49
|
+
var ROLE = Object.freeze({
|
|
50
|
+
badge: 'badge',
|
|
51
|
+
notificationCircle: 'notificationCircle',
|
|
52
|
+
hintDot: 'hintDot'
|
|
53
|
+
});
|
|
54
|
+
exports.ROLE = ROLE;
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
// @flow
|
|
8
|
+
|
|
9
|
+
export const HIERARCHY = Object.freeze({
|
|
10
|
+
primary: 'primary',
|
|
11
|
+
secondary: 'secondary',
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const SHAPE = Object.freeze({
|
|
15
|
+
pill: 'pill',
|
|
16
|
+
rectangle: 'rectangle',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const COLOR = Object.freeze({
|
|
20
|
+
accent: 'accent',
|
|
21
|
+
primary: 'primary',
|
|
22
|
+
positive: 'positive',
|
|
23
|
+
negative: 'negative',
|
|
24
|
+
warning: 'warning',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const PLACEMENT = Object.freeze({
|
|
28
|
+
topLeft: 'topLeft',
|
|
29
|
+
topRight: 'topRight',
|
|
30
|
+
bottomRight: 'bottomRight',
|
|
31
|
+
bottomLeft: 'bottomLeft',
|
|
32
|
+
topLeftEdge: 'topLeftEdge',
|
|
33
|
+
topEdge: 'topEdge',
|
|
34
|
+
topRightEdge: 'topRightEdge',
|
|
35
|
+
bottomRightEdge: 'bottomRightEdge',
|
|
36
|
+
bottomEdge: 'bottomEdge',
|
|
37
|
+
bottomLeftEdge: 'bottomLeftEdge',
|
|
38
|
+
leftTopEdge: 'leftTopEdge',
|
|
39
|
+
rightTopEdge: 'rightTopEdge',
|
|
40
|
+
rightBottomEdge: 'rightBottomEdge',
|
|
41
|
+
leftBottomEdge: 'leftBottomEdge',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const ROLE = Object.freeze({
|
|
45
|
+
badge: 'badge',
|
|
46
|
+
notificationCircle: 'notificationCircle',
|
|
47
|
+
hintDot: 'hintDot',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
declare var __DEV__: boolean;
|
|
51
|
+
declare var __NODE__: boolean;
|
|
52
|
+
declare var __BROWSER__: boolean;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _index = require("../styles/index.js");
|
|
13
|
+
|
|
14
|
+
var _overrides = require("../helpers/overrides.js");
|
|
15
|
+
|
|
16
|
+
var _styledComponents = require("./styled-components.js");
|
|
17
|
+
|
|
18
|
+
var _constants = require("./constants.js");
|
|
19
|
+
|
|
20
|
+
var _utils = require("./utils.js");
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
26
|
+
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); }
|
|
27
|
+
|
|
28
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
29
|
+
|
|
30
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
31
|
+
|
|
32
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
33
|
+
|
|
34
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
35
|
+
|
|
36
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
37
|
+
|
|
38
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
39
|
+
|
|
40
|
+
var HintDot = function HintDot(_ref) {
|
|
41
|
+
var children = _ref.children,
|
|
42
|
+
color = _ref.color,
|
|
43
|
+
horizontalOffsetProp = _ref.horizontalOffset,
|
|
44
|
+
verticalOffsetProp = _ref.verticalOffset,
|
|
45
|
+
hidden = _ref.hidden,
|
|
46
|
+
_ref$overrides = _ref.overrides,
|
|
47
|
+
overrides = _ref$overrides === void 0 ? {} : _ref$overrides;
|
|
48
|
+
|
|
49
|
+
var _getOverrides = (0, _overrides.getOverrides)(overrides.Badge, _styledComponents.StyledHintDot),
|
|
50
|
+
_getOverrides2 = _slicedToArray(_getOverrides, 2),
|
|
51
|
+
HintDot = _getOverrides2[0],
|
|
52
|
+
hintDotProps = _getOverrides2[1];
|
|
53
|
+
|
|
54
|
+
var _getOverrides3 = (0, _overrides.getOverrides)(overrides.Root, _styledComponents.StyledRoot),
|
|
55
|
+
_getOverrides4 = _slicedToArray(_getOverrides3, 2),
|
|
56
|
+
Root = _getOverrides4[0],
|
|
57
|
+
rootProps = _getOverrides4[1];
|
|
58
|
+
|
|
59
|
+
var _getOverrides5 = (0, _overrides.getOverrides)(overrides.Positioner, _styledComponents.StyledPositioner),
|
|
60
|
+
_getOverrides6 = _slicedToArray(_getOverrides5, 2),
|
|
61
|
+
Positioner = _getOverrides6[0],
|
|
62
|
+
positionerProps = _getOverrides6[1];
|
|
63
|
+
|
|
64
|
+
var _useStyletron = (0, _index.useStyletron)(),
|
|
65
|
+
_useStyletron2 = _slicedToArray(_useStyletron, 2),
|
|
66
|
+
theme = _useStyletron2[1];
|
|
67
|
+
|
|
68
|
+
var anchor = (0, _utils.getAnchorFromChildren)(children); // if the anchor is a string, we supply default offsets
|
|
69
|
+
|
|
70
|
+
var horizontalOffset = horizontalOffsetProp;
|
|
71
|
+
var verticalOffset = verticalOffsetProp;
|
|
72
|
+
|
|
73
|
+
if (typeof anchor === 'string') {
|
|
74
|
+
if (!horizontalOffset) {
|
|
75
|
+
horizontalOffset = '-14px';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!verticalOffset) {
|
|
79
|
+
verticalOffset = '-4px';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return /*#__PURE__*/React.createElement(Root, rootProps, anchor, /*#__PURE__*/React.createElement(Positioner, _extends({
|
|
84
|
+
$horizontalOffset: horizontalOffset,
|
|
85
|
+
$verticalOffset: verticalOffset,
|
|
86
|
+
$placement: theme.direction === 'rtl' ? _constants.PLACEMENT.topLeft : _constants.PLACEMENT.topRight,
|
|
87
|
+
$role: _constants.ROLE.hintDot
|
|
88
|
+
}, positionerProps), /*#__PURE__*/React.createElement(HintDot, _extends({}, hintDotProps, {
|
|
89
|
+
$color: color,
|
|
90
|
+
$horizontalOffset: horizontalOffset,
|
|
91
|
+
$hidden: hidden
|
|
92
|
+
}))));
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
var _default = HintDot;
|
|
96
|
+
exports.default = _default;
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
// @flow
|
|
8
|
+
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { useStyletron } from '../styles/index.js';
|
|
11
|
+
import { getOverrides } from '../helpers/overrides.js';
|
|
12
|
+
import { StyledHintDot, StyledRoot, StyledPositioner } from './styled-components.js';
|
|
13
|
+
import type { HintDotPropsT } from './types.js';
|
|
14
|
+
import { PLACEMENT, ROLE } from './constants.js';
|
|
15
|
+
import { getAnchorFromChildren } from './utils.js';
|
|
16
|
+
|
|
17
|
+
const HintDot = ({
|
|
18
|
+
children,
|
|
19
|
+
color,
|
|
20
|
+
horizontalOffset: horizontalOffsetProp,
|
|
21
|
+
verticalOffset: verticalOffsetProp,
|
|
22
|
+
hidden,
|
|
23
|
+
overrides = {},
|
|
24
|
+
}: HintDotPropsT) => {
|
|
25
|
+
const [HintDot, hintDotProps] = getOverrides(overrides.Badge, StyledHintDot);
|
|
26
|
+
const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
|
|
27
|
+
const [Positioner, positionerProps] = getOverrides(overrides.Positioner, StyledPositioner);
|
|
28
|
+
|
|
29
|
+
const [, theme] = useStyletron();
|
|
30
|
+
|
|
31
|
+
const anchor = getAnchorFromChildren(children);
|
|
32
|
+
|
|
33
|
+
// if the anchor is a string, we supply default offsets
|
|
34
|
+
let horizontalOffset = horizontalOffsetProp;
|
|
35
|
+
let verticalOffset = verticalOffsetProp;
|
|
36
|
+
if (typeof anchor === 'string') {
|
|
37
|
+
if (!horizontalOffset) {
|
|
38
|
+
horizontalOffset = '-14px';
|
|
39
|
+
}
|
|
40
|
+
if (!verticalOffset) {
|
|
41
|
+
verticalOffset = '-4px';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return (
|
|
45
|
+
<Root {...rootProps}>
|
|
46
|
+
{anchor}
|
|
47
|
+
<Positioner
|
|
48
|
+
$horizontalOffset={horizontalOffset}
|
|
49
|
+
$verticalOffset={verticalOffset}
|
|
50
|
+
$placement={theme.direction === 'rtl' ? PLACEMENT.topLeft : PLACEMENT.topRight}
|
|
51
|
+
$role={ROLE.hintDot}
|
|
52
|
+
{...positionerProps}
|
|
53
|
+
>
|
|
54
|
+
<HintDot
|
|
55
|
+
{...hintDotProps}
|
|
56
|
+
$color={color}
|
|
57
|
+
$horizontalOffset={horizontalOffset}
|
|
58
|
+
$hidden={hidden}
|
|
59
|
+
/>
|
|
60
|
+
</Positioner>
|
|
61
|
+
</Root>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
export default HintDot;
|
|
65
|
+
|
|
66
|
+
declare var __DEV__: boolean;
|
|
67
|
+
declare var __NODE__: boolean;
|
|
68
|
+
declare var __BROWSER__: boolean;
|