draft-components 0.61.0 → 0.63.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/components/calendar/calendar-day.d.ts +2 -1
- package/components/calendar/calendar-day.js +2 -2
- package/components/calendar/calendar.d.ts +4 -2
- package/components/calendar/calendar.js +6 -2
- package/components/date-picker/date-picker.d.ts +3 -1
- package/components/date-picker/date-picker.js +6 -3
- package/components/date-picker-popover/date-picker-popover.d.ts +18 -0
- package/components/date-picker-popover/date-picker-popover.js +35 -0
- package/components/date-picker-popover/index.d.ts +1 -0
- package/components/date-picker-popover/index.js +13 -0
- package/components/date-preset-picker-popover/date-preset-picker-popover.js +2 -1
- package/components/date-range-picker/date-range-picker.js +2 -2
- package/components/datetime-input/date-components.js +7 -12
- package/components/datetime-input/datetime-input.js +1 -1
- package/components/dialog/dialog.js +2 -1
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/inline-message/inline-message.js +2 -1
- package/components/number-input/number-input.js +2 -1
- package/components/slider/slider.d.ts +6 -5
- package/components/slider/slider.js +26 -8
- package/components/table/table-cell.d.ts +4 -2
- package/components/table/table-cell.js +2 -2
- package/components/table/table-sort-button.js +2 -1
- package/components/tabs/tabs-state.js +2 -1
- package/components/toaster/toaster.js +1 -1
- package/css/draft-components.css +2 -2
- package/hooks/use-capture-focus.js +6 -4
- package/hooks/use-close-on-click-outside.js +3 -2
- package/hooks/use-close-on-esc-press.js +2 -1
- package/lib/plain-date-range.js +6 -8
- package/lib/plain-date.js +7 -8
- package/lib/stack.js +0 -1
- package/lib/util.js +1 -1
- package/package.json +1 -1
- package/scss/components/_actions-group.scss +5 -3
- package/scss/components/_alert.scss +34 -32
- package/scss/components/_avatar.scss +20 -18
- package/scss/components/_box.scss +49 -47
- package/scss/components/_breadcrumbs.scss +6 -4
- package/scss/components/_button.scss +20 -18
- package/scss/components/_calendar.scss +21 -11
- package/scss/components/_checkbox.scss +4 -2
- package/scss/components/_date-picker.scss +4 -2
- package/scss/components/_date-preset-picker-popover.scss +11 -9
- package/scss/components/_datetime-input.scss +11 -9
- package/scss/components/_dialog.scss +9 -7
- package/scss/components/_form-field.scss +4 -2
- package/scss/components/_formatted-content.scss +23 -21
- package/scss/components/_inline-message.scss +3 -1
- package/scss/components/_input.scss +11 -9
- package/scss/components/_label.scss +5 -2
- package/scss/components/_loading-view.scss +20 -18
- package/scss/components/_non-ideal-state-view.scss +27 -25
- package/scss/components/_number-input.scss +4 -2
- package/scss/components/_radio-button.scss +4 -2
- package/scss/components/_radio-group.scss +17 -14
- package/scss/components/_scope-buttons.scss +4 -2
- package/scss/components/_secret.scss +4 -2
- package/scss/components/_segmented-control.scss +7 -5
- package/scss/components/_select.scss +9 -7
- package/scss/components/_selection-control.scss +11 -9
- package/scss/components/_slider.scss +88 -98
- package/scss/components/_switch.scss +5 -3
- package/scss/components/_table.scss +19 -16
- package/scss/components/_tabs.scss +13 -12
- package/scss/components/_tag.scss +37 -35
- package/scss/components/_text-input.scss +3 -1
- package/scss/components/_toast.scss +25 -23
- package/scss/components/_toaster.scss +8 -6
- package/scss/components/_tooltip.scss +6 -4
- package/scss/components/_vertical-navigation.scss +16 -14
- package/scss/draft-components-utils.scss +0 -1
- package/scss/draft-components.scss +0 -1
- package/scss/themes/_default-theme.scss +162 -156
- package/scss/utils/_borders.scss +14 -12
- package/scss/utils/_gap.scss +14 -12
- package/scss/utils/_margin.scss +14 -12
- package/scss/utils/_padding.scss +14 -12
- package/scss/.DS_Store +0 -0
|
@@ -5,6 +5,7 @@ export interface CalendarDayProps {
|
|
|
5
5
|
isCurrent?: boolean;
|
|
6
6
|
isFocusable?: boolean;
|
|
7
7
|
isSelected?: boolean;
|
|
8
|
+
isDisabled?: boolean;
|
|
8
9
|
isInRange?: boolean;
|
|
9
10
|
isRangeStart?: boolean;
|
|
10
11
|
isRangeEnd?: boolean;
|
|
@@ -15,4 +16,4 @@ export interface CalendarDayProps {
|
|
|
15
16
|
onPick(day: PlainDate): void;
|
|
16
17
|
onHover?(day: PlainDate): void;
|
|
17
18
|
}
|
|
18
|
-
export declare function CalendarDay({ className, isCurrent, isFocusable, isSelected, isInRange, isRangeStart, isRangeEnd, isInRangePreview, isRangePreviewStart, isRangePreviewEnd, date, onPick, onHover, }: CalendarDayProps): JSX.Element;
|
|
19
|
+
export declare function CalendarDay({ className, isCurrent, isFocusable, isSelected, isDisabled, isInRange, isRangeStart, isRangeEnd, isInRangePreview, isRangePreviewStart, isRangePreviewEnd, date, onPick, onHover, }: CalendarDayProps): JSX.Element;
|
|
@@ -4,7 +4,7 @@ exports.CalendarDay = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const guards_1 = require("../../lib/guards");
|
|
6
6
|
const react_helpers_1 = require("../../lib/react-helpers");
|
|
7
|
-
function CalendarDay({ className, isCurrent, isFocusable, isSelected, isInRange, isRangeStart, isRangeEnd, isInRangePreview, isRangePreviewStart, isRangePreviewEnd, date, onPick, onHover, }) {
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, react_helpers_1.classNames)(className, 'dc-calendar-day', isCurrent && 'dc-calendar-day_current', isSelected && 'dc-calendar-day_selected', isInRange && 'dc-calendar-day_in-range', isRangeStart && 'dc-calendar-day_range-start', isRangeEnd && 'dc-calendar-day_range-end', isInRangePreview && 'dc-calendar-day_in-range-preview', isRangePreviewStart && 'dc-calendar-day_range-preview-start', isRangePreviewEnd && 'dc-calendar-day_range-preview-end'), role: "gridcell" }, { children: (0, jsx_runtime_1.jsx)("button", Object.assign({ className: "dc-calendar-day__btn", tabIndex: isFocusable ? 0 : -1, "aria-selected": isSelected, onClick: () => onPick(date), onMouseEnter: () => (0, guards_1.isFunction)(onHover) && onHover(date) }, { children: date.day }), void 0) }), void 0));
|
|
7
|
+
function CalendarDay({ className, isCurrent, isFocusable, isSelected, isDisabled, isInRange, isRangeStart, isRangeEnd, isInRangePreview, isRangePreviewStart, isRangePreviewEnd, date, onPick, onHover, }) {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, react_helpers_1.classNames)(className, 'dc-calendar-day', isCurrent && 'dc-calendar-day_current', isSelected && 'dc-calendar-day_selected', isDisabled && 'dc-calendar-day_disabled', isInRange && 'dc-calendar-day_in-range', isRangeStart && 'dc-calendar-day_range-start', isRangeEnd && 'dc-calendar-day_range-end', isInRangePreview && 'dc-calendar-day_in-range-preview', isRangePreviewStart && 'dc-calendar-day_range-preview-start', isRangePreviewEnd && 'dc-calendar-day_range-preview-end'), role: "gridcell" }, { children: (0, jsx_runtime_1.jsx)("button", Object.assign({ className: "dc-calendar-day__btn", tabIndex: isFocusable ? 0 : -1, "aria-selected": isSelected, disabled: isDisabled, onClick: () => onPick(date), onMouseEnter: () => (0, guards_1.isFunction)(onHover) && onHover(date) }, { children: date.day }), void 0) }), void 0));
|
|
9
9
|
}
|
|
10
10
|
exports.CalendarDay = CalendarDay;
|
|
@@ -7,8 +7,10 @@ export interface CalendarProps {
|
|
|
7
7
|
nextMonthButtonLabel?: string;
|
|
8
8
|
prevYearButtonLabel?: string;
|
|
9
9
|
prevMonthButtonLabel?: string;
|
|
10
|
-
|
|
10
|
+
minDate?: PlainDate | null;
|
|
11
|
+
maxDate?: PlainDate | null;
|
|
11
12
|
focusDate: PlainDate;
|
|
13
|
+
children: ReactNode[];
|
|
12
14
|
onChangeFocusDate(focusDate: PlainDate): void;
|
|
13
15
|
}
|
|
14
|
-
export declare function Calendar({ className, locale, nextYearButtonLabel, nextMonthButtonLabel, prevYearButtonLabel, prevMonthButtonLabel,
|
|
16
|
+
export declare function Calendar({ className, locale, nextYearButtonLabel, nextMonthButtonLabel, prevYearButtonLabel, prevMonthButtonLabel, minDate, maxDate, focusDate, children, onChangeFocusDate, }: CalendarProps): JSX.Element;
|
|
@@ -17,7 +17,7 @@ const daysOfWeek = [
|
|
|
17
17
|
new Date('2021-01-09'),
|
|
18
18
|
new Date('2021-01-10'), // Sunday
|
|
19
19
|
];
|
|
20
|
-
function Calendar({ className, locale, nextYearButtonLabel, nextMonthButtonLabel, prevYearButtonLabel, prevMonthButtonLabel,
|
|
20
|
+
function Calendar({ className, locale, nextYearButtonLabel, nextMonthButtonLabel, prevYearButtonLabel, prevMonthButtonLabel, minDate, maxDate, focusDate, children, onChangeFocusDate, }) {
|
|
21
21
|
const isFocused = (0, react_1.useRef)(false);
|
|
22
22
|
const gridRef = (0, react_1.useRef)(null);
|
|
23
23
|
const headerId = (0, react_1.useRef)('');
|
|
@@ -71,7 +71,11 @@ function Calendar({ className, locale, nextYearButtonLabel, nextMonthButtonLabel
|
|
|
71
71
|
}
|
|
72
72
|
if (newFocusDate) {
|
|
73
73
|
event.preventDefault();
|
|
74
|
-
|
|
74
|
+
const isNewFocusDateDisabled = (minDate != null && newFocusDate.isBefore(minDate)) ||
|
|
75
|
+
(maxDate != null && newFocusDate.isAfter(maxDate));
|
|
76
|
+
if (!isNewFocusDateDisabled) {
|
|
77
|
+
onChangeFocusDate(newFocusDate);
|
|
78
|
+
}
|
|
75
79
|
}
|
|
76
80
|
} }, { children: children }), void 0)] }), void 0));
|
|
77
81
|
}
|
|
@@ -7,7 +7,9 @@ export interface DatePickerProps {
|
|
|
7
7
|
prevYearButtonLabel?: string;
|
|
8
8
|
prevMonthButtonLabel?: string;
|
|
9
9
|
footer?: ReactNode;
|
|
10
|
+
min?: ISODate;
|
|
11
|
+
max?: ISODate;
|
|
10
12
|
value: ISODate | null;
|
|
11
13
|
onChangeValue(isoDate: ISODate): void;
|
|
12
14
|
}
|
|
13
|
-
export declare function DatePicker({ locale, nextYearButtonLabel, nextMonthButtonLabel, prevYearButtonLabel, prevMonthButtonLabel, footer, value, onChangeValue, }: DatePickerProps): JSX.Element;
|
|
15
|
+
export declare function DatePicker({ locale, nextYearButtonLabel, nextMonthButtonLabel, prevYearButtonLabel, prevMonthButtonLabel, footer, min, max, value, onChangeValue, }: DatePickerProps): JSX.Element;
|
|
@@ -7,9 +7,11 @@ const plain_date_1 = require("../../lib/plain-date");
|
|
|
7
7
|
const calendar_1 = require("../calendar/calendar");
|
|
8
8
|
const calendar_row_1 = require("../calendar/calendar-row");
|
|
9
9
|
const calendar_day_1 = require("../calendar/calendar-day");
|
|
10
|
-
function DatePicker({ locale, nextYearButtonLabel, nextMonthButtonLabel, prevYearButtonLabel, prevMonthButtonLabel, footer, value, onChangeValue, }) {
|
|
10
|
+
function DatePicker({ locale, nextYearButtonLabel, nextMonthButtonLabel, prevYearButtonLabel, prevMonthButtonLabel, footer, min, max, value, onChangeValue, }) {
|
|
11
11
|
const selectedDate = value ? plain_date_1.PlainDate.fromISODate(value) : null;
|
|
12
12
|
const currentDate = plain_date_1.PlainDate.now();
|
|
13
|
+
const minDate = min ? plain_date_1.PlainDate.fromISODate(min) : null;
|
|
14
|
+
const maxDate = max ? plain_date_1.PlainDate.fromISODate(max) : null;
|
|
13
15
|
const [focusDate, setFocusDate] = (0, react_1.useState)(selectedDate ? selectedDate : currentDate.startOfMonth);
|
|
14
16
|
const firstDate = focusDate.startOfMonth;
|
|
15
17
|
const lastDate = focusDate.endOfMonth;
|
|
@@ -35,7 +37,8 @@ function DatePicker({ locale, nextYearButtonLabel, nextMonthButtonLabel, prevYea
|
|
|
35
37
|
d = 0;
|
|
36
38
|
}
|
|
37
39
|
for (; d < plain_date_1.PlainDate.DAYS_IN_WEEK; d += 1) {
|
|
38
|
-
renderedDays.push((0, jsx_runtime_1.jsx)(calendar_day_1.CalendarDay, { date: date, isCurrent: date.equals(currentDate), isFocusable: date.equals(focusDate), isSelected: selectedDate ? date.equals(selectedDate) : false,
|
|
40
|
+
renderedDays.push((0, jsx_runtime_1.jsx)(calendar_day_1.CalendarDay, { date: date, isCurrent: date.equals(currentDate), isFocusable: date.equals(focusDate), isSelected: selectedDate ? date.equals(selectedDate) : false, isDisabled: (minDate != null && date.isBefore(minDate)) ||
|
|
41
|
+
(maxDate != null && date.isAfter(maxDate)), onPick: handleDayPick }, `day-${date.toISOString()}`));
|
|
39
42
|
date = date.addDays(1);
|
|
40
43
|
}
|
|
41
44
|
renderedWeeks.push((0, jsx_runtime_1.jsx)(calendar_row_1.CalendarRow, { children: renderedDays }, `week-${w}`));
|
|
@@ -47,6 +50,6 @@ function DatePicker({ locale, nextYearButtonLabel, nextMonthButtonLabel, prevYea
|
|
|
47
50
|
: focusDate);
|
|
48
51
|
}
|
|
49
52
|
}, [value]);
|
|
50
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "dc-date-picker" }, { children: [(0, jsx_runtime_1.jsx)(calendar_1.Calendar, Object.assign({ locale: locale, nextYearButtonLabel: nextYearButtonLabel, nextMonthButtonLabel: nextMonthButtonLabel, prevYearButtonLabel: prevYearButtonLabel, prevMonthButtonLabel: prevMonthButtonLabel, focusDate: focusDate, onChangeFocusDate: setFocusDate }, { children: renderedWeeks }), void 0), footer && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "dc-date-range-picker__footer" }, { children: footer }), void 0)] }), void 0));
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "dc-date-picker" }, { children: [(0, jsx_runtime_1.jsx)(calendar_1.Calendar, Object.assign({ locale: locale, nextYearButtonLabel: nextYearButtonLabel, nextMonthButtonLabel: nextMonthButtonLabel, prevYearButtonLabel: prevYearButtonLabel, prevMonthButtonLabel: prevMonthButtonLabel, minDate: minDate, maxDate: maxDate, focusDate: focusDate, onChangeFocusDate: setFocusDate }, { children: renderedWeeks }), void 0), footer && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "dc-date-range-picker__footer" }, { children: footer }), void 0)] }), void 0));
|
|
51
54
|
}
|
|
52
55
|
exports.DatePicker = DatePicker;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ISODate } from '../../lib/plain-date';
|
|
3
|
+
export declare type DatePickerPopoverProps = {
|
|
4
|
+
defaultIsOpen?: boolean;
|
|
5
|
+
locale?: string;
|
|
6
|
+
footer?: ReactNode;
|
|
7
|
+
min?: ISODate;
|
|
8
|
+
max?: ISODate;
|
|
9
|
+
value: ISODate | null;
|
|
10
|
+
onChangeValue(value: ISODate): void;
|
|
11
|
+
children(props: {
|
|
12
|
+
isOpen: boolean;
|
|
13
|
+
openPopover(): void;
|
|
14
|
+
closePopover(): void;
|
|
15
|
+
togglePopover(): void;
|
|
16
|
+
}): JSX.Element;
|
|
17
|
+
};
|
|
18
|
+
export declare function DatePickerPopover({ defaultIsOpen, locale, footer, min, max, value, onChangeValue, children, }: DatePickerPopoverProps): JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatePickerPopover = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const popover_1 = require("../popover");
|
|
7
|
+
const date_picker_1 = require("../date-picker");
|
|
8
|
+
function DatePickerPopover({ defaultIsOpen = false, locale, footer, min, max, value, onChangeValue, children, }) {
|
|
9
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(defaultIsOpen);
|
|
10
|
+
function openPopover() {
|
|
11
|
+
setIsOpen(true);
|
|
12
|
+
}
|
|
13
|
+
function closePopover() {
|
|
14
|
+
setIsOpen(false);
|
|
15
|
+
}
|
|
16
|
+
function togglePopover() {
|
|
17
|
+
if (isOpen) {
|
|
18
|
+
closePopover();
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
openPopover();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function handleChangeValue(value) {
|
|
25
|
+
onChangeValue(value);
|
|
26
|
+
closePopover();
|
|
27
|
+
}
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)(popover_1.Popover, Object.assign({ isShown: isOpen, onClose: closePopover, content: (0, jsx_runtime_1.jsx)(date_picker_1.DatePicker, { locale: locale, footer: footer, min: min, max: max, value: value, onChangeValue: handleChangeValue }, void 0) }, { children: children({
|
|
29
|
+
isOpen,
|
|
30
|
+
openPopover,
|
|
31
|
+
closePopover,
|
|
32
|
+
togglePopover,
|
|
33
|
+
}) }), void 0));
|
|
34
|
+
}
|
|
35
|
+
exports.DatePickerPopover = DatePickerPopover;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './date-picker-popover';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./date-picker-popover"), exports);
|
|
@@ -6,6 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const popover_1 = require("../popover");
|
|
7
7
|
const date_preset_picker_1 = require("./date-preset-picker");
|
|
8
8
|
exports.DatePresetPickerPopover = (0, react_1.forwardRef)(function DatePresetPickerPopover({ locale, timeZone, defaultIsOpen = false, hideSelectedRange = false, position = 'bottom', alignment = 'start', cancelButtonLabel, confirmButtonLabel, customDatePresetLabel, disableActionButtons, showLoadingIndicator, options, value, onChangeValue, children: render, }, ref) {
|
|
9
|
+
var _a;
|
|
9
10
|
const [isShown, setIsShown] = (0, react_1.useState)(defaultIsOpen);
|
|
10
11
|
const confirmButtonRef = (0, react_1.useRef)(null);
|
|
11
12
|
const [selectionState, setSelectionState] = (0, react_1.useState)(valueToSelectionState);
|
|
@@ -100,7 +101,7 @@ exports.DatePresetPickerPopover = (0, react_1.forwardRef)(function DatePresetPic
|
|
|
100
101
|
openPopover();
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
|
-
return ((0, jsx_runtime_1.jsx)(popover_1.Popover, Object.assign({ ref: ref, className: "dc-date-preset-picker-popover", isShown: isShown, position: position, alignment: alignment, content: (0, jsx_runtime_1.jsx)(date_preset_picker_1.DatePresetPicker, { confirmButtonRef: confirmButtonRef, locale: locale, formattedDateRange: hideSelectedRange ? null : formattedDateRange, formattedTimeZone: formattedTimeZone, cancelButtonLabel: cancelButtonLabel, confirmButtonLabel: confirmButtonLabel, customDatePresetLabel: customDatePresetLabel, disableActionButtons: disableActionButtons, showLoadingIndicator: showLoadingIndicator, options: options, datePreset: selectionState.option
|
|
104
|
+
return ((0, jsx_runtime_1.jsx)(popover_1.Popover, Object.assign({ ref: ref, className: "dc-date-preset-picker-popover", isShown: isShown, position: position, alignment: alignment, content: (0, jsx_runtime_1.jsx)(date_preset_picker_1.DatePresetPicker, { confirmButtonRef: confirmButtonRef, locale: locale, formattedDateRange: hideSelectedRange ? null : formattedDateRange, formattedTimeZone: formattedTimeZone, cancelButtonLabel: cancelButtonLabel, confirmButtonLabel: confirmButtonLabel, customDatePresetLabel: customDatePresetLabel, disableActionButtons: disableActionButtons, showLoadingIndicator: showLoadingIndicator, options: options, datePreset: ((_a = selectionState.option) === null || _a === void 0 ? void 0 : _a.datePreset) || '', dateRange: selectionState.dateRange, onChangeDatePreset: handleChangeDatePreset, onChangeDateRange: handleChangeDateRange, onCancel: closePopover, onConfirm: handleConfirm }, void 0), focusElementRefAfterOpen: confirmButtonRef, onClose: closePopover }, { children: render({
|
|
104
105
|
isShown,
|
|
105
106
|
openPopover,
|
|
106
107
|
closePopover,
|
|
@@ -87,12 +87,12 @@ function DateRangePicker({ locale, nextYearButtonLabel, nextMonthButtonLabel, pr
|
|
|
87
87
|
renderedWeeks.push((0, jsx_runtime_1.jsx)(calendar_row_1.CalendarRow, { children: renderedDays }, `week-${w}`));
|
|
88
88
|
}
|
|
89
89
|
(0, react_1.useEffect)(() => {
|
|
90
|
-
if (value
|
|
90
|
+
if (value === null || value === void 0 ? void 0 : value.start) {
|
|
91
91
|
setFocusDate((focusDate) => focusDate.toISOString() !== value.start
|
|
92
92
|
? plain_date_1.PlainDate.fromISODate(value.start)
|
|
93
93
|
: focusDate);
|
|
94
94
|
}
|
|
95
|
-
}, [value
|
|
95
|
+
}, [value === null || value === void 0 ? void 0 : value.start]);
|
|
96
96
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "dc-date-picker" }, { children: [(0, jsx_runtime_1.jsx)(calendar_1.Calendar, Object.assign({ locale: locale, nextYearButtonLabel: nextYearButtonLabel, nextMonthButtonLabel: nextMonthButtonLabel, prevYearButtonLabel: prevYearButtonLabel, prevMonthButtonLabel: prevMonthButtonLabel, focusDate: focusDate, onChangeFocusDate: (focusDate) => {
|
|
97
97
|
setFocusDate(focusDate);
|
|
98
98
|
if (start) {
|
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DateComponents = void 0;
|
|
4
4
|
class DateComponents {
|
|
5
|
-
year;
|
|
6
|
-
month;
|
|
7
|
-
day;
|
|
8
|
-
hour;
|
|
9
|
-
minute;
|
|
10
5
|
constructor(values) {
|
|
11
6
|
if (values) {
|
|
12
7
|
for (const [key, value] of Object.entries(values)) {
|
|
@@ -14,13 +9,6 @@ class DateComponents {
|
|
|
14
9
|
}
|
|
15
10
|
}
|
|
16
11
|
}
|
|
17
|
-
static options = {
|
|
18
|
-
year: { min: 1, max: 9999, digits: 4 },
|
|
19
|
-
month: { min: 1, max: 12, digits: 2 },
|
|
20
|
-
day: { min: 1, max: 31, digits: 2 },
|
|
21
|
-
hour: { min: 0, max: 23, digits: 2 },
|
|
22
|
-
minute: { min: 0, max: 59, digits: 2 },
|
|
23
|
-
};
|
|
24
12
|
static makeFormDatetimeISO(dateString) {
|
|
25
13
|
const dateTimeRegex = /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}$/;
|
|
26
14
|
const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -106,3 +94,10 @@ class DateComponents {
|
|
|
106
94
|
}
|
|
107
95
|
}
|
|
108
96
|
exports.DateComponents = DateComponents;
|
|
97
|
+
DateComponents.options = {
|
|
98
|
+
year: { min: 1, max: 9999, digits: 4 },
|
|
99
|
+
month: { min: 1, max: 12, digits: 2 },
|
|
100
|
+
day: { min: 1, max: 31, digits: 2 },
|
|
101
|
+
hour: { min: 0, max: 23, digits: 2 },
|
|
102
|
+
minute: { min: 0, max: 59, digits: 2 },
|
|
103
|
+
};
|
|
@@ -137,7 +137,7 @@ exports.DatetimeInput = (0, react_1.forwardRef)(function DatetimeInput({ size =
|
|
|
137
137
|
if (index) {
|
|
138
138
|
children.push((0, jsx_runtime_1.jsx)("span", Object.assign({ className: "dc-datetime-input__separator" }, { children: separator }), `separator-${index}`));
|
|
139
139
|
}
|
|
140
|
-
children.push((0, jsx_runtime_1.jsx)(date_component_input_1.DateComponentInput, { id: ids
|
|
140
|
+
children.push((0, jsx_runtime_1.jsx)(date_component_input_1.DateComponentInput, { id: ids === null || ids === void 0 ? void 0 : ids[dateComponent], label: (ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels[dateComponent]) || dateComponent, placeholder: placeholders === null || placeholders === void 0 ? void 0 : placeholders[dateComponent], disabled: disabled, readOnly: readOnly, name: dateComponent, value: dateComponents.getDisplayedValue(dateComponent), onChange: handleChange }, dateComponent));
|
|
141
141
|
});
|
|
142
142
|
return (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "dc-datetime-input__group" }, { children: children }), void 0);
|
|
143
143
|
}
|
|
@@ -36,7 +36,8 @@ function Dialog({ style, className, isOpen, onClose = util_1.noop, shouldShowClo
|
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
38
|
return ((0, jsx_runtime_1.jsx)(portal_1.Portal, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ "data-testid": "dialog-container", className: "dc-dialog-container", onClick: (event) => {
|
|
39
|
-
|
|
39
|
+
var _a;
|
|
40
|
+
if (!((_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))) {
|
|
40
41
|
onClose();
|
|
41
42
|
}
|
|
42
43
|
} }, { children: [(0, jsx_runtime_1.jsx)("div", { tabIndex: 0 }, void 0), (0, jsx_runtime_1.jsxs)(box_1.Box, Object.assign({}, props, { ref: dialogRef, style: { ...style, width: widthInPx }, className: (0, react_helpers_1.classNames)(className, 'dc-dialog'), borderRadius: "lg", padding: "none", elevation: "lg", role: "dialog", "aria-modal": true }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "dc-dialog__header" }, { children: [(heading || description) && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "dc-dialog__header-content" }, { children: [heading && (0, jsx_runtime_1.jsx)(formatted_content_1.Headline, Object.assign({ as: "h2" }, { children: heading }), void 0), description && ((0, jsx_runtime_1.jsx)(formatted_content_1.Subheadline, Object.assign({ as: "div", className: "dc-dialog__description" }, { children: description }), void 0))] }), void 0)), shouldShowCloseButton && ((0, jsx_runtime_1.jsx)(button_1.Button, { "data-testid": "dialog-close-button", className: "dc-dialog__close-btn", appearance: "minimal", size: "sm", noPadding: true, leadingIcon: closeIcon, onClick: onClose }, void 0))] }), void 0), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "dc-dialog__content" }, { children: children }), void 0), actions && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "dc-dialog__actions" }, { children: actions }), void 0)] }), void 0), (0, jsx_runtime_1.jsx)("div", { tabIndex: 0 }, void 0)] }), void 0) }, void 0));
|
package/components/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './button';
|
|
|
7
7
|
export * from './buttons-group';
|
|
8
8
|
export * from './checkbox';
|
|
9
9
|
export * from './date-picker';
|
|
10
|
+
export * from './date-picker-popover';
|
|
10
11
|
export * from './date-preset-picker-popover';
|
|
11
12
|
export * from './date-range-picker';
|
|
12
13
|
export * from './datetime-input';
|
package/components/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./button"), exports);
|
|
|
19
19
|
__exportStar(require("./buttons-group"), exports);
|
|
20
20
|
__exportStar(require("./checkbox"), exports);
|
|
21
21
|
__exportStar(require("./date-picker"), exports);
|
|
22
|
+
__exportStar(require("./date-picker-popover"), exports);
|
|
22
23
|
__exportStar(require("./date-preset-picker-popover"), exports);
|
|
23
24
|
__exportStar(require("./date-range-picker"), exports);
|
|
24
25
|
__exportStar(require("./datetime-input"), exports);
|
|
@@ -17,6 +17,7 @@ const inlineMessageIcons = {
|
|
|
17
17
|
default: info_circle_fill_1.infoCircleFill,
|
|
18
18
|
};
|
|
19
19
|
function InlineMessage({ appearance = 'default', shouldShowIcon = false, className, children, ...props }) {
|
|
20
|
-
|
|
20
|
+
var _a;
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)(formatted_content_1.Footnote, Object.assign({}, props, { className: (0, react_helpers_1.classNames)(className, 'dc-inline-message', `dc-inline-message_${appearance}`) }, { children: [shouldShowIcon ? ((0, jsx_runtime_1.jsx)(svg_icon_1.SvgIcon, { className: "dc-inline-message__icon", "data-testid": "inline-message-icon", icon: (_a = inlineMessageIcons[appearance]) !== null && _a !== void 0 ? _a : inlineMessageIcons.default, width: 16, height: 16 }, void 0)) : null, children] }), void 0));
|
|
21
22
|
}
|
|
22
23
|
exports.InlineMessage = InlineMessage;
|
|
@@ -80,7 +80,8 @@ exports.NumberInput = (0, react_1.forwardRef)(function NumberInput({ style, clas
|
|
|
80
80
|
}) }, { children: [(0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ appearance: "secondary", size: size, noPadding: true, disabled: disabled, onClick: () => !readOnly && decrement(step) }, { children: decrementButtonLabel }), void 0), (0, jsx_runtime_1.jsx)(text_input_1.TextInput, Object.assign({}, props, { ref: ref, className: "dc-number-input__text-input", size: size, disabled: disabled, readOnly: readOnly, fullWidth: fullWidth, type: "text", value: value, onKeyDown: handleKeyDown, onChangeValue: handleChangeValue }), void 0), (0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ appearance: "secondary", size: size, noPadding: true, disabled: disabled, onClick: () => !readOnly && increment(step) }, { children: incrementButtonLabel }), void 0)] }), void 0));
|
|
81
81
|
});
|
|
82
82
|
function getFractionDigits(n) {
|
|
83
|
-
|
|
83
|
+
var _a;
|
|
84
|
+
const fraction = (_a = String(n).split(/[.,]/)[1]) !== null && _a !== void 0 ? _a : '';
|
|
84
85
|
return fraction.length;
|
|
85
86
|
}
|
|
86
87
|
function formatFloat(n, fractionDigits) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef } from 'react';
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
2
|
export interface SliderProps extends ComponentPropsWithoutRef<'input'> {
|
|
3
|
+
thumb?: 'round' | 'rect';
|
|
4
|
+
numberOfTickMarks?: number;
|
|
5
|
+
step?: number;
|
|
3
6
|
min?: number;
|
|
4
7
|
max?: number;
|
|
5
|
-
step?: number;
|
|
6
|
-
thumbStyle?: 'round' | 'rect';
|
|
7
|
-
tickMarksCount?: number;
|
|
8
8
|
value: number;
|
|
9
|
+
renderTickMarkLabel?(at: number): ReactNode;
|
|
9
10
|
onChangeValue(value: number): void;
|
|
10
11
|
}
|
|
11
|
-
export declare function Slider({ style, className, disabled, readOnly,
|
|
12
|
+
export declare function Slider({ style, className, disabled, readOnly, thumb, numberOfTickMarks, step, min, max, value, renderTickMarkLabel, onChangeValue, ...props }: SliderProps): JSX.Element;
|
|
@@ -3,14 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Slider = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const guards_1 = require("../../lib/guards");
|
|
6
7
|
const react_helpers_1 = require("../../lib/react-helpers");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const util_1 = require("../../lib/util");
|
|
9
|
+
function Slider({ style, className, disabled, readOnly, thumb = 'round', numberOfTickMarks = 0, step = 1, min = 0, max = 100, value = 0, renderTickMarkLabel, onChangeValue, ...props }) {
|
|
10
|
+
var _a;
|
|
11
|
+
const id = (0, react_1.useRef)(props.id);
|
|
12
|
+
if (!id.current) {
|
|
13
|
+
id.current = (0, util_1.uniqueId)('slider_');
|
|
14
|
+
}
|
|
15
|
+
const handleChange = (0, react_1.useCallback)((event) => onChangeValue(Number(event.target.value)), [onChangeValue]);
|
|
16
|
+
const valuePercent = `${((value - min) / (max - min)) * 100}%`;
|
|
17
|
+
const background = `linear-gradient(
|
|
18
|
+
to right,
|
|
19
|
+
var(--dc-slider-fill-track-bg) 0%,
|
|
20
|
+
var(--dc-slider-fill-track-bg) ${valuePercent},
|
|
21
|
+
var(--dc-slider-track-bg) ${valuePercent},
|
|
22
|
+
var(--dc-slider-track-bg) ${valuePercent}
|
|
23
|
+
)`;
|
|
24
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ style: style, className: (0, react_helpers_1.classNames)('dc-slider', thumb && `dc-slider_thumb_${thumb}`, disabled && 'dc-slider_disabled', className) }, { children: [(0, jsx_runtime_1.jsx)("input", Object.assign({}, props, { id: (_a = id.current) !== null && _a !== void 0 ? _a : (0, util_1.uniqueId)('slider_'), style: { background }, className: "dc-slider__input", type: "range", min: min, max: max, step: step, value: value, disabled: disabled, readOnly: readOnly, onChange: handleChange }), void 0), (0, jsx_runtime_1.jsx)(SliderTickMarks, { numberOfTickMarks: numberOfTickMarks, renderTickMarkLabel: renderTickMarkLabel }, void 0)] }), void 0));
|
|
15
25
|
}
|
|
16
26
|
exports.Slider = Slider;
|
|
27
|
+
function SliderTickMarks(props) {
|
|
28
|
+
const { numberOfTickMarks, renderTickMarkLabel } = props;
|
|
29
|
+
const withLabel = (0, guards_1.isFunction)(renderTickMarkLabel);
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "dc-slider__tick-marks" }, { children: Array.from({ length: numberOfTickMarks }).map((_, index) => {
|
|
31
|
+
const label = withLabel && renderTickMarkLabel(index);
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "dc-slider-tick-mark" }, { children: label && ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: "dc-slider-tick-mark__label" }, { children: label }), void 0)) }), index));
|
|
33
|
+
}) }), void 0));
|
|
34
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
export declare type TableCellProps = ComponentPropsWithoutRef<'td'
|
|
3
|
-
|
|
2
|
+
export declare type TableCellProps = ComponentPropsWithoutRef<'td'> & {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function TableCell({ className, isLoading, align, children, ...props }: TableCellProps): JSX.Element;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TableCell = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_helpers_1 = require("../../lib/react-helpers");
|
|
6
|
-
function TableCell({ className, align = 'left', children, ...props }) {
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)("td", Object.assign({}, props, { align: align, className: (0, react_helpers_1.classNames)(
|
|
6
|
+
function TableCell({ className, isLoading = false, align = 'left', children, ...props }) {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)("td", Object.assign({}, props, { align: align, className: (0, react_helpers_1.classNames)('dc-table-cell', isLoading && 'dc-table-cell_loading', className) }, { children: children }), void 0));
|
|
8
8
|
}
|
|
9
9
|
exports.TableCell = TableCell;
|
|
@@ -40,7 +40,8 @@ const displayedOrders = {
|
|
|
40
40
|
desc: 'descending',
|
|
41
41
|
};
|
|
42
42
|
function TableSortButton({ column, order, onSort, renderLabel = renderDefaultLabel, className, ...props }) {
|
|
43
|
-
|
|
43
|
+
var _a;
|
|
44
|
+
const nextOrder = (_a = orderSequence[order]) !== null && _a !== void 0 ? _a : 'asc';
|
|
44
45
|
return ((0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({}, props, { className: (0, react_helpers_1.classNames)(className, 'dc-table-sort-btn'), appearance: "minimal", noPadding: true, size: "xs", leadingIcon: (0, jsx_runtime_1.jsx)(svg_icon_1.SvgIcon, { icon: orderIcons[order], size: 14 }, void 0), onClick: () => {
|
|
45
46
|
(0, guards_1.isFunction)(onSort) && onSort(nextOrder);
|
|
46
47
|
} }, { children: renderLabel(column, nextOrder) }), void 0));
|
|
@@ -32,8 +32,9 @@ function TabsStateProvider({ children, selectedTabKey, onSelectTab, }) {
|
|
|
32
32
|
setFocusedTabKey(tabKey);
|
|
33
33
|
}
|
|
34
34
|
function focusTab(tabKey) {
|
|
35
|
+
var _a;
|
|
35
36
|
setFocusedTabKey(tabKey);
|
|
36
|
-
document.getElementById(getTabId(tabKey))
|
|
37
|
+
(_a = document.getElementById(getTabId(tabKey))) === null || _a === void 0 ? void 0 : _a.focus();
|
|
37
38
|
}
|
|
38
39
|
return {
|
|
39
40
|
tabsOrder,
|
|
@@ -15,7 +15,7 @@ function Toaster({ className, position = 'top-center', toastGap = 16, ...props }
|
|
|
15
15
|
if (!listElement) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
const toastAppearsOnBottom = position
|
|
18
|
+
const toastAppearsOnBottom = position === null || position === void 0 ? void 0 : position.startsWith('bottom');
|
|
19
19
|
const items = listElement.children;
|
|
20
20
|
let offset = 0;
|
|
21
21
|
for (let i = 0; i < items.length; i += 1) {
|