baseui 10.12.1 → 11.0.2
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/README.md +3 -3
- package/accordion/accordion.js +60 -13
- package/accordion/accordion.js.flow +49 -12
- package/accordion/index.d.ts +0 -3
- package/accordion/panel.js +7 -6
- package/accordion/panel.js.flow +20 -20
- package/accordion/stateless-accordion.js +2 -4
- package/accordion/stateless-accordion.js.flow +0 -2
- package/accordion/types.js.flow +0 -5
- package/button/constants.js +1 -2
- package/button/constants.js.flow +0 -1
- package/button/index.d.ts +0 -1
- package/button/styled-components.js +2 -29
- package/button/styled-components.js.flow +2 -30
- package/checkbox/checkbox.js +6 -30
- package/checkbox/checkbox.js.flow +7 -38
- package/checkbox/constants.js +2 -1
- package/checkbox/constants.js.flow +2 -1
- package/checkbox/index.d.ts +4 -6
- package/checkbox/index.js +0 -6
- package/checkbox/index.js.flow +0 -1
- package/checkbox/styled-components.js +52 -149
- package/checkbox/styled-components.js.flow +59 -165
- package/checkbox/types.js.flow +0 -5
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +1 -1
- package/data-table/column-datetime.js +1 -1
- package/data-table/column-datetime.js.flow +3 -1
- package/data-table/column.js +6 -2
- package/data-table/column.js.flow +9 -7
- package/data-table/data-table.js +10 -2
- package/data-table/data-table.js.flow +4 -1
- package/data-table/header-cell.js +3 -0
- package/data-table/header-cell.js.flow +1 -1
- package/data-table/index.d.ts +7 -8
- package/data-table/stateful-data-table.js +2 -1
- package/data-table/stateful-data-table.js.flow +1 -0
- package/data-table/types.js.flow +8 -0
- package/datepicker/calendar.js +28 -15
- package/datepicker/calendar.js.flow +31 -14
- package/datepicker/constants.js +12 -2
- package/datepicker/constants.js.flow +10 -0
- package/datepicker/datepicker.js +117 -86
- package/datepicker/datepicker.js.flow +123 -66
- package/datepicker/day.js +85 -34
- package/datepicker/day.js.flow +118 -54
- package/datepicker/locale.js.flow +0 -1
- package/datepicker/month.js +3 -1
- package/datepicker/month.js.flow +2 -0
- 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 -3
- package/datepicker/stateful-datepicker.js +6 -1
- package/datepicker/stateful-datepicker.js.flow +7 -1
- package/datepicker/styled-components.js +23 -1
- package/datepicker/styled-components.js.flow +12 -2
- package/datepicker/types.js.flow +46 -43
- package/datepicker/utils/date-helpers.js +30 -0
- package/datepicker/utils/date-helpers.js.flow +12 -0
- package/datepicker/week.js +3 -1
- package/datepicker/week.js.flow +2 -0
- package/es/accordion/accordion.js +52 -12
- package/es/accordion/panel.js +7 -5
- package/es/accordion/stateless-accordion.js +2 -4
- package/es/button/constants.js +1 -2
- package/es/button/styled-components.js +2 -29
- package/es/checkbox/checkbox.js +7 -32
- package/es/checkbox/constants.js +2 -1
- package/es/checkbox/index.js +1 -1
- package/es/checkbox/styled-components.js +51 -146
- package/es/data-table/column-categorical.js +1 -1
- package/es/data-table/column-datetime.js +1 -1
- package/es/data-table/column.js +6 -2
- package/es/data-table/data-table.js +6 -2
- package/es/data-table/header-cell.js +3 -0
- package/es/data-table/stateful-data-table.js +2 -1
- package/es/datepicker/calendar.js +28 -15
- package/es/datepicker/constants.js +8 -0
- package/es/datepicker/datepicker.js +106 -79
- package/es/datepicker/day.js +77 -34
- package/es/datepicker/month.js +3 -1
- 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/styled-components.js +8 -2
- package/es/datepicker/types.js +1 -1
- package/es/datepicker/utils/date-helpers.js +16 -0
- package/es/datepicker/week.js +3 -1
- package/es/file-uploader/file-uploader.js +4 -4
- package/es/form-control/styled-components.js +0 -1
- package/es/header-navigation/styled-components.js +3 -3
- package/es/helpers/overrides.js +1 -2
- package/es/input/styled-components.js +4 -4
- package/es/layer/layer.js +4 -4
- package/es/list/list-item.js +5 -1
- package/es/list/menu-adapter.js +4 -0
- package/es/locale/index.js +0 -7
- package/es/menu/stateful-container.js +0 -1
- package/es/menu/styled-components.js +1 -1
- package/es/modal/index.js +1 -1
- package/es/modal/modal.js +19 -65
- package/es/modal/styled-components.js +12 -48
- package/es/phone-input/default-props.js +1 -1
- package/es/phone-input/index.js +0 -4
- package/es/phone-input/phone-input-lite.js +55 -31
- package/es/radio/radio.js +1 -7
- package/es/radio/radiogroup.js +3 -28
- package/es/radio/styled-components.js +4 -5
- package/es/rating/styled-components.js +3 -3
- package/es/select/index.js +1 -2
- package/es/select/select-component.js +20 -20
- package/es/select/styled-components.js +21 -17
- package/es/snackbar/snackbar-context.js +1 -1
- package/es/snackbar/styled-components.js +2 -2
- package/es/spinner/index.js +3 -9
- package/es/spinner/styled-components.js +2 -32
- package/es/table/filter.js +3 -3
- package/es/tag/styled-components.js +1 -1
- package/es/themes/dark-theme/color-component-tokens.js +0 -38
- package/es/themes/dark-theme/color-tokens.js +0 -2
- package/es/themes/dark-theme/create-dark-theme.js +0 -2
- package/es/themes/dark-theme/dark-theme.js +0 -2
- package/es/themes/light-theme/color-component-tokens.js +0 -38
- package/es/themes/light-theme/color-tokens.js +0 -2
- package/es/themes/light-theme/create-light-theme.js +0 -2
- package/es/themes/light-theme/light-theme.js +0 -2
- package/es/timepicker/timepicker.js +1 -8
- package/es/typography/index.js +1 -31
- package/esm/accordion/accordion.js +60 -13
- package/esm/accordion/panel.js +7 -6
- package/esm/accordion/stateless-accordion.js +2 -4
- package/esm/button/constants.js +1 -2
- package/esm/button/styled-components.js +2 -29
- package/esm/checkbox/checkbox.js +7 -30
- package/esm/checkbox/constants.js +2 -1
- package/esm/checkbox/index.js +1 -1
- package/esm/checkbox/styled-components.js +52 -147
- package/esm/data-table/column-categorical.js +1 -1
- package/esm/data-table/column-datetime.js +1 -1
- package/esm/data-table/column.js +6 -2
- package/esm/data-table/data-table.js +10 -2
- package/esm/data-table/header-cell.js +3 -0
- package/esm/data-table/stateful-data-table.js +2 -1
- package/esm/datepicker/calendar.js +28 -15
- package/esm/datepicker/constants.js +8 -0
- package/esm/datepicker/datepicker.js +116 -86
- package/esm/datepicker/day.js +84 -34
- package/esm/datepicker/month.js +3 -1
- 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/styled-components.js +24 -2
- package/esm/datepicker/types.js +1 -1
- package/esm/datepicker/utils/date-helpers.js +30 -0
- package/esm/datepicker/week.js +3 -1
- package/esm/file-uploader/file-uploader.js +4 -4
- package/esm/form-control/styled-components.js +0 -1
- package/esm/header-navigation/styled-components.js +3 -3
- package/esm/helpers/overrides.js +1 -2
- package/esm/input/styled-components.js +4 -4
- package/esm/layer/layer.js +4 -4
- package/esm/list/list-item.js +5 -1
- package/esm/list/menu-adapter.js +4 -0
- package/esm/locale/index.js +0 -7
- package/esm/menu/stateful-container.js +0 -1
- package/esm/menu/styled-components.js +1 -1
- package/esm/modal/index.js +1 -1
- package/esm/modal/modal.js +28 -71
- package/esm/modal/styled-components.js +6 -38
- package/esm/phone-input/default-props.js +1 -1
- package/esm/phone-input/index.js +0 -4
- package/esm/phone-input/phone-input-lite.js +60 -37
- package/esm/radio/radio.js +1 -7
- package/esm/radio/radiogroup.js +3 -28
- package/esm/radio/styled-components.js +4 -5
- package/esm/rating/styled-components.js +3 -3
- package/esm/select/index.js +1 -2
- package/esm/select/select-component.js +20 -20
- package/esm/select/styled-components.js +21 -14
- package/esm/snackbar/snackbar-context.js +1 -1
- package/esm/snackbar/styled-components.js +2 -2
- package/esm/spinner/index.js +3 -9
- package/esm/spinner/styled-components.js +2 -40
- package/esm/table/filter.js +3 -3
- package/esm/tag/styled-components.js +1 -1
- package/esm/themes/dark-theme/color-component-tokens.js +0 -38
- package/esm/themes/dark-theme/color-tokens.js +0 -2
- package/esm/themes/dark-theme/create-dark-theme.js +1 -2
- package/esm/themes/dark-theme/dark-theme.js +1 -2
- package/esm/themes/light-theme/color-component-tokens.js +0 -38
- package/esm/themes/light-theme/color-tokens.js +0 -2
- package/esm/themes/light-theme/create-light-theme.js +1 -2
- package/esm/themes/light-theme/light-theme.js +1 -2
- package/esm/timepicker/timepicker.js +1 -8
- package/esm/typography/index.js +1 -35
- package/file-uploader/file-uploader.js +3 -3
- package/file-uploader/file-uploader.js.flow +4 -4
- package/form-control/index.d.ts +9 -0
- package/form-control/styled-components.js +0 -1
- package/form-control/styled-components.js.flow +0 -1
- package/header-navigation/styled-components.js +3 -3
- package/header-navigation/styled-components.js.flow +3 -3
- package/helpers/overrides.js +1 -2
- package/helpers/overrides.js.flow +1 -1
- package/input/index.d.ts +5 -9
- package/input/styled-components.js +4 -4
- package/input/styled-components.js.flow +4 -4
- package/layer/layer.js +4 -4
- package/layer/layer.js.flow +4 -3
- package/list/list-item.js +5 -1
- package/list/list-item.js.flow +4 -0
- package/list/menu-adapter.js +4 -0
- package/list/menu-adapter.js.flow +4 -0
- package/list/types.js.flow +4 -0
- package/locale/index.js +0 -7
- package/locale/index.js.flow +0 -7
- package/locale.ts +0 -1
- package/menu/index.d.ts +1 -3
- package/menu/stateful-container.js +0 -1
- package/menu/stateful-container.js.flow +0 -1
- package/menu/styled-components.js +1 -1
- package/menu/styled-components.js.flow +1 -1
- package/modal/index.d.ts +4 -6
- package/modal/index.js +0 -6
- package/modal/index.js.flow +0 -1
- package/modal/modal.js +27 -70
- package/modal/modal.js.flow +17 -83
- package/modal/styled-components.js +7 -40
- package/modal/styled-components.js.flow +12 -44
- package/modal/types.js.flow +1 -10
- package/package.json +3 -2
- package/phone-input/default-props.js +1 -1
- package/phone-input/default-props.js.flow +1 -1
- package/phone-input/index.d.ts +0 -1
- package/phone-input/index.js +0 -36
- package/phone-input/index.js.flow +0 -4
- package/phone-input/phone-input-lite.js +63 -38
- package/phone-input/phone-input-lite.js.flow +66 -44
- package/radio/index.d.ts +4 -9
- package/radio/radio.js +1 -7
- package/radio/radio.js.flow +1 -8
- package/radio/radiogroup.js +3 -28
- package/radio/radiogroup.js.flow +2 -26
- package/radio/styled-components.js +4 -5
- package/radio/styled-components.js.flow +3 -4
- package/radio/types.js.flow +4 -15
- package/rating/styled-components.js +3 -3
- package/rating/styled-components.js.flow +3 -3
- package/select/index.d.ts +0 -2
- package/select/index.js +0 -6
- package/select/index.js.flow +0 -2
- package/select/select-component.js +23 -24
- package/select/select-component.js.flow +25 -14
- package/select/styled-components.js +23 -17
- package/select/styled-components.js.flow +17 -12
- package/snackbar/snackbar-context.js +1 -1
- package/snackbar/snackbar-context.js.flow +1 -1
- package/snackbar/styled-components.js +1 -1
- package/snackbar/styled-components.js.flow +11 -11
- package/spinner/index.d.ts +5 -18
- package/spinner/index.js +2 -68
- package/spinner/index.js.flow +2 -27
- package/spinner/styled-components.js +9 -45
- package/spinner/styled-components.js.flow +2 -34
- package/spinner/types.js.flow +1 -19
- package/styles/types.js.flow +0 -2
- package/table/filter.js +3 -3
- package/table/filter.js.flow +3 -3
- package/tag/styled-components.js +1 -1
- package/tag/styled-components.js.flow +1 -1
- package/tag/types.js.flow +1 -1
- package/theme.ts +0 -81
- package/themes/dark-theme/color-component-tokens.js +0 -38
- package/themes/dark-theme/color-component-tokens.js.flow +0 -42
- package/themes/dark-theme/color-tokens.js +0 -2
- package/themes/dark-theme/color-tokens.js.flow +0 -2
- package/themes/dark-theme/create-dark-theme.js +1 -3
- package/themes/dark-theme/create-dark-theme.js.flow +0 -2
- package/themes/dark-theme/dark-theme.js +1 -3
- package/themes/dark-theme/dark-theme.js.flow +0 -2
- package/themes/light-theme/color-component-tokens.js +0 -38
- package/themes/light-theme/color-component-tokens.js.flow +0 -43
- package/themes/light-theme/color-tokens.js +0 -2
- package/themes/light-theme/color-tokens.js.flow +0 -2
- package/themes/light-theme/create-light-theme.js +1 -3
- package/themes/light-theme/create-light-theme.js.flow +0 -2
- package/themes/light-theme/light-theme.js +1 -3
- package/themes/light-theme/light-theme.js.flow +0 -2
- package/themes/types.js.flow +0 -68
- package/timepicker/timepicker.js +1 -8
- package/timepicker/timepicker.js.flow +4 -10
- package/typography/index.d.ts +0 -23
- package/typography/index.js +2 -57
- package/typography/index.js.flow +0 -31
- package/es/spinner/spinner.js +0 -68
- package/es/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -35
- package/es/themes/light-theme/color-deprecated-semantic-tokens.js +0 -35
- package/esm/spinner/spinner.js +0 -125
- package/esm/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -38
- package/esm/themes/light-theme/color-deprecated-semantic-tokens.js +0 -38
- package/spinner/spinner.js +0 -136
- package/spinner/spinner.js.flow +0 -75
- package/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -50
- package/themes/dark-theme/color-deprecated-semantic-tokens.js.flow +0 -42
- package/themes/light-theme/color-deprecated-semantic-tokens.js +0 -50
- package/themes/light-theme/color-deprecated-semantic-tokens.js.flow +0 -42
package/datepicker/types.js.flow
CHANGED
|
@@ -9,7 +9,13 @@ LICENSE file in the root directory of this source tree.
|
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
import type { OverrideT } from '../helpers/overrides.js';
|
|
11
11
|
import type { SizeT } from '../input/types.js';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
INPUT_ROLE,
|
|
14
|
+
ORIENTATION,
|
|
15
|
+
RANGED_CALENDAR_BEHAVIOR,
|
|
16
|
+
STATE_CHANGE_TYPE,
|
|
17
|
+
DENSITY,
|
|
18
|
+
} from './constants.js';
|
|
13
19
|
import type { DateIOAdapter } from './utils/types.js';
|
|
14
20
|
import type {
|
|
15
21
|
TimePickerPropsT as TimePickerPropsTBase,
|
|
@@ -21,8 +27,6 @@ import type { OptionT } from '../select/index.js';
|
|
|
21
27
|
// flowlint-next-line unclear-type:off
|
|
22
28
|
type LocaleT = any; // see https://github.com/date-fns/date-fns/blob/master/src/locale/index.js.flow
|
|
23
29
|
|
|
24
|
-
type onChangeT<T> = ({ date: ?T | Array<T> }) => mixed;
|
|
25
|
-
|
|
26
30
|
export type DensityT = $Keys<typeof DENSITY>;
|
|
27
31
|
|
|
28
32
|
export type DatepickerOverridesT = {
|
|
@@ -74,6 +78,8 @@ export type DayPropsT<T = Date> = {
|
|
|
74
78
|
includeDates: ?Array<T>,
|
|
75
79
|
highlighted: boolean,
|
|
76
80
|
range: boolean,
|
|
81
|
+
hasLockedBehavior: boolean,
|
|
82
|
+
selectedInput: InputRoleT,
|
|
77
83
|
focusedCalendar: boolean,
|
|
78
84
|
locale: ?LocaleT,
|
|
79
85
|
maxDate: ?T,
|
|
@@ -82,13 +88,13 @@ export type DayPropsT<T = Date> = {
|
|
|
82
88
|
month: ?number,
|
|
83
89
|
onBlur: ({ event: Event, date: T }) => mixed,
|
|
84
90
|
onFocus: ({ event: Event, date: T }) => mixed,
|
|
85
|
-
onSelect: ({ date:
|
|
91
|
+
onSelect: ({ date: T | Array<?T> }) => mixed,
|
|
86
92
|
onClick: ({ event: Event, date: T }) => mixed,
|
|
87
93
|
onMouseOver: ({ event: Event, date: T }) => mixed,
|
|
88
94
|
onMouseLeave: ({ event: Event, date: T }) => mixed,
|
|
89
95
|
overrides?: DatepickerOverridesT,
|
|
90
96
|
peekNextMonth: boolean,
|
|
91
|
-
value: ?T |
|
|
97
|
+
value: ?T | $ReadOnlyArray<?T>,
|
|
92
98
|
};
|
|
93
99
|
|
|
94
100
|
export type DayStateT = {
|
|
@@ -117,13 +123,16 @@ export type WeekPropsT<T = Date> = {
|
|
|
117
123
|
onDayFocus: ({ date: T, event: Event }) => mixed,
|
|
118
124
|
onDayMouseOver: ({ date: T, event: Event }) => mixed,
|
|
119
125
|
onDayMouseLeave: ({ date: T, event: Event }) => mixed,
|
|
120
|
-
onChange?:
|
|
126
|
+
onChange?: ({ +date: ?T | Array<?T> }) => mixed,
|
|
121
127
|
overrides?: DatepickerOverridesT,
|
|
122
128
|
peekNextMonth: boolean,
|
|
123
|
-
value: ?T |
|
|
129
|
+
value: ?T | $ReadOnlyArray<?T>,
|
|
130
|
+
hasLockedBehavior: boolean,
|
|
131
|
+
selectedInput?: InputRoleT,
|
|
124
132
|
};
|
|
125
133
|
|
|
126
|
-
export type MonthPropsT<T = Date> =
|
|
134
|
+
export type MonthPropsT<T = Date> = {
|
|
135
|
+
...WeekPropsT<T>,
|
|
127
136
|
fixedHeight?: boolean,
|
|
128
137
|
};
|
|
129
138
|
|
|
@@ -133,7 +142,7 @@ export type CalendarInternalState<T = Date> = {
|
|
|
133
142
|
date: T,
|
|
134
143
|
quickSelectId: ?string,
|
|
135
144
|
rootElement: ?HTMLElement,
|
|
136
|
-
time: Array
|
|
145
|
+
time: Array<?T>,
|
|
137
146
|
};
|
|
138
147
|
|
|
139
148
|
export type CalendarPropsT<T = Date> = {
|
|
@@ -157,6 +166,8 @@ export type CalendarPropsT<T = Date> = {
|
|
|
157
166
|
includeDates?: ?Array<T>,
|
|
158
167
|
/** Defines if a range of dates can be selected. */
|
|
159
168
|
range?: boolean,
|
|
169
|
+
/** Determines whether startDate and endDate should be updated independently of eachother */
|
|
170
|
+
hasLockedBehavior?: boolean,
|
|
160
171
|
/** A locale object. See `date-fns` for more details https://github.com/date-fns/date-fns/tree/master/src/locale. */
|
|
161
172
|
locale?: ?LocaleT,
|
|
162
173
|
/** A max date that is selectable. */
|
|
@@ -179,7 +190,7 @@ export type CalendarPropsT<T = Date> = {
|
|
|
179
190
|
/** Event handler that is called when the current rendered month's year is changed. */
|
|
180
191
|
onYearChange?: ({ date: T }) => mixed,
|
|
181
192
|
/** Event handler that is called when a new date is selected. */
|
|
182
|
-
onChange?:
|
|
193
|
+
onChange?: ({ +date: ?T | Array<?T> }) => mixed,
|
|
183
194
|
/** Event handler that is called when a selection is made using the quick select menu. */
|
|
184
195
|
onQuickSelectChange?: (option?: QuickSelectOption<T>) => mixed,
|
|
185
196
|
/** Sets the orientation of the calendar when multiple months are displayed */
|
|
@@ -194,8 +205,10 @@ export type CalendarPropsT<T = Date> = {
|
|
|
194
205
|
/** Defines if tabbing inside the calendar is circled within it. */
|
|
195
206
|
trapTabbing?: boolean,
|
|
196
207
|
/** Currently selected date. */
|
|
197
|
-
value?: ?T |
|
|
208
|
+
value?: ?T | $ReadOnlyArray<?T>,
|
|
198
209
|
fixedHeight?: boolean,
|
|
210
|
+
/** Determines whether user clicked startDate or endDate input to trigger calendar open */
|
|
211
|
+
selectedInput?: InputRoleT,
|
|
199
212
|
};
|
|
200
213
|
|
|
201
214
|
export type HeaderPropsT<T = Date> = CalendarPropsT<T> & {
|
|
@@ -209,7 +222,8 @@ export type QuickSelectOption<T> = {
|
|
|
209
222
|
endDate?: T,
|
|
210
223
|
};
|
|
211
224
|
|
|
212
|
-
export type DatepickerPropsT<T = Date> =
|
|
225
|
+
export type DatepickerPropsT<T = Date> = {
|
|
226
|
+
...CalendarPropsT<T>,
|
|
213
227
|
'aria-label'?: string,
|
|
214
228
|
'aria-labelledby'?: string,
|
|
215
229
|
'aria-describedby'?: ?string,
|
|
@@ -222,19 +236,26 @@ export type DatepickerPropsT<T = Date> = CalendarPropsT<T> & {
|
|
|
222
236
|
required?: boolean,
|
|
223
237
|
clearable?: boolean,
|
|
224
238
|
displayValueAtRangeIndex?: number,
|
|
225
|
-
formatDisplayValue?: (date: ?T |
|
|
239
|
+
formatDisplayValue?: (date: ?T | $ReadOnlyArray<?T>, formatString: string) => string,
|
|
226
240
|
formatString: string,
|
|
227
241
|
/** Where to mount the popover */
|
|
228
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,
|
|
229
245
|
/** Called when calendar is closed */
|
|
230
246
|
onClose?: () => mixed,
|
|
231
247
|
/** Called when calendar is opened */
|
|
232
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,
|
|
233
251
|
mask?: string | null,
|
|
252
|
+
/** Determines whether startDate and endDate should be updated independently of eachother */
|
|
253
|
+
rangedCalendarBehavior?: RangedCalendarBehaviorT,
|
|
234
254
|
/** Determines if startDate and endDate should be separated into two input fields. Ignored if `range` is not true. */
|
|
235
255
|
separateRangeInputs?: boolean,
|
|
236
256
|
startDateLabel?: string,
|
|
237
257
|
endDateLabel?: string,
|
|
258
|
+
value?: ?T | $ReadOnlyArray<?T>,
|
|
238
259
|
};
|
|
239
260
|
|
|
240
261
|
export type SharedStylePropsT = {
|
|
@@ -260,6 +281,9 @@ export type SharedStylePropsT = {
|
|
|
260
281
|
$hasRangeHighlighted: ?boolean,
|
|
261
282
|
$hasRangeOnRight: ?boolean,
|
|
262
283
|
$hasRangeSelected: ?boolean,
|
|
284
|
+
$hasLockedBehavior: boolean,
|
|
285
|
+
$selectedInput: InputRoleT,
|
|
286
|
+
$value: Date | Array<Date>,
|
|
263
287
|
$order: ?number,
|
|
264
288
|
$hasDateLabel: ?boolean,
|
|
265
289
|
};
|
|
@@ -268,7 +292,7 @@ export type StateChangeTypeT = ?$Values<typeof STATE_CHANGE_TYPE>;
|
|
|
268
292
|
|
|
269
293
|
export type ContainerStateT<T = Date> = {
|
|
270
294
|
/** Selected `Date`. If `range` is set, `value` is an array of 2 values. */
|
|
271
|
-
value?: ?T |
|
|
295
|
+
value?: ?T | $ReadOnlyArray<?T>,
|
|
272
296
|
};
|
|
273
297
|
|
|
274
298
|
export type NavigationContainerStateT<T = Date> = {
|
|
@@ -289,46 +313,21 @@ export type StateReducerT<T = Date> = (
|
|
|
289
313
|
currentState: ContainerStateT<T>
|
|
290
314
|
) => ContainerStateT<T>;
|
|
291
315
|
|
|
292
|
-
export type NavigationContainerStateReducerT<T = Date> = (
|
|
293
|
-
stateType: StateChangeTypeT,
|
|
294
|
-
nextState: NavigationContainerStateT<T>,
|
|
295
|
-
currentState: NavigationContainerStateT<T>
|
|
296
|
-
) => NavigationContainerStateT<T>;
|
|
297
|
-
|
|
298
316
|
export type StatefulContainerPropsT<PropsT, T = Date> = {
|
|
299
317
|
children: (PropsT) => React.Node,
|
|
300
318
|
/** Initial state of an uncontrolled datepicker component. */
|
|
301
319
|
initialState: ContainerStateT<T>,
|
|
302
320
|
/** A state change handler. */
|
|
303
321
|
stateReducer: StateReducerT<T>,
|
|
304
|
-
/**
|
|
305
|
-
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,
|
|
306
326
|
adapter?: DateIOAdapter<T>,
|
|
307
327
|
/** Should the date value be stored as an array or single value. */
|
|
308
328
|
range?: boolean,
|
|
309
329
|
};
|
|
310
330
|
|
|
311
|
-
// This type is seemingly not used anywhere
|
|
312
|
-
export type NavigationContainerPropsT<T = Date> = {
|
|
313
|
-
children: (CalendarPropsT<T>) => React.Node,
|
|
314
|
-
range?: boolean,
|
|
315
|
-
highlightedDate?: ?Date,
|
|
316
|
-
/** Day's `mouseover` event handler. */
|
|
317
|
-
onDayMouseOver: (params: { date: Date, event: Event }) => mixed,
|
|
318
|
-
/** Day's `mouseleave` event handler. */
|
|
319
|
-
onDayMouseLeave: (params: { date: Date, event: Event }) => mixed,
|
|
320
|
-
/** Event handler that is called when a new date is selected. */
|
|
321
|
-
onChange: onChangeT<T>,
|
|
322
|
-
/** Event handler that is called when the current rendered month is changed. */
|
|
323
|
-
onMonthChange?: ({ date: T }) => mixed,
|
|
324
|
-
/** Event handler that is called when the current rendered year is changed. */
|
|
325
|
-
onYearChange?: ({ date: T }) => mixed,
|
|
326
|
-
/** Selected `Date`. If `range` is set, `value` is an array of 2 values. */
|
|
327
|
-
value?: ?T | Array<T>,
|
|
328
|
-
stateReducer: NavigationContainerStateReducerT<T>,
|
|
329
|
-
trapTabbing: boolean,
|
|
330
|
-
};
|
|
331
|
-
|
|
332
331
|
export type StatefulDatepickerPropsT<PropsT, T = Date> = $Diff<
|
|
333
332
|
StatefulContainerPropsT<PropsT, T>,
|
|
334
333
|
{
|
|
@@ -372,6 +371,10 @@ export type TimezonePickerPropsT = {
|
|
|
372
371
|
positive?: boolean,
|
|
373
372
|
};
|
|
374
373
|
|
|
374
|
+
export type InputRoleT = ?$Values<typeof INPUT_ROLE>;
|
|
375
|
+
|
|
376
|
+
export type RangedCalendarBehaviorT = ?$Values<typeof RANGED_CALENDAR_BEHAVIOR>;
|
|
377
|
+
|
|
375
378
|
declare var __DEV__: boolean;
|
|
376
379
|
declare var __NODE__: boolean;
|
|
377
380
|
declare var __BROWSER__: boolean;
|
|
@@ -5,6 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
|
|
10
|
+
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."); }
|
|
11
|
+
|
|
12
|
+
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); }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
|
|
8
20
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
9
21
|
|
|
10
22
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -230,6 +242,24 @@ var DateHelpers = function DateHelpers(_adapter) {
|
|
|
230
242
|
return false;
|
|
231
243
|
});
|
|
232
244
|
|
|
245
|
+
_defineProperty(this, "dateRangeIncludesDates", function (dateRange, dates) {
|
|
246
|
+
var _dateRange = _slicedToArray(dateRange, 2),
|
|
247
|
+
startDate = _dateRange[0],
|
|
248
|
+
endDate = _dateRange[1];
|
|
249
|
+
|
|
250
|
+
if (startDate && endDate && Array.isArray(dates) && dates.length) {
|
|
251
|
+
for (var i = 0; i < dates.length; i++) {
|
|
252
|
+
var _day = dates[i];
|
|
253
|
+
|
|
254
|
+
if (_this.isDayInRange(_day, startDate, endDate)) {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return false;
|
|
261
|
+
});
|
|
262
|
+
|
|
233
263
|
_defineProperty(this, "subDays", function (date, days) {
|
|
234
264
|
return _this.adapter.addDays(date, days * -1);
|
|
235
265
|
});
|
|
@@ -191,6 +191,18 @@ class DateHelpers<T> {
|
|
|
191
191
|
}
|
|
192
192
|
return false;
|
|
193
193
|
};
|
|
194
|
+
dateRangeIncludesDates: (Array<?T>, ?Array<T>) => boolean = (dateRange, dates) => {
|
|
195
|
+
const [startDate, endDate] = dateRange;
|
|
196
|
+
if (startDate && endDate && Array.isArray(dates) && dates.length) {
|
|
197
|
+
for (let i = 0; i < dates.length; i++) {
|
|
198
|
+
const day = dates[i];
|
|
199
|
+
if (this.isDayInRange(day, startDate, endDate)) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return false;
|
|
205
|
+
};
|
|
194
206
|
subDays: (T, number) => T = (date, days) => {
|
|
195
207
|
return this.adapter.addDays(date, days * -1);
|
|
196
208
|
};
|
package/datepicker/week.js
CHANGED
|
@@ -114,7 +114,9 @@ var Week = /*#__PURE__*/function (_React$Component) {
|
|
|
114
114
|
onMouseLeave: _this.props.onDayMouseLeave,
|
|
115
115
|
overrides: _this.props.overrides,
|
|
116
116
|
peekNextMonth: _this.props.peekNextMonth,
|
|
117
|
-
value: _this.props.value
|
|
117
|
+
value: _this.props.value,
|
|
118
|
+
hasLockedBehavior: _this.props.hasLockedBehavior,
|
|
119
|
+
selectedInput: _this.props.selectedInput
|
|
118
120
|
})
|
|
119
121
|
);
|
|
120
122
|
}));
|
package/datepicker/week.js.flow
CHANGED
|
@@ -75,6 +75,8 @@ export default class Week<T = Date> extends React.Component<WeekPropsT<T>> {
|
|
|
75
75
|
overrides={this.props.overrides}
|
|
76
76
|
peekNextMonth={this.props.peekNextMonth}
|
|
77
77
|
value={this.props.value}
|
|
78
|
+
hasLockedBehavior={this.props.hasLockedBehavior}
|
|
79
|
+
selectedInput={this.props.selectedInput}
|
|
78
80
|
/>
|
|
79
81
|
);
|
|
80
82
|
})
|
|
@@ -22,6 +22,8 @@ export default class Accordion extends React.Component {
|
|
|
22
22
|
expanded: [],
|
|
23
23
|
...this.props.initialState
|
|
24
24
|
});
|
|
25
|
+
|
|
26
|
+
_defineProperty(this, "itemRefs", []);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
//flowlint-next-line unclear-type:off
|
|
@@ -64,6 +66,50 @@ export default class Accordion extends React.Component {
|
|
|
64
66
|
typeof onChange === 'function' && onChange(newState);
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
handleKeyDown(e) {
|
|
70
|
+
if (this.props.disabled) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const itemRefs = this.itemRefs;
|
|
75
|
+
const HOME = 36;
|
|
76
|
+
const END = 35;
|
|
77
|
+
const ARROW_UP = 38;
|
|
78
|
+
const ARROW_DOWN = 40;
|
|
79
|
+
|
|
80
|
+
if (e.keyCode === HOME) {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
const firstItem = itemRefs[0];
|
|
83
|
+
firstItem.current && firstItem.current.focus();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (e.keyCode === END) {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
const lastItem = itemRefs[itemRefs.length - 1];
|
|
89
|
+
lastItem.current && lastItem.current.focus();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (e.keyCode === ARROW_UP) {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
const activeItemIdx = itemRefs.findIndex(item => item.current === document.activeElement);
|
|
95
|
+
|
|
96
|
+
if (activeItemIdx > 0) {
|
|
97
|
+
const prevItem = itemRefs[activeItemIdx - 1];
|
|
98
|
+
prevItem.current && prevItem.current.focus();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (e.keyCode === ARROW_DOWN) {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
const activeItemIdx = itemRefs.findIndex(item => item.current === document.activeElement);
|
|
105
|
+
|
|
106
|
+
if (activeItemIdx < itemRefs.length - 1) {
|
|
107
|
+
const nextItem = itemRefs[activeItemIdx + 1];
|
|
108
|
+
nextItem.current && nextItem.current.focus();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
67
113
|
getItems() {
|
|
68
114
|
const {
|
|
69
115
|
expanded
|
|
@@ -72,13 +118,14 @@ export default class Accordion extends React.Component {
|
|
|
72
118
|
accordion,
|
|
73
119
|
disabled,
|
|
74
120
|
children,
|
|
75
|
-
renderPanelContent,
|
|
76
121
|
renderAll,
|
|
77
122
|
overrides
|
|
78
123
|
} = this.props; // flowlint-next-line unclear-type:off
|
|
79
124
|
|
|
80
125
|
return React.Children.map(children, (child, index) => {
|
|
81
|
-
if (!child) return;
|
|
126
|
+
if (!child) return;
|
|
127
|
+
const itemRef = /*#__PURE__*/React.createRef();
|
|
128
|
+
this.itemRefs.push(itemRef); // If there is no key provided use the panel order as a default key
|
|
82
129
|
|
|
83
130
|
const key = child.key || String(index);
|
|
84
131
|
let isExpanded = false;
|
|
@@ -91,9 +138,9 @@ export default class Accordion extends React.Component {
|
|
|
91
138
|
|
|
92
139
|
const props = {
|
|
93
140
|
key,
|
|
141
|
+
ref: itemRef,
|
|
94
142
|
expanded: isExpanded || child.props.expanded,
|
|
95
143
|
accordion,
|
|
96
|
-
renderPanelContent,
|
|
97
144
|
renderAll,
|
|
98
145
|
overrides: child.props.overrides || overrides,
|
|
99
146
|
disabled: child.props.disabled || disabled,
|
|
@@ -103,13 +150,6 @@ export default class Accordion extends React.Component {
|
|
|
103
150
|
});
|
|
104
151
|
}
|
|
105
152
|
|
|
106
|
-
componentDidMount() {
|
|
107
|
-
// TODO(v11)
|
|
108
|
-
if (process.env.NODE_ENV !== "production" && this.props.renderPanelContent) {
|
|
109
|
-
console.warn('baseui:Accordion The `renderPanelContent` prop is deprecated. Please update your code to use `renderAll`.');
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
153
|
render() {
|
|
114
154
|
const {
|
|
115
155
|
overrides = {}
|
|
@@ -121,7 +161,8 @@ export default class Accordion extends React.Component {
|
|
|
121
161
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
122
162
|
"data-baseweb": "accordion",
|
|
123
163
|
$disabled: this.props.disabled,
|
|
124
|
-
$isFocusVisible: false
|
|
164
|
+
$isFocusVisible: false,
|
|
165
|
+
onKeyDown: this.handleKeyDown.bind(this)
|
|
125
166
|
}, rootProps), this.getItems());
|
|
126
167
|
}
|
|
127
168
|
|
|
@@ -136,6 +177,5 @@ _defineProperty(Accordion, "defaultProps", {
|
|
|
136
177
|
onChange: () => {},
|
|
137
178
|
overrides: {},
|
|
138
179
|
renderAll: false,
|
|
139
|
-
renderPanelContent: false,
|
|
140
180
|
stateReducer: (type, newState) => newState
|
|
141
181
|
});
|
package/es/accordion/panel.js
CHANGED
|
@@ -22,9 +22,8 @@ const Panel = ({
|
|
|
22
22
|
onKeyDown = () => {},
|
|
23
23
|
overrides = {},
|
|
24
24
|
title = '',
|
|
25
|
-
renderPanelContent = false,
|
|
26
25
|
renderAll = false
|
|
27
|
-
}) => {
|
|
26
|
+
}, ref) => {
|
|
28
27
|
const [localState, setLocalState] = React.useState({
|
|
29
28
|
expanded,
|
|
30
29
|
isFocusVisible: false,
|
|
@@ -148,7 +147,8 @@ const Panel = ({
|
|
|
148
147
|
onClick: handleClick,
|
|
149
148
|
onKeyDown: handleKeyDown,
|
|
150
149
|
onFocus: forkFocus(headerProps, handleFocus),
|
|
151
|
-
onBlur: forkBlur(headerProps, handleBlur)
|
|
150
|
+
onBlur: forkBlur(headerProps, handleBlur),
|
|
151
|
+
ref: ref
|
|
152
152
|
}), title, /*#__PURE__*/React.createElement(ToggleIcon, _extends({
|
|
153
153
|
viewBox: "0 0 24 24",
|
|
154
154
|
title: localState.expanded ? locale.accordion.collapse : locale.accordion.expand,
|
|
@@ -174,7 +174,9 @@ const Panel = ({
|
|
|
174
174
|
ref: _animateRef
|
|
175
175
|
}, sharedProps, contentProps, ariaControls ? {
|
|
176
176
|
id: ariaControls
|
|
177
|
-
} : {}), localState.expanded || renderAll ||
|
|
177
|
+
} : {}), localState.expanded || renderAll || localState.animationInProgress ? children : null))));
|
|
178
178
|
};
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
const ForwardedPanel = /*#__PURE__*/React.forwardRef(Panel);
|
|
181
|
+
ForwardedPanel.displayName = 'Panel';
|
|
182
|
+
export default ForwardedPanel;
|
|
@@ -17,8 +17,7 @@ function StatelessAccordion({
|
|
|
17
17
|
expanded,
|
|
18
18
|
onChange,
|
|
19
19
|
overrides = {},
|
|
20
|
-
renderAll
|
|
21
|
-
renderPanelContent
|
|
20
|
+
renderAll
|
|
22
21
|
}) {
|
|
23
22
|
const {
|
|
24
23
|
Root: RootOverrides,
|
|
@@ -57,8 +56,7 @@ function StatelessAccordion({
|
|
|
57
56
|
});
|
|
58
57
|
} : onChange,
|
|
59
58
|
overrides: child.props.overrides || PanelOverrides,
|
|
60
|
-
renderAll
|
|
61
|
-
renderPanelContent
|
|
59
|
+
renderAll
|
|
62
60
|
});
|
|
63
61
|
}));
|
|
64
62
|
}
|
package/es/button/constants.js
CHANGED
|
@@ -212,14 +212,6 @@ function getLoadingSpinnerColors({
|
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
case KIND.minimal:
|
|
216
|
-
{
|
|
217
|
-
return {
|
|
218
|
-
foreground: $theme.colors.buttonMinimalSpinnerForeground,
|
|
219
|
-
background: $theme.colors.buttonMinimalSpinnerBackground
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
|
|
223
215
|
case KIND.primary:
|
|
224
216
|
default:
|
|
225
217
|
{
|
|
@@ -289,7 +281,7 @@ function getDisabledStyles({
|
|
|
289
281
|
color: $theme.colors.buttonDisabledActiveText,
|
|
290
282
|
backgroundColor: $theme.colors.buttonDisabledActiveFill
|
|
291
283
|
};
|
|
292
|
-
} else if ($kind === KIND.
|
|
284
|
+
} else if ($kind === KIND.tertiary) {
|
|
293
285
|
return {
|
|
294
286
|
backgroundColor: $theme.colors.buttonTertiaryDisabledActiveFill,
|
|
295
287
|
color: $theme.colors.buttonTertiaryDisabledActiveText
|
|
@@ -298,7 +290,7 @@ function getDisabledStyles({
|
|
|
298
290
|
}
|
|
299
291
|
|
|
300
292
|
return {
|
|
301
|
-
backgroundColor: $kind === KIND.
|
|
293
|
+
backgroundColor: $kind === KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
|
|
302
294
|
color: $theme.colors.buttonDisabledText
|
|
303
295
|
};
|
|
304
296
|
}
|
|
@@ -428,25 +420,6 @@ function getColorStyles({
|
|
|
428
420
|
}
|
|
429
421
|
};
|
|
430
422
|
|
|
431
|
-
case KIND.minimal:
|
|
432
|
-
if ($isSelected) {
|
|
433
|
-
return {
|
|
434
|
-
color: $theme.colors.buttonMinimalSelectedText,
|
|
435
|
-
backgroundColor: $theme.colors.buttonMinimalSelectedFill
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
return {
|
|
440
|
-
color: $theme.colors.buttonMinimalText,
|
|
441
|
-
backgroundColor: $theme.colors.buttonMinimalFill,
|
|
442
|
-
':hover': {
|
|
443
|
-
backgroundColor: $isLoading ? $theme.colors.buttonMinimalActive : $theme.colors.buttonMinimalHover
|
|
444
|
-
},
|
|
445
|
-
':active': {
|
|
446
|
-
backgroundColor: $theme.colors.buttonMinimalActive
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
|
|
450
423
|
default:
|
|
451
424
|
return Object.freeze({});
|
|
452
425
|
}
|
package/es/checkbox/checkbox.js
CHANGED
|
@@ -10,7 +10,7 @@ LICENSE file in the root directory of this source tree.
|
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
12
|
import { getOverride, getOverrideProps } from '../helpers/overrides.js';
|
|
13
|
-
import { Checkmark as StyledCheckmark, Input as StyledInput, Label as StyledLabel, Root as StyledRoot, Toggle as StyledToggle,
|
|
13
|
+
import { Checkmark as StyledCheckmark, Input as StyledInput, Label as StyledLabel, Root as StyledRoot, Toggle as StyledToggle, ToggleTrack as StyledToggleTrack } from './styled-components.js';
|
|
14
14
|
import { STYLE_TYPE } from './constants.js';
|
|
15
15
|
import { isFocusVisible } from '../utils/focusVisible.js';
|
|
16
16
|
|
|
@@ -81,10 +81,6 @@ class StatelessCheckbox extends React.Component {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
|
-
|
|
85
|
-
_defineProperty(this, "isToggle", () => {
|
|
86
|
-
return this.props.checkmarkType === STYLE_TYPE.toggle || this.props.checkmarkType === STYLE_TYPE.toggle_round;
|
|
87
|
-
});
|
|
88
84
|
}
|
|
89
85
|
|
|
90
86
|
componentDidMount() {
|
|
@@ -95,31 +91,16 @@ class StatelessCheckbox extends React.Component {
|
|
|
95
91
|
|
|
96
92
|
if (autoFocus && inputRef.current) {
|
|
97
93
|
inputRef.current.focus();
|
|
98
|
-
} // TODO(v11)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (process.env.NODE_ENV !== "production") {
|
|
102
|
-
if (this.props.checkmarkType === STYLE_TYPE.toggle) {
|
|
103
|
-
console.warn("baseui:Checkbox The STYLE_TYPE.toggle value on the 'checkmarkType' prop does not conform to the current base design specification. " + 'Please update your code to STYLE_TYPE.toggle_round. This will be updated automatically in a future major version.');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (this.props.isError) {
|
|
107
|
-
console.warn('baseui:Checkbox Property "isError" will be removed in the next major version. Use "error" property instead.');
|
|
108
|
-
}
|
|
109
94
|
}
|
|
110
95
|
}
|
|
111
96
|
|
|
112
97
|
render() {
|
|
113
|
-
const {
|
|
114
|
-
checkmarkType
|
|
115
|
-
} = this.props;
|
|
116
98
|
const {
|
|
117
99
|
overrides = {},
|
|
118
100
|
onChange,
|
|
119
|
-
labelPlacement = this.
|
|
101
|
+
labelPlacement = this.props.checkmarkType === STYLE_TYPE.toggle ? 'left' : 'right',
|
|
120
102
|
inputRef,
|
|
121
103
|
isIndeterminate,
|
|
122
|
-
isError,
|
|
123
104
|
error,
|
|
124
105
|
disabled,
|
|
125
106
|
value,
|
|
@@ -136,7 +117,6 @@ class StatelessCheckbox extends React.Component {
|
|
|
136
117
|
Label: LabelOverride,
|
|
137
118
|
Input: InputOverride,
|
|
138
119
|
Toggle: ToggleOverride,
|
|
139
|
-
ToggleInner: ToggleInnerOverride,
|
|
140
120
|
ToggleTrack: ToggleTrackOverride
|
|
141
121
|
} = overrides;
|
|
142
122
|
const Root = getOverride(RootOverride) || StyledRoot;
|
|
@@ -144,7 +124,6 @@ class StatelessCheckbox extends React.Component {
|
|
|
144
124
|
const Label = getOverride(LabelOverride) || StyledLabel;
|
|
145
125
|
const Input = getOverride(InputOverride) || StyledInput;
|
|
146
126
|
const Toggle = getOverride(ToggleOverride) || StyledToggle;
|
|
147
|
-
const ToggleInner = getOverride(ToggleInnerOverride) || StyledToggleInner;
|
|
148
127
|
const ToggleTrack = getOverride(ToggleTrackOverride) || StyledToggleTrack;
|
|
149
128
|
const inputEvents = {
|
|
150
129
|
onChange,
|
|
@@ -162,17 +141,14 @@ class StatelessCheckbox extends React.Component {
|
|
|
162
141
|
$isFocusVisible: this.state.isFocusVisible,
|
|
163
142
|
$isHovered: this.state.isHovered,
|
|
164
143
|
$isActive: this.state.isActive,
|
|
165
|
-
$isError: isError,
|
|
166
144
|
$error: error,
|
|
167
145
|
$checked: checked,
|
|
168
146
|
$isIndeterminate: isIndeterminate,
|
|
169
147
|
$required: required,
|
|
170
148
|
$disabled: disabled,
|
|
171
|
-
$value: value
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const labelComp = /*#__PURE__*/React.createElement(Label, _extends({
|
|
149
|
+
$value: value
|
|
150
|
+
};
|
|
151
|
+
const labelComp = children && /*#__PURE__*/React.createElement(Label, _extends({
|
|
176
152
|
$labelPlacement: labelPlacement
|
|
177
153
|
}, sharedProps, getOverrideProps(LabelOverride)), this.props.containsInteractiveElement ?
|
|
178
154
|
/*#__PURE__*/
|
|
@@ -185,7 +161,7 @@ class StatelessCheckbox extends React.Component {
|
|
|
185
161
|
"data-baseweb": "checkbox",
|
|
186
162
|
title: title || null,
|
|
187
163
|
$labelPlacement: labelPlacement
|
|
188
|
-
}, sharedProps, mouseEvents, getOverrideProps(RootOverride)), (labelPlacement === 'top' || labelPlacement === 'left') && labelComp, this.
|
|
164
|
+
}, sharedProps, mouseEvents, getOverrideProps(RootOverride)), (labelPlacement === 'top' || labelPlacement === 'left') && labelComp, this.props.checkmarkType === STYLE_TYPE.toggle ? /*#__PURE__*/React.createElement(ToggleTrack, _extends({}, sharedProps, getOverrideProps(ToggleTrackOverride)), /*#__PURE__*/React.createElement(Toggle, _extends({}, sharedProps, getOverrideProps(ToggleOverride)))) : /*#__PURE__*/React.createElement(Checkmark, _extends({}, sharedProps, getOverrideProps(CheckmarkOverride))), /*#__PURE__*/React.createElement(Input, _extends({
|
|
189
165
|
value: value,
|
|
190
166
|
name: name,
|
|
191
167
|
checked: checked,
|
|
@@ -194,7 +170,7 @@ class StatelessCheckbox extends React.Component {
|
|
|
194
170
|
"aria-checked": isIndeterminate ? 'mixed' : checked,
|
|
195
171
|
"aria-describedby": this.props['aria-describedby'],
|
|
196
172
|
"aria-errormessage": this.props['aria-errormessage'],
|
|
197
|
-
"aria-invalid": error ||
|
|
173
|
+
"aria-invalid": error || null,
|
|
198
174
|
"aria-required": required || null,
|
|
199
175
|
disabled: disabled,
|
|
200
176
|
type: type,
|
|
@@ -215,7 +191,6 @@ _defineProperty(StatelessCheckbox, "defaultProps", {
|
|
|
215
191
|
autoFocus: false,
|
|
216
192
|
isIndeterminate: false,
|
|
217
193
|
inputRef: /*#__PURE__*/React.createRef(),
|
|
218
|
-
isError: false,
|
|
219
194
|
error: false,
|
|
220
195
|
type: 'checkbox',
|
|
221
196
|
checkmarkType: STYLE_TYPE.default,
|
package/es/checkbox/constants.js
CHANGED
|
@@ -12,7 +12,8 @@ export const STATE_TYPE = {
|
|
|
12
12
|
export const STYLE_TYPE = Object.freeze({
|
|
13
13
|
default: 'default',
|
|
14
14
|
toggle: 'toggle',
|
|
15
|
-
|
|
15
|
+
// maintaining key with aliased value to assist in transition to v11 but will be removed soon after release
|
|
16
|
+
toggle_round: 'toggle'
|
|
16
17
|
});
|
|
17
18
|
export const LABEL_PLACEMENT = Object.freeze({
|
|
18
19
|
top: 'top',
|