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
package/datepicker/types.js.flow
CHANGED
|
@@ -27,10 +27,6 @@ import type { OptionT } from '../select/index.js';
|
|
|
27
27
|
// flowlint-next-line unclear-type:off
|
|
28
28
|
type LocaleT = any; // see https://github.com/date-fns/date-fns/blob/master/src/locale/index.js.flow
|
|
29
29
|
|
|
30
|
-
export type DateValueT<T> = ?T | Array<?T>;
|
|
31
|
-
|
|
32
|
-
type onChangeT<T> = ({ date: DateValueT<T> }) => mixed;
|
|
33
|
-
|
|
34
30
|
export type DensityT = $Keys<typeof DENSITY>;
|
|
35
31
|
|
|
36
32
|
export type DatepickerOverridesT = {
|
|
@@ -92,13 +88,13 @@ export type DayPropsT<T = Date> = {
|
|
|
92
88
|
month: ?number,
|
|
93
89
|
onBlur: ({ event: Event, date: T }) => mixed,
|
|
94
90
|
onFocus: ({ event: Event, date: T }) => mixed,
|
|
95
|
-
onSelect: ({ date:
|
|
91
|
+
onSelect: ({ date: T | Array<?T> }) => mixed,
|
|
96
92
|
onClick: ({ event: Event, date: T }) => mixed,
|
|
97
93
|
onMouseOver: ({ event: Event, date: T }) => mixed,
|
|
98
94
|
onMouseLeave: ({ event: Event, date: T }) => mixed,
|
|
99
95
|
overrides?: DatepickerOverridesT,
|
|
100
96
|
peekNextMonth: boolean,
|
|
101
|
-
value:
|
|
97
|
+
value: ?T | $ReadOnlyArray<?T>,
|
|
102
98
|
};
|
|
103
99
|
|
|
104
100
|
export type DayStateT = {
|
|
@@ -127,15 +123,16 @@ export type WeekPropsT<T = Date> = {
|
|
|
127
123
|
onDayFocus: ({ date: T, event: Event }) => mixed,
|
|
128
124
|
onDayMouseOver: ({ date: T, event: Event }) => mixed,
|
|
129
125
|
onDayMouseLeave: ({ date: T, event: Event }) => mixed,
|
|
130
|
-
onChange?:
|
|
126
|
+
onChange?: ({ +date: ?T | Array<?T> }) => mixed,
|
|
131
127
|
overrides?: DatepickerOverridesT,
|
|
132
128
|
peekNextMonth: boolean,
|
|
133
|
-
value:
|
|
129
|
+
value: ?T | $ReadOnlyArray<?T>,
|
|
134
130
|
hasLockedBehavior: boolean,
|
|
135
131
|
selectedInput?: InputRoleT,
|
|
136
132
|
};
|
|
137
133
|
|
|
138
|
-
export type MonthPropsT<T = Date> =
|
|
134
|
+
export type MonthPropsT<T = Date> = {
|
|
135
|
+
...WeekPropsT<T>,
|
|
139
136
|
fixedHeight?: boolean,
|
|
140
137
|
};
|
|
141
138
|
|
|
@@ -193,7 +190,7 @@ export type CalendarPropsT<T = Date> = {
|
|
|
193
190
|
/** Event handler that is called when the current rendered month's year is changed. */
|
|
194
191
|
onYearChange?: ({ date: T }) => mixed,
|
|
195
192
|
/** Event handler that is called when a new date is selected. */
|
|
196
|
-
onChange?:
|
|
193
|
+
onChange?: ({ +date: ?T | Array<?T> }) => mixed,
|
|
197
194
|
/** Event handler that is called when a selection is made using the quick select menu. */
|
|
198
195
|
onQuickSelectChange?: (option?: QuickSelectOption<T>) => mixed,
|
|
199
196
|
/** Sets the orientation of the calendar when multiple months are displayed */
|
|
@@ -208,7 +205,7 @@ export type CalendarPropsT<T = Date> = {
|
|
|
208
205
|
/** Defines if tabbing inside the calendar is circled within it. */
|
|
209
206
|
trapTabbing?: boolean,
|
|
210
207
|
/** Currently selected date. */
|
|
211
|
-
value?:
|
|
208
|
+
value?: ?T | $ReadOnlyArray<?T>,
|
|
212
209
|
fixedHeight?: boolean,
|
|
213
210
|
/** Determines whether user clicked startDate or endDate input to trigger calendar open */
|
|
214
211
|
selectedInput?: InputRoleT,
|
|
@@ -225,7 +222,8 @@ export type QuickSelectOption<T> = {
|
|
|
225
222
|
endDate?: T,
|
|
226
223
|
};
|
|
227
224
|
|
|
228
|
-
export type DatepickerPropsT<T = Date> =
|
|
225
|
+
export type DatepickerPropsT<T = Date> = {
|
|
226
|
+
...CalendarPropsT<T>,
|
|
229
227
|
'aria-label'?: string,
|
|
230
228
|
'aria-labelledby'?: string,
|
|
231
229
|
'aria-describedby'?: ?string,
|
|
@@ -238,14 +236,18 @@ export type DatepickerPropsT<T = Date> = CalendarPropsT<T> & {
|
|
|
238
236
|
required?: boolean,
|
|
239
237
|
clearable?: boolean,
|
|
240
238
|
displayValueAtRangeIndex?: number,
|
|
241
|
-
formatDisplayValue?: (date:
|
|
239
|
+
formatDisplayValue?: (date: ?T | $ReadOnlyArray<?T>, formatString: string) => string,
|
|
242
240
|
formatString: string,
|
|
243
241
|
/** Where to mount the popover */
|
|
244
242
|
mountNode?: HTMLElement,
|
|
243
|
+
/** When single picker, fn is always called. When range picker, fn is called when start and end date are selected. */
|
|
244
|
+
onChange?: ({ date: ?T | Array<T> }) => mixed,
|
|
245
245
|
/** Called when calendar is closed */
|
|
246
246
|
onClose?: () => mixed,
|
|
247
247
|
/** Called when calendar is opened */
|
|
248
248
|
onOpen?: () => mixed,
|
|
249
|
+
/** When single picker, fn is always called. When range picker, fn is called when either start or end date changes. */
|
|
250
|
+
onRangeChange?: ({ +date: ?T | Array<?T> }) => mixed,
|
|
249
251
|
mask?: string | null,
|
|
250
252
|
/** Determines whether startDate and endDate should be updated independently of eachother */
|
|
251
253
|
rangedCalendarBehavior?: RangedCalendarBehaviorT,
|
|
@@ -253,6 +255,7 @@ export type DatepickerPropsT<T = Date> = CalendarPropsT<T> & {
|
|
|
253
255
|
separateRangeInputs?: boolean,
|
|
254
256
|
startDateLabel?: string,
|
|
255
257
|
endDateLabel?: string,
|
|
258
|
+
value?: ?T | $ReadOnlyArray<?T>,
|
|
256
259
|
};
|
|
257
260
|
|
|
258
261
|
export type SharedStylePropsT = {
|
|
@@ -289,7 +292,7 @@ export type StateChangeTypeT = ?$Values<typeof STATE_CHANGE_TYPE>;
|
|
|
289
292
|
|
|
290
293
|
export type ContainerStateT<T = Date> = {
|
|
291
294
|
/** Selected `Date`. If `range` is set, `value` is an array of 2 values. */
|
|
292
|
-
value?:
|
|
295
|
+
value?: ?T | $ReadOnlyArray<?T>,
|
|
293
296
|
};
|
|
294
297
|
|
|
295
298
|
export type NavigationContainerStateT<T = Date> = {
|
|
@@ -310,46 +313,21 @@ export type StateReducerT<T = Date> = (
|
|
|
310
313
|
currentState: ContainerStateT<T>
|
|
311
314
|
) => ContainerStateT<T>;
|
|
312
315
|
|
|
313
|
-
export type NavigationContainerStateReducerT<T = Date> = (
|
|
314
|
-
stateType: StateChangeTypeT,
|
|
315
|
-
nextState: NavigationContainerStateT<T>,
|
|
316
|
-
currentState: NavigationContainerStateT<T>
|
|
317
|
-
) => NavigationContainerStateT<T>;
|
|
318
|
-
|
|
319
316
|
export type StatefulContainerPropsT<PropsT, T = Date> = {
|
|
320
317
|
children: (PropsT) => React.Node,
|
|
321
318
|
/** Initial state of an uncontrolled datepicker component. */
|
|
322
319
|
initialState: ContainerStateT<T>,
|
|
323
320
|
/** A state change handler. */
|
|
324
321
|
stateReducer: StateReducerT<T>,
|
|
325
|
-
/**
|
|
326
|
-
onChange?:
|
|
322
|
+
/** When single picker, fn is called when date/time is selected. When range picker, fn is called when both start and end are selected. */
|
|
323
|
+
onChange?: ({ date: ?T | Array<T> }) => mixed,
|
|
324
|
+
/** When single picker, fn is called when date/time is selected. When range picker, fn is called when either start or end date changes. */
|
|
325
|
+
onRangeChange?: ({ +date: ?T | Array<?T> }) => mixed,
|
|
327
326
|
adapter?: DateIOAdapter<T>,
|
|
328
327
|
/** Should the date value be stored as an array or single value. */
|
|
329
328
|
range?: boolean,
|
|
330
329
|
};
|
|
331
330
|
|
|
332
|
-
// This type is seemingly not used anywhere
|
|
333
|
-
export type NavigationContainerPropsT<T = Date> = {
|
|
334
|
-
children: (CalendarPropsT<T>) => React.Node,
|
|
335
|
-
range?: boolean,
|
|
336
|
-
highlightedDate?: ?Date,
|
|
337
|
-
/** Day's `mouseover` event handler. */
|
|
338
|
-
onDayMouseOver: (params: { date: Date, event: Event }) => mixed,
|
|
339
|
-
/** Day's `mouseleave` event handler. */
|
|
340
|
-
onDayMouseLeave: (params: { date: Date, event: Event }) => mixed,
|
|
341
|
-
/** Event handler that is called when a new date is selected. */
|
|
342
|
-
onChange: onChangeT<T>,
|
|
343
|
-
/** Event handler that is called when the current rendered month is changed. */
|
|
344
|
-
onMonthChange?: ({ date: T }) => mixed,
|
|
345
|
-
/** Event handler that is called when the current rendered year is changed. */
|
|
346
|
-
onYearChange?: ({ date: T }) => mixed,
|
|
347
|
-
/** Selected `Date`. If `range` is set, `value` is an array of 2 values. */
|
|
348
|
-
value?: DateValueT<T>,
|
|
349
|
-
stateReducer: NavigationContainerStateReducerT<T>,
|
|
350
|
-
trapTabbing: boolean,
|
|
351
|
-
};
|
|
352
|
-
|
|
353
331
|
export type StatefulDatepickerPropsT<PropsT, T = Date> = $Diff<
|
|
354
332
|
StatefulContainerPropsT<PropsT, T>,
|
|
355
333
|
{
|
|
@@ -93,7 +93,7 @@ var DateHelpers = function DateHelpers(_adapter) {
|
|
|
93
93
|
var UtilsClass = adapter.constructor;
|
|
94
94
|
var className = adapter.constructor.name; // This ensures that if the adapter class isn't
|
|
95
95
|
// supported it just falls back the default formats
|
|
96
|
-
// NOTE: in e2e tests
|
|
96
|
+
// NOTE: in e2e tests playwright seems to add
|
|
97
97
|
// a JSHandle wrapping class to all objects
|
|
98
98
|
// so className always resolves to JSHandle:e
|
|
99
99
|
// and if falls back to the default
|
|
@@ -68,7 +68,7 @@ class DateHelpers<T> {
|
|
|
68
68
|
// This ensures that if the adapter class isn't
|
|
69
69
|
// supported it just falls back the default formats
|
|
70
70
|
|
|
71
|
-
// NOTE: in e2e tests
|
|
71
|
+
// NOTE: in e2e tests playwright seems to add
|
|
72
72
|
// a JSHandle wrapping class to all objects
|
|
73
73
|
// so className always resolves to JSHandle:e
|
|
74
74
|
// and if falls back to the default
|
package/dnd-list/index.d.ts
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {StyletronComponent} from 'styletron-react';
|
|
3
|
-
import {Override} from '../overrides';
|
|
4
|
-
import {
|
|
5
|
-
arrayMove as arrayMoveT,
|
|
6
|
-
arrayRemove as arrayRemoveT,
|
|
7
|
-
} from 'react-movable';
|
|
2
|
+
import { StyletronComponent } from 'styletron-react';
|
|
3
|
+
import { Override } from '../overrides';
|
|
4
|
+
import { arrayMove as arrayMoveT, arrayRemove as arrayRemoveT } from 'react-movable';
|
|
8
5
|
|
|
9
6
|
// export {arrayMove, arrayRemove} from 'react-movable';
|
|
10
7
|
|
|
11
|
-
export
|
|
8
|
+
export declare const STATE_CHANGE_TYPE: {
|
|
12
9
|
change: 'change';
|
|
13
|
-
}
|
|
10
|
+
};
|
|
14
11
|
|
|
15
12
|
export type StateReducer = (
|
|
16
|
-
stateChangeType: STATE_CHANGE_TYPE[keyof STATE_CHANGE_TYPE],
|
|
13
|
+
stateChangeType: typeof STATE_CHANGE_TYPE[keyof typeof STATE_CHANGE_TYPE],
|
|
17
14
|
nextState: State,
|
|
18
|
-
currentState: State
|
|
15
|
+
currentState: State
|
|
19
16
|
) => State;
|
|
20
17
|
|
|
21
18
|
export interface StatefulListProps {
|
|
@@ -23,17 +20,11 @@ export interface StatefulListProps {
|
|
|
23
20
|
stateReducer?: StateReducer;
|
|
24
21
|
removable?: boolean;
|
|
25
22
|
removableByMove?: boolean;
|
|
26
|
-
onChange?: (
|
|
27
|
-
params: {
|
|
28
|
-
newState: React.ReactNode[];
|
|
29
|
-
oldIndex: number;
|
|
30
|
-
newIndex: number;
|
|
31
|
-
},
|
|
32
|
-
) => any;
|
|
23
|
+
onChange?: (params: { newState: React.ReactNode[]; oldIndex: number; newIndex: number }) => any;
|
|
33
24
|
overrides?: ListOverrides;
|
|
34
25
|
}
|
|
35
26
|
|
|
36
|
-
export const StatefulList: React.FC<StatefulListProps>;
|
|
27
|
+
export declare const StatefulList: React.FC<StatefulListProps>;
|
|
37
28
|
|
|
38
29
|
export interface State {
|
|
39
30
|
items: React.ReactNode[];
|
|
@@ -43,14 +34,11 @@ export type StatefulComponentContainerProps = StatefulListProps & {
|
|
|
43
34
|
children: React.ReactNode;
|
|
44
35
|
};
|
|
45
36
|
|
|
46
|
-
export class StatefulListContainer extends React.Component<
|
|
47
|
-
|
|
48
|
-
State
|
|
49
|
-
> {
|
|
50
|
-
onChange({oldIndex, newIndex}: {oldIndex: number; newIndex: number}): void;
|
|
37
|
+
export class StatefulListContainer extends React.Component<StatefulComponentContainerProps, State> {
|
|
38
|
+
onChange({ oldIndex, newIndex }: { oldIndex: number; newIndex: number }): void;
|
|
51
39
|
internalSetState(
|
|
52
|
-
type: STATE_CHANGE_TYPE[keyof STATE_CHANGE_TYPE],
|
|
53
|
-
changes: State
|
|
40
|
+
type: typeof STATE_CHANGE_TYPE[keyof typeof STATE_CHANGE_TYPE],
|
|
41
|
+
changes: State
|
|
54
42
|
): void;
|
|
55
43
|
}
|
|
56
44
|
|
|
@@ -75,19 +63,18 @@ export interface ListProps {
|
|
|
75
63
|
removable?: boolean;
|
|
76
64
|
removableByMove?: boolean;
|
|
77
65
|
items?: React.ReactNode[];
|
|
78
|
-
onChange?: (args: {oldIndex: number; newIndex: number}) => any;
|
|
66
|
+
onChange?: (args: { oldIndex: number; newIndex: number }) => any;
|
|
79
67
|
overrides?: ListOverrides;
|
|
80
68
|
}
|
|
81
69
|
|
|
82
70
|
export class List extends React.Component<ListProps> {}
|
|
83
71
|
|
|
84
|
-
export const StyledRoot: StyletronComponent<any>;
|
|
85
|
-
export const StyledList: StyletronComponent<any>;
|
|
86
|
-
export const StyledItem: StyletronComponent<any>;
|
|
87
|
-
export const StyledDragHandle: StyletronComponent<any>;
|
|
88
|
-
export const StyledCloseHandle: StyletronComponent<any>;
|
|
89
|
-
export const StyledLabel: StyletronComponent<any>;
|
|
72
|
+
export declare const StyledRoot: StyletronComponent<any>;
|
|
73
|
+
export declare const StyledList: StyletronComponent<any>;
|
|
74
|
+
export declare const StyledItem: StyletronComponent<any>;
|
|
75
|
+
export declare const StyledDragHandle: StyletronComponent<any>;
|
|
76
|
+
export declare const StyledCloseHandle: StyletronComponent<any>;
|
|
77
|
+
export declare const StyledLabel: StyletronComponent<any>;
|
|
90
78
|
|
|
91
|
-
export const
|
|
92
|
-
export const
|
|
93
|
-
export const arrayRemove: typeof arrayRemoveT;
|
|
79
|
+
export declare const arrayMove: typeof arrayMoveT;
|
|
80
|
+
export declare const arrayRemove: typeof arrayRemoveT;
|
package/drawer/index.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
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
|
-
export
|
|
5
|
+
export declare const SIZE: {
|
|
6
6
|
default: 'default';
|
|
7
7
|
full: 'full';
|
|
8
8
|
auto: 'auto';
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export declare const SIZE_DIMENSIONS: {
|
|
12
12
|
default: '500px';
|
|
13
13
|
full: '100%';
|
|
14
14
|
auto: 'auto';
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
|
|
17
|
-
export
|
|
17
|
+
export declare const ANCHOR: {
|
|
18
18
|
left: 'left';
|
|
19
19
|
right: 'right';
|
|
20
20
|
top: 'top';
|
|
21
21
|
bottom: 'bottom';
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
23
|
|
|
24
|
-
export
|
|
24
|
+
export declare const CLOSE_SOURCE: {
|
|
25
25
|
closeButton: 'closeButton';
|
|
26
26
|
backdrop: 'backdrop';
|
|
27
27
|
escape: 'escape';
|
|
28
|
-
}
|
|
28
|
+
};
|
|
29
29
|
|
|
30
30
|
export interface SharedStylePropsArg {
|
|
31
31
|
children?: React.ReactNode;
|
|
32
32
|
$animating?: boolean;
|
|
33
33
|
$isVisible?: boolean;
|
|
34
34
|
$isOpen?: boolean;
|
|
35
|
-
$size?: SIZE[keyof SIZE];
|
|
35
|
+
$size?: typeof SIZE[keyof typeof SIZE];
|
|
36
36
|
$closeable?: boolean;
|
|
37
|
-
$anchor?: ANCHOR[keyof ANCHOR];
|
|
37
|
+
$anchor?: typeof ANCHOR[keyof typeof ANCHOR];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export interface DrawerOverrides {
|
|
@@ -53,10 +53,10 @@ export interface DrawerProps {
|
|
|
53
53
|
renderAll?: boolean;
|
|
54
54
|
isOpen?: boolean;
|
|
55
55
|
mountNode?: HTMLElement;
|
|
56
|
-
onClose?: (args: {closeSource?: CLOSE_SOURCE[keyof CLOSE_SOURCE]}) => any;
|
|
56
|
+
onClose?: (args: { closeSource?: typeof CLOSE_SOURCE[keyof typeof CLOSE_SOURCE] }) => any;
|
|
57
57
|
overrides?: DrawerOverrides;
|
|
58
|
-
size?: SIZE[keyof SIZE] | string;
|
|
59
|
-
anchor?: ANCHOR[keyof ANCHOR] | string;
|
|
58
|
+
size?: typeof SIZE[keyof typeof SIZE] | string;
|
|
59
|
+
anchor?: typeof ANCHOR[keyof typeof ANCHOR] | string;
|
|
60
60
|
showBackdrop?: boolean;
|
|
61
61
|
onBackdropClick?: (event: React.MouseEvent<HTMLElement>) => any;
|
|
62
62
|
onEscapeKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => any;
|
|
@@ -76,21 +76,16 @@ export class Drawer extends React.Component<DrawerProps, DrawerState> {
|
|
|
76
76
|
clearTimers(): void;
|
|
77
77
|
didOpen(): void;
|
|
78
78
|
didClose(): void;
|
|
79
|
-
triggerClose(source: CLOSE_SOURCE[keyof CLOSE_SOURCE]): void;
|
|
79
|
+
triggerClose(source: typeof CLOSE_SOURCE[keyof typeof CLOSE_SOURCE]): void;
|
|
80
80
|
animateOutComplete(): void;
|
|
81
|
-
getSharedProps(): SharedStylePropsArg & {children: React.ReactNode};
|
|
81
|
+
getSharedProps(): SharedStylePropsArg & { children: React.ReactNode };
|
|
82
82
|
getChildren(): React.ReactNode;
|
|
83
83
|
getRef(component: string): React.Ref<any>;
|
|
84
84
|
renderDrawer(): React.ReactNode;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
export const StyledRoot: StyletronComponent<any>;
|
|
88
|
-
export const StyledBackdrop: StyletronComponent<any>;
|
|
89
|
-
export const StyledDrawerContainer: StyletronComponent<any>;
|
|
90
|
-
export const StyledDrawerBody: StyletronComponent<any>;
|
|
91
|
-
export const StyledClose: StyletronComponent<any>;
|
|
92
|
-
|
|
93
|
-
export const SIZE: SIZE;
|
|
94
|
-
export const ANCHOR: ANCHOR;
|
|
95
|
-
export const SIZE_DIMENSIONS: SIZE_DIMENSIONS;
|
|
96
|
-
export const CLOSE_SOURCE: CLOSE_SOURCE;
|
|
87
|
+
export declare const StyledRoot: StyletronComponent<any>;
|
|
88
|
+
export declare const StyledBackdrop: StyletronComponent<any>;
|
|
89
|
+
export declare const StyledDrawerContainer: StyletronComponent<any>;
|
|
90
|
+
export declare const StyledDrawerBody: StyletronComponent<any>;
|
|
91
|
+
export declare const StyledClose: StyletronComponent<any>;
|
|
@@ -8,13 +8,12 @@ LICENSE file in the root directory of this source tree.
|
|
|
8
8
|
*/
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
import { getOverrides } from '../helpers/overrides.js';
|
|
11
|
-
import { Cell, Grid } from '../layout-grid/index.js';
|
|
12
11
|
import { useStyletron } from '../styles/index.js';
|
|
13
12
|
import { isFocusVisible } from '../utils/focusVisible.js';
|
|
14
13
|
import { KIND, POSITION } from './constants.js';
|
|
15
14
|
import MobileNav from './mobile-menu.js';
|
|
16
15
|
import UserMenu from './user-menu.js';
|
|
17
|
-
import { StyledRoot, StyledSpacing, StyledPrimaryMenuContainer,
|
|
16
|
+
import { StyledRoot, StyledSpacing, StyledPrimaryMenuContainer, StyledSecondaryMenuContainer, StyledAppName, StyledMainMenuItem, StyledDesktopMenuContainer, StyledDesktopMenu } from './styled-components.js';
|
|
18
17
|
import { defaultMapItemToNode, mapItemsActive } from './utils.js';
|
|
19
18
|
|
|
20
19
|
function MainMenuItem(props) {
|
|
@@ -72,11 +71,8 @@ function SecondaryMenu(props) {
|
|
|
72
71
|
onSelect,
|
|
73
72
|
overrides = {}
|
|
74
73
|
} = props;
|
|
75
|
-
const [SubnavContainer, subnavContainerProps] = getOverrides(overrides.SubnavContainer, StyledSubnavContainer);
|
|
76
74
|
const [SecondaryMenuContainer, secondaryMenuContainerProps] = getOverrides(overrides.SecondaryMenuContainer, StyledSecondaryMenuContainer);
|
|
77
|
-
return /*#__PURE__*/React.createElement(
|
|
78
|
-
span: [0, 8, 12]
|
|
79
|
-
}, /*#__PURE__*/React.createElement(SecondaryMenuContainer, _extends({
|
|
75
|
+
return /*#__PURE__*/React.createElement(SecondaryMenuContainer, _extends({
|
|
80
76
|
role: "navigation",
|
|
81
77
|
"aria-label": "Secondary navigation"
|
|
82
78
|
}, secondaryMenuContainerProps), items.map((item, index) =>
|
|
@@ -89,7 +85,7 @@ function SecondaryMenu(props) {
|
|
|
89
85
|
key: index,
|
|
90
86
|
onSelect: onSelect,
|
|
91
87
|
overrides: overrides
|
|
92
|
-
})))
|
|
88
|
+
})));
|
|
93
89
|
}
|
|
94
90
|
|
|
95
91
|
export default function AppNavBar(props) {
|
|
@@ -116,6 +112,8 @@ export default function AppNavBar(props) {
|
|
|
116
112
|
const [Spacing, spacingProps] = getOverrides(overrides.Spacing, StyledSpacing);
|
|
117
113
|
const [AppName, appNameProps] = getOverrides(overrides.AppName, StyledAppName);
|
|
118
114
|
const [PrimaryMenuContainer, primaryMenuContainerProps] = getOverrides(overrides.PrimaryMenuContainer, StyledPrimaryMenuContainer);
|
|
115
|
+
const [DesktopMenuContainer, desktopMenuContainerProps] = getOverrides(overrides.DesktopMenuContainer, StyledDesktopMenuContainer);
|
|
116
|
+
const [DesktopMenu, desktopMenuProps] = getOverrides(overrides.DesktopMenu, StyledDesktopMenu);
|
|
119
117
|
let secondaryMenu;
|
|
120
118
|
let desktopSubNavPosition = POSITION.horizontal;
|
|
121
119
|
let mobileSubNavPosition = POSITION.vertical;
|
|
@@ -127,9 +125,7 @@ export default function AppNavBar(props) {
|
|
|
127
125
|
display: 'none'
|
|
128
126
|
}
|
|
129
127
|
})
|
|
130
|
-
}, /*#__PURE__*/React.createElement(
|
|
131
|
-
span: [4, 8, 0]
|
|
132
|
-
}, /*#__PURE__*/React.createElement(Spacing, spacingProps, mainItems.length || userItems.length ? /*#__PURE__*/React.createElement(MobileNav, props) : null, /*#__PURE__*/React.createElement(AppName, appNameProps, title)))), secondaryMenu && mobileSubNavPosition === POSITION.horizontal && /*#__PURE__*/React.createElement(SecondaryMenu, {
|
|
128
|
+
}, /*#__PURE__*/React.createElement(Spacing, spacingProps, mainItems.length || userItems.length ? /*#__PURE__*/React.createElement(MobileNav, props) : null, /*#__PURE__*/React.createElement(AppName, appNameProps, title)), secondaryMenu && mobileSubNavPosition === POSITION.horizontal && /*#__PURE__*/React.createElement(SecondaryMenu, {
|
|
133
129
|
items: secondaryMenu,
|
|
134
130
|
mapItemToNode: mapItemToNode,
|
|
135
131
|
onSelect: onMainItemSelect,
|
|
@@ -140,11 +136,7 @@ export default function AppNavBar(props) {
|
|
|
140
136
|
display: 'none'
|
|
141
137
|
}
|
|
142
138
|
})
|
|
143
|
-
}, /*#__PURE__*/React.createElement(
|
|
144
|
-
span: [0, 3, 3]
|
|
145
|
-
}, /*#__PURE__*/React.createElement(Spacing, spacingProps, /*#__PURE__*/React.createElement(AppName, appNameProps, title))), /*#__PURE__*/React.createElement(Cell, {
|
|
146
|
-
span: userItems.length ? [0, 4, 8] : [0, 5, 9]
|
|
147
|
-
}, /*#__PURE__*/React.createElement(PrimaryMenuContainer, _extends({
|
|
139
|
+
}, /*#__PURE__*/React.createElement(DesktopMenuContainer, desktopMenuContainerProps, /*#__PURE__*/React.createElement(DesktopMenu, desktopMenuProps, /*#__PURE__*/React.createElement(AppName, appNameProps, title), /*#__PURE__*/React.createElement(PrimaryMenuContainer, _extends({
|
|
148
140
|
role: "navigation",
|
|
149
141
|
"aria-label": "Main navigation"
|
|
150
142
|
}, primaryMenuContainerProps), mainItems.map((item, index) => {
|
|
@@ -165,9 +157,7 @@ export default function AppNavBar(props) {
|
|
|
165
157
|
onSelect: onMainItemSelect,
|
|
166
158
|
overrides: overrides
|
|
167
159
|
});
|
|
168
|
-
}))
|
|
169
|
-
span: [0, 1, 1]
|
|
170
|
-
}, /*#__PURE__*/React.createElement(Spacing, spacingProps, /*#__PURE__*/React.createElement(UserMenu, {
|
|
160
|
+
})), userItems.length ? /*#__PURE__*/React.createElement(UserMenu, {
|
|
171
161
|
mapItemToNode: mapItemToNode,
|
|
172
162
|
onItemSelect: onUserItemSelect,
|
|
173
163
|
overrides: overrides,
|
|
@@ -175,7 +165,7 @@ export default function AppNavBar(props) {
|
|
|
175
165
|
usernameSubtitle: usernameSubtitle,
|
|
176
166
|
userImgUrl: userImgUrl,
|
|
177
167
|
userItems: userItems
|
|
178
|
-
})
|
|
168
|
+
}) : null)), secondaryMenu && desktopSubNavPosition === POSITION.horizontal && /*#__PURE__*/React.createElement(SecondaryMenu, {
|
|
179
169
|
items: secondaryMenu,
|
|
180
170
|
mapItemToNode: mapItemToNode,
|
|
181
171
|
onSelect: onMainItemSelect,
|
|
@@ -43,20 +43,11 @@ export const StyledRoot = styled('div', props => {
|
|
|
43
43
|
} = props;
|
|
44
44
|
return { ...$theme.typography.font300,
|
|
45
45
|
boxSizing: 'border-box',
|
|
46
|
-
backgroundColor: $theme.colors.backgroundPrimary
|
|
47
|
-
boxShadow: '0px 1px 0px rgba(0, 0, 0, 0.08)',
|
|
48
|
-
width: '100%'
|
|
46
|
+
backgroundColor: $theme.colors.backgroundPrimary
|
|
49
47
|
};
|
|
50
48
|
});
|
|
51
49
|
StyledRoot.displayName = "StyledRoot";
|
|
52
|
-
export const StyledSubnavContainer = styled('div',
|
|
53
|
-
$theme
|
|
54
|
-
}) => {
|
|
55
|
-
return {
|
|
56
|
-
boxSizing: 'border-box',
|
|
57
|
-
boxShadow: '0px -1px 0px rgba(0, 0, 0, 0.08)'
|
|
58
|
-
};
|
|
59
|
-
});
|
|
50
|
+
export const StyledSubnavContainer = styled('div', {});
|
|
60
51
|
StyledSubnavContainer.displayName = "StyledSubnavContainer";
|
|
61
52
|
export const StyledSpacing = styled('div', props => {
|
|
62
53
|
const {
|
|
@@ -106,9 +97,11 @@ export const StyledPrimaryMenuContainer = styled('div', ({
|
|
|
106
97
|
height: '100%',
|
|
107
98
|
display: 'flex',
|
|
108
99
|
flexDirection: 'row',
|
|
100
|
+
flexGrow: 1,
|
|
109
101
|
flexWrap: 'nowrap',
|
|
110
102
|
justifyContent: 'flex-end',
|
|
111
|
-
alignItems: 'stretch'
|
|
103
|
+
alignItems: 'stretch',
|
|
104
|
+
paddingInlineEnd: $theme.sizing.scale1000
|
|
112
105
|
};
|
|
113
106
|
});
|
|
114
107
|
StyledPrimaryMenuContainer.displayName = "StyledPrimaryMenuContainer";
|
|
@@ -167,6 +160,8 @@ export const StyledSecondaryMenuContainer = styled('div', ({
|
|
|
167
160
|
flexDirection: 'row',
|
|
168
161
|
flexWrap: 'nowrap',
|
|
169
162
|
justifyContent: 'flex-start',
|
|
163
|
+
margin: 'auto',
|
|
164
|
+
maxWidth: `${$theme.breakpoints.large}px`,
|
|
170
165
|
alignItems: 'stretch',
|
|
171
166
|
overflow: 'auto'
|
|
172
167
|
};
|
|
@@ -219,4 +214,28 @@ export const StyledUserProfileInfoContainer = styled('div', ({
|
|
|
219
214
|
alignSelf: 'center'
|
|
220
215
|
};
|
|
221
216
|
});
|
|
222
|
-
StyledUserProfileInfoContainer.displayName = "StyledUserProfileInfoContainer";
|
|
217
|
+
StyledUserProfileInfoContainer.displayName = "StyledUserProfileInfoContainer";
|
|
218
|
+
export const StyledDesktopMenuContainer = styled('div', ({
|
|
219
|
+
$theme
|
|
220
|
+
}) => {
|
|
221
|
+
return {
|
|
222
|
+
borderBottomWidth: '1px',
|
|
223
|
+
borderBottomStyle: 'solid',
|
|
224
|
+
borderBottomColor: `${$theme.colors.borderOpaque}`
|
|
225
|
+
};
|
|
226
|
+
});
|
|
227
|
+
StyledDesktopMenuContainer.displayName = "StyledDesktopMenuContainer";
|
|
228
|
+
export const StyledDesktopMenu = styled('div', ({
|
|
229
|
+
$theme
|
|
230
|
+
}) => {
|
|
231
|
+
return {
|
|
232
|
+
alignItems: 'center',
|
|
233
|
+
display: 'flex',
|
|
234
|
+
justifyContent: 'space-between',
|
|
235
|
+
margin: 'auto',
|
|
236
|
+
maxWidth: `${$theme.breakpoints.large}px`,
|
|
237
|
+
paddingBlockStart: '18px',
|
|
238
|
+
paddingBlockEnd: '18px'
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
StyledDesktopMenu.displayName = "StyledDesktopMenu";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Copyright (c) Uber Technologies, Inc.
|
|
5
|
+
|
|
6
|
+
This source code is licensed under the MIT license found in the
|
|
7
|
+
LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { getOverrides } from '../helpers/overrides.js';
|
|
11
|
+
import { StyledBadge, StyledRoot, StyledPositioner } from './styled-components.js';
|
|
12
|
+
import { PLACEMENT, ROLE, SHAPE, HIERARCHY } from './constants.js';
|
|
13
|
+
import { getAnchorFromChildren } from './utils.js';
|
|
14
|
+
|
|
15
|
+
const Badge = ({
|
|
16
|
+
children,
|
|
17
|
+
content,
|
|
18
|
+
color,
|
|
19
|
+
shape = SHAPE.rectangle,
|
|
20
|
+
placement = PLACEMENT.topRight,
|
|
21
|
+
hierarchy,
|
|
22
|
+
horizontalOffset,
|
|
23
|
+
verticalOffset,
|
|
24
|
+
hidden,
|
|
25
|
+
overrides = {}
|
|
26
|
+
}) => {
|
|
27
|
+
const [Badge, badgeProps] = getOverrides(overrides.Badge, StyledBadge);
|
|
28
|
+
const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
|
|
29
|
+
const [Positioner, positionerProps] = getOverrides(overrides.Positioner, StyledPositioner);
|
|
30
|
+
const anchor = getAnchorFromChildren(children);
|
|
31
|
+
const VALID_RECT_PLACEMENTS = [PLACEMENT.topLeft, PLACEMENT.topRight, PLACEMENT.bottomRight, PLACEMENT.bottomLeft];
|
|
32
|
+
|
|
33
|
+
if (process.env.NODE_ENV !== "production") {
|
|
34
|
+
if (shape === SHAPE.rectangle && !VALID_RECT_PLACEMENTS.includes(placement)) {
|
|
35
|
+
console.warn('Rectangle badges should only be placed in a corner or used inline');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (shape === SHAPE.rectangle && hierarchy === HIERARCHY.secondary && anchor) {
|
|
39
|
+
console.warn('Secondary badges should not be positioned. Use the inline version of this badge instead.');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (shape === SHAPE.pill && hierarchy === HIERARCHY.secondary) {
|
|
43
|
+
console.warn('Pill badges should only be used with primary hierarchy');
|
|
44
|
+
}
|
|
45
|
+
} // If there's no anchor, render the badge inline
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if (!anchor) {
|
|
49
|
+
return /*#__PURE__*/React.createElement(Badge, _extends({
|
|
50
|
+
$hierarchy: hierarchy,
|
|
51
|
+
$shape: shape,
|
|
52
|
+
$color: color,
|
|
53
|
+
$hidden: hidden
|
|
54
|
+
}, badgeProps), content);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return /*#__PURE__*/React.createElement(Root, rootProps, anchor, /*#__PURE__*/React.createElement(Positioner, _extends({
|
|
58
|
+
$horizontalOffset: horizontalOffset,
|
|
59
|
+
$verticalOffset: verticalOffset,
|
|
60
|
+
$placement: placement,
|
|
61
|
+
$role: ROLE.badge
|
|
62
|
+
}, positionerProps), /*#__PURE__*/React.createElement(Badge, _extends({
|
|
63
|
+
$hierarchy: hierarchy,
|
|
64
|
+
$shape: shape,
|
|
65
|
+
$color: color,
|
|
66
|
+
$hidden: hidden
|
|
67
|
+
}, badgeProps), content)));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default Badge;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 HIERARCHY = Object.freeze({
|
|
8
|
+
primary: 'primary',
|
|
9
|
+
secondary: 'secondary'
|
|
10
|
+
});
|
|
11
|
+
export const SHAPE = Object.freeze({
|
|
12
|
+
pill: 'pill',
|
|
13
|
+
rectangle: 'rectangle'
|
|
14
|
+
});
|
|
15
|
+
export const COLOR = Object.freeze({
|
|
16
|
+
accent: 'accent',
|
|
17
|
+
primary: 'primary',
|
|
18
|
+
positive: 'positive',
|
|
19
|
+
negative: 'negative',
|
|
20
|
+
warning: 'warning'
|
|
21
|
+
});
|
|
22
|
+
export const PLACEMENT = Object.freeze({
|
|
23
|
+
topLeft: 'topLeft',
|
|
24
|
+
topRight: 'topRight',
|
|
25
|
+
bottomRight: 'bottomRight',
|
|
26
|
+
bottomLeft: 'bottomLeft',
|
|
27
|
+
topLeftEdge: 'topLeftEdge',
|
|
28
|
+
topEdge: 'topEdge',
|
|
29
|
+
topRightEdge: 'topRightEdge',
|
|
30
|
+
bottomRightEdge: 'bottomRightEdge',
|
|
31
|
+
bottomEdge: 'bottomEdge',
|
|
32
|
+
bottomLeftEdge: 'bottomLeftEdge',
|
|
33
|
+
leftTopEdge: 'leftTopEdge',
|
|
34
|
+
rightTopEdge: 'rightTopEdge',
|
|
35
|
+
rightBottomEdge: 'rightBottomEdge',
|
|
36
|
+
leftBottomEdge: 'leftBottomEdge'
|
|
37
|
+
});
|
|
38
|
+
export const ROLE = Object.freeze({
|
|
39
|
+
badge: 'badge',
|
|
40
|
+
notificationCircle: 'notificationCircle',
|
|
41
|
+
hintDot: 'hintDot'
|
|
42
|
+
});
|