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
|
@@ -0,0 +1,325 @@
|
|
|
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
|
+
import { styled } from '../styles/index.js';
|
|
9
|
+
import type { PlacementT, ColorT, ShapeT, RoleT, HierarchyT } from './types.js';
|
|
10
|
+
import { COLOR, SHAPE, ROLE, PLACEMENT, HIERARCHY } from './constants.js';
|
|
11
|
+
|
|
12
|
+
function getColorStyles({ $theme, $hierarchy, $color }): {|
|
|
13
|
+
color: string,
|
|
14
|
+
backgroundColor: string,
|
|
15
|
+
|} {
|
|
16
|
+
const COLOR_STYLES = {
|
|
17
|
+
[HIERARCHY.primary]: {
|
|
18
|
+
[COLOR.accent]: {
|
|
19
|
+
color: $theme.colors.contentInversePrimary,
|
|
20
|
+
backgroundColor: $theme.colors.backgroundAccent,
|
|
21
|
+
},
|
|
22
|
+
[COLOR.primary]: {
|
|
23
|
+
color: $theme.colors.contentInversePrimary,
|
|
24
|
+
backgroundColor: $theme.colors.backgroundInversePrimary,
|
|
25
|
+
},
|
|
26
|
+
[COLOR.positive]: {
|
|
27
|
+
color: $theme.colors.contentInversePrimary,
|
|
28
|
+
backgroundColor: $theme.colors.backgroundPositive,
|
|
29
|
+
},
|
|
30
|
+
[COLOR.negative]: {
|
|
31
|
+
color: $theme.colors.contentInversePrimary,
|
|
32
|
+
backgroundColor: $theme.colors.backgroundNegative,
|
|
33
|
+
},
|
|
34
|
+
[COLOR.warning]: {
|
|
35
|
+
color: $theme.colors.primaryA,
|
|
36
|
+
backgroundColor: $theme.colors.backgroundWarning,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
[HIERARCHY.secondary]: {
|
|
40
|
+
[COLOR.accent]: {
|
|
41
|
+
color: $theme.colors.contentAccent,
|
|
42
|
+
backgroundColor: $theme.colors.backgroundLightAccent,
|
|
43
|
+
},
|
|
44
|
+
[COLOR.primary]: {
|
|
45
|
+
color: $theme.colors.primaryA,
|
|
46
|
+
backgroundColor: $theme.colors.backgroundSecondary,
|
|
47
|
+
},
|
|
48
|
+
[COLOR.positive]: {
|
|
49
|
+
color: $theme.colors.contentPositive,
|
|
50
|
+
backgroundColor: $theme.colors.backgroundLightPositive,
|
|
51
|
+
},
|
|
52
|
+
[COLOR.negative]: {
|
|
53
|
+
color: $theme.colors.contentNegative,
|
|
54
|
+
backgroundColor: $theme.colors.backgroundLightNegative,
|
|
55
|
+
},
|
|
56
|
+
[COLOR.warning]: {
|
|
57
|
+
color: $theme.colors.contentWarning,
|
|
58
|
+
backgroundColor: $theme.colors.backgroundLightWarning,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return COLOR_STYLES[$hierarchy][$color];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT = {
|
|
67
|
+
top: '-10px',
|
|
68
|
+
right: '-10px',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const DEFAULT_HINT_DOT_PLACEMENT = {
|
|
72
|
+
top: '-4px',
|
|
73
|
+
right: '-4px',
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const POSITION_STYLES = Object.freeze({
|
|
77
|
+
[ROLE.badge]: {
|
|
78
|
+
[PLACEMENT.topEdge]: {
|
|
79
|
+
top: '-8px',
|
|
80
|
+
left: '50%',
|
|
81
|
+
transform: 'translateX(-50%)',
|
|
82
|
+
},
|
|
83
|
+
[PLACEMENT.bottomEdge]: {
|
|
84
|
+
bottom: '-8px',
|
|
85
|
+
left: '50%',
|
|
86
|
+
transform: 'translateX(-50%)',
|
|
87
|
+
},
|
|
88
|
+
[PLACEMENT.topLeft]: {
|
|
89
|
+
top: '16px',
|
|
90
|
+
left: '16px',
|
|
91
|
+
},
|
|
92
|
+
[PLACEMENT.topRight]: {
|
|
93
|
+
top: '16px',
|
|
94
|
+
right: '16px',
|
|
95
|
+
},
|
|
96
|
+
[PLACEMENT.bottomRight]: {
|
|
97
|
+
bottom: '16px',
|
|
98
|
+
right: '16px',
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
[PLACEMENT.bottomLeft]: {
|
|
102
|
+
bottom: '16px',
|
|
103
|
+
left: '16px',
|
|
104
|
+
},
|
|
105
|
+
[PLACEMENT.topLeftEdge]: {
|
|
106
|
+
top: '-8px',
|
|
107
|
+
left: '16px',
|
|
108
|
+
},
|
|
109
|
+
[PLACEMENT.topRightEdge]: {
|
|
110
|
+
top: '-8px',
|
|
111
|
+
right: '16px',
|
|
112
|
+
},
|
|
113
|
+
[PLACEMENT.bottomRightEdge]: {
|
|
114
|
+
bottom: '-8px',
|
|
115
|
+
right: '16px',
|
|
116
|
+
},
|
|
117
|
+
[PLACEMENT.bottomLeftEdge]: {
|
|
118
|
+
bottom: '-8px',
|
|
119
|
+
left: '16px',
|
|
120
|
+
},
|
|
121
|
+
[PLACEMENT.leftTopEdge]: {
|
|
122
|
+
top: '16px',
|
|
123
|
+
left: '-8px',
|
|
124
|
+
},
|
|
125
|
+
[PLACEMENT.rightTopEdge]: {
|
|
126
|
+
top: '16px',
|
|
127
|
+
right: '-8px',
|
|
128
|
+
},
|
|
129
|
+
[PLACEMENT.rightBottomEdge]: {
|
|
130
|
+
bottom: '16px',
|
|
131
|
+
right: '-8px',
|
|
132
|
+
},
|
|
133
|
+
[PLACEMENT.leftBottomEdge]: {
|
|
134
|
+
bottom: '16px',
|
|
135
|
+
left: '-8px',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
[ROLE.notificationCircle]: {
|
|
139
|
+
[PLACEMENT.topLeft]: {
|
|
140
|
+
top: '-10px',
|
|
141
|
+
left: '-10px',
|
|
142
|
+
},
|
|
143
|
+
[PLACEMENT.topRight]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
144
|
+
// NotificationCircle can only be placed topLeft or topRight, other values fall back to topRight
|
|
145
|
+
[PLACEMENT.topEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
146
|
+
[PLACEMENT.bottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
147
|
+
[PLACEMENT.bottomRight]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
148
|
+
[PLACEMENT.bottomLeft]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
149
|
+
[PLACEMENT.topLeftEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
150
|
+
[PLACEMENT.topRightEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
151
|
+
[PLACEMENT.bottomRightEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
152
|
+
[PLACEMENT.bottomLeftEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
153
|
+
[PLACEMENT.leftTopEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
154
|
+
[PLACEMENT.rightTopEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
155
|
+
[PLACEMENT.rightBottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
156
|
+
[PLACEMENT.leftBottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
157
|
+
},
|
|
158
|
+
[ROLE.hintDot]: {
|
|
159
|
+
[PLACEMENT.topLeft]: {
|
|
160
|
+
top: '-4px',
|
|
161
|
+
left: '-4px',
|
|
162
|
+
},
|
|
163
|
+
[PLACEMENT.topRight]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
164
|
+
// HintDot can only be placed topLeft or topRight, other values fall back to topRight
|
|
165
|
+
[PLACEMENT.topEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
166
|
+
[PLACEMENT.bottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
167
|
+
[PLACEMENT.bottomRight]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
168
|
+
[PLACEMENT.bottomLeft]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
169
|
+
[PLACEMENT.topLeftEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
170
|
+
[PLACEMENT.topRightEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
171
|
+
[PLACEMENT.bottomRightEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
172
|
+
[PLACEMENT.bottomLeftEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
173
|
+
[PLACEMENT.leftTopEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
174
|
+
[PLACEMENT.rightTopEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
175
|
+
[PLACEMENT.rightBottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
176
|
+
[PLACEMENT.leftBottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
export const StyledRoot = styled<{}>('div', () => {
|
|
181
|
+
return {
|
|
182
|
+
position: 'relative',
|
|
183
|
+
display: 'inline-block',
|
|
184
|
+
lineHeight: 'initial',
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const TOP_PLACEMENTS = [
|
|
189
|
+
PLACEMENT.topLeft,
|
|
190
|
+
PLACEMENT.topRight,
|
|
191
|
+
PLACEMENT.topLeftEdge,
|
|
192
|
+
PLACEMENT.topEdge,
|
|
193
|
+
PLACEMENT.topRightEdge,
|
|
194
|
+
PLACEMENT.leftTopEdge,
|
|
195
|
+
PLACEMENT.rightTopEdge,
|
|
196
|
+
];
|
|
197
|
+
const BOTTOM_PLACEMENTS = [
|
|
198
|
+
PLACEMENT.bottomLeft,
|
|
199
|
+
PLACEMENT.bottomRight,
|
|
200
|
+
PLACEMENT.bottomLeftEdge,
|
|
201
|
+
PLACEMENT.bottomEdge,
|
|
202
|
+
PLACEMENT.bottomRightEdge,
|
|
203
|
+
PLACEMENT.leftBottomEdge,
|
|
204
|
+
PLACEMENT.rightBottomEdge,
|
|
205
|
+
];
|
|
206
|
+
const LEFT_PLACEMENTS = [
|
|
207
|
+
PLACEMENT.topLeft,
|
|
208
|
+
PLACEMENT.topLeftEdge,
|
|
209
|
+
PLACEMENT.topEdge,
|
|
210
|
+
PLACEMENT.bottomLeft,
|
|
211
|
+
PLACEMENT.bottomLeftEdge,
|
|
212
|
+
PLACEMENT.bottomEdge,
|
|
213
|
+
PLACEMENT.leftTopEdge,
|
|
214
|
+
PLACEMENT.leftBottomEdge,
|
|
215
|
+
];
|
|
216
|
+
const RIGHT_PLACEMENTS = [
|
|
217
|
+
PLACEMENT.topRight,
|
|
218
|
+
PLACEMENT.topRightEdge,
|
|
219
|
+
PLACEMENT.bottomRight,
|
|
220
|
+
PLACEMENT.bottomRightEdge,
|
|
221
|
+
PLACEMENT.rightTopEdge,
|
|
222
|
+
PLACEMENT.rightBottomEdge,
|
|
223
|
+
];
|
|
224
|
+
|
|
225
|
+
export const StyledPositioner = styled<{
|
|
226
|
+
$role: RoleT,
|
|
227
|
+
$placement: PlacementT,
|
|
228
|
+
$horizontalOffset?: ?string,
|
|
229
|
+
$verticalOffset?: ?string,
|
|
230
|
+
}>('div', ({ $theme, $role, $placement, $horizontalOffset, $verticalOffset }) => {
|
|
231
|
+
let positionStyle = POSITION_STYLES[$role][$placement];
|
|
232
|
+
|
|
233
|
+
if ($verticalOffset) {
|
|
234
|
+
if (TOP_PLACEMENTS.includes($placement)) {
|
|
235
|
+
positionStyle = { ...positionStyle, top: $verticalOffset };
|
|
236
|
+
}
|
|
237
|
+
if (BOTTOM_PLACEMENTS.includes($placement)) {
|
|
238
|
+
positionStyle = { ...positionStyle, bottom: $verticalOffset };
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if ($horizontalOffset) {
|
|
243
|
+
if (LEFT_PLACEMENTS.includes($placement)) {
|
|
244
|
+
positionStyle = { ...positionStyle, left: $horizontalOffset };
|
|
245
|
+
}
|
|
246
|
+
if (RIGHT_PLACEMENTS.includes($placement)) {
|
|
247
|
+
positionStyle = { ...positionStyle, right: $horizontalOffset };
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return {
|
|
252
|
+
...positionStyle,
|
|
253
|
+
position: 'absolute',
|
|
254
|
+
lineHeight: 'initial',
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
export const StyledBadge = styled<{
|
|
259
|
+
$shape?: ShapeT,
|
|
260
|
+
$color?: ColorT,
|
|
261
|
+
$hierarchy?: HierarchyT,
|
|
262
|
+
$hidden?: boolean,
|
|
263
|
+
}>(
|
|
264
|
+
'div',
|
|
265
|
+
({
|
|
266
|
+
$theme,
|
|
267
|
+
$shape = SHAPE.rectangle,
|
|
268
|
+
$color = COLOR.accent,
|
|
269
|
+
$hierarchy = HIERARCHY.primary,
|
|
270
|
+
$hidden,
|
|
271
|
+
}) => {
|
|
272
|
+
return {
|
|
273
|
+
visibility: $hidden ? 'hidden' : 'inherit',
|
|
274
|
+
boxSizing: 'border-box',
|
|
275
|
+
height: $theme.sizing.scale700,
|
|
276
|
+
borderRadius:
|
|
277
|
+
$shape === SHAPE.rectangle ? $theme.borders.radius200 : $theme.borders.radius500,
|
|
278
|
+
paddingRight: $shape === SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
|
|
279
|
+
paddingLeft: $shape === SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
|
|
280
|
+
display: 'inline-flex',
|
|
281
|
+
alignItems: 'center',
|
|
282
|
+
...getColorStyles({ $theme, $hierarchy, $color }),
|
|
283
|
+
...($hierarchy === HIERARCHY.primary
|
|
284
|
+
? $theme.typography.LabelSmall
|
|
285
|
+
: $theme.typography.ParagraphSmall),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
export const StyledNotificationCircle = styled<{
|
|
291
|
+
$color?: ColorT,
|
|
292
|
+
$hidden?: boolean,
|
|
293
|
+
}>('div', ({ $theme, $color = COLOR.accent, $hidden }) => {
|
|
294
|
+
return {
|
|
295
|
+
visibility: $hidden ? 'hidden' : 'inherit',
|
|
296
|
+
height: $theme.sizing.scale700,
|
|
297
|
+
width: $theme.sizing.scale700,
|
|
298
|
+
borderRadius: '20px',
|
|
299
|
+
display: 'inline-flex',
|
|
300
|
+
alignItems: 'center',
|
|
301
|
+
justifyContent: 'center',
|
|
302
|
+
...getColorStyles({ $theme, $hierarchy: HIERARCHY.primary, $color }),
|
|
303
|
+
...$theme.typography.LabelXSmall,
|
|
304
|
+
};
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
export const StyledHintDot = styled<{ $color: ColorT, $hidden?: boolean }>(
|
|
308
|
+
'div',
|
|
309
|
+
({ $theme, $color = COLOR.accent, $hidden }) => {
|
|
310
|
+
return {
|
|
311
|
+
visibility: $hidden ? 'hidden' : 'inherit',
|
|
312
|
+
backgroundColor: $theme.colors[$color],
|
|
313
|
+
boxSizing: 'content-box',
|
|
314
|
+
height: '8px',
|
|
315
|
+
width: '8px',
|
|
316
|
+
borderRadius: '50%',
|
|
317
|
+
border: `4px solid ${$theme.colors.backgroundPrimary}`,
|
|
318
|
+
...getColorStyles({ $theme, $hierarchy: HIERARCHY.primary, $color }),
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
declare var __DEV__: boolean;
|
|
324
|
+
declare var __NODE__: boolean;
|
|
325
|
+
declare var __BROWSER__: boolean;
|
package/badge/types.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
var React = _interopRequireWildcard(require("react"));
|
|
6
|
+
|
|
7
|
+
var _constants = require("./constants.js");
|
|
8
|
+
|
|
9
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
10
|
+
|
|
11
|
+
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; }
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
import * as React from 'react';
|
|
9
|
+
import { HIERARCHY, SHAPE, COLOR, PLACEMENT, ROLE } from './constants.js';
|
|
10
|
+
import type { OverrideT } from '../helpers/overrides.js';
|
|
11
|
+
|
|
12
|
+
export type HierarchyT = $Values<typeof HIERARCHY>;
|
|
13
|
+
export type ShapeT = $Values<typeof SHAPE>;
|
|
14
|
+
export type ColorT = $Values<typeof COLOR>;
|
|
15
|
+
export type PlacementT = $Values<typeof PLACEMENT>;
|
|
16
|
+
export type RoleT = $Values<typeof ROLE>;
|
|
17
|
+
|
|
18
|
+
export type BadgeOverridesT = {
|
|
19
|
+
Root?: OverrideT,
|
|
20
|
+
Positioner?: OverrideT,
|
|
21
|
+
Badge?: OverrideT,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type BadgePropsT = {
|
|
25
|
+
content: React.Node,
|
|
26
|
+
hierarchy?: HierarchyT,
|
|
27
|
+
shape?: ShapeT,
|
|
28
|
+
color?: ColorT,
|
|
29
|
+
placement?: PlacementT,
|
|
30
|
+
hidden?: boolean,
|
|
31
|
+
horizontalOffset?: string,
|
|
32
|
+
verticalOffset?: string,
|
|
33
|
+
overrides?: BadgeOverridesT,
|
|
34
|
+
children?: React.Node,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type NotificationCirclePropsT = {
|
|
38
|
+
content: React.Node,
|
|
39
|
+
color?: ColorT,
|
|
40
|
+
placement?: PlacementT,
|
|
41
|
+
hidden?: boolean,
|
|
42
|
+
horizontalOffset?: string,
|
|
43
|
+
verticalOffset?: string,
|
|
44
|
+
overrides?: BadgeOverridesT,
|
|
45
|
+
children?: React.Node,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type HintDotPropsT = {
|
|
49
|
+
color?: ColorT,
|
|
50
|
+
hidden?: boolean,
|
|
51
|
+
horizontalOffset?: string,
|
|
52
|
+
verticalOffset?: string,
|
|
53
|
+
overrides?: BadgeOverridesT,
|
|
54
|
+
children?: React.Node,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
declare var __DEV__: boolean;
|
|
58
|
+
declare var __NODE__: boolean;
|
|
59
|
+
declare var __BROWSER__: boolean;
|
package/badge/utils.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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.getAnchorFromChildren = void 0;
|
|
9
|
+
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
Copyright (c) Uber Technologies, Inc.
|
|
18
|
+
|
|
19
|
+
This source code is licensed under the MIT license found in the
|
|
20
|
+
LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
var getAnchorFromChildren = function getAnchorFromChildren(children) {
|
|
23
|
+
var childArray = React.Children.toArray(children);
|
|
24
|
+
|
|
25
|
+
if (childArray.length !== 1) {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.error("[baseui] No more than 1 child may be passed to Badge, found ".concat(childArray.length, " children"));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return childArray[0];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.getAnchorFromChildren = getAnchorFromChildren;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
import * as React from 'react';
|
|
9
|
+
|
|
10
|
+
export const getAnchorFromChildren = (children: ?React.Node) => {
|
|
11
|
+
const childArray = React.Children.toArray(children);
|
|
12
|
+
if (childArray.length !== 1) {
|
|
13
|
+
// eslint-disable-next-line no-console
|
|
14
|
+
console.error(
|
|
15
|
+
`[baseui] No more than 1 child may be passed to Badge, found ${childArray.length} children`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return childArray[0];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
declare var __DEV__: boolean;
|
|
22
|
+
declare var __NODE__: boolean;
|
|
23
|
+
declare var __BROWSER__: boolean;
|