@economic/taco 14.0.0 → 14.1.0-EC-85807-code-report-fixes.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/charts/components/Area/AreaChart.cjs.map +1 -1
- package/dist/charts/components/Area/AreaChart.d.ts +1 -1
- package/dist/charts/components/Area/AreaChart.js.map +1 -1
- package/dist/charts/components/Bar/BarChart.cjs +2 -2
- package/dist/charts/components/Bar/BarChart.cjs.map +1 -1
- package/dist/charts/components/Bar/BarChart.d.ts +1 -1
- package/dist/charts/components/Bar/BarChart.js +2 -2
- package/dist/charts/components/Bar/BarChart.js.map +1 -1
- package/dist/charts/components/ChartWrapper.cjs.map +1 -1
- package/dist/charts/components/ChartWrapper.js.map +1 -1
- package/dist/charts/components/Composed/BarLineChart.cjs.map +1 -1
- package/dist/charts/components/Composed/BarLineChart.d.ts +2 -2
- package/dist/charts/components/Composed/BarLineChart.js.map +1 -1
- package/dist/charts/components/Donut/DonutChart.cjs.map +1 -1
- package/dist/charts/components/Donut/DonutChart.d.ts +1 -1
- package/dist/charts/components/Donut/DonutChart.js.map +1 -1
- package/dist/charts/components/LegacyDonut/ActiveShape.cjs +7 -5
- package/dist/charts/components/LegacyDonut/ActiveShape.cjs.map +1 -1
- package/dist/charts/components/LegacyDonut/ActiveShape.d.ts +6 -3
- package/dist/charts/components/LegacyDonut/ActiveShape.js +7 -5
- package/dist/charts/components/LegacyDonut/ActiveShape.js.map +1 -1
- package/dist/charts/components/LegacyDonut/CenteredLabel.cjs +1 -1
- package/dist/charts/components/LegacyDonut/CenteredLabel.cjs.map +1 -1
- package/dist/charts/components/LegacyDonut/CenteredLabel.js +1 -1
- package/dist/charts/components/LegacyDonut/CenteredLabel.js.map +1 -1
- package/dist/charts/components/LegacyDonut/LegacyDonutChart.cjs +119 -103
- package/dist/charts/components/LegacyDonut/LegacyDonutChart.cjs.map +1 -1
- package/dist/charts/components/LegacyDonut/LegacyDonutChart.d.ts +13 -2
- package/dist/charts/components/LegacyDonut/LegacyDonutChart.js +119 -103
- package/dist/charts/components/LegacyDonut/LegacyDonutChart.js.map +1 -1
- package/dist/charts/components/LegacyDonut/Legend.cjs +1 -1
- package/dist/charts/components/LegacyDonut/Legend.cjs.map +1 -1
- package/dist/charts/components/LegacyDonut/Legend.js +1 -1
- package/dist/charts/components/LegacyDonut/Legend.js.map +1 -1
- package/dist/charts/components/Legend.cjs +1 -1
- package/dist/charts/components/Legend.cjs.map +1 -1
- package/dist/charts/components/Legend.js +1 -1
- package/dist/charts/components/Legend.js.map +1 -1
- package/dist/charts/components/Line/LineChart.cjs.map +1 -1
- package/dist/charts/components/Line/LineChart.d.ts +3 -2
- package/dist/charts/components/Line/LineChart.js.map +1 -1
- package/dist/charts/components/Pie/PieChart.cjs +4 -4
- package/dist/charts/components/Pie/PieChart.cjs.map +1 -1
- package/dist/charts/components/Pie/PieChart.js +4 -4
- package/dist/charts/components/Pie/PieChart.js.map +1 -1
- package/dist/charts/components/Pie/util.cjs.map +1 -1
- package/dist/charts/components/Pie/util.d.ts +2 -1
- package/dist/charts/components/Pie/util.js.map +1 -1
- package/dist/charts/components/Tooltip.cjs.map +1 -1
- package/dist/charts/components/Tooltip.d.ts +2 -3
- package/dist/charts/components/Tooltip.js.map +1 -1
- package/dist/charts/components/types.d.ts +9 -5
- package/dist/charts/components/useChartData.cjs +5 -3
- package/dist/charts/components/useChartData.cjs.map +1 -1
- package/dist/charts/components/useChartData.d.ts +6 -2
- package/dist/charts/components/useChartData.js +5 -3
- package/dist/charts/components/useChartData.js.map +1 -1
- package/dist/charts/utils/color.cjs +6 -10
- package/dist/charts/utils/color.cjs.map +1 -1
- package/dist/charts/utils/color.js +6 -10
- package/dist/charts/utils/color.js.map +1 -1
- package/dist/charts/utils/common.cjs +10 -10
- package/dist/charts/utils/common.cjs.map +1 -1
- package/dist/charts/utils/common.d.ts +5 -6
- package/dist/charts/utils/common.js +10 -10
- package/dist/charts/utils/common.js.map +1 -1
- package/dist/components/AlertDialog/Context.cjs.map +1 -1
- package/dist/components/AlertDialog/Context.d.ts +1 -1
- package/dist/components/AlertDialog/Context.js.map +1 -1
- package/dist/components/Calendar/Calendar.cjs.map +1 -1
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Combobox/Combobox.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/Combobox/useCombobox.cjs +2 -4
- package/dist/components/Combobox/useCombobox.cjs.map +1 -1
- package/dist/components/Combobox/useCombobox.d.ts +1 -1
- package/dist/components/Combobox/useCombobox.js +2 -4
- package/dist/components/Combobox/useCombobox.js.map +1 -1
- package/dist/components/Datepicker/useDatepicker.cjs.map +1 -1
- package/dist/components/Datepicker/useDatepicker.js.map +1 -1
- package/dist/components/Dialog/Context.cjs.map +1 -1
- package/dist/components/Dialog/Context.d.ts +1 -1
- package/dist/components/Dialog/Context.js.map +1 -1
- package/dist/components/Dialog/components/Content.cjs.map +1 -1
- package/dist/components/Dialog/components/Content.js.map +1 -1
- package/dist/components/Drawer/components/Content.cjs +1 -1
- package/dist/components/Drawer/components/Content.cjs.map +1 -1
- package/dist/components/Drawer/components/Content.js +1 -1
- package/dist/components/Drawer/components/Content.js.map +1 -1
- package/dist/components/Drawer/useDrawerStack.cjs.map +1 -1
- package/dist/components/Drawer/useDrawerStack.js.map +1 -1
- package/dist/components/Hanger/Hanger.cjs.map +1 -1
- package/dist/components/Hanger/Hanger.js.map +1 -1
- package/dist/components/Header/Header.cjs +1 -1
- package/dist/components/Header/Header.cjs.map +1 -1
- package/dist/components/Header/Header.js +1 -1
- package/dist/components/Header/Header.js.map +1 -1
- package/dist/components/Header/components/PrimaryNavigation.cjs.map +1 -1
- package/dist/components/Header/components/PrimaryNavigation.js.map +1 -1
- package/dist/components/Icon/Icon.cjs.map +1 -1
- package/dist/components/Icon/Icon.js.map +1 -1
- package/dist/components/Layout/components/Sidebar.cjs +2 -1
- package/dist/components/Layout/components/Sidebar.cjs.map +1 -1
- package/dist/components/Layout/components/Sidebar.js +2 -1
- package/dist/components/Layout/components/Sidebar.js.map +1 -1
- package/dist/components/LegacyComponents/IconButton/IconButton.cjs.map +1 -1
- package/dist/components/LegacyComponents/IconButton/IconButton.js.map +1 -1
- package/dist/components/List/components/Toggle.cjs +0 -2
- package/dist/components/List/components/Toggle.cjs.map +1 -1
- package/dist/components/List/components/Toggle.js +0 -2
- package/dist/components/List/components/Toggle.js.map +1 -1
- package/dist/components/Listbox/Listbox.cjs +2 -5
- package/dist/components/Listbox/Listbox.cjs.map +1 -1
- package/dist/components/Listbox/Listbox.js +2 -5
- package/dist/components/Listbox/Listbox.js.map +1 -1
- package/dist/components/Listbox/useListbox.cjs +1 -1
- package/dist/components/Listbox/useListbox.cjs.map +1 -1
- package/dist/components/Listbox/useListbox.js +1 -1
- package/dist/components/Listbox/useListbox.js.map +1 -1
- package/dist/components/Listbox/useMultiListbox.cjs +1 -1
- package/dist/components/Listbox/useMultiListbox.cjs.map +1 -1
- package/dist/components/Listbox/useMultiListbox.js +1 -1
- package/dist/components/Listbox/useMultiListbox.js.map +1 -1
- package/dist/components/Listbox/util.cjs.map +1 -1
- package/dist/components/Listbox/util.js.map +1 -1
- package/dist/components/Menu/components/Content.cjs.map +1 -1
- package/dist/components/Menu/components/Content.js.map +1 -1
- package/dist/components/Menu/components/Item.cjs.map +1 -1
- package/dist/components/Menu/components/Item.d.ts +2 -2
- package/dist/components/Menu/components/Item.js.map +1 -1
- package/dist/components/Menu/components/Trigger.cjs +1 -5
- package/dist/components/Menu/components/Trigger.cjs.map +1 -1
- package/dist/components/Menu/components/Trigger.js +1 -5
- package/dist/components/Menu/components/Trigger.js.map +1 -1
- package/dist/components/Pagination/usePaginationShortcuts.cjs +0 -1
- package/dist/components/Pagination/usePaginationShortcuts.cjs.map +1 -1
- package/dist/components/Pagination/usePaginationShortcuts.js +0 -1
- package/dist/components/Pagination/usePaginationShortcuts.js.map +1 -1
- package/dist/components/Provider/Provider.cjs.map +1 -1
- package/dist/components/Provider/Provider.d.ts +1 -1
- package/dist/components/Provider/Provider.js.map +1 -1
- package/dist/components/SearchInput/SearchInput.cjs +0 -1
- package/dist/components/SearchInput/SearchInput.cjs.map +1 -1
- package/dist/components/SearchInput/SearchInput.js +0 -1
- package/dist/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/components/SearchInput2/SearchInput2.cjs +0 -1
- package/dist/components/SearchInput2/SearchInput2.cjs.map +1 -1
- package/dist/components/SearchInput2/SearchInput2.js +0 -1
- package/dist/components/SearchInput2/SearchInput2.js.map +1 -1
- package/dist/components/Select2/Select2.cjs +6 -7
- package/dist/components/Select2/Select2.cjs.map +1 -1
- package/dist/components/Select2/Select2.js +6 -7
- package/dist/components/Select2/Select2.js.map +1 -1
- package/dist/components/Select2/components/Search.cjs +0 -1
- package/dist/components/Select2/components/Search.cjs.map +1 -1
- package/dist/components/Select2/components/Search.js +0 -1
- package/dist/components/Select2/components/Search.js.map +1 -1
- package/dist/components/Select2/components/Trigger.cjs +1 -1
- package/dist/components/Select2/components/Trigger.cjs.map +1 -1
- package/dist/components/Select2/components/Trigger.js +1 -1
- package/dist/components/Select2/components/Trigger.js.map +1 -1
- package/dist/components/Table3/components/Columns/Cell/EditingControlCell.cjs +1 -1
- package/dist/components/Table3/components/Columns/Cell/EditingControlCell.cjs.map +1 -1
- package/dist/components/Table3/components/Columns/Cell/EditingControlCell.js +1 -1
- package/dist/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/components/Table3/components/Columns/Cell/util.cjs.map +1 -1
- package/dist/components/Table3/components/Columns/Cell/util.js.map +1 -1
- package/dist/components/Table3/components/Editing/Alert.cjs +4 -4
- package/dist/components/Table3/components/Editing/Alert.cjs.map +1 -1
- package/dist/components/Table3/components/Editing/Alert.js +4 -4
- package/dist/components/Table3/components/Editing/Alert.js.map +1 -1
- package/dist/components/Table3/features/useEditingState.cjs +1 -1
- package/dist/components/Table3/features/useEditingState.cjs.map +1 -1
- package/dist/components/Table3/features/useEditingState.js +1 -1
- package/dist/components/Table3/features/useEditingState.js.map +1 -1
- package/dist/components/Table3/types.d.ts +2 -2
- package/dist/components/Table3/useTable3.cjs +8 -6
- package/dist/components/Table3/useTable3.cjs.map +1 -1
- package/dist/components/Table3/useTable3.js +8 -6
- package/dist/components/Table3/useTable3.js.map +1 -1
- package/dist/components/Table3/util/editing.cjs +1 -1
- package/dist/components/Table3/util/editing.cjs.map +1 -1
- package/dist/components/Table3/util/editing.d.ts +1 -1
- package/dist/components/Table3/util/editing.js +1 -1
- package/dist/components/Table3/util/editing.js.map +1 -1
- package/dist/hooks/useBoundaryOverflowDetection.cjs.map +1 -1
- package/dist/hooks/useBoundaryOverflowDetection.d.ts +1 -1
- package/dist/hooks/useBoundaryOverflowDetection.js.map +1 -1
- package/dist/hooks/useBoundingClientRectListener.cjs.map +1 -1
- package/dist/hooks/useBoundingClientRectListener.d.ts +1 -1
- package/dist/hooks/useBoundingClientRectListener.js.map +1 -1
- package/dist/hooks/useControlled.cjs +6 -10
- package/dist/hooks/useControlled.cjs.map +1 -1
- package/dist/hooks/useControlled.js +6 -10
- package/dist/hooks/useControlled.js.map +1 -1
- package/dist/hooks/useIsFormControl.cjs.map +1 -1
- package/dist/hooks/useIsFormControl.d.ts +1 -1
- package/dist/hooks/useIsFormControl.js.map +1 -1
- package/dist/hooks/useMergedRef.cjs.map +1 -1
- package/dist/hooks/useMergedRef.js.map +1 -1
- package/dist/hooks/usePrevious.cjs.map +1 -1
- package/dist/hooks/usePrevious.js.map +1 -1
- package/dist/primitives/Button.cjs.map +1 -1
- package/dist/primitives/Button.js.map +1 -1
- package/dist/primitives/Collection/components/Root.cjs +9 -16
- package/dist/primitives/Collection/components/Root.cjs.map +1 -1
- package/dist/primitives/Collection/components/Root.js +9 -16
- package/dist/primitives/Collection/components/Root.js.map +1 -1
- package/dist/primitives/Listbox2/components/Context.cjs.map +1 -1
- package/dist/primitives/Listbox2/components/Context.d.ts +1 -0
- package/dist/primitives/Listbox2/components/Context.js.map +1 -1
- package/dist/primitives/Listbox2/components/Option.cjs +8 -2
- package/dist/primitives/Listbox2/components/Option.cjs.map +1 -1
- package/dist/primitives/Listbox2/components/Option.js +8 -2
- package/dist/primitives/Listbox2/components/Option.js.map +1 -1
- package/dist/primitives/Listbox2/components/Root.cjs +3 -2
- package/dist/primitives/Listbox2/components/Root.cjs.map +1 -1
- package/dist/primitives/Listbox2/components/Root.js +3 -2
- package/dist/primitives/Listbox2/components/Root.js.map +1 -1
- package/dist/primitives/Sortable/components/Item.cjs +2 -4
- package/dist/primitives/Sortable/components/Item.cjs.map +1 -1
- package/dist/primitives/Sortable/components/Item.js +2 -4
- package/dist/primitives/Sortable/components/Item.js.map +1 -1
- package/dist/primitives/Table/Core/components/Body/Body.cjs +4 -4
- package/dist/primitives/Table/Core/components/Body/Body.cjs.map +1 -1
- package/dist/primitives/Table/Core/components/Body/Body.js +4 -4
- package/dist/primitives/Table/Core/components/Body/Body.js.map +1 -1
- package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell.cjs.map +1 -1
- package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell.js.map +1 -1
- package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.cjs.map +1 -1
- package/dist/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
- package/dist/primitives/Table/Core/components/Columns/Cell/util.cjs +22 -16
- package/dist/primitives/Table/Core/components/Columns/Cell/util.cjs.map +1 -1
- package/dist/primitives/Table/Core/components/Columns/Cell/util.js +22 -16
- package/dist/primitives/Table/Core/components/Columns/Cell/util.js.map +1 -1
- package/dist/primitives/Table/Core/components/Footer/Summary.cjs.map +1 -1
- package/dist/primitives/Table/Core/components/Footer/Summary.js.map +1 -1
- package/dist/primitives/Table/Core/components/Header/util.cjs +4 -3
- package/dist/primitives/Table/Core/components/Header/util.cjs.map +1 -1
- package/dist/primitives/Table/Core/components/Header/util.js +4 -3
- package/dist/primitives/Table/Core/components/Header/util.js.map +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/Filters.cjs +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/Filters.cjs.map +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/Filters.js +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/Filters.js.map +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.cjs +4 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.cjs.map +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js +4 -2
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.cjs.map +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.js.map +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Print/Print.cjs +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Print/Print.cjs.map +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Print/Print.js +1 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
- package/dist/primitives/Table/Core/features/useTableRef.cjs +7 -0
- package/dist/primitives/Table/Core/features/useTableRef.cjs.map +1 -1
- package/dist/primitives/Table/Core/features/useTableRef.js +7 -0
- package/dist/primitives/Table/Core/features/useTableRef.js.map +1 -1
- package/dist/primitives/Table/Core/features/useTableRenderer.cjs +2 -2
- package/dist/primitives/Table/Core/features/useTableRenderer.cjs.map +1 -1
- package/dist/primitives/Table/Core/features/useTableRenderer.js +2 -2
- package/dist/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/primitives/Table/Core/features/useTableStyleColumnFreezing.cjs +2 -2
- package/dist/primitives/Table/Core/features/useTableStyleColumnFreezing.cjs.map +1 -1
- package/dist/primitives/Table/Core/features/useTableStyleColumnFreezing.js +2 -2
- package/dist/primitives/Table/Core/features/useTableStyleColumnFreezing.js.map +1 -1
- package/dist/primitives/Table/Core/features/useTableStyleGrid.cjs.map +1 -1
- package/dist/primitives/Table/Core/features/useTableStyleGrid.js.map +1 -1
- package/dist/primitives/Table/Core/listeners/useTableRowActiveListener.cjs +2 -4
- package/dist/primitives/Table/Core/listeners/useTableRowActiveListener.cjs.map +1 -1
- package/dist/primitives/Table/Core/listeners/useTableRowActiveListener.d.ts +2 -2
- package/dist/primitives/Table/Core/listeners/useTableRowActiveListener.js +2 -4
- package/dist/primitives/Table/Core/listeners/useTableRowActiveListener.js.map +1 -1
- package/dist/primitives/Table/types.cjs.map +1 -1
- package/dist/primitives/Table/types.d.ts +6 -0
- package/dist/primitives/Table/types.js.map +1 -1
- package/dist/primitives/Table/useTableDataLoader2.cjs +36 -3
- package/dist/primitives/Table/useTableDataLoader2.cjs.map +1 -1
- package/dist/primitives/Table/useTableDataLoader2.d.ts +2 -1
- package/dist/primitives/Table/useTableDataLoader2.js +36 -3
- package/dist/primitives/Table/useTableDataLoader2.js.map +1 -1
- package/dist/primitives/Table/useTableManager/features/useTableRowActive.cjs +0 -1
- package/dist/primitives/Table/useTableManager/features/useTableRowActive.cjs.map +1 -1
- package/dist/primitives/Table/useTableManager/features/useTableRowActive.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/features/useTableRowActive.js +0 -1
- package/dist/primitives/Table/useTableManager/features/useTableRowActive.js.map +1 -1
- package/dist/primitives/Table/useTableManager/features/useTableRowClick.cjs +0 -2
- package/dist/primitives/Table/useTableManager/features/useTableRowClick.cjs.map +1 -1
- package/dist/primitives/Table/useTableManager/features/useTableRowClick.js +0 -2
- package/dist/primitives/Table/useTableManager/features/useTableRowClick.js.map +1 -1
- package/dist/primitives/Table/useTableManager/features/useTableRowSelection.cjs +0 -1
- package/dist/primitives/Table/useTableManager/features/useTableRowSelection.cjs.map +1 -1
- package/dist/primitives/Table/useTableManager/features/useTableRowSelection.js +0 -1
- package/dist/primitives/Table/useTableManager/features/useTableRowSelection.js.map +1 -1
- package/dist/primitives/Table/useTableManager/features/useTableServerLoading.cjs +10 -1
- package/dist/primitives/Table/useTableManager/features/useTableServerLoading.cjs.map +1 -1
- package/dist/primitives/Table/useTableManager/features/useTableServerLoading.d.ts +3 -2
- package/dist/primitives/Table/useTableManager/features/useTableServerLoading.js +10 -1
- package/dist/primitives/Table/useTableManager/features/useTableServerLoading.js.map +1 -1
- package/dist/primitives/Table/useTableManager/useTableManager.cjs +1 -5
- package/dist/primitives/Table/useTableManager/useTableManager.cjs.map +1 -1
- package/dist/primitives/Table/useTableManager/useTableManager.js +1 -5
- package/dist/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/primitives/Table/useTableManager/util/dataTypes.cjs.map +1 -1
- package/dist/primitives/Table/useTableManager/util/dataTypes.d.ts +3 -3
- package/dist/primitives/Table/useTableManager/util/dataTypes.js.map +1 -1
- package/dist/primitives/Table/useTableManager/util/filtering.cjs.map +1 -1
- package/dist/primitives/Table/useTableManager/util/filtering.js.map +1 -1
- package/dist/primitives/Table/useTableManager/util/search.cjs +1 -1
- package/dist/primitives/Table/useTableManager/util/search.cjs.map +1 -1
- package/dist/primitives/Table/useTableManager/util/search.js +1 -1
- package/dist/primitives/Table/useTableManager/util/search.js.map +1 -1
- package/dist/primitives/Table/useTableManager/util/setup.cjs +3 -3
- package/dist/primitives/Table/useTableManager/util/setup.cjs.map +1 -1
- package/dist/primitives/Table/useTableManager/util/setup.js +3 -3
- package/dist/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/dataTypes.cjs +4 -4
- package/dist/utils/dataTypes.cjs.map +1 -1
- package/dist/utils/dataTypes.d.ts +1 -1
- package/dist/utils/dataTypes.js +4 -4
- package/dist/utils/dataTypes.js.map +1 -1
- package/dist/utils/date.cjs +14 -16
- package/dist/utils/date.cjs.map +1 -1
- package/dist/utils/date.js +14 -16
- package/dist/utils/date.js.map +1 -1
- package/dist/utils/debounce.cjs.map +1 -1
- package/dist/utils/debounce.d.ts +1 -1
- package/dist/utils/debounce.js.map +1 -1
- package/dist/utils/device.cjs +1 -1
- package/dist/utils/device.cjs.map +1 -1
- package/dist/utils/device.js +1 -1
- package/dist/utils/device.js.map +1 -1
- package/dist/utils/dom.cjs +1 -1
- package/dist/utils/dom.cjs.map +1 -1
- package/dist/utils/dom.d.ts +2 -2
- package/dist/utils/dom.js +1 -1
- package/dist/utils/dom.js.map +1 -1
- package/dist/utils/hooks/useDraggable.cjs.map +1 -1
- package/dist/utils/hooks/useDraggable.d.ts +9 -1
- package/dist/utils/hooks/useDraggable.js.map +1 -1
- package/dist/utils/hooks/useListKeyboardNavigation.cjs +1 -1
- package/dist/utils/hooks/useListKeyboardNavigation.cjs.map +1 -1
- package/dist/utils/hooks/useListKeyboardNavigation.js +1 -1
- package/dist/utils/hooks/useListKeyboardNavigation.js.map +1 -1
- package/dist/utils/hooks/useListScrollTo.cjs.map +1 -1
- package/dist/utils/hooks/useListScrollTo.d.ts +4 -1
- package/dist/utils/hooks/useListScrollTo.js.map +1 -1
- package/dist/utils/hooks/useOnClickOutside.cjs.map +1 -1
- package/dist/utils/hooks/useOnClickOutside.d.ts +1 -1
- package/dist/utils/hooks/useOnClickOutside.js.map +1 -1
- package/dist/utils/hooks/useTruncated.cjs.map +1 -1
- package/dist/utils/hooks/useTruncated.d.ts +2 -1
- package/dist/utils/hooks/useTruncated.js.map +1 -1
- package/dist/utils/mergeRefs.cjs.map +1 -1
- package/dist/utils/mergeRefs.d.ts +1 -1
- package/dist/utils/mergeRefs.js.map +1 -1
- package/dist/utils/storyutils.d.ts +1 -3
- package/package.json +4 -5
- package/plugins/tailwindcss-group-peer.js +1 -1
- package/scripts/stylelint-plugin/radius.mjs +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCombobox.js","sources":["../../../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["import debounce from 'lodash/debounce';\nimport { nanoid } from 'nanoid';\nimport * as React from 'react';\n\nimport type { InputProps } from '@/components';\nimport type {\n ScrollableListItem,\n ScrollableListItemValue,\n ScrollableListPropsWithRef,\n} from '@/components/Listbox/ScrollableList';\nimport { getId } from '@/components/Listbox/ScrollableList';\nimport {\n setInputValueByRef,\n getIndexFromValue,\n findByValue,\n useFlattenedData,\n sanitizeItem,\n getOptionParents,\n filterData,\n} from '@/components/Listbox/util';\nimport { useMergedRef } from '@/hooks/useMergedRef';\nimport { isElementInsideTable3OrReport } from '@/utils/dom';\nimport { createCustomKeyboardEvent } from '@/utils/input';\n\nimport type { ComboboxProps } from './Combobox';\n\nconst debouncer = debounce(f => f(), 200);\n\nconst defaultConvertToInputValue = (value: ScrollableListItemValue | undefined) => String(value ?? '');\n\ntype useCombobox = Omit<React.HTMLAttributes<HTMLDivElement>, 'popover'> & {\n combobox: React.HTMLAttributes<HTMLSpanElement>;\n input: Omit<InputProps, 'defaultValue'> & { ref: React.RefObject<HTMLInputElement> };\n list: ScrollableListPropsWithRef;\n button: { ref: any };\n popover: { open: boolean; onOpenChange: (open: boolean) => void };\n};\n\nexport const useCombobox = (props: Omit<ComboboxProps, 'dialog'>, ref: React.Ref<HTMLInputElement>): useCombobox => {\n const {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data: unfilteredData = [],\n defaultValue,\n disabled,\n id: _nativeId,\n inline,\n loading: __,\n onChange,\n onClick,\n onKeyDown,\n onSearch,\n readOnly,\n value,\n valueRenderer,\n ...otherProps\n } = props;\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n const [open, setOpen] = React.useState(false);\n const listId = React.useMemo(() => nanoid(), []);\n const flattenedData = useFlattenedData(unfilteredData);\n\n const convertToInputValue = React.useCallback(\n (val: ScrollableListItemValue | undefined): string => {\n const option = findByValue(flattenedData, val);\n if (typeof valueRenderer === 'function' && option) {\n return valueRenderer(option);\n }\n return defaultConvertToInputValue(val);\n },\n [valueRenderer, flattenedData]\n );\n\n const [inputValue, setInputValue] = React.useState<string>(convertToInputValue(value));\n const shouldFilterData = !onSearch && (!inline || (inline && inputValue !== convertToInputValue(value)));\n const data = React.useMemo(\n () => (shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData),\n [shouldFilterData, inputValue, flattenedData]\n );\n // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state\n const [currentIndex, setCurrentIndex] = React.useState<number | undefined>(\n inputValue === undefined ? undefined : getIndexFromValue(data, inputValue)\n );\n\n const setInputValueByIndex = (index: number | undefined, event?: string): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n const eventType = event ?? 'focusout';\n setInputValueByRef(inputRef.current, option.value, eventType);\n }\n }\n };\n\n const setCurrentValue = (index: number | undefined, event?: string) => {\n if (index === undefined) {\n return;\n }\n\n const option = data[index];\n\n if (option?.value === value) {\n // if the selected option is already selected, refill input with its value\n setInputValue(convertToInputValue(value));\n } else {\n // if the selected option is not already selected, trigger blur event\n setInputValueByIndex(index, event);\n }\n };\n\n // ensure the external value is synced with the internal value when mounting, e.g. incase a default value was set\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByIndex(getIndexFromValue(data, defaultValue));\n }\n }, [data]);\n\n // Sync input text when `value` changes externally, during render (not in an effect) so it's correct before the\n // \"show listbox\" effect below — otherwise a one-render stale-text window can open the popover on reset.\n const [prevValue, setPrevValue] = React.useState(value);\n if (value !== prevValue) {\n setPrevValue(value);\n\n if (value !== undefined) {\n // Compare rendered values to handle valueRenderer (e.g. \"1000\" renders as \"1000 - Account Name\").\n const renderedValue = convertToInputValue(value);\n if (renderedValue !== inputValue) {\n setInputValue(renderedValue);\n }\n } else if (prevValue !== undefined && inputValue === convertToInputValue(prevValue)) {\n // `value` was cleared externally and the input still shows its previous rendered text (not user-typed),\n // so clear it. Text the user typed never matches the previous render, so it's preserved.\n if (inputValue !== '') {\n setInputValue('');\n }\n }\n }\n\n React.useEffect(() => {\n if (onSearch) {\n debouncer(() => {\n onSearch(inputValue);\n });\n }\n }, [inputValue]);\n\n // show listbox based on input value\n React.useEffect(() => {\n // don't show the popover if the internal (input) value already is the current value\n // this prevents the popover showing after selecting a value or pressing escape\n const isCurrentValue = value !== undefined && value !== null && inputValue === convertToInputValue(value);\n\n if (inputValue && data.length && !isCurrentValue) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n\n if (!open) {\n setOpen(true);\n }\n } else {\n setOpen(false);\n }\n // `value` commits one render after the input on Tab/select; without it in the deps the guard\n // reopens the popover with a stale `value` and never re-runs to close it. EC-83328\n }, [inputValue, data, value]);\n\n React.useEffect(() => {\n if (open) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n } else {\n setCurrentIndex(undefined);\n }\n }, [open]);\n\n const findOption = React.useCallback(\n (inputVal: string): ScrollableListItem | undefined => {\n // First try to find by raw value\n const itemByValue = findByValue(flattenedData, inputVal);\n if (itemByValue) {\n return itemByValue;\n }\n\n // If valueRenderer is provided, also try to match against rendered values\n if (valueRenderer) {\n return flattenedData.find(option => valueRenderer(option) === inputVal);\n }\n\n return undefined;\n },\n [flattenedData, valueRenderer]\n );\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n if (listRef.current && event.relatedTarget === listRef.current) {\n event.preventDefault();\n return;\n }\n\n const item = findOption(event.target.value);\n\n // If the found item's value equals the current value, just update the display to rendered format\n // This handles the case where user types the raw value but valueRenderer shows something different\n // (e.g., user types \"1000\" but display should be \"1000 - Account Name\")\n if (item && item.value === value) {\n setInputValue(convertToInputValue(value));\n if (props.onBlur) {\n props.onBlur(event);\n }\n return;\n }\n\n // event.target.value is always a string so it is important to cast value to a string (convertToInputValue) before checking the equality\n if (onChange && event.target.value !== convertToInputValue(value)) {\n (event as any).detail = sanitizeItem(item);\n\n const parents = getOptionParents(flattenedData, item?.path);\n\n if (parents !== null && parents.length > 0) {\n (event as any).detail.parents = parents;\n }\n\n onChange(event);\n }\n\n if (props.onBlur) {\n props.onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInputValue(event.target.value);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>): void => {\n if (inline || (!open && inputValue && data.length)) {\n setOpen(true);\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n // Explicitly stop propagation for arrow keys when Combobox is in open state and inside Table3\n // This ensures Table3 won't react to these keys when using the Combobox\n if (\n isElementInsideTable3OrReport(event.currentTarget) &&\n (event.key === 'ArrowUp' || event.key === 'ArrowDown') &&\n open\n ) {\n event.stopPropagation();\n }\n\n if (!event.ctrlKey && !event.metaKey) {\n switch (event.key) {\n case 'Backspace': {\n return;\n }\n\n case 'Escape': {\n event.preventDefault();\n if (open) {\n // as focus is on input, need to prevent propagation to not close dialog.\n event.stopPropagation();\n }\n setInputValue(convertToInputValue(value));\n setOpen(false);\n return;\n }\n\n case 'Tab': {\n // default focusout will trigger onBlur and we don't want to trigger it twice\n setCurrentValue(currentIndex, 'change');\n setOpen(false);\n return;\n }\n\n case 'Enter': {\n event.preventDefault();\n\n if (isElementInsideTable3OrReport(event.currentTarget)) {\n if (inline && !open) {\n setOpen(true);\n } else if (buttonRef.current && !open) {\n buttonRef.current.click();\n }\n }\n\n if (open) {\n // we need to focusout to trigger onBlur as we are not actually blurring the input\n setCurrentValue(currentIndex, 'focusout');\n setOpen(false);\n }\n\n return;\n }\n\n case 'ArrowDown':\n if (open) {\n event.preventDefault();\n } else if (!inline && buttonRef.current && !isElementInsideTable3OrReport(event.currentTarget)) {\n buttonRef.current.click();\n }\n break;\n\n case 'ArrowUp':\n case 'Home':\n case 'End': {\n if (open) {\n event.preventDefault();\n }\n break;\n }\n\n default:\n }\n\n // we aren't focused on the list, so manually forward the keydown event to it\n if (listRef.current) {\n listRef.current.dispatchEvent(createCustomKeyboardEvent(event));\n }\n\n if (\n inline &&\n !open &&\n (event.key === 'ArrowUp' || event.key === 'ArrowDown') &&\n !isElementInsideTable3OrReport(event.currentTarget)\n ) {\n event.preventDefault();\n const initialIndex = event.key === 'ArrowUp' ? data.length - 1 : 0;\n setCurrentIndex(currentIndex === undefined ? initialIndex : currentIndex);\n setOpen(true);\n }\n }\n\n if (!event.isDefaultPrevented() && onKeyDown) {\n onKeyDown(event);\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setCurrentIndex(index);\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n setCurrentValue(index);\n setOpen(false);\n };\n\n const combobox = {\n 'aria-expanded': open,\n 'aria-owns': listId,\n 'aria-haspopup': 'listbox' as const,\n role: 'combobox',\n };\n\n const input = {\n ...otherProps,\n 'aria-controls': listId,\n // Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup and that the suggestions\n // are related to the string that is present in the textbox\n 'aria-autocomplete': 'list' as const,\n // Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element\n 'aria-activedescendant':\n currentIndex !== undefined && data[currentIndex] ? getId(listId, String(data[currentIndex].value)) : undefined,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n disabled,\n onBlur: !disabled && !readOnly ? handleInputBlur : undefined,\n onChange: !disabled && !readOnly ? handleInputChange : undefined,\n onClick: !disabled && !readOnly ? handleInputClick : undefined,\n onKeyDownCapture: !disabled && !readOnly ? handleInputKeyDown : undefined,\n readOnly,\n ref: inputRef,\n type: 'text',\n value: inputValue ?? '',\n };\n\n const list: ScrollableListPropsWithRef = {\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n id: listId,\n onChange: handleListboxChange,\n onClick: handleListboxClick,\n ref: listRef,\n scrollOnFocus: false,\n tabIndex: -1,\n value: currentIndex,\n };\n\n const button = {\n ref: buttonRef,\n };\n\n return {\n combobox,\n input,\n list,\n button,\n popover: {\n open,\n onOpenChange: setOpen,\n //visible: !data.length ? false : open,\n },\n };\n};\n"],"names":[],"mappings":";;;;;;;;AA0BA,MAAM,YAAY,SAAS,CAAA,MAAK,EAAA,GAAK,GAAG;AAExC,MAAM,6BAA6B,CAAC,UAA+C,OAAO,SAAS,EAAE;AAU9F,MAAM,cAAc,CAAC,OAAsC,QAAkD;AAChH,QAAM;AAAA,IACF,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB,MAAM,iBAAiB,CAAA;AAAA,IACvB;AAAA,IACA;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACH;AACJ,QAAM,WAAW,aAA+B,GAAG;AACnD,QAAM,YAAY,MAAM,OAA0B,IAAI;AACtD,QAAM,UAAU,MAAM,OAAyB,IAAI;AACnD,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,KAAK;AAC5C,QAAM,SAAS,MAAM,QAAQ,MAAM,OAAA,GAAU,CAAA,CAAE;AAC/C,QAAM,gBAAgB,iBAAiB,cAAc;AAErD,QAAM,sBAAsB,MAAM;AAAA,IAC9B,CAAC,QAAqD;AAClD,YAAM,SAAS,YAAY,eAAe,GAAG;AAC7C,UAAI,OAAO,kBAAkB,cAAc,QAAQ;AAC/C,eAAO,cAAc,MAAM;AAAA,MAC/B;AACA,aAAO,2BAA2B,GAAG;AAAA,IACzC;AAAA,IACA,CAAC,eAAe,aAAa;AAAA,EAAA;AAGjC,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAiB,oBAAoB,KAAK,CAAC;AACrF,QAAM,mBAAmB,CAAC,aAAa,CAAC,UAAW,UAAU,eAAe,oBAAoB,KAAK;AACrG,QAAM,OA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iBAAiB;AAAA;AAAA;AAAA,IAGjB,qBAAqB;AAAA;AAAA,IAErB,yBACI,iBAAiB,UAAa,KAAK,YAAY,IAAI,MAAM,QAAQ,OAAO,KAAK,YAAY,EAAE,KAAK,CAAC,IAAI;AAAA,IACzG,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB;AAAA,IACA,QAAQ,CAAC,YAAY,CAAC,WAAW,kBAAkB;AAAA,IACnD,UAAU,CAAC,YAAY,CAAC,WAAW,oBAAoB;AAAA,IACvD,SAAS,CAAC,YAAY,CAAC,WAAW,mBAAmB;AAAA,IACrD,kBAAkB,CAAC,YAAY,CAAC,WAAW,qBAAqB;AAAA,IAChE;AAAA,IACA,KAAK;AAAA,IACL,MAAM;AAAA,IACN,OAAO,cAAc;AAAA,EAAA;AAGzB,QAAM,OAAmC;AAAA,IACrC,mBAAmB;AAAA,IACnB;AAAA,IACA;AAAA,IACA,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,KAAK;AAAA,IACL,eAAe;AAAA,IACf,UAAU;AAAA,IACV,OAAO;AAAA,EAAA;AAGX,QAAM,SAAS;AAAA,IACX,KAAK;AAAA,EAAA;AAGT,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,MACL;AAAA,MACA,cAAc;AAAA;AAAA,IAAA;AAAA,EAElB;AAER;"}
|
|
1
|
+
{"version":3,"file":"useCombobox.js","sources":["../../../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["import debounce from 'lodash/debounce';\nimport { nanoid } from 'nanoid';\nimport * as React from 'react';\n\nimport type { InputProps } from '@/components';\nimport type {\n ScrollableListItem,\n ScrollableListItemValue,\n ScrollableListPropsWithRef,\n} from '@/components/Listbox/ScrollableList';\nimport { getId } from '@/components/Listbox/ScrollableList';\nimport {\n setInputValueByRef,\n getIndexFromValue,\n findByValue,\n useFlattenedData,\n sanitizeItem,\n getOptionParents,\n filterData,\n} from '@/components/Listbox/util';\nimport { useMergedRef } from '@/hooks/useMergedRef';\nimport { isElementInsideTable3OrReport } from '@/utils/dom';\nimport { createCustomKeyboardEvent } from '@/utils/input';\n\nimport type { ComboboxProps } from './Combobox';\n\nconst debouncer = debounce(f => f(), 200);\n\nconst defaultConvertToInputValue = (value: ScrollableListItemValue | undefined) => String(value ?? '');\n\ntype useCombobox = Omit<React.HTMLAttributes<HTMLDivElement>, 'popover'> & {\n combobox: React.HTMLAttributes<HTMLSpanElement>;\n input: Omit<InputProps, 'defaultValue'> & { ref: React.RefObject<HTMLInputElement> };\n list: ScrollableListPropsWithRef;\n button: { ref: React.LegacyRef<HTMLButtonElement> };\n popover: { open: boolean; onOpenChange: (open: boolean) => void };\n};\n\nexport const useCombobox = (props: Omit<ComboboxProps, 'dialog'>, ref: React.Ref<HTMLInputElement>): useCombobox => {\n const {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data: unfilteredData = [],\n defaultValue,\n disabled,\n id: _nativeId,\n inline,\n loading: __,\n onChange,\n onClick,\n onKeyDown,\n onSearch,\n readOnly,\n value,\n valueRenderer,\n ...otherProps\n } = props;\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n const [open, setOpen] = React.useState(false);\n const listId = React.useMemo(() => nanoid(), []);\n const flattenedData = useFlattenedData(unfilteredData);\n\n const convertToInputValue = React.useCallback(\n (val: ScrollableListItemValue | undefined): string => {\n const option = findByValue(flattenedData, val);\n if (typeof valueRenderer === 'function' && option) {\n return valueRenderer(option);\n }\n return defaultConvertToInputValue(val);\n },\n [valueRenderer, flattenedData]\n );\n\n const [inputValue, setInputValue] = React.useState<string>(convertToInputValue(value));\n const shouldFilterData = !onSearch && (!inline || (inline && inputValue !== convertToInputValue(value)));\n const data = React.useMemo(\n () => (shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData),\n [shouldFilterData, inputValue, flattenedData]\n );\n // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state\n const [currentIndex, setCurrentIndex] = React.useState<number | undefined>(\n inputValue === undefined ? undefined : getIndexFromValue(data, inputValue)\n );\n\n const setInputValueByIndex = (index: number | undefined, event?: string): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n const eventType = event ?? 'focusout';\n setInputValueByRef(inputRef.current, option.value, eventType);\n }\n }\n };\n\n const setCurrentValue = (index: number | undefined, event?: string) => {\n if (index === undefined) {\n return;\n }\n\n const option = data[index];\n\n if (option?.value === value) {\n // if the selected option is already selected, refill input with its value\n setInputValue(convertToInputValue(value));\n } else {\n // if the selected option is not already selected, trigger blur event\n setInputValueByIndex(index, event);\n }\n };\n\n // ensure the external value is synced with the internal value when mounting, e.g. incase a default value was set\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByIndex(getIndexFromValue(data, defaultValue));\n }\n }, [data]);\n\n // Sync input text when `value` changes externally, during render (not in an effect) so it's correct before the\n // \"show listbox\" effect below — otherwise a one-render stale-text window can open the popover on reset.\n const [prevValue, setPrevValue] = React.useState(value);\n if (value !== prevValue) {\n setPrevValue(value);\n\n if (value !== undefined) {\n // Compare rendered values to handle valueRenderer (e.g. \"1000\" renders as \"1000 - Account Name\").\n const renderedValue = convertToInputValue(value);\n if (renderedValue !== inputValue) {\n setInputValue(renderedValue);\n }\n } else if (prevValue !== undefined && inputValue === convertToInputValue(prevValue) && inputValue !== '') {\n // `value` was cleared externally and the input still shows its previous rendered text (not user-typed),\n // so clear it. Text the user typed never matches the previous render, so it's preserved.\n setInputValue('');\n }\n }\n\n React.useEffect(() => {\n if (onSearch) {\n debouncer(() => {\n onSearch(inputValue);\n });\n }\n }, [inputValue]);\n\n // show listbox based on input value\n React.useEffect(() => {\n // don't show the popover if the internal (input) value already is the current value\n // this prevents the popover showing after selecting a value or pressing escape\n const isCurrentValue = value !== undefined && value !== null && inputValue === convertToInputValue(value);\n\n if (inputValue && data.length && !isCurrentValue) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n\n if (!open) {\n setOpen(true);\n }\n } else {\n setOpen(false);\n }\n // `value` commits one render after the input on Tab/select; without it in the deps the guard\n // reopens the popover with a stale `value` and never re-runs to close it. EC-83328\n }, [inputValue, data, value]);\n\n React.useEffect(() => {\n if (open) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n } else {\n setCurrentIndex(undefined);\n }\n }, [open]);\n\n const findOption = React.useCallback(\n (inputVal: string): ScrollableListItem | undefined => {\n // First try to find by raw value\n const itemByValue = findByValue(flattenedData, inputVal);\n if (itemByValue) {\n return itemByValue;\n }\n\n // If valueRenderer is provided, also try to match against rendered values\n if (valueRenderer) {\n return flattenedData.find(option => valueRenderer(option) === inputVal);\n }\n\n return undefined;\n },\n [flattenedData, valueRenderer]\n );\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n if (listRef.current && event.relatedTarget === listRef.current) {\n event.preventDefault();\n return;\n }\n\n const item = findOption(event.target.value);\n\n // If the found item's value equals the current value, just update the display to rendered format\n // This handles the case where user types the raw value but valueRenderer shows something different\n // (e.g., user types \"1000\" but display should be \"1000 - Account Name\")\n if (item && item.value === value) {\n setInputValue(convertToInputValue(value));\n if (props.onBlur) {\n props.onBlur(event);\n }\n return;\n }\n\n // event.target.value is always a string so it is important to cast value to a string (convertToInputValue) before checking the equality\n if (onChange && event.target.value !== convertToInputValue(value)) {\n (event as any).detail = sanitizeItem(item);\n\n const parents = getOptionParents(flattenedData, item?.path);\n\n if (parents !== null && parents.length > 0) {\n (event as any).detail.parents = parents;\n }\n\n onChange(event);\n }\n\n if (props.onBlur) {\n props.onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInputValue(event.target.value);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>): void => {\n if (inline || (!open && inputValue && data.length)) {\n setOpen(true);\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n // Explicitly stop propagation for arrow keys when Combobox is in open state and inside Table3\n // This ensures Table3 won't react to these keys when using the Combobox\n if (\n isElementInsideTable3OrReport(event.currentTarget) &&\n (event.key === 'ArrowUp' || event.key === 'ArrowDown') &&\n open\n ) {\n event.stopPropagation();\n }\n\n if (!event.ctrlKey && !event.metaKey) {\n switch (event.key) {\n case 'Backspace': {\n return;\n }\n\n case 'Escape': {\n event.preventDefault();\n if (open) {\n // as focus is on input, need to prevent propagation to not close dialog.\n event.stopPropagation();\n }\n setInputValue(convertToInputValue(value));\n setOpen(false);\n return;\n }\n\n case 'Tab': {\n // default focusout will trigger onBlur and we don't want to trigger it twice\n setCurrentValue(currentIndex, 'change');\n setOpen(false);\n return;\n }\n\n case 'Enter': {\n event.preventDefault();\n\n if (isElementInsideTable3OrReport(event.currentTarget)) {\n if (inline && !open) {\n setOpen(true);\n } else if (buttonRef.current && !open) {\n buttonRef.current.click();\n }\n }\n\n if (open) {\n // we need to focusout to trigger onBlur as we are not actually blurring the input\n setCurrentValue(currentIndex, 'focusout');\n setOpen(false);\n }\n\n return;\n }\n\n case 'ArrowDown':\n if (open) {\n event.preventDefault();\n } else if (!inline && buttonRef.current && !isElementInsideTable3OrReport(event.currentTarget)) {\n buttonRef.current.click();\n }\n break;\n\n case 'ArrowUp':\n case 'Home':\n case 'End': {\n if (open) {\n event.preventDefault();\n }\n break;\n }\n\n default:\n }\n\n // we aren't focused on the list, so manually forward the keydown event to it\n if (listRef.current) {\n listRef.current.dispatchEvent(createCustomKeyboardEvent(event));\n }\n\n if (\n inline &&\n !open &&\n (event.key === 'ArrowUp' || event.key === 'ArrowDown') &&\n !isElementInsideTable3OrReport(event.currentTarget)\n ) {\n event.preventDefault();\n const initialIndex = event.key === 'ArrowUp' ? data.length - 1 : 0;\n setCurrentIndex(currentIndex === undefined ? initialIndex : currentIndex);\n setOpen(true);\n }\n }\n\n if (!event.isDefaultPrevented() && onKeyDown) {\n onKeyDown(event);\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setCurrentIndex(index);\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n setCurrentValue(index);\n setOpen(false);\n };\n\n const combobox = {\n 'aria-expanded': open,\n 'aria-owns': listId,\n 'aria-haspopup': 'listbox' as const,\n role: 'combobox',\n };\n\n const input = {\n ...otherProps,\n 'aria-controls': listId,\n // Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup and that the suggestions\n // are related to the string that is present in the textbox\n 'aria-autocomplete': 'list' as const,\n // Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element\n 'aria-activedescendant':\n currentIndex !== undefined && data[currentIndex] ? getId(listId, String(data[currentIndex].value)) : undefined,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n disabled,\n onBlur: !disabled && !readOnly ? handleInputBlur : undefined,\n onChange: !disabled && !readOnly ? handleInputChange : undefined,\n onClick: !disabled && !readOnly ? handleInputClick : undefined,\n onKeyDownCapture: !disabled && !readOnly ? handleInputKeyDown : undefined,\n readOnly,\n ref: inputRef,\n type: 'text',\n value: inputValue ?? '',\n };\n\n const list: ScrollableListPropsWithRef = {\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n id: listId,\n onChange: handleListboxChange,\n onClick: handleListboxClick,\n ref: listRef,\n scrollOnFocus: false,\n tabIndex: -1,\n value: currentIndex,\n };\n\n const button = {\n ref: buttonRef,\n };\n\n return {\n combobox,\n input,\n list,\n button,\n popover: {\n open,\n onOpenChange: setOpen,\n //visible: !data.length ? false : open,\n },\n };\n};\n"],"names":[],"mappings":";;;;;;;;AA0BA,MAAM,YAAY,SAAS,CAAA,MAAK,EAAA,GAAK,GAAG;AAExC,MAAM,6BAA6B,CAAC,UAA+C,OAAO,SAAS,EAAE;AAU9F,MAAM,cAAc,CAAC,OAAsC,QAAkD;AAChH,QAAM;A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AAmB;AAAA,IACrD,kBAAkB,CAAC,YAAY,CAAC,WAAW,qBAAqB;AAAA,IAChE;AAAA,IACA,KAAK;AAAA,IACL,MAAM;AAAA,IACN,OAAO,cAAc;AAAA,EAAA;AAGzB,QAAM,OAAmC;AAAA,IACrC,mBAAmB;AAAA,IACnB;AAAA,IACA;AAAA,IACA,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,KAAK;AAAA,IACL,eAAe;AAAA,IACf,UAAU;AAAA,IACV,OAAO;AAAA,EAAA;AAGX,QAAM,SAAS;AAAA,IACX,KAAK;AAAA,EAAA;AAGT,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,MACL;AAAA,MACA,cAAc;AAAA;AAAA,IAAA;AAAA,EAElB;AAER;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDatepicker.cjs","sources":["../../../src/components/Datepicker/useDatepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { isMatch } from 'react-day-picker';\n\nimport type { CalendarProps, InputProps as BaseInputProps } from '@/components';\nimport { useLocalization } from '@/components';\nimport { useMergedRef } from '@/hooks/useMergedRef';\nimport { format, parse, parseFromCustomString } from '@/utils/date';\nimport { setInputValueByRef } from '@/utils/input';\n\nimport type { DatepickerProps } from './Datepicker';\n\ntype InputProps = BaseInputProps & { ref: React.RefObject<HTMLInputElement> };\ntype useDatepicker = React.HTMLAttributes<HTMLDivElement> & {\n calendar: CalendarProps;\n input: InputProps;\n};\n\nexport const useDatepicker = (\n { defaultValue: _, calendar, onBlur, onChange, value, ...props }: DatepickerProps,\n ref: React.Ref<HTMLInputElement>\n): useDatepicker => {\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const { formatting } = useLocalization();\n const [internalValue, setInternalValue] = React.useState(format(value, formatting.date) ?? '');\n const originalValueAsDate = parse(value);\n\n // update internal value if it changed 'externally'\n React.useEffect(() => {\n const formattedValue = format(value, formatting.date);\n\n if (formattedValue !== internalValue) {\n setInternalValue(formattedValue ?? '');\n }\n }, [value]);\n\n const isDisabledDay = React.useMemo(() => {\n if (originalValueAsDate && calendar?.disabledDays) {\n
|
|
1
|
+
{"version":3,"file":"useDatepicker.cjs","sources":["../../../src/components/Datepicker/useDatepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { isMatch } from 'react-day-picker';\n\nimport type { CalendarProps, InputProps as BaseInputProps } from '@/components';\nimport { useLocalization } from '@/components';\nimport { useMergedRef } from '@/hooks/useMergedRef';\nimport { format, parse, parseFromCustomString } from '@/utils/date';\nimport { setInputValueByRef } from '@/utils/input';\n\nimport type { DatepickerProps } from './Datepicker';\n\ntype InputProps = BaseInputProps & { ref: React.RefObject<HTMLInputElement> };\ntype useDatepicker = React.HTMLAttributes<HTMLDivElement> & {\n calendar: CalendarProps;\n input: InputProps;\n};\n\nexport const useDatepicker = (\n { defaultValue: _, calendar, onBlur, onChange, value, ...props }: DatepickerProps,\n ref: React.Ref<HTMLInputElement>\n): useDatepicker => {\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const { formatting } = useLocalization();\n const [internalValue, setInternalValue] = React.useState(format(value, formatting.date) ?? '');\n const originalValueAsDate = parse(value);\n\n // update internal value if it changed 'externally'\n React.useEffect(() => {\n const formattedValue = format(value, formatting.date);\n\n if (formattedValue !== internalValue) {\n setInternalValue(formattedValue ?? '');\n }\n }, [value]);\n\n const isDisabledDay = React.useMemo(() => {\n if (originalValueAsDate && calendar?.disabledDays) {\n // can happen if you type a disabled date in input.\n return isMatch(originalValueAsDate, calendar?.disabledDays);\n }\n\n return false;\n }, [originalValueAsDate]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n const valueAsDate = parseFromCustomString(\n event.target.value,\n 'dd.mm.yy',\n originalValueAsDate?.getMonth(),\n originalValueAsDate?.getFullYear()\n );\n const formattedValue = valueAsDate ? format(valueAsDate) || '' : '';\n\n event.target.value = formattedValue;\n\n const isEmpty = !event.target.value.trim();\n\n if (onChange) {\n (event as any).detail = isEmpty ? null : valueAsDate;\n onChange(event);\n } else {\n // update the internal value to use the formatted date\n setInternalValue(isEmpty ? '' : formattedValue);\n }\n\n if (onBlur) {\n onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInternalValue(event.target.value);\n };\n\n const handleChange = (date: Date) => {\n setInputValueByRef(inputRef.current, format(date, formatting.date), 'focusout');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (props.onKeyDown) {\n props.onKeyDown(event);\n }\n\n if (event.key === 'Enter') {\n event.target.dispatchEvent(new Event('focusout', { bubbles: true }));\n }\n };\n\n const inputProps: InputProps = {\n ...props,\n autoComplete: 'off',\n invalid: props.invalid || isDisabledDay,\n onBlur: handleInputBlur,\n onChange: handleInputChange,\n onKeyDown: handleKeyDown,\n ref: inputRef,\n type: 'text',\n value: internalValue,\n };\n\n const calendarProps: CalendarProps = {\n ...calendar,\n onChange: handleChange,\n value: originalValueAsDate,\n };\n\n return {\n input: inputProps,\n calendar: calendarProps,\n };\n};\n"],"names":["useMergedRef","useLocalization","React","format","parse","isMatch","parseFromCustomString","date","setInputValueByRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,MAAM,gBAAgB,CACzB,EAAE,cAAc,GAAG,UAAU,QAAQ,UAAU,OAAO,GAAG,MAAA,GACzD,QACgB;AAChB,QAAM,WAAWA,aAAAA,aAA+B,GAAG;AACnD,QAAM,EAAE,WAAA,IAAeC,6BAAA;AACvB,QAAM,CAAC,eAAe,gBAAgB,IAAIC,iBAAM,SAASC,KAAAA,OAAO,OAAO,WAAW,IAAI,KAAK,EAAE;AAC7F,QAAM,sBAAsBC,KAAAA,MAAM,KAAK;AAGvCF,mBAAM,UAAU,MAAM;AAClB,UAAM,iBAAiBC,KAAAA,OAAO,OAAO,WAAW,IAAI;AAEpD,QAAI,mB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ACH,cAAc;AAAA,IACd,SAAS,MAAM,WAAW;AAAA,IAC1B,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,KAAK;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAGX,QAAM,gBAA+B;AAAA,IACjC,GAAG;AAAA,IACH,UAAU;AAAA,IACV,OAAO;AAAA,EAAA;AAGX,SAAO;AAAA,IACH,OAAO;AAAA,IACP,UAAU;AAAA,EAAA;AAElB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDatepicker.js","sources":["../../../src/components/Datepicker/useDatepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { isMatch } from 'react-day-picker';\n\nimport type { CalendarProps, InputProps as BaseInputProps } from '@/components';\nimport { useLocalization } from '@/components';\nimport { useMergedRef } from '@/hooks/useMergedRef';\nimport { format, parse, parseFromCustomString } from '@/utils/date';\nimport { setInputValueByRef } from '@/utils/input';\n\nimport type { DatepickerProps } from './Datepicker';\n\ntype InputProps = BaseInputProps & { ref: React.RefObject<HTMLInputElement> };\ntype useDatepicker = React.HTMLAttributes<HTMLDivElement> & {\n calendar: CalendarProps;\n input: InputProps;\n};\n\nexport const useDatepicker = (\n { defaultValue: _, calendar, onBlur, onChange, value, ...props }: DatepickerProps,\n ref: React.Ref<HTMLInputElement>\n): useDatepicker => {\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const { formatting } = useLocalization();\n const [internalValue, setInternalValue] = React.useState(format(value, formatting.date) ?? '');\n const originalValueAsDate = parse(value);\n\n // update internal value if it changed 'externally'\n React.useEffect(() => {\n const formattedValue = format(value, formatting.date);\n\n if (formattedValue !== internalValue) {\n setInternalValue(formattedValue ?? '');\n }\n }, [value]);\n\n const isDisabledDay = React.useMemo(() => {\n if (originalValueAsDate && calendar?.disabledDays) {\n
|
|
1
|
+
{"version":3,"file":"useDatepicker.js","sources":["../../../src/components/Datepicker/useDatepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { isMatch } from 'react-day-picker';\n\nimport type { CalendarProps, InputProps as BaseInputProps } from '@/components';\nimport { useLocalization } from '@/components';\nimport { useMergedRef } from '@/hooks/useMergedRef';\nimport { format, parse, parseFromCustomString } from '@/utils/date';\nimport { setInputValueByRef } from '@/utils/input';\n\nimport type { DatepickerProps } from './Datepicker';\n\ntype InputProps = BaseInputProps & { ref: React.RefObject<HTMLInputElement> };\ntype useDatepicker = React.HTMLAttributes<HTMLDivElement> & {\n calendar: CalendarProps;\n input: InputProps;\n};\n\nexport const useDatepicker = (\n { defaultValue: _, calendar, onBlur, onChange, value, ...props }: DatepickerProps,\n ref: React.Ref<HTMLInputElement>\n): useDatepicker => {\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const { formatting } = useLocalization();\n const [internalValue, setInternalValue] = React.useState(format(value, formatting.date) ?? '');\n const originalValueAsDate = parse(value);\n\n // update internal value if it changed 'externally'\n React.useEffect(() => {\n const formattedValue = format(value, formatting.date);\n\n if (formattedValue !== internalValue) {\n setInternalValue(formattedValue ?? '');\n }\n }, [value]);\n\n const isDisabledDay = React.useMemo(() => {\n if (originalValueAsDate && calendar?.disabledDays) {\n // can happen if you type a disabled date in input.\n return isMatch(originalValueAsDate, calendar?.disabledDays);\n }\n\n return false;\n }, [originalValueAsDate]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n const valueAsDate = parseFromCustomString(\n event.target.value,\n 'dd.mm.yy',\n originalValueAsDate?.getMonth(),\n originalValueAsDate?.getFullYear()\n );\n const formattedValue = valueAsDate ? format(valueAsDate) || '' : '';\n\n event.target.value = formattedValue;\n\n const isEmpty = !event.target.value.trim();\n\n if (onChange) {\n (event as any).detail = isEmpty ? null : valueAsDate;\n onChange(event);\n } else {\n // update the internal value to use the formatted date\n setInternalValue(isEmpty ? '' : formattedValue);\n }\n\n if (onBlur) {\n onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInternalValue(event.target.value);\n };\n\n const handleChange = (date: Date) => {\n setInputValueByRef(inputRef.current, format(date, formatting.date), 'focusout');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (props.onKeyDown) {\n props.onKeyDown(event);\n }\n\n if (event.key === 'Enter') {\n event.target.dispatchEvent(new Event('focusout', { bubbles: true }));\n }\n };\n\n const inputProps: InputProps = {\n ...props,\n autoComplete: 'off',\n invalid: props.invalid || isDisabledDay,\n onBlur: handleInputBlur,\n onChange: handleInputChange,\n onKeyDown: handleKeyDown,\n ref: inputRef,\n type: 'text',\n value: internalValue,\n };\n\n const calendarProps: CalendarProps = {\n ...calendar,\n onChange: handleChange,\n value: originalValueAsDate,\n };\n\n return {\n input: inputProps,\n calendar: calendarProps,\n };\n};\n"],"names":[],"mappings":";;;;;;AAiBO,MAAM,gBAAgB,CACzB,EAAE,cAAc,GAAG,UAAU,QAAQ,UAAU,OAAO,GAAG,MAAA,GACzD,QACgB;AAChB,QAAM,WAAW,aAA+B,GAAG;AACnD,QAAM,EAAE,WAAA,IAAe,gBAAA;AACvB,QAAM,CAAC,eAAe,gBAAgB,IAAI,MAAM,SAAS,OAAO,OAAO,WAAW,IAAI,KAAK,EAAE;AAC7F,QAAM,sBAAsB,MAAM,KAAK;AAGvC,QAAM,UAAU,MAAM;AAClB,UAAM,iBAAiB,OAAO,OAAO,WAAW,IAAI;AAEpD,QAAI,mBAAmB,eAAe;AAClC,uBAAiB,kBAAkB,EAAE;AAAA,IACzC;AAAA,EACJ,GAAG,CAAC,KAAK,CAAC;AAEV,QAAM,gBAAgB,MAAM,QAAQ,MAAM;AACtC,QAAI,uBAAuB,UAAU,cAAc;AAE/C,aAAO,QAAQ,qBAAqB,UAAU,YAAY;AAAA,IAC9D;AAEA,WAAO;AAAA,EACX,GAAG,CAAC,mBAAmB,CAAC;AAGxB,QAAM,kBAAkB,CAAC,UAAoD;AACzE,UAAM,QAAA;AAEN,UAAM,cA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["../../../src/components/Dialog/Context.tsx"],"sourcesContent":["/* oxlint-disable no-empty-function */\nimport * as React from 'react';\n\nimport type { DialogSize } from './types';\n\nexport type DialogContext = {\n closeOnEscape: boolean;\n draggable: boolean;\n drawer: {\n open: boolean;\n toggle: () => void;\n };\n elements: {\n drawer?: React.ReactNode;\n extra?: React.ReactNode;\n };\n onClose?: () => void;\n /** Stable ref to the dialog popup element. */\n popupRef: React.RefObject<HTMLElement | null> | null;\n props: Record<string,
|
|
1
|
+
{"version":3,"file":"Context.cjs","sources":["../../../src/components/Dialog/Context.tsx"],"sourcesContent":["/* oxlint-disable no-empty-function */\nimport * as React from 'react';\n\nimport type { DialogSize } from './types';\n\nexport type DialogContext = {\n closeOnEscape: boolean;\n draggable: boolean;\n drawer: {\n open: boolean;\n toggle: () => void;\n };\n elements: {\n drawer?: React.ReactNode;\n extra?: React.ReactNode;\n };\n onClose?: () => void;\n /** Stable ref to the dialog popup element. */\n popupRef: React.RefObject<HTMLElement | null> | null;\n props: Record<string, unknown>;\n /** Forwarded ref from `<Dialog>` — attached to the Trigger button. */\n ref: React.Ref<HTMLElement>;\n showCloseButton: boolean;\n size: DialogSize;\n};\n\nexport const DialogContext = React.createContext<DialogContext>({\n closeOnEscape: true,\n draggable: false,\n drawer: {\n open: false,\n toggle: () => {},\n },\n elements: {\n drawer: undefined,\n extra: undefined,\n },\n onClose: () => {},\n popupRef: null,\n props: {},\n ref: null,\n showCloseButton: true,\n size: 'sm',\n});\n\nexport const useCurrentDialog = () => {\n return React.useContext(DialogContext);\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BO,MAAM,gBAAgBA,iBAAM,cAA6B;AAAA,EAC5D,eAAe;AAAA,EACf,WAAW;AAAA,EACX,QAAQ;AAAA,IACJ,MAAM;AAAA,IACN,QAAQ,MAAM;AAAA,IAAC;AAAA,EAAA;AAAA,EAEnB,UAAU;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAAA,EAEX,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,UAAU;AAAA,EACV,OAAO,CAAA;AAAA,EACP,KAAK;AAAA,EACL,iBAAiB;AAAA,EACjB,MAAM;AACV,CAAC;AAEM,MAAM,mBAAmB,MAAM;AAClC,SAAOA,iBAAM,WAAW,aAAa;AACzC;;;"}
|
|
@@ -14,7 +14,7 @@ export type DialogContext = {
|
|
|
14
14
|
onClose?: () => void;
|
|
15
15
|
/** Stable ref to the dialog popup element. */
|
|
16
16
|
popupRef: React.RefObject<HTMLElement | null> | null;
|
|
17
|
-
props: Record<string,
|
|
17
|
+
props: Record<string, unknown>;
|
|
18
18
|
/** Forwarded ref from `<Dialog>` — attached to the Trigger button. */
|
|
19
19
|
ref: React.Ref<HTMLElement>;
|
|
20
20
|
showCloseButton: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sources":["../../../src/components/Dialog/Context.tsx"],"sourcesContent":["/* oxlint-disable no-empty-function */\nimport * as React from 'react';\n\nimport type { DialogSize } from './types';\n\nexport type DialogContext = {\n closeOnEscape: boolean;\n draggable: boolean;\n drawer: {\n open: boolean;\n toggle: () => void;\n };\n elements: {\n drawer?: React.ReactNode;\n extra?: React.ReactNode;\n };\n onClose?: () => void;\n /** Stable ref to the dialog popup element. */\n popupRef: React.RefObject<HTMLElement | null> | null;\n props: Record<string,
|
|
1
|
+
{"version":3,"file":"Context.js","sources":["../../../src/components/Dialog/Context.tsx"],"sourcesContent":["/* oxlint-disable no-empty-function */\nimport * as React from 'react';\n\nimport type { DialogSize } from './types';\n\nexport type DialogContext = {\n closeOnEscape: boolean;\n draggable: boolean;\n drawer: {\n open: boolean;\n toggle: () => void;\n };\n elements: {\n drawer?: React.ReactNode;\n extra?: React.ReactNode;\n };\n onClose?: () => void;\n /** Stable ref to the dialog popup element. */\n popupRef: React.RefObject<HTMLElement | null> | null;\n props: Record<string, unknown>;\n /** Forwarded ref from `<Dialog>` — attached to the Trigger button. */\n ref: React.Ref<HTMLElement>;\n showCloseButton: boolean;\n size: DialogSize;\n};\n\nexport const DialogContext = React.createContext<DialogContext>({\n closeOnEscape: true,\n draggable: false,\n drawer: {\n open: false,\n toggle: () => {},\n },\n elements: {\n drawer: undefined,\n extra: undefined,\n },\n onClose: () => {},\n popupRef: null,\n props: {},\n ref: null,\n showCloseButton: true,\n size: 'sm',\n});\n\nexport const useCurrentDialog = () => {\n return React.useContext(DialogContext);\n};\n"],"names":[],"mappings":";AA0BO,MAAM,gBAAgB,MAAM,cAA6B;AAAA,EAC5D,eAAe;AAAA,EACf,WAAW;AAAA,EACX,QAAQ;AAAA,IACJ,MAAM;AAAA,IACN,QAAQ,MAAM;AAAA,IAAC;AAAA,EAAA;AAAA,EAEnB,UAAU;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAAA,EAEX,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,UAAU;AAAA,EACV,OAAO,CAAA;AAAA,EACP,KAAK;AAAA,EACL,iBAAiB;AAAA,EACjB,MAAM;AACV,CAAC;AAEM,MAAM,mBAAmB,MAAM;AAClC,SAAO,MAAM,WAAW,aAAa;AACzC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Content.cjs","sources":["../../../../src/components/Dialog/components/Content.tsx"],"sourcesContent":["import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';\nimport cn from 'clsx';\nimport * as React from 'react';\n\nimport { Backdrop, LegacyIconButton, useLocalization } from '@/components';\nimport { useDraggable } from '@/utils/hooks/useDraggable';\nimport { mergeRefs } from '@/utils/mergeRefs';\n\nimport type { DialogContext } from '../Context';\nimport { useCurrentDialog } from '../Context';\nimport { DIALOG_POSITION_CLASSNAMES, DIALOG_SIZE_CLASSNAME } from '../util';\n\nexport type DialogContentDrawerRenderProps = DialogContext['drawer'];\n\nexport type DialogContentRenderProps = {\n close: () => void;\n drawer?: DialogContentDrawerRenderProps;\n};\n\nexport type DialogTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: DialogTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('text-center', props.className);\n return <DialogPrimitive.Title {...props} className={className} ref={ref} />;\n});\n\nexport type DialogFooterProps = React.HTMLAttributes<HTMLDivElement>;\nexport const Footer = React.forwardRef(function DialogFooter(props: DialogFooterProps, ref: React.Ref<HTMLDivElement>) {\n const className = cn('mt-8 flex justify-end', props.className);\n return (\n <div {...props} className={className} ref={ref}>\n {props.children}\n </div>\n );\n});\n\nexport type DialogCloseProps = React.HTMLAttributes<HTMLButtonElement> & {\n children: React.JSX.Element;\n};\n\nexport const Close = React.forwardRef(function DialogClose(props: DialogCloseProps, ref: React.Ref<HTMLButtonElement>) {\n const dialog = useCurrentDialog();\n const { children, ...restProps } = props;\n\n return <DialogPrimitive.Close {...restProps} onClick={dialog.onClose} ref={ref} render={children} />;\n});\n\nconst RenderPropWrapper = React.forwardRef(function RenderPropWrapper({ children, onClick, renderProps }: any, ref) {\n const close = () => {\n onClick(new CustomEvent('close'));\n };\n\n return children({ close, ref, ...renderProps });\n});\n\nexport type DialogContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible label to be announced when the dialog is opened */\n 'aria-label': string;\n children: React.ReactNode | ((props: DialogContentRenderProps) => React.ReactNode);\n initialFocus?: DialogPrimitive.Popup.Props['initialFocus'];\n finalFocus?: DialogPrimitive.Popup.Props['finalFocus'];\n};\nexport const Content = React.forwardRef(function DialogContent(\n props: DialogContentProps,\n forwardedRef: React.Ref<HTMLDivElement>\n) {\n const dialog = useCurrentDialog();\n // Popup ref lives on the Dialog root so descendants can read it via `useDialogScope`;\n // we attach it to the popup node here and merge in any forwarded ref.\n const popupRef = dialog.popupRef as React.
|
|
1
|
+
{"version":3,"file":"Content.cjs","sources":["../../../../src/components/Dialog/components/Content.tsx"],"sourcesContent":["import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';\nimport cn from 'clsx';\nimport * as React from 'react';\n\nimport { Backdrop, LegacyIconButton, useLocalization } from '@/components';\nimport { useDraggable } from '@/utils/hooks/useDraggable';\nimport { mergeRefs } from '@/utils/mergeRefs';\n\nimport type { DialogContext } from '../Context';\nimport { useCurrentDialog } from '../Context';\nimport { DIALOG_POSITION_CLASSNAMES, DIALOG_SIZE_CLASSNAME } from '../util';\n\nexport type DialogContentDrawerRenderProps = DialogContext['drawer'];\n\nexport type DialogContentRenderProps = {\n close: () => void;\n drawer?: DialogContentDrawerRenderProps;\n};\n\nexport type DialogTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: DialogTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('text-center', props.className);\n return <DialogPrimitive.Title {...props} className={className} ref={ref} />;\n});\n\nexport type DialogFooterProps = React.HTMLAttributes<HTMLDivElement>;\nexport const Footer = React.forwardRef(function DialogFooter(props: DialogFooterProps, ref: React.Ref<HTMLDivElement>) {\n const className = cn('mt-8 flex justify-end', props.className);\n return (\n <div {...props} className={className} ref={ref}>\n {props.children}\n </div>\n );\n});\n\nexport type DialogCloseProps = React.HTMLAttributes<HTMLButtonElement> & {\n children: React.JSX.Element;\n};\n\nexport const Close = React.forwardRef(function DialogClose(props: DialogCloseProps, ref: React.Ref<HTMLButtonElement>) {\n const dialog = useCurrentDialog();\n const { children, ...restProps } = props;\n\n return <DialogPrimitive.Close {...restProps} onClick={dialog.onClose} ref={ref} render={children} />;\n});\n\nconst RenderPropWrapper = React.forwardRef(function RenderPropWrapper({ children, onClick, renderProps }: any, ref) {\n const close = () => {\n onClick(new CustomEvent('close'));\n };\n\n return children({ close, ref, ...renderProps });\n});\n\nexport type DialogContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible label to be announced when the dialog is opened */\n 'aria-label': string;\n children: React.ReactNode | ((props: DialogContentRenderProps) => React.ReactNode);\n initialFocus?: DialogPrimitive.Popup.Props['initialFocus'];\n finalFocus?: DialogPrimitive.Popup.Props['finalFocus'];\n};\nexport const Content = React.forwardRef(function DialogContent(\n props: DialogContentProps,\n forwardedRef: React.Ref<HTMLDivElement>\n) {\n const dialog = useCurrentDialog();\n // Popup ref lives on the Dialog root so descendants can read it via `useDialogScope`;\n // we attach it to the popup node here and merge in any forwarded ref.\n const popupRef = dialog.popupRef as React.RefObject<HTMLDivElement | null>;\n const setPopupRef = React.useMemo(() => mergeRefs<HTMLDivElement>([popupRef, forwardedRef]), [popupRef, forwardedRef]);\n const { position, dragging, handleProps: dragHandleProps } = useDraggable(popupRef);\n const { texts } = useLocalization();\n\n const className = cn(\n 'relative animate-[fade-in_150ms] rounded bg-white print:!static',\n DIALOG_POSITION_CLASSNAMES,\n DIALOG_SIZE_CLASSNAME[dialog.size],\n 'print:m-0 print:h-max print:w-full print:overflow-visible'\n );\n\n const containerClassName = cn(\n 'relative z-10 rounded bg-white p-6 shadow print:p-0',\n // The `!fixed` property is crucial to ensure that when a draggable dialog is moved, the printed document still displays its content across the full page.\n 'print:!inset-0 print:!m-0 print:h-max print:!transform-none print:overflow-visible',\n {\n 'rounded-b-none': !!dialog.elements.extra,\n },\n props.className\n );\n\n let output;\n\n if (typeof props.children === 'function') {\n output = (\n <Close>\n <RenderPropWrapper renderProps={{ drawer: dialog.drawer }}>{props.children}</RenderPropWrapper>\n </Close>\n );\n } else {\n output = props.children;\n }\n return (\n <DialogPrimitive.Portal>\n <Backdrop>\n <DialogPrimitive.Popup\n {...props}\n className={className}\n ref={setPopupRef}\n style={{\n ...props.style,\n left: dialog.draggable ? `${position.x}px` : undefined,\n top: dialog.draggable ? `${position.y}px` : undefined,\n }}>\n <div className={containerClassName} data-taco=\"dialog\">\n {output}\n {dialog.draggable && (\n <div\n {...dragHandleProps}\n role=\"button\"\n draggable\n aria-grabbed={dragging}\n aria-label={texts.dialog.drag}\n className=\"yt-dialog__drag top-1.5 h-3 w-24 cursor-move rounded bg-gray-100 text-center absolute-center-x print:hidden\"\n />\n )}\n {dialog.showCloseButton ? (\n <DialogPrimitive.Close\n onClick={dialog.onClose}\n render={\n <LegacyIconButton\n appearance=\"discrete\"\n aria-label={texts.dialog.close}\n className=\"absolute right-0 top-0 mr-2 mt-2 print:hidden\"\n icon=\"close\"\n />\n }></DialogPrimitive.Close>\n ) : null}\n </div>\n {dialog.elements.drawer}\n {dialog.elements.extra}\n </DialogPrimitive.Popup>\n </Backdrop>\n </DialogPrimitive.Portal>\n );\n});\n"],"names":["React","DialogPrimitive","dialog","useCurrentDialog","RenderPropWrapper","mergeRefs","useDraggable","useLocalization","DIALOG_POSITION_CLASSNAMES","DIALOG_SIZE_CLASSNAME","Backdrop","LegacyIconButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,MAAM,QAAQA,iBAAM,WAAW,SAAS,YAAY,OAAyB,KAAoC;AACpH,QAAM,YAAY,GAAG,eAAe,MAAM,SAAS;AACnD,wDAAQC,cAAgB,OAAhB,EAAuB,GAAG,OAAO,WAAsB,KAAU;AAC7E,CAAC;AAGM,MAAM,SAASD,iBAAM,WAAW,SAAS,aAAa,OAA0B,KAAgC;AACnH,QAAM,YAAY,GAAG,yBAAyB,MAAM,SAAS;AAC7D,wDACK,OAAA,EAAK,GAAG,OAAO,WAAsB,IAAA,GACjC,MAAM,QACX;AAER,CAAC;AAMM,MAAM,QAAQA,iBAAM,WAAW,SAAS,YAAY,OAAyB,KAAmC;AACnH,QAAME,WAASC,QAAAA,iBAAA;AACf,QAAM,EAAE,UAAU,GAAG,UAAA,IAAc;AAEnC,SAAOH,iCAAA,cAACC,cAAgB,OAAhB,EAAuB,GAAG,WAAW,SAASC,SAAO,SAAS,KAAU,QAAQ,SAAA,CAAU;AACtG,CAAC;AAED,MAAM,oBAAoBF,iBAAM,WAAW,SAASI,mBAAkB,EAAE,UAAU,SAAS,YAAA,GAAoB,KAAK;AAChH,QAAM,QAAQ,MAAM;AAChB,YAAQ,IAAI,YAAY,OAAO,CAAC;A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,IACAF,iCAAA,cAAC,SAAI,WAAW,oBAAoB,aAAU,SAAA,GACzC,QACAE,SAAO,aACJF,iCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACI,GAAG;AAAA,QACJ,MAAK;AAAA,QACL,WAAS;AAAA,QACT,gBAAc;AAAA,QACd,cAAY,MAAM,OAAO;AAAA,QACzB,WAAU;AAAA,MAAA;AAAA,IAAA,GAGjBE,SAAO,kBACJF,iCAAA;AAAA,MAACC,OAAAA,OAAgB;AAAA,MAAhB;AAAA,QACG,SAASC,SAAO;AAAA,QAChB,QACIF,iCAAA;AAAA,UAACW,WAAAA;AAAAA,UAAA;AAAA,YACG,YAAW;AAAA,YACX,cAAY,MAAM,OAAO;AAAA,YACzB,WAAU;AAAA,YACV,MAAK;AAAA,UAAA;AAAA,QAAA;AAAA,MACT;AAAA,IAAA,IAER,IACR;AAAA,IACCT,SAAO,SAAS;AAAA,IAChBA,SAAO,SAAS;AAAA,EAAA,CAEzB,CACJ;AAER,CAAC;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Content.js","sources":["../../../../src/components/Dialog/components/Content.tsx"],"sourcesContent":["import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';\nimport cn from 'clsx';\nimport * as React from 'react';\n\nimport { Backdrop, LegacyIconButton, useLocalization } from '@/components';\nimport { useDraggable } from '@/utils/hooks/useDraggable';\nimport { mergeRefs } from '@/utils/mergeRefs';\n\nimport type { DialogContext } from '../Context';\nimport { useCurrentDialog } from '../Context';\nimport { DIALOG_POSITION_CLASSNAMES, DIALOG_SIZE_CLASSNAME } from '../util';\n\nexport type DialogContentDrawerRenderProps = DialogContext['drawer'];\n\nexport type DialogContentRenderProps = {\n close: () => void;\n drawer?: DialogContentDrawerRenderProps;\n};\n\nexport type DialogTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: DialogTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('text-center', props.className);\n return <DialogPrimitive.Title {...props} className={className} ref={ref} />;\n});\n\nexport type DialogFooterProps = React.HTMLAttributes<HTMLDivElement>;\nexport const Footer = React.forwardRef(function DialogFooter(props: DialogFooterProps, ref: React.Ref<HTMLDivElement>) {\n const className = cn('mt-8 flex justify-end', props.className);\n return (\n <div {...props} className={className} ref={ref}>\n {props.children}\n </div>\n );\n});\n\nexport type DialogCloseProps = React.HTMLAttributes<HTMLButtonElement> & {\n children: React.JSX.Element;\n};\n\nexport const Close = React.forwardRef(function DialogClose(props: DialogCloseProps, ref: React.Ref<HTMLButtonElement>) {\n const dialog = useCurrentDialog();\n const { children, ...restProps } = props;\n\n return <DialogPrimitive.Close {...restProps} onClick={dialog.onClose} ref={ref} render={children} />;\n});\n\nconst RenderPropWrapper = React.forwardRef(function RenderPropWrapper({ children, onClick, renderProps }: any, ref) {\n const close = () => {\n onClick(new CustomEvent('close'));\n };\n\n return children({ close, ref, ...renderProps });\n});\n\nexport type DialogContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible label to be announced when the dialog is opened */\n 'aria-label': string;\n children: React.ReactNode | ((props: DialogContentRenderProps) => React.ReactNode);\n initialFocus?: DialogPrimitive.Popup.Props['initialFocus'];\n finalFocus?: DialogPrimitive.Popup.Props['finalFocus'];\n};\nexport const Content = React.forwardRef(function DialogContent(\n props: DialogContentProps,\n forwardedRef: React.Ref<HTMLDivElement>\n) {\n const dialog = useCurrentDialog();\n // Popup ref lives on the Dialog root so descendants can read it via `useDialogScope`;\n // we attach it to the popup node here and merge in any forwarded ref.\n const popupRef = dialog.popupRef as React.
|
|
1
|
+
{"version":3,"file":"Content.js","sources":["../../../../src/components/Dialog/components/Content.tsx"],"sourcesContent":["import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';\nimport cn from 'clsx';\nimport * as React from 'react';\n\nimport { Backdrop, LegacyIconButton, useLocalization } from '@/components';\nimport { useDraggable } from '@/utils/hooks/useDraggable';\nimport { mergeRefs } from '@/utils/mergeRefs';\n\nimport type { DialogContext } from '../Context';\nimport { useCurrentDialog } from '../Context';\nimport { DIALOG_POSITION_CLASSNAMES, DIALOG_SIZE_CLASSNAME } from '../util';\n\nexport type DialogContentDrawerRenderProps = DialogContext['drawer'];\n\nexport type DialogContentRenderProps = {\n close: () => void;\n drawer?: DialogContentDrawerRenderProps;\n};\n\nexport type DialogTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: DialogTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('text-center', props.className);\n return <DialogPrimitive.Title {...props} className={className} ref={ref} />;\n});\n\nexport type DialogFooterProps = React.HTMLAttributes<HTMLDivElement>;\nexport const Footer = React.forwardRef(function DialogFooter(props: DialogFooterProps, ref: React.Ref<HTMLDivElement>) {\n const className = cn('mt-8 flex justify-end', props.className);\n return (\n <div {...props} className={className} ref={ref}>\n {props.children}\n </div>\n );\n});\n\nexport type DialogCloseProps = React.HTMLAttributes<HTMLButtonElement> & {\n children: React.JSX.Element;\n};\n\nexport const Close = React.forwardRef(function DialogClose(props: DialogCloseProps, ref: React.Ref<HTMLButtonElement>) {\n const dialog = useCurrentDialog();\n const { children, ...restProps } = props;\n\n return <DialogPrimitive.Close {...restProps} onClick={dialog.onClose} ref={ref} render={children} />;\n});\n\nconst RenderPropWrapper = React.forwardRef(function RenderPropWrapper({ children, onClick, renderProps }: any, ref) {\n const close = () => {\n onClick(new CustomEvent('close'));\n };\n\n return children({ close, ref, ...renderProps });\n});\n\nexport type DialogContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible label to be announced when the dialog is opened */\n 'aria-label': string;\n children: React.ReactNode | ((props: DialogContentRenderProps) => React.ReactNode);\n initialFocus?: DialogPrimitive.Popup.Props['initialFocus'];\n finalFocus?: DialogPrimitive.Popup.Props['finalFocus'];\n};\nexport const Content = React.forwardRef(function DialogContent(\n props: DialogContentProps,\n forwardedRef: React.Ref<HTMLDivElement>\n) {\n const dialog = useCurrentDialog();\n // Popup ref lives on the Dialog root so descendants can read it via `useDialogScope`;\n // we attach it to the popup node here and merge in any forwarded ref.\n const popupRef = dialog.popupRef as React.RefObject<HTMLDivElement | null>;\n const setPopupRef = React.useMemo(() => mergeRefs<HTMLDivElement>([popupRef, forwardedRef]), [popupRef, forwardedRef]);\n const { position, dragging, handleProps: dragHandleProps } = useDraggable(popupRef);\n const { texts } = useLocalization();\n\n const className = cn(\n 'relative animate-[fade-in_150ms] rounded bg-white print:!static',\n DIALOG_POSITION_CLASSNAMES,\n DIALOG_SIZE_CLASSNAME[dialog.size],\n 'print:m-0 print:h-max print:w-full print:overflow-visible'\n );\n\n const containerClassName = cn(\n 'relative z-10 rounded bg-white p-6 shadow print:p-0',\n // The `!fixed` property is crucial to ensure that when a draggable dialog is moved, the printed document still displays its content across the full page.\n 'print:!inset-0 print:!m-0 print:h-max print:!transform-none print:overflow-visible',\n {\n 'rounded-b-none': !!dialog.elements.extra,\n },\n props.className\n );\n\n let output;\n\n if (typeof props.children === 'function') {\n output = (\n <Close>\n <RenderPropWrapper renderProps={{ drawer: dialog.drawer }}>{props.children}</RenderPropWrapper>\n </Close>\n );\n } else {\n output = props.children;\n }\n return (\n <DialogPrimitive.Portal>\n <Backdrop>\n <DialogPrimitive.Popup\n {...props}\n className={className}\n ref={setPopupRef}\n style={{\n ...props.style,\n left: dialog.draggable ? `${position.x}px` : undefined,\n top: dialog.draggable ? `${position.y}px` : undefined,\n }}>\n <div className={containerClassName} data-taco=\"dialog\">\n {output}\n {dialog.draggable && (\n <div\n {...dragHandleProps}\n role=\"button\"\n draggable\n aria-grabbed={dragging}\n aria-label={texts.dialog.drag}\n className=\"yt-dialog__drag top-1.5 h-3 w-24 cursor-move rounded bg-gray-100 text-center absolute-center-x print:hidden\"\n />\n )}\n {dialog.showCloseButton ? (\n <DialogPrimitive.Close\n onClick={dialog.onClose}\n render={\n <LegacyIconButton\n appearance=\"discrete\"\n aria-label={texts.dialog.close}\n className=\"absolute right-0 top-0 mr-2 mt-2 print:hidden\"\n icon=\"close\"\n />\n }></DialogPrimitive.Close>\n ) : null}\n </div>\n {dialog.elements.drawer}\n {dialog.elements.extra}\n </DialogPrimitive.Popup>\n </Backdrop>\n </DialogPrimitive.Portal>\n );\n});\n"],"names":["DialogPrimitive","RenderPropWrapper"],"mappings":";;;;;;;;;;AAoBO,MAAM,QAAQ,MAAM,WAAW,SAAS,YAAY,OAAyB,KAAoC;AACpH,QAAM,YAAY,GAAG,eAAe,MAAM,SAAS;AACnD,6CAAQA,OAAgB,OAAhB,EAAuB,GAAG,OAAO,WAAsB,KAAU;AAC7E,CAAC;AAGM,MAAM,SAAS,MAAM,WAAW,SAAS,aAAa,OAA0B,KAAgC;AACnH,QAAM,YAAY,GAAG,yBAAyB,MAAM,SAAS;AAC7D,6CACK,OAAA,EAAK,GAAG,OAAO,WAAsB,IAAA,GACjC,MAAM,QACX;AAER,CAAC;AAMM,MAAM,QAAQ,MAAM,WAAW,SAAS,YAAY,OAAyB,KAAmC;AACnH,QAAM,SAAS,iBAAA;AACf,QAAM,EAAE,UAAU,GAAG,UAAA,IAAc;AAEnC,SAAO,sBAAA,cAACA,OAAgB,OAAhB,EAAuB,GAAG,WAAW,SAAS,OAAO,SAAS,KAAU,QAAQ,SAAA,CAAU;AACtG,CAAC;AAED,MAAM,oBAAoB,MAAM,WAAW,SAASC,mBAAkB,EAAE,UAAU,SAAS,YAAA,GAAoB,KAAK;AAChH,QAAM,QAAQ,MAAM;AAChB,YAAQ,IAAI,YAAY,OAAO,CAAC;AAAA,EACpC;AAEA,SAAO,SAAS,EAAE,OAAO,KAAK,GAAG,aAAa;AAClD,CAAC;AASM,MAAM,UAAU,MAAM,WAAW,SAAS,cAC7C,OACA,cACF;AACE,QAAM,SAAS,iBAAA;AAGf,QAAM,WAAW,OAAO;AACxB,QAAM,cAAc,MAAM,QAAQ,MAAM,UAA0B,CAAC,UAAU,YAAY,CAAC,GAAG,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O;AAAA,QAChB,QACI,sBAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,YAAW;AAAA,YACX,cAAY,MAAM,OAAO;AAAA,YACzB,WAAU;AAAA,YACV,MAAK;AAAA,UAAA;AAAA,QAAA;AAAA,MACT;AAAA,IAAA,IAER,IACR;AAAA,IACC,OAAO,SAAS;AAAA,IAChB,OAAO,SAAS;AAAA,EAAA,CAEzB,CACJ;AAER,CAAC;"}
|
|
@@ -98,7 +98,7 @@ const Content = React.forwardRef(function Content2(props, externalRef) {
|
|
|
98
98
|
if (containerWidth) {
|
|
99
99
|
return Math.min(RESIZE_MAX, Math.max(RESIZE_MIN, containerWidth - position.x || 0));
|
|
100
100
|
}
|
|
101
|
-
return;
|
|
101
|
+
return void 0;
|
|
102
102
|
}, [containerWidth, position]);
|
|
103
103
|
React.useImperativeHandle(
|
|
104
104
|
containerRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Content.cjs","sources":["../../../../src/components/Drawer/components/Content.tsx"],"sourcesContent":["import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer';\nimport cn from 'clsx';\nimport React from 'react';\n\nimport type { GroupProps } from '@/components';\nimport { LegacyIconButton, useLocalization } from '@/components';\nimport { useCurrentMenu } from '@/components/Menu/Context';\nimport { useMergedRef } from '@/hooks/useMergedRef';\nimport { useDraggable } from '@/utils/hooks/useDraggable';\n\nimport { useCurrentDrawer } from '../Context';\nimport { getDrawerContainerClassNames, getDrawerContentClassNames, getDrawerDragHandlerClassNames } from '../util';\n\nconst RESIZE_MIN = 360;\nconst RESIZE_MAX = 1000;\n\nexport enum DrawerAnimationDefinition {\n Visible = 'visible',\n Hidden = 'hidden',\n}\n\nconst RenderPropWrapper = React.forwardRef(function RenderPropWrapper({ children, onClick, renderProps }: any, ref) {\n const close = () => {\n onClick(new CustomEvent('close'));\n };\n\n return children({ close, ref, ...renderProps });\n});\n\nexport type DrawerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DrawerTitle(props: DrawerTitleProps, externalRef: React.Ref<HTMLHeadingElement>) {\n const { className, children, ...otherProps } = props;\n const ref = useMergedRef<HTMLHeadingElement>(externalRef);\n const [style, setStyle] = React.useState({});\n const { texts } = useLocalization();\n const { onClickBack } = useCurrentDrawer();\n\n /**\n * By design in default drawer version Title has grey separator, but we might have exceptions like Drawer + Tabs scenario,\n * where we might want to hide the grey separator. For this reason separator was rendered with using of classNames,\n * so it can be easily overriden in exceptional scenarios.\n * */\n const cName = cn('mb-0 flex grow-0 items-start justify-self-start border-b-[1px] border-gray-200 px-4 py-4', className);\n\n React.useEffect(() => {\n const drawer = ref?.current?.closest('[data-taco=\"drawer\"]');\n\n // This is the margin amount that we need to deduct from the margins to align with the design\n const marginAdjust = 4;\n\n const closeButton: HTMLButtonElement | null = drawer?.querySelector(`[aria-label=\"${texts.drawer.close}\"]`) ?? null;\n const closeButtonWidth = closeButton?.offsetWidth ?? 0;\n const closeButtonRightMargin = 8;\n\n const actionsWrapper: HTMLSpanElement | null = drawer?.querySelector('#taco-drawer-actions[data-taco=\"group\"]') ?? null;\n const actionsWrapperWidth = actionsWrapper?.offsetWidth ?? 0;\n const actionsWrapperRightMargin = 8;\n\n const marginRight =\n closeButtonWidth + actionsWrapperWidth + closeButtonRightMargin + actionsWrapperRightMargin - marginAdjust;\n\n setStyle({ marginRight });\n }, [ref, texts.drawer.close]);\n\n return (\n <DrawerPrimitive.Title className={cName} {...otherProps} ref={ref}>\n {onClickBack ? (\n <LegacyIconButton\n appearance=\"discrete\"\n aria-label={texts.drawer.back}\n className=\"mr-3 text-base\"\n icon=\"chevron-left\"\n onClick={onClickBack}\n />\n ) : null}\n {\n // We need to apply the right margin as an inline style instead of using Tailwind CSS.\n // This is necessary because we are creating styles dynamically at runtime,\n // and Tailwind doesn't support generating runtime styles.\n }\n <span className=\"line-clamp-2 inline-block overflow-y-hidden\" style={style}>\n {children}\n </span>\n </DrawerPrimitive.Title>\n );\n});\n\nexport type DrawerFooterProps = React.HTMLAttributes<HTMLDivElement>;\nexport const Footer = React.forwardRef(function DrawerFooter(props: DrawerFooterProps, ref: React.Ref<HTMLDivElement>) {\n const { className: _1, ...otherProps } = props;\n /**\n * The same scenario as Title, grey separator rendered using classNames to have posibility to override it.\n */\n const cName = cn('mt-auto flex grow-0 justify-end border-t-[1px] border-gray-200 p-4', props.className);\n return <div {...otherProps} className={cName} ref={ref} />;\n});\n\nexport const Actions = React.forwardRef(function Actions(props: GroupProps, ref: React.Ref<HTMLDivElement>) {\n const { className, ...otherProps } = props;\n const cName = cn('absolute right-10 top-0 mr-[2] mt-4 flex gap-2', className);\n // Id is added to identify the actions wrapper inside a useEffect in Dialog.Title\n return <div {...otherProps} className={cName} id=\"taco-drawer-actions\" ref={ref} />;\n});\n\nexport type DrawerCloseProps = React.HTMLAttributes<HTMLButtonElement> & {\n children: React.ReactElement;\n};\n\nexport const Close = React.forwardRef(function DrawerClose(props: DrawerCloseProps, ref: React.Ref<HTMLButtonElement>) {\n const { onClose } = useCurrentDrawer();\n\n const { children, ...restProps } = props;\n\n return <DrawerPrimitive.Close {...restProps} onClick={onClose} ref={ref} render={children} />;\n});\n\nexport type DrawerInnerContentProps = React.HTMLAttributes<HTMLDivElement>;\n/**\n * It is container component, needed to provide default scrolling behaviour and padding, to simplyfy usage, requested by feature devs.\n * It is optional to use InnerContent component, if consumer need to implement custom behaviour or paddings for inner content,\n * then it's simply enough to render children and wrap them in custom implementation.\n */\nexport const InnerContent = React.forwardRef(function InnerContent(\n props: DrawerInnerContentProps,\n ref: React.Ref<HTMLDivElement>\n) {\n const { className, children, ...otherProps } = props;\n return (\n <div {...otherProps} className={cn('flex grow flex-col overflow-y-hidden', className)} ref={ref}>\n <div className=\"w-full gap-y-0.5 overflow-auto p-4\">{children}</div>\n </div>\n );\n});\n\nexport type DrawerContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible label to be announced when the side drawer is opened */\n 'aria-label': string;\n children: React.ReactNode | ((props: { close: () => void }) => React.ReactNode);\n};\nexport const Content = React.forwardRef(function Content(props: DrawerContentProps, externalRef: React.Ref<HTMLDivElement>) {\n const { containerRef, size, onResize, variant, showCloseButton, outlet } = useCurrentDrawer();\n const { className, children, ...otherProps } = props;\n const { texts } = useLocalization();\n const ref = useMergedRef<HTMLDivElement>(externalRef);\n\n const contentRef = React.useRef(null);\n\n // if the drawer was opened by a menu, we need to close the menu when the drawer closes\n // the menu is still open (and mounted) because it is the trigger for the drawer\n const menu = useCurrentMenu();\n let finalFocus: DrawerPrimitive.Popup.Props['finalFocus'];\n\n if (menu) {\n finalFocus = () => {\n menu.close();\n };\n }\n\n const containerClassName: string = React.useMemo(() => cn(getDrawerContainerClassNames(variant), className), [className]);\n\n const { contentClassName, dragHandlerClassName } = React.useMemo(() => {\n const contentClassName = getDrawerContentClassNames(size, variant);\n const dragHandlerClassName: string = getDrawerDragHandlerClassNames();\n return { contentClassName, dragHandlerClassName };\n }, [size, variant]);\n\n const [containerWidth, setContainerWidth] = React.useState<number>();\n\n // resize\n const dragHandlerRef = React.useRef<HTMLDivElement>(null);\n\n const {\n position,\n dragging,\n handleProps: dragHandleProps,\n resetPosition,\n } = useDraggable(useMergedRef<HTMLDivElement>(dragHandlerRef));\n\n const resizedWidth = React.useMemo((): number | undefined => {\n if (containerWidth) {\n return Math.min(RESIZE_MAX, Math.max(RESIZE_MIN, containerWidth - position.x || 0));\n }\n return;\n }, [containerWidth, position]);\n\n React.useImperativeHandle(\n containerRef,\n () => ({\n onOpen: () => {\n requestAnimationFrame(() => {\n if (contentRef.current) {\n setContainerWidth((contentRef.current as HTMLElement)?.offsetWidth);\n }\n });\n },\n }),\n []\n );\n\n React.useEffect(() => {\n if (onResize) {\n onResize(position.x);\n }\n }, [position]);\n\n React.useEffect(() => {\n if (!dragging && resizedWidth) {\n setContainerWidth(resizedWidth);\n resetPosition();\n }\n }, [dragging]);\n\n let output;\n\n if (typeof children === 'function') {\n output = (\n <Close>\n <RenderPropWrapper>{children}</RenderPropWrapper>\n </Close>\n );\n } else {\n output = children;\n }\n\n const content = (\n <div ref={contentRef} data-taco=\"drawer\" className={containerClassName}>\n {output}\n <div className={dragHandlerClassName} {...dragHandleProps} data-testid=\"resize-handler\" ref={dragHandlerRef}>\n {dragging ? <div data-testid=\"resize-hit-area\" className=\"fixed bottom-0 left-0 right-0 top-0\" /> : null}\n </div>\n {showCloseButton ? (\n <Close>\n <LegacyIconButton\n appearance=\"discrete\"\n aria-label={texts.drawer.close}\n className=\"absolute right-0 top-0 mr-2 mt-4\"\n icon=\"close\"\n />\n </Close>\n ) : null}\n </div>\n );\n\n if (!outlet) {\n return null;\n }\n\n return (\n <DrawerPrimitive.Portal container={outlet ?? undefined} className=\"h-full\">\n {variant === 'overlay' ? (\n <DrawerPrimitive.Backdrop\n className=\"fixed inset-0 cursor-default overflow-y-auto bg-brand-midnight/[0.3] print:absolute print:overflow-visible\"\n data-taco=\"backdrop\"\n />\n ) : null}\n <DrawerPrimitive.Viewport className=\"h-full\">\n <DrawerPrimitive.Popup\n {...otherProps}\n className={contentClassName}\n finalFocus={finalFocus}\n ref={ref}\n style={{ width: resizedWidth }}>\n <DrawerPrimitive.Content>{content}</DrawerPrimitive.Content>\n </DrawerPrimitive.Popup>\n </DrawerPrimitive.Viewport>\n </DrawerPrimitive.Portal>\n );\n});\n"],"names":["RenderPropWrapper","useMergedRef","useLocalization","useCurrentDrawer","drawer","DrawerPrimitive","LegacyIconButton","Actions","InnerContent","Content","useCurrentMenu","getDrawerContainerClassNames","contentClassName","getDrawerContentClassNames","dragHandlerClassName","getDrawerDragHandlerClassNames","useDraggable"],"mappings":";;;;;;;;;;;;AAaA,MAAM,aAAa;AACnB,MAAM,aAAa;AAOnB,MAAM,oBAAoB,MAAM,WAAW,SAASA,mBAAkB,EAAE,UAAU,SAAS,YAAA,GAAoB,KAAK;AAChH,QAAM,QAAQ,MAAM;AAChB,YAAQ,IAAI,YAAY,OAAO,CAAC;AAAA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|
|
1
|
+
{"version":3,"file":"Content.cjs","sources":["../../../../src/components/Drawer/components/Content.tsx"],"sourcesContent":["import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer';\nimport cn from 'clsx';\nimport React from 'react';\n\nimport type { GroupProps } from '@/components';\nimport { LegacyIconButton, useLocalization } from '@/components';\nimport { useCurrentMenu } from '@/components/Menu/Context';\nimport { useMergedRef } from '@/hooks/useMergedRef';\nimport { useDraggable } from '@/utils/hooks/useDraggable';\n\nimport { useCurrentDrawer } from '../Context';\nimport { getDrawerContainerClassNames, getDrawerContentClassNames, getDrawerDragHandlerClassNames } from '../util';\n\nconst RESIZE_MIN = 360;\nconst RESIZE_MAX = 1000;\n\nexport enum DrawerAnimationDefinition {\n Visible = 'visible',\n Hidden = 'hidden',\n}\n\nconst RenderPropWrapper = React.forwardRef(function RenderPropWrapper({ children, onClick, renderProps }: any, ref) {\n const close = () => {\n onClick(new CustomEvent('close'));\n };\n\n return children({ close, ref, ...renderProps });\n});\n\nexport type DrawerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DrawerTitle(props: DrawerTitleProps, externalRef: React.Ref<HTMLHeadingElement>) {\n const { className, children, ...otherProps } = props;\n const ref = useMergedRef<HTMLHeadingElement>(externalRef);\n const [style, setStyle] = React.useState({});\n const { texts } = useLocalization();\n const { onClickBack } = useCurrentDrawer();\n\n /**\n * By design in default drawer version Title has grey separator, but we might have exceptions like Drawer + Tabs scenario,\n * where we might want to hide the grey separator. For this reason separator was rendered with using of classNames,\n * so it can be easily overriden in exceptional scenarios.\n * */\n const cName = cn('mb-0 flex grow-0 items-start justify-self-start border-b-[1px] border-gray-200 px-4 py-4', className);\n\n React.useEffect(() => {\n const drawer = ref?.current?.closest('[data-taco=\"drawer\"]');\n\n // This is the margin amount that we need to deduct from the margins to align with the design\n const marginAdjust = 4;\n\n const closeButton: HTMLButtonElement | null = drawer?.querySelector(`[aria-label=\"${texts.drawer.close}\"]`) ?? null;\n const closeButtonWidth = closeButton?.offsetWidth ?? 0;\n const closeButtonRightMargin = 8;\n\n const actionsWrapper: HTMLSpanElement | null = drawer?.querySelector('#taco-drawer-actions[data-taco=\"group\"]') ?? null;\n const actionsWrapperWidth = actionsWrapper?.offsetWidth ?? 0;\n const actionsWrapperRightMargin = 8;\n\n const marginRight =\n closeButtonWidth + actionsWrapperWidth + closeButtonRightMargin + actionsWrapperRightMargin - marginAdjust;\n\n setStyle({ marginRight });\n }, [ref, texts.drawer.close]);\n\n return (\n <DrawerPrimitive.Title className={cName} {...otherProps} ref={ref}>\n {onClickBack ? (\n <LegacyIconButton\n appearance=\"discrete\"\n aria-label={texts.drawer.back}\n className=\"mr-3 text-base\"\n icon=\"chevron-left\"\n onClick={onClickBack}\n />\n ) : null}\n {\n // We need to apply the right margin as an inline style instead of using Tailwind CSS.\n // This is necessary because we are creating styles dynamically at runtime,\n // and Tailwind doesn't support generating runtime styles.\n }\n <span className=\"line-clamp-2 inline-block overflow-y-hidden\" style={style}>\n {children}\n </span>\n </DrawerPrimitive.Title>\n );\n});\n\nexport type DrawerFooterProps = React.HTMLAttributes<HTMLDivElement>;\nexport const Footer = React.forwardRef(function DrawerFooter(props: DrawerFooterProps, ref: React.Ref<HTMLDivElement>) {\n const { className: _1, ...otherProps } = props;\n /**\n * The same scenario as Title, grey separator rendered using classNames to have posibility to override it.\n */\n const cName = cn('mt-auto flex grow-0 justify-end border-t-[1px] border-gray-200 p-4', props.className);\n return <div {...otherProps} className={cName} ref={ref} />;\n});\n\nexport const Actions = React.forwardRef(function Actions(props: GroupProps, ref: React.Ref<HTMLDivElement>) {\n const { className, ...otherProps } = props;\n const cName = cn('absolute right-10 top-0 mr-[2] mt-4 flex gap-2', className);\n // Id is added to identify the actions wrapper inside a useEffect in Dialog.Title\n return <div {...otherProps} className={cName} id=\"taco-drawer-actions\" ref={ref} />;\n});\n\nexport type DrawerCloseProps = React.HTMLAttributes<HTMLButtonElement> & {\n children: React.ReactElement;\n};\n\nexport const Close = React.forwardRef(function DrawerClose(props: DrawerCloseProps, ref: React.Ref<HTMLButtonElement>) {\n const { onClose } = useCurrentDrawer();\n\n const { children, ...restProps } = props;\n\n return <DrawerPrimitive.Close {...restProps} onClick={onClose} ref={ref} render={children} />;\n});\n\nexport type DrawerInnerContentProps = React.HTMLAttributes<HTMLDivElement>;\n/**\n * It is container component, needed to provide default scrolling behaviour and padding, to simplyfy usage, requested by feature devs.\n * It is optional to use InnerContent component, if consumer need to implement custom behaviour or paddings for inner content,\n * then it's simply enough to render children and wrap them in custom implementation.\n */\nexport const InnerContent = React.forwardRef(function InnerContent(\n props: DrawerInnerContentProps,\n ref: React.Ref<HTMLDivElement>\n) {\n const { className, children, ...otherProps } = props;\n return (\n <div {...otherProps} className={cn('flex grow flex-col overflow-y-hidden', className)} ref={ref}>\n <div className=\"w-full gap-y-0.5 overflow-auto p-4\">{children}</div>\n </div>\n );\n});\n\nexport type DrawerContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible label to be announced when the side drawer is opened */\n 'aria-label': string;\n children: React.ReactNode | ((props: { close: () => void }) => React.ReactNode);\n};\nexport const Content = React.forwardRef(function Content(props: DrawerContentProps, externalRef: React.Ref<HTMLDivElement>) {\n const { containerRef, size, onResize, variant, showCloseButton, outlet } = useCurrentDrawer();\n const { className, children, ...otherProps } = props;\n const { texts } = useLocalization();\n const ref = useMergedRef<HTMLDivElement>(externalRef);\n\n const contentRef = React.useRef(null);\n\n // if the drawer was opened by a menu, we need to close the menu when the drawer closes\n // the menu is still open (and mounted) because it is the trigger for the drawer\n const menu = useCurrentMenu();\n let finalFocus: DrawerPrimitive.Popup.Props['finalFocus'];\n\n if (menu) {\n finalFocus = () => {\n menu.close();\n };\n }\n\n const containerClassName: string = React.useMemo(() => cn(getDrawerContainerClassNames(variant), className), [className]);\n\n const { contentClassName, dragHandlerClassName } = React.useMemo(() => {\n const contentClassName = getDrawerContentClassNames(size, variant);\n const dragHandlerClassName: string = getDrawerDragHandlerClassNames();\n return { contentClassName, dragHandlerClassName };\n }, [size, variant]);\n\n const [containerWidth, setContainerWidth] = React.useState<number>();\n\n // resize\n const dragHandlerRef = React.useRef<HTMLDivElement>(null);\n\n const {\n position,\n dragging,\n handleProps: dragHandleProps,\n resetPosition,\n } = useDraggable(useMergedRef<HTMLDivElement>(dragHandlerRef));\n\n const resizedWidth = React.useMemo((): number | undefined => {\n if (containerWidth) {\n return Math.min(RESIZE_MAX, Math.max(RESIZE_MIN, containerWidth - position.x || 0));\n }\n\n return undefined;\n }, [containerWidth, position]);\n\n React.useImperativeHandle(\n containerRef,\n () => ({\n onOpen: () => {\n requestAnimationFrame(() => {\n if (contentRef.current) {\n setContainerWidth((contentRef.current as HTMLElement)?.offsetWidth);\n }\n });\n },\n }),\n []\n );\n\n React.useEffect(() => {\n if (onResize) {\n onResize(position.x);\n }\n }, [position]);\n\n React.useEffect(() => {\n if (!dragging && resizedWidth) {\n setContainerWidth(resizedWidth);\n resetPosition();\n }\n }, [dragging]);\n\n let output;\n\n if (typeof children === 'function') {\n output = (\n <Close>\n <RenderPropWrapper>{children}</RenderPropWrapper>\n </Close>\n );\n } else {\n output = children;\n }\n\n const content = (\n <div ref={contentRef} data-taco=\"drawer\" className={containerClassName}>\n {output}\n <div className={dragHandlerClassName} {...dragHandleProps} data-testid=\"resize-handler\" ref={dragHandlerRef}>\n {dragging ? <div data-testid=\"resize-hit-area\" className=\"fixed bottom-0 left-0 right-0 top-0\" /> : null}\n </div>\n {showCloseButton ? (\n <Close>\n <LegacyIconButton\n appearance=\"discrete\"\n aria-label={texts.drawer.close}\n className=\"absolute right-0 top-0 mr-2 mt-4\"\n icon=\"close\"\n />\n </Close>\n ) : null}\n </div>\n );\n\n if (!outlet) {\n return null;\n }\n\n return (\n <DrawerPrimitive.Portal container={outlet ?? undefined} className=\"h-full\">\n {variant === 'overlay' ? (\n <DrawerPrimitive.Backdrop\n className=\"fixed inset-0 cursor-default overflow-y-auto bg-brand-midnight/[0.3] print:absolute print:overflow-visible\"\n data-taco=\"backdrop\"\n />\n ) : null}\n <DrawerPrimitive.Viewport className=\"h-full\">\n <DrawerPrimitive.Popup\n {...otherProps}\n className={contentClassName}\n finalFocus={finalFocus}\n ref={ref}\n style={{ width: resizedWidth }}>\n <DrawerPrimitive.Content>{content}</DrawerPrimitive.Content>\n </DrawerPrimitive.Popup>\n </DrawerPrimitive.Viewport>\n </DrawerPrimitive.Portal>\n );\n});\n"],"names":["RenderPropWrapper","useMergedRef","useLocalization","useCurrentDrawer","drawer","DrawerPrimitive","LegacyIconButton","Actions","InnerContent","Content","useCurrentMenu","getDrawerContainerClassNames","contentClassName","getDrawerContentClassNames","dragHandlerClassName","getDrawerDragHandlerClassNames","useDraggable"],"mappings":";;;;;;;;;;;;AAaA,MAAM,aAAa;AACnB,MAAM,aAAa;AAOnB,MAAM,oBAAoB,MAAM,WAAW,SAASA,mBAAkB,EAAE,UAAU,SAAS,YAAA,GAAoB,KAAK;AAChH,QAAM,QAAQ,MAAM;AAChB,YAAQ,IAAI,YAAY,OAAO,CAAC;AAAA,EACpC;AAEA,SAAO,SAAS,EAAE,OAAO,KAAK,GAAG,aAAa;AAClD,CAAC;AAGM,MAAM,QAAQ,MAAM,WAAW,SAAS,YAAY,OAAyB,aAA4C;AAC5H,QAAM,EAAE,WAAW,UAAU,GAAG,eAAe;AAC/C,QAAM,MAAMC,aAAAA,aAAiC,WAAW;AACxD,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,CAAA,CAAE;AAC3C,QAAM,EAAE,MAAA,IAAUC,6BAAA;AAClB,QAAM,EAAE,YAAA,IAAgBC,yBAAA;AAOxB,QAAM,QAAQ,GAAG,4FAA4F,SAAS;AAEtH,QAAM,UAAU,MAAM;AAClB,UAAMC,UAAS,KAAK,SAAS,QAAQ,sBAAsB;AAG3D,UAAM,eAAe;AAErB,UAAM,cAAwCA,SAAQ,cAAc,gBAAgB,MAAM,OAAO,KAAK,IAAI,KAAK;AAC/G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MACX,cAAY,MAAM,OAAO;AAAA,MACzB,WAAU;AAAA,MACV,MAAK;AAAA,IAAA;AAAA,EAAA,CAEb,IACA,IACR;AAGJ,MAAI,CAAC,QAAQ;AACT,WAAO;AAAA,EACX;AAEA,SACI,sBAAA,cAACD,OAAAA,OAAgB,QAAhB,EAAuB,WAAW,UAAU,QAAW,WAAU,SAAA,GAC7D,YAAY,YACT,sBAAA;AAAA,IAACA,OAAAA,OAAgB;AAAA,IAAhB;AAAA,MACG,WAAU;AAAA,MACV,aAAU;AAAA,IAAA;AAAA,EAAA,IAEd,MACJ,sBAAA,cAACA,OAAAA,OAAgB,UAAhB,EAAyB,WAAU,YAChC,sBAAA;AAAA,IAACA,OAAAA,OAAgB;AAAA,IAAhB;AAAA,MACI,GAAG;AAAA,MACJ,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,OAAO,EAAE,OAAO,aAAA;AAAA,IAAa;AAAA,IAC7B,sBAAA,cAACA,OAAAA,OAAgB,SAAhB,MAAyB,OAAQ;AAAA,EAAA,CAE1C,CACJ;AAER,CAAC;;;;;;;"}
|
|
@@ -96,7 +96,7 @@ const Content = React__default.forwardRef(function Content2(props, externalRef)
|
|
|
96
96
|
if (containerWidth) {
|
|
97
97
|
return Math.min(RESIZE_MAX, Math.max(RESIZE_MIN, containerWidth - position.x || 0));
|
|
98
98
|
}
|
|
99
|
-
return;
|
|
99
|
+
return void 0;
|
|
100
100
|
}, [containerWidth, position]);
|
|
101
101
|
React__default.useImperativeHandle(
|
|
102
102
|
containerRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Content.js","sources":["../../../../src/components/Drawer/components/Content.tsx"],"sourcesContent":["import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer';\nimport cn from 'clsx';\nimport React from 'react';\n\nimport type { GroupProps } from '@/components';\nimport { LegacyIconButton, useLocalization } from '@/components';\nimport { useCurrentMenu } from '@/components/Menu/Context';\nimport { useMergedRef } from '@/hooks/useMergedRef';\nimport { useDraggable } from '@/utils/hooks/useDraggable';\n\nimport { useCurrentDrawer } from '../Context';\nimport { getDrawerContainerClassNames, getDrawerContentClassNames, getDrawerDragHandlerClassNames } from '../util';\n\nconst RESIZE_MIN = 360;\nconst RESIZE_MAX = 1000;\n\nexport enum DrawerAnimationDefinition {\n Visible = 'visible',\n Hidden = 'hidden',\n}\n\nconst RenderPropWrapper = React.forwardRef(function RenderPropWrapper({ children, onClick, renderProps }: any, ref) {\n const close = () => {\n onClick(new CustomEvent('close'));\n };\n\n return children({ close, ref, ...renderProps });\n});\n\nexport type DrawerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DrawerTitle(props: DrawerTitleProps, externalRef: React.Ref<HTMLHeadingElement>) {\n const { className, children, ...otherProps } = props;\n const ref = useMergedRef<HTMLHeadingElement>(externalRef);\n const [style, setStyle] = React.useState({});\n const { texts } = useLocalization();\n const { onClickBack } = useCurrentDrawer();\n\n /**\n * By design in default drawer version Title has grey separator, but we might have exceptions like Drawer + Tabs scenario,\n * where we might want to hide the grey separator. For this reason separator was rendered with using of classNames,\n * so it can be easily overriden in exceptional scenarios.\n * */\n const cName = cn('mb-0 flex grow-0 items-start justify-self-start border-b-[1px] border-gray-200 px-4 py-4', className);\n\n React.useEffect(() => {\n const drawer = ref?.current?.closest('[data-taco=\"drawer\"]');\n\n // This is the margin amount that we need to deduct from the margins to align with the design\n const marginAdjust = 4;\n\n const closeButton: HTMLButtonElement | null = drawer?.querySelector(`[aria-label=\"${texts.drawer.close}\"]`) ?? null;\n const closeButtonWidth = closeButton?.offsetWidth ?? 0;\n const closeButtonRightMargin = 8;\n\n const actionsWrapper: HTMLSpanElement | null = drawer?.querySelector('#taco-drawer-actions[data-taco=\"group\"]') ?? null;\n const actionsWrapperWidth = actionsWrapper?.offsetWidth ?? 0;\n const actionsWrapperRightMargin = 8;\n\n const marginRight =\n closeButtonWidth + actionsWrapperWidth + closeButtonRightMargin + actionsWrapperRightMargin - marginAdjust;\n\n setStyle({ marginRight });\n }, [ref, texts.drawer.close]);\n\n return (\n <DrawerPrimitive.Title className={cName} {...otherProps} ref={ref}>\n {onClickBack ? (\n <LegacyIconButton\n appearance=\"discrete\"\n aria-label={texts.drawer.back}\n className=\"mr-3 text-base\"\n icon=\"chevron-left\"\n onClick={onClickBack}\n />\n ) : null}\n {\n // We need to apply the right margin as an inline style instead of using Tailwind CSS.\n // This is necessary because we are creating styles dynamically at runtime,\n // and Tailwind doesn't support generating runtime styles.\n }\n <span className=\"line-clamp-2 inline-block overflow-y-hidden\" style={style}>\n {children}\n </span>\n </DrawerPrimitive.Title>\n );\n});\n\nexport type DrawerFooterProps = React.HTMLAttributes<HTMLDivElement>;\nexport const Footer = React.forwardRef(function DrawerFooter(props: DrawerFooterProps, ref: React.Ref<HTMLDivElement>) {\n const { className: _1, ...otherProps } = props;\n /**\n * The same scenario as Title, grey separator rendered using classNames to have posibility to override it.\n */\n const cName = cn('mt-auto flex grow-0 justify-end border-t-[1px] border-gray-200 p-4', props.className);\n return <div {...otherProps} className={cName} ref={ref} />;\n});\n\nexport const Actions = React.forwardRef(function Actions(props: GroupProps, ref: React.Ref<HTMLDivElement>) {\n const { className, ...otherProps } = props;\n const cName = cn('absolute right-10 top-0 mr-[2] mt-4 flex gap-2', className);\n // Id is added to identify the actions wrapper inside a useEffect in Dialog.Title\n return <div {...otherProps} className={cName} id=\"taco-drawer-actions\" ref={ref} />;\n});\n\nexport type DrawerCloseProps = React.HTMLAttributes<HTMLButtonElement> & {\n children: React.ReactElement;\n};\n\nexport const Close = React.forwardRef(function DrawerClose(props: DrawerCloseProps, ref: React.Ref<HTMLButtonElement>) {\n const { onClose } = useCurrentDrawer();\n\n const { children, ...restProps } = props;\n\n return <DrawerPrimitive.Close {...restProps} onClick={onClose} ref={ref} render={children} />;\n});\n\nexport type DrawerInnerContentProps = React.HTMLAttributes<HTMLDivElement>;\n/**\n * It is container component, needed to provide default scrolling behaviour and padding, to simplyfy usage, requested by feature devs.\n * It is optional to use InnerContent component, if consumer need to implement custom behaviour or paddings for inner content,\n * then it's simply enough to render children and wrap them in custom implementation.\n */\nexport const InnerContent = React.forwardRef(function InnerContent(\n props: DrawerInnerContentProps,\n ref: React.Ref<HTMLDivElement>\n) {\n const { className, children, ...otherProps } = props;\n return (\n <div {...otherProps} className={cn('flex grow flex-col overflow-y-hidden', className)} ref={ref}>\n <div className=\"w-full gap-y-0.5 overflow-auto p-4\">{children}</div>\n </div>\n );\n});\n\nexport type DrawerContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible label to be announced when the side drawer is opened */\n 'aria-label': string;\n children: React.ReactNode | ((props: { close: () => void }) => React.ReactNode);\n};\nexport const Content = React.forwardRef(function Content(props: DrawerContentProps, externalRef: React.Ref<HTMLDivElement>) {\n const { containerRef, size, onResize, variant, showCloseButton, outlet } = useCurrentDrawer();\n const { className, children, ...otherProps } = props;\n const { texts } = useLocalization();\n const ref = useMergedRef<HTMLDivElement>(externalRef);\n\n const contentRef = React.useRef(null);\n\n // if the drawer was opened by a menu, we need to close the menu when the drawer closes\n // the menu is still open (and mounted) because it is the trigger for the drawer\n const menu = useCurrentMenu();\n let finalFocus: DrawerPrimitive.Popup.Props['finalFocus'];\n\n if (menu) {\n finalFocus = () => {\n menu.close();\n };\n }\n\n const containerClassName: string = React.useMemo(() => cn(getDrawerContainerClassNames(variant), className), [className]);\n\n const { contentClassName, dragHandlerClassName } = React.useMemo(() => {\n const contentClassName = getDrawerContentClassNames(size, variant);\n const dragHandlerClassName: string = getDrawerDragHandlerClassNames();\n return { contentClassName, dragHandlerClassName };\n }, [size, variant]);\n\n const [containerWidth, setContainerWidth] = React.useState<number>();\n\n // resize\n const dragHandlerRef = React.useRef<HTMLDivElement>(null);\n\n const {\n position,\n dragging,\n handleProps: dragHandleProps,\n resetPosition,\n } = useDraggable(useMergedRef<HTMLDivElement>(dragHandlerRef));\n\n const resizedWidth = React.useMemo((): number | undefined => {\n if (containerWidth) {\n return Math.min(RESIZE_MAX, Math.max(RESIZE_MIN, containerWidth - position.x || 0));\n }\n return;\n }, [containerWidth, position]);\n\n React.useImperativeHandle(\n containerRef,\n () => ({\n onOpen: () => {\n requestAnimationFrame(() => {\n if (contentRef.current) {\n setContainerWidth((contentRef.current as HTMLElement)?.offsetWidth);\n }\n });\n },\n }),\n []\n );\n\n React.useEffect(() => {\n if (onResize) {\n onResize(position.x);\n }\n }, [position]);\n\n React.useEffect(() => {\n if (!dragging && resizedWidth) {\n setContainerWidth(resizedWidth);\n resetPosition();\n }\n }, [dragging]);\n\n let output;\n\n if (typeof children === 'function') {\n output = (\n <Close>\n <RenderPropWrapper>{children}</RenderPropWrapper>\n </Close>\n );\n } else {\n output = children;\n }\n\n const content = (\n <div ref={contentRef} data-taco=\"drawer\" className={containerClassName}>\n {output}\n <div className={dragHandlerClassName} {...dragHandleProps} data-testid=\"resize-handler\" ref={dragHandlerRef}>\n {dragging ? <div data-testid=\"resize-hit-area\" className=\"fixed bottom-0 left-0 right-0 top-0\" /> : null}\n </div>\n {showCloseButton ? (\n <Close>\n <LegacyIconButton\n appearance=\"discrete\"\n aria-label={texts.drawer.close}\n className=\"absolute right-0 top-0 mr-2 mt-4\"\n icon=\"close\"\n />\n </Close>\n ) : null}\n </div>\n );\n\n if (!outlet) {\n return null;\n }\n\n return (\n <DrawerPrimitive.Portal container={outlet ?? undefined} className=\"h-full\">\n {variant === 'overlay' ? (\n <DrawerPrimitive.Backdrop\n className=\"fixed inset-0 cursor-default overflow-y-auto bg-brand-midnight/[0.3] print:absolute print:overflow-visible\"\n data-taco=\"backdrop\"\n />\n ) : null}\n <DrawerPrimitive.Viewport className=\"h-full\">\n <DrawerPrimitive.Popup\n {...otherProps}\n className={contentClassName}\n finalFocus={finalFocus}\n ref={ref}\n style={{ width: resizedWidth }}>\n <DrawerPrimitive.Content>{content}</DrawerPrimitive.Content>\n </DrawerPrimitive.Popup>\n </DrawerPrimitive.Viewport>\n </DrawerPrimitive.Portal>\n );\n});\n"],"names":["React","RenderPropWrapper","DrawerPrimitive","Actions","InnerContent","Content","contentClassName","dragHandlerClassName"],"mappings":";;;;;;;;;;AAaA,MAAM,aAAa;AACnB,MAAM,aAAa;AAOnB,MAAM,oBAAoBA,eAAM,WAAW,SAASC,mBAAkB,EAAE,UAAU,SAAS,YAAA,GAAoB,KAAK;AAChH,QAAM,QAAQ,MAAM;AAChB,YAAQ,IAAI,YAAY,OAAO,CAAC;AAAA,EACpC;AAEA,SAAO,SAAS,EAAE,OAAO,KAAK,GAAG,aAAa;AAClD,CAAC;AAGM,MAAM,QAAQD,eAAM,WAAW,SAAS,YAAY,OAAyB,aAA4C;AAC5H,QAAM,EAAE,WAAW,UAAU,GAAG,eAAe;AAC/C,QAAM,MAAM,aAAiC,WAAW;AACxD,QAAM,CAAC,OAAO,QAAQ,IAAIA,eAAM,SAAS,CAAA,CAAE;AAC3C,QAAM,EAAE,MAAA,IAAU,gBAAA;AAClB,QAAM,EAAE,YAAA,IAAgB,iBAAA;AAOxB,QAAM,QAAQ,GAAG,4FAA4F,SAAS;AAEtHA,iBAAM,UAAU,MAAM;AAClB,UAAM,SAAS,KAAK,SAAS,QAAQ,sBAAsB;AAG3D,UAAM,eAAe;AAErB,UAAM,cAAwC,QAAQ,cAAc,gBAAgB,MAAM,OAAO,KAAK,IAAI,KAAK;AAC/G,UAAM,mBAAmB,aAAa,eAAe;AACrD,UAAM,yBAAyB;AAE/B,UAAM,iBAAyC,QAAQ,cAAc,yCAAyC,KAAK;AACnH,UAAM,sBAAsB,gBAAgB,eAAe;AAC3D,UAAM,4BAA4B;AAElC,UAAM,cACF,mBAAmB,sBAAsB,yBAAyB,4BAA4B;AAElG,aAAS,EAAE,aAAa;AAAA,EAC5B,GAAG,CAAC,KAAK,MAAM,OAAO,KAAK,CAAC;AAE5B,SACIA,+BAAA,cAACE,OAAgB,OAAhB,EAAsB,WAAW,OAAQ,GAAG,YAAY,IAAA,GACpD,cACGF,+BAAA;AAA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AhB;AAAA,MACI,GAAG;AAAA,MACJ,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,OAAO,EAAE,OAAO,aAAA;AAAA,IAAa;AAAA,IAC7BF,+BAAA,cAACE,OAAgB,SAAhB,MAAyB,OAAQ;AAAA,EAAA,CAE1C,CACJ;AAER,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Content.js","sources":["../../../../src/components/Drawer/components/Content.tsx"],"sourcesContent":["import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer';\nimport cn from 'clsx';\nimport React from 'react';\n\nimport type { GroupProps } from '@/components';\nimport { LegacyIconButton, useLocalization } from '@/components';\nimport { useCurrentMenu } from '@/components/Menu/Context';\nimport { useMergedRef } from '@/hooks/useMergedRef';\nimport { useDraggable } from '@/utils/hooks/useDraggable';\n\nimport { useCurrentDrawer } from '../Context';\nimport { getDrawerContainerClassNames, getDrawerContentClassNames, getDrawerDragHandlerClassNames } from '../util';\n\nconst RESIZE_MIN = 360;\nconst RESIZE_MAX = 1000;\n\nexport enum DrawerAnimationDefinition {\n Visible = 'visible',\n Hidden = 'hidden',\n}\n\nconst RenderPropWrapper = React.forwardRef(function RenderPropWrapper({ children, onClick, renderProps }: any, ref) {\n const close = () => {\n onClick(new CustomEvent('close'));\n };\n\n return children({ close, ref, ...renderProps });\n});\n\nexport type DrawerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DrawerTitle(props: DrawerTitleProps, externalRef: React.Ref<HTMLHeadingElement>) {\n const { className, children, ...otherProps } = props;\n const ref = useMergedRef<HTMLHeadingElement>(externalRef);\n const [style, setStyle] = React.useState({});\n const { texts } = useLocalization();\n const { onClickBack } = useCurrentDrawer();\n\n /**\n * By design in default drawer version Title has grey separator, but we might have exceptions like Drawer + Tabs scenario,\n * where we might want to hide the grey separator. For this reason separator was rendered with using of classNames,\n * so it can be easily overriden in exceptional scenarios.\n * */\n const cName = cn('mb-0 flex grow-0 items-start justify-self-start border-b-[1px] border-gray-200 px-4 py-4', className);\n\n React.useEffect(() => {\n const drawer = ref?.current?.closest('[data-taco=\"drawer\"]');\n\n // This is the margin amount that we need to deduct from the margins to align with the design\n const marginAdjust = 4;\n\n const closeButton: HTMLButtonElement | null = drawer?.querySelector(`[aria-label=\"${texts.drawer.close}\"]`) ?? null;\n const closeButtonWidth = closeButton?.offsetWidth ?? 0;\n const closeButtonRightMargin = 8;\n\n const actionsWrapper: HTMLSpanElement | null = drawer?.querySelector('#taco-drawer-actions[data-taco=\"group\"]') ?? null;\n const actionsWrapperWidth = actionsWrapper?.offsetWidth ?? 0;\n const actionsWrapperRightMargin = 8;\n\n const marginRight =\n closeButtonWidth + actionsWrapperWidth + closeButtonRightMargin + actionsWrapperRightMargin - marginAdjust;\n\n setStyle({ marginRight });\n }, [ref, texts.drawer.close]);\n\n return (\n <DrawerPrimitive.Title className={cName} {...otherProps} ref={ref}>\n {onClickBack ? (\n <LegacyIconButton\n appearance=\"discrete\"\n aria-label={texts.drawer.back}\n className=\"mr-3 text-base\"\n icon=\"chevron-left\"\n onClick={onClickBack}\n />\n ) : null}\n {\n // We need to apply the right margin as an inline style instead of using Tailwind CSS.\n // This is necessary because we are creating styles dynamically at runtime,\n // and Tailwind doesn't support generating runtime styles.\n }\n <span className=\"line-clamp-2 inline-block overflow-y-hidden\" style={style}>\n {children}\n </span>\n </DrawerPrimitive.Title>\n );\n});\n\nexport type DrawerFooterProps = React.HTMLAttributes<HTMLDivElement>;\nexport const Footer = React.forwardRef(function DrawerFooter(props: DrawerFooterProps, ref: React.Ref<HTMLDivElement>) {\n const { className: _1, ...otherProps } = props;\n /**\n * The same scenario as Title, grey separator rendered using classNames to have posibility to override it.\n */\n const cName = cn('mt-auto flex grow-0 justify-end border-t-[1px] border-gray-200 p-4', props.className);\n return <div {...otherProps} className={cName} ref={ref} />;\n});\n\nexport const Actions = React.forwardRef(function Actions(props: GroupProps, ref: React.Ref<HTMLDivElement>) {\n const { className, ...otherProps } = props;\n const cName = cn('absolute right-10 top-0 mr-[2] mt-4 flex gap-2', className);\n // Id is added to identify the actions wrapper inside a useEffect in Dialog.Title\n return <div {...otherProps} className={cName} id=\"taco-drawer-actions\" ref={ref} />;\n});\n\nexport type DrawerCloseProps = React.HTMLAttributes<HTMLButtonElement> & {\n children: React.ReactElement;\n};\n\nexport const Close = React.forwardRef(function DrawerClose(props: DrawerCloseProps, ref: React.Ref<HTMLButtonElement>) {\n const { onClose } = useCurrentDrawer();\n\n const { children, ...restProps } = props;\n\n return <DrawerPrimitive.Close {...restProps} onClick={onClose} ref={ref} render={children} />;\n});\n\nexport type DrawerInnerContentProps = React.HTMLAttributes<HTMLDivElement>;\n/**\n * It is container component, needed to provide default scrolling behaviour and padding, to simplyfy usage, requested by feature devs.\n * It is optional to use InnerContent component, if consumer need to implement custom behaviour or paddings for inner content,\n * then it's simply enough to render children and wrap them in custom implementation.\n */\nexport const InnerContent = React.forwardRef(function InnerContent(\n props: DrawerInnerContentProps,\n ref: React.Ref<HTMLDivElement>\n) {\n const { className, children, ...otherProps } = props;\n return (\n <div {...otherProps} className={cn('flex grow flex-col overflow-y-hidden', className)} ref={ref}>\n <div className=\"w-full gap-y-0.5 overflow-auto p-4\">{children}</div>\n </div>\n );\n});\n\nexport type DrawerContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible label to be announced when the side drawer is opened */\n 'aria-label': string;\n children: React.ReactNode | ((props: { close: () => void }) => React.ReactNode);\n};\nexport const Content = React.forwardRef(function Content(props: DrawerContentProps, externalRef: React.Ref<HTMLDivElement>) {\n const { containerRef, size, onResize, variant, showCloseButton, outlet } = useCurrentDrawer();\n const { className, children, ...otherProps } = props;\n const { texts } = useLocalization();\n const ref = useMergedRef<HTMLDivElement>(externalRef);\n\n const contentRef = React.useRef(null);\n\n // if the drawer was opened by a menu, we need to close the menu when the drawer closes\n // the menu is still open (and mounted) because it is the trigger for the drawer\n const menu = useCurrentMenu();\n let finalFocus: DrawerPrimitive.Popup.Props['finalFocus'];\n\n if (menu) {\n finalFocus = () => {\n menu.close();\n };\n }\n\n const containerClassName: string = React.useMemo(() => cn(getDrawerContainerClassNames(variant), className), [className]);\n\n const { contentClassName, dragHandlerClassName } = React.useMemo(() => {\n const contentClassName = getDrawerContentClassNames(size, variant);\n const dragHandlerClassName: string = getDrawerDragHandlerClassNames();\n return { contentClassName, dragHandlerClassName };\n }, [size, variant]);\n\n const [containerWidth, setContainerWidth] = React.useState<number>();\n\n // resize\n const dragHandlerRef = React.useRef<HTMLDivElement>(null);\n\n const {\n position,\n dragging,\n handleProps: dragHandleProps,\n resetPosition,\n } = useDraggable(useMergedRef<HTMLDivElement>(dragHandlerRef));\n\n const resizedWidth = React.useMemo((): number | undefined => {\n if (containerWidth) {\n return Math.min(RESIZE_MAX, Math.max(RESIZE_MIN, containerWidth - position.x || 0));\n }\n\n return undefined;\n }, [containerWidth, position]);\n\n React.useImperativeHandle(\n containerRef,\n () => ({\n onOpen: () => {\n requestAnimationFrame(() => {\n if (contentRef.current) {\n setContainerWidth((contentRef.current as HTMLElement)?.offsetWidth);\n }\n });\n },\n }),\n []\n );\n\n React.useEffect(() => {\n if (onResize) {\n onResize(position.x);\n }\n }, [position]);\n\n React.useEffect(() => {\n if (!dragging && resizedWidth) {\n setContainerWidth(resizedWidth);\n resetPosition();\n }\n }, [dragging]);\n\n let output;\n\n if (typeof children === 'function') {\n output = (\n <Close>\n <RenderPropWrapper>{children}</RenderPropWrapper>\n </Close>\n );\n } else {\n output = children;\n }\n\n const content = (\n <div ref={contentRef} data-taco=\"drawer\" className={containerClassName}>\n {output}\n <div className={dragHandlerClassName} {...dragHandleProps} data-testid=\"resize-handler\" ref={dragHandlerRef}>\n {dragging ? <div data-testid=\"resize-hit-area\" className=\"fixed bottom-0 left-0 right-0 top-0\" /> : null}\n </div>\n {showCloseButton ? (\n <Close>\n <LegacyIconButton\n appearance=\"discrete\"\n aria-label={texts.drawer.close}\n className=\"absolute right-0 top-0 mr-2 mt-4\"\n icon=\"close\"\n />\n </Close>\n ) : null}\n </div>\n );\n\n if (!outlet) {\n return null;\n }\n\n return (\n <DrawerPrimitive.Portal container={outlet ?? undefined} className=\"h-full\">\n {variant === 'overlay' ? (\n <DrawerPrimitive.Backdrop\n className=\"fixed inset-0 cursor-default overflow-y-auto bg-brand-midnight/[0.3] print:absolute print:overflow-visible\"\n data-taco=\"backdrop\"\n />\n ) : null}\n <DrawerPrimitive.Viewport className=\"h-full\">\n <DrawerPrimitive.Popup\n {...otherProps}\n className={contentClassName}\n finalFocus={finalFocus}\n ref={ref}\n style={{ width: resizedWidth }}>\n <DrawerPrimitive.Content>{content}</DrawerPrimitive.Content>\n </DrawerPrimitive.Popup>\n </DrawerPrimitive.Viewport>\n </DrawerPrimitive.Portal>\n );\n});\n"],"names":["React","RenderPropWrapper","DrawerPrimitive","Actions","InnerContent","Content","contentClassName","dragHandlerClassName"],"mappings":";;;;;;;;;;AAaA,MAAM,aAAa;AACnB,MAAM,aAAa;AAOnB,MAAM,oBAAoBA,eAAM,WAAW,SAASC,mBAAkB,EAAE,UAAU,SAAS,YAAA,GAAoB,KAAK;AAChH,QAAM,QAAQ,MAAM;AAChB,YAAQ,IAAI,YAAY,OAAO,CAAC;AAAA,EACpC;AAEA,SAAO,SAAS,EAAE,OAAO,KAAK,GAAG,aAAa;AAClD,CAAC;AAGM,MAAM,QAAQD,eAAM,WAAW,SAAS,YAAY,OAAyB,aAA4C;AAC5H,QAAM,EAAE,WAAW,UAAU,GAAG,eAAe;AAC/C,QAAM,MAAM,aAAiC,WAAW;AACxD,QAAM,CAAC,OAAO,QAAQ,IAAIA,eAAM,SAAS,CAAA,CAAE;AAC3C,QAAM,EAAE,MAAA,IAAU,gBAAA;AAClB,QAAM,EAAE,YAAA,IAAgB,iBAAA;AAOxB,QAAM,QAAQ,GAAG,4FAA4F,SAAS;AAEtHA,iBAAM,UAAU,MAAM;AAClB,UAAM,SAAS,KAAK,SAAS,QAAQ,sBAAsB;AAG3D,UAAM,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IAAC;AAAA,IAAA;AAAA,MACG,YAAW;AAAA,MACX,cAAY,MAAM,OAAO;AAAA,MACzB,WAAU;AAAA,MACV,MAAK;AAAA,IAAA;AAAA,EAAA,CAEb,IACA,IACR;AAGJ,MAAI,CAAC,QAAQ;AACT,WAAO;AAAA,EACX;AAEA,SACIA,+BAAA,cAACE,OAAgB,QAAhB,EAAuB,WAAW,UAAU,QAAW,WAAU,SAAA,GAC7D,YAAY,YACTF,+BAAA;AAAA,IAACE,OAAgB;AAAA,IAAhB;AAAA,MACG,WAAU;AAAA,MACV,aAAU;AAAA,IAAA;AAAA,EAAA,IAEd,MACJF,+BAAA,cAACE,OAAgB,UAAhB,EAAyB,WAAU,YAChCF,+BAAA;AAAA,IAACE,OAAgB;AAAA,IAAhB;AAAA,MACI,GAAG;AAAA,MACJ,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,OAAO,EAAE,OAAO,aAAA;AAAA,IAAa;AAAA,IAC7BF,+BAAA,cAACE,OAAgB,SAAhB,MAAyB,OAAQ;AAAA,EAAA,CAE1C,CACJ;AAER,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDrawerStack.cjs","sources":["../../../src/components/Drawer/useDrawerStack.tsx"],"sourcesContent":["import React from 'react';\n\n// drawerStack getting set by previous drawer instance, to be able to close previous instance, when new instance getting opened.\nlet drawerStack: React.
|
|
1
|
+
{"version":3,"file":"useDrawerStack.cjs","sources":["../../../src/components/Drawer/useDrawerStack.tsx"],"sourcesContent":["import React from 'react';\n\n// drawerStack getting set by previous drawer instance, to be able to close previous instance, when new instance getting opened.\nlet drawerStack: React.RefObject<(() => void) | undefined> | undefined;\n\ntype Props = {\n open: boolean | undefined;\n setOpen: (open: boolean) => void;\n onClose?: () => void;\n onOpen: () => void;\n};\n// this prevents two drawers being open at once and used when one drawer getting opened before another one got closed.\nexport const useDrawerStack = ({ open, setOpen, onClose, onOpen }: Props) => {\n const onCloseRef = React.useRef<(() => void) | undefined>(undefined);\n\n const close = React.useCallback(() => {\n setOpen(false);\n onClose?.();\n }, [setOpen, onClose]);\n\n React.useLayoutEffect(() => {\n onCloseRef.current = close;\n }, [close]);\n\n React.useEffect(() => {\n if (open) {\n onOpen();\n\n if (drawerStack !== undefined) {\n drawerStack.current?.();\n }\n drawerStack = onCloseRef;\n } else if (drawerStack === onCloseRef) {\n // if drawerStack is equal to current close callback,\n // this means that drawer getting closed completely instead of getting closed on re-open\n drawerStack = undefined;\n }\n\n return () => {\n if (drawerStack === onCloseRef) {\n drawerStack = undefined;\n }\n };\n }, [open]);\n};\n"],"names":[],"mappings":";;;AAGA,IAAI;AASG,MAAM,iBAAiB,CAAC,EAAE,MAAM,SAAS,SAAS,aAAoB;AACzE,QAAM,aAAa,MAAM,OAAiC,MAAS;AAEnE,QAAM,QAAQ,MAAM,YAAY,MAAM;AAClC,YAAQ,KAAK;AACb,cAAA;AAAA,EACJ,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,QAAM,gBAAgB,MAAM;AACxB,eAAW,UAAU;AAAA,EACzB,GAAG,CAAC,KAAK,CAAC;AAEV,QAAM,UAAU,MAAM;AAClB,QAAI,MAAM;AACN,aAAA;AAEA,UAAI,gBAAgB,QAAW;AAC3B,oBAAY,UAAA;AAAA,MAChB;AACA,oBAAc;AAAA,IAClB,WAAW,gBAAgB,YAAY;AAGnC,oBAAc;AAAA,IAClB;AAEA,WAAO,MAAM;AACT,UAAI,gBAAgB,YAAY;AAC5B,sBAAc;AAAA,MAClB;AAAA,IACJ;AAAA,EACJ,GAAG,CAAC,IAAI,CAAC;AACb;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDrawerStack.js","sources":["../../../src/components/Drawer/useDrawerStack.tsx"],"sourcesContent":["import React from 'react';\n\n// drawerStack getting set by previous drawer instance, to be able to close previous instance, when new instance getting opened.\nlet drawerStack: React.
|
|
1
|
+
{"version":3,"file":"useDrawerStack.js","sources":["../../../src/components/Drawer/useDrawerStack.tsx"],"sourcesContent":["import React from 'react';\n\n// drawerStack getting set by previous drawer instance, to be able to close previous instance, when new instance getting opened.\nlet drawerStack: React.RefObject<(() => void) | undefined> | undefined;\n\ntype Props = {\n open: boolean | undefined;\n setOpen: (open: boolean) => void;\n onClose?: () => void;\n onOpen: () => void;\n};\n// this prevents two drawers being open at once and used when one drawer getting opened before another one got closed.\nexport const useDrawerStack = ({ open, setOpen, onClose, onOpen }: Props) => {\n const onCloseRef = React.useRef<(() => void) | undefined>(undefined);\n\n const close = React.useCallback(() => {\n setOpen(false);\n onClose?.();\n }, [setOpen, onClose]);\n\n React.useLayoutEffect(() => {\n onCloseRef.current = close;\n }, [close]);\n\n React.useEffect(() => {\n if (open) {\n onOpen();\n\n if (drawerStack !== undefined) {\n drawerStack.current?.();\n }\n drawerStack = onCloseRef;\n } else if (drawerStack === onCloseRef) {\n // if drawerStack is equal to current close callback,\n // this means that drawer getting closed completely instead of getting closed on re-open\n drawerStack = undefined;\n }\n\n return () => {\n if (drawerStack === onCloseRef) {\n drawerStack = undefined;\n }\n };\n }, [open]);\n};\n"],"names":["React"],"mappings":";AAGA,IAAI;AASG,MAAM,iBAAiB,CAAC,EAAE,MAAM,SAAS,SAAS,aAAoB;AACzE,QAAM,aAAaA,eAAM,OAAiC,MAAS;AAEnE,QAAM,QAAQA,eAAM,YAAY,MAAM;AAClC,YAAQ,KAAK;AACb,cAAA;AAAA,EACJ,GAAG,CAAC,SAAS,OAAO,CAAC;AAErBA,iBAAM,gBAAgB,MAAM;AACxB,eAAW,UAAU;AAAA,EACzB,GAAG,CAAC,KAAK,CAAC;AAEVA,iBAAM,UAAU,MAAM;AAClB,QAAI,MAAM;AACN,aAAA;AAEA,UAAI,gBAAgB,QAAW;AAC3B,oBAAY,UAAA;AAAA,MAChB;AACA,oBAAc;AAAA,IAClB,WAAW,gBAAgB,YAAY;AAGnC,oBAAc;AAAA,IAClB;AAEA,WAAO,MAAM;AACT,UAAI,gBAAgB,YAAY;AAC5B,sBAAc;AAAA,MAClB;AAAA,IACJ;AAAA,EACJ,GAAG,CAAC,IAAI,CAAC;AACb;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hanger.cjs","sources":["../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import { Popover as PopoverPrimitive } from '@base-ui/react/popover';\nimport cn from 'clsx';\nimport * as React from 'react';\n\nimport { LegacyIconButton, useLocalization } from '@/components';\nimport type { Placement } from '@/types';\nimport { mergeRefs } from '@/utils/mergeRefs';\n\nimport { UnstyledArrow } from './Arrow';\n\nimport './Hanger.css';\n\ntype HangerContextValue = {\n /** Handler called when hanger closes by user interaction */\n onClose?: () => void;\n anchorRef: React.RefObject<HTMLElement | null>;\n};\nconst HangerContext = React.createContext<HangerContextValue>({\n anchorRef: { current: null },\n onClose: undefined,\n});\n\nexport type HangerTexts = {\n /** Aria-label for the close icon button of hanger */\n close: string;\n};\n\nexport type HangerAnchorProps = React.PropsWithChildren;\n// `Hanger.Anchor` is a pure pass-through that renders its child untouched. It exists only to keep\n// the composable API (<Hanger.Anchor>…</Hanger.Anchor>) — the Hanger root owns the single DOM\n// wrapper that serves as the positioning anchor, so this adds no DOM and needs no ref.\nconst Anchor: React.FC<HangerAnchorProps> = ({ children }) => <>{children}</>;\n\nexport type HangerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: HangerTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('mb-1 flex w-full text-base font-bold', props.className);\n return <span {...props} className={className} ref={ref} />;\n});\n\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\n placement?: Placement;\n hideWhenDetached?: boolean;\n container?: HTMLElement | null;\n};\n\nconst Content = React.forwardRef(function HangerContent(props: HangerContentProps, ref: React.Ref<HTMLDivElement>) {\n const { placement: side, hideWhenDetached = false, container, ...popoverContentProps } = props;\n const context = React.useContext(HangerContext);\n const { texts } = useLocalization();\n const className = cn(\n 'max-w-sm rounded border border-transparent bg-blue-500 p-3 pr-12 text-white yt-shadow focus:border-transparent print:hidden',\n props.className\n );\n\n return (\n <PopoverPrimitive.Portal container={container}>\n <PopoverPrimitive.Positioner\n anchor={context.anchorRef}\n className={hideWhenDetached ? 'data-[anchor-hidden]:hidden' : undefined}\n side={side}\n sideOffset={11}>\n <PopoverPrimitive.Popup {...popoverContentProps} className={className} data-taco=\"hanger\" ref={ref}>\n {props.children}\n <UnstyledArrow className=\"text-blue-500\" />\n <PopoverPrimitive.Close\n render={\n <LegacyIconButton\n appearance=\"primary\"\n aria-label={texts.hanger.close}\n className=\"absolute right-0 top-0 mx-2 mt-2 text-white\"\n icon=\"close\"\n onClick={context.onClose}\n />\n }\n />\n </PopoverPrimitive.Popup>\n </PopoverPrimitive.Positioner>\n </PopoverPrimitive.Portal>\n );\n});\n\nexport type HangerProps = React.PropsWithChildren<{\n /** An anchor to be used for the hanger, should not be set if `children` already contains an anchor */\n anchor?: React.JSX.Element;\n /**\n * Shows or hides hanger depending on the value\n * @defaultValue true\n */\n defaultOpen?: boolean;\n /** Handler called when user closes the hanger */\n onClose?: () => void;\n}>;\n\nexport type ForwardedHangerWithStatics = React.ForwardRefExoticComponent<HangerProps & React.RefAttributes<HTMLElement>> & {\n Anchor: React.FC<HangerAnchorProps>;\n Content: React.ForwardRefExoticComponent<HangerContentProps>;\n Title: React.ForwardRefExoticComponent<HangerTitleProps>;\n};\n\nexport const Hanger = React.forwardRef<HTMLSpanElement, HangerProps>(function Hanger(props, ref) {\n const { anchor, children, defaultOpen = true, onClose, ...otherProps } = props;\n const anchorRef = React.useRef<HTMLElement>(null);\n const combinedRef = mergeRefs([anchorRef as React.
|
|
1
|
+
{"version":3,"file":"Hanger.cjs","sources":["../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import { Popover as PopoverPrimitive } from '@base-ui/react/popover';\nimport cn from 'clsx';\nimport * as React from 'react';\n\nimport { LegacyIconButton, useLocalization } from '@/components';\nimport type { Placement } from '@/types';\nimport { mergeRefs } from '@/utils/mergeRefs';\n\nimport { UnstyledArrow } from './Arrow';\n\nimport './Hanger.css';\n\ntype HangerContextValue = {\n /** Handler called when hanger closes by user interaction */\n onClose?: () => void;\n anchorRef: React.RefObject<HTMLElement | null>;\n};\nconst HangerContext = React.createContext<HangerContextValue>({\n anchorRef: { current: null },\n onClose: undefined,\n});\n\nexport type HangerTexts = {\n /** Aria-label for the close icon button of hanger */\n close: string;\n};\n\nexport type HangerAnchorProps = React.PropsWithChildren;\n// `Hanger.Anchor` is a pure pass-through that renders its child untouched. It exists only to keep\n// the composable API (<Hanger.Anchor>…</Hanger.Anchor>) — the Hanger root owns the single DOM\n// wrapper that serves as the positioning anchor, so this adds no DOM and needs no ref.\nconst Anchor: React.FC<HangerAnchorProps> = ({ children }) => <>{children}</>;\n\nexport type HangerTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: HangerTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n const className = cn('mb-1 flex w-full text-base font-bold', props.className);\n return <span {...props} className={className} ref={ref} />;\n});\n\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\n placement?: Placement;\n hideWhenDetached?: boolean;\n container?: HTMLElement | null;\n};\n\nconst Content = React.forwardRef(function HangerContent(props: HangerContentProps, ref: React.Ref<HTMLDivElement>) {\n const { placement: side, hideWhenDetached = false, container, ...popoverContentProps } = props;\n const context = React.useContext(HangerContext);\n const { texts } = useLocalization();\n const className = cn(\n 'max-w-sm rounded border border-transparent bg-blue-500 p-3 pr-12 text-white yt-shadow focus:border-transparent print:hidden',\n props.className\n );\n\n return (\n <PopoverPrimitive.Portal container={container}>\n <PopoverPrimitive.Positioner\n anchor={context.anchorRef}\n className={hideWhenDetached ? 'data-[anchor-hidden]:hidden' : undefined}\n side={side}\n sideOffset={11}>\n <PopoverPrimitive.Popup {...popoverContentProps} className={className} data-taco=\"hanger\" ref={ref}>\n {props.children}\n <UnstyledArrow className=\"text-blue-500\" />\n <PopoverPrimitive.Close\n render={\n <LegacyIconButton\n appearance=\"primary\"\n aria-label={texts.hanger.close}\n className=\"absolute right-0 top-0 mx-2 mt-2 text-white\"\n icon=\"close\"\n onClick={context.onClose}\n />\n }\n />\n </PopoverPrimitive.Popup>\n </PopoverPrimitive.Positioner>\n </PopoverPrimitive.Portal>\n );\n});\n\nexport type HangerProps = React.PropsWithChildren<{\n /** An anchor to be used for the hanger, should not be set if `children` already contains an anchor */\n anchor?: React.JSX.Element;\n /**\n * Shows or hides hanger depending on the value\n * @defaultValue true\n */\n defaultOpen?: boolean;\n /** Handler called when user closes the hanger */\n onClose?: () => void;\n}>;\n\nexport type ForwardedHangerWithStatics = React.ForwardRefExoticComponent<HangerProps & React.RefAttributes<HTMLElement>> & {\n Anchor: React.FC<HangerAnchorProps>;\n Content: React.ForwardRefExoticComponent<HangerContentProps>;\n Title: React.ForwardRefExoticComponent<HangerTitleProps>;\n};\n\nexport const Hanger = React.forwardRef<HTMLSpanElement, HangerProps>(function Hanger(props, ref) {\n const { anchor, children, defaultOpen = true, onClose, ...otherProps } = props;\n const anchorRef = React.useRef<HTMLElement>(null);\n const combinedRef = mergeRefs([anchorRef as React.RefObject<HTMLElement | null>, ref]);\n const context = React.useMemo(() => ({ anchorRef, onClose }), [onClose]);\n\n // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal\n const [open, setOpen] = React.useState(false);\n React.useEffect(() => {\n if (defaultOpen) {\n setOpen(defaultOpen);\n }\n }, []);\n\n // Hanger should only close from its close button, matching the previous Radix onInteractOutside behavior.\n const handleOpenChange = (nextOpen: boolean, eventDetails: PopoverPrimitive.Root.ChangeEventDetails) => {\n if (!nextOpen && (eventDetails.reason === 'outside-press' || eventDetails.reason === 'focus-out')) {\n eventDetails.cancel();\n return;\n }\n\n setOpen(nextOpen);\n };\n\n // Single inline <span> wrapper: serves as the Floating UI anchor (its rect matches the\n // in-flow trigger child) and contains the FloatingFocusManager guard spans Base UI injects\n // when open, so they aren't siblings of the Hanger in parent IntersectionObservers\n // (e.g. OverflowGroup's) and don't get counted as overflowed children.\n return (\n <HangerContext.Provider value={context}>\n <span {...otherProps} ref={combinedRef as React.Ref<HTMLSpanElement>}>\n <PopoverPrimitive.Root open={open} onOpenChange={handleOpenChange}>\n {/* Anchor via the `anchor` prop. */}\n {anchor}\n {/* Composition (<Hanger.Anchor>) and the popup Content (portaled out) come through {children}. */}\n {children}\n </PopoverPrimitive.Root>\n </span>\n </HangerContext.Provider>\n );\n}) as ForwardedHangerWithStatics;\nHanger.Anchor = Anchor;\nHanger.Content = Content;\nHanger.Title = Title;\n"],"names":["React","useLocalization","PopoverPrimitive","UnstyledArrow","LegacyIconButton","Hanger","mergeRefs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,gBAAgBA,iBAAM,cAAkC;AAAA,EAC1D,WAAW,EAAE,SAAS,KAAA;AAAA,EACtB,SAAS;AACb,CAAC;AAWD,MAAM,SAAsC,CAAC,EAAE,SAAA,sFAAkB,QAAS;AAGnE,MAAM,QAAQA,iBAAM,WAAW,SAAS,YAAY,OAAyB,KAAoC;AACpH,QAAM,YAAY,GAAG,wCAAwC,MAAM,SAAS;AAC5E,SAAOA,iCAAA,cAAC,QAAA,EAAM,GAAG,OAAO,WAAsB,KAAU;AAC5D,CAAC;AASD,MAAM,UAAUA,iBAAM,WAAW,SAAS,cAAc,OAA2B,KAAgC;AAC/G,QAAM,EAAE,WAAW,MAAM,mBAAmB,OAAO,WAAW,GAAG,wBAAwB;AACzF,QAAM,UAAUA,iBAAM,WAAW,aAAa;AAC9C,QAAM,EAAE,MAAA,IAAUC,6BAAA;AAClB,QAAM,YAAY;AAAA,IACd;AAAA,IACA,MAAM;AAAA,EAAA;AAGV,SACID,iCAAA,cAACE,QAAAA,QAAiB,QAAjB,EAAwB,UAAA,GAC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