@farming-labs/theme 0.2.134 → 0.2.136
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/README.md +5 -0
- package/dist/command-search-dialog.mjs +701 -0
- package/dist/deferred-dialog.mjs +27 -12
- package/dist/docs-command-search.d.mts +2 -8
- package/dist/docs-command-search.mjs +17 -688
- package/package.json +6 -5
- package/styles/bundles/browser-framework.css +125 -9
- package/styles/bundles/shared-framework.css +125 -9
package/dist/deferred-dialog.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { Suspense, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { Component, Suspense, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
|
|
@@ -10,12 +10,27 @@ function DeferredDialog({ open, onOpenChange, children }) {
|
|
|
10
10
|
const [hasOpened, setHasOpened] = useState(open);
|
|
11
11
|
if (open && !hasOpened) setHasOpened(true);
|
|
12
12
|
if (!open && !hasOpened) return null;
|
|
13
|
-
return /* @__PURE__ */ jsx(
|
|
14
|
-
fallback: open ? /* @__PURE__ */ jsx(LoadingDialog, {
|
|
15
|
-
|
|
13
|
+
return /* @__PURE__ */ jsx(DialogBoundary, {
|
|
14
|
+
fallback: open ? /* @__PURE__ */ jsx(LoadingDialog, {
|
|
15
|
+
failed: true,
|
|
16
|
+
onOpenChange
|
|
17
|
+
}) : null,
|
|
18
|
+
children: /* @__PURE__ */ jsx(Suspense, {
|
|
19
|
+
fallback: open ? /* @__PURE__ */ jsx(LoadingDialog, { onOpenChange }) : null,
|
|
20
|
+
children
|
|
21
|
+
})
|
|
16
22
|
});
|
|
17
23
|
}
|
|
18
|
-
|
|
24
|
+
var DialogBoundary = class extends Component {
|
|
25
|
+
state = { failed: false };
|
|
26
|
+
static getDerivedStateFromError() {
|
|
27
|
+
return { failed: true };
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
return this.state.failed ? this.props.fallback : this.props.children;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
function LoadingDialog({ onOpenChange, failed = false }) {
|
|
19
34
|
const closeButton = useRef(null);
|
|
20
35
|
useEffect(() => {
|
|
21
36
|
const previousFocus = document.activeElement;
|
|
@@ -23,7 +38,7 @@ function LoadingDialog({ onOpenChange }) {
|
|
|
23
38
|
document.body.style.overflow = "hidden";
|
|
24
39
|
closeButton.current?.focus();
|
|
25
40
|
const onKeyDown = (event) => {
|
|
26
|
-
if (event.key === "Escape") onOpenChange(false);
|
|
41
|
+
if (event.key === "Escape") onOpenChange(false, "escape");
|
|
27
42
|
if (event.key === "Tab") {
|
|
28
43
|
event.preventDefault();
|
|
29
44
|
closeButton.current?.focus();
|
|
@@ -38,12 +53,12 @@ function LoadingDialog({ onOpenChange }) {
|
|
|
38
53
|
}, [onOpenChange]);
|
|
39
54
|
return createPortal(/* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
40
55
|
className: "fd-ai-overlay",
|
|
41
|
-
onClick: () => onOpenChange(false)
|
|
56
|
+
onClick: () => onOpenChange(false, "overlay")
|
|
42
57
|
}), /* @__PURE__ */ jsx("div", {
|
|
43
58
|
role: "dialog",
|
|
44
59
|
"aria-modal": "true",
|
|
45
|
-
"aria-label": "Loading dialog",
|
|
46
|
-
"aria-busy":
|
|
60
|
+
"aria-label": failed ? "Dialog unavailable" : "Loading dialog",
|
|
61
|
+
"aria-busy": !failed,
|
|
47
62
|
className: "fd-ai-dialog",
|
|
48
63
|
style: {
|
|
49
64
|
left: "50%",
|
|
@@ -54,13 +69,13 @@ function LoadingDialog({ onOpenChange }) {
|
|
|
54
69
|
children: /* @__PURE__ */ jsxs("div", {
|
|
55
70
|
className: "fd-ai-header",
|
|
56
71
|
children: [/* @__PURE__ */ jsx("span", {
|
|
57
|
-
role: "status",
|
|
72
|
+
role: failed ? "alert" : "status",
|
|
58
73
|
className: "fd-ai-header-title",
|
|
59
|
-
children: "Loading…"
|
|
74
|
+
children: failed ? "Unable to load. Reload this page to try again." : "Loading…"
|
|
60
75
|
}), /* @__PURE__ */ jsx("button", {
|
|
61
76
|
ref: closeButton,
|
|
62
77
|
className: "fd-ai-close-btn",
|
|
63
|
-
onClick: () => onOpenChange(false),
|
|
78
|
+
onClick: () => onOpenChange(false, "button"),
|
|
64
79
|
"aria-label": "Close dialog",
|
|
65
80
|
children: "×"
|
|
66
81
|
})]
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/docs-command-search.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Built-in docs search command palette.
|
|
6
|
-
* Intercepts Cmd+K and sidebar search button to provide an advanced
|
|
7
|
-
* fuzzy-search experience. Styled entirely via omni-* CSS classes
|
|
8
|
-
* so each theme provides its own visual variant.
|
|
9
|
-
*/
|
|
10
4
|
declare function DocsCommandSearch({
|
|
11
5
|
api,
|
|
12
6
|
locale,
|
|
@@ -15,6 +9,6 @@ declare function DocsCommandSearch({
|
|
|
15
9
|
api?: string;
|
|
16
10
|
locale?: string;
|
|
17
11
|
analytics?: boolean;
|
|
18
|
-
}):
|
|
12
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
19
13
|
//#endregion
|
|
20
14
|
export { DocsCommandSearch };
|