@lerianstudio/sindarian-ui 2.0.0-beta.25 → 2.0.0-beta.26
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/chart.js +4 -231
- package/dist/charts/index.js +1 -11
- package/dist/components/breadcrumb/get-breadcrumb-paths.js +1 -18
- package/dist/components/breadcrumb/index.js +1 -37
- package/dist/components/card/account-card/index.js +1 -69
- package/dist/components/card/basic-card/index.js +1 -20
- package/dist/components/card/dashboard-card/index.js +1 -20
- package/dist/components/card/entity-card/index.js +1 -68
- package/dist/components/card/index.js +1 -20
- package/dist/components/dialog/confirmation-dialog/index.js +1 -96
- package/dist/components/dialog/confirmation-dialog/use-confirm-dialog.js +1 -55
- package/dist/components/dialog/index.js +1 -19
- package/dist/components/dialog/large-dialog/index.js +1 -21
- package/dist/components/entity-box/index.js +1 -67
- package/dist/components/entity-data-table/index.js +1 -20
- package/dist/components/form/combo-box-field/index.js +1 -35
- package/dist/components/form/country-field/index.js +1 -11
- package/dist/components/form/date-picker-field/index.js +1 -83
- package/dist/components/form/date-range-field/index.js +1 -58
- package/dist/components/form/date-time-picker-field/index.js +1 -114
- package/dist/components/form/file-upload-field/index.js +1 -69
- package/dist/components/form/index.js +1 -31
- package/dist/components/form/input-field/index.js +1 -96
- package/dist/components/form/otp-field/index.js +1 -19
- package/dist/components/form/pagination-limit-field/index.js +1 -10
- package/dist/components/form/password-field/index.js +1 -16
- package/dist/components/form/radio-group-field/index.js +1 -36
- package/dist/components/form/renderable-label.js +1 -57
- package/dist/components/form/select-field/index.js +1 -68
- package/dist/components/form/state-field/index.js +1 -42
- package/dist/components/form/switch-field/index.js +1 -16
- package/dist/components/form/textarea-field/index.js +1 -23
- package/dist/components/page/index.js +1 -20
- package/dist/components/page-header/index.js +1 -80
- package/dist/components/pagination/index.js +1 -10
- package/dist/components/table/id-table-cell.js +1 -109
- package/dist/components/table/index.js +1 -19
- package/dist/components/table/locked-table-actions.js +1 -41
- package/dist/components/table/name-table-cell.js +1 -58
- package/dist/components/ui/accordion/index.js +1 -62
- package/dist/components/ui/alert/index.js +1 -45
- package/dist/components/ui/alert-dialog/index.js +1 -84
- package/dist/components/ui/autocomplete/index.js +1 -440
- package/dist/components/ui/autosize-textarea/index.js +1 -89
- package/dist/components/ui/avatar/index.js +1 -51
- package/dist/components/ui/badge/index.js +1 -83
- package/dist/components/ui/breadcrumb/index.js +1 -35
- package/dist/components/ui/button/index.js +1 -65
- package/dist/components/ui/calendar/index.js +1 -118
- package/dist/components/ui/card/index.js +1 -32
- package/dist/components/ui/checkbox/index.js +1 -44
- package/dist/components/ui/collapsible/index.js +1 -50
- package/dist/components/ui/command/index.js +1 -95
- package/dist/components/ui/copy-field/index.js +1 -163
- package/dist/components/ui/dialog/index.js +1 -80
- package/dist/components/ui/dropdown-menu/index.js +1 -110
- package/dist/components/ui/field/index.js +1 -82
- package/dist/components/ui/file-upload/index.js +1 -574
- package/dist/components/ui/form.js +1 -162
- package/dist/components/ui/hover-card/index.js +1 -51
- package/dist/components/ui/icon-button/index.js +1 -35
- package/dist/components/ui/input/adornment.js +1 -21
- package/dist/components/ui/input/index.js +1 -99
- package/dist/components/ui/label/index.js +1 -45
- package/dist/components/ui/lerian-wordmark/index.js +1 -7
- package/dist/components/ui/loading-button/index.js +1 -9
- package/dist/components/ui/multiple-select/index.js +1 -235
- package/dist/components/ui/otp-input/index.js +1 -62
- package/dist/components/ui/paper/index.js +1 -8
- package/dist/components/ui/paper-collapsible/index.js +1 -24
- package/dist/components/ui/popover/index.js +1 -55
- package/dist/components/ui/progress/index.js +1 -66
- package/dist/components/ui/qr-code/index.js +1 -27
- package/dist/components/ui/radio-group/index.js +1 -48
- package/dist/components/ui/scroll-area/index.js +1 -49
- package/dist/components/ui/select/index.js +1 -119
- package/dist/components/ui/separator/index.js +1 -43
- package/dist/components/ui/sheet/index.js +1 -136
- package/dist/components/ui/sidebar/index.js +1 -27
- package/dist/components/ui/sidebar/next-router.cjs +1 -119
- package/dist/components/ui/sidebar/sidebar-back-button.js +1 -8
- package/dist/components/ui/sidebar/sidebar-components.js +1 -23
- package/dist/components/ui/sidebar/sidebar-expand-button.js +1 -49
- package/dist/components/ui/sidebar/sidebar-item-button.js +1 -21
- package/dist/components/ui/sidebar/sidebar-item-collapsible.js +1 -52
- package/dist/components/ui/sidebar/sidebar-item-icon-button.js +1 -18
- package/dist/components/ui/sidebar/sidebar-item.js +1 -44
- package/dist/components/ui/sidebar/sidebar-provider.js +1 -201
- package/dist/components/ui/sidebar/sidebar-root.js +1 -130
- package/dist/components/ui/sidebar/sidebar-router.js +1 -126
- package/dist/components/ui/sidebar/sidebar-trigger.js +1 -57
- package/dist/components/ui/skeleton/index.js +1 -8
- package/dist/components/ui/stepper/index.js +1 -29
- package/dist/components/ui/switch/index.js +1 -43
- package/dist/components/ui/table/index.js +1 -56
- package/dist/components/ui/tabs/index.js +1 -55
- package/dist/components/ui/textarea/index.js +1 -8
- package/dist/components/ui/time-picker/index.js +1 -85
- package/dist/components/ui/toast/index.js +1 -3
- package/dist/components/ui/toast/toaster.js +1 -16
- package/dist/components/ui/toggle-group/index.js +1 -156
- package/dist/components/ui/tooltip/index.js +1 -81
- package/dist/domain/blotter/index.js +1 -20
- package/dist/domain/delinquency-aging/aging-buckets.js +1 -120
- package/dist/domain/delinquency-aging/index.js +1 -222
- package/dist/domain/figure/index.js +1 -19
- package/dist/domain/format.js +1 -137
- package/dist/domain/index.js +1 -43
- package/dist/domain/key-id/index.js +1 -174
- package/dist/domain/ledger-sheet/index.js +1 -28
- package/dist/domain/money-diff.js +1 -48
- package/dist/domain/money-math.js +1 -104
- package/dist/domain/money-text/index.js +1 -123
- package/dist/domain/section-label/index.js +1 -17
- package/dist/domain/status-rail/index.js +1 -76
- package/dist/domain/threshold-gauge/index.js +1 -161
- package/dist/enterprise/alert-banner/index.js +1 -24
- package/dist/enterprise/app-shell/index.js +1 -87
- package/dist/enterprise/cursor-pager/index.js +1 -26
- package/dist/enterprise/data-table/column-size.js +1 -103
- package/dist/enterprise/data-table/index.js +1 -345
- package/dist/enterprise/date-range-picker/index.js +1 -115
- package/dist/enterprise/detail-panel/index.js +1 -20
- package/dist/enterprise/empty-state/index.js +1 -14
- package/dist/enterprise/index.js +1 -39
- package/dist/enterprise/number-input/index.js +1 -252
- package/dist/enterprise/search-input/index.js +1 -121
- package/dist/enterprise/stat-card/index.js +1 -75
- package/dist/enterprise/status-badge/index.js +1 -120
- package/dist/enterprise/use-is-mobile.js +1 -68
- package/dist/enterprise/virtualized-table/index.js +1 -141
- package/dist/esm/charts/chart.js +4 -190
- package/dist/esm/charts/index.js +1 -3
- package/dist/esm/components/breadcrumb/get-breadcrumb-paths.js +1 -12
- package/dist/esm/components/breadcrumb/index.js +1 -30
- package/dist/esm/components/card/account-card/index.js +1 -53
- package/dist/esm/components/card/basic-card/index.js +1 -14
- package/dist/esm/components/card/dashboard-card/index.js +1 -14
- package/dist/esm/components/card/entity-card/index.js +1 -52
- package/dist/esm/components/card/index.js +1 -4
- package/dist/esm/components/dialog/confirmation-dialog/index.js +1 -60
- package/dist/esm/components/dialog/confirmation-dialog/use-confirm-dialog.js +1 -49
- package/dist/esm/components/dialog/index.js +1 -3
- package/dist/esm/components/dialog/large-dialog/index.js +1 -16
- package/dist/esm/components/entity-box/index.js +1 -56
- package/dist/esm/components/entity-data-table/index.js +1 -17
- package/dist/esm/components/form/combo-box-field/index.js +1 -28
- package/dist/esm/components/form/country-field/index.js +1 -7
- package/dist/esm/components/form/date-picker-field/index.js +1 -43
- package/dist/esm/components/form/date-range-field/index.js +1 -18
- package/dist/esm/components/form/date-time-picker-field/index.js +1 -74
- package/dist/esm/components/form/file-upload-field/index.js +1 -65
- package/dist/esm/components/form/index.js +1 -15
- package/dist/esm/components/form/input-field/index.js +1 -92
- package/dist/esm/components/form/otp-field/index.js +1 -15
- package/dist/esm/components/form/pagination-limit-field/index.js +1 -6
- package/dist/esm/components/form/password-field/index.js +1 -10
- package/dist/esm/components/form/radio-group-field/index.js +1 -32
- package/dist/esm/components/form/renderable-label.js +1 -54
- package/dist/esm/components/form/select-field/index.js +1 -64
- package/dist/esm/components/form/state-field/index.js +1 -35
- package/dist/esm/components/form/switch-field/index.js +1 -12
- package/dist/esm/components/form/textarea-field/index.js +1 -19
- package/dist/esm/components/page/index.js +1 -15
- package/dist/esm/components/page-header/index.js +1 -71
- package/dist/esm/components/pagination/index.js +1 -6
- package/dist/esm/components/table/id-table-cell.js +1 -105
- package/dist/esm/components/table/index.js +1 -3
- package/dist/esm/components/table/locked-table-actions.js +1 -37
- package/dist/esm/components/table/name-table-cell.js +1 -54
- package/dist/esm/components/ui/accordion/index.js +1 -24
- package/dist/esm/components/ui/alert/index.js +1 -38
- package/dist/esm/components/ui/alert-dialog/index.js +1 -39
- package/dist/esm/components/ui/autocomplete/index.js +1 -392
- package/dist/esm/components/ui/autosize-textarea/index.js +1 -51
- package/dist/esm/components/ui/avatar/index.js +1 -14
- package/dist/esm/components/ui/badge/index.js +1 -79
- package/dist/esm/components/ui/breadcrumb/index.js +1 -27
- package/dist/esm/components/ui/button/index.js +1 -60
- package/dist/esm/components/ui/calendar/index.js +1 -82
- package/dist/esm/components/ui/card/index.js +1 -24
- package/dist/esm/components/ui/checkbox/index.js +1 -9
- package/dist/esm/components/ui/collapsible/index.js +1 -13
- package/dist/esm/components/ui/command/index.js +1 -51
- package/dist/esm/components/ui/copy-field/index.js +1 -127
- package/dist/esm/components/ui/dialog/index.js +1 -36
- package/dist/esm/components/ui/dropdown-menu/index.js +1 -60
- package/dist/esm/components/ui/field/index.js +1 -71
- package/dist/esm/components/ui/file-upload/index.js +1 -536
- package/dist/esm/components/ui/form.js +1 -118
- package/dist/esm/components/ui/hover-card/index.js +1 -14
- package/dist/esm/components/ui/icon-button/index.js +1 -31
- package/dist/esm/components/ui/input/adornment.js +1 -17
- package/dist/esm/components/ui/input/index.js +1 -60
- package/dist/esm/components/ui/label/index.js +1 -10
- package/dist/esm/components/ui/lerian-wordmark/index.js +1 -4
- package/dist/esm/components/ui/loading-button/index.js +1 -7
- package/dist/esm/components/ui/multiple-select/index.js +1 -196
- package/dist/esm/components/ui/otp-input/index.js +1 -21
- package/dist/esm/components/ui/paper/index.js +1 -5
- package/dist/esm/components/ui/paper-collapsible/index.js +1 -19
- package/dist/esm/components/ui/popover/index.js +1 -17
- package/dist/esm/components/ui/progress/index.js +1 -31
- package/dist/esm/components/ui/qr-code/index.js +1 -24
- package/dist/esm/components/ui/radio-group/index.js +1 -12
- package/dist/esm/components/ui/scroll-area/index.js +1 -13
- package/dist/esm/components/ui/select/index.js +1 -74
- package/dist/esm/components/ui/separator/index.js +1 -8
- package/dist/esm/components/ui/sheet/index.js +1 -92
- package/dist/esm/components/ui/sidebar/index.js +1 -11
- package/dist/esm/components/ui/sidebar/next-router.cjs +1 -119
- package/dist/esm/components/ui/sidebar/sidebar-back-button.js +1 -5
- package/dist/esm/components/ui/sidebar/sidebar-components.js +1 -15
- package/dist/esm/components/ui/sidebar/sidebar-expand-button.js +1 -42
- package/dist/esm/components/ui/sidebar/sidebar-item-button.js +1 -18
- package/dist/esm/components/ui/sidebar/sidebar-item-collapsible.js +1 -44
- package/dist/esm/components/ui/sidebar/sidebar-item-icon-button.js +1 -14
- package/dist/esm/components/ui/sidebar/sidebar-item.js +1 -40
- package/dist/esm/components/ui/sidebar/sidebar-provider.js +1 -193
- package/dist/esm/components/ui/sidebar/sidebar-root.js +1 -126
- package/dist/esm/components/ui/sidebar/sidebar-router.js +1 -89
- package/dist/esm/components/ui/sidebar/sidebar-trigger.js +1 -53
- package/dist/esm/components/ui/skeleton/index.js +1 -6
- package/dist/esm/components/ui/stepper/index.js +1 -20
- package/dist/esm/components/ui/switch/index.js +1 -8
- package/dist/esm/components/ui/table/index.js +1 -44
- package/dist/esm/components/ui/tabs/index.js +1 -17
- package/dist/esm/components/ui/textarea/index.js +1 -6
- package/dist/esm/components/ui/time-picker/index.js +1 -49
- package/dist/esm/components/ui/toast/index.js +1 -2
- package/dist/esm/components/ui/toast/toaster.js +1 -13
- package/dist/esm/components/ui/toggle-group/index.js +1 -120
- package/dist/esm/components/ui/tooltip/index.js +1 -43
- package/dist/esm/domain/blotter/index.js +1 -16
- package/dist/esm/domain/delinquency-aging/aging-buckets.js +1 -115
- package/dist/esm/domain/delinquency-aging/index.js +1 -218
- package/dist/esm/domain/figure/index.js +1 -15
- package/dist/esm/domain/format.js +1 -128
- package/dist/esm/domain/index.js +1 -19
- package/dist/esm/domain/key-id/index.js +1 -169
- package/dist/esm/domain/ledger-sheet/index.js +1 -24
- package/dist/esm/domain/money-diff.js +1 -45
- package/dist/esm/domain/money-math.js +1 -98
- package/dist/esm/domain/money-text/index.js +1 -118
- package/dist/esm/domain/section-label/index.js +1 -14
- package/dist/esm/domain/status-rail/index.js +1 -71
- package/dist/esm/domain/threshold-gauge/index.js +1 -157
- package/dist/esm/enterprise/alert-banner/index.js +1 -21
- package/dist/esm/enterprise/app-shell/index.js +1 -51
- package/dist/esm/enterprise/cursor-pager/index.js +1 -23
- package/dist/esm/enterprise/data-table/column-size.js +1 -97
- package/dist/esm/enterprise/data-table/index.js +1 -342
- package/dist/esm/enterprise/date-range-picker/index.js +1 -112
- package/dist/esm/enterprise/detail-panel/index.js +1 -17
- package/dist/esm/enterprise/empty-state/index.js +1 -11
- package/dist/esm/enterprise/index.js +1 -22
- package/dist/esm/enterprise/number-input/index.js +1 -214
- package/dist/esm/enterprise/search-input/index.js +1 -85
- package/dist/esm/enterprise/stat-card/index.js +1 -72
- package/dist/esm/enterprise/status-badge/index.js +1 -116
- package/dist/esm/enterprise/use-is-mobile.js +1 -31
- package/dist/esm/enterprise/virtualized-table/index.js +1 -138
- package/dist/esm/hooks/use-click-away.js +1 -22
- package/dist/esm/hooks/use-pagination.js +1 -38
- package/dist/esm/hooks/use-stepper.js +1 -22
- package/dist/esm/hooks/use-time.js +1 -13
- package/dist/esm/hooks/use-toast.js +1 -107
- package/dist/esm/index.js +1 -77
- package/dist/esm/lib/storage/get-storage-object.js +1 -17
- package/dist/esm/lib/storage/get-storage.js +1 -14
- package/dist/esm/lib/storage/index.js +1 -2
- package/dist/esm/lib/typography.js +1 -31
- package/dist/esm/lib/utils.js +1 -41
- package/dist/esm/theme/get-theme-script.js +1 -41
- package/dist/esm/theme/index.js +1 -4
- package/dist/esm/theme/mode-toggle.js +1 -45
- package/dist/esm/theme/theme-provider.js +1 -122
- package/dist/esm/toast/helpers.js +1 -36
- package/dist/esm/toast/index.js +1 -4
- package/dist/esm/types/metadata-type.js +1 -1
- package/dist/esm/utils/countries.cjs +1 -17
- package/dist/esm/utils/country-utils.js +1 -18
- package/dist/esm/utils/currency-codes.js +1 -181
- package/dist/hooks/use-click-away.js +1 -29
- package/dist/hooks/use-pagination.js +1 -41
- package/dist/hooks/use-stepper.js +1 -26
- package/dist/hooks/use-time.js +1 -20
- package/dist/hooks/use-toast.js +1 -111
- package/dist/index.js +1 -96
- package/dist/lib/storage/get-storage-object.js +1 -23
- package/dist/lib/storage/get-storage.js +1 -17
- package/dist/lib/storage/index.js +1 -18
- package/dist/lib/typography.js +1 -34
- package/dist/lib/utils.js +1 -45
- package/dist/theme/get-theme-script.js +1 -44
- package/dist/theme/index.js +1 -11
- package/dist/theme/mode-toggle.js +1 -48
- package/dist/theme/theme-provider.js +1 -160
- package/dist/toast/helpers.js +1 -41
- package/dist/toast/index.js +1 -10
- package/dist/types/metadata-type.js +1 -2
- package/dist/utils/countries.cjs +1 -17
- package/dist/utils/country-utils.js +1 -25
- package/dist/utils/currency-codes.js +1 -184
- package/package.json +4 -3
|
@@ -1,49 +1 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.SidebarExpandButton = void 0;
|
|
8
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
-
const react_1 = __importDefault(require("react"));
|
|
10
|
-
const lucide_react_1 = require("lucide-react");
|
|
11
|
-
const sidebar_provider_1 = require("./sidebar-provider");
|
|
12
|
-
const sidebar_components_1 = require("./sidebar-components");
|
|
13
|
-
const tooltip_1 = require("../../ui/tooltip");
|
|
14
|
-
const icon_button_1 = require("../icon-button");
|
|
15
|
-
const SidebarExpandButton = ({ tooltip }) => {
|
|
16
|
-
const { isCollapsed, isDrawer, toggleSidebar } = (0, sidebar_provider_1.useSidebar)();
|
|
17
|
-
/**
|
|
18
|
-
* Nothing to collapse in a drawer. The expanded branch below hangs its button
|
|
19
|
-
* at `right-[-20px]`, twenty pixels outside the rail — off the canvas of an
|
|
20
|
-
* overlay that has no page beside it — and collapsing to a 72px strip inside
|
|
21
|
-
* a 244px sheet is not a state worth reaching. The drawer's own close control
|
|
22
|
-
* and the backdrop are how it is dismissed.
|
|
23
|
-
*
|
|
24
|
-
* ⚠️ `isDrawer`, NOT `isMobile`. A consumer left on the default
|
|
25
|
-
* `mobile="inline"` still has a real rail below 768px, and its collapse
|
|
26
|
-
* control has to come with it.
|
|
27
|
-
*/
|
|
28
|
-
if (isDrawer) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [!isCollapsed && ((0, jsx_runtime_1.jsx)("div", { "data-slot": "sidebar-expand-button", className: "border-border bg-card flex w-full", children: (0, jsx_runtime_1.jsx)("div", { className: "absolute right-[-20px] bottom-4", children: (0, jsx_runtime_1.jsx)(icon_button_1.IconButton, { variant: "secondary", rounded: true, onClick: toggleSidebar, "aria-label": tooltip || 'Collapse sidebar', "aria-expanded": true, children: (0, jsx_runtime_1.jsx)(lucide_react_1.PanelLeftClose, { className: "text-muted-foreground" }) }) }) })), isCollapsed && ((0, jsx_runtime_1.jsx)(sidebar_components_1.SidebarFooter, { children: (0, jsx_runtime_1.jsx)(tooltip_1.TooltipProvider, { children: (0, jsx_runtime_1.jsxs)(tooltip_1.Tooltip, { children: [(0, jsx_runtime_1.jsx)(tooltip_1.TooltipTrigger
|
|
32
|
-
// `hover:text-accent-foreground` on the TRIGGER, not only on
|
|
33
|
-
// the glyph below. The base ink here used to be base/400, which
|
|
34
|
-
// no rule paired with anything; now that it is the muted token,
|
|
35
|
-
// it is the ink anything inside this trigger inherits, and the
|
|
36
|
-
// muted token reads 1.07:1 on sunglow in dark. The glyph
|
|
37
|
-
// overrides it today, so this pairs the fill for whatever the
|
|
38
|
-
// trigger holds next.
|
|
39
|
-
, {
|
|
40
|
-
// `hover:text-accent-foreground` on the TRIGGER, not only on
|
|
41
|
-
// the glyph below. The base ink here used to be base/400, which
|
|
42
|
-
// no rule paired with anything; now that it is the muted token,
|
|
43
|
-
// it is the ink anything inside this trigger inherits, and the
|
|
44
|
-
// muted token reads 1.07:1 on sunglow in dark. The glyph
|
|
45
|
-
// overrides it today, so this pairs the fill for whatever the
|
|
46
|
-
// trigger holds next.
|
|
47
|
-
className: "group/expand-button text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-sm bg-transparent p-2", onClick: toggleSidebar, "aria-label": tooltip || 'Expand sidebar', "aria-expanded": false, children: (0, jsx_runtime_1.jsx)(lucide_react_1.PanelRightClose, { className: "group-hover/expand-button:text-accent-foreground dark:text-white" }) }), (0, jsx_runtime_1.jsx)(tooltip_1.TooltipContent, { side: "right", children: tooltip || 'Expand' })] }) }) }))] }));
|
|
48
|
-
};
|
|
49
|
-
exports.SidebarExpandButton = SidebarExpandButton;
|
|
1
|
+
"use client";"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{"default":e}};Object.defineProperty(exports,"__esModule",{value:true});exports.SidebarExpandButton=void 0;const jsx_runtime_1=require("react/jsx-runtime");const react_1=__importDefault(require("react"));const lucide_react_1=require("lucide-react");const sidebar_provider_1=require("./sidebar-provider");const sidebar_components_1=require("./sidebar-components");const tooltip_1=require("../../ui/tooltip");const icon_button_1=require("../icon-button");const SidebarExpandButton=({tooltip:e})=>{const{isCollapsed:r,isDrawer:o,toggleSidebar:t}=(0,sidebar_provider_1.useSidebar)();if(o){return null}return(0,jsx_runtime_1.jsxs)(react_1.default.Fragment,{children:[!r&&(0,jsx_runtime_1.jsx)("div",{"data-slot":"sidebar-expand-button",className:"border-border bg-card flex w-full",children:(0,jsx_runtime_1.jsx)("div",{className:"absolute right-[-20px] bottom-4",children:(0,jsx_runtime_1.jsx)(icon_button_1.IconButton,{variant:"secondary",rounded:true,onClick:t,"aria-label":e||"Collapse sidebar","aria-expanded":true,children:(0,jsx_runtime_1.jsx)(lucide_react_1.PanelLeftClose,{className:"text-muted-foreground"})})})}),r&&(0,jsx_runtime_1.jsx)(sidebar_components_1.SidebarFooter,{children:(0,jsx_runtime_1.jsx)(tooltip_1.TooltipProvider,{children:(0,jsx_runtime_1.jsxs)(tooltip_1.Tooltip,{children:[(0,jsx_runtime_1.jsx)(tooltip_1.TooltipTrigger,{className:"group/expand-button text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-sm bg-transparent p-2",onClick:t,"aria-label":e||"Expand sidebar","aria-expanded":false,children:(0,jsx_runtime_1.jsx)(lucide_react_1.PanelRightClose,{className:"group-hover/expand-button:text-accent-foreground dark:text-white"})}),(0,jsx_runtime_1.jsx)(tooltip_1.TooltipContent,{side:"right",children:e||"Expand"})]})})})]})};exports.SidebarExpandButton=SidebarExpandButton;
|
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.SidebarItemButton = SidebarItemButton;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const button_1 = require("../../ui/button");
|
|
7
|
-
const utils_1 = require("../../../lib/utils");
|
|
8
|
-
const sidebar_router_1 = require("./sidebar-router");
|
|
9
|
-
function SidebarItemButton({ className, title, icon, href, active, inactive, disabled = false, ...props }) {
|
|
10
|
-
const { Link } = (0, sidebar_router_1.useSidebarRouter)();
|
|
11
|
-
const sharedClassName = (0, utils_1.cn)((0, button_1.buttonVariants)({
|
|
12
|
-
variant: active ? 'tertiary' : 'outline',
|
|
13
|
-
fullWidth: true,
|
|
14
|
-
size: 'small'
|
|
15
|
-
}), 'group/link flex items-center justify-start', inactive && 'hover:border-transparent', disabled && 'cursor-default opacity-30', className);
|
|
16
|
-
const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [icon && ((0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)((0, button_1.iconVariants)({ position: 'start', size: 'small' })), children: icon })), title] }));
|
|
17
|
-
if (disabled || inactive) {
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)("div", { "data-slot": "sidebar-item-button", className: sharedClassName, children: content }));
|
|
19
|
-
}
|
|
20
|
-
return ((0, jsx_runtime_1.jsx)(Link, { "data-slot": "sidebar-item-button", href: href, className: sharedClassName, ...props, children: content }));
|
|
21
|
-
}
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SidebarItemButton=SidebarItemButton;const jsx_runtime_1=require("react/jsx-runtime");const button_1=require("../../ui/button");const utils_1=require("../../../lib/utils");const sidebar_router_1=require("./sidebar-router");function SidebarItemButton({className:n,title:a,icon:t,href:u,active:o,inactive:e,disabled:r=false,...l}){const{Link:c}=(0,sidebar_router_1.useSidebarRouter)();const s=(0,utils_1.cn)((0,button_1.buttonVariants)({variant:o?"tertiary":"outline",fullWidth:true,size:"small"}),"group/link flex items-center justify-start",e&&"hover:border-transparent",r&&"cursor-default opacity-30",n);const i=(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[t&&(0,jsx_runtime_1.jsx)("span",{className:(0,utils_1.cn)((0,button_1.iconVariants)({position:"start",size:"small"})),children:t}),a]});if(r||e){return(0,jsx_runtime_1.jsx)("div",{"data-slot":"sidebar-item-button",className:s,children:i})}return(0,jsx_runtime_1.jsx)(c,{"data-slot":"sidebar-item-button",href:u,className:s,...l,children:i})}
|
|
@@ -1,52 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SidebarItemCollapsible = SidebarItemCollapsible;
|
|
7
|
-
exports.SidebarItemCollapsibleTrigger = SidebarItemCollapsibleTrigger;
|
|
8
|
-
exports.SidebarItemCollapsibleContent = SidebarItemCollapsibleContent;
|
|
9
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
10
|
-
const react_1 = __importDefault(require("react"));
|
|
11
|
-
const utils_1 = require("../../../lib/utils");
|
|
12
|
-
const react_collapsible_1 = require("@radix-ui/react-collapsible");
|
|
13
|
-
const lucide_react_1 = require("lucide-react");
|
|
14
|
-
const sidebar_provider_1 = require("./sidebar-provider");
|
|
15
|
-
const separator_1 = require("../separator");
|
|
16
|
-
const sidebar_item_button_1 = require("./sidebar-item-button");
|
|
17
|
-
const button_1 = require("../button");
|
|
18
|
-
const sidebar_item_icon_button_1 = require("./sidebar-item-icon-button");
|
|
19
|
-
function SidebarItemCollapsible({ name, className, ...props }) {
|
|
20
|
-
const { isCollapsed, getItemCollapsed, setItemCollapsed } = (0, sidebar_provider_1.useSidebar)();
|
|
21
|
-
const [open, setOpen] = react_1.default.useState(name ? getItemCollapsed(name) : false);
|
|
22
|
-
const handleOpenChange = (open) => {
|
|
23
|
-
setOpen(open);
|
|
24
|
-
if (name) {
|
|
25
|
-
setItemCollapsed(name, open);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
react_1.default.useEffect(() => {
|
|
29
|
-
if (name) {
|
|
30
|
-
setOpen(getItemCollapsed(name));
|
|
31
|
-
}
|
|
32
|
-
}, [name, getItemCollapsed]);
|
|
33
|
-
return ((0, jsx_runtime_1.jsx)(react_collapsible_1.Collapsible, { open: open, onOpenChange: handleOpenChange, "data-slot": "sidebar-item-collapsible", className: (0, utils_1.cn)({
|
|
34
|
-
'rounded-md': isCollapsed
|
|
35
|
-
}, className), ...props }));
|
|
36
|
-
}
|
|
37
|
-
function SidebarItemCollapsibleTrigger({ className, icon, title, children: _children, ...props }) {
|
|
38
|
-
const { isCollapsed } = (0, sidebar_provider_1.useSidebar)();
|
|
39
|
-
return ((0, jsx_runtime_1.jsxs)(react_collapsible_1.CollapsibleTrigger, { "data-slot": "sidebar-item-collapsible-trigger", className: (0, utils_1.cn)('flex w-full flex-row p-0', 'transition-all hover:underline [&[data-state=open]>svg]:rotate-90', (0, button_1.buttonVariants)({
|
|
40
|
-
variant: 'outline',
|
|
41
|
-
fullWidth: true,
|
|
42
|
-
size: 'small'
|
|
43
|
-
}), {
|
|
44
|
-
'size-10': isCollapsed
|
|
45
|
-
}, className), ...props, children: [isCollapsed && ((0, jsx_runtime_1.jsx)(sidebar_item_icon_button_1.SidebarItemIconButton, { title: title, icon: icon, href: "", inactive: true })), !isCollapsed && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(sidebar_item_button_1.SidebarItemButton, { title: title, icon: icon, href: '', inactive: true }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "text-foreground mr-1 size-6 shrink-0 cursor-pointer transition-transform duration-200" })] }))] }));
|
|
46
|
-
}
|
|
47
|
-
function SidebarItemCollapsibleContent({ className, children, ...props }) {
|
|
48
|
-
const { isCollapsed } = (0, sidebar_provider_1.useSidebar)();
|
|
49
|
-
return ((0, jsx_runtime_1.jsx)(react_collapsible_1.CollapsibleContent, { "data-slot": "sidebar-item-collapsible-content", className: (0, utils_1.cn)('mt-1 flex flex-col gap-1', 'motion-safe:data-[state=closed]:animate-collapsible-up motion-safe:data-[state=open]:animate-collapsible-down overflow-hidden transition-all duration-200 ease-in-out', {
|
|
50
|
-
'items-center': isCollapsed
|
|
51
|
-
}, className), ...props, children: isCollapsed ? (children) : ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-stretch gap-3", children: [(0, jsx_runtime_1.jsx)(separator_1.Separator, { className: "ml-5 h-auto", orientation: "vertical" }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-full flex-col gap-1", children: children })] })) }));
|
|
52
|
-
}
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{"default":e}};Object.defineProperty(exports,"__esModule",{value:true});exports.SidebarItemCollapsible=SidebarItemCollapsible;exports.SidebarItemCollapsibleTrigger=SidebarItemCollapsibleTrigger;exports.SidebarItemCollapsibleContent=SidebarItemCollapsibleContent;const jsx_runtime_1=require("react/jsx-runtime");const react_1=__importDefault(require("react"));const utils_1=require("../../../lib/utils");const react_collapsible_1=require("@radix-ui/react-collapsible");const lucide_react_1=require("lucide-react");const sidebar_provider_1=require("./sidebar-provider");const separator_1=require("../separator");const sidebar_item_button_1=require("./sidebar-item-button");const button_1=require("../button");const sidebar_item_icon_button_1=require("./sidebar-item-icon-button");function SidebarItemCollapsible({name:e,className:t,...i}){const{isCollapsed:r,getItemCollapsed:s,setItemCollapsed:a}=(0,sidebar_provider_1.useSidebar)();const[n,l]=react_1.default.useState(e?s(e):false);const c=o=>{l(o);if(e){a(e,o)}};react_1.default.useEffect(()=>{if(e){l(s(e))}},[e,s]);return(0,jsx_runtime_1.jsx)(react_collapsible_1.Collapsible,{open:n,onOpenChange:c,"data-slot":"sidebar-item-collapsible",className:(0,utils_1.cn)({"rounded-md":r},t),...i})}function SidebarItemCollapsibleTrigger({className:e,icon:t,title:i,children:r,...s}){const{isCollapsed:a}=(0,sidebar_provider_1.useSidebar)();return(0,jsx_runtime_1.jsxs)(react_collapsible_1.CollapsibleTrigger,{"data-slot":"sidebar-item-collapsible-trigger",className:(0,utils_1.cn)("flex w-full flex-row p-0","transition-all hover:underline [&[data-state=open]>svg]:rotate-90",(0,button_1.buttonVariants)({variant:"outline",fullWidth:true,size:"small"}),{"size-10":a},e),...s,children:[a&&(0,jsx_runtime_1.jsx)(sidebar_item_icon_button_1.SidebarItemIconButton,{title:i,icon:t,href:"",inactive:true}),!a&&(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(sidebar_item_button_1.SidebarItemButton,{title:i,icon:t,href:"",inactive:true}),(0,jsx_runtime_1.jsx)(lucide_react_1.ChevronRight,{className:"text-foreground mr-1 size-6 shrink-0 cursor-pointer transition-transform duration-200"})]})]})}function SidebarItemCollapsibleContent({className:e,children:t,...i}){const{isCollapsed:r}=(0,sidebar_provider_1.useSidebar)();return(0,jsx_runtime_1.jsx)(react_collapsible_1.CollapsibleContent,{"data-slot":"sidebar-item-collapsible-content",className:(0,utils_1.cn)("mt-1 flex flex-col gap-1","motion-safe:data-[state=closed]:animate-collapsible-up motion-safe:data-[state=open]:animate-collapsible-down overflow-hidden transition-all duration-200 ease-in-out",{"items-center":r},e),...i,children:r?t:(0,jsx_runtime_1.jsxs)("div",{className:"flex items-stretch gap-3",children:[(0,jsx_runtime_1.jsx)(separator_1.Separator,{className:"ml-5 h-auto",orientation:"vertical"}),(0,jsx_runtime_1.jsx)("div",{className:"flex w-full flex-col gap-1",children:t})]})})}
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.SidebarItemIconButton = void 0;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const button_1 = require("../../ui/button");
|
|
7
|
-
const tooltip_1 = require("../../ui/tooltip");
|
|
8
|
-
const utils_1 = require("../../../lib/utils");
|
|
9
|
-
const icon_button_1 = require("../icon-button");
|
|
10
|
-
const sidebar_router_1 = require("./sidebar-router");
|
|
11
|
-
const SidebarItemIconButton = ({ className, title, icon, href, active, inactive, disabled, ...props }) => {
|
|
12
|
-
const { Link } = (0, sidebar_router_1.useSidebarRouter)();
|
|
13
|
-
const sharedClassName = (0, utils_1.cn)((0, button_1.buttonVariants)({
|
|
14
|
-
variant: active ? 'tertiary' : 'outline'
|
|
15
|
-
}), (0, icon_button_1.iconButtonVariants)(), inactive && 'hover:border-transparent', disabled && 'cursor-default opacity-30', className);
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(tooltip_1.TooltipProvider, { children: (0, jsx_runtime_1.jsxs)(tooltip_1.Tooltip, { delayDuration: 0, children: [(0, jsx_runtime_1.jsx)(tooltip_1.TooltipTrigger, { asChild: true, children: disabled || inactive ? ((0, jsx_runtime_1.jsx)("div", { "data-slot": "sidebar-item-icon-button", className: sharedClassName, children: icon })) : ((0, jsx_runtime_1.jsx)(Link, { "data-slot": "sidebar-item-icon-button", href: href, className: sharedClassName, ...props, children: icon })) }), (0, jsx_runtime_1.jsx)(tooltip_1.TooltipContent, { side: "right", children: title })] }) }));
|
|
17
|
-
};
|
|
18
|
-
exports.SidebarItemIconButton = SidebarItemIconButton;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SidebarItemIconButton=void 0;const jsx_runtime_1=require("react/jsx-runtime");const button_1=require("../../ui/button");const tooltip_1=require("../../ui/tooltip");const utils_1=require("../../../lib/utils");const icon_button_1=require("../icon-button");const sidebar_router_1=require("./sidebar-router");const SidebarItemIconButton=({className:i,title:n,icon:t,href:s,active:u,inactive:e,disabled:r,...a})=>{const{Link:c}=(0,sidebar_router_1.useSidebarRouter)();const o=(0,utils_1.cn)((0,button_1.buttonVariants)({variant:u?"tertiary":"outline"}),(0,icon_button_1.iconButtonVariants)(),e&&"hover:border-transparent",r&&"cursor-default opacity-30",i);return(0,jsx_runtime_1.jsx)(tooltip_1.TooltipProvider,{children:(0,jsx_runtime_1.jsxs)(tooltip_1.Tooltip,{delayDuration:0,children:[(0,jsx_runtime_1.jsx)(tooltip_1.TooltipTrigger,{asChild:true,children:r||e?(0,jsx_runtime_1.jsx)("div",{"data-slot":"sidebar-item-icon-button",className:o,children:t}):(0,jsx_runtime_1.jsx)(c,{"data-slot":"sidebar-item-icon-button",href:s,className:o,...a,children:t})}),(0,jsx_runtime_1.jsx)(tooltip_1.TooltipContent,{side:"right",children:n})]})})};exports.SidebarItemIconButton=SidebarItemIconButton;
|
|
@@ -1,44 +1 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.SidebarItem = void 0;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const sidebar_item_button_1 = require("./sidebar-item-button");
|
|
7
|
-
const sidebar_item_icon_button_1 = require("./sidebar-item-icon-button");
|
|
8
|
-
const sidebar_provider_1 = require("./sidebar-provider");
|
|
9
|
-
const sidebar_router_1 = require("./sidebar-router");
|
|
10
|
-
const SidebarItem = ({ active, href, children: _children, onClick, ...props }) => {
|
|
11
|
-
const { usePathname } = (0, sidebar_router_1.useSidebarRouter)();
|
|
12
|
-
const pathname = usePathname();
|
|
13
|
-
const { isCollapsed, isDrawer, setOpenMobile } = (0, sidebar_provider_1.useSidebar)();
|
|
14
|
-
const isActive = (href) => pathname === href;
|
|
15
|
-
/**
|
|
16
|
-
* ⛔ ACTIVATING A DESTINATION CLOSES THE DRAWER. It is the whole point of the
|
|
17
|
-
* drawer and it was the one interaction that left it open: Escape, the
|
|
18
|
-
* backdrop and the X all dismissed it, a navigation link did not.
|
|
19
|
-
*
|
|
20
|
-
* The overlay is modal, so `document.body` carries `pointer-events: none`
|
|
21
|
-
* while it is up, and a consumer's `SidebarItem` is a client-side `Link`
|
|
22
|
-
* under a provider that survives the route change — so the reader landed on
|
|
23
|
-
* the new page rendered INERT behind a drawer they had to dismiss a second
|
|
24
|
-
* time, on a phone.
|
|
25
|
-
*
|
|
26
|
-
* Here rather than in `SidebarRoot`, because this is the component that knows
|
|
27
|
-
* an activation happened; `SidebarBackButton` and every
|
|
28
|
-
* `SidebarItemCollapsibleContent` leaf render through it, so they are covered
|
|
29
|
-
* by construction. Guarded on `isDrawer` so an inline rail — where nothing is
|
|
30
|
-
* covering the page — behaves exactly as before, and the consumer's own
|
|
31
|
-
* handler still runs either way.
|
|
32
|
-
*/
|
|
33
|
-
const handleClick = (event) => {
|
|
34
|
-
onClick?.(event);
|
|
35
|
-
if (isDrawer) {
|
|
36
|
-
setOpenMobile(false);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
if (isCollapsed) {
|
|
40
|
-
return ((0, jsx_runtime_1.jsx)(sidebar_item_icon_button_1.SidebarItemIconButton, { "data-slot": "sidebar-item", href: href, active: isActive(href) || active, onClick: handleClick, ...props }));
|
|
41
|
-
}
|
|
42
|
-
return ((0, jsx_runtime_1.jsx)(sidebar_item_button_1.SidebarItemButton, { "data-slot": "sidebar-item", href: href, active: isActive(href) || active, onClick: handleClick, ...props }));
|
|
43
|
-
};
|
|
44
|
-
exports.SidebarItem = SidebarItem;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SidebarItem=void 0;const jsx_runtime_1=require("react/jsx-runtime");const sidebar_item_button_1=require("./sidebar-item-button");const sidebar_item_icon_button_1=require("./sidebar-item-icon-button");const sidebar_provider_1=require("./sidebar-provider");const sidebar_router_1=require("./sidebar-router");const SidebarItem=({active:r,href:e,children:_,onClick:n,...i})=>{const{usePathname:a}=(0,sidebar_router_1.useSidebarRouter)();const d=a();const{isCollapsed:u,isDrawer:c,setOpenMobile:b}=(0,sidebar_provider_1.useSidebar)();const s=t=>d===t;const o=t=>{n?.(t);if(c){b(false)}};if(u){return(0,jsx_runtime_1.jsx)(sidebar_item_icon_button_1.SidebarItemIconButton,{"data-slot":"sidebar-item",href:e,active:s(e)||r,onClick:o,...i})}return(0,jsx_runtime_1.jsx)(sidebar_item_button_1.SidebarItemButton,{"data-slot":"sidebar-item",href:e,active:s(e)||r,onClick:o,...i})};exports.SidebarItem=SidebarItem;
|
|
@@ -1,201 +1 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.SidebarProvider = exports.useSidebar = exports.SidebarContext = exports.SIDEBAR_MOBILE_QUERY = void 0;
|
|
8
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
-
const react_1 = __importDefault(require("react"));
|
|
10
|
-
const storage_1 = require("../../../lib/storage");
|
|
11
|
-
/**
|
|
12
|
-
* The viewport below which the rail stops being a layout and becomes a drawer.
|
|
13
|
-
*
|
|
14
|
-
* ⛔ THE NEGATION OF THE TRIGGER'S QUERY, SPELLED AS A NEGATION.
|
|
15
|
-
*
|
|
16
|
-
* `SidebarTrigger` hides itself at `min-[768px]`, which is `width >= 768`. This
|
|
17
|
-
* is its exact complement AT ANY PRECISION, which `(max-width: 767px)` was not:
|
|
18
|
-
* that pair leaves the open interval (767, 768) matched by neither rule, and a
|
|
19
|
-
* viewport there draws the rail AND a hamburger that opens nothing — with the
|
|
20
|
-
* rail inline, `SidebarRoot` mounts no `Sheet`, so the control is dead. Chromium
|
|
21
|
-
* snaps its layout viewport to a whole pixel and never lands there, measured at
|
|
22
|
-
* four zoom levels; that is a rounding behaviour to rely on, not a boundary.
|
|
23
|
-
*
|
|
24
|
-
* ⚠️ THE PAIR HAS TO BE IN THE SAME UNIT. It used to be `md:hidden` over there,
|
|
25
|
-
* and `md` is 48rem: rem in a media query follows the BROWSER'S default font
|
|
26
|
-
* size, so at Chrome's "Small" setting that class hid the hamburger from 576px
|
|
27
|
-
* while this query still asked for a drawer up to 767px — a band of viewports
|
|
28
|
-
* with no navigation at all. Anything else that hides or shows a control at
|
|
29
|
-
* this boundary states it in pixels for the same reason.
|
|
30
|
-
*
|
|
31
|
-
* Media Queries Level 4 boolean logic, which is not a new requirement here:
|
|
32
|
-
* Tailwind v4 emits MQ4 RANGE syntax for everything this package ships —
|
|
33
|
-
* `min-[768px]` on the trigger compiles to `@media (width >= 768px)` and
|
|
34
|
-
* `max-sm:` on `SheetContent` to `@media (width < 40rem)` — and range syntax
|
|
35
|
-
* and boolean `not` landed in the same browsers (Chrome 88, Firefox 64,
|
|
36
|
-
* Safari 16.4). `(width < 768px)` is the equivalent range spelling of this
|
|
37
|
-
* line, should a reader prefer the pair to match character for character.
|
|
38
|
-
*/
|
|
39
|
-
exports.SIDEBAR_MOBILE_QUERY = 'not (min-width: 768px)';
|
|
40
|
-
/**
|
|
41
|
-
* Where focus goes when the rail has to receive it. The rail's own content is
|
|
42
|
-
* links and buttons, so this is deliberately the short list rather than the
|
|
43
|
-
* full tabbable grammar: a `[tabindex]` sweep would have to exclude `-1`, and
|
|
44
|
-
* nothing in a sidebar carries one.
|
|
45
|
-
*/
|
|
46
|
-
const FOCUSABLE = 'a[href], button:not([disabled])';
|
|
47
|
-
/**
|
|
48
|
-
* Exported so `SidebarRoot` can re-provide it for the drawer's subtree. That
|
|
49
|
-
* subtree is the only place `isCollapsed` and `isDrawer` differ from the
|
|
50
|
-
* provider's own values, and scoping the override to it is what keeps a
|
|
51
|
-
* consumer on `mobile="inline"` seeing exactly today's rail.
|
|
52
|
-
*/
|
|
53
|
-
exports.SidebarContext = react_1.default.createContext(undefined);
|
|
54
|
-
const useSidebar = () => {
|
|
55
|
-
const context = react_1.default.useContext(exports.SidebarContext);
|
|
56
|
-
if (!context) {
|
|
57
|
-
throw new Error('useSidebar must be used within a SidebarProvider');
|
|
58
|
-
}
|
|
59
|
-
return context;
|
|
60
|
-
};
|
|
61
|
-
exports.useSidebar = useSidebar;
|
|
62
|
-
const SidebarProvider = ({ children }) => {
|
|
63
|
-
const [hydrated, setHydrated] = react_1.default.useState(false);
|
|
64
|
-
const [collapsed, setCollapsed] = react_1.default.useState(false);
|
|
65
|
-
const [items, _setItems] = react_1.default.useState({});
|
|
66
|
-
const [isMobile, setIsMobile] = react_1.default.useState(false);
|
|
67
|
-
const [openMobile, _setOpenMobile] = react_1.default.useState(false);
|
|
68
|
-
const sidebarId = react_1.default.useId();
|
|
69
|
-
/**
|
|
70
|
-
* ⛔ RADIX CANNOT RESTORE THIS FOCUS BY ITSELF. `DialogContent` preventDefaults
|
|
71
|
-
* the focus scope's own restore and focuses `triggerRef.current` instead —
|
|
72
|
-
* the ref a `SheetTrigger` would have filled. The drawer is opened from this
|
|
73
|
-
* state rather than from a trigger inside the dialog, so that ref is null and
|
|
74
|
-
* closing dropped focus onto `<body>`: a keyboard reader who opened the
|
|
75
|
-
* navigation and pressed Escape was returned to the top of the document.
|
|
76
|
-
*
|
|
77
|
-
* Captured here rather than in `SidebarTrigger` so that a consumer opening
|
|
78
|
-
* the drawer from its own control gets the same behaviour.
|
|
79
|
-
*/
|
|
80
|
-
const opener = react_1.default.useRef(null);
|
|
81
|
-
const setOpenMobile = react_1.default.useCallback((open) => {
|
|
82
|
-
if (open && typeof document !== 'undefined') {
|
|
83
|
-
opener.current = document.activeElement;
|
|
84
|
-
}
|
|
85
|
-
_setOpenMobile(open);
|
|
86
|
-
}, []);
|
|
87
|
-
/**
|
|
88
|
-
* ⛔ THE VIEWPORT AT THE MOMENT FOCUS MOVES, NOT AT THE MOMENT IT OPENED.
|
|
89
|
-
*
|
|
90
|
-
* Radix calls `restoreDrawerFocus` from the focus scope's UNMOUNT handler,
|
|
91
|
-
* which is the last thing in the commit to touch focus — later than any
|
|
92
|
-
* effect in this provider, so the decision has to be made inside the handler
|
|
93
|
-
* rather than beside it. By then `isMobile` has already flipped.
|
|
94
|
-
*/
|
|
95
|
-
const isMobileRef = react_1.default.useRef(false);
|
|
96
|
-
isMobileRef.current = isMobile;
|
|
97
|
-
const restoreDrawerFocus = react_1.default.useCallback(() => {
|
|
98
|
-
// `isConnected`: the control that opened the drawer may itself have been
|
|
99
|
-
// unmounted by whatever the reader did inside it.
|
|
100
|
-
//
|
|
101
|
-
// ⛔ AND NOT AT ALL WHEN THE VIEWPORT IS THE ONE THAT DISMISSED IT. A
|
|
102
|
-
// tablet rotated from portrait to landscape with the navigation open
|
|
103
|
-
// crosses 768px, so the drawer is replaced by the rail and the opener is
|
|
104
|
-
// `SidebarTrigger` — which the same breakpoint just hid.
|
|
105
|
-
// `.focus()` on a `display: none` element is a silent no-op, and Radix's
|
|
106
|
-
// own restore is already `preventDefault()`ed, so focus fell to `<body>`
|
|
107
|
-
// and the reader lost their place (SC 2.4.3). Measured in Chromium at
|
|
108
|
-
// 390 → 1280: `{"rails":1,"triggerDisplay":"none","focus":"BODY:"}`.
|
|
109
|
-
if (isMobileRef.current && opener.current?.isConnected) {
|
|
110
|
-
opener.current.focus();
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
// The rail is what the drawer became, so that is where the reader goes.
|
|
114
|
-
// Below the breakpoint there is nothing here to find — a closed drawer
|
|
115
|
-
// leaves no navigation in the DOM — and focus stays where Radix left it.
|
|
116
|
-
document
|
|
117
|
-
.getElementById(sidebarId)
|
|
118
|
-
?.querySelector(FOCUSABLE)
|
|
119
|
-
?.focus();
|
|
120
|
-
}, [sidebarId]);
|
|
121
|
-
const toggleSidebar = () => setCollapsed((collapsed) => !collapsed);
|
|
122
|
-
const getItemCollapsed = (key) => {
|
|
123
|
-
return items[key] || false;
|
|
124
|
-
};
|
|
125
|
-
const setItemCollapsed = (key, value) => {
|
|
126
|
-
_setItems((items) => ({ ...items, [key]: value }));
|
|
127
|
-
};
|
|
128
|
-
// Read from localStorage after hydration to avoid SSR mismatch
|
|
129
|
-
react_1.default.useEffect(() => {
|
|
130
|
-
setCollapsed((0, storage_1.getStorage)('sidebar-collapsed', false) === 'true');
|
|
131
|
-
_setItems((0, storage_1.getStorageObject)('sidebar-items', {}));
|
|
132
|
-
setHydrated(true);
|
|
133
|
-
}, []);
|
|
134
|
-
/**
|
|
135
|
-
* ⚠️ FALSE UNTIL THE CLIENT SAYS OTHERWISE. There is no viewport on the
|
|
136
|
-
* server, so the first paint is always the rail and the drawer appears on
|
|
137
|
-
* hydration; starting from a guess would make the markup differ between the
|
|
138
|
-
* two renders. The `matchMedia` guard is the one `theme-provider.tsx` next
|
|
139
|
-
* door already carries: jsdom and some embedded runtimes ship without it, and
|
|
140
|
-
* a missing media API is a desktop, not a crash.
|
|
141
|
-
*/
|
|
142
|
-
react_1.default.useEffect(() => {
|
|
143
|
-
if (typeof window.matchMedia !== 'function') {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
const media = window.matchMedia(exports.SIDEBAR_MOBILE_QUERY);
|
|
147
|
-
const sync = () => setIsMobile(media.matches);
|
|
148
|
-
sync();
|
|
149
|
-
media.addEventListener('change', sync);
|
|
150
|
-
return () => media.removeEventListener('change', sync);
|
|
151
|
-
}, []);
|
|
152
|
-
/**
|
|
153
|
-
* A drawer left open while the viewport grows back would keep an overlay and
|
|
154
|
-
* a focus trap over a layout that is already showing its rail, with nothing
|
|
155
|
-
* on screen to dismiss them.
|
|
156
|
-
*
|
|
157
|
-
* Where focus goes afterwards is `restoreDrawerFocus`'s decision, not this
|
|
158
|
-
* effect's: Radix's unmount handler runs later than anything here.
|
|
159
|
-
*/
|
|
160
|
-
react_1.default.useEffect(() => {
|
|
161
|
-
if (!isMobile) {
|
|
162
|
-
_setOpenMobile(false);
|
|
163
|
-
}
|
|
164
|
-
}, [isMobile]);
|
|
165
|
-
// Only persist to localStorage after hydration to avoid overwriting stored values
|
|
166
|
-
react_1.default.useEffect(() => {
|
|
167
|
-
if (!hydrated) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
localStorage.setItem('sidebar-collapsed', JSON.stringify(collapsed));
|
|
171
|
-
}, [collapsed, hydrated]);
|
|
172
|
-
react_1.default.useEffect(() => {
|
|
173
|
-
if (!hydrated) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
localStorage.setItem('sidebar-items', JSON.stringify(items));
|
|
177
|
-
}, [items, hydrated]);
|
|
178
|
-
return ((0, jsx_runtime_1.jsx)(exports.SidebarContext.Provider, { value: {
|
|
179
|
-
/**
|
|
180
|
-
* ⚠️ A NARROW VIEWPORT DOES NOT TOUCH THIS. It used to be forced false
|
|
181
|
-
* whenever `isMobile`, which silently changed the rail for every
|
|
182
|
-
* consumer — including the ones that never asked for a drawer.
|
|
183
|
-
* `SidebarRoot` overrides it for the drawer's own subtree instead, so
|
|
184
|
-
* the stored preference reaches an inline rail unchanged at every
|
|
185
|
-
* viewport.
|
|
186
|
-
*/
|
|
187
|
-
isCollapsed: collapsed,
|
|
188
|
-
isDrawer: false,
|
|
189
|
-
isMobile,
|
|
190
|
-
openMobile,
|
|
191
|
-
setOpenMobile,
|
|
192
|
-
restoreDrawerFocus,
|
|
193
|
-
sidebarId,
|
|
194
|
-
items,
|
|
195
|
-
setItems: _setItems,
|
|
196
|
-
getItemCollapsed,
|
|
197
|
-
setItemCollapsed,
|
|
198
|
-
toggleSidebar
|
|
199
|
-
}, children: children }));
|
|
200
|
-
};
|
|
201
|
-
exports.SidebarProvider = SidebarProvider;
|
|
1
|
+
"use client";"use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{"default":t}};Object.defineProperty(exports,"__esModule",{value:true});exports.SidebarProvider=exports.useSidebar=exports.SidebarContext=exports.SIDEBAR_MOBILE_QUERY=void 0;const jsx_runtime_1=require("react/jsx-runtime");const react_1=__importDefault(require("react"));const storage_1=require("../../../lib/storage");exports.SIDEBAR_MOBILE_QUERY="not (min-width: 768px)";const FOCUSABLE="a[href], button:not([disabled])";exports.SidebarContext=react_1.default.createContext(void 0);const useSidebar=()=>{const t=react_1.default.useContext(exports.SidebarContext);if(!t){throw new Error("useSidebar must be used within a SidebarProvider")}return t};exports.useSidebar=useSidebar;const SidebarProvider=({children:t})=>{const[r,b]=react_1.default.useState(false);const[n,l]=react_1.default.useState(false);const[a,u]=react_1.default.useState({});const[o,S]=react_1.default.useState(false);const[p,c]=react_1.default.useState(false);const i=react_1.default.useId();const d=react_1.default.useRef(null);const x=react_1.default.useCallback(e=>{if(e&&typeof document!=="undefined"){d.current=document.activeElement}c(e)},[]);const f=react_1.default.useRef(false);f.current=o;const m=react_1.default.useCallback(()=>{if(f.current&&d.current?.isConnected){d.current.focus();return}document.getElementById(i)?.querySelector(FOCUSABLE)?.focus()},[i]);const E=()=>l(e=>!e);const _=e=>{return a[e]||false};const g=(e,s)=>{u(I=>({...I,[e]:s}))};react_1.default.useEffect(()=>{l((0,storage_1.getStorage)("sidebar-collapsed",false)==="true");u((0,storage_1.getStorageObject)("sidebar-items",{}));b(true)},[]);react_1.default.useEffect(()=>{if(typeof window.matchMedia!=="function"){return}const e=window.matchMedia(exports.SIDEBAR_MOBILE_QUERY);const s=()=>S(e.matches);s();e.addEventListener("change",s);return()=>e.removeEventListener("change",s)},[]);react_1.default.useEffect(()=>{if(!o){c(false)}},[o]);react_1.default.useEffect(()=>{if(!r){return}localStorage.setItem("sidebar-collapsed",JSON.stringify(n))},[n,r]);react_1.default.useEffect(()=>{if(!r){return}localStorage.setItem("sidebar-items",JSON.stringify(a))},[a,r]);return(0,jsx_runtime_1.jsx)(exports.SidebarContext.Provider,{value:{isCollapsed:n,isDrawer:false,isMobile:o,openMobile:p,setOpenMobile:x,restoreDrawerFocus:m,sidebarId:i,items:a,setItems:u,getItemCollapsed:_,setItemCollapsed:g,toggleSidebar:E},children:t})};exports.SidebarProvider=SidebarProvider;
|
|
@@ -1,130 +1 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.SidebarRoot = void 0;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const class_variance_authority_1 = require("class-variance-authority");
|
|
7
|
-
const sidebar_provider_1 = require("./sidebar-provider");
|
|
8
|
-
const utils_1 = require("../../../lib/utils");
|
|
9
|
-
const sheet_1 = require("../sheet");
|
|
10
|
-
/**
|
|
11
|
-
* ⛔ THE WIDTHS ARE TOKENS, NOT LITERALS.
|
|
12
|
-
*
|
|
13
|
-
* They were `w-[72px]` and `w-[244px]`, which a consumer could only override by
|
|
14
|
-
* winning a specificity argument with `cn`. `--sidebar-width` and
|
|
15
|
-
* `--sidebar-width-collapsed` are declared in `tokens.css`, so the default
|
|
16
|
-
* still ships with the stylesheet, and a consumer re-points either one with
|
|
17
|
-
* `className="[--sidebar-width:280px]"` ON THE RAIL, which moves the rail and
|
|
18
|
-
* the mobile drawer together (see `liftWidthOverrides` below), or with a rule
|
|
19
|
-
* on `:root`/`html`.
|
|
20
|
-
*
|
|
21
|
-
* ⚠️ A DECLARATION ON A REACT-TREE ANCESTOR REACHES THE RAIL AND NOT THE
|
|
22
|
-
* DRAWER. Custom properties inherit down the DOM tree, and the drawer is
|
|
23
|
-
* portalled to `document.body`, so a layout wrapper is not an ancestor of it.
|
|
24
|
-
* `:root` is, which is why it is named above and a wrapper is not.
|
|
25
|
-
*/
|
|
26
|
-
const sidebarVariants = (0, class_variance_authority_1.cva)('group/sidebar shadow-sidebar relative flex flex-col transition-[width] duration-300 ease-in-out', {
|
|
27
|
-
variants: {
|
|
28
|
-
collapsed: {
|
|
29
|
-
true: 'w-[var(--sidebar-width-collapsed)]',
|
|
30
|
-
false: 'w-[var(--sidebar-width)]'
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
defaultVariants: {
|
|
34
|
-
collapsed: false
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* Tailwind arbitrary-property classes that re-point the sidebar geometry, e.g.
|
|
39
|
-
* `[--sidebar-width:320px]` or `[--sidebar-width-collapsed:88px]`.
|
|
40
|
-
*
|
|
41
|
-
* ⚠️ ANCHORED TO A CLASS BOUNDARY, WHICH IS THE WHOLE POINT OF THE LOOKBEHIND.
|
|
42
|
-
* Unanchored it also matched the tail of `md:[--sidebar-width:320px]` and
|
|
43
|
-
* lifted it with the prefix stripped — an override a consumer scoped to
|
|
44
|
-
* ≥768px, applied unconditionally to the drawer that only exists below it.
|
|
45
|
-
*/
|
|
46
|
-
const WIDTH_OVERRIDE = /(?<=^|\s)\[--sidebar-width(?:-collapsed)?:[^\]]+\]/g;
|
|
47
|
-
/**
|
|
48
|
-
* ⛔ THE ONE PART OF THE CONSUMER'S className THAT HAS TO CROSS THE PORTAL.
|
|
49
|
-
*
|
|
50
|
-
* `SheetContent` mounts through `SheetPortal` into `document.body`, and custom
|
|
51
|
-
* properties inherit down the DOM tree rather than the React tree. So the
|
|
52
|
-
* documented override — a class on the rail — set `--sidebar-width` on an
|
|
53
|
-
* element the drawer is not a descendant of, and the whole className that DOES
|
|
54
|
-
* travel lands on the inner `<nav>`, which is BELOW the element that reads the
|
|
55
|
-
* variable. Measured in Chromium: rail 320px, drawer 244px. Following the
|
|
56
|
-
* instruction handed to product-console produced a 280px rail on desktop and a
|
|
57
|
-
* 244px drawer on a phone, silently.
|
|
58
|
-
*
|
|
59
|
-
* ⚠️ ONLY THE GEOMETRY TOKENS. The rest of a rail className is rail-shaped —
|
|
60
|
-
* `h-full`, and the `data-[collapsed=false]:min-w-70` all eight console
|
|
61
|
-
* sidebars pass — and putting that on the sheet would reinstate the
|
|
62
|
-
* 280px-inside-a-244px-sheet overflow from the other side.
|
|
63
|
-
*/
|
|
64
|
-
function liftWidthOverrides(className) {
|
|
65
|
-
return className?.match(WIDTH_OVERRIDE)?.join(' ');
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* ⛔ BELOW 768px A RAIL IS NOT A LAYOUT — once a consumer opts in.
|
|
69
|
-
*
|
|
70
|
-
* The widths above are a fixed share of a flex row, so at 390px the expanded
|
|
71
|
-
* rail took 63% of the screen and left the page 146px, and the only affordance
|
|
72
|
-
* — `SidebarExpandButton` — shrinks it to 72px, which is still 18% and still
|
|
73
|
-
* permanently on screen. There was nothing that removed it.
|
|
74
|
-
*
|
|
75
|
-
* With `mobile="drawer"` the rail is replaced below the breakpoint by an
|
|
76
|
-
* overlay drawer. Escape, the backdrop click, the focus trap and returning
|
|
77
|
-
* focus to whatever opened it are Radix Dialog's, through the kit's own
|
|
78
|
-
* `Sheet`; none of that is re-implemented here.
|
|
79
|
-
*/
|
|
80
|
-
const SidebarRoot = ({ className, id, mobile = 'inline', mobileTitle = 'Navigation', mobileCloseLabel = 'Close', ...props }) => {
|
|
81
|
-
const context = (0, sidebar_provider_1.useSidebar)();
|
|
82
|
-
const { isCollapsed, isMobile, openMobile, setOpenMobile, restoreDrawerFocus, sidebarId } = context;
|
|
83
|
-
if (!isMobile || mobile === 'inline') {
|
|
84
|
-
return ((0, jsx_runtime_1.jsx)("nav", { "data-slot": "sidebar-root", className: (0, utils_1.cn)(sidebarVariants({ collapsed: isCollapsed }), className), "data-collapsed": isCollapsed, ...props, id: mobile === 'drawer' ? sidebarId : id }));
|
|
85
|
-
}
|
|
86
|
-
return ((0, jsx_runtime_1.jsx)(sidebar_provider_1.SidebarContext.Provider, { value: { ...context, isCollapsed: false, isDrawer: true }, children: (0, jsx_runtime_1.jsx)(sheet_1.Sheet, { open: openMobile, onOpenChange: setOpenMobile, children: (0, jsx_runtime_1.jsxs)(sheet_1.SheetContent, { side: "left", closeLabel: mobileCloseLabel,
|
|
87
|
-
// The Sheet's own paddings are built for a form panel; a rail brings
|
|
88
|
-
// its own. `max-w-full` so a consumer widening `--sidebar-width` past
|
|
89
|
-
// the viewport still cannot push the drawer off screen. The lifted
|
|
90
|
-
// override goes LAST so it re-points the variable this element reads.
|
|
91
|
-
//
|
|
92
|
-
// ⛔ THE `max-sm:` PAIR IS NOT A DUPLICATE. `SheetContent` grew a
|
|
93
|
-
// phone step — `max-sm:w-full max-sm:px-4` — because a form panel at
|
|
94
|
-
// two fifths of a 390px screen is unreadable. A NAVIGATION drawer is
|
|
95
|
-
// the one panel that must not take it: 244px over a dimmed page is
|
|
96
|
-
// the design, and full-bleed removes the tap-outside-to-close target
|
|
97
|
-
// that every other way out of this drawer is an alternative to.
|
|
98
|
-
// tailwind-merge drops a conflicting class only when the modifiers
|
|
99
|
-
// match, so a bare `w-[…]` cannot reach `max-sm:w-full` and these two
|
|
100
|
-
// tokens are what state the exemption. Measured: without them the
|
|
101
|
-
// drawer is 390px wide with 16px of inset on a 390px phone.
|
|
102
|
-
className: (0, utils_1.cn)('w-[var(--sidebar-width)] max-w-full gap-0 p-0 max-sm:w-[var(--sidebar-width)] max-sm:p-0', liftWidthOverrides(className)), "aria-describedby": undefined,
|
|
103
|
-
// ⛔ RADIX'S OWN RESTORE GOES NOWHERE HERE. `DialogContent`
|
|
104
|
-
// preventDefaults the focus scope's restore and focuses the ref a
|
|
105
|
-
// `SheetTrigger` would have filled; this drawer is opened from provider
|
|
106
|
-
// state, so that ref is null and closing dropped focus onto `<body>`.
|
|
107
|
-
// Running first means `composeEventHandlers` skips Radix's half.
|
|
108
|
-
onCloseAutoFocus: (event) => {
|
|
109
|
-
event.preventDefault();
|
|
110
|
-
restoreDrawerFocus();
|
|
111
|
-
}, children: [(0, jsx_runtime_1.jsx)(sheet_1.SheetTitle, { className: "sr-only", children: mobileTitle }), (0, jsx_runtime_1.jsx)("nav", { "data-slot": "sidebar-root", "data-mobile": "true",
|
|
112
|
-
/* ⛔ NO `data-collapsed` HERE. The consumer className is forwarded
|
|
113
|
-
verbatim, and all eight console sidebars pass
|
|
114
|
-
`data-[collapsed=false]:min-w-70`; stamping the attribute armed
|
|
115
|
-
it, giving the navigation a 280px min-width inside a 244px sheet.
|
|
116
|
-
`min-width` resolves after `max-width`, so the sheet could not
|
|
117
|
-
claw it back and the contents were 36px wider than the drawer.
|
|
118
|
-
`data-mobile` already names this surface and a drawer is never
|
|
119
|
-
collapsed, so the attribute had nothing left to say. */
|
|
120
|
-
className: (0, utils_1.cn)(sidebarVariants({ collapsed: false }), 'h-full w-full shadow-none', className), ...props,
|
|
121
|
-
/* ⛔ AFTER THE SPREAD, AND NOT THE CALLER'S. This is the target of
|
|
122
|
-
`SidebarTrigger`'s `aria-controls` and the handle the provider
|
|
123
|
-
uses to put focus back into the navigation when the viewport
|
|
124
|
-
grows. Spread first, a caller that set `id` replaced it and left
|
|
125
|
-
a dangling `aria-controls` — which axe reports as a CRITICAL
|
|
126
|
-
`aria-valid-attr-value` — and a focus restore that lands on
|
|
127
|
-
`<body>`. Both silent. */
|
|
128
|
-
id: sidebarId })] }) }) }));
|
|
129
|
-
};
|
|
130
|
-
exports.SidebarRoot = SidebarRoot;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SidebarRoot=void 0;const jsx_runtime_1=require("react/jsx-runtime");const class_variance_authority_1=require("class-variance-authority");const sidebar_provider_1=require("./sidebar-provider");const utils_1=require("../../../lib/utils");const sheet_1=require("../sheet");const sidebarVariants=(0,class_variance_authority_1.cva)("group/sidebar shadow-sidebar relative flex flex-col transition-[width] duration-300 ease-in-out",{variants:{collapsed:{true:"w-[var(--sidebar-width-collapsed)]",false:"w-[var(--sidebar-width)]"}},defaultVariants:{collapsed:false}});const WIDTH_OVERRIDE=/(?<=^|\s)\[--sidebar-width(?:-collapsed)?:[^\]]+\]/g;function liftWidthOverrides(e){return e?.match(WIDTH_OVERRIDE)?.join(" ")}const SidebarRoot=({className:e,id:o,mobile:s="inline",mobileTitle:l="Navigation",mobileCloseLabel:d="Close",...a})=>{const r=(0,sidebar_provider_1.useSidebar)();const{isCollapsed:i,isMobile:n,openMobile:c,setOpenMobile:u,restoreDrawerFocus:b,sidebarId:t}=r;if(!n||s==="inline"){return(0,jsx_runtime_1.jsx)("nav",{"data-slot":"sidebar-root",className:(0,utils_1.cn)(sidebarVariants({collapsed:i}),e),"data-collapsed":i,...a,id:s==="drawer"?t:o})}return(0,jsx_runtime_1.jsx)(sidebar_provider_1.SidebarContext.Provider,{value:{...r,isCollapsed:false,isDrawer:true},children:(0,jsx_runtime_1.jsx)(sheet_1.Sheet,{open:c,onOpenChange:u,children:(0,jsx_runtime_1.jsxs)(sheet_1.SheetContent,{side:"left",closeLabel:d,className:(0,utils_1.cn)("w-[var(--sidebar-width)] max-w-full gap-0 p-0 max-sm:w-[var(--sidebar-width)] max-sm:p-0",liftWidthOverrides(e)),"aria-describedby":void 0,onCloseAutoFocus:h=>{h.preventDefault();b()},children:[(0,jsx_runtime_1.jsx)(sheet_1.SheetTitle,{className:"sr-only",children:l}),(0,jsx_runtime_1.jsx)("nav",{"data-slot":"sidebar-root","data-mobile":"true",className:(0,utils_1.cn)(sidebarVariants({collapsed:false}),"h-full w-full shadow-none",e),...a,id:t})]})})})};exports.SidebarRoot=SidebarRoot;
|