prime-ui-kit 0.4.1 → 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,11 +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
- layoutNav: "AppShell_layoutNav2"
123
+ layoutNav: "AppShell_layoutNav2",
124
+ layoutMainInset: "AppShell_layoutMainInset2"
108
125
  };
109
126
 
110
127
  // src/layout/app-shell/AppShell.tsx
@@ -142,8 +159,35 @@ var AppShellMain = React4.forwardRef(function AppShellMain2({ className, childre
142
159
  );
143
160
  });
144
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
+ }
145
186
  var AppShellTemplate = React4.forwardRef(
146
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();
147
191
  return /* @__PURE__ */ jsxs(
148
192
  AppShellRoot,
149
193
  {
@@ -153,7 +197,10 @@ var AppShellTemplate = React4.forwardRef(
153
197
  "data-layout-template": "app",
154
198
  children: [
155
199
  /* @__PURE__ */ jsx4(AppShellNav, { ...navProps, children: nav }),
156
- /* @__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
+ ] })
157
204
  ]
158
205
  }
159
206
  );
@@ -164,6 +211,7 @@ var AppShell = {
164
211
  Root: AppShellRoot,
165
212
  Nav: AppShellNav,
166
213
  Main: AppShellMain,
214
+ MainInset: AppShellMainInset,
167
215
  Template: AppShellTemplate
168
216
  };
169
217
 
@@ -486,22 +534,6 @@ var Typography = { Root: TypographyRoot };
486
534
 
487
535
  // src/internal/slot.tsx
488
536
  import * as React12 from "react";
489
-
490
- // src/internal/mergeRefs.ts
491
- function mergeRefs(...refs) {
492
- return (value) => {
493
- for (const ref of refs) {
494
- if (ref == null) continue;
495
- if (typeof ref === "function") {
496
- ref(value);
497
- } else {
498
- ref.current = value;
499
- }
500
- }
501
- };
502
- }
503
-
504
- // src/internal/slot.tsx
505
537
  import { Fragment, jsx as jsx8 } from "react/jsx-runtime";
506
538
  function mergeProps(slotProps, childProps) {
507
539
  const merged = { ...slotProps };