@pixpilot/shadcn-ui 0.4.0 → 0.4.2
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/AbsoluteFill.cjs +24 -1
- package/dist/AbsoluteFill.js +21 -1
- package/dist/Alert.cjs +82 -1
- package/dist/Alert.js +77 -1
- package/dist/Button.cjs +84 -1
- package/dist/Button.d.cts +1 -1
- package/dist/Button.d.ts +1 -1
- package/dist/Button.js +79 -1
- package/dist/CloseButtonAbsolute.cjs +20 -1
- package/dist/CloseButtonAbsolute.js +16 -1
- package/dist/CloseButtonRounded.cjs +22 -1
- package/dist/CloseButtonRounded.js +17 -1
- package/dist/Combobox.cjs +53 -1
- package/dist/Combobox.js +48 -1
- package/dist/CommandOptionList.cjs +29 -1
- package/dist/CommandOptionList.js +25 -1
- package/dist/ContentCard.cjs +27 -1
- package/dist/ContentCard.d.cts +1 -1
- package/dist/ContentCard.js +23 -1
- package/dist/DatePicker.cjs +38 -1
- package/dist/DatePicker.d.cts +1 -1
- package/dist/DatePicker.js +33 -1
- package/dist/LoadingOverlay.cjs +65 -1
- package/dist/LoadingOverlay.js +60 -1
- package/dist/Select.cjs +27 -1
- package/dist/Select.d.cts +1 -1
- package/dist/Select.js +23 -1
- package/dist/Slider.cjs +19 -1
- package/dist/Slider.js +15 -1
- package/dist/ThemeToggle.cjs +98 -1
- package/dist/ThemeToggle.js +94 -1
- package/dist/_virtual/rolldown_runtime.cjs +25 -1
- package/dist/confirmation-dialog/ConfirmationDialog.cjs +46 -1
- package/dist/confirmation-dialog/ConfirmationDialog.d.cts +1 -0
- package/dist/confirmation-dialog/ConfirmationDialog.js +42 -1
- package/dist/confirmation-dialog/DialogProvider.cjs +16 -1
- package/dist/confirmation-dialog/DialogProvider.js +12 -1
- package/dist/confirmation-dialog/confirmation-dialogs.cjs +14 -1
- package/dist/confirmation-dialog/confirmation-dialogs.js +12 -1
- package/dist/confirmation-dialog/index.cjs +6 -1
- package/dist/confirmation-dialog/index.js +6 -1
- package/dist/file-upload/FileUpload.cjs +68 -1
- package/dist/file-upload/FileUpload.d.ts +2 -2
- package/dist/file-upload/FileUpload.js +63 -1
- package/dist/file-upload/FileUploadItems.cjs +36 -1
- package/dist/file-upload/FileUploadItems.js +32 -1
- package/dist/file-upload/FileUploadListItem.cjs +88 -1
- package/dist/file-upload/FileUploadListItem.js +82 -1
- package/dist/file-upload/hooks/index.cjs +3 -1
- package/dist/file-upload/hooks/index.d.cts +2 -0
- package/dist/file-upload/hooks/index.js +3 -1
- package/dist/file-upload/hooks/use-file-error.cjs +15 -1
- package/dist/file-upload/hooks/use-file-error.js +13 -1
- package/dist/file-upload/hooks/use-file-upload-progress-callbacks.cjs +34 -1
- package/dist/file-upload/hooks/use-file-upload-progress-callbacks.d.cts +1 -0
- package/dist/file-upload/hooks/use-file-upload-progress-callbacks.js +31 -1
- package/dist/file-upload/hooks/use-file-upload-store.cjs +77 -1
- package/dist/file-upload/hooks/use-file-upload-store.d.cts +2 -0
- package/dist/file-upload/hooks/use-file-upload-store.js +75 -1
- package/dist/file-upload/index.cjs +5 -1
- package/dist/file-upload/index.d.cts +2 -1
- package/dist/file-upload/index.js +5 -1
- package/dist/file-upload/utils/create-placeholder-file.cjs +11 -1
- package/dist/file-upload/utils/create-placeholder-file.js +10 -1
- package/dist/file-upload/utils/get-file-key.cjs +8 -1
- package/dist/file-upload/utils/get-file-key.d.cts +1 -0
- package/dist/file-upload/utils/get-file-key.js +7 -1
- package/dist/file-upload/utils/get-file-meta.cjs +23 -1
- package/dist/file-upload/utils/get-file-meta.d.cts +1 -0
- package/dist/file-upload/utils/get-file-meta.js +21 -1
- package/dist/file-upload/utils/index.d.cts +4 -0
- package/dist/file-upload/utils/is-file-equal.cjs +9 -1
- package/dist/file-upload/utils/is-file-equal.d.cts +1 -0
- package/dist/file-upload/utils/is-file-equal.js +8 -1
- package/dist/file-upload/utils/merge-file-metadata.cjs +26 -1
- package/dist/file-upload/utils/merge-file-metadata.d.cts +1 -0
- package/dist/file-upload/utils/merge-file-metadata.js +26 -1
- package/dist/file-upload-inline/FileUploadInline.cjs +71 -1
- package/dist/file-upload-inline/FileUploadInline.d.ts +2 -2
- package/dist/file-upload-inline/FileUploadInline.js +66 -1
- package/dist/file-upload-inline/FileUploadInlineItem.cjs +94 -1
- package/dist/file-upload-inline/FileUploadInlineItem.js +88 -1
- package/dist/file-upload-inline/defaults.cjs +11 -1
- package/dist/file-upload-inline/defaults.js +10 -1
- package/dist/file-upload-inline/index.cjs +1 -1
- package/dist/file-upload-inline/index.js +1 -1
- package/dist/file-upload-inline/utils.cjs +36 -1
- package/dist/file-upload-inline/utils.js +34 -1
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/use-media-query.cjs +9 -1
- package/dist/hooks/use-media-query.js +7 -1
- package/dist/icon-selector/IconPicker.cjs +93 -1
- package/dist/icon-selector/IconPicker.d.cts +0 -1
- package/dist/icon-selector/IconPicker.d.ts +0 -1
- package/dist/icon-selector/IconPicker.js +88 -1
- package/dist/icon-selector/constants.cjs +6 -1
- package/dist/icon-selector/constants.js +5 -0
- package/dist/icon-selector/icon-picker-container.cjs +35 -1
- package/dist/icon-selector/icon-picker-container.js +32 -1
- package/dist/icon-selector/icon-picker-content.cjs +146 -1
- package/dist/icon-selector/icon-picker-content.js +141 -1
- package/dist/icon-selector/index.cjs +1 -1
- package/dist/icon-selector/index.d.cts +2 -2
- package/dist/icon-selector/index.d.ts +2 -2
- package/dist/icon-selector/index.js +1 -1
- package/dist/icon-selector/use-async-providers.cjs +69 -1
- package/dist/icon-selector/use-async-providers.js +67 -1
- package/dist/icon-selector/utils/is-valid-provider.cjs +11 -1
- package/dist/icon-selector/utils/is-valid-provider.js +10 -1
- package/dist/icon-selector/virtualized-icon-grid.cjs +137 -1
- package/dist/icon-selector/virtualized-icon-grid.js +132 -1
- package/dist/index.cjs +76 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +37 -1
- package/dist/node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.cjs +18 -0
- package/dist/node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.js +17 -0
- package/dist/node_modules/.pnpm/tailwind-merge@3.4.0/node_modules/tailwind-merge/dist/bundle-mjs.cjs +1894 -0
- package/dist/node_modules/.pnpm/tailwind-merge@3.4.0/node_modules/tailwind-merge/dist/bundle-mjs.js +1893 -0
- package/dist/packages/shadcn/src/lib/utils.cjs +10 -1
- package/dist/packages/shadcn/src/lib/utils.js +10 -1
- package/dist/pagination/Pagination.cjs +156 -1
- package/dist/pagination/Pagination.js +151 -1
- package/dist/pagination/index.cjs +1 -1
- package/dist/pagination/index.js +1 -1
- package/dist/rich-text-editor/RichTextEditor.cjs +132 -1
- package/dist/rich-text-editor/RichTextEditor.js +126 -1
- package/dist/rich-text-editor/index.cjs +1 -1
- package/dist/rich-text-editor/index.js +1 -1
- package/dist/rich-text-editor/predefined-toolbar-options.cjs +84 -1
- package/dist/rich-text-editor/predefined-toolbar-options.js +81 -1
- package/dist/spinner/index.cjs +1 -1
- package/dist/spinner/index.js +1 -1
- package/dist/spinner/spinner.cjs +73 -6
- package/dist/spinner/spinner.js +70 -6
- package/dist/spinner/styles.cjs +24 -12
- package/dist/spinner/styles.js +23 -12
- package/dist/tags-input.cjs +226 -1
- package/dist/tags-input.js +222 -1
- package/dist/theme-provider/ThemeProvider.cjs +27 -1
- package/dist/theme-provider/ThemeProvider.js +23 -1
- package/dist/theme-provider/index.cjs +4 -1
- package/dist/theme-provider/index.js +4 -1
- package/dist/toast/AlertToast.cjs +36 -1
- package/dist/toast/AlertToast.js +31 -1
- package/dist/toast/index.cjs +1 -1
- package/dist/toast/index.js +1 -1
- package/dist/toast/toast.cjs +75 -1
- package/dist/toast/toast.js +66 -1
- package/package.json +2 -2
- package/dist/_virtual/rolldown_runtime.js +0 -1
- package/dist/node_modules/.pnpm/@diceui_shared@0.12.0_@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@1_2c51ffe880f01dd537d5b6a13313daf4/node_modules/@diceui/shared/dist/index.cjs +0 -1
- package/dist/node_modules/.pnpm/@diceui_shared@0.12.0_@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@1_2c51ffe880f01dd537d5b6a13313daf4/node_modules/@diceui/shared/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@diceui_tags-input@0.7.2_@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__reac_e193dc2ff0d426ed009417f8d89778fd/node_modules/@diceui/tags-input/dist/index.cjs +0 -1
- package/dist/node_modules/.pnpm/@diceui_tags-input@0.7.2_@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__reac_e193dc2ff0d426ed009417f8d89778fd/node_modules/@diceui/tags-input/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_core@1.7.3/node_modules/@floating-ui/core/dist/floating-ui.core.cjs +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_core@1.7.3/node_modules/@floating-ui/core/dist/floating-ui.core.js +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.cjs +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_react-dom@2.1.6_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_react-dom@2.1.6_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react/dist/floating-ui.react.esm.cjs +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react/dist/floating-ui.react.esm.js +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react/dist/floating-ui.react.utils.cjs +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_react@0.27.16_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@floating-ui/react/dist/floating-ui.react.utils.js +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.cjs +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.cjs +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -1
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -1
- package/dist/node_modules/.pnpm/tabbable@6.3.0/node_modules/tabbable/dist/index.cjs +0 -1
- package/dist/node_modules/.pnpm/tabbable@6.3.0/node_modules/tabbable/dist/index.esm.js +0 -1
- package/dist/packages/shadcn/src/components/index.cjs +0 -1
- package/dist/packages/shadcn/src/components/index.js +0 -1
- package/dist/packages/shadcn/src/components/ui/OrContinueWithSeparator.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/OrContinueWithSeparator.js +0 -1
- package/dist/packages/shadcn/src/components/ui/alert-dialog.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/alert-dialog.js +0 -1
- package/dist/packages/shadcn/src/components/ui/alert.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/alert.js +0 -1
- package/dist/packages/shadcn/src/components/ui/avatar.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/avatar.js +0 -1
- package/dist/packages/shadcn/src/components/ui/badge.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/badge.js +0 -1
- package/dist/packages/shadcn/src/components/ui/button.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/button.js +0 -1
- package/dist/packages/shadcn/src/components/ui/calendar.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/calendar.js +0 -1
- package/dist/packages/shadcn/src/components/ui/card.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/card.js +0 -1
- package/dist/packages/shadcn/src/components/ui/checkbox.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/checkbox.js +0 -1
- package/dist/packages/shadcn/src/components/ui/command.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/command.js +0 -1
- package/dist/packages/shadcn/src/components/ui/dialog.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/dialog.js +0 -1
- package/dist/packages/shadcn/src/components/ui/dropdown-menu.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/dropdown-menu.js +0 -1
- package/dist/packages/shadcn/src/components/ui/file-upload.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/file-upload.js +0 -1
- package/dist/packages/shadcn/src/components/ui/form.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/form.js +0 -1
- package/dist/packages/shadcn/src/components/ui/index.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/index.js +0 -1
- package/dist/packages/shadcn/src/components/ui/input.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/input.js +0 -1
- package/dist/packages/shadcn/src/components/ui/label.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/label.js +0 -1
- package/dist/packages/shadcn/src/components/ui/pagination.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/pagination.js +0 -1
- package/dist/packages/shadcn/src/components/ui/popover.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/popover.js +0 -1
- package/dist/packages/shadcn/src/components/ui/radio-group.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/radio-group.js +0 -1
- package/dist/packages/shadcn/src/components/ui/select.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/select.js +0 -1
- package/dist/packages/shadcn/src/components/ui/separator.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/separator.js +0 -1
- package/dist/packages/shadcn/src/components/ui/shadcn-io/tags/index.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/shadcn-io/tags/index.js +0 -1
- package/dist/packages/shadcn/src/components/ui/shadcn-io/tags-input-inline/index.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/shadcn-io/tags-input-inline/index.js +0 -1
- package/dist/packages/shadcn/src/components/ui/sheet.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/sheet.js +0 -1
- package/dist/packages/shadcn/src/components/ui/slider.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/slider.js +0 -1
- package/dist/packages/shadcn/src/components/ui/switch.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/switch.js +0 -1
- package/dist/packages/shadcn/src/components/ui/tabs.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/tabs.js +0 -1
- package/dist/packages/shadcn/src/components/ui/textarea.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/textarea.js +0 -1
- package/dist/packages/shadcn/src/components/ui/tooltip.cjs +0 -1
- package/dist/packages/shadcn/src/components/ui/tooltip.js +0 -1
- package/dist/packages/shadcn/src/lib/index.cjs +0 -1
- package/dist/packages/shadcn/src/lib/index.js +0 -1
|
@@ -1 +1,146 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_LoadingOverlay = require('../LoadingOverlay.cjs');
|
|
3
|
+
const require_use_async_providers = require('./use-async-providers.cjs');
|
|
4
|
+
const require_virtualized_icon_grid = require('./virtualized-icon-grid.cjs');
|
|
5
|
+
let __pixpilot_shadcn = require("@pixpilot/shadcn");
|
|
6
|
+
__pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
|
|
7
|
+
let lucide_react = require("lucide-react");
|
|
8
|
+
lucide_react = require_rolldown_runtime.__toESM(lucide_react);
|
|
9
|
+
let react = require("react");
|
|
10
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
13
|
+
|
|
14
|
+
//#region src/icon-selector/icon-picker-content.tsx
|
|
15
|
+
function noIconMessage(hasIcons, isSearching) {
|
|
16
|
+
if (hasIcons) return "";
|
|
17
|
+
if (!isSearching) return "No icons provided by the selected provider!";
|
|
18
|
+
return "No icons found matching your search";
|
|
19
|
+
}
|
|
20
|
+
const IconPickerContent = ({ providers: providersProp, onChange, onSelect, maxHeight = "60vh" }) => {
|
|
21
|
+
const [searchQuery, setSearchQuery] = (0, react.useState)("");
|
|
22
|
+
const { providers, isLoading } = require_use_async_providers.useAsyncProviders(providersProp);
|
|
23
|
+
const providerPrefixes = (0, react.useMemo)(() => providers.map((provider) => provider.prefix), [providers]);
|
|
24
|
+
const [activeProvider, setActiveProvider] = (0, react.useState)(providerPrefixes[0] ?? "default");
|
|
25
|
+
/**
|
|
26
|
+
* Sync activeProvider when providers load with delay
|
|
27
|
+
*/
|
|
28
|
+
(0, react.useEffect)(() => {
|
|
29
|
+
if (providerPrefixes.length > 0) setActiveProvider((current) => {
|
|
30
|
+
if (current === "default") return providerPrefixes[0] ?? "default";
|
|
31
|
+
return current;
|
|
32
|
+
});
|
|
33
|
+
}, [providerPrefixes]);
|
|
34
|
+
/**
|
|
35
|
+
* Get all icons for a provider
|
|
36
|
+
*/
|
|
37
|
+
const getProviderIcons = (0, react.useCallback)((provider) => {
|
|
38
|
+
try {
|
|
39
|
+
return provider.icons.map((iconName) => `${provider.prefix}:${iconName}`);
|
|
40
|
+
} catch {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
44
|
+
/**
|
|
45
|
+
* Create a map of all icons grouped by provider
|
|
46
|
+
*/
|
|
47
|
+
const allIconsByProvider = (0, react.useMemo)(() => {
|
|
48
|
+
const map = {};
|
|
49
|
+
for (const provider of providers) map[provider.prefix] = getProviderIcons(provider);
|
|
50
|
+
return map;
|
|
51
|
+
}, [providers, getProviderIcons]);
|
|
52
|
+
/**
|
|
53
|
+
* Filter icons: when searching, show from all providers; otherwise show active
|
|
54
|
+
*/
|
|
55
|
+
const filteredIconsData = (0, react.useMemo)(() => {
|
|
56
|
+
if (!searchQuery) return {
|
|
57
|
+
isSearching: false,
|
|
58
|
+
data: allIconsByProvider[activeProvider] ?? []
|
|
59
|
+
};
|
|
60
|
+
const results = [];
|
|
61
|
+
const searchLower = searchQuery.toLowerCase();
|
|
62
|
+
for (const provider of providers) {
|
|
63
|
+
const filtered = (allIconsByProvider[provider.prefix] ?? []).filter((icon) => icon.toLowerCase().includes(searchLower));
|
|
64
|
+
results.push(...filtered);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
isSearching: true,
|
|
68
|
+
data: results
|
|
69
|
+
};
|
|
70
|
+
}, [
|
|
71
|
+
searchQuery,
|
|
72
|
+
activeProvider,
|
|
73
|
+
allIconsByProvider,
|
|
74
|
+
providers
|
|
75
|
+
]);
|
|
76
|
+
const handleSelectIcon = (0, react.useCallback)((iconName) => {
|
|
77
|
+
onChange?.(iconName);
|
|
78
|
+
onSelect?.();
|
|
79
|
+
}, [onChange, onSelect]);
|
|
80
|
+
const { isSearching, data: filteredData } = filteredIconsData;
|
|
81
|
+
const hasNoResults = !isSearching && filteredData.length === 0 || isSearching && filteredData.length === 0;
|
|
82
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
83
|
+
className: "flex flex-col gap-4 min-h-[200px] max-h-[80vh]",
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
86
|
+
className: "relative",
|
|
87
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Input, {
|
|
88
|
+
placeholder: "Search icons...",
|
|
89
|
+
value: searchQuery,
|
|
90
|
+
onChange: (e) => setSearchQuery(e.target.value),
|
|
91
|
+
autoFocus: true,
|
|
92
|
+
disabled: isLoading
|
|
93
|
+
}), searchQuery && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
94
|
+
type: "button",
|
|
95
|
+
onClick: () => setSearchQuery(""),
|
|
96
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",
|
|
97
|
+
"aria-label": "Clear search",
|
|
98
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "h-4 w-4" })
|
|
99
|
+
})]
|
|
100
|
+
}),
|
|
101
|
+
!isSearching && providers.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Tabs, {
|
|
102
|
+
value: activeProvider,
|
|
103
|
+
onValueChange: setActiveProvider,
|
|
104
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.TabsList, {
|
|
105
|
+
className: "w-full",
|
|
106
|
+
children: providers.map((provider) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.TabsTrigger, {
|
|
107
|
+
value: provider.prefix,
|
|
108
|
+
children: provider.name ?? provider.prefix
|
|
109
|
+
}, provider.prefix))
|
|
110
|
+
}), providers.map((provider) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.TabsContent, {
|
|
111
|
+
value: provider.prefix,
|
|
112
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_virtualized_icon_grid.default, {
|
|
113
|
+
icons: allIconsByProvider[provider.prefix] ?? [],
|
|
114
|
+
onSelectIcon: handleSelectIcon,
|
|
115
|
+
maxHeight
|
|
116
|
+
})
|
|
117
|
+
}, provider.prefix))]
|
|
118
|
+
}),
|
|
119
|
+
hasNoResults && isSearching && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
120
|
+
className: "flex items-center justify-center py-8",
|
|
121
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
122
|
+
className: "text-sm text-muted-foreground",
|
|
123
|
+
children: noIconMessage(false, isSearching)
|
|
124
|
+
})
|
|
125
|
+
}),
|
|
126
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_LoadingOverlay.LoadingOverlay, {
|
|
127
|
+
message: "Loading icons...",
|
|
128
|
+
loading: isLoading
|
|
129
|
+
}),
|
|
130
|
+
isSearching && providers.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_virtualized_icon_grid.default, {
|
|
131
|
+
icons: filteredData,
|
|
132
|
+
onSelectIcon: handleSelectIcon,
|
|
133
|
+
maxHeight
|
|
134
|
+
}),
|
|
135
|
+
!isSearching && providers.length === 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_virtualized_icon_grid.default, {
|
|
136
|
+
icons: filteredData,
|
|
137
|
+
onSelectIcon: handleSelectIcon,
|
|
138
|
+
maxHeight
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
var icon_picker_content_default = IconPickerContent;
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
exports.default = icon_picker_content_default;
|
|
@@ -1 +1,141 @@
|
|
|
1
|
-
import{LoadingOverlay
|
|
1
|
+
import { LoadingOverlay } from "../LoadingOverlay.js";
|
|
2
|
+
import { useAsyncProviders } from "./use-async-providers.js";
|
|
3
|
+
import virtualized_icon_grid_default from "./virtualized-icon-grid.js";
|
|
4
|
+
import { Input, Tabs, TabsContent, TabsList, TabsTrigger } from "@pixpilot/shadcn";
|
|
5
|
+
import { X } from "lucide-react";
|
|
6
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/icon-selector/icon-picker-content.tsx
|
|
10
|
+
function noIconMessage(hasIcons, isSearching) {
|
|
11
|
+
if (hasIcons) return "";
|
|
12
|
+
if (!isSearching) return "No icons provided by the selected provider!";
|
|
13
|
+
return "No icons found matching your search";
|
|
14
|
+
}
|
|
15
|
+
const IconPickerContent = ({ providers: providersProp, onChange, onSelect, maxHeight = "60vh" }) => {
|
|
16
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
17
|
+
const { providers, isLoading } = useAsyncProviders(providersProp);
|
|
18
|
+
const providerPrefixes = useMemo(() => providers.map((provider) => provider.prefix), [providers]);
|
|
19
|
+
const [activeProvider, setActiveProvider] = useState(providerPrefixes[0] ?? "default");
|
|
20
|
+
/**
|
|
21
|
+
* Sync activeProvider when providers load with delay
|
|
22
|
+
*/
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (providerPrefixes.length > 0) setActiveProvider((current) => {
|
|
25
|
+
if (current === "default") return providerPrefixes[0] ?? "default";
|
|
26
|
+
return current;
|
|
27
|
+
});
|
|
28
|
+
}, [providerPrefixes]);
|
|
29
|
+
/**
|
|
30
|
+
* Get all icons for a provider
|
|
31
|
+
*/
|
|
32
|
+
const getProviderIcons = useCallback((provider) => {
|
|
33
|
+
try {
|
|
34
|
+
return provider.icons.map((iconName) => `${provider.prefix}:${iconName}`);
|
|
35
|
+
} catch {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
}, []);
|
|
39
|
+
/**
|
|
40
|
+
* Create a map of all icons grouped by provider
|
|
41
|
+
*/
|
|
42
|
+
const allIconsByProvider = useMemo(() => {
|
|
43
|
+
const map = {};
|
|
44
|
+
for (const provider of providers) map[provider.prefix] = getProviderIcons(provider);
|
|
45
|
+
return map;
|
|
46
|
+
}, [providers, getProviderIcons]);
|
|
47
|
+
/**
|
|
48
|
+
* Filter icons: when searching, show from all providers; otherwise show active
|
|
49
|
+
*/
|
|
50
|
+
const filteredIconsData = useMemo(() => {
|
|
51
|
+
if (!searchQuery) return {
|
|
52
|
+
isSearching: false,
|
|
53
|
+
data: allIconsByProvider[activeProvider] ?? []
|
|
54
|
+
};
|
|
55
|
+
const results = [];
|
|
56
|
+
const searchLower = searchQuery.toLowerCase();
|
|
57
|
+
for (const provider of providers) {
|
|
58
|
+
const filtered = (allIconsByProvider[provider.prefix] ?? []).filter((icon) => icon.toLowerCase().includes(searchLower));
|
|
59
|
+
results.push(...filtered);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
isSearching: true,
|
|
63
|
+
data: results
|
|
64
|
+
};
|
|
65
|
+
}, [
|
|
66
|
+
searchQuery,
|
|
67
|
+
activeProvider,
|
|
68
|
+
allIconsByProvider,
|
|
69
|
+
providers
|
|
70
|
+
]);
|
|
71
|
+
const handleSelectIcon = useCallback((iconName) => {
|
|
72
|
+
onChange?.(iconName);
|
|
73
|
+
onSelect?.();
|
|
74
|
+
}, [onChange, onSelect]);
|
|
75
|
+
const { isSearching, data: filteredData } = filteredIconsData;
|
|
76
|
+
const hasNoResults = !isSearching && filteredData.length === 0 || isSearching && filteredData.length === 0;
|
|
77
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
78
|
+
className: "flex flex-col gap-4 min-h-[200px] max-h-[80vh]",
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsxs("div", {
|
|
81
|
+
className: "relative",
|
|
82
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
83
|
+
placeholder: "Search icons...",
|
|
84
|
+
value: searchQuery,
|
|
85
|
+
onChange: (e) => setSearchQuery(e.target.value),
|
|
86
|
+
autoFocus: true,
|
|
87
|
+
disabled: isLoading
|
|
88
|
+
}), searchQuery && /* @__PURE__ */ jsx("button", {
|
|
89
|
+
type: "button",
|
|
90
|
+
onClick: () => setSearchQuery(""),
|
|
91
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",
|
|
92
|
+
"aria-label": "Clear search",
|
|
93
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
94
|
+
})]
|
|
95
|
+
}),
|
|
96
|
+
!isSearching && providers.length > 1 && /* @__PURE__ */ jsxs(Tabs, {
|
|
97
|
+
value: activeProvider,
|
|
98
|
+
onValueChange: setActiveProvider,
|
|
99
|
+
children: [/* @__PURE__ */ jsx(TabsList, {
|
|
100
|
+
className: "w-full",
|
|
101
|
+
children: providers.map((provider) => /* @__PURE__ */ jsx(TabsTrigger, {
|
|
102
|
+
value: provider.prefix,
|
|
103
|
+
children: provider.name ?? provider.prefix
|
|
104
|
+
}, provider.prefix))
|
|
105
|
+
}), providers.map((provider) => /* @__PURE__ */ jsx(TabsContent, {
|
|
106
|
+
value: provider.prefix,
|
|
107
|
+
children: /* @__PURE__ */ jsx(virtualized_icon_grid_default, {
|
|
108
|
+
icons: allIconsByProvider[provider.prefix] ?? [],
|
|
109
|
+
onSelectIcon: handleSelectIcon,
|
|
110
|
+
maxHeight
|
|
111
|
+
})
|
|
112
|
+
}, provider.prefix))]
|
|
113
|
+
}),
|
|
114
|
+
hasNoResults && isSearching && /* @__PURE__ */ jsx("div", {
|
|
115
|
+
className: "flex items-center justify-center py-8",
|
|
116
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
117
|
+
className: "text-sm text-muted-foreground",
|
|
118
|
+
children: noIconMessage(false, isSearching)
|
|
119
|
+
})
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ jsx(LoadingOverlay, {
|
|
122
|
+
message: "Loading icons...",
|
|
123
|
+
loading: isLoading
|
|
124
|
+
}),
|
|
125
|
+
isSearching && providers.length > 0 && /* @__PURE__ */ jsx(virtualized_icon_grid_default, {
|
|
126
|
+
icons: filteredData,
|
|
127
|
+
onSelectIcon: handleSelectIcon,
|
|
128
|
+
maxHeight
|
|
129
|
+
}),
|
|
130
|
+
!isSearching && providers.length === 1 && /* @__PURE__ */ jsx(virtualized_icon_grid_default, {
|
|
131
|
+
icons: filteredData,
|
|
132
|
+
onSelectIcon: handleSelectIcon,
|
|
133
|
+
maxHeight
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
var icon_picker_content_default = IconPickerContent;
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
export { icon_picker_content_default as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_IconPicker = require('./IconPicker.cjs');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { IconProvider, IconProviderLoader, IconProviderProps } from "./types.cjs";
|
|
2
|
+
import { IconPicker, IconPickerProps, IconPickerVariant } from "./IconPicker.cjs";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { IconProvider, IconProviderLoader, IconProviderProps } from "./types.js";
|
|
2
|
+
import { IconPicker, IconPickerProps, IconPickerVariant } from "./IconPicker.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IconPicker
|
|
1
|
+
import { IconPicker } from "./IconPicker.js";
|
|
@@ -1 +1,69 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_is_valid_provider = require('./utils/is-valid-provider.cjs');
|
|
3
|
+
let react = require("react");
|
|
4
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
5
|
+
|
|
6
|
+
//#region src/icon-selector/use-async-providers.ts
|
|
7
|
+
function useAsyncProviders(providers = []) {
|
|
8
|
+
const [state, setState] = (0, react.useState)({
|
|
9
|
+
resolved: [],
|
|
10
|
+
loading: false,
|
|
11
|
+
errors: []
|
|
12
|
+
});
|
|
13
|
+
const previousProvidersRef = (0, react.useRef)([]);
|
|
14
|
+
(0, react.useEffect)(() => {
|
|
15
|
+
let isMounted = true;
|
|
16
|
+
if (state.loading) return;
|
|
17
|
+
if (previousProvidersRef.current.length === providers.length && providers.every((p, i) => p === previousProvidersRef.current[i])) return;
|
|
18
|
+
previousProvidersRef.current = providers;
|
|
19
|
+
const loadProviders = async () => {
|
|
20
|
+
if (!providers.length) {
|
|
21
|
+
if (isMounted) setState({
|
|
22
|
+
resolved: [],
|
|
23
|
+
loading: false,
|
|
24
|
+
errors: []
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setState((prev) => ({
|
|
29
|
+
...prev,
|
|
30
|
+
loading: true,
|
|
31
|
+
errors: []
|
|
32
|
+
}));
|
|
33
|
+
const loaded = [];
|
|
34
|
+
const loadErrors = [];
|
|
35
|
+
const results = await Promise.allSettled(providers.map(async (p) => {
|
|
36
|
+
if (typeof p === "function") return p();
|
|
37
|
+
return p;
|
|
38
|
+
}));
|
|
39
|
+
for (const [index, result] of results.entries()) if (result.status === "fulfilled") {
|
|
40
|
+
const provider = result.value;
|
|
41
|
+
if (require_is_valid_provider.isValidProvider(provider)) loaded.push(provider);
|
|
42
|
+
else {
|
|
43
|
+
const err = /* @__PURE__ */ new Error(`Invalid provider at index ${index}: Missing required fields.`);
|
|
44
|
+
loadErrors.push(err);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
const err = result.reason instanceof Error ? result.reason : new Error(String(result.reason));
|
|
48
|
+
loadErrors.push(err);
|
|
49
|
+
}
|
|
50
|
+
setState({
|
|
51
|
+
resolved: loaded,
|
|
52
|
+
loading: false,
|
|
53
|
+
errors: loadErrors
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
loadProviders();
|
|
57
|
+
return () => {
|
|
58
|
+
isMounted = false;
|
|
59
|
+
};
|
|
60
|
+
}, [providers, state.loading]);
|
|
61
|
+
return {
|
|
62
|
+
providers: state.resolved,
|
|
63
|
+
isLoading: state.loading,
|
|
64
|
+
errors: state.errors
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
exports.useAsyncProviders = useAsyncProviders;
|
|
@@ -1 +1,67 @@
|
|
|
1
|
-
import{isValidProvider
|
|
1
|
+
import { isValidProvider } from "./utils/is-valid-provider.js";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/icon-selector/use-async-providers.ts
|
|
5
|
+
function useAsyncProviders(providers = []) {
|
|
6
|
+
const [state, setState] = useState({
|
|
7
|
+
resolved: [],
|
|
8
|
+
loading: false,
|
|
9
|
+
errors: []
|
|
10
|
+
});
|
|
11
|
+
const previousProvidersRef = useRef([]);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
let isMounted = true;
|
|
14
|
+
if (state.loading) return;
|
|
15
|
+
if (previousProvidersRef.current.length === providers.length && providers.every((p, i) => p === previousProvidersRef.current[i])) return;
|
|
16
|
+
previousProvidersRef.current = providers;
|
|
17
|
+
const loadProviders = async () => {
|
|
18
|
+
if (!providers.length) {
|
|
19
|
+
if (isMounted) setState({
|
|
20
|
+
resolved: [],
|
|
21
|
+
loading: false,
|
|
22
|
+
errors: []
|
|
23
|
+
});
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
setState((prev) => ({
|
|
27
|
+
...prev,
|
|
28
|
+
loading: true,
|
|
29
|
+
errors: []
|
|
30
|
+
}));
|
|
31
|
+
const loaded = [];
|
|
32
|
+
const loadErrors = [];
|
|
33
|
+
const results = await Promise.allSettled(providers.map(async (p) => {
|
|
34
|
+
if (typeof p === "function") return p();
|
|
35
|
+
return p;
|
|
36
|
+
}));
|
|
37
|
+
for (const [index, result] of results.entries()) if (result.status === "fulfilled") {
|
|
38
|
+
const provider = result.value;
|
|
39
|
+
if (isValidProvider(provider)) loaded.push(provider);
|
|
40
|
+
else {
|
|
41
|
+
const err = /* @__PURE__ */ new Error(`Invalid provider at index ${index}: Missing required fields.`);
|
|
42
|
+
loadErrors.push(err);
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
const err = result.reason instanceof Error ? result.reason : new Error(String(result.reason));
|
|
46
|
+
loadErrors.push(err);
|
|
47
|
+
}
|
|
48
|
+
setState({
|
|
49
|
+
resolved: loaded,
|
|
50
|
+
loading: false,
|
|
51
|
+
errors: loadErrors
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
loadProviders();
|
|
55
|
+
return () => {
|
|
56
|
+
isMounted = false;
|
|
57
|
+
};
|
|
58
|
+
}, [providers, state.loading]);
|
|
59
|
+
return {
|
|
60
|
+
providers: state.resolved,
|
|
61
|
+
isLoading: state.loading,
|
|
62
|
+
errors: state.errors
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { useAsyncProviders };
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/icon-selector/utils/is-valid-provider.ts
|
|
3
|
+
/**
|
|
4
|
+
* Validates if a value is a valid IconProvider structure
|
|
5
|
+
*/
|
|
6
|
+
function isValidProvider(value) {
|
|
7
|
+
return typeof value === "object" && value !== null && "prefix" in value && "icons" in value && "name" in value && typeof value.prefix === "string" && Array.isArray(value.icons);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.isValidProvider = isValidProvider;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/icon-selector/utils/is-valid-provider.ts
|
|
2
|
+
/**
|
|
3
|
+
* Validates if a value is a valid IconProvider structure
|
|
4
|
+
*/
|
|
5
|
+
function isValidProvider(value) {
|
|
6
|
+
return typeof value === "object" && value !== null && "prefix" in value && "icons" in value && "name" in value && typeof value.prefix === "string" && Array.isArray(value.icons);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { isValidProvider };
|
|
@@ -1 +1,137 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
5
|
+
let react = require("react");
|
|
6
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
9
|
+
let __iconify_react = require("@iconify/react");
|
|
10
|
+
__iconify_react = require_rolldown_runtime.__toESM(__iconify_react);
|
|
11
|
+
let __tanstack_react_virtual = require("@tanstack/react-virtual");
|
|
12
|
+
__tanstack_react_virtual = require_rolldown_runtime.__toESM(__tanstack_react_virtual);
|
|
13
|
+
|
|
14
|
+
//#region src/icon-selector/virtualized-icon-grid.tsx
|
|
15
|
+
const CELL_SIZE_DEFAULT = 80;
|
|
16
|
+
const ROW_HEIGHT = 80;
|
|
17
|
+
const DEFAULT_HEIGHT = 480;
|
|
18
|
+
const MIN_COLUMNS = 3;
|
|
19
|
+
const IconCell = react.default.memo(({ iconName, onSelectIcon }) => {
|
|
20
|
+
if (!iconName) return null;
|
|
21
|
+
const displayName = iconName.split(":")[1] ?? iconName;
|
|
22
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
23
|
+
type: "button",
|
|
24
|
+
onClick: () => onSelectIcon(iconName),
|
|
25
|
+
className: "w-full h-full flex flex-col items-center justify-center gap-1 rounded-md border border-transparent hover:border-primary hover:bg-accent transition-colors p-1",
|
|
26
|
+
title: iconName,
|
|
27
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__iconify_react.Icon, {
|
|
28
|
+
icon: iconName,
|
|
29
|
+
width: "24",
|
|
30
|
+
height: "24"
|
|
31
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32
|
+
className: "truncate text-xs text-muted-foreground max-w-full",
|
|
33
|
+
children: displayName
|
|
34
|
+
})]
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
IconCell.displayName = "IconCell";
|
|
38
|
+
const VirtualizedIconGrid = ({ icons, onSelectIcon, maxHeight = DEFAULT_HEIGHT, columnCount: providedColumnCount, cellSize = CELL_SIZE_DEFAULT }) => {
|
|
39
|
+
const scrollableRef = (0, react.useRef)(null);
|
|
40
|
+
const containerRef = (0, react.useRef)(null);
|
|
41
|
+
const [containerWidth, setContainerWidth] = (0, react.useState)(0);
|
|
42
|
+
const columnCount = (0, react.useMemo)(() => {
|
|
43
|
+
if (providedColumnCount !== void 0 && providedColumnCount > 0) return providedColumnCount;
|
|
44
|
+
if (containerWidth === 0) return MIN_COLUMNS;
|
|
45
|
+
return Math.max(MIN_COLUMNS, Math.floor(containerWidth / cellSize));
|
|
46
|
+
}, [
|
|
47
|
+
containerWidth,
|
|
48
|
+
cellSize,
|
|
49
|
+
providedColumnCount
|
|
50
|
+
]);
|
|
51
|
+
(0, react.useEffect)(() => {
|
|
52
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
53
|
+
for (const entry of entries) setContainerWidth(entry.contentRect.width);
|
|
54
|
+
});
|
|
55
|
+
if (containerRef.current) resizeObserver.observe(containerRef.current);
|
|
56
|
+
return () => {
|
|
57
|
+
resizeObserver.disconnect();
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
60
|
+
const height = typeof maxHeight === "number" ? maxHeight : DEFAULT_HEIGHT;
|
|
61
|
+
const rowVirtualizer = (0, __tanstack_react_virtual.useVirtualizer)({
|
|
62
|
+
count: (0, react.useMemo)(() => Math.ceil(icons.length / columnCount), [icons.length, columnCount]),
|
|
63
|
+
getScrollElement: () => scrollableRef.current,
|
|
64
|
+
estimateSize: () => ROW_HEIGHT,
|
|
65
|
+
overscan: 10
|
|
66
|
+
});
|
|
67
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
68
|
+
const totalSize = rowVirtualizer.getTotalSize();
|
|
69
|
+
const handleSelectIcon = (0, react.useCallback)((iconName) => {
|
|
70
|
+
onSelectIcon(iconName);
|
|
71
|
+
}, [onSelectIcon]);
|
|
72
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
73
|
+
ref: containerRef,
|
|
74
|
+
style: {
|
|
75
|
+
height,
|
|
76
|
+
width: "100%",
|
|
77
|
+
overflow: "hidden",
|
|
78
|
+
position: "relative",
|
|
79
|
+
display: "flex",
|
|
80
|
+
flexDirection: "column"
|
|
81
|
+
},
|
|
82
|
+
children: containerRef.current && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
83
|
+
ref: scrollableRef,
|
|
84
|
+
style: {
|
|
85
|
+
height: "100%",
|
|
86
|
+
width: "100%",
|
|
87
|
+
overflow: "auto",
|
|
88
|
+
flex: 1
|
|
89
|
+
},
|
|
90
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
91
|
+
style: {
|
|
92
|
+
height: `${totalSize}px`,
|
|
93
|
+
width: "100%",
|
|
94
|
+
position: "relative"
|
|
95
|
+
},
|
|
96
|
+
children: virtualRows.map((virtualRow) => {
|
|
97
|
+
const startIndex = virtualRow.index * columnCount;
|
|
98
|
+
const endIndex = Math.min(startIndex + columnCount, icons.length);
|
|
99
|
+
const rowIcons = icons.slice(startIndex, endIndex);
|
|
100
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
101
|
+
style: {
|
|
102
|
+
position: "absolute",
|
|
103
|
+
top: 0,
|
|
104
|
+
left: 0,
|
|
105
|
+
width: "100%",
|
|
106
|
+
height: `${virtualRow.size}px`,
|
|
107
|
+
transform: `translateY(${virtualRow.start}px)`
|
|
108
|
+
},
|
|
109
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
110
|
+
style: {
|
|
111
|
+
display: "grid",
|
|
112
|
+
gridTemplateColumns: `repeat(${columnCount}, 1fr)`,
|
|
113
|
+
height: "100%",
|
|
114
|
+
width: "100%",
|
|
115
|
+
gap: "0"
|
|
116
|
+
},
|
|
117
|
+
children: rowIcons.map((iconName) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
118
|
+
style: {
|
|
119
|
+
minHeight: "100%",
|
|
120
|
+
minWidth: "0"
|
|
121
|
+
},
|
|
122
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconCell, {
|
|
123
|
+
iconName,
|
|
124
|
+
onSelectIcon: handleSelectIcon
|
|
125
|
+
})
|
|
126
|
+
}, iconName))
|
|
127
|
+
})
|
|
128
|
+
}, virtualRow.key);
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
var virtualized_icon_grid_default = VirtualizedIconGrid;
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
exports.default = virtualized_icon_grid_default;
|