@netlify/spark-ui 0.0.10 → 0.0.11
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/assets/SearchToggle.css +1 -0
- package/dist/assets/index.css +1 -0
- package/dist/assets/index2.css +1 -0
- package/dist/compat.module-DWiGVdMB.js +175 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/preact/Icon/index.d.ts +7 -0
- package/dist/components/preact/Icon/index.js +125 -0
- package/dist/components/preact/KeyboardKey/index.d.ts +6 -0
- package/dist/components/preact/KeyboardKey/index.js +7 -0
- package/dist/components/preact/Modal/index.d.ts +9 -0
- package/dist/components/preact/Modal/index.js +8 -0
- package/dist/components/preact/SearchModal/components/SearchFooter.d.ts +6 -0
- package/dist/components/preact/SearchModal/components/SearchFooter.js +7 -0
- package/dist/components/preact/SearchModal/components/SearchFooterTip.d.ts +6 -0
- package/dist/components/preact/SearchModal/components/SearchFooterTip.js +7 -0
- package/dist/components/preact/SearchModal/components/SearchHeading.d.ts +6 -0
- package/dist/components/preact/SearchModal/components/SearchHeading.js +5 -0
- package/dist/components/preact/SearchModal/components/SearchInput.d.ts +8 -0
- package/dist/components/preact/SearchModal/components/SearchInput.js +30 -0
- package/dist/components/preact/SearchModal/components/SearchLink.d.ts +11 -0
- package/dist/components/preact/SearchModal/components/SearchLink.js +15 -0
- package/dist/components/preact/SearchModal/components/SearchToggle/SearchToggle.d.ts +10 -0
- package/dist/components/preact/SearchModal/components/SearchToggle/SearchToggle.js +12 -0
- package/dist/components/preact/SearchModal/components/SearchWindow.d.ts +3 -0
- package/dist/components/preact/SearchModal/components/SearchWindow.js +33 -0
- package/dist/components/preact/SearchModal/components/index.js +16 -0
- package/dist/components/preact/SearchModal/hooks/useKeyboardNav.d.ts +14 -0
- package/dist/components/preact/SearchModal/hooks/useKeyboardNav.js +24 -0
- package/dist/components/preact/SearchModal/hooks/useSearch.d.ts +17 -0
- package/dist/components/preact/SearchModal/hooks/useSearch.js +57 -0
- package/dist/components/preact/SearchModal/hooks/useSearchHotkeys.d.ts +13 -0
- package/dist/components/preact/SearchModal/hooks/useSearchHotkeys.js +12 -0
- package/dist/components/preact/SearchModal/hooks/useSearchParams.d.ts +11 -0
- package/dist/components/preact/SearchModal/hooks/useSearchParams.js +11 -0
- package/dist/components/preact/SearchModal/hooks/useSearchToggles.d.ts +12 -0
- package/dist/components/preact/SearchModal/hooks/useSearchToggles.js +15 -0
- package/dist/components/preact/SearchModal/index.d.ts +6 -0
- package/dist/components/preact/SearchModal/index.js +57 -0
- package/dist/components/preact/SearchModal/types/search.types.d.ts +25 -0
- package/dist/components/preact/SearchModal/types/search.types.js +1 -0
- package/dist/components/preact/SearchModal/utils/index.d.ts +2 -0
- package/dist/components/preact/SearchModal/utils/index.js +11 -0
- package/dist/components/preact/index.d.ts +8 -0
- package/dist/components/preact/index.js +16 -0
- package/dist/hooks.module-ExpuRnbo.js +131 -0
- package/dist/jsxRuntime.module-Bzuv3cXw.js +13 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/pluralize.d.ts +1 -0
- package/dist/utils/useClickOutside.d.ts +1 -0
- package/dist/utils/useTimeout.d.ts +4 -0
- package/package.json +19 -4
- package/packages/components/index.ts +8 -8
- package/packages/components/preact/SearchModal/components/index.ts +7 -0
- package/packages/components/{search → preact/SearchModal}/hooks/useSearch.ts +1 -1
- package/packages/components/{search/SearchModal.tsx → preact/SearchModal/index.tsx} +4 -4
- package/packages/components/preact/index.ts +9 -0
- /package/{packages/components/search/components/index.ts → dist/components/preact/SearchModal/components/index.d.ts} +0 -0
- /package/packages/components/{Icon.tsx → preact/Icon/index.tsx} +0 -0
- /package/packages/components/{KeyboardKey → preact/KeyboardKey}/KeyboardKey.css +0 -0
- /package/packages/components/{KeyboardKey/KeyboardKey.tsx → preact/KeyboardKey/index.tsx} +0 -0
- /package/packages/components/{Modal/Modal.tsx → preact/Modal/index.tsx} +0 -0
- /package/packages/components/{search → preact/SearchModal}/components/SearchFooter.tsx +0 -0
- /package/packages/components/{search → preact/SearchModal}/components/SearchFooterTip.tsx +0 -0
- /package/packages/components/{search → preact/SearchModal}/components/SearchHeading.tsx +0 -0
- /package/packages/components/{search → preact/SearchModal}/components/SearchInput.tsx +0 -0
- /package/packages/components/{search → preact/SearchModal}/components/SearchLink.tsx +0 -0
- /package/packages/components/{search → preact/SearchModal}/components/SearchToggle/SearchToggle.css +0 -0
- /package/packages/components/{search → preact/SearchModal}/components/SearchToggle/SearchToggle.tsx +0 -0
- /package/packages/components/{search → preact/SearchModal}/components/SearchWindow.tsx +0 -0
- /package/packages/components/{search → preact/SearchModal}/hooks/useKeyboardNav.ts +0 -0
- /package/packages/components/{search → preact/SearchModal}/hooks/useSearchHotkeys.ts +0 -0
- /package/packages/components/{search → preact/SearchModal}/hooks/useSearchParams.ts +0 -0
- /package/packages/components/{search → preact/SearchModal}/hooks/useSearchToggles.ts +0 -0
- /package/packages/components/{search → preact/SearchModal}/types/search.types.tsx +0 -0
- /package/packages/components/{search → preact/SearchModal}/utils/index.ts +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { y as a } from "../../../../hooks.module-ExpuRnbo.js";
|
|
2
|
+
function l(r, t, o) {
|
|
3
|
+
a(() => {
|
|
4
|
+
const c = (e) => {
|
|
5
|
+
if (t) {
|
|
6
|
+
if (e.key === "Escape") {
|
|
7
|
+
o();
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
11
|
+
e.preventDefault();
|
|
12
|
+
const d = r.current;
|
|
13
|
+
if (!d) return;
|
|
14
|
+
const n = Array.from(d.querySelectorAll("a")), u = n.findIndex((i) => i === document.activeElement), y = e.key === "ArrowDown" ? (u + 1) % n.length : (u - 1 + n.length) % n.length;
|
|
15
|
+
n[y].focus();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return document.addEventListener("keydown", c), () => document.removeEventListener("keydown", c);
|
|
20
|
+
}, [r, t, o]);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
l as useKeyboardNav
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SearchState } from '../types/search.types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook that encapsulates client-side search logic:
|
|
4
|
+
*
|
|
5
|
+
* - Initializes and manages search state (`searchTerm`, `results`, `isLoading`)
|
|
6
|
+
* - Uses a debounced `useTimeout` to delay firing search requests until user input stabilizes
|
|
7
|
+
* - Triggers `submitSearch` when input is empty or 3+ characters, querying `window.pagefind`
|
|
8
|
+
* - Maps and formats raw search results into a consistent shape with title, excerpt, url, and icon
|
|
9
|
+
* - Exposes `setSearchTerm` for live input handling and `submitSearch` for manual triggering
|
|
10
|
+
*/
|
|
11
|
+
export declare function useSearch(): {
|
|
12
|
+
state: SearchState;
|
|
13
|
+
actions: {
|
|
14
|
+
setSearchTerm: (query: string) => void;
|
|
15
|
+
submitSearch: (query: string) => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { A as h, y as p, d as g } from "../../../../hooks.module-ExpuRnbo.js";
|
|
2
|
+
import { getSiteIcon as S } from "../utils/index.js";
|
|
3
|
+
function w(s, r) {
|
|
4
|
+
const t = h(null), c = h("");
|
|
5
|
+
return p(() => () => {
|
|
6
|
+
t.current && clearTimeout(t.current);
|
|
7
|
+
}, []), { reset: () => {
|
|
8
|
+
t.current && clearTimeout(t.current);
|
|
9
|
+
}, run: (e) => {
|
|
10
|
+
c.current = e, t.current = setTimeout(
|
|
11
|
+
() => s(c.current),
|
|
12
|
+
r
|
|
13
|
+
);
|
|
14
|
+
} };
|
|
15
|
+
}
|
|
16
|
+
function y() {
|
|
17
|
+
const [s, r] = g({
|
|
18
|
+
searchTerm: "",
|
|
19
|
+
results: [],
|
|
20
|
+
isLoading: !1
|
|
21
|
+
}), { reset: t, run: c } = w((e) => {
|
|
22
|
+
(e.length > 2 || e.length === 0) && o(e);
|
|
23
|
+
}, 300), o = async (e) => {
|
|
24
|
+
if (!(window != null && window.pagefind)) return;
|
|
25
|
+
r((n) => ({ ...n, isLoading: !0 }));
|
|
26
|
+
const i = await window.pagefind.search(e), d = await Promise.all(
|
|
27
|
+
i.results.map(async (n) => {
|
|
28
|
+
var u, l, m;
|
|
29
|
+
const a = await n.data();
|
|
30
|
+
return {
|
|
31
|
+
icon: S((u = a.meta) == null ? void 0 : u.content_type),
|
|
32
|
+
content_type: (l = a.meta) == null ? void 0 : l.content_type,
|
|
33
|
+
title: (m = a.meta) == null ? void 0 : m.title,
|
|
34
|
+
url: a.url,
|
|
35
|
+
excerpt: a.excerpt
|
|
36
|
+
};
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
r((n) => ({
|
|
40
|
+
...n,
|
|
41
|
+
results: d,
|
|
42
|
+
isLoading: !1
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
state: s,
|
|
47
|
+
actions: {
|
|
48
|
+
setSearchTerm: (e) => {
|
|
49
|
+
r((i) => ({ ...i, searchTerm: e })), t(), c(e);
|
|
50
|
+
},
|
|
51
|
+
submitSearch: o
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
y as useSearch
|
|
57
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook that enables a keyboard shortcut (`⌘ + K` or `Ctrl + K`)
|
|
3
|
+
* to toggle a search UI open or closed.
|
|
4
|
+
*
|
|
5
|
+
* - When the user presses `Meta/Ctrl + K`, it prevents the default browser behavior,
|
|
6
|
+
* stops the event from bubbling up, and either opens or closes the search UI
|
|
7
|
+
* depending on the current `isOpen` state.
|
|
8
|
+
*
|
|
9
|
+
* @param isOpen - Whether the search interface is currently open.
|
|
10
|
+
* @param onOpen - Callback to open the search interface.
|
|
11
|
+
* @param onClose - Callback to close the search interface.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useSearchHotkeys(isOpen: boolean, onOpen: () => void, onClose: () => void): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { y as d } from "../../../../hooks.module-ExpuRnbo.js";
|
|
2
|
+
function m(t, n, o) {
|
|
3
|
+
d(() => {
|
|
4
|
+
const r = (e) => {
|
|
5
|
+
e.metaKey && e.key === "k" && (e.preventDefault(), e.stopImmediatePropagation(), t ? o() : n());
|
|
6
|
+
};
|
|
7
|
+
return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
|
|
8
|
+
}, [t, n, o]);
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
m as useSearchHotkeys
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook that checks the current URL for a `search` query parameter
|
|
3
|
+
* and, if found, updates the search term and opens the search interface.
|
|
4
|
+
*
|
|
5
|
+
* Useful for enabling deep linking to a search view with a pre-filled term,
|
|
6
|
+
* such as when sharing URLs like `?search=netlify`.
|
|
7
|
+
*
|
|
8
|
+
* @param setSearchTerm - Function to update the search input state.
|
|
9
|
+
* @param onOpen - Function to trigger opening of the search interface (e.g., modal or drawer).
|
|
10
|
+
*/
|
|
11
|
+
export declare function useSearchParams(setSearchTerm: (term: string) => void, onOpen: () => void): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { y as e } from "../../../../hooks.module-ExpuRnbo.js";
|
|
2
|
+
function t(a, o) {
|
|
3
|
+
e(() => {
|
|
4
|
+
if (typeof location > "u") return;
|
|
5
|
+
const r = (location == null ? void 0 : location.search) && new URLSearchParams(location.search).get("search");
|
|
6
|
+
r && (a(r), o());
|
|
7
|
+
}, [a, o]);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
t as useSearchParams
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook that attaches click event listeners to all DOM elements
|
|
3
|
+
* with the `[data-ntl-search-toggle]` attribute. When clicked, these elements
|
|
4
|
+
* will trigger the provided `onOpen` callback.
|
|
5
|
+
*
|
|
6
|
+
* This is useful for enabling search toggles via declarative HTML attributes
|
|
7
|
+
* in situations where the search modal or drawer needs to be controlled from
|
|
8
|
+
* multiple points in the DOM.
|
|
9
|
+
*
|
|
10
|
+
* @param onOpen - A function to be called when a toggle element is clicked.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useSearchToggles(onOpen: () => void): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { y as c } from "../../../../hooks.module-ExpuRnbo.js";
|
|
2
|
+
function l(t) {
|
|
3
|
+
c(() => {
|
|
4
|
+
const r = document.querySelectorAll("[data-ntl-search-toggle]");
|
|
5
|
+
if (r.length)
|
|
6
|
+
return r.forEach((e) => {
|
|
7
|
+
e.removeAttribute("disabled"), e.addEventListener("click", t);
|
|
8
|
+
}), () => {
|
|
9
|
+
r.forEach((e) => e.removeEventListener("click", t));
|
|
10
|
+
};
|
|
11
|
+
}, [t]);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
l as useSearchToggles
|
|
15
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { u as e } from "../../../jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
+
import { A as h, y as l, d as f } from "../../../hooks.module-ExpuRnbo.js";
|
|
3
|
+
import p from "../Modal/index.js";
|
|
4
|
+
import S from "./components/SearchFooter.js";
|
|
5
|
+
import u from "./components/SearchFooterTip.js";
|
|
6
|
+
import T from "./components/SearchInput.js";
|
|
7
|
+
import "./components/SearchToggle/SearchToggle.js";
|
|
8
|
+
import y from "./components/SearchWindow.js";
|
|
9
|
+
import i from "../KeyboardKey/index.js";
|
|
10
|
+
import { useSearch as g } from "./hooks/useSearch.js";
|
|
11
|
+
import { useKeyboardNav as v } from "./hooks/useKeyboardNav.js";
|
|
12
|
+
import { useSearchHotkeys as k } from "./hooks/useSearchHotkeys.js";
|
|
13
|
+
import { useSearchParams as N } from "./hooks/useSearchParams.js";
|
|
14
|
+
import { useSearchToggles as w } from "./hooks/useSearchToggles.js";
|
|
15
|
+
import '../../../assets/index2.css';function L(a) {
|
|
16
|
+
const r = h(null);
|
|
17
|
+
return l(() => {
|
|
18
|
+
function t(o) {
|
|
19
|
+
r.current && !r.current.contains(o.target) && a();
|
|
20
|
+
}
|
|
21
|
+
return document.addEventListener("mousedown", t), () => {
|
|
22
|
+
document.removeEventListener("mousedown", t);
|
|
23
|
+
};
|
|
24
|
+
}, [a]), r;
|
|
25
|
+
}
|
|
26
|
+
function W({ children: a }) {
|
|
27
|
+
const { state: r, actions: t } = g(), [o, m] = f(!1), c = () => m(!0), n = () => m(!1), s = h(null), d = L(n);
|
|
28
|
+
return w(c), N(t.setSearchTerm, c), k(o, c, n), v(s, o, n), l(() => {
|
|
29
|
+
s.current && (o ? s.current.showModal() : s.current.close());
|
|
30
|
+
}, [o]), /* @__PURE__ */ e(p, { ref: s, className: "search-modal", children: /* @__PURE__ */ e("div", { ref: d, class: "search-container", children: [
|
|
31
|
+
/* @__PURE__ */ e("form", { class: "search", children: /* @__PURE__ */ e(T, { setSearchTerm: t.setSearchTerm, initialValue: r.searchTerm }) }),
|
|
32
|
+
/* @__PURE__ */ e(
|
|
33
|
+
y,
|
|
34
|
+
{
|
|
35
|
+
searchLoading: r.isLoading,
|
|
36
|
+
searchTerm: r.searchTerm,
|
|
37
|
+
results: r.results,
|
|
38
|
+
children: a
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
/* @__PURE__ */ e(S, { children: [
|
|
42
|
+
/* @__PURE__ */ e(u, { children: [
|
|
43
|
+
/* @__PURE__ */ e(i, { keyNames: ["Esc"] }),
|
|
44
|
+
"to close"
|
|
45
|
+
] }),
|
|
46
|
+
/* @__PURE__ */ e(u, { children: [
|
|
47
|
+
/* @__PURE__ */ e(i, { keyNames: ["Tab"] }),
|
|
48
|
+
/* @__PURE__ */ e("span", { children: "or" }),
|
|
49
|
+
/* @__PURE__ */ e(i, { keyNames: ["↑", "↓"] }),
|
|
50
|
+
"to navigate"
|
|
51
|
+
] })
|
|
52
|
+
] })
|
|
53
|
+
] }) });
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
W as default
|
|
57
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentChildren } from 'preact';
|
|
2
|
+
import { IconName } from '../../Icon';
|
|
3
|
+
export interface ResultProps {
|
|
4
|
+
icon: IconName;
|
|
5
|
+
title: string;
|
|
6
|
+
content_type?: string;
|
|
7
|
+
url: string;
|
|
8
|
+
excerpt?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface SearchWindowProps {
|
|
11
|
+
searchLoading: boolean;
|
|
12
|
+
searchTerm?: string;
|
|
13
|
+
results?: ResultProps[];
|
|
14
|
+
children: ComponentChildren;
|
|
15
|
+
}
|
|
16
|
+
export interface SearchResultsProps {
|
|
17
|
+
searchLoading: boolean;
|
|
18
|
+
searchTerm?: string;
|
|
19
|
+
results?: ResultProps[];
|
|
20
|
+
}
|
|
21
|
+
export interface SearchState {
|
|
22
|
+
searchTerm: string;
|
|
23
|
+
results: ResultProps[];
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as KeyboardKey } from './KeyboardKey';
|
|
2
|
+
export { default as Modal } from './Modal';
|
|
3
|
+
export { default as Icon } from './Icon';
|
|
4
|
+
export { default as SearchLink } from './SearchModal/components/SearchLink';
|
|
5
|
+
export { default as SearchHeading } from './SearchModal/components/SearchHeading';
|
|
6
|
+
export { default as SearchToggle } from './SearchModal/components/SearchToggle/SearchToggle';
|
|
7
|
+
export { default as SearchModal } from './SearchModal';
|
|
8
|
+
export { type IconName } from './Icon';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as o } from "./KeyboardKey/index.js";
|
|
2
|
+
import { default as f } from "./Modal/index.js";
|
|
3
|
+
import { default as d } from "./Icon/index.js";
|
|
4
|
+
import { default as m } from "./SearchModal/components/SearchLink.js";
|
|
5
|
+
import { default as s } from "./SearchModal/components/SearchHeading.js";
|
|
6
|
+
import { default as x } from "./SearchModal/components/SearchToggle/SearchToggle.js";
|
|
7
|
+
import { default as h } from "./SearchModal/index.js";
|
|
8
|
+
export {
|
|
9
|
+
d as Icon,
|
|
10
|
+
o as KeyboardKey,
|
|
11
|
+
f as Modal,
|
|
12
|
+
s as SearchHeading,
|
|
13
|
+
m as SearchLink,
|
|
14
|
+
h as SearchModal,
|
|
15
|
+
x as SearchToggle
|
|
16
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { options as w } from "preact";
|
|
2
|
+
var v, u, H, y, s = 0, C = [], n = w, A = n.__b, F = n.__r, g = n.diffed, k = n.__c, q = n.unmount, T = n.__;
|
|
3
|
+
function d(_, t) {
|
|
4
|
+
n.__h && n.__h(u, _, s || t), s = 0;
|
|
5
|
+
var r = u.__H || (u.__H = { __: [], __h: [] });
|
|
6
|
+
return _ >= r.__.length && r.__.push({}), r.__[_];
|
|
7
|
+
}
|
|
8
|
+
function S(_) {
|
|
9
|
+
return s = 1, x(W, _);
|
|
10
|
+
}
|
|
11
|
+
function x(_, t, r) {
|
|
12
|
+
var o = d(v++, 2);
|
|
13
|
+
if (o.t = _, !o.__c && (o.__ = [r ? r(t) : W(void 0, t), function(c) {
|
|
14
|
+
var e = o.__N ? o.__N[0] : o.__[0], f = o.t(e, c);
|
|
15
|
+
e !== f && (o.__N = [f, o.__[1]], o.__c.setState({}));
|
|
16
|
+
}], o.__c = u, !u.__f)) {
|
|
17
|
+
var a = function(c, e, f) {
|
|
18
|
+
if (!o.__c.__H) return !0;
|
|
19
|
+
var m = o.__c.__H.__.filter(function(i) {
|
|
20
|
+
return !!i.__c;
|
|
21
|
+
});
|
|
22
|
+
if (m.every(function(i) {
|
|
23
|
+
return !i.__N;
|
|
24
|
+
})) return !h || h.call(this, c, e, f);
|
|
25
|
+
var E = o.__c.props !== c;
|
|
26
|
+
return m.forEach(function(i) {
|
|
27
|
+
if (i.__N) {
|
|
28
|
+
var j = i.__[0];
|
|
29
|
+
i.__ = i.__N, i.__N = void 0, j !== i.__[0] && (E = !0);
|
|
30
|
+
}
|
|
31
|
+
}), h && h.call(this, c, e, f) || E;
|
|
32
|
+
};
|
|
33
|
+
u.__f = !0;
|
|
34
|
+
var h = u.shouldComponentUpdate, N = u.componentWillUpdate;
|
|
35
|
+
u.componentWillUpdate = function(c, e, f) {
|
|
36
|
+
if (this.__e) {
|
|
37
|
+
var m = h;
|
|
38
|
+
h = void 0, a(c, e, f), h = m;
|
|
39
|
+
}
|
|
40
|
+
N && N.call(this, c, e, f);
|
|
41
|
+
}, u.shouldComponentUpdate = a;
|
|
42
|
+
}
|
|
43
|
+
return o.__N || o.__;
|
|
44
|
+
}
|
|
45
|
+
function G(_, t) {
|
|
46
|
+
var r = d(v++, 3);
|
|
47
|
+
!n.__s && b(r.__H, t) && (r.__ = _, r.u = t, u.__H.__h.push(r));
|
|
48
|
+
}
|
|
49
|
+
function I(_) {
|
|
50
|
+
return s = 5, z(function() {
|
|
51
|
+
return { current: _ };
|
|
52
|
+
}, []);
|
|
53
|
+
}
|
|
54
|
+
function z(_, t) {
|
|
55
|
+
var r = d(v++, 7);
|
|
56
|
+
return b(r.__H, t) && (r.__ = _(), r.__H = t, r.__h = _), r.__;
|
|
57
|
+
}
|
|
58
|
+
function B() {
|
|
59
|
+
for (var _; _ = C.shift(); ) if (_.__P && _.__H) try {
|
|
60
|
+
_.__H.__h.forEach(l), _.__H.__h.forEach(p), _.__H.__h = [];
|
|
61
|
+
} catch (t) {
|
|
62
|
+
_.__H.__h = [], n.__e(t, _.__v);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
n.__b = function(_) {
|
|
66
|
+
u = null, A && A(_);
|
|
67
|
+
}, n.__ = function(_, t) {
|
|
68
|
+
_ && t.__k && t.__k.__m && (_.__m = t.__k.__m), T && T(_, t);
|
|
69
|
+
}, n.__r = function(_) {
|
|
70
|
+
F && F(_), v = 0;
|
|
71
|
+
var t = (u = _.__c).__H;
|
|
72
|
+
t && (H === u ? (t.__h = [], u.__h = [], t.__.forEach(function(r) {
|
|
73
|
+
r.__N && (r.__ = r.__N), r.u = r.__N = void 0;
|
|
74
|
+
})) : (t.__h.forEach(l), t.__h.forEach(p), t.__h = [], v = 0)), H = u;
|
|
75
|
+
}, n.diffed = function(_) {
|
|
76
|
+
g && g(_);
|
|
77
|
+
var t = _.__c;
|
|
78
|
+
t && t.__H && (t.__H.__h.length && (C.push(t) !== 1 && y === n.requestAnimationFrame || ((y = n.requestAnimationFrame) || D)(B)), t.__H.__.forEach(function(r) {
|
|
79
|
+
r.u && (r.__H = r.u), r.u = void 0;
|
|
80
|
+
})), H = u = null;
|
|
81
|
+
}, n.__c = function(_, t) {
|
|
82
|
+
t.some(function(r) {
|
|
83
|
+
try {
|
|
84
|
+
r.__h.forEach(l), r.__h = r.__h.filter(function(o) {
|
|
85
|
+
return !o.__ || p(o);
|
|
86
|
+
});
|
|
87
|
+
} catch (o) {
|
|
88
|
+
t.some(function(a) {
|
|
89
|
+
a.__h && (a.__h = []);
|
|
90
|
+
}), t = [], n.__e(o, r.__v);
|
|
91
|
+
}
|
|
92
|
+
}), k && k(_, t);
|
|
93
|
+
}, n.unmount = function(_) {
|
|
94
|
+
q && q(_);
|
|
95
|
+
var t, r = _.__c;
|
|
96
|
+
r && r.__H && (r.__H.__.forEach(function(o) {
|
|
97
|
+
try {
|
|
98
|
+
l(o);
|
|
99
|
+
} catch (a) {
|
|
100
|
+
t = a;
|
|
101
|
+
}
|
|
102
|
+
}), r.__H = void 0, t && n.__e(t, r.__v));
|
|
103
|
+
};
|
|
104
|
+
var U = typeof requestAnimationFrame == "function";
|
|
105
|
+
function D(_) {
|
|
106
|
+
var t, r = function() {
|
|
107
|
+
clearTimeout(o), U && cancelAnimationFrame(t), setTimeout(_);
|
|
108
|
+
}, o = setTimeout(r, 100);
|
|
109
|
+
U && (t = requestAnimationFrame(r));
|
|
110
|
+
}
|
|
111
|
+
function l(_) {
|
|
112
|
+
var t = u, r = _.__c;
|
|
113
|
+
typeof r == "function" && (_.__c = void 0, r()), u = t;
|
|
114
|
+
}
|
|
115
|
+
function p(_) {
|
|
116
|
+
var t = u;
|
|
117
|
+
_.__c = _.__(), u = t;
|
|
118
|
+
}
|
|
119
|
+
function b(_, t) {
|
|
120
|
+
return !_ || _.length !== t.length || t.some(function(r, o) {
|
|
121
|
+
return r !== _[o];
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function W(_, t) {
|
|
125
|
+
return typeof t == "function" ? t(_) : t;
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
I as A,
|
|
129
|
+
S as d,
|
|
130
|
+
G as y
|
|
131
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { options as i } from "preact";
|
|
2
|
+
var v = 0;
|
|
3
|
+
function t(f, _, u, c, l, p) {
|
|
4
|
+
_ || (_ = {});
|
|
5
|
+
var n, o, r = _;
|
|
6
|
+
if ("ref" in r) for (o in r = {}, _) o == "ref" ? n = _[o] : r[o] = _[o];
|
|
7
|
+
var e = { type: f, props: r, key: u, ref: n, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --v, __i: -1, __u: 0, __source: l, __self: p };
|
|
8
|
+
if (typeof f == "function" && (n = f.defaultProps)) for (o in n) r[o] === void 0 && (r[o] = n[o]);
|
|
9
|
+
return i.vnode && i.vnode(e), e;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
t as u
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { pluralize } from './pluralize';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pluralize: (count: number, singular: string, plural: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useClickOutside<T extends HTMLElement>(callback: () => void): import('preact').RefObject<T>;
|
package/package.json
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/spark-ui",
|
|
3
3
|
"description": "Assets, design tokens, components, and utilities",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.11",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/components/preact/index.js",
|
|
7
|
+
"types": "dist/components/preact/index.d.ts",
|
|
5
8
|
"scripts": {
|
|
6
9
|
"build:tokens": "npx tz build",
|
|
10
|
+
"build:vite": "vite build",
|
|
7
11
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.astro",
|
|
8
12
|
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx,.astro --fix",
|
|
9
13
|
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,astro,json,css,md,mdx}\" --ignore-path packages/styles/tokens.css",
|
|
10
|
-
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,astro,json,css,md,mdx}\" --ignore-path packages/styles/tokens.css"
|
|
14
|
+
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,astro,json,css,md,mdx}\" --ignore-path packages/styles/tokens.css",
|
|
15
|
+
"prepublishOnly": "npm run build:vite"
|
|
11
16
|
},
|
|
12
17
|
"files": [
|
|
13
18
|
"packages/",
|
|
19
|
+
"dist",
|
|
14
20
|
"README.md"
|
|
15
21
|
],
|
|
16
22
|
"exports": {
|
|
23
|
+
"./preact": "./dist/components/preact/index.js",
|
|
17
24
|
"./logos/*.svg": "./packages/assets/logos/*.svg",
|
|
18
25
|
"./styles/*.css": "./packages/styles/*.css",
|
|
19
26
|
"./components/search": "./packages/components/search/components/index.ts",
|
|
@@ -21,7 +28,12 @@
|
|
|
21
28
|
"./utils": "./packages/utils/index.ts"
|
|
22
29
|
},
|
|
23
30
|
"dependencies": {
|
|
24
|
-
"preact": "^10.
|
|
31
|
+
"@preact/preset-vite": "^2.10.1",
|
|
32
|
+
"glob": "^11.0.1",
|
|
33
|
+
"preact": "^10.26.4",
|
|
34
|
+
"vite": "^6.2.5",
|
|
35
|
+
"vite-plugin-dts": "^4.5.3",
|
|
36
|
+
"vite-plugin-lib-inject-css": "^2.2.1"
|
|
25
37
|
},
|
|
26
38
|
"devDependencies": {
|
|
27
39
|
"@terrazzo/cli": "^0.6.3",
|
|
@@ -39,5 +51,8 @@
|
|
|
39
51
|
"preact": "^10.26.4",
|
|
40
52
|
"prettier": "^3.5.3",
|
|
41
53
|
"prettier-plugin-astro": "^0.14.1"
|
|
42
|
-
}
|
|
54
|
+
},
|
|
55
|
+
"sideEffects": [
|
|
56
|
+
"**/*.css"
|
|
57
|
+
]
|
|
43
58
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { default as KeyboardKey } from './
|
|
2
|
-
export { default as Modal } from './
|
|
3
|
-
export { default as Icon } from './Icon';
|
|
4
|
-
export { default as SearchLink } from './
|
|
5
|
-
export { default as SearchHeading } from './
|
|
6
|
-
export { default as SearchToggle } from './
|
|
7
|
-
export { default as SearchModal } from './
|
|
1
|
+
export { default as KeyboardKey } from './preact/KeyboardKey';
|
|
2
|
+
export { default as Modal } from './preact/Modal';
|
|
3
|
+
export { default as Icon } from './preact/Icon';
|
|
4
|
+
export { default as SearchLink } from './preact/SearchModal/components/SearchLink';
|
|
5
|
+
export { default as SearchHeading } from './preact/SearchModal/components/SearchHeading';
|
|
6
|
+
export { default as SearchToggle } from './preact/SearchModal/components/SearchToggle/SearchToggle';
|
|
7
|
+
export { default as SearchModal } from './preact/SearchModal';
|
|
8
8
|
export { default as Tabs } from './Tabs.astro';
|
|
9
9
|
|
|
10
|
-
export { type IconName } from './Icon';
|
|
10
|
+
export { type IconName } from './preact/Icon';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as SearchFooter } from './SearchFooter';
|
|
2
|
+
export { default as SearchFooterTip } from './SearchFooterTip';
|
|
3
|
+
export { default as SearchHeading } from './SearchHeading';
|
|
4
|
+
export { default as SearchInput } from './SearchInput';
|
|
5
|
+
export { default as SearchLink } from './SearchLink';
|
|
6
|
+
export { default as SearchToggle } from './SearchToggle/SearchToggle';
|
|
7
|
+
export { default as SearchWindow } from './SearchWindow';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'preact/hooks';
|
|
2
2
|
import type { SearchState } from '../types/search.types';
|
|
3
|
-
import { useTimeout } from '
|
|
3
|
+
import { useTimeout } from '../../../../utils/useTimeout';
|
|
4
4
|
import { getSiteIcon } from '../utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { type ComponentChildren } from 'preact';
|
|
2
2
|
import { useState, useEffect, useRef } from 'preact/hooks';
|
|
3
3
|
|
|
4
|
-
import Modal from '../Modal
|
|
4
|
+
import Modal from '../Modal';
|
|
5
5
|
import { SearchFooter, SearchFooterTip, SearchInput, SearchWindow } from './components';
|
|
6
|
-
import KeyboardKey from '
|
|
6
|
+
import KeyboardKey from '../KeyboardKey';
|
|
7
7
|
import { useSearch } from './hooks/useSearch';
|
|
8
8
|
import { useKeyboardNav } from './hooks/useKeyboardNav';
|
|
9
9
|
import { useSearchHotkeys } from './hooks/useSearchHotkeys';
|
|
10
10
|
import { useSearchParams } from './hooks/useSearchParams';
|
|
11
11
|
import { useSearchToggles } from './hooks/useSearchToggles';
|
|
12
|
-
import { useClickOutside } from '
|
|
12
|
+
import { useClickOutside } from '../../../utils/useClickOutside';
|
|
13
13
|
|
|
14
|
-
import '
|
|
14
|
+
import '../../../styles/search.css';
|
|
15
15
|
|
|
16
16
|
interface Props {
|
|
17
17
|
children: ComponentChildren;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as KeyboardKey } from './KeyboardKey';
|
|
2
|
+
export { default as Modal } from './Modal';
|
|
3
|
+
export { default as Icon } from './Icon';
|
|
4
|
+
export { default as SearchLink } from './SearchModal/components/SearchLink';
|
|
5
|
+
export { default as SearchHeading } from './SearchModal/components/SearchHeading';
|
|
6
|
+
export { default as SearchToggle } from './SearchModal/components/SearchToggle/SearchToggle';
|
|
7
|
+
export { default as SearchModal } from './SearchModal';
|
|
8
|
+
|
|
9
|
+
export { type IconName } from './Icon';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/packages/components/{search → preact/SearchModal}/components/SearchToggle/SearchToggle.css
RENAMED
|
File without changes
|
/package/packages/components/{search → preact/SearchModal}/components/SearchToggle/SearchToggle.tsx
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|