diff --git a/.storybook/manager.ts b/.storybook/manager.ts deleted file mode 100644 index 2d78890c1..000000000 --- a/.storybook/manager.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { addons } from "@storybook/addons"; - -addons.setConfig({ - panelPosition: "bottom", -}); diff --git a/package.json b/package.json index e03bd15dc..0d1a6a25b 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,6 @@ "@storybook/addon-links": "^8.2.9", "@storybook/addon-mdx-gfm": "^8.2.9", "@storybook/addon-storysource": "^8.2.9", - "@storybook/addons": "^7.6.17", "@storybook/blocks": "^8.2.9", "@storybook/react": "^8.2.9", "@storybook/react-vite": "^8.2.9", diff --git a/packages/calendar/src/components/calendar/CalendarMonth.tsx b/packages/calendar/src/components/calendar/CalendarMonth.tsx index 169fff1b5..3fbfe9e24 100644 --- a/packages/calendar/src/components/calendar/CalendarMonth.tsx +++ b/packages/calendar/src/components/calendar/CalendarMonth.tsx @@ -1,5 +1,6 @@ import { Box, Row, Text } from "@stenajs-webui/core"; import * as React from "react"; +import { ReactNode } from "react"; import { CalendarDayProps, CalendarOnClicks, @@ -21,7 +22,6 @@ import { CalendarDay } from "./renderers/CalendarDay"; import { FlatButton, stenaAngleDown } from "@stenajs-webui/elements"; import { WeekNumberCell } from "./renderers/WeekNumberCell"; import { DisabledDayWrapper } from "./DisabledDayWrapper"; -import { ReactNode } from "react"; export interface CalendarMonthProps extends CalendarOnClicks, @@ -106,48 +106,46 @@ export function CalendarMonth({ ))} {month.weeks.map((week: WeekData) => ( - <> - - {showWeekNumber && ( - - {renderWeekNumber ? ( - renderWeekNumber(week, theme, onClickWeek) - ) : ( - - )} - - )} - {week.days.map((day) => ( - - ))} - - + + {showWeekNumber && ( + + {renderWeekNumber ? ( + renderWeekNumber(week, theme, onClickWeek) + ) : ( + + )} + + )} + {week.days.map((day) => ( + + ))} + ))} diff --git a/packages/calendar/src/components/input-types/date-input/DateInput.tsx b/packages/calendar/src/components/input-types/date-input/DateInput.tsx index f9c6bc55b..02415e6ae 100644 --- a/packages/calendar/src/components/input-types/date-input/DateInput.tsx +++ b/packages/calendar/src/components/input-types/date-input/DateInput.tsx @@ -1,11 +1,10 @@ import { Box } from "@stenajs-webui/core"; import { stenaCalendar, TextInputButton } from "@stenajs-webui/elements"; import { TextInput, TextInputProps } from "@stenajs-webui/forms"; -import { Popover } from "@stenajs-webui/tooltip"; +import { ControlledPopover } from "@stenajs-webui/tooltip"; import { format } from "date-fns"; import * as React from "react"; import { defaultPopoverPlacement } from "../../../config/DefaultPopoverPlacement"; -import { useCalendarPopoverUpdater } from "../../../features/internal-panel-state/UseCalendarPopoverUpdater"; import { DateFormats } from "../../../util/date/DateFormats"; import { SingleDateCalendar } from "../../calendar-types/single-date-calendar/SingleDateCalendar"; import { @@ -42,16 +41,6 @@ export interface DateInputProps /** * Portal target, HTML element. If not set, portal is not used. */ - portalTarget?: HTMLElement | null; - /** - * Z-index of the calendar overlay. - * @default 100 - */ - zIndex?: number; - /** - * Width of the input element. - * * @default 125px - */ width?: string; /** * The calendar theme to use. @@ -69,13 +58,11 @@ export const DateInput: React.FC = ({ displayFormat = DateFormats.fullDate, placeholder = "Enter date", value, - zIndex = 100, calendarTheme = defaultCalendarTheme, calendarProps, openOnMount, onClose, onChange, - portalTarget, variant, width, minDate, @@ -85,48 +72,42 @@ export const DateInput: React.FC = ({ const { hideCalendar, showingCalendar, onSelectDate, showCalendar } = useDateInput(onChange, onClose, openOnMount); - const { tippyRef, onChangePanel } = useCalendarPopoverUpdater(); - return ( - ( + + + } + value={value ? format(value, displayFormat) : ""} + placeholder={placeholder} + size={9} + disabled={disabled} + autoFocus={openOnMount} + variant={variant} + min={minDate} + max={maxDate} + /> + + )} placement={defaultPopoverPlacement} - zIndex={zIndex} - appendTo={portalTarget ?? "parent"} - tippyRef={tippyRef} - disabled={disabled} - content={ - - } > - - } - value={value ? format(value, displayFormat) : ""} - placeholder={placeholder} - size={9} - disabled={disabled} - autoFocus={openOnMount} - variant={variant} - min={minDate} - max={maxDate} + - + ); }; diff --git a/packages/calendar/src/components/input-types/date-range-dual-text-input/DateRangeDualTextInput.tsx b/packages/calendar/src/components/input-types/date-range-dual-text-input/DateRangeDualTextInput.tsx index 940f9e249..19a8aba0b 100644 --- a/packages/calendar/src/components/input-types/date-range-dual-text-input/DateRangeDualTextInput.tsx +++ b/packages/calendar/src/components/input-types/date-range-dual-text-input/DateRangeDualTextInput.tsx @@ -1,10 +1,10 @@ -import { Box, useDelayedFalse } from "@stenajs-webui/core"; +import { Box } from "@stenajs-webui/core"; import { stenaArrowRight } from "@stenajs-webui/elements"; import { TextInputProps, ValueAndOnValueChangeProps, } from "@stenajs-webui/forms"; -import { Popover } from "@stenajs-webui/tooltip"; +import { ControlledPopover } from "@stenajs-webui/tooltip"; import { isAfter } from "date-fns"; import * as React from "react"; import { useMemo, useRef } from "react"; @@ -115,63 +115,61 @@ export function DateRangeDualTextInput({ [calendarProps?.statePerMonth, startDate, endDate, dateInFocus] ); - const delayedIsCalendarVisible = useDelayedFalse(isCalendarVisible, 300); - return ( - ( + + - ) - } + + )} + placement={defaultPopoverPlacement} + onRequestClose={hideCalendar} + open={isCalendarVisible} > - - + ); } diff --git a/packages/calendar/src/components/input-types/date-range-input/DateRangeInput.tsx b/packages/calendar/src/components/input-types/date-range-input/DateRangeInput.tsx index fe826d65b..dc63c7f31 100644 --- a/packages/calendar/src/components/input-types/date-range-input/DateRangeInput.tsx +++ b/packages/calendar/src/components/input-types/date-range-input/DateRangeInput.tsx @@ -19,7 +19,7 @@ import { } from "@stenajs-webui/elements"; import { CalendarWithMonthSwitcher } from "../../../features/month-switcher/CalendarWithMonthSwitcher"; import { CalendarPanelType } from "../../../features/calendar-with-month-year-pickers/CalendarPanelType"; -import { Popover } from "@stenajs-webui/tooltip"; +import { ControlledPopover } from "@stenajs-webui/tooltip"; import { buildDayStateForDateRange } from "../../../util/calendar/StateModifier"; import { OptionalMinMaxDatesAsString } from "../../../types/CalendarTypes"; import { DateRange } from "../../../types/DateRange"; @@ -45,16 +45,6 @@ export interface DateRangeInputProps * @default End date */ placeholderEndDate?: string; - /** - * Portal target, HTML element. If not set, portal is not used. - */ - portalTarget?: HTMLElement | null; - - /** - * Z-index of the calendar overlay. - * @default 100 - */ - zIndex?: number; /** * Width of the input element. @@ -83,10 +73,8 @@ export function DateRangeInput({ displayFormat = DateFormats.fullDate, placeholderStartDate = "Start date", placeholderEndDate = "End date", - portalTarget, value, onValueChange, - zIndex = 100, width, calendarTheme = defaultCalendarTheme, calendarProps, @@ -119,61 +107,59 @@ export function DateRangeInput({ ); return ( - ( + + + + + + + + )} + open={showingCalendar} placement={defaultPopoverPlacement} - appendTo={portalTarget ?? "parent"} - onClickOutside={hideCalendar} - content={ - - } + onRequestClose={hideCalendar} > - - - - - - - - + + ); } diff --git a/packages/calendar/src/components/input-types/date-text-input/DateTextInput.tsx b/packages/calendar/src/components/input-types/date-text-input/DateTextInput.tsx index fd83cce61..91373950a 100644 --- a/packages/calendar/src/components/input-types/date-text-input/DateTextInput.tsx +++ b/packages/calendar/src/components/input-types/date-text-input/DateTextInput.tsx @@ -1,12 +1,11 @@ import { Box, Omit, Row } from "@stenajs-webui/core"; import { FlatButton, stenaCalendar } from "@stenajs-webui/elements"; import { TextInput, TextInputProps } from "@stenajs-webui/forms"; -import { Popover } from "@stenajs-webui/tooltip"; +import { ControlledPopover } from "@stenajs-webui/tooltip"; import { format, isValid, parse } from "date-fns"; import * as React from "react"; import { useCallback, useState } from "react"; import { defaultPopoverPlacement } from "../../../config/DefaultPopoverPlacement"; -import { useCalendarPopoverUpdater } from "../../../features/internal-panel-state/UseCalendarPopoverUpdater"; import { DateFormats } from "../../../util/date/DateFormats"; import { SingleDateCalendar, @@ -39,10 +38,6 @@ export interface DateTextInputProps hideCalenderIcon?: boolean; /** Placeholder for the input, @default YYYY-MM-DD */ placeholder?: string; - /** Portal target, HTML element. If not set, portal is not used. */ - portalTarget?: HTMLElement | null; - /** Z-index of the calendar overlay, @default 100 */ - zIndex?: number; /** The date text input theme to use. */ calendarTheme?: CalendarTheme; } @@ -54,10 +49,8 @@ export const DateTextInput: React.FC> = ({ disableCalender = false, onValueChange, placeholder = "yyyy-mm-dd", - portalTarget, value, width = "130px", - zIndex = 100, calendarTheme = defaultCalendarTheme, hideCalenderIcon = false, minDate, @@ -66,7 +59,6 @@ export const DateTextInput: React.FC> = ({ ...props }) => { const [open, setOpen] = useState(false); - const { tippyRef, onChangePanel } = useCalendarPopoverUpdater(); const toggleCalendar = useCallback(() => { setOpen(!open); @@ -108,55 +100,51 @@ export const DateTextInput: React.FC> = ({ return ( - ( + + + + ) : undefined } - minDate={minDate} - maxDate={maxDate} - theme={calendarTheme} + onValueChange={onValueChangeHandler} + placeholder={placeholder} + value={value || ""} + min={minDate} + max={maxDate} + size={10} + {...popoverProps} /> - } + )} + hideArrow + open={open} + placement={defaultPopoverPlacement} + onRequestClose={hideCalendar} > - - - - ) : undefined + - + ); }; diff --git a/packages/calendar/src/components/input-types/date-time-input/DateTimeInput.tsx b/packages/calendar/src/components/input-types/date-time-input/DateTimeInput.tsx index bc8925a13..b13448072 100644 --- a/packages/calendar/src/components/input-types/date-time-input/DateTimeInput.tsx +++ b/packages/calendar/src/components/input-types/date-time-input/DateTimeInput.tsx @@ -1,10 +1,10 @@ import { Box, Column, Row, Space, useDelayedFalse } from "@stenajs-webui/core"; -import { PrimaryButton } from "@stenajs-webui/elements"; +import { PrimaryButton, stenaClock } from "@stenajs-webui/elements"; import { TextInputProps, ValueAndOnValueChangeProps, } from "@stenajs-webui/forms"; -import { Popover } from "@stenajs-webui/tooltip"; +import { ControlledPopover } from "@stenajs-webui/tooltip"; import * as React from "react"; import { useCallback, useMemo, useRef } from "react"; import { defaultPopoverPlacement } from "../../../config/DefaultPopoverPlacement"; @@ -22,7 +22,6 @@ import { useInputStates } from "./hooks/UseInputStates"; import { useUserInputHandlers } from "./hooks/UseUserInputHandlers"; import { OptionalMinMaxDatesAsString } from "../../../types/CalendarTypes"; import { defaultMaxDate } from "../../../config/DefaultMaxDate"; -import { stenaClock } from "@stenajs-webui/elements"; export interface DateTimeInputProps extends ValueAndOnValueChangeProps, @@ -118,74 +117,74 @@ export const DateTimeInput: React.FC = ({ return ( - ( + + + + )} placement={defaultPopoverPlacement} - visible={isCalendarVisible || isTimePickerVisible} - onClickOutside={hideAll} - content={ - (delayedIsCalendarVisible || delayedIsTimePickerVisible) && ( - - {delayedIsCalendarVisible ? ( - - ) : delayedIsTimePickerVisible ? ( - - - - - - - - - - ) : null} - - ) - } + open={isCalendarVisible || isTimePickerVisible} + onRequestClose={hideAll} > - - + {(delayedIsCalendarVisible || delayedIsTimePickerVisible) && ( + + {delayedIsCalendarVisible ? ( + + ) : delayedIsTimePickerVisible ? ( + + + + + + + + + + ) : null} + + )} + ); }; diff --git a/packages/calendar/src/config/DefaultPopoverPlacement.ts b/packages/calendar/src/config/DefaultPopoverPlacement.ts index f19d603e4..052e62640 100644 --- a/packages/calendar/src/config/DefaultPopoverPlacement.ts +++ b/packages/calendar/src/config/DefaultPopoverPlacement.ts @@ -1,3 +1 @@ -import { PopoverPlacement } from "@stenajs-webui/tooltip"; - -export const defaultPopoverPlacement: PopoverPlacement = "bottom"; +export const defaultPopoverPlacement = "bottom"; diff --git a/packages/calendar/src/features/internal-panel-state/UseCalendarPopoverUpdater.ts b/packages/calendar/src/features/internal-panel-state/UseCalendarPopoverUpdater.ts deleted file mode 100644 index 75646f6ae..000000000 --- a/packages/calendar/src/features/internal-panel-state/UseCalendarPopoverUpdater.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { useTippyInstance } from "@stenajs-webui/tooltip"; -import { useCallback } from "react"; - -export const useCalendarPopoverUpdater = () => { - const [tippyRef, tippyInstanceRef] = useTippyInstance(); - - const onChangePanel = useCallback(() => { - tippyInstanceRef.current?.popperInstance?.update(); - }, [tippyInstanceRef]); - - return { - onChangePanel, - tippyRef, - }; -}; diff --git a/packages/grid/src/features/standard-table/components/StandardTable.tsx b/packages/grid/src/features/standard-table/components/StandardTable.tsx index 96d6e142a..b10fbc781 100644 --- a/packages/grid/src/features/standard-table/components/StandardTable.tsx +++ b/packages/grid/src/features/standard-table/components/StandardTable.tsx @@ -39,7 +39,6 @@ import { ColGroups } from "./ColGroups"; import styles from "./StandardTable.module.css"; import { StandardTableContent } from "./StandardTableContent"; import { StandardTableHeadRow } from "./StandardTableHeadRow"; -import { TableHeadProps } from "../../table-ui/components/table/TableHeadItem"; export interface StandardTableProps< TItem extends object, @@ -76,12 +75,6 @@ export interface StandardTableProps< */ config: StandardTableConfig; - /** - * Append tooltip to HTML element. This prop is passed to Tippy. - * This is useful to solve z-index problems. - */ - appendTooltipTo?: TableHeadProps["appendTooltipTo"]; - /** * Items to list in the table. */ @@ -182,7 +175,6 @@ export const StandardTable = function StandardTable< variant = "standard", onKeyDown, onSortOrderChange, - appendTooltipTo, ...props }: StandardTableProps) { const generatedTableId = useId(); @@ -320,7 +312,6 @@ export const StandardTable = function StandardTable< diff --git a/packages/grid/src/features/standard-table/components/StandardTableHeadRow.tsx b/packages/grid/src/features/standard-table/components/StandardTableHeadRow.tsx index a8949d9e5..1b727a54a 100644 --- a/packages/grid/src/features/standard-table/components/StandardTableHeadRow.tsx +++ b/packages/grid/src/features/standard-table/components/StandardTableHeadRow.tsx @@ -19,12 +19,10 @@ import { useStandardTableConfig } from "../hooks/UseStandardTableConfig"; import { getCellBorderFromGroup } from "../util/CellBorderCalculator"; import { StandardTableHeadItem } from "./StandardTableHeadItem"; import { TrWithHoverBackground } from "./TrWithHoverBackground"; -import { TableHeadProps } from "../../table-ui/components/table/TableHeadItem"; interface StandardTableHeaderProps { items?: Array; height?: string; - appendTooltipTo?: TableHeadProps["appendTooltipTo"]; } const getTopPosition = ( @@ -47,11 +45,7 @@ const getTopPosition = ( export const StandardTableHeadRow = React.memo(function StandardTableHeadRow< TItem ->({ - items, - appendTooltipTo, - height = defaultTableRowHeight, -}: StandardTableHeaderProps) { +>({ items, height = defaultTableRowHeight }: StandardTableHeaderProps) { const groupConfigsAndIds = useGroupConfigsAndIdsForRows(); const { @@ -181,7 +175,6 @@ export const StandardTableHeadRow = React.memo(function StandardTableHeadRow< disableBorderLeft={groupIndex === 0 && index === 0} stickyHeader={stickyHeader} top={stickyHeaderStyle.top} - appendTooltipTo={appendTooltipTo} /> ); })} diff --git a/packages/grid/src/features/standard-table/features/column-groups/ColumnInGroup.tsx b/packages/grid/src/features/standard-table/features/column-groups/ColumnInGroup.tsx index fc6a5631e..a1b626f01 100644 --- a/packages/grid/src/features/standard-table/features/column-groups/ColumnInGroup.tsx +++ b/packages/grid/src/features/standard-table/features/column-groups/ColumnInGroup.tsx @@ -110,11 +110,7 @@ export const ColumnInGroup = function ColumnGroupColumnItem< {loading ? ( ) : error ? ( - + = ({ crudStatus }) => { ); return ( <> - {errorMessage ? ( - - {icon} - - ) : ( - icon - )} + {errorMessage ? {icon} : icon} ); } diff --git a/packages/grid/src/features/table-ui/components/ModifiedField.tsx b/packages/grid/src/features/table-ui/components/ModifiedField.tsx index f8412f54d..7a5869128 100644 --- a/packages/grid/src/features/table-ui/components/ModifiedField.tsx +++ b/packages/grid/src/features/table-ui/components/ModifiedField.tsx @@ -55,7 +55,7 @@ export const ModifiedField: React.FC = ({ )} {hasRightIcon && } {showEmptyFieldWarning ? ( - + + void; selected?: boolean; alignRight?: boolean; sortOrderIconVariant?: SortOrderIconVariant; - appendTooltipTo?: TooltipProps["appendTo"]; } export const TableHeadItem: React.FC = React.memo( @@ -47,7 +41,6 @@ export const TableHeadItem: React.FC = React.memo( overflow = "hidden", alignRight, sortOrderIconVariant, - appendTooltipTo, ...boxProps }) => { const containerRef = useRef(null); @@ -120,13 +113,7 @@ export const TableHeadItem: React.FC = React.memo( <> ev.stopPropagation()}> - + = React.memo( ) : popoverContent ? ( ( + + )} trigger={"click"} - zIndex={1000} disablePadding > - + {popoverContent} ) : null} diff --git a/packages/panels/src/components/action-menu-button/ActionMenuButton.tsx b/packages/panels/src/components/action-menu-button/ActionMenuButton.tsx index 3759a32f1..0cc0140e2 100644 --- a/packages/panels/src/components/action-menu-button/ActionMenuButton.tsx +++ b/packages/panels/src/components/action-menu-button/ActionMenuButton.tsx @@ -11,8 +11,7 @@ import { stenaAngleDown, } from "@stenajs-webui/elements"; import { useBoolean } from "@stenajs-webui/core"; -import { Popover, PopoverProps } from "@stenajs-webui/tooltip"; -import { Plugin as TippyPlugin, Props as TippyProps } from "tippy.js"; +import { ControlledPopover, PopoverProps } from "@stenajs-webui/tooltip"; export interface ActionMenuButtonProps extends Omit< @@ -23,10 +22,6 @@ export interface ActionMenuButtonProps renderItems: (close: () => void) => ReactNode; /** The placement of the Action Menu. */ placement?: PopoverProps["placement"]; - /** Z-index of the Action Menu */ - zIndex?: number; - /** Portal target, HTML element. If not set, portal is not used. */ - portalTarget?: PopoverProps["appendTo"]; menuWidth?: ActionMenuProps["width"]; menuTop?: ActionMenuProps["top"]; buttonComponent: @@ -42,8 +37,6 @@ export const ActionMenuButton: React.FC = ({ placement = "bottom", buttonComponent: Button, rightIcon = stenaAngleDown, - portalTarget = "parent", - zIndex, menuWidth, menuTop, onClick, @@ -56,44 +49,6 @@ export const ActionMenuButton: React.FC = ({ const fallbackRef = useRef(null); const ref = buttonRef ?? fallbackRef; - const focusManager: TippyPlugin = { - name: "focusManager", - defaultValue: true, - fn({ popper }) { - let restoreFocus = false; - - const closeOnEscape = (event: KeyboardEvent) => { - if (event.key === "Escape") { - restoreFocus = true; - close(); - } - if (event.key === "Enter" || event.key === " ") { - restoreFocus = true; - } - }; - - return { - onCreate() { - popper.addEventListener("keydown", closeOnEscape); - }, - onDestroy() { - popper.removeEventListener("keydown", closeOnEscape); - }, - onMount() { - restoreFocus = false; - popper - .querySelector("button:not([disabled]), a[href]") - ?.focus(); - }, - onHide() { - if (ref.current && restoreFocus) { - ref.current.focus(); - } - }, - }; - }, - }; - const contextValue = useMemo(() => ({ open, close }), [open, close]); const handleClick = ( @@ -105,33 +60,30 @@ export const ActionMenuButton: React.FC = ({ return ( <> -