@stridge/noctis 1.0.0-beta.2 → 1.0.0-beta.3
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Sheet } from "./sheet.js";
|
|
3
|
-
import { createContext, use, useMemo, useReducer, useRef } from "react";
|
|
3
|
+
import { createContext, use, useEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/sheet/sheet-stack.tsx
|
|
6
6
|
/** The empty stack. */
|
|
@@ -111,25 +111,43 @@ function useSheetStackContext() {
|
|
|
111
111
|
if (!manager) throw new Error("useSheetStackContext must be used within <SheetStack>.");
|
|
112
112
|
return manager;
|
|
113
113
|
}
|
|
114
|
-
/**
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
/**
|
|
115
|
+
* One stacked layer. A `manager.push` adds the entry already `open`, so handing that straight to
|
|
116
|
+
* `Sheet.Root` would mount Base UI's dialog in the open state and skip its enter transition — the panel
|
|
117
|
+
* would snap in with no slide. Instead the root mounts closed and flips to the entry's visibility on the
|
|
118
|
+
* first commit, so Base UI runs the closed→open transition and the layer animates in like a
|
|
119
|
+
* trigger-opened sheet. After that the local state tracks `entry.open`, so `pop`/`close` animate out too.
|
|
120
|
+
*/
|
|
121
|
+
function SheetStackLayer({ entry, manager, children }) {
|
|
122
|
+
const [open, setOpen] = useState(false);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
setOpen(entry.open);
|
|
125
|
+
}, [entry.open]);
|
|
119
126
|
return /* @__PURE__ */ jsx(Sheet.Root, {
|
|
120
|
-
open
|
|
121
|
-
onOpenChange: (
|
|
122
|
-
/* v8 ignore next --
|
|
123
|
-
if (!
|
|
127
|
+
open,
|
|
128
|
+
onOpenChange: (next) => {
|
|
129
|
+
/* v8 ignore next -- next===true never fires: layers open via the controlled `open` prop (manager.push), never by Base UI requesting open on a triggerless stack root */
|
|
130
|
+
if (!next) manager.close(entry.key);
|
|
124
131
|
},
|
|
125
|
-
onOpenChangeComplete: (
|
|
126
|
-
if (!
|
|
132
|
+
onOpenChangeComplete: (next) => {
|
|
133
|
+
if (!next) manager.remove(entry.key);
|
|
127
134
|
},
|
|
128
135
|
children: /* @__PURE__ */ jsxs(Sheet.Content, {
|
|
129
136
|
side: entry.side,
|
|
130
137
|
size: entry.size,
|
|
131
|
-
children: [entry.content,
|
|
138
|
+
children: [entry.content, children]
|
|
132
139
|
})
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/** Render layers from `index` down, each nested inside the one before it so the stack reads as depth. */
|
|
143
|
+
function renderLayer(entries, index, manager) {
|
|
144
|
+
if (index >= entries.length) return null;
|
|
145
|
+
const entry = entries[index];
|
|
146
|
+
if (!entry) return null;
|
|
147
|
+
return /* @__PURE__ */ jsx(SheetStackLayer, {
|
|
148
|
+
entry,
|
|
149
|
+
manager,
|
|
150
|
+
children: renderLayer(entries, index + 1, manager)
|
|
133
151
|
}, entry.key);
|
|
134
152
|
}
|
|
135
153
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stridge/noctis",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"culori": "4.0.2",
|
|
70
70
|
"lucide-react": "1.17.0",
|
|
71
71
|
"simple-icons": "16.23.0",
|
|
72
|
-
"@stridge/noctis-design-tokens": "1.0.0-beta.
|
|
73
|
-
"@stridge/noctis-
|
|
74
|
-
"@stridge/noctis-
|
|
72
|
+
"@stridge/noctis-design-tokens": "1.0.0-beta.3",
|
|
73
|
+
"@stridge/noctis-theme-engine": "1.0.0-beta.3",
|
|
74
|
+
"@stridge/noctis-intl": "1.0.0-beta.3"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"react": "19.2.7",
|