@moneyforward/mfui-components 3.28.0 → 3.29.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/dist/src/Accordion/Accordion.js +1 -1
- package/dist/src/Button/Button.js +1 -1
- package/dist/src/CheckboxGroup/CheckboxGroup.js +1 -1
- package/dist/src/DataTable/DataTableCell/DataTableCell.js +3 -3
- package/dist/src/DataTable/DataTableCell/DataTableCell.types.d.ts +8 -0
- package/dist/src/DataTable/DataTableRow/DataTableRow.js +7 -1
- package/dist/src/DateTimeSelection/FilterDatePicker/CalendarPopover/CalendarPopover.d.ts +1 -1
- package/dist/src/DateTimeSelection/FilterDatePicker/CalendarPopover/CalendarPopover.js +2 -2
- package/dist/src/DateTimeSelection/FilterDatePicker/CalendarPopover/CalendarPopover.types.d.ts +1 -0
- package/dist/src/DateTimeSelection/FilterDatePicker/FilterDatePicker.d.ts +1 -1
- package/dist/src/DateTimeSelection/FilterDatePicker/FilterDatePicker.js +2 -2
- package/dist/src/DateTimeSelection/FilterDatePicker/FilterDatePicker.types.d.ts +7 -1
- package/dist/src/DateTimeSelection/FilterDateRangePicker/DateRangePickerContent/DateRangePickerContent.d.ts +1 -1
- package/dist/src/DateTimeSelection/FilterDateRangePicker/DateRangePickerContent/DateRangePickerContent.js +2 -2
- package/dist/src/DateTimeSelection/FilterDateRangePicker/DateRangePickerContent/DateRangePickerContent.types.d.ts +1 -0
- package/dist/src/DateTimeSelection/FilterDateRangePicker/FilterDateRangePicker.d.ts +1 -1
- package/dist/src/DateTimeSelection/FilterDateRangePicker/FilterDateRangePicker.js +2 -2
- package/dist/src/DateTimeSelection/FilterDateRangePicker/FilterDateRangePicker.types.d.ts +7 -1
- package/dist/src/DateTimeSelection/FilterMonthPicker/FilterMonthPicker.d.ts +1 -1
- package/dist/src/DateTimeSelection/FilterMonthPicker/FilterMonthPicker.js +2 -2
- package/dist/src/DateTimeSelection/FilterMonthPicker/FilterMonthPicker.types.d.ts +7 -1
- package/dist/src/DateTimeSelection/FilterMonthPicker/MonthPickerPopover/MonthPickerPopover.d.ts +1 -1
- package/dist/src/DateTimeSelection/FilterMonthPicker/MonthPickerPopover/MonthPickerPopover.js +2 -2
- package/dist/src/DateTimeSelection/FilterMonthPicker/MonthPickerPopover/MonthPickerPopover.types.d.ts +1 -0
- package/dist/src/DateTimeSelection/FilterMonthRangePicker/FilterMonthRangePicker.d.ts +1 -1
- package/dist/src/DateTimeSelection/FilterMonthRangePicker/FilterMonthRangePicker.js +2 -2
- package/dist/src/DateTimeSelection/FilterMonthRangePicker/FilterMonthRangePicker.types.d.ts +7 -1
- package/dist/src/DateTimeSelection/FilterMonthRangePicker/MonthRangePickerPopover/MonthRangePickerPopover.d.ts +1 -1
- package/dist/src/DateTimeSelection/FilterMonthRangePicker/MonthRangePickerPopover/MonthRangePickerPopover.js +2 -2
- package/dist/src/DateTimeSelection/FilterMonthRangePicker/MonthRangePickerPopover/MonthRangePickerPopover.types.d.ts +1 -0
- package/dist/src/DateTimeSelection/MonthRangePicker/MonthRangePickerMonthCell/MonthRangePickerMonthCell.js +1 -1
- package/dist/src/DateTimeSelection/TimePicker/TimePicker.d.ts +2 -0
- package/dist/src/DateTimeSelection/TimePicker/TimePicker.js +2 -2
- package/dist/src/DateTimeSelection/TimePicker/TimePicker.types.d.ts +6 -0
- package/dist/src/DateTimeSelection/shared/BaseRangePicker/BaseRangePickerPopover/BaseRangePickerCalendar/BaseRangePickerDateCell.js +1 -1
- package/dist/src/DateTimeSelection/shared/DayCell/DayCell.js +2 -2
- package/dist/src/DateTimeSelection/shared/accessibility/getDateAriaAttributes.d.ts +0 -1
- package/dist/src/DateTimeSelection/shared/accessibility/getDateAriaAttributes.js +0 -1
- package/dist/src/Dialog/Dialog.d.ts +3 -1
- package/dist/src/Dialog/Dialog.js +8 -4
- package/dist/src/Dialog/hooks/useDialogStateController.d.ts +5 -1
- package/dist/src/Dialog/hooks/useDialogStateController.js +7 -4
- package/dist/src/Disclosure/Disclosure.js +1 -1
- package/dist/src/FilterTrigger/FilterTrigger.js +1 -1
- package/dist/src/IconButton/IconButton.types.d.ts +6 -2
- package/dist/src/MainNavigation/BaseMainNavigation.js +4 -4
- package/dist/src/MainNavigation/NarrowViewportMainNavigation.js +2 -2
- package/dist/src/MultipleSelectBox/MultipleSelectBox.js +5 -4
- package/dist/src/MultipleSelectBox/MultipleSelectBox.types.d.ts +13 -2
- package/dist/src/MultipleSelectBox/MultipleSelectBoxTrigger/MultipleSelectBoxTrigger.js +1 -1
- package/dist/src/Pagination/PagePicker/PagePicker.js +2 -2
- package/dist/src/SearchBox/SearchBox.d.ts +3 -0
- package/dist/src/SearchBox/SearchBox.js +4 -1
- package/dist/src/SelectBox/SelectBox.js +9 -6
- package/dist/src/SelectBox/SelectBox.types.d.ts +13 -2
- package/dist/src/Sidebar/Sidebar.d.ts +1 -1
- package/dist/src/Sidebar/Sidebar.js +3 -3
- package/dist/src/Sidebar/Sidebar.types.d.ts +2 -2
- package/dist/src/Sidebar/SidebarServiceMenu.d.ts +3 -4
- package/dist/src/Sidebar/SidebarServiceMenu.js +5 -12
- package/dist/src/SubNavigation/SubNavigation.js +2 -2
- package/dist/styled-system/recipes/day-cell-slot-recipe.d.ts +1 -1
- package/dist/styled-system/recipes/day-cell-slot-recipe.js +4 -0
- package/dist/styled-system/tokens/index.js +60 -0
- package/dist/styled-system/tokens/tokens.d.ts +2 -2
- package/dist/styled-system/types/prop-type.d.ts +1 -1
- package/dist/styles.css +31 -54
- package/dist/theme-orange.css +18 -3
- package/package.json +3 -3
|
@@ -63,7 +63,7 @@ const AccordionTrigger = forwardRef(({ children, className, onClick, ...props },
|
|
|
63
63
|
toggle();
|
|
64
64
|
onClick?.(event);
|
|
65
65
|
}, [onClick, toggle]);
|
|
66
|
-
return (_jsx(FocusIndicator, { children: _jsxs("button", { ref: ref, className: cx(classes.trigger, 'mfui-Accordion__trigger', className), "aria-expanded": isOpen, "aria-controls": id, onClick: handleClick, ...props, children: [_jsx(Typography, { variant: "controlLabel", children: children }), isOpen ? _jsx(DisclosureBasicExpanded, { "aria-hidden": "true" }) : _jsx(DisclosureBasicCollapsed, { "aria-hidden": "true" })] }) }));
|
|
66
|
+
return (_jsx(FocusIndicator, { children: _jsxs("button", { ref: ref, className: cx(classes.trigger, 'mfui-Accordion__trigger', className), "aria-expanded": isOpen, "aria-controls": id, type: "button", onClick: handleClick, ...props, children: [_jsx(Typography, { variant: "controlLabel", children: children }), isOpen ? _jsx(DisclosureBasicExpanded, { "aria-hidden": "true" }) : _jsx(DisclosureBasicCollapsed, { "aria-hidden": "true" })] }) }));
|
|
67
67
|
});
|
|
68
68
|
const AccordionTarget = forwardRef(({ children, className, style, ...props }, ref) => {
|
|
69
69
|
const { size } = useAccordionContext();
|
|
@@ -50,5 +50,5 @@ type = 'button', href, customLinkComponent, ...props }, ref) => {
|
|
|
50
50
|
...props,
|
|
51
51
|
};
|
|
52
52
|
}, [isButton, classes.root, className, href, isDisabled, type, props, ref]);
|
|
53
|
-
return (_jsx(FocusIndicator, { children: _jsxs(Tag, { ...tagProps, children: [leftIcon ? _jsx("div", { className: cx(classes.leftIcon, 'mfui-Button__leftIcon'), children: leftIcon }) : null, loading ? (_jsx(ProgressIndicator, { className: cx(classes.loadingIndicator, 'mfui-Button__loadingIndicator') })) : null, typeof children === 'string' ? _jsx(Typography, { variant: typographyVariant, children: children }) : children, rightIcon ? _jsx("div", { className: cx(classes.rightIcon, 'mfui-Button__rightIcon'), children: rightIcon }) : null, isDropdownTrigger ? _jsx(Dropdown, { className: cx(classes.dropdownIcon, 'mfui-Button__dropdownIcon') }) : null] }) }));
|
|
53
|
+
return (_jsx(FocusIndicator, { children: _jsxs(Tag, { ...tagProps, children: [leftIcon ? _jsx("div", { className: cx(classes.leftIcon, 'mfui-Button__leftIcon'), children: leftIcon }) : null, loading ? (_jsx(ProgressIndicator, { className: cx(classes.loadingIndicator, 'mfui-Button__loadingIndicator') })) : null, typeof children === 'string' ? _jsx(Typography, { variant: typographyVariant, children: children }) : children, rightIcon ? _jsx("div", { className: cx(classes.rightIcon, 'mfui-Button__rightIcon'), children: rightIcon }) : null, isDropdownTrigger ? (_jsx(Dropdown, { "aria-hidden": "true", className: cx(classes.dropdownIcon, 'mfui-Button__dropdownIcon') })) : null] }) }));
|
|
54
54
|
});
|
|
@@ -41,5 +41,5 @@ export const CheckboxGroup = forwardRef(({ className, defaultValues, values, dis
|
|
|
41
41
|
values: values ?? localValues,
|
|
42
42
|
onChange: handleOnChange,
|
|
43
43
|
}), [disabled, handleOnChange, localValues, name, values]);
|
|
44
|
-
return (_jsx("div", { ref: ref, ...props, className: cx(classes.root, 'mfui-CheckboxGroup__root', className), children: _jsx(CheckboxGroupContext.Provider, { value: contextValue, children: children }) }));
|
|
44
|
+
return (_jsx("div", { ref: ref, ...props, className: cx(classes.root, 'mfui-CheckboxGroup__root', className), role: "group", children: _jsx(CheckboxGroupContext.Provider, { value: contextValue, children: children }) }));
|
|
45
45
|
});
|
|
@@ -38,7 +38,7 @@ export const DataTableCell = forwardRef(({ onClickCell, children, type = 'text',
|
|
|
38
38
|
}
|
|
39
39
|
if (onClickCell) {
|
|
40
40
|
return (_jsx(FocusIndicator, { position: "inside", children: _jsx("button", { type: "button", className: cx(classes.interactiveCell, 'mfui-DataTableCell__interactiveCell',
|
|
41
|
-
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridCell__interactiveCell'), onClick: handleClick, children: _jsx(CellContent, { depth: depth, disclosureIconProps: nestingIconProps, classes: classes, children: children }) }) }));
|
|
41
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridCell__interactiveCell'), ...(nestingIconProps && { 'aria-expanded': nestingIconProps.isOpen ?? false }), onClick: handleClick, children: _jsx(CellContent, { depth: depth, disclosureIconProps: nestingIconProps, classes: classes, children: children }) }) }));
|
|
42
42
|
}
|
|
43
43
|
if (isCheckboxCell) {
|
|
44
44
|
return (_jsx(FocusIndicator, { position: "inside", children: _jsx("div", { className: cx(classes.defaultCell, 'mfui-DataTableCell__defaultCell',
|
|
@@ -64,9 +64,9 @@ function DisclosureIcon({ disclosureIconProps, classes, }) {
|
|
|
64
64
|
}
|
|
65
65
|
const disclosureIcon = (() => {
|
|
66
66
|
if (disclosureIconProps.type === 'basic') {
|
|
67
|
-
return disclosureIconProps.isOpen ? _jsx(DisclosureBasicExpanded, {}) : _jsx(DisclosureBasicCollapsed, {});
|
|
67
|
+
return disclosureIconProps.isOpen ? (_jsx(DisclosureBasicExpanded, { "aria-hidden": "true" })) : (_jsx(DisclosureBasicCollapsed, { "aria-hidden": "true" }));
|
|
68
68
|
}
|
|
69
|
-
return disclosureIconProps.isOpen ? _jsx(DisclosureNestedExpanded, {}) : _jsx(DisclosureNestedCollapsed, {});
|
|
69
|
+
return disclosureIconProps.isOpen ? (_jsx(DisclosureNestedExpanded, { "aria-hidden": "true" })) : (_jsx(DisclosureNestedCollapsed, { "aria-hidden": "true" }));
|
|
70
70
|
})();
|
|
71
71
|
return (_jsx("div", { className: cx(classes.disclosureIconWrapper, 'mfui-DataTableCell__disclosureIconWrapper',
|
|
72
72
|
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridCell__disclosureIconWrapper'), children: disclosureIcon }));
|
|
@@ -75,6 +75,14 @@ export type DataTableCellProps = {
|
|
|
75
75
|
* If provided, the dropdown icon is displayed in the cell.
|
|
76
76
|
* If not provided, the dropdown icon is not displayed.
|
|
77
77
|
*
|
|
78
|
+
* `aria-expanded` is set automatically based on `isOpen`:
|
|
79
|
+
* on the cell button when the cell is interactive (`onClickCell`),
|
|
80
|
+
* or on the row when the row is interactive (`onClickRow`).
|
|
81
|
+
*
|
|
82
|
+
* Note: the attribute on the cell button is fully derived from `isOpen`
|
|
83
|
+
* and cannot be overridden, while an `aria-expanded` passed to
|
|
84
|
+
* `DataTable.Row` takes precedence over the derived value.
|
|
85
|
+
*
|
|
78
86
|
* @default undefined
|
|
79
87
|
*/
|
|
80
88
|
disclosureIconProps?: {
|
|
@@ -17,6 +17,12 @@ export const DataTableRow = forwardRef(({ children, disabled = false, highlighte
|
|
|
17
17
|
interactive: isInteractive,
|
|
18
18
|
disabled,
|
|
19
19
|
});
|
|
20
|
+
// When the interactive row itself toggles a disclosure (a child cell shows the disclosure icon
|
|
21
|
+
// but does not handle the click by itself), expose the expanded state on the row.
|
|
22
|
+
const disclosureIconProps = Children.toArray(children)
|
|
23
|
+
.filter((child) => isValidElement(child) && isComponentOrWrapped(child, DataTableCell))
|
|
24
|
+
.find((cell) => cell.props.disclosureIconProps && !cell.props.onClickCell)?.props.disclosureIconProps;
|
|
25
|
+
const ariaExpanded = isInteractive && disclosureIconProps ? (disclosureIconProps.isOpen ?? false) : undefined;
|
|
20
26
|
const handleClickRow = (event) => {
|
|
21
27
|
if (!disabled) {
|
|
22
28
|
onClickRow?.(event);
|
|
@@ -28,7 +34,7 @@ export const DataTableRow = forwardRef(({ children, disabled = false, highlighte
|
|
|
28
34
|
}
|
|
29
35
|
};
|
|
30
36
|
return (_jsxs("tr", { ref: ref, className: cx(classes.root, 'mfui-DataTableRow__root',
|
|
31
|
-
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridRow__root', className), ...props,
|
|
37
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridRow__root', className), ...(ariaExpanded !== undefined && { 'aria-expanded': ariaExpanded }), ...props,
|
|
32
38
|
// When the row is clickable, the role should be 'button' in order to allow screen readers to understand the row is clickable.
|
|
33
39
|
role: isInteractive ? 'button' : 'row', tabIndex: isInteractive ? 0 : undefined, ...(disabled && { 'aria-disabled': disabled }), onClick: handleClickRow, onKeyDown: handleKeyDownRow, children: [isSelectable ? (_jsx(DataTableCell, { columnIndex: 0, isRowHighlighted: isRowHighlighted, disabled: disabled, children: _jsx(Checkbox, { checked: checkboxProps?.checked, "aria-label": checkboxProps?.['aria-label'] ?? '行を選択', disabled: disabled || checkboxProps?.disabled, onChange: checkboxProps?.onChange, onClick: checkboxProps?.onClick }) })) : null, Children.map(children, (child, index) => {
|
|
34
40
|
if (!isValidElement(child)) {
|
|
@@ -3,4 +3,4 @@ import { type InternalCalendarPopoverProps } from './CalendarPopover.types';
|
|
|
3
3
|
* Internal component that accesses BasePickerContext for viewing-month reset and focus trap.
|
|
4
4
|
* Must be rendered inside a BasePickerProvider.
|
|
5
5
|
*/
|
|
6
|
-
export declare function InternalCalendarPopover({ currentValue, defaultValue, isCalendarOpen, toggleCalendar, handleValueChange, handleClear, disabled, className, classes, formattedValue, hasValue, label, clearButtonProps, checkDisabledDate, minDate, maxDate, prevMonthIconButtonProps, nextMonthIconButtonProps, todayButtonProps, triggerRef, targetDOMNode, dialogId, }: InternalCalendarPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function InternalCalendarPopover({ currentValue, defaultValue, isCalendarOpen, toggleCalendar, handleValueChange, handleClear, disabled, className, classes, formattedValue, hasValue, enableClearButton, label, clearButtonProps, checkDisabledDate, minDate, maxDate, prevMonthIconButtonProps, nextMonthIconButtonProps, todayButtonProps, triggerRef, targetDOMNode, dialogId, }: InternalCalendarPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,7 +17,7 @@ const BASE_FORMAT = 'YYYY-MM-DD';
|
|
|
17
17
|
* Internal component that accesses BasePickerContext for viewing-month reset and focus trap.
|
|
18
18
|
* Must be rendered inside a BasePickerProvider.
|
|
19
19
|
*/
|
|
20
|
-
export function InternalCalendarPopover({ currentValue, defaultValue, isCalendarOpen, toggleCalendar, handleValueChange, handleClear, disabled, className, classes, formattedValue, hasValue, label, clearButtonProps, checkDisabledDate, minDate, maxDate, prevMonthIconButtonProps, nextMonthIconButtonProps, todayButtonProps, triggerRef, targetDOMNode, dialogId, }) {
|
|
20
|
+
export function InternalCalendarPopover({ currentValue, defaultValue, isCalendarOpen, toggleCalendar, handleValueChange, handleClear, disabled, className, classes, formattedValue, hasValue, enableClearButton, label, clearButtonProps, checkDisabledDate, minDate, maxDate, prevMonthIconButtonProps, nextMonthIconButtonProps, todayButtonProps, triggerRef, targetDOMNode, dialogId, }) {
|
|
21
21
|
const { setViewingValue, setPendingFocusDate } = useBasePickerContext();
|
|
22
22
|
const { handleOnKeyDown } = useFocusTrap({
|
|
23
23
|
onPressingTabOnNotFocusableElement: (event) => {
|
|
@@ -39,7 +39,7 @@ export function InternalCalendarPopover({ currentValue, defaultValue, isCalendar
|
|
|
39
39
|
setViewingValue(dayjs(dateToFocus).startOf('month').startOf('day').toDate());
|
|
40
40
|
setPendingFocusDate(formattedDate);
|
|
41
41
|
}, [currentValue, defaultValue, setViewingValue, setPendingFocusDate]);
|
|
42
|
-
return (_jsx(Popover, { open: isCalendarOpen, targetDOMNode: targetDOMNode, renderTrigger: ({ setTriggerRef, togglePopover, handleTriggerKeyDown, handleTriggerBlur }) => (_jsxs("div", { ref: setTriggerRef, "data-selected": hasValue, className: cx(classes.wrapper, 'mfui-FilterDatePicker__wrapper'), children: [_jsx(FocusIndicator, { children: _jsxs("button", { ref: triggerRef, type: "button", disabled: disabled, className: cx(classes.trigger, 'mfui-FilterDatePicker__trigger', className), "data-selected": hasValue, "data-mfui-has-clear-button": hasValue, "aria-controls": dialogId, "aria-expanded": isCalendarOpen, "aria-haspopup": "dialog", onClick: togglePopover, onKeyDown: handleTriggerKeyDown, onBlur: handleTriggerBlur, children: [_jsx("span", { className: cx(classes.content, 'mfui-FilterDatePicker__content'), "data-mfui-content": "filter-date-picker-display-value", children: hasValue ? (_jsxs(Typography, { variant: "strongBody", children: [_jsx("span", { "data-mfui-content": "filter-date-picker-label", children: `${label}:` }), _jsx("span", { "data-mfui-content": "filter-date-picker-value", children: formattedValue })] })) : (_jsx(Typography, { variant: "controlLabel", children: _jsx("span", { "data-mfui-content": "filter-date-picker-label", children: label }) })) }), _jsx("span", { className: cx(classes.calendarIcon, 'mfui-FilterDatePicker__calendarIcon'), children: _jsx(CalendarIcon, { "aria-hidden": true }) })] }) }), hasValue ? (_jsx("div", { className: cx(classes.clearButtonWrapper, 'mfui-FilterDatePicker__clearButtonWrapper'), children: _jsx(ClearButton, { "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', "data-mfui-content": "filter-date-picker-clear-button", disabled: disabled, onClick: handleClear }) })) : null] })), renderContent: () => (_jsx("div", { id: dialogId, role: "dialog", "aria-label": label, className: "mfui-FilterDatePicker__popoverWrapper", onKeyDown: handleOnKeyDown, children: _jsx(DatePickerPanel, { value: currentValue, checkDisabledDate: checkDisabledDate, minDate: minDate, maxDate: maxDate, prevMonthIconButtonProps: prevMonthIconButtonProps, nextMonthIconButtonProps: nextMonthIconButtonProps, todayButtonProps: todayButtonProps, onChange: (date) => {
|
|
42
|
+
return (_jsx(Popover, { open: isCalendarOpen, targetDOMNode: targetDOMNode, renderTrigger: ({ setTriggerRef, togglePopover, handleTriggerKeyDown, handleTriggerBlur }) => (_jsxs("div", { ref: setTriggerRef, "data-selected": hasValue, className: cx(classes.wrapper, 'mfui-FilterDatePicker__wrapper'), children: [_jsx(FocusIndicator, { children: _jsxs("button", { ref: triggerRef, type: "button", disabled: disabled, className: cx(classes.trigger, 'mfui-FilterDatePicker__trigger', className), "data-selected": hasValue, "data-mfui-has-clear-button": enableClearButton ? hasValue : null, "aria-controls": dialogId, "aria-expanded": isCalendarOpen, "aria-haspopup": "dialog", onClick: togglePopover, onKeyDown: handleTriggerKeyDown, onBlur: handleTriggerBlur, children: [_jsx("span", { className: cx(classes.content, 'mfui-FilterDatePicker__content'), "data-mfui-content": "filter-date-picker-display-value", children: hasValue ? (_jsxs(Typography, { variant: "strongBody", children: [_jsx("span", { "data-mfui-content": "filter-date-picker-label", children: `${label}:` }), _jsx("span", { "data-mfui-content": "filter-date-picker-value", children: formattedValue })] })) : (_jsx(Typography, { variant: "controlLabel", children: _jsx("span", { "data-mfui-content": "filter-date-picker-label", children: label }) })) }), _jsx("span", { className: cx(classes.calendarIcon, 'mfui-FilterDatePicker__calendarIcon'), children: _jsx(CalendarIcon, { "aria-hidden": true }) })] }) }), enableClearButton && hasValue ? (_jsx("div", { className: cx(classes.clearButtonWrapper, 'mfui-FilterDatePicker__clearButtonWrapper'), children: _jsx(ClearButton, { "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', "data-mfui-content": "filter-date-picker-clear-button", disabled: disabled, onClick: handleClear }) })) : null] })), renderContent: () => (_jsx("div", { id: dialogId, role: "dialog", "aria-label": label, className: "mfui-FilterDatePicker__popoverWrapper", onKeyDown: handleOnKeyDown, children: _jsx(DatePickerPanel, { value: currentValue, checkDisabledDate: checkDisabledDate, minDate: minDate, maxDate: maxDate, prevMonthIconButtonProps: prevMonthIconButtonProps, nextMonthIconButtonProps: nextMonthIconButtonProps, todayButtonProps: todayButtonProps, onChange: (date) => {
|
|
43
43
|
handleValueChange(date);
|
|
44
44
|
} }) })), minWidth: "min-content", onOpenStateChanged: toggleCalendar, onOpen: handlePopoverOpen }));
|
|
45
45
|
}
|
package/dist/src/DateTimeSelection/FilterDatePicker/CalendarPopover/CalendarPopover.types.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type InternalCalendarPopoverProps = {
|
|
|
12
12
|
classes: ReturnType<typeof filterDatePickerSlotRecipe>;
|
|
13
13
|
formattedValue: string | undefined;
|
|
14
14
|
hasValue: boolean;
|
|
15
|
+
enableClearButton: boolean;
|
|
15
16
|
label: string;
|
|
16
17
|
clearButtonProps: FilterDatePickerProps['clearButtonProps'];
|
|
17
18
|
checkDisabledDate: FilterDatePickerProps['checkDisabledDate'];
|
|
@@ -11,4 +11,4 @@ import { type FilterDatePickerProps } from './FilterDatePicker.types';
|
|
|
11
11
|
* neither of which are appropriate here. FilterDatePicker uses CalendarIcon and
|
|
12
12
|
* has no form-field semantics.
|
|
13
13
|
*/
|
|
14
|
-
export declare function FilterDatePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format, clearButtonProps, disabled, className, targetDOMNode, checkDisabledDate, minDate, maxDate, prevMonthIconButtonProps, nextMonthIconButtonProps, todayButtonProps, }: FilterDatePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function FilterDatePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format, enableClearButton, clearButtonProps, disabled, className, targetDOMNode, checkDisabledDate, minDate, maxDate, prevMonthIconButtonProps, nextMonthIconButtonProps, todayButtonProps, }: FilterDatePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -19,7 +19,7 @@ const DEFAULT_FORMAT = 'YYYY/MM/DD';
|
|
|
19
19
|
* neither of which are appropriate here. FilterDatePicker uses CalendarIcon and
|
|
20
20
|
* has no form-field semantics.
|
|
21
21
|
*/
|
|
22
|
-
export function FilterDatePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format = DEFAULT_FORMAT, clearButtonProps, disabled = false, className, targetDOMNode, checkDisabledDate, minDate, maxDate, prevMonthIconButtonProps, nextMonthIconButtonProps, todayButtonProps, }) {
|
|
22
|
+
export function FilterDatePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format = DEFAULT_FORMAT, enableClearButton = false, clearButtonProps, disabled = false, className, targetDOMNode, checkDisabledDate, minDate, maxDate, prevMonthIconButtonProps, nextMonthIconButtonProps, todayButtonProps, }) {
|
|
23
23
|
const classes = filterDatePickerSlotRecipe();
|
|
24
24
|
const triggerRef = useRef(null);
|
|
25
25
|
const dialogId = useId();
|
|
@@ -71,5 +71,5 @@ export function FilterDatePicker({ label, value, defaultValue, onChange, open, o
|
|
|
71
71
|
}, [value, onChange, triggerRef]);
|
|
72
72
|
const formattedValue = currentValue ? dayjs(currentValue).format(format) : undefined;
|
|
73
73
|
const hasValue = !!formattedValue;
|
|
74
|
-
return (_jsx(BasePickerProvider, { value: currentValue, children: _jsx(InternalCalendarPopover, { currentValue: currentValue, defaultValue: defaultValue, isCalendarOpen: isCalendarOpen, toggleCalendar: toggleCalendar, handleValueChange: handleValueChange, handleClear: handleClear, disabled: disabled, className: className, classes: classes, formattedValue: formattedValue, hasValue: hasValue, label: label, clearButtonProps: clearButtonProps, checkDisabledDate: checkDisabledDate, minDate: minDate, maxDate: maxDate, prevMonthIconButtonProps: prevMonthIconButtonProps, nextMonthIconButtonProps: nextMonthIconButtonProps, todayButtonProps: todayButtonProps, triggerRef: triggerRef, targetDOMNode: targetDOMNode, dialogId: dialogId }) }));
|
|
74
|
+
return (_jsx(BasePickerProvider, { value: currentValue, children: _jsx(InternalCalendarPopover, { currentValue: currentValue, defaultValue: defaultValue, isCalendarOpen: isCalendarOpen, toggleCalendar: toggleCalendar, handleValueChange: handleValueChange, handleClear: handleClear, disabled: disabled, className: className, classes: classes, formattedValue: formattedValue, hasValue: hasValue, enableClearButton: enableClearButton, label: label, clearButtonProps: clearButtonProps, checkDisabledDate: checkDisabledDate, minDate: minDate, maxDate: maxDate, prevMonthIconButtonProps: prevMonthIconButtonProps, nextMonthIconButtonProps: nextMonthIconButtonProps, todayButtonProps: todayButtonProps, triggerRef: triggerRef, targetDOMNode: targetDOMNode, dialogId: dialogId }) }));
|
|
75
75
|
}
|
|
@@ -37,7 +37,13 @@ export type FilterDatePickerProps = {
|
|
|
37
37
|
*/
|
|
38
38
|
format?: string;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Whether to show the clear button when the selected date is present.
|
|
41
|
+
*
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
enableClearButton?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Props for the clear button.
|
|
41
47
|
*
|
|
42
48
|
* @property aria-label - The alternative text for the clear button. Default is '値をクリアする'.
|
|
43
49
|
*/
|
|
@@ -3,4 +3,4 @@ import { type InternalDateRangePickerContentProps } from './DateRangePickerConte
|
|
|
3
3
|
* Internal component that accesses BaseRangePickerContext for display and clear handling.
|
|
4
4
|
* Must be rendered inside a BaseRangePickerProvider.
|
|
5
5
|
*/
|
|
6
|
-
export declare function InternalDateRangePickerContent({ classes, triggerRef, dialogId, label, format, disabled, className, clearButtonProps, targetDOMNode, isCalendarOpen, toggleCalendar, calendarLocale, }: InternalDateRangePickerContentProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function InternalDateRangePickerContent({ classes, triggerRef, dialogId, label, format, disabled, className, enableClearButton, clearButtonProps, targetDOMNode, isCalendarOpen, toggleCalendar, calendarLocale, }: InternalDateRangePickerContentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -15,7 +15,7 @@ import { useBaseRangePickerContext } from '../../shared/BaseRangePicker/BaseRang
|
|
|
15
15
|
* Internal component that accesses BaseRangePickerContext for display and clear handling.
|
|
16
16
|
* Must be rendered inside a BaseRangePickerProvider.
|
|
17
17
|
*/
|
|
18
|
-
export function InternalDateRangePickerContent({ classes, triggerRef, dialogId, label, format, disabled, className, clearButtonProps, targetDOMNode, isCalendarOpen, toggleCalendar, calendarLocale, }) {
|
|
18
|
+
export function InternalDateRangePickerContent({ classes, triggerRef, dialogId, label, format, disabled, className, enableClearButton, clearButtonProps, targetDOMNode, isCalendarOpen, toggleCalendar, calendarLocale, }) {
|
|
19
19
|
const { startDate, endDate, handleClear: contextHandleClear, setPendingFocusDate } = useBaseRangePickerContext();
|
|
20
20
|
const formattedStartDate = startDate ? dayjs(startDate).format(format) : undefined;
|
|
21
21
|
const formattedEndDate = endDate ? dayjs(endDate).format(format) : undefined;
|
|
@@ -29,5 +29,5 @@ export function InternalDateRangePickerContent({ classes, triggerRef, dialogId,
|
|
|
29
29
|
const dateToFocus = startDate ?? endDate ?? new Date();
|
|
30
30
|
setPendingFocusDate(dayjs(dateToFocus).format('YYYY-MM-DD'));
|
|
31
31
|
}, [startDate, endDate, setPendingFocusDate]);
|
|
32
|
-
return (_jsx(Popover, { open: isCalendarOpen, targetDOMNode: targetDOMNode, minWidth: "min-content", allowedPlacements: ['bottom-start', 'top-start'], renderTrigger: ({ setTriggerRef, togglePopover, handleTriggerKeyDown, handleTriggerBlur }) => (_jsxs("div", { ref: setTriggerRef, "data-selected": hasValue, className: cx(classes.wrapper, 'mfui-FilterDateRangePicker__wrapper'), children: [_jsx(FocusIndicator, { children: _jsxs("button", { ref: triggerRef, type: "button", disabled: disabled, className: cx(classes.trigger, 'mfui-FilterDateRangePicker__trigger', className), "data-selected": hasValue, "data-mfui-has-clear-button": hasValue, "aria-controls": dialogId, "aria-expanded": isCalendarOpen, "aria-haspopup": "dialog", onClick: togglePopover, onKeyDown: handleTriggerKeyDown, onBlur: handleTriggerBlur, children: [_jsx("span", { className: cx(classes.content, 'mfui-FilterDateRangePicker__content'), "data-mfui-content": "filter-date-range-picker-display-value", children: hasValue ? (_jsxs(Typography, { variant: "strongBody", children: [_jsx("span", { "data-mfui-content": "filter-date-range-picker-label", children: `${label}:` }), _jsx("span", { "data-mfui-content": "filter-date-range-picker-value", children: formattedValue })] })) : (_jsx(Typography, { variant: "controlLabel", children: _jsx("span", { "data-mfui-content": "filter-date-range-picker-label", children: label }) })) }), _jsx("span", { className: cx(classes.calendarIcon, 'mfui-FilterDateRangePicker__calendarIcon'), children: _jsx(CalendarIcon, { "aria-hidden": true }) })] }) }), hasValue ? (_jsx("div", { className: cx(classes.clearButtonWrapper, 'mfui-FilterDateRangePicker__clearButtonWrapper'), children: _jsx(ClearButton, { "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', "data-mfui-content": "filter-date-range-picker-clear-button", disabled: disabled, onClick: handleTriggerClear }) })) : null] })), renderContent: () => (_jsx("div", { id: dialogId, role: "dialog", "aria-label": label, className: cx(classes.popoverWrapper, 'mfui-FilterDateRangePicker__popoverWrapper'), children: _jsx(CalendarLocaleProvider, { value: calendarLocale, children: _jsx(DateRangePickerPopover, {}) }) })), onOpenStateChanged: toggleCalendar, onOpen: handlePopoverOpen }));
|
|
32
|
+
return (_jsx(Popover, { open: isCalendarOpen, targetDOMNode: targetDOMNode, minWidth: "min-content", allowedPlacements: ['bottom-start', 'top-start'], renderTrigger: ({ setTriggerRef, togglePopover, handleTriggerKeyDown, handleTriggerBlur }) => (_jsxs("div", { ref: setTriggerRef, "data-selected": hasValue, className: cx(classes.wrapper, 'mfui-FilterDateRangePicker__wrapper'), children: [_jsx(FocusIndicator, { children: _jsxs("button", { ref: triggerRef, type: "button", disabled: disabled, className: cx(classes.trigger, 'mfui-FilterDateRangePicker__trigger', className), "data-selected": hasValue, "data-mfui-has-clear-button": enableClearButton ? hasValue : null, "aria-controls": dialogId, "aria-expanded": isCalendarOpen, "aria-haspopup": "dialog", onClick: togglePopover, onKeyDown: handleTriggerKeyDown, onBlur: handleTriggerBlur, children: [_jsx("span", { className: cx(classes.content, 'mfui-FilterDateRangePicker__content'), "data-mfui-content": "filter-date-range-picker-display-value", children: hasValue ? (_jsxs(Typography, { variant: "strongBody", children: [_jsx("span", { "data-mfui-content": "filter-date-range-picker-label", children: `${label}:` }), _jsx("span", { "data-mfui-content": "filter-date-range-picker-value", children: formattedValue })] })) : (_jsx(Typography, { variant: "controlLabel", children: _jsx("span", { "data-mfui-content": "filter-date-range-picker-label", children: label }) })) }), _jsx("span", { className: cx(classes.calendarIcon, 'mfui-FilterDateRangePicker__calendarIcon'), children: _jsx(CalendarIcon, { "aria-hidden": true }) })] }) }), enableClearButton && hasValue ? (_jsx("div", { className: cx(classes.clearButtonWrapper, 'mfui-FilterDateRangePicker__clearButtonWrapper'), children: _jsx(ClearButton, { "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', "data-mfui-content": "filter-date-range-picker-clear-button", disabled: disabled, onClick: handleTriggerClear }) })) : null] })), renderContent: () => (_jsx("div", { id: dialogId, role: "dialog", "aria-label": label, className: cx(classes.popoverWrapper, 'mfui-FilterDateRangePicker__popoverWrapper'), children: _jsx(CalendarLocaleProvider, { value: calendarLocale, children: _jsx(DateRangePickerPopover, {}) }) })), onOpenStateChanged: toggleCalendar, onOpen: handlePopoverOpen }));
|
|
33
33
|
}
|
|
@@ -9,6 +9,7 @@ export type InternalDateRangePickerContentProps = {
|
|
|
9
9
|
format: string;
|
|
10
10
|
disabled: boolean;
|
|
11
11
|
className: string | undefined;
|
|
12
|
+
enableClearButton: boolean;
|
|
12
13
|
clearButtonProps: FilterDateRangePickerProps['clearButtonProps'];
|
|
13
14
|
targetDOMNode: FilterDateRangePickerProps['targetDOMNode'];
|
|
14
15
|
isCalendarOpen: boolean;
|
|
@@ -11,4 +11,4 @@ import { type FilterDateRangePickerProps } from './FilterDateRangePicker.types';
|
|
|
11
11
|
* neither of which are appropriate here. FilterDateRangePicker uses CalendarIcon and
|
|
12
12
|
* has no form-field semantics.
|
|
13
13
|
*/
|
|
14
|
-
export declare function FilterDateRangePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format, clearButtonProps, disabled, className, targetDOMNode, minDate, maxDate, calendarLocale, }: FilterDateRangePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function FilterDateRangePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format, enableClearButton, clearButtonProps, disabled, className, targetDOMNode, minDate, maxDate, calendarLocale, }: FilterDateRangePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -18,7 +18,7 @@ const DEFAULT_FORMAT = 'YYYY/MM/DD';
|
|
|
18
18
|
* neither of which are appropriate here. FilterDateRangePicker uses CalendarIcon and
|
|
19
19
|
* has no form-field semantics.
|
|
20
20
|
*/
|
|
21
|
-
export function FilterDateRangePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format = DEFAULT_FORMAT, clearButtonProps, disabled = false, className, targetDOMNode, minDate, maxDate, calendarLocale = 'ja', }) {
|
|
21
|
+
export function FilterDateRangePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format = DEFAULT_FORMAT, enableClearButton = false, clearButtonProps, disabled = false, className, targetDOMNode, minDate, maxDate, calendarLocale = 'ja', }) {
|
|
22
22
|
const classes = filterDateRangePickerSlotRecipe();
|
|
23
23
|
const triggerRef = useRef(null);
|
|
24
24
|
const dialogId = useId();
|
|
@@ -38,5 +38,5 @@ export function FilterDateRangePicker({ label, value, defaultValue, onChange, op
|
|
|
38
38
|
onOpenStateChanged?.(false);
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
|
-
return (_jsx(BaseRangePickerProvider, { value: value, defaultValue: defaultValue, format: format, isOpen: isCalendarOpen, open: openCalendar, close: closeCalendar, minDate: minDate, maxDate: maxDate, disabled: disabled, onChange: onChange, children: _jsx(InternalDateRangePickerContent, { classes: classes, triggerRef: triggerRef, dialogId: dialogId, label: label, format: format, disabled: disabled, className: className, clearButtonProps: clearButtonProps, targetDOMNode: targetDOMNode, isCalendarOpen: isCalendarOpen, toggleCalendar: toggleCalendar, calendarLocale: calendarLocale }) }));
|
|
41
|
+
return (_jsx(BaseRangePickerProvider, { value: value, defaultValue: defaultValue, format: format, isOpen: isCalendarOpen, open: openCalendar, close: closeCalendar, minDate: minDate, maxDate: maxDate, disabled: disabled, onChange: onChange, children: _jsx(InternalDateRangePickerContent, { classes: classes, triggerRef: triggerRef, dialogId: dialogId, label: label, format: format, disabled: disabled, className: className, enableClearButton: enableClearButton, clearButtonProps: clearButtonProps, targetDOMNode: targetDOMNode, isCalendarOpen: isCalendarOpen, toggleCalendar: toggleCalendar, calendarLocale: calendarLocale }) }));
|
|
42
42
|
}
|
|
@@ -40,7 +40,13 @@ export type FilterDateRangePickerProps = {
|
|
|
40
40
|
*/
|
|
41
41
|
format?: string;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Whether to show the clear button when a complete date range is selected.
|
|
44
|
+
*
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
enableClearButton?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Props for the clear button.
|
|
44
50
|
*
|
|
45
51
|
* @property aria-label - The alternative text for the clear button. Default is '値をクリアする'.
|
|
46
52
|
*/
|
|
@@ -11,4 +11,4 @@ import { type FilterMonthPickerProps } from './FilterMonthPicker.types';
|
|
|
11
11
|
* neither of which are appropriate here. FilterMonthPicker uses CalendarIcon and
|
|
12
12
|
* has no form-field semantics.
|
|
13
13
|
*/
|
|
14
|
-
export declare function FilterMonthPicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format, clearButtonProps, disabled, className, targetDOMNode, checkDisabledMonth, minMonth, maxMonth, calendarLocale, }: FilterMonthPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function FilterMonthPicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format, enableClearButton, clearButtonProps, disabled, className, targetDOMNode, checkDisabledMonth, minMonth, maxMonth, calendarLocale, }: FilterMonthPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -19,7 +19,7 @@ const DEFAULT_FORMAT = 'YYYY/MM';
|
|
|
19
19
|
* neither of which are appropriate here. FilterMonthPicker uses CalendarIcon and
|
|
20
20
|
* has no form-field semantics.
|
|
21
21
|
*/
|
|
22
|
-
export function FilterMonthPicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format = DEFAULT_FORMAT, clearButtonProps, disabled = false, className, targetDOMNode, checkDisabledMonth, minMonth, maxMonth, calendarLocale = 'ja', }) {
|
|
22
|
+
export function FilterMonthPicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format = DEFAULT_FORMAT, enableClearButton = false, clearButtonProps, disabled = false, className, targetDOMNode, checkDisabledMonth, minMonth, maxMonth, calendarLocale = 'ja', }) {
|
|
23
23
|
const classes = filterMonthPickerSlotRecipe();
|
|
24
24
|
const triggerRef = useRef(null);
|
|
25
25
|
const dialogId = useId();
|
|
@@ -71,5 +71,5 @@ export function FilterMonthPicker({ label, value, defaultValue, onChange, open,
|
|
|
71
71
|
}, [value, onChange, triggerRef]);
|
|
72
72
|
const formattedValue = currentValue ? dayjs(currentValue).format(format) : undefined;
|
|
73
73
|
const hasValue = !!formattedValue;
|
|
74
|
-
return (_jsx(BasePickerProvider, { value: currentValue, baseFormat: "YYYY-MM", children: _jsx(InternalMonthPickerPopover, { currentValue: currentValue, defaultValue: defaultValue, isPickerOpen: isPickerOpen, togglePicker: togglePicker, handleValueChange: handleValueChange, handleClear: handleClear, disabled: disabled, className: className, classes: classes, formattedValue: formattedValue, hasValue: hasValue, label: label, clearButtonProps: clearButtonProps, checkDisabledMonth: checkDisabledMonth, minMonth: minMonth, maxMonth: maxMonth, calendarLocale: calendarLocale, triggerRef: triggerRef, targetDOMNode: targetDOMNode, dialogId: dialogId }) }));
|
|
74
|
+
return (_jsx(BasePickerProvider, { value: currentValue, baseFormat: "YYYY-MM", children: _jsx(InternalMonthPickerPopover, { currentValue: currentValue, defaultValue: defaultValue, isPickerOpen: isPickerOpen, togglePicker: togglePicker, handleValueChange: handleValueChange, handleClear: handleClear, disabled: disabled, className: className, classes: classes, formattedValue: formattedValue, hasValue: hasValue, enableClearButton: enableClearButton, label: label, clearButtonProps: clearButtonProps, checkDisabledMonth: checkDisabledMonth, minMonth: minMonth, maxMonth: maxMonth, calendarLocale: calendarLocale, triggerRef: triggerRef, targetDOMNode: targetDOMNode, dialogId: dialogId }) }));
|
|
75
75
|
}
|
|
@@ -37,7 +37,13 @@ export type FilterMonthPickerProps = {
|
|
|
37
37
|
*/
|
|
38
38
|
format?: string;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Whether to show the clear button when the selected month is present.
|
|
41
|
+
*
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
enableClearButton?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Props for the clear button.
|
|
41
47
|
*
|
|
42
48
|
* @property aria-label - The alternative text for the clear button. Default is '値をクリアする'.
|
|
43
49
|
*/
|
package/dist/src/DateTimeSelection/FilterMonthPicker/MonthPickerPopover/MonthPickerPopover.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { type InternalMonthPickerPopoverProps } from './MonthPickerPopover.types
|
|
|
3
3
|
* Internal component that accesses BasePickerContext for viewing-month reset and focus trap.
|
|
4
4
|
* Must be rendered inside a BasePickerProvider.
|
|
5
5
|
*/
|
|
6
|
-
export declare function InternalMonthPickerPopover({ currentValue, defaultValue, isPickerOpen, togglePicker, handleValueChange, handleClear, disabled, className, classes, formattedValue, hasValue, label, clearButtonProps, checkDisabledMonth, minMonth, maxMonth, calendarLocale, triggerRef, targetDOMNode, dialogId, }: InternalMonthPickerPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function InternalMonthPickerPopover({ currentValue, defaultValue, isPickerOpen, togglePicker, handleValueChange, handleClear, disabled, className, classes, formattedValue, hasValue, enableClearButton, label, clearButtonProps, checkDisabledMonth, minMonth, maxMonth, calendarLocale, triggerRef, targetDOMNode, dialogId, }: InternalMonthPickerPopoverProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/src/DateTimeSelection/FilterMonthPicker/MonthPickerPopover/MonthPickerPopover.js
CHANGED
|
@@ -18,7 +18,7 @@ const MONTH_BASE_FORMAT = 'YYYY-MM';
|
|
|
18
18
|
* Internal component that accesses BasePickerContext for viewing-month reset and focus trap.
|
|
19
19
|
* Must be rendered inside a BasePickerProvider.
|
|
20
20
|
*/
|
|
21
|
-
export function InternalMonthPickerPopover({ currentValue, defaultValue, isPickerOpen, togglePicker, handleValueChange, handleClear, disabled, className, classes, formattedValue, hasValue, label, clearButtonProps, checkDisabledMonth, minMonth, maxMonth, calendarLocale = 'ja', triggerRef, targetDOMNode, dialogId, }) {
|
|
21
|
+
export function InternalMonthPickerPopover({ currentValue, defaultValue, isPickerOpen, togglePicker, handleValueChange, handleClear, disabled, className, classes, formattedValue, hasValue, enableClearButton, label, clearButtonProps, checkDisabledMonth, minMonth, maxMonth, calendarLocale = 'ja', triggerRef, targetDOMNode, dialogId, }) {
|
|
22
22
|
const { viewingValue, setViewingValue, setPendingFocusDate } = useBasePickerContext();
|
|
23
23
|
const { handleOnKeyDown } = useFocusTrap({
|
|
24
24
|
onPressingTabOnNotFocusableElement: (event) => {
|
|
@@ -39,7 +39,7 @@ export function InternalMonthPickerPopover({ currentValue, defaultValue, isPicke
|
|
|
39
39
|
setViewingValue(monthToFocus);
|
|
40
40
|
setPendingFocusDate(dayjs(monthToFocus).format(MONTH_BASE_FORMAT));
|
|
41
41
|
}, [currentValue, defaultValue, setViewingValue, setPendingFocusDate]);
|
|
42
|
-
return (_jsx(Popover, { open: isPickerOpen, targetDOMNode: targetDOMNode, renderTrigger: ({ setTriggerRef, togglePopover, handleTriggerKeyDown, handleTriggerBlur }) => (_jsxs("div", { ref: setTriggerRef, "data-selected": hasValue, className: cx(classes.wrapper, 'mfui-FilterMonthPicker__wrapper'), children: [_jsx(FocusIndicator, { children: _jsxs("button", { ref: triggerRef, type: "button", disabled: disabled, className: cx(classes.trigger, 'mfui-FilterMonthPicker__trigger', className), "data-selected": hasValue, "data-mfui-has-clear-button": hasValue, "aria-controls": dialogId, "aria-expanded": isPickerOpen, "aria-haspopup": "dialog", onClick: togglePopover, onKeyDown: handleTriggerKeyDown, onBlur: handleTriggerBlur, children: [_jsx("span", { className: cx(classes.content, 'mfui-FilterMonthPicker__content'), "data-mfui-content": "filter-month-picker-display-value", children: hasValue ? (_jsxs(Typography, { variant: "strongBody", children: [_jsx("span", { "data-mfui-content": "filter-month-picker-label", children: `${label}:` }), _jsx("span", { "data-mfui-content": "filter-month-picker-value", children: formattedValue })] })) : (_jsx(Typography, { variant: "controlLabel", children: _jsx("span", { "data-mfui-content": "filter-month-picker-label", children: label }) })) }), _jsx("span", { className: cx(classes.calendarIcon, 'mfui-FilterMonthPicker__calendarIcon'), children: _jsx(CalendarIcon, { "aria-hidden": true }) })] }) }), hasValue ? (_jsx("div", { className: cx(classes.clearButtonWrapper, 'mfui-FilterMonthPicker__clearButtonWrapper'), children: _jsx(ClearButton, { "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', "data-mfui-content": "filter-month-picker-clear-button", disabled: disabled, onClick: handleClear }) })) : null] })), renderContent: () => (_jsx("div", { id: dialogId, role: "dialog", "aria-label": label, className: "mfui-FilterMonthPicker__popoverWrapper", onKeyDown: handleOnKeyDown, children: _jsx(CalendarLocaleProvider, { value: calendarLocale, children: _jsx(MonthPickerPanel, { viewingValue: viewingValue, setViewingValue: setViewingValue, value: currentValue, minMonth: minMonth, maxMonth: maxMonth, checkDisabledMonth: checkDisabledMonth, onChange: (date) => {
|
|
42
|
+
return (_jsx(Popover, { open: isPickerOpen, targetDOMNode: targetDOMNode, renderTrigger: ({ setTriggerRef, togglePopover, handleTriggerKeyDown, handleTriggerBlur }) => (_jsxs("div", { ref: setTriggerRef, "data-selected": hasValue, className: cx(classes.wrapper, 'mfui-FilterMonthPicker__wrapper'), children: [_jsx(FocusIndicator, { children: _jsxs("button", { ref: triggerRef, type: "button", disabled: disabled, className: cx(classes.trigger, 'mfui-FilterMonthPicker__trigger', className), "data-selected": hasValue, "data-mfui-has-clear-button": enableClearButton ? hasValue : null, "aria-controls": dialogId, "aria-expanded": isPickerOpen, "aria-haspopup": "dialog", onClick: togglePopover, onKeyDown: handleTriggerKeyDown, onBlur: handleTriggerBlur, children: [_jsx("span", { className: cx(classes.content, 'mfui-FilterMonthPicker__content'), "data-mfui-content": "filter-month-picker-display-value", children: hasValue ? (_jsxs(Typography, { variant: "strongBody", children: [_jsx("span", { "data-mfui-content": "filter-month-picker-label", children: `${label}:` }), _jsx("span", { "data-mfui-content": "filter-month-picker-value", children: formattedValue })] })) : (_jsx(Typography, { variant: "controlLabel", children: _jsx("span", { "data-mfui-content": "filter-month-picker-label", children: label }) })) }), _jsx("span", { className: cx(classes.calendarIcon, 'mfui-FilterMonthPicker__calendarIcon'), children: _jsx(CalendarIcon, { "aria-hidden": true }) })] }) }), enableClearButton && hasValue ? (_jsx("div", { className: cx(classes.clearButtonWrapper, 'mfui-FilterMonthPicker__clearButtonWrapper'), children: _jsx(ClearButton, { "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', "data-mfui-content": "filter-month-picker-clear-button", disabled: disabled, onClick: handleClear }) })) : null] })), renderContent: () => (_jsx("div", { id: dialogId, role: "dialog", "aria-label": label, className: "mfui-FilterMonthPicker__popoverWrapper", onKeyDown: handleOnKeyDown, children: _jsx(CalendarLocaleProvider, { value: calendarLocale, children: _jsx(MonthPickerPanel, { viewingValue: viewingValue, setViewingValue: setViewingValue, value: currentValue, minMonth: minMonth, maxMonth: maxMonth, checkDisabledMonth: checkDisabledMonth, onChange: (date) => {
|
|
43
43
|
handleValueChange(date);
|
|
44
44
|
} }) }) })), minWidth: "min-content", allowedPlacements: ['bottom-start', 'top-start'], onOpenStateChanged: togglePicker, onOpen: handlePopoverOpen }));
|
|
45
45
|
}
|
|
@@ -12,6 +12,7 @@ export type InternalMonthPickerPopoverProps = {
|
|
|
12
12
|
classes: ReturnType<typeof filterMonthPickerSlotRecipe>;
|
|
13
13
|
formattedValue: string | undefined;
|
|
14
14
|
hasValue: boolean;
|
|
15
|
+
enableClearButton: boolean;
|
|
15
16
|
label: string;
|
|
16
17
|
clearButtonProps: FilterMonthPickerProps['clearButtonProps'];
|
|
17
18
|
checkDisabledMonth: FilterMonthPickerProps['checkDisabledMonth'];
|
|
@@ -12,4 +12,4 @@ import { type FilterMonthRangePickerProps } from './FilterMonthRangePicker.types
|
|
|
12
12
|
* neither of which are appropriate here. FilterMonthRangePicker uses CalendarIcon and
|
|
13
13
|
* has no form-field semantics.
|
|
14
14
|
*/
|
|
15
|
-
export declare function FilterMonthRangePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format, initialDisplayedMonths, clearButtonProps, disabled, className, targetDOMNode, minMonth, maxMonth, }: FilterMonthRangePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function FilterMonthRangePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format, initialDisplayedMonths, enableClearButton, clearButtonProps, disabled, className, targetDOMNode, minMonth, maxMonth, }: FilterMonthRangePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -21,7 +21,7 @@ const DEFAULT_FORMAT = 'YYYY/MM';
|
|
|
21
21
|
* neither of which are appropriate here. FilterMonthRangePicker uses CalendarIcon and
|
|
22
22
|
* has no form-field semantics.
|
|
23
23
|
*/
|
|
24
|
-
export function FilterMonthRangePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format = DEFAULT_FORMAT, initialDisplayedMonths = 'currentAndNext', clearButtonProps, disabled = false, className, targetDOMNode, minMonth, maxMonth, }) {
|
|
24
|
+
export function FilterMonthRangePicker({ label, value, defaultValue, onChange, open, onOpenStateChanged, format = DEFAULT_FORMAT, initialDisplayedMonths = 'currentAndNext', enableClearButton = false, clearButtonProps, disabled = false, className, targetDOMNode, minMonth, maxMonth, }) {
|
|
25
25
|
const classes = filterMonthRangePickerSlotRecipe();
|
|
26
26
|
const triggerRef = useRef(null);
|
|
27
27
|
const dialogId = useId();
|
|
@@ -85,5 +85,5 @@ export function FilterMonthRangePicker({ label, value, defaultValue, onChange, o
|
|
|
85
85
|
}
|
|
86
86
|
return new Date(startDate.getFullYear() - 1, 0, 1);
|
|
87
87
|
})();
|
|
88
|
-
return (_jsx(BaseRangePickerProvider, { value: currentValue, defaultValue: defaultValue, disabled: disabled, format: format, isOpen: isPickerOpen, open: openPicker, close: closePickerAndNotify, minDate: minMonth, maxDate: maxMonth, initialDisplayedMonths: initialDisplayedMonths, initialViewingDate: initialViewingDate, onChange: handleRangeChange, children: _jsx(InternalMonthRangePickerPopover, { isPickerOpen: isPickerOpen, togglePicker: togglePicker, handleClear: handleClear, disabled: disabled, className: className, classes: classes, formattedValue: formattedValue, hasValue: hasValue, label: label, clearButtonProps: clearButtonProps, minMonth: minMonth, maxMonth: maxMonth, triggerRef: triggerRef, targetDOMNode: targetDOMNode, dialogId: dialogId }) }));
|
|
88
|
+
return (_jsx(BaseRangePickerProvider, { value: currentValue, defaultValue: defaultValue, disabled: disabled, format: format, isOpen: isPickerOpen, open: openPicker, close: closePickerAndNotify, minDate: minMonth, maxDate: maxMonth, initialDisplayedMonths: initialDisplayedMonths, initialViewingDate: initialViewingDate, onChange: handleRangeChange, children: _jsx(InternalMonthRangePickerPopover, { isPickerOpen: isPickerOpen, togglePicker: togglePicker, handleClear: handleClear, disabled: disabled, className: className, classes: classes, formattedValue: formattedValue, hasValue: hasValue, enableClearButton: enableClearButton, label: label, clearButtonProps: clearButtonProps, minMonth: minMonth, maxMonth: maxMonth, triggerRef: triggerRef, targetDOMNode: targetDOMNode, dialogId: dialogId }) }));
|
|
89
89
|
}
|
|
@@ -37,7 +37,13 @@ export type FilterMonthRangePickerProps = {
|
|
|
37
37
|
*/
|
|
38
38
|
format?: string;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Whether to show the clear button when a complete range is selected.
|
|
41
|
+
*
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
enableClearButton?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Props for the clear button.
|
|
41
47
|
*
|
|
42
48
|
* @property aria-label - The alternative text for the clear button. Default is '値をクリアする'.
|
|
43
49
|
*/
|
|
@@ -2,4 +2,4 @@ import { type InternalMonthRangePickerPopoverProps } from './MonthRangePickerPop
|
|
|
2
2
|
/**
|
|
3
3
|
* Internal popover UI for FilterMonthRangePicker. Must render inside BaseRangePickerProvider.
|
|
4
4
|
*/
|
|
5
|
-
export declare function InternalMonthRangePickerPopover({ isPickerOpen, togglePicker, handleClear, disabled, className, classes, formattedValue, hasValue, label, clearButtonProps, minMonth, maxMonth, triggerRef, targetDOMNode, dialogId, }: InternalMonthRangePickerPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function InternalMonthRangePickerPopover({ isPickerOpen, togglePicker, handleClear, disabled, className, classes, formattedValue, hasValue, enableClearButton, label, clearButtonProps, minMonth, maxMonth, triggerRef, targetDOMNode, dialogId, }: InternalMonthRangePickerPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -15,7 +15,7 @@ import { getFocusableNodes } from '../../../utilities/dom/getFocusableNodes';
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal popover UI for FilterMonthRangePicker. Must render inside BaseRangePickerProvider.
|
|
17
17
|
*/
|
|
18
|
-
export function InternalMonthRangePickerPopover({ isPickerOpen, togglePicker, handleClear, disabled, className, classes, formattedValue, hasValue, label, clearButtonProps, minMonth, maxMonth, triggerRef, targetDOMNode, dialogId, }) {
|
|
18
|
+
export function InternalMonthRangePickerPopover({ isPickerOpen, togglePicker, handleClear, disabled, className, classes, formattedValue, hasValue, enableClearButton, label, clearButtonProps, minMonth, maxMonth, triggerRef, targetDOMNode, dialogId, }) {
|
|
19
19
|
const { viewingMonth, setViewingMonth, temporaryStart, temporaryEnd, startDate, endDate, setPendingFocusDate } = useBaseRangePickerContext();
|
|
20
20
|
const { handleOnKeyDown } = useFocusTrap({
|
|
21
21
|
onPressingTabOnNotFocusableElement: (event) => {
|
|
@@ -50,5 +50,5 @@ export function InternalMonthRangePickerPopover({ isPickerOpen, togglePicker, ha
|
|
|
50
50
|
setViewingMonth(monthToFocus);
|
|
51
51
|
setPendingFocusDate(dayjs(monthToFocus).format('YYYY-MM'));
|
|
52
52
|
}, [temporaryStart, temporaryEnd, startDate, endDate, setViewingMonth, setPendingFocusDate]);
|
|
53
|
-
return (_jsx(Popover, { open: isPickerOpen, targetDOMNode: targetDOMNode, renderTrigger: ({ setTriggerRef, togglePopover, handleTriggerKeyDown, handleTriggerBlur }) => (_jsxs("div", { ref: setTriggerRef, "data-selected": hasValue, className: cx(classes.wrapper, 'mfui-FilterMonthRangePicker__wrapper'), children: [_jsx(FocusIndicator, { children: _jsxs("button", { ref: triggerRef, type: "button", disabled: disabled, className: cx(classes.trigger, 'mfui-FilterMonthRangePicker__trigger', className), "data-selected": hasValue, "data-mfui-has-clear-button": hasValue, "aria-controls": dialogId, "aria-expanded": isPickerOpen, "aria-haspopup": "dialog", onClick: togglePopover, onKeyDown: handleTriggerKeyDown, onBlur: handleTriggerBlur, children: [_jsx("span", { className: cx(classes.content, 'mfui-FilterMonthRangePicker__content'), "data-mfui-content": "filter-month-range-picker-display-value", children: hasValue ? (_jsxs(Typography, { variant: "strongBody", children: [_jsx("span", { "data-mfui-content": "filter-month-range-picker-label", children: `${label}:` }), _jsx("span", { "data-mfui-content": "filter-month-range-picker-value", children: formattedValue })] })) : (_jsx(Typography, { variant: "controlLabel", children: _jsx("span", { "data-mfui-content": "filter-month-range-picker-label", children: label }) })) }), _jsx("span", { className: cx(classes.calendarIcon, 'mfui-FilterMonthRangePicker__calendarIcon'), children: _jsx(CalendarIcon, { "aria-hidden": true }) })] }) }), hasValue ? (_jsx("div", { className: cx(classes.clearButtonWrapper, 'mfui-FilterMonthRangePicker__clearButtonWrapper'), children: _jsx(ClearButton, { "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', "data-mfui-content": "filter-month-range-picker-clear-button", disabled: disabled, onClick: handleClear }) })) : null] })), renderContent: () => (_jsx("div", { id: dialogId, role: "dialog", "aria-label": label, className: "mfui-FilterMonthRangePicker__popoverWrapper", onKeyDown: handleOnKeyDown, children: _jsx(MonthRangePickerPanel, { viewingValue: viewingMonth, setViewingValue: setViewingMonth, value: [temporaryStart, temporaryEnd], minMonth: minMonth, maxMonth: maxMonth }) })), minWidth: "min-content", allowedPlacements: ['bottom-start', 'top-start'], onOpenStateChanged: togglePicker, onOpen: handlePopoverOpen }));
|
|
53
|
+
return (_jsx(Popover, { open: isPickerOpen, targetDOMNode: targetDOMNode, renderTrigger: ({ setTriggerRef, togglePopover, handleTriggerKeyDown, handleTriggerBlur }) => (_jsxs("div", { ref: setTriggerRef, "data-selected": hasValue, className: cx(classes.wrapper, 'mfui-FilterMonthRangePicker__wrapper'), children: [_jsx(FocusIndicator, { children: _jsxs("button", { ref: triggerRef, type: "button", disabled: disabled, className: cx(classes.trigger, 'mfui-FilterMonthRangePicker__trigger', className), "data-selected": hasValue, "data-mfui-has-clear-button": enableClearButton ? hasValue : null, "aria-controls": dialogId, "aria-expanded": isPickerOpen, "aria-haspopup": "dialog", onClick: togglePopover, onKeyDown: handleTriggerKeyDown, onBlur: handleTriggerBlur, children: [_jsx("span", { className: cx(classes.content, 'mfui-FilterMonthRangePicker__content'), "data-mfui-content": "filter-month-range-picker-display-value", children: hasValue ? (_jsxs(Typography, { variant: "strongBody", children: [_jsx("span", { "data-mfui-content": "filter-month-range-picker-label", children: `${label}:` }), _jsx("span", { "data-mfui-content": "filter-month-range-picker-value", children: formattedValue })] })) : (_jsx(Typography, { variant: "controlLabel", children: _jsx("span", { "data-mfui-content": "filter-month-range-picker-label", children: label }) })) }), _jsx("span", { className: cx(classes.calendarIcon, 'mfui-FilterMonthRangePicker__calendarIcon'), children: _jsx(CalendarIcon, { "aria-hidden": true }) })] }) }), enableClearButton && hasValue ? (_jsx("div", { className: cx(classes.clearButtonWrapper, 'mfui-FilterMonthRangePicker__clearButtonWrapper'), children: _jsx(ClearButton, { "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', "data-mfui-content": "filter-month-range-picker-clear-button", disabled: disabled, onClick: handleClear }) })) : null] })), renderContent: () => (_jsx("div", { id: dialogId, role: "dialog", "aria-label": label, className: "mfui-FilterMonthRangePicker__popoverWrapper", onKeyDown: handleOnKeyDown, children: _jsx(MonthRangePickerPanel, { viewingValue: viewingMonth, setViewingValue: setViewingMonth, value: [temporaryStart, temporaryEnd], minMonth: minMonth, maxMonth: maxMonth }) })), minWidth: "min-content", allowedPlacements: ['bottom-start', 'top-start'], onOpenStateChanged: togglePicker, onOpen: handlePopoverOpen }));
|
|
54
54
|
}
|
|
@@ -9,6 +9,7 @@ export type InternalMonthRangePickerPopoverProps = {
|
|
|
9
9
|
classes: ReturnType<typeof filterMonthRangePickerSlotRecipe>;
|
|
10
10
|
formattedValue: string | undefined;
|
|
11
11
|
hasValue: boolean;
|
|
12
|
+
enableClearButton: boolean;
|
|
12
13
|
label: string;
|
|
13
14
|
clearButtonProps: FilterMonthRangePickerProps['clearButtonProps'];
|
|
14
15
|
minMonth: FilterMonthRangePickerProps['minMonth'];
|
|
@@ -49,5 +49,5 @@ export function MonthRangePickerMonthCell({ isInRange, isRangeStart, isRangeEnd,
|
|
|
49
49
|
}
|
|
50
50
|
return statusParts.length > 0 ? `${monthText}, ${statusParts.join(', ')}` : monthText;
|
|
51
51
|
}, [calendarLocale, monthCellProps.date, monthCellProps.disabled, selected, isInRange, isRangeStart, isRangeEnd]);
|
|
52
|
-
return (_jsx("div", { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: _jsx(MonthCell, { ...monthCellProps, monthFormat: monthFormat, selected: selected, inRange: isInRange, "aria-label": accessibleLabel, "aria-pressed": selected ? 'true' : undefined,
|
|
52
|
+
return (_jsx("div", { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: _jsx(MonthCell, { ...monthCellProps, monthFormat: monthFormat, selected: selected, inRange: isInRange, "aria-label": accessibleLabel, "aria-pressed": selected ? 'true' : undefined, onKeyDown: handleKeyboardNavigation }) }));
|
|
53
53
|
}
|
|
@@ -30,6 +30,7 @@ export declare const TimePicker: import("react").ForwardRefExoticComponent<Omit<
|
|
|
30
30
|
size?: "small" | "medium" | "large";
|
|
31
31
|
invalid?: boolean;
|
|
32
32
|
onClear?: (event: import("react").MouseEvent<HTMLButtonElement>) => void;
|
|
33
|
+
enableClearButton?: boolean;
|
|
33
34
|
clearButtonProps?: Pick<import("../..").IconButtonProps, "aria-label">;
|
|
34
35
|
pickerIndicatorIconButtonProps?: Pick<import("../..").IconButtonProps, "aria-label">;
|
|
35
36
|
}> & {
|
|
@@ -38,6 +39,7 @@ export declare const TimePicker: import("react").ForwardRefExoticComponent<Omit<
|
|
|
38
39
|
size?: "small" | "medium" | "large";
|
|
39
40
|
invalid?: boolean;
|
|
40
41
|
onClear?: (event: import("react").MouseEvent<HTMLButtonElement>) => void;
|
|
42
|
+
enableClearButton?: boolean;
|
|
41
43
|
clearButtonProps?: Pick<import("../..").IconButtonProps, "aria-label">;
|
|
42
44
|
pickerIndicatorIconButtonProps?: Pick<import("../..").IconButtonProps, "aria-label">;
|
|
43
45
|
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -35,7 +35,7 @@ import { getTimePickerLabel } from './constants';
|
|
|
35
35
|
* // With seconds
|
|
36
36
|
* <TimePicker format="HH:mm:ss" />
|
|
37
37
|
*/
|
|
38
|
-
export const TimePicker = forwardRef(({ value, defaultValue, onChange, format = 'HH:mm', size = 'medium', disabled = false, invalid = false, step, onClear, clearButtonProps, pickerIndicatorIconButtonProps, className, ...inputProps }, ref) => {
|
|
38
|
+
export const TimePicker = forwardRef(({ value, defaultValue, onChange, format = 'HH:mm', size = 'medium', disabled = false, invalid = false, step, onClear, enableClearButton = false, clearButtonProps, pickerIndicatorIconButtonProps, className, ...inputProps }, ref) => {
|
|
39
39
|
const inputRef = useRef(null);
|
|
40
40
|
const mergedInputRef = mergeRefs(ref, inputRef);
|
|
41
41
|
// Track the live value internally so the clear button can read it whether
|
|
@@ -79,7 +79,7 @@ export const TimePicker = forwardRef(({ value, defaultValue, onChange, format =
|
|
|
79
79
|
return (_jsx(FocusIndicator, { children: _jsxs("div", { className: cx(classes.root, 'mfui-TimePicker__root', className), children: [_jsx("input", { ...inputProps, ref: mergedInputRef, type: "time", className: cx(classes.input, 'mfui-TimePicker__input'), value: value, defaultValue: defaultValue, disabled: disabled, step: resolvedStep, "aria-invalid": invalid || undefined, onChange: (event) => {
|
|
80
80
|
setInternalValue(event.target.value);
|
|
81
81
|
onChange?.(event.target.value, event);
|
|
82
|
-
} }), hasValue && !disabled ? (_jsx(ClearButton, { size: size === 'small' ? 'small' : 'default', "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', className: cx(classes.clearButton, 'mfui-TimePicker__clearButton'), disabled: disabled, onClick: handleClear })) : null, _jsx(IconButton, { size: size === 'small' ? 'small' : 'default', "aria-label": pickerLabel, className: cx(classes.pickerButton, 'mfui-TimePicker__pickerButton'), disabled: disabled, onClick: () => {
|
|
82
|
+
} }), enableClearButton && hasValue && !disabled ? (_jsx(ClearButton, { size: size === 'small' ? 'small' : 'default', "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', className: cx(classes.clearButton, 'mfui-TimePicker__clearButton'), disabled: disabled, onClick: handleClear })) : null, _jsx(IconButton, { size: size === 'small' ? 'small' : 'default', "aria-label": pickerLabel, className: cx(classes.pickerButton, 'mfui-TimePicker__pickerButton'), disabled: disabled, onClick: () => {
|
|
83
83
|
triggerPicker();
|
|
84
84
|
}, children: _jsx(Time, {}) })] }) }));
|
|
85
85
|
});
|
|
@@ -39,6 +39,12 @@ type TimePickerOwnProps = {
|
|
|
39
39
|
* Callback fired when the clear button is clicked.
|
|
40
40
|
*/
|
|
41
41
|
onClear?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to show the clear button when the input has a value.
|
|
44
|
+
*
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
enableClearButton?: boolean;
|
|
42
48
|
/**
|
|
43
49
|
* Props for the clear IconButton. Use `aria-label` to override the default
|
|
44
50
|
* accessible name.
|
|
@@ -38,5 +38,5 @@ export function BaseRangePickerDateCell({ date, selected, inRange, disabled, isR
|
|
|
38
38
|
}
|
|
39
39
|
return statusParts.length > 0 ? `${dateText}, ${statusParts.join(', ')}` : dateText;
|
|
40
40
|
}, [date, selected, inRange, disabled, isRangeStart, isRangeEnd]);
|
|
41
|
-
return (_jsx(DateCell, { ...rest, date: date, selected: selected, inRange: inRange, disabled: disabled, "aria-label": accessibleLabel, "aria-pressed": selected ? 'true' : undefined
|
|
41
|
+
return (_jsx(DateCell, { ...rest, date: date, selected: selected, inRange: inRange, disabled: disabled, "aria-label": accessibleLabel, "aria-pressed": selected ? 'true' : undefined }));
|
|
42
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from '../../../../styled-system/css';
|
|
3
3
|
import { dayCellSlotRecipe } from '../../../../styled-system/recipes';
|
|
4
4
|
import { Typography } from '../../../Typography';
|
|
@@ -12,5 +12,5 @@ export function DayCell({ day }) {
|
|
|
12
12
|
const classNames = dayCellSlotRecipe();
|
|
13
13
|
const abbreviation = DAY_ABBREVIATIONS[calendarLocale][day];
|
|
14
14
|
const fullName = DAY_FULL_NAMES[calendarLocale][day];
|
|
15
|
-
return (
|
|
15
|
+
return (_jsxs("div", { className: cx(classNames.root, 'mfui-DayCell__root'), children: [_jsx(Typography, { "aria-hidden": true, variant: "contentHeading", className: cx(classNames.label, 'mfui-DayCell__label'), children: abbreviation }), _jsx("span", { className: cx(classNames.srOnlyLabel, 'mfui-DayCell__srOnlyLabel'), children: fullName })] }));
|
|
16
16
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The general purpose Dialog component.
|
|
3
|
-
* This component extends the props of `<div>` element
|
|
3
|
+
* This component extends the props of `<div>` element. The extended props and `ref` are
|
|
4
|
+
* applied to the root overlay element covering the viewport, while `role="dialog"` and
|
|
5
|
+
* `aria-modal="true"` are set on the inner dialog window element.
|
|
4
6
|
*
|
|
5
7
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog
|
|
6
8
|
*/
|