@brainfish-ai/components 0.26.0 → 0.26.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.
- package/dist/chat-search.d.ts +14 -1
- package/dist/esm/chunks/ChatSearch.Cqo4WF3n.js +95 -0
- package/dist/esm/chunks/ChatSearch.Cqo4WF3n.js.map +1 -0
- package/dist/esm/chunks/Conversation.UZ5rx7_0.js +22 -0
- package/dist/esm/chunks/{Conversation.BriXFYqU.js.map → Conversation.UZ5rx7_0.js.map} +1 -1
- package/dist/esm/chunks/FormattedMessage.D9xA6QsH.js +23 -0
- package/dist/esm/chunks/FormattedMessage.D9xA6QsH.js.map +1 -0
- package/dist/esm/chunks/MermaidDiagram.PRgXQ5Yh.js +2 -0
- package/dist/esm/chunks/{MermaidDiagram.xQ0CVFOI.js.map → MermaidDiagram.PRgXQ5Yh.js.map} +1 -1
- package/dist/esm/chunks/_commonjsHelpers.lGe4XDVY.js +2 -0
- package/dist/esm/chunks/_commonjsHelpers.lGe4XDVY.js.map +1 -0
- package/dist/esm/chunks/button.BYc5d6AZ.js +3 -0
- package/dist/esm/chunks/{button.DQL6gCAt.js.map → button.BYc5d6AZ.js.map} +1 -1
- package/dist/esm/chunks/chart.BDL2tf-S.js +10 -0
- package/dist/esm/chunks/{chart.4ZbtBMmR.js.map → chart.BDL2tf-S.js.map} +1 -1
- package/dist/esm/chunks/chat-logo.CqPppEb9.js +3 -0
- package/dist/esm/chunks/chat-logo.CqPppEb9.js.map +1 -0
- package/dist/esm/chunks/combobox.CxaWbDm9.js +6 -0
- package/dist/esm/chunks/{combobox.CJKym3Z1.js.map → combobox.CxaWbDm9.js.map} +1 -1
- package/dist/esm/chunks/dark.DuW7JuAk.js +2 -0
- package/dist/esm/chunks/{dark.Cq2RCgy4.js.map → dark.DuW7JuAk.js.map} +1 -1
- package/dist/esm/chunks/data-table.CJOR-1Kf.js +5 -0
- package/dist/esm/chunks/{data-table.DbcAYxMY.js.map → data-table.CJOR-1Kf.js.map} +1 -1
- package/dist/esm/chunks/date-picker.Bhplnvxn.js +4 -0
- package/dist/esm/chunks/{date-picker._cBTpdEK.js.map → date-picker.Bhplnvxn.js.map} +1 -1
- package/dist/esm/chunks/extends.DPdBf6DS.js +2 -0
- package/dist/esm/chunks/extends.DPdBf6DS.js.map +1 -0
- package/dist/esm/chunks/feature-flags.DOcVlPHk.js +3 -0
- package/dist/esm/chunks/{feature-flags.DeDEcnd1.js.map → feature-flags.DOcVlPHk.js.map} +1 -1
- package/dist/esm/chunks/feedback.BXKvlNz1.js +13 -0
- package/dist/esm/chunks/{feedback.W2OzN-5r.js.map → feedback.BXKvlNz1.js.map} +1 -1
- package/dist/esm/chunks/file-upload-status.4ukNFyi2.js +8 -0
- package/dist/esm/chunks/{file-upload-status.DP2iuttI.js.map → file-upload-status.4ukNFyi2.js.map} +1 -1
- package/dist/esm/chunks/filters.ita3UAnO.js +22 -0
- package/dist/esm/chunks/{filters.-7vSLEQ2.js.map → filters.ita3UAnO.js.map} +1 -1
- package/dist/esm/chunks/font-picker.BwEWBowG.js +6 -0
- package/dist/esm/chunks/{font-picker.DisEoE8a.js.map → font-picker.BwEWBowG.js.map} +1 -1
- package/dist/esm/chunks/formatDate.D2xEZm8f.js +2 -0
- package/dist/esm/chunks/{formatDate.CWN6IFKq.js.map → formatDate.D2xEZm8f.js.map} +1 -1
- package/dist/esm/chunks/formatNumber.DhVn228t.js +2 -0
- package/dist/esm/chunks/{formatNumber.Bm2k8QrT.js.map → formatNumber.DhVn228t.js.map} +1 -1
- package/dist/esm/chunks/generating-star.BN9p_FDu.js +7 -0
- package/dist/esm/chunks/generating-star.BN9p_FDu.js.map +1 -0
- package/dist/esm/chunks/header-nav.B4IJjted.js +10 -0
- package/dist/esm/chunks/{header-nav.b4hvOsKc.js.map → header-nav.B4IJjted.js.map} +1 -1
- package/dist/esm/chunks/header-pane.C1RWesOW.js +20 -0
- package/dist/esm/chunks/{header-pane.BFXHXxVn.js.map → header-pane.C1RWesOW.js.map} +1 -1
- package/dist/esm/chunks/hooks.BQTKhHSv.js +2 -0
- package/dist/esm/chunks/hooks.BQTKhHSv.js.map +1 -0
- package/dist/esm/chunks/index.uF4ME3WQ.js +4 -0
- package/dist/esm/chunks/{index.BqibIWDw.js.map → index.uF4ME3WQ.js.map} +1 -1
- package/dist/esm/chunks/input-with-tags.DrDDPxse.js +5 -0
- package/dist/esm/chunks/{input-with-tags.tg2nhPFv.js.map → input-with-tags.DrDDPxse.js.map} +1 -1
- package/dist/esm/chunks/logo.CketsPBx.js +5 -0
- package/dist/esm/chunks/{logo.D5BMN6Db.js.map → logo.CketsPBx.js.map} +1 -1
- package/dist/esm/chunks/primary.CMQbo1GJ.js +2 -0
- package/dist/esm/chunks/{primary.CtiRZbqq.js.map → primary.CMQbo1GJ.js.map} +1 -1
- package/dist/esm/chunks/review-list.qvxeqG9l.js +6 -0
- package/dist/esm/chunks/{review-list.BtSnfpSc.js.map → review-list.qvxeqG9l.js.map} +1 -1
- package/dist/esm/chunks/sidebar.IcJADYLR.js +25 -0
- package/dist/esm/chunks/sidebar.IcJADYLR.js.map +1 -0
- package/dist/esm/chunks/simpleSelect.DK1qZSXM.js +3 -0
- package/dist/esm/chunks/{simpleSelect.B1rktKkt.js.map → simpleSelect.DK1qZSXM.js.map} +1 -1
- package/dist/esm/chunks/status-badge.C-jt7Zs2.js +3 -0
- package/dist/esm/chunks/{status-badge.eFJ1PYeb.js.map → status-badge.C-jt7Zs2.js.map} +1 -1
- package/dist/esm/chunks/trend-value.BPBDBsk2.js +3 -0
- package/dist/esm/chunks/{trend-value.COSukPwk.js.map → trend-value.BPBDBsk2.js.map} +1 -1
- package/dist/esm/chunks/two-level-combobox.Bv2OQgjh.js +8 -0
- package/dist/esm/chunks/{two-level-combobox.BXs2z9u5.js.map → two-level-combobox.Bv2OQgjh.js.map} +1 -1
- package/dist/esm/chunks/useChartDateFormatters.Dx2h5AAm.js +2 -0
- package/dist/esm/chunks/{useChartDateFormatters.DS9ASgFO.js.map → useChartDateFormatters.Dx2h5AAm.js.map} +1 -1
- package/dist/esm/chunks/utils.C6Qu-kwd.js +2 -0
- package/dist/esm/chunks/{utils.Cwtlq8dh.js.map → utils.C6Qu-kwd.js.map} +1 -1
- package/dist/esm/colors.js +1 -169
- package/dist/esm/colors.js.map +1 -1
- package/dist/esm/components/article-suggestions-banner.js +4 -53
- package/dist/esm/components/article-suggestions-banner.js.map +1 -1
- package/dist/esm/components/articles-coverage.js +4 -116
- package/dist/esm/components/articles-coverage.js.map +1 -1
- package/dist/esm/components/articles-updated.js +4 -74
- package/dist/esm/components/articles-updated.js.map +1 -1
- package/dist/esm/components/breadcrumbs.js +3 -13
- package/dist/esm/components/breadcrumbs.js.map +1 -1
- package/dist/esm/components/chart-area-linear.js +6 -66
- package/dist/esm/components/chart-area-linear.js.map +1 -1
- package/dist/esm/components/chart-radial-stacked.js +2 -48
- package/dist/esm/components/chart-radial-stacked.js.map +1 -1
- package/dist/esm/components/chat-search.js +1 -1
- package/dist/esm/components/combobox.js +1 -1
- package/dist/esm/components/confirm-dialog.js +2 -47
- package/dist/esm/components/confirm-dialog.js.map +1 -1
- package/dist/esm/components/conversation.js +1 -1
- package/dist/esm/components/convos.js +27 -607
- package/dist/esm/components/convos.js.map +1 -1
- package/dist/esm/components/data-table.js +1 -1
- package/dist/esm/components/date-picker.js +1 -1
- package/dist/esm/components/discoveries-created.js +4 -64
- package/dist/esm/components/discoveries-created.js.map +1 -1
- package/dist/esm/components/feedback.js +1 -1
- package/dist/esm/components/file-upload.js +1 -1
- package/dist/esm/components/filter.js +1 -1
- package/dist/esm/components/font-picker.js +1 -1
- package/dist/esm/components/generating-star.js +1 -1
- package/dist/esm/components/input-with-tags.js +1 -1
- package/dist/esm/components/logo.js +1 -1
- package/dist/esm/components/markdown.js +1 -2
- package/dist/esm/components/markdown.js.map +1 -1
- package/dist/esm/components/metric-card.js +3 -29
- package/dist/esm/components/metric-card.js.map +1 -1
- package/dist/esm/components/select.js +1 -1
- package/dist/esm/components/trend-value.js +1 -1
- package/dist/esm/components/two-level-combobox.js +1 -1
- package/dist/esm/components/ui/accordion.js +7 -46
- package/dist/esm/components/ui/accordion.js.map +1 -1
- package/dist/esm/components/ui/alert-dialog.js +3 -114
- package/dist/esm/components/ui/alert-dialog.js.map +1 -1
- package/dist/esm/components/ui/alert.js +4 -103
- package/dist/esm/components/ui/alert.js.map +1 -1
- package/dist/esm/components/ui/avatar.js +7 -89
- package/dist/esm/components/ui/avatar.js.map +1 -1
- package/dist/esm/components/ui/badge.js +2 -26
- package/dist/esm/components/ui/badge.js.map +1 -1
- package/dist/esm/components/ui/breadcrumb.js +4 -60
- package/dist/esm/components/ui/breadcrumb.js.map +1 -1
- package/dist/esm/components/ui/button-group.js +4 -88
- package/dist/esm/components/ui/button-group.js.map +1 -1
- package/dist/esm/components/ui/button.js +1 -5
- package/dist/esm/components/ui/button.js.map +1 -1
- package/dist/esm/components/ui/calendar.js +2 -20
- package/dist/esm/components/ui/calendar.js.map +1 -1
- package/dist/esm/components/ui/card.js +1 -55
- package/dist/esm/components/ui/card.js.map +1 -1
- package/dist/esm/components/ui/collapsible.js +1 -33
- package/dist/esm/components/ui/collapsible.js.map +1 -1
- package/dist/esm/components/ui/combobox.js +1 -1
- package/dist/esm/components/ui/command.js +2 -79
- package/dist/esm/components/ui/command.js.map +1 -1
- package/dist/esm/components/ui/dialog.js +4 -60
- package/dist/esm/components/ui/dialog.js.map +1 -1
- package/dist/esm/components/ui/div-button.js +2 -61
- package/dist/esm/components/ui/div-button.js.map +1 -1
- package/dist/esm/components/ui/dropdown-menu.js +3 -114
- package/dist/esm/components/ui/dropdown-menu.js.map +1 -1
- package/dist/esm/components/ui/icon.js +2 -25
- package/dist/esm/components/ui/icon.js.map +1 -1
- package/dist/esm/components/ui/input.js +4 -47
- package/dist/esm/components/ui/input.js.map +1 -1
- package/dist/esm/components/ui/item.js +11 -140
- package/dist/esm/components/ui/item.js.map +1 -1
- package/dist/esm/components/ui/label.js +1 -19
- package/dist/esm/components/ui/label.js.map +1 -1
- package/dist/esm/components/ui/popover.js +1 -31
- package/dist/esm/components/ui/popover.js.map +1 -1
- package/dist/esm/components/ui/progress.js +2 -22
- package/dist/esm/components/ui/progress.js.map +1 -1
- package/dist/esm/components/ui/scroll-area.js +2 -32
- package/dist/esm/components/ui/scroll-area.js.map +1 -1
- package/dist/esm/components/ui/select.js +5 -66
- package/dist/esm/components/ui/select.js.map +1 -1
- package/dist/esm/components/ui/separator.js +1 -23
- package/dist/esm/components/ui/separator.js.map +1 -1
- package/dist/esm/components/ui/sheet.js +3 -62
- package/dist/esm/components/ui/sheet.js.map +1 -1
- package/dist/esm/components/ui/spinner.js +2 -17
- package/dist/esm/components/ui/spinner.js.map +1 -1
- package/dist/esm/components/ui/switch.js +2 -26
- package/dist/esm/components/ui/switch.js.map +1 -1
- package/dist/esm/components/ui/table.js +1 -82
- package/dist/esm/components/ui/table.js.map +1 -1
- package/dist/esm/components/ui/textarea.js +1 -33
- package/dist/esm/components/ui/textarea.js.map +1 -1
- package/dist/esm/components/ui/tooltip.js +3 -31
- package/dist/esm/components/ui/tooltip.js.map +1 -1
- package/dist/esm/global.css +1 -1
- package/dist/esm/index.js +1 -53
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layouts/full-layout.js +1 -1
- package/dist/esm/layouts/header-nav.js +1 -1
- package/dist/esm/layouts/sidebar.js +1 -1
- package/dist/esm/logos/microsoft-logo.js +6 -66
- package/dist/esm/logos/microsoft-logo.js.map +1 -1
- package/dist/esm/logos/microsoft-teams-logo.js +12 -112
- package/dist/esm/logos/microsoft-teams-logo.js.map +1 -1
- package/dist/esm/logos/slack-logo.js +3 -39
- package/dist/esm/logos/slack-logo.js.map +1 -1
- package/dist/esm/scenes/knowledge-review.js +17 -380
- package/dist/esm/scenes/knowledge-review.js.map +1 -1
- package/dist/esm/tailwind.preset.js +1 -1526
- package/dist/esm/tailwind.preset.js.map +1 -1
- package/dist/index.d.ts +22 -1
- package/dist/logo.d.ts +9 -0
- package/dist/stats.html +47 -46
- package/package.json +17 -18
- package/tailwind.preset.ts +1 -0
- package/dist/esm/chunks/ChatSearch.CeQrTOVx.js +0 -6825
- package/dist/esm/chunks/ChatSearch.CeQrTOVx.js.map +0 -1
- package/dist/esm/chunks/Conversation.BriXFYqU.js +0 -831
- package/dist/esm/chunks/FormattedMessage.CRbM-hF6.js +0 -39715
- package/dist/esm/chunks/FormattedMessage.CRbM-hF6.js.map +0 -1
- package/dist/esm/chunks/MermaidDiagram.xQ0CVFOI.js +0 -50
- package/dist/esm/chunks/_commonjsHelpers.BFTU3MAI.js +0 -8
- package/dist/esm/chunks/_commonjsHelpers.BFTU3MAI.js.map +0 -1
- package/dist/esm/chunks/button.DQL6gCAt.js +0 -48
- package/dist/esm/chunks/chart.4ZbtBMmR.js +0 -199
- package/dist/esm/chunks/combobox.CJKym3Z1.js +0 -95
- package/dist/esm/chunks/dark.Cq2RCgy4.js +0 -18
- package/dist/esm/chunks/data-table.DbcAYxMY.js +0 -102
- package/dist/esm/chunks/date-picker._cBTpdEK.js +0 -26
- package/dist/esm/chunks/extends.mO86zOh3.js +0 -12
- package/dist/esm/chunks/extends.mO86zOh3.js.map +0 -1
- package/dist/esm/chunks/feature-flags.DeDEcnd1.js +0 -22
- package/dist/esm/chunks/feedback.W2OzN-5r.js +0 -214
- package/dist/esm/chunks/file-upload-status.DP2iuttI.js +0 -141
- package/dist/esm/chunks/filters.-7vSLEQ2.js +0 -565
- package/dist/esm/chunks/font-picker.DisEoE8a.js +0 -181
- package/dist/esm/chunks/formatDate.CWN6IFKq.js +0 -952
- package/dist/esm/chunks/formatNumber.Bm2k8QrT.js +0 -10
- package/dist/esm/chunks/generating-star.DMDPNTaM.js +0 -1501
- package/dist/esm/chunks/generating-star.DMDPNTaM.js.map +0 -1
- package/dist/esm/chunks/header-nav.b4hvOsKc.js +0 -197
- package/dist/esm/chunks/header-pane.BFXHXxVn.js +0 -559
- package/dist/esm/chunks/hooks.BWVaVAT-.js +0 -343
- package/dist/esm/chunks/hooks.BWVaVAT-.js.map +0 -1
- package/dist/esm/chunks/index.BqibIWDw.js +0 -137
- package/dist/esm/chunks/input-with-tags.tg2nhPFv.js +0 -110
- package/dist/esm/chunks/logo.D5BMN6Db.js +0 -191
- package/dist/esm/chunks/primary.CtiRZbqq.js +0 -18
- package/dist/esm/chunks/review-list.BtSnfpSc.js +0 -117
- package/dist/esm/chunks/sidebar.BamKohb5.js +0 -803
- package/dist/esm/chunks/sidebar.BamKohb5.js.map +0 -1
- package/dist/esm/chunks/simpleSelect.B1rktKkt.js +0 -23
- package/dist/esm/chunks/status-badge.eFJ1PYeb.js +0 -18
- package/dist/esm/chunks/trend-value.COSukPwk.js +0 -51
- package/dist/esm/chunks/two-level-combobox.BXs2z9u5.js +0 -132
- package/dist/esm/chunks/useChartDateFormatters.DS9ASgFO.js +0 -11
- package/dist/esm/chunks/utils.Cwtlq8dh.js +0 -45
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Check, SpinnerGap } from '@phosphor-icons/react';
|
|
3
|
-
import { c as cn } from './utils.Cwtlq8dh.js';
|
|
4
|
-
import { CommandItem } from '../components/ui/command.js';
|
|
5
|
-
import { C as Combobox } from './combobox.CJKym3Z1.js';
|
|
6
|
-
|
|
7
|
-
const FONT_CACHE_KEY = "brainfish-google-fonts-cache";
|
|
8
|
-
const FONT_CACHE_TIMESTAMP_KEY = "brainfish-google-fonts-cache-timestamp";
|
|
9
|
-
const FONT_CACHE_DURATION_MS = 24 * 60 * 60 * 1e3;
|
|
10
|
-
const loadedFonts = /* @__PURE__ */ new Set();
|
|
11
|
-
const getCachedFonts = () => {
|
|
12
|
-
try {
|
|
13
|
-
const timestamp = localStorage.getItem(FONT_CACHE_TIMESTAMP_KEY);
|
|
14
|
-
if (!timestamp) return null;
|
|
15
|
-
const cacheAge = Date.now() - parseInt(timestamp, 10);
|
|
16
|
-
if (cacheAge > FONT_CACHE_DURATION_MS) {
|
|
17
|
-
localStorage.removeItem(FONT_CACHE_KEY);
|
|
18
|
-
localStorage.removeItem(FONT_CACHE_TIMESTAMP_KEY);
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
const cached = localStorage.getItem(FONT_CACHE_KEY);
|
|
22
|
-
if (!cached) return null;
|
|
23
|
-
return JSON.parse(cached);
|
|
24
|
-
} catch {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const setCachedFonts = (fonts) => {
|
|
29
|
-
try {
|
|
30
|
-
localStorage.setItem(FONT_CACHE_KEY, JSON.stringify(fonts));
|
|
31
|
-
localStorage.setItem(FONT_CACHE_TIMESTAMP_KEY, Date.now().toString());
|
|
32
|
-
} catch {
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const loadFont = (fontFamily) => {
|
|
36
|
-
if (loadedFonts.has(fontFamily)) return;
|
|
37
|
-
const link = document.createElement("link");
|
|
38
|
-
link.href = `https://fonts.googleapis.com/css2?family=${fontFamily.replace(/ /g, "+")}&display=swap`;
|
|
39
|
-
link.rel = "stylesheet";
|
|
40
|
-
document.head.appendChild(link);
|
|
41
|
-
loadedFonts.add(fontFamily);
|
|
42
|
-
};
|
|
43
|
-
const clearFontCache = () => {
|
|
44
|
-
try {
|
|
45
|
-
localStorage.removeItem(FONT_CACHE_KEY);
|
|
46
|
-
localStorage.removeItem(FONT_CACHE_TIMESTAMP_KEY);
|
|
47
|
-
} catch {
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
function useFontOptions({ apiKey, maxFonts = 500, onError }) {
|
|
52
|
-
const [fonts, setFonts] = React.useState([]);
|
|
53
|
-
const [isLoading, setIsLoading] = React.useState(true);
|
|
54
|
-
const onErrorRef = React.useRef(onError);
|
|
55
|
-
React.useEffect(() => {
|
|
56
|
-
onErrorRef.current = onError;
|
|
57
|
-
}, [onError]);
|
|
58
|
-
React.useEffect(() => {
|
|
59
|
-
const fetchFonts = async () => {
|
|
60
|
-
const cachedFonts = getCachedFonts();
|
|
61
|
-
if (cachedFonts && cachedFonts.length > 0) {
|
|
62
|
-
setFonts(cachedFonts.slice(0, maxFonts));
|
|
63
|
-
setIsLoading(false);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
try {
|
|
67
|
-
const response = await fetch(`https://www.googleapis.com/webfonts/v1/webfonts?key=${apiKey}&sort=popularity`);
|
|
68
|
-
if (!response.ok) {
|
|
69
|
-
throw new Error(`Failed to fetch fonts: ${response.statusText}`);
|
|
70
|
-
}
|
|
71
|
-
const data = await response.json();
|
|
72
|
-
const fontOptions = data.items.map((fontItem) => ({
|
|
73
|
-
value: fontItem.family,
|
|
74
|
-
label: fontItem.family,
|
|
75
|
-
category: fontItem.category,
|
|
76
|
-
variants: fontItem.variants
|
|
77
|
-
}));
|
|
78
|
-
setCachedFonts(fontOptions);
|
|
79
|
-
setFonts(fontOptions.slice(0, maxFonts));
|
|
80
|
-
} catch (err) {
|
|
81
|
-
const error = err instanceof Error ? err : new Error("Failed to fetch fonts");
|
|
82
|
-
console.error("FontPicker: Failed to fetch Google Fonts", error);
|
|
83
|
-
onErrorRef.current?.(error);
|
|
84
|
-
} finally {
|
|
85
|
-
setIsLoading(false);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
void fetchFonts();
|
|
89
|
-
}, [apiKey, maxFonts]);
|
|
90
|
-
return { fonts, isLoading, loadFont };
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const FontPickerItem = React.memo(function FontPickerItem2({ font, isSelected, onSelect }) {
|
|
94
|
-
const itemRef = React.useRef(null);
|
|
95
|
-
const [isVisible, setIsVisible] = React.useState(false);
|
|
96
|
-
React.useEffect(() => {
|
|
97
|
-
const observer = new IntersectionObserver(
|
|
98
|
-
([entry]) => {
|
|
99
|
-
if (entry.isIntersecting) {
|
|
100
|
-
setIsVisible(true);
|
|
101
|
-
observer.disconnect();
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
{ threshold: 0.1 }
|
|
105
|
-
);
|
|
106
|
-
if (itemRef.current) {
|
|
107
|
-
observer.observe(itemRef.current);
|
|
108
|
-
}
|
|
109
|
-
return () => observer.disconnect();
|
|
110
|
-
}, []);
|
|
111
|
-
React.useEffect(() => {
|
|
112
|
-
if (isVisible) {
|
|
113
|
-
loadFont(font.value);
|
|
114
|
-
}
|
|
115
|
-
}, [isVisible, font.value]);
|
|
116
|
-
const ariaLabel = `Select ${font.label} font${font.category ? `, ${font.category} category` : ""}`;
|
|
117
|
-
return /* @__PURE__ */ React.createElement(
|
|
118
|
-
CommandItem,
|
|
119
|
-
{
|
|
120
|
-
ref: itemRef,
|
|
121
|
-
value: font.label,
|
|
122
|
-
onSelect,
|
|
123
|
-
className: "cursor-pointer",
|
|
124
|
-
"aria-label": ariaLabel,
|
|
125
|
-
"aria-selected": isSelected
|
|
126
|
-
},
|
|
127
|
-
/* @__PURE__ */ React.createElement("span", { style: { fontFamily: isVisible ? font.value : void 0 }, className: "flex-1 truncate" }, font.label),
|
|
128
|
-
font.category && /* @__PURE__ */ React.createElement("span", { className: "text-xs text-muted-foreground capitalize" }, font.category),
|
|
129
|
-
/* @__PURE__ */ React.createElement(Check, { className: cn("ml-2 h-4 w-4", isSelected ? "opacity-100" : "opacity-0") })
|
|
130
|
-
);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
function FontPicker({
|
|
134
|
-
value,
|
|
135
|
-
onChange,
|
|
136
|
-
apiKey,
|
|
137
|
-
placeholder = "Select a font...",
|
|
138
|
-
searchPlaceholder = "Search fonts...",
|
|
139
|
-
noResultsText = "No fonts found.",
|
|
140
|
-
loadingText = "Loading fonts...",
|
|
141
|
-
disabled = false,
|
|
142
|
-
className,
|
|
143
|
-
dropdownWidth,
|
|
144
|
-
maxFonts = 500,
|
|
145
|
-
onError
|
|
146
|
-
}) {
|
|
147
|
-
const { fonts, isLoading, loadFont } = useFontOptions({ apiKey, maxFonts, onError });
|
|
148
|
-
React.useEffect(() => {
|
|
149
|
-
if (value) {
|
|
150
|
-
loadFont(value);
|
|
151
|
-
}
|
|
152
|
-
}, [value, loadFont]);
|
|
153
|
-
const options = fonts;
|
|
154
|
-
return /* @__PURE__ */ React.createElement(
|
|
155
|
-
Combobox,
|
|
156
|
-
{
|
|
157
|
-
options,
|
|
158
|
-
value,
|
|
159
|
-
onChange,
|
|
160
|
-
defaultValueLabel: placeholder,
|
|
161
|
-
placeholder: searchPlaceholder,
|
|
162
|
-
noResultsLabel: noResultsText,
|
|
163
|
-
disabled: disabled || isLoading,
|
|
164
|
-
className,
|
|
165
|
-
dropdownWidth,
|
|
166
|
-
renderTrigger: ({ selectedItem }) => {
|
|
167
|
-
if (isLoading) {
|
|
168
|
-
return /* @__PURE__ */ React.createElement("span", { className: "flex items-center gap-2 text-muted-foreground" }, /* @__PURE__ */ React.createElement(SpinnerGap, { className: "h-4 w-4 animate-spin" }), loadingText);
|
|
169
|
-
}
|
|
170
|
-
if (selectedItem) {
|
|
171
|
-
return /* @__PURE__ */ React.createElement("span", { style: { fontFamily: selectedItem.value } }, selectedItem.label);
|
|
172
|
-
}
|
|
173
|
-
return /* @__PURE__ */ React.createElement("span", { className: "text-muted-foreground" }, placeholder);
|
|
174
|
-
},
|
|
175
|
-
renderItem: ({ item, isSelected, onSelect }) => /* @__PURE__ */ React.createElement(FontPickerItem, { font: item, isSelected, onSelect })
|
|
176
|
-
}
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export { FontPicker as F, FontPickerItem as a, clearFontCache as c, getCachedFonts as g, loadFont as l, setCachedFonts as s, useFontOptions as u };
|
|
181
|
-
//# sourceMappingURL=font-picker.DisEoE8a.js.map
|