prime-ui-kit 0.4.0 → 0.5.1

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.
@@ -27,6 +27,8 @@ function useOverlayPortalLayer() {
27
27
 
28
28
  // src/layout/app-shell/AppShell.tsx
29
29
  import * as React4 from "react";
30
+ import { useLayoutEffect } from "react";
31
+ import { useInRouterContext, useLocation } from "react-router-dom";
30
32
 
31
33
  // src/components/scroll-container/ScrollContainer.tsx
32
34
  import * as React3 from "react";
@@ -100,13 +102,26 @@ function toDataAttributes(input) {
100
102
  return result;
101
103
  }
102
104
 
105
+ // src/internal/mergeRefs.ts
106
+ function mergeRefs(...refs) {
107
+ return (value) => {
108
+ for (const ref of refs) {
109
+ if (ref == null) continue;
110
+ if (typeof ref === "function") {
111
+ ref(value);
112
+ } else {
113
+ ref.current = value;
114
+ }
115
+ }
116
+ };
117
+ }
118
+
103
119
  // src/layout/app-shell/AppShell.module.css
104
120
  var AppShell_default = {
105
121
  layoutRoot: "AppShell_layoutRoot2",
106
122
  layoutMain: "AppShell_layoutMain2",
107
123
  layoutNav: "AppShell_layoutNav2",
108
- layoutMainSurface: "AppShell_layoutMainSurface2",
109
- layoutMainPage: "AppShell_layoutMainPage2"
124
+ layoutMainInset: "AppShell_layoutMainInset2"
110
125
  };
111
126
 
112
127
  // src/layout/app-shell/AppShell.tsx
@@ -128,7 +143,7 @@ function AppShellNav({ className, children, ...rest }) {
128
143
  return /* @__PURE__ */ jsx4("div", { className: cx(AppShell_default.layoutNav, className), "data-layout-region": "nav", ...rest, children });
129
144
  }
130
145
  AppShellNav.displayName = "AppShell.Nav";
131
- var AppShellMain = React4.forwardRef(function AppShellMain2({ variant = "plain", className, children, ...rest }, forwardedRef) {
146
+ var AppShellMain = React4.forwardRef(function AppShellMain2({ className, children, ...rest }, forwardedRef) {
132
147
  return /* @__PURE__ */ jsx4(
133
148
  ScrollContainer,
134
149
  {
@@ -136,12 +151,7 @@ var AppShellMain = React4.forwardRef(function AppShellMain2({ variant = "plain",
136
151
  ref: forwardedRef,
137
152
  axis: "vertical",
138
153
  overscrollBehavior: "contain",
139
- className: cx(
140
- AppShell_default.layoutMain,
141
- variant === "surface" && AppShell_default.layoutMainSurface,
142
- variant === "page" && AppShell_default.layoutMainPage,
143
- className
144
- ),
154
+ className: cx(AppShell_default.layoutMain, className),
145
155
  "data-layout-region": "main",
146
156
  ...rest,
147
157
  children
@@ -149,8 +159,35 @@ var AppShellMain = React4.forwardRef(function AppShellMain2({ variant = "plain",
149
159
  );
150
160
  });
151
161
  AppShellMain.displayName = "AppShell.Main";
162
+ var AppShellMainInset = React4.forwardRef(
163
+ function AppShellMainInset2({ className, children, ...rest }, forwardedRef) {
164
+ return /* @__PURE__ */ jsx4(
165
+ "div",
166
+ {
167
+ ref: forwardedRef,
168
+ className: cx(AppShell_default.layoutMainInset, className),
169
+ "data-app-shell-main-inset": "",
170
+ ...rest,
171
+ children
172
+ }
173
+ );
174
+ }
175
+ );
176
+ AppShellMainInset.displayName = "AppShell.MainInset";
177
+ function AppShellMainRouteScrollReset({
178
+ mainRef
179
+ }) {
180
+ const { pathname } = useLocation();
181
+ useLayoutEffect(() => {
182
+ mainRef.current?.scrollTo(0, 0);
183
+ }, [pathname]);
184
+ return null;
185
+ }
152
186
  var AppShellTemplate = React4.forwardRef(
153
187
  function AppShellTemplate2({ fillViewport, className, nav, children, navProps, mainProps, ...rootRest }, forwardedRef) {
188
+ const mainElementRef = React4.useRef(null);
189
+ const setMainRef = React4.useMemo(() => mergeRefs(mainElementRef, forwardedRef), [forwardedRef]);
190
+ const inRouter = useInRouterContext();
154
191
  return /* @__PURE__ */ jsxs(
155
192
  AppShellRoot,
156
193
  {
@@ -160,7 +197,10 @@ var AppShellTemplate = React4.forwardRef(
160
197
  "data-layout-template": "app",
161
198
  children: [
162
199
  /* @__PURE__ */ jsx4(AppShellNav, { ...navProps, children: nav }),
163
- /* @__PURE__ */ jsx4(AppShellMain, { ref: forwardedRef, ...mainProps, children })
200
+ /* @__PURE__ */ jsxs(AppShellMain, { ref: setMainRef, ...mainProps, children: [
201
+ /* @__PURE__ */ jsx4(AppShellMainInset, { children }),
202
+ inRouter ? /* @__PURE__ */ jsx4(AppShellMainRouteScrollReset, { mainRef: mainElementRef }) : null
203
+ ] })
164
204
  ]
165
205
  }
166
206
  );
@@ -171,6 +211,7 @@ var AppShell = {
171
211
  Root: AppShellRoot,
172
212
  Nav: AppShellNav,
173
213
  Main: AppShellMain,
214
+ MainInset: AppShellMainInset,
174
215
  Template: AppShellTemplate
175
216
  };
176
217
 
@@ -178,9 +219,9 @@ var AppShell = {
178
219
  import {
179
220
  ChevronsUpDown,
180
221
  PanelLeftClose,
181
- PanelLeftOpen as PanelLeftOpen2,
222
+ PanelLeftOpen,
182
223
  PanelRightClose,
183
- PanelRightOpen as PanelRightOpen2
224
+ PanelRightOpen
184
225
  } from "lucide-react";
185
226
  import * as React17 from "react";
186
227
  import { NavLink } from "react-router-dom";
@@ -493,22 +534,6 @@ var Typography = { Root: TypographyRoot };
493
534
 
494
535
  // src/internal/slot.tsx
495
536
  import * as React12 from "react";
496
-
497
- // src/internal/mergeRefs.ts
498
- function mergeRefs(...refs) {
499
- return (value) => {
500
- for (const ref of refs) {
501
- if (ref == null) continue;
502
- if (typeof ref === "function") {
503
- ref(value);
504
- } else {
505
- ref.current = value;
506
- }
507
- }
508
- };
509
- }
510
-
511
- // src/internal/slot.tsx
512
537
  import { Fragment, jsx as jsx8 } from "react/jsx-runtime";
513
538
  function mergeProps(slotProps, childProps) {
514
539
  const merged = { ...slotProps };
@@ -560,6 +585,7 @@ var Sidebar_default = {
560
585
  navArea: "Sidebar_navArea2",
561
586
  backdrop: "Sidebar_backdrop2",
562
587
  navPanel: "Sidebar_navPanel2",
588
+ navPanelSurface: "Sidebar_navPanelSurface2",
563
589
  header: "Sidebar_header2",
564
590
  headerRow: "Sidebar_headerRow2",
565
591
  headerMain: "Sidebar_headerMain2",
@@ -597,15 +623,12 @@ var Sidebar_default = {
597
623
  navCategoryTrigger: "Sidebar_navCategoryTrigger2",
598
624
  navCategoryLabel: "Sidebar_navCategoryLabel2",
599
625
  navCategoryCount: "Sidebar_navCategoryCount2",
600
- navCategoryPanel: "Sidebar_navCategoryPanel2",
601
- floatingToggle: "Sidebar_floatingToggle2"
626
+ navCategoryPanel: "Sidebar_navCategoryPanel2"
602
627
  };
603
628
 
604
629
  // src/layout/sidebar/SidebarRoot.tsx
605
630
  import { animate, useMotionValue, useMotionValueEvent, useReducedMotion } from "framer-motion";
606
- import { PanelLeftOpen, PanelRightOpen } from "lucide-react";
607
631
  import * as React16 from "react";
608
- import { createPortal as createPortal2 } from "react-dom";
609
632
 
610
633
  // src/hooks/useEscapeKey.ts
611
634
  import * as React13 from "react";
@@ -870,21 +893,11 @@ var SidebarRoot = React16.forwardRef(function SidebarRoot2({
870
893
  if (root == null) return;
871
894
  root.style.setProperty("--sb-progress", value.toString());
872
895
  });
873
- const [floatingPortalReady, setFloatingPortalReady] = React16.useState(false);
874
- React16.useLayoutEffect(() => {
875
- setFloatingPortalReady(true);
876
- }, []);
877
- const showFloatingToggle = Boolean(responsive) && isMobile && !openState;
878
896
  const closeMobile = React16.useCallback(() => {
879
897
  setLayoutState("hidden");
880
898
  }, [setLayoutState]);
881
899
  const navAreaRef = useOverlayModal(mobileOpen, closeMobile);
882
900
  const navPanelId = React16.useId();
883
- const floatingToggleLabel = side === "left" ? "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u0430\u0439\u0434\u0431\u0430\u0440" : "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u0430\u0439\u0434\u0431\u0430\u0440 \u0441\u043F\u0440\u0430\u0432\u0430";
884
- const floatingToggleIcon = side === "left" ? /* @__PURE__ */ jsx9(PanelLeftOpen, { size: "1em" }) : /* @__PURE__ */ jsx9(PanelRightOpen, { size: "1em" });
885
- const onFloatingToggleClick = React16.useCallback(() => {
886
- setLayoutState("expanded");
887
- }, [setLayoutState]);
888
901
  const contextValue = React16.useMemo(
889
902
  () => ({
890
903
  size,
@@ -901,7 +914,7 @@ var SidebarRoot = React16.forwardRef(function SidebarRoot2({
901
914
  }),
902
915
  [isMobile, layoutState, navPanelId, openState, setOpen, setState, side, size, toggleOpen]
903
916
  );
904
- return /* @__PURE__ */ jsx9(SidebarProvider, { value: contextValue, children: /* @__PURE__ */ jsxs2(
917
+ return /* @__PURE__ */ jsx9(SidebarProvider, { value: contextValue, children: /* @__PURE__ */ jsx9(
905
918
  "aside",
906
919
  {
907
920
  ...rest,
@@ -920,37 +933,20 @@ var SidebarRoot = React16.forwardRef(function SidebarRoot2({
920
933
  "sidebar-mode": layoutState,
921
934
  "sidebar-root": true
922
935
  }),
923
- children: [
924
- /* @__PURE__ */ jsxs2("div", { ref: navAreaRef, className: Sidebar_default.navArea, children: [
925
- /* @__PURE__ */ jsx9(
926
- "button",
927
- {
928
- type: "button",
929
- className: Sidebar_default.backdrop,
930
- "aria-label": "\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0441\u0430\u0439\u0434\u0431\u0430\u0440",
931
- onClick: closeMobile,
932
- tabIndex: mobileOpen ? 0 : -1,
933
- "aria-hidden": mobileOpen ? void 0 : true
934
- }
935
- ),
936
- children
937
- ] }),
938
- showFloatingToggle && floatingPortalReady && typeof document !== "undefined" ? createPortal2(
939
- /* @__PURE__ */ jsx9(
940
- "button",
941
- {
942
- type: "button",
943
- className: Sidebar_default.floatingToggle,
944
- onClick: onFloatingToggleClick,
945
- "aria-label": floatingToggleLabel,
946
- "aria-controls": navPanelId,
947
- "data-side": side,
948
- children: /* @__PURE__ */ jsx9("span", { className: Sidebar_default.menuIcon, "aria-hidden": "true", children: floatingToggleIcon })
949
- }
950
- ),
951
- document.body
952
- ) : null
953
- ]
936
+ children: /* @__PURE__ */ jsxs2("div", { ref: navAreaRef, className: Sidebar_default.navArea, children: [
937
+ /* @__PURE__ */ jsx9(
938
+ "button",
939
+ {
940
+ type: "button",
941
+ className: Sidebar_default.backdrop,
942
+ "aria-label": "\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0441\u0430\u0439\u0434\u0431\u0430\u0440",
943
+ onClick: closeMobile,
944
+ tabIndex: mobileOpen ? 0 : -1,
945
+ "aria-hidden": mobileOpen ? void 0 : true
946
+ }
947
+ ),
948
+ children
949
+ ] })
954
950
  }
955
951
  ) });
956
952
  });
@@ -961,9 +957,9 @@ import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
961
957
  var SidebarComposedRoot = SidebarRoot;
962
958
  function iconForToggle(state, side) {
963
959
  if (side === "left") {
964
- return state === "hidden" ? /* @__PURE__ */ jsx10(PanelLeftOpen2, { size: "1em" }) : /* @__PURE__ */ jsx10(PanelLeftClose, { size: "1em" });
960
+ return state === "hidden" ? /* @__PURE__ */ jsx10(PanelLeftOpen, { size: "1em" }) : /* @__PURE__ */ jsx10(PanelLeftClose, { size: "1em" });
965
961
  }
966
- return state === "hidden" ? /* @__PURE__ */ jsx10(PanelRightOpen2, { size: "1em" }) : /* @__PURE__ */ jsx10(PanelRightClose, { size: "1em" });
962
+ return state === "hidden" ? /* @__PURE__ */ jsx10(PanelRightOpen, { size: "1em" }) : /* @__PURE__ */ jsx10(PanelRightClose, { size: "1em" });
967
963
  }
968
964
  var SidebarToggleButton = React17.forwardRef(
969
965
  ({
@@ -1005,19 +1001,18 @@ function SidebarNavPanel({
1005
1001
  children,
1006
1002
  ...rest
1007
1003
  }) {
1008
- const { navPanelId, isMobile, state } = useSidebarContext();
1009
- const showEdgeToggle = showToggle && !(isMobile && state === "hidden");
1010
- return /* @__PURE__ */ jsxs3(
1004
+ const { navPanelId } = useSidebarContext();
1005
+ return /* @__PURE__ */ jsx10(
1011
1006
  "nav",
1012
1007
  {
1013
1008
  ...rest,
1014
1009
  id: id ?? navPanelId,
1015
1010
  className: cx(Sidebar_default.navPanel, className),
1016
1011
  "aria-label": rest["aria-label"] ?? "Sidebar navigation",
1017
- children: [
1012
+ children: /* @__PURE__ */ jsxs3("div", { className: Sidebar_default.navPanelSurface, children: [
1018
1013
  children,
1019
- showEdgeToggle ? /* @__PURE__ */ jsx10(SidebarToggleButton, { placement: "edge" }) : null
1020
- ]
1014
+ showToggle ? /* @__PURE__ */ jsx10(SidebarToggleButton, { placement: "edge" }) : null
1015
+ ] })
1021
1016
  }
1022
1017
  );
1023
1018
  }