@powerhousedao/connect 4.1.0-dev.106 → 4.1.0-dev.108
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/AddDriveModal-7r-BM-yT.js +1 -0
- package/dist/assets/ClearStorageModal-9gL_vLgY.js +1 -0
- package/dist/assets/CookiesPolicyModal-BdPCCPNX.js +1 -0
- package/dist/assets/CreateDocumentModal-C09c_nGK.js +1 -0
- package/dist/assets/DebugSettingsModal-BkU8bK-I.js +1 -0
- package/dist/assets/DeleteDriveModal-Ctt3VSe4.js +1 -0
- package/dist/assets/DeleteItemModal-DZLHSQPf.js +1 -0
- package/dist/assets/DisclaimerModal-BTFCt2N-.js +1 -0
- package/dist/assets/DriveSettingsModal-B18X9rkK.js +1 -0
- package/dist/assets/ExportDocumentWithErrorsModal-B_tnIZE0.js +1 -0
- package/dist/assets/SettingsModal-BDHjn5Ac.js +1 -0
- package/dist/assets/UpgradeDriveModal-kyIQAIjP.js +1 -0
- package/dist/assets/common-8r_LaZs4.css +1 -0
- package/dist/assets/common-n2B-GsjO.js +1 -0
- package/dist/assets/config-CU-aFfVJ.js +1 -0
- package/dist/assets/design_system-CZfmC8Ij.js +45 -0
- package/dist/assets/design_system_connect-DHQbQvgv.js +53 -0
- package/dist/assets/document_drive-CP6paqKN.js +305 -0
- package/dist/assets/document_engineering-DojqH50p.js +1 -0
- package/dist/assets/document_model-DLxR7ZLO.js +230 -0
- package/dist/assets/document_model_editor-ButtI7kP.js +2 -0
- package/dist/assets/drive_explorer-IB_BS5Au.js +2 -0
- package/dist/assets/editor-CgH7LMsL.js +105 -0
- package/dist/assets/editor-ClAkqmdQ.js +1 -0
- package/dist/assets/graphql-BS4Brs_E.js +75 -0
- package/dist/assets/graphql_request-9RNJ00DB.js +3 -0
- package/dist/assets/hmr-LMNkvzP7.js +1 -0
- package/dist/assets/index-BAlx9zX9.js +18 -0
- package/dist/assets/index-Br7E7qjt.css +1 -0
- package/dist/assets/reactor_browser-BbZdm6Aa.js +25 -0
- package/dist/assets/sentry_browser-BFJlXALZ.js +498 -0
- package/dist/assets/sentry_react-C4W8xEsl.js +3 -0
- package/dist/assets/virtual_ph_external-packages-CM1tCR4L.js +1 -0
- package/dist/assets/zod-C6yxFxyo.js +1 -0
- package/dist/index.html +17 -2
- package/heroku/config/nginx.conf.template +7 -18
- package/lib/package.copy.json +27 -57
- package/lib/src/components/analytics.js +1 -1
- package/lib/src/components/analytics.js.map +1 -1
- package/lib/src/components/app-loader.d.ts +1 -1
- package/lib/src/components/app-loader.d.ts.map +1 -1
- package/lib/src/components/app-loader.js +2 -5
- package/lib/src/components/app-loader.js.map +1 -1
- package/lib/src/components/app-skeleton.d.ts.map +1 -1
- package/lib/src/components/app-skeleton.js +1 -1
- package/lib/src/components/app-skeleton.js.map +1 -1
- package/lib/src/components/app.d.ts.map +1 -1
- package/lib/src/components/app.js +3 -4
- package/lib/src/components/app.js.map +1 -1
- package/lib/src/components/cookie-banner.d.ts.map +1 -1
- package/lib/src/components/cookie-banner.js +3 -4
- package/lib/src/components/cookie-banner.js.map +1 -1
- package/lib/src/components/document-editor-container.js +2 -2
- package/lib/src/components/document-editor-container.js.map +1 -1
- package/lib/src/components/drive-editor-container.js +2 -2
- package/lib/src/components/drive-editor-container.js.map +1 -1
- package/lib/src/components/editor-loader.d.ts +1 -1
- package/lib/src/components/editor-loader.d.ts.map +1 -1
- package/lib/src/components/editor-loader.js +1 -1
- package/lib/src/components/editor-loader.js.map +1 -1
- package/lib/src/components/editors.js +2 -2
- package/lib/src/components/editors.js.map +1 -1
- package/lib/src/components/footer.js +3 -2
- package/lib/src/components/footer.js.map +1 -1
- package/lib/src/components/index.d.ts +1 -2
- package/lib/src/components/index.d.ts.map +1 -1
- package/lib/src/components/index.js +1 -2
- package/lib/src/components/index.js.map +1 -1
- package/lib/src/components/login.js +1 -1
- package/lib/src/components/login.js.map +1 -1
- package/lib/src/components/modal/index.d.ts +17 -1
- package/lib/src/components/modal/index.d.ts.map +1 -1
- package/lib/src/components/modal/index.js +17 -1
- package/lib/src/components/modal/index.js.map +1 -1
- package/lib/src/components/modal/modals/AddDriveModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/AddDriveModal.js +2 -1
- package/lib/src/components/modal/modals/AddDriveModal.js.map +1 -1
- package/lib/src/components/modal/modals/ClearStorageModal.js +2 -2
- package/lib/src/components/modal/modals/ClearStorageModal.js.map +1 -1
- package/lib/src/components/modal/modals/CookiesPolicyModal.js +1 -1
- package/lib/src/components/modal/modals/CookiesPolicyModal.js.map +1 -1
- package/lib/src/components/modal/modals/CreateDocumentModal.js +1 -1
- package/lib/src/components/modal/modals/CreateDocumentModal.js.map +1 -1
- package/lib/src/components/modal/modals/DebugSettingsModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/DebugSettingsModal.js +3 -2
- package/lib/src/components/modal/modals/DebugSettingsModal.js.map +1 -1
- package/lib/src/components/modal/modals/DeleteDriveModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/DeleteDriveModal.js +2 -1
- package/lib/src/components/modal/modals/DeleteDriveModal.js.map +1 -1
- package/lib/src/components/modal/modals/DeleteItemModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/DeleteItemModal.js +2 -1
- package/lib/src/components/modal/modals/DeleteItemModal.js.map +1 -1
- package/lib/src/components/modal/modals/DisclaimerModal.js +1 -1
- package/lib/src/components/modal/modals/DisclaimerModal.js.map +1 -1
- package/lib/src/components/modal/modals/DriveSettingsModal.js +2 -2
- package/lib/src/components/modal/modals/DriveSettingsModal.js.map +1 -1
- package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.js +1 -1
- package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.js.map +1 -1
- package/lib/src/components/modal/modals/SettingsModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/SettingsModal.js +4 -6
- package/lib/src/components/modal/modals/SettingsModal.js.map +1 -1
- package/lib/src/components/modal/modals/UpgradeDriveModal.js +1 -1
- package/lib/src/components/modal/modals/UpgradeDriveModal.js.map +1 -1
- package/lib/src/components/modal/modals/settings/about.js +1 -1
- package/lib/src/components/modal/modals/settings/about.js.map +1 -1
- package/lib/src/components/modal/modals/settings/danger-zone.js +1 -1
- package/lib/src/components/modal/modals/settings/danger-zone.js.map +1 -1
- package/lib/src/components/modal/modals/settings/default-editor.js +1 -1
- package/lib/src/components/modal/modals/settings/default-editor.js.map +1 -1
- package/lib/src/components/modal/modals/settings/package-manager.d.ts +1 -1
- package/lib/src/components/modal/modals/settings/package-manager.d.ts.map +1 -1
- package/lib/src/components/modal/modals/settings/package-manager.js +4 -5
- package/lib/src/components/modal/modals/settings/package-manager.js.map +1 -1
- package/lib/src/components/ph-logo.js +1 -1
- package/lib/src/components/ph-logo.js.map +1 -1
- package/lib/src/components/reload-connect-toast.d.ts.map +1 -0
- package/lib/src/components/reload-connect-toast.js.map +1 -0
- package/lib/src/components/root.js +1 -1
- package/lib/src/components/root.js.map +1 -1
- package/lib/src/components/router.js +1 -1
- package/lib/src/components/router.js.map +1 -1
- package/lib/src/components/search-bar.d.ts.map +1 -1
- package/lib/src/components/search-bar.js +2 -1
- package/lib/src/components/search-bar.js.map +1 -1
- package/lib/src/components/sidebar.d.ts.map +1 -1
- package/lib/src/components/sidebar.js +3 -2
- package/lib/src/components/sidebar.js.map +1 -1
- package/lib/src/context/sentry-provider.js +1 -1
- package/lib/src/context/sentry-provider.js.map +1 -1
- package/lib/src/feature-flags.d.ts.map +1 -0
- package/lib/src/feature-flags.js.map +1 -0
- package/lib/src/globals.d.ts +1 -1
- package/lib/src/globals.d.ts.map +1 -1
- package/lib/src/hooks/useCheckLatestVersion.js +3 -3
- package/lib/src/hooks/useCheckLatestVersion.js.map +1 -1
- package/lib/src/index.d.ts +1 -8
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +1 -8
- package/lib/src/index.js.map +1 -1
- package/lib/src/main.js +1 -1
- package/lib/src/main.js.map +1 -1
- package/lib/src/pages/content.d.ts.map +1 -1
- package/lib/src/pages/content.js +2 -3
- package/lib/src/pages/content.js.map +1 -1
- package/lib/src/pages/index.d.ts +2 -1
- package/lib/src/pages/index.d.ts.map +1 -1
- package/lib/src/pages/index.js +2 -1
- package/lib/src/pages/index.js.map +1 -1
- package/lib/src/services/index.d.ts +6 -2
- package/lib/src/services/index.d.ts.map +1 -1
- package/lib/src/services/index.js +5 -2
- package/lib/src/services/index.js.map +1 -1
- package/lib/src/services/toast.d.ts +2 -2
- package/lib/src/services/toast.d.ts.map +1 -1
- package/lib/src/services/toast.js +1 -1
- package/lib/src/services/toast.js.map +1 -1
- package/lib/src/store/document-model.d.ts.map +1 -1
- package/lib/src/store/document-model.js +3 -3
- package/lib/src/store/document-model.js.map +1 -1
- package/lib/src/store/editor.d.ts +2 -2
- package/lib/src/store/editor.d.ts.map +1 -1
- package/lib/src/store/editor.js +6 -6
- package/lib/src/store/editor.js.map +1 -1
- package/lib/src/store/reactor.d.ts.map +1 -1
- package/lib/src/store/reactor.js +6 -21
- package/lib/src/store/reactor.js.map +1 -1
- package/lib/src/utils/drive-sections.d.ts +1 -1
- package/lib/src/utils/drive-sections.d.ts.map +1 -1
- package/lib/src/utils/drive-sections.js +1 -1
- package/lib/src/utils/drive-sections.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/vite.config.d.ts.map +1 -1
- package/lib/vite.config.js +23 -0
- package/lib/vite.config.js.map +1 -1
- package/package.copy.json +27 -57
- package/package.json +34 -64
- package/dist/assets/AddDriveModal-CtZf_obp.js +0 -248
- package/dist/assets/AddDriveModal-CtZf_obp.js.map +0 -1
- package/dist/assets/ClearStorageModal-C2hbvDkF.js +0 -46
- package/dist/assets/ClearStorageModal-C2hbvDkF.js.map +0 -1
- package/dist/assets/CookiesPolicyModal-Cd7uBIEB.js +0 -34
- package/dist/assets/CookiesPolicyModal-Cd7uBIEB.js.map +0 -1
- package/dist/assets/CreateDocumentModal-Dgkc55q6.js +0 -69
- package/dist/assets/CreateDocumentModal-Dgkc55q6.js.map +0 -1
- package/dist/assets/DebugSettingsModal-CPmyP1YW.js +0 -5134
- package/dist/assets/DebugSettingsModal-CPmyP1YW.js.map +0 -1
- package/dist/assets/DeleteDriveModal-apg0MYPC.js +0 -55
- package/dist/assets/DeleteDriveModal-apg0MYPC.js.map +0 -1
- package/dist/assets/DeleteItemModal-D-z5CndZ.js +0 -47
- package/dist/assets/DeleteItemModal-D-z5CndZ.js.map +0 -1
- package/dist/assets/DisclaimerModal-B1Jtt1cj.js +0 -21
- package/dist/assets/DisclaimerModal-B1Jtt1cj.js.map +0 -1
- package/dist/assets/DriveSettingsModal-CnXO-QWT.js +0 -103
- package/dist/assets/DriveSettingsModal-CnXO-QWT.js.map +0 -1
- package/dist/assets/ExportDocumentWithErrorsModal-HI8wR1ha.js +0 -44
- package/dist/assets/ExportDocumentWithErrorsModal-HI8wR1ha.js.map +0 -1
- package/dist/assets/SettingsModal-W6c3EI1V.js +0 -1723
- package/dist/assets/SettingsModal-W6c3EI1V.js.map +0 -1
- package/dist/assets/UpgradeDriveModal-CzMEFvzJ.js +0 -40
- package/dist/assets/UpgradeDriveModal-CzMEFvzJ.js.map +0 -1
- package/dist/assets/ccip-kd0oo78s.js +0 -168
- package/dist/assets/ccip-kd0oo78s.js.map +0 -1
- package/dist/assets/confirmation-modal-BRCSDFfA.js +0 -16
- package/dist/assets/confirmation-modal-BRCSDFfA.js.map +0 -1
- package/dist/assets/disclosure-Cdsd0yEm.js +0 -9
- package/dist/assets/disclosure-Cdsd0yEm.js.map +0 -1
- package/dist/assets/drive-by-id-Dtyl2hjB.js +0 -14
- package/dist/assets/drive-by-id-Dtyl2hjB.js.map +0 -1
- package/dist/assets/dropdown-menu-BJNDsW2h.js +0 -1026
- package/dist/assets/dropdown-menu-BJNDsW2h.js.map +0 -1
- package/dist/assets/editor-BNCF82f5.js +0 -47585
- package/dist/assets/editor-BNCF82f5.js.map +0 -1
- package/dist/assets/editor-DLJCk_iy.js +0 -416
- package/dist/assets/editor-DLJCk_iy.js.map +0 -1
- package/dist/assets/form-input-CPnbINdu.js +0 -11
- package/dist/assets/form-input-CPnbINdu.js.map +0 -1
- package/dist/assets/hmr-DO4QUuY_.js +0 -5
- package/dist/assets/hmr-DO4QUuY_.js.map +0 -1
- package/dist/assets/hoist-non-react-statics.cjs-Dz4HIRQF.js +0 -224
- package/dist/assets/hoist-non-react-statics.cjs-Dz4HIRQF.js.map +0 -1
- package/dist/assets/index-7h14d2-k.js +0 -45
- package/dist/assets/index-7h14d2-k.js.map +0 -1
- package/dist/assets/index-CtewK_c6.js +0 -183
- package/dist/assets/index-CtewK_c6.js.map +0 -1
- package/dist/assets/index-DK-Td17X.js +0 -92921
- package/dist/assets/index-DK-Td17X.js.map +0 -1
- package/dist/assets/index-DOrl22sv.css +0 -6263
- package/dist/assets/index-DXMjnAPx.js +0 -285
- package/dist/assets/index-DXMjnAPx.js.map +0 -1
- package/dist/assets/index-PvEUoqAt.js +0 -25570
- package/dist/assets/index-PvEUoqAt.js.map +0 -1
- package/dist/assets/index.esm-BTzn889G.js +0 -1801
- package/dist/assets/index.esm-BTzn889G.js.map +0 -1
- package/dist/assets/options-Bqnui46O.js +0 -81
- package/dist/assets/options-Bqnui46O.js.map +0 -1
- package/dist/assets/read-required-modal-DyeA1PS1.js +0 -44
- package/dist/assets/read-required-modal-DyeA1PS1.js.map +0 -1
- package/dist/assets/toggle-BeBMssLx.js +0 -33
- package/dist/assets/toggle-BeBMssLx.js.map +0 -1
- package/dist/assets/virtual_ph_external-packages-DawtJ3DU.js +0 -8
- package/dist/assets/virtual_ph_external-packages-DawtJ3DU.js.map +0 -1
- package/lib/feature-flags.d.ts.map +0 -1
- package/lib/feature-flags.js.map +0 -1
- package/lib/src/components/modal/modals/settings/index.d.ts +0 -5
- package/lib/src/components/modal/modals/settings/index.d.ts.map +0 -1
- package/lib/src/components/modal/modals/settings/index.js +0 -5
- package/lib/src/components/modal/modals/settings/index.js.map +0 -1
- package/lib/src/components/toast/index.d.ts +0 -2
- package/lib/src/components/toast/index.d.ts.map +0 -1
- package/lib/src/components/toast/index.js +0 -2
- package/lib/src/components/toast/index.js.map +0 -1
- package/lib/src/components/toast/reload-connect-toast.d.ts.map +0 -1
- package/lib/src/components/toast/reload-connect-toast.js.map +0 -1
- package/lib/src/pages/demo/index.d.ts +0 -2
- package/lib/src/pages/demo/index.d.ts.map +0 -1
- package/lib/src/pages/demo/index.js +0 -2
- package/lib/src/pages/demo/index.js.map +0 -1
- package/lib/src/services/renown/index.d.ts +0 -4
- package/lib/src/services/renown/index.d.ts.map +0 -1
- package/lib/src/services/renown/index.js +0 -4
- package/lib/src/services/renown/index.js.map +0 -1
- package/lib/src/services/storage/index.d.ts +0 -4
- package/lib/src/services/storage/index.d.ts.map +0 -1
- package/lib/src/services/storage/index.js +0 -4
- package/lib/src/services/storage/index.js.map +0 -1
- /package/lib/src/components/{toast/reload-connect-toast.d.ts → reload-connect-toast.d.ts} +0 -0
- /package/lib/src/components/{toast/reload-connect-toast.js → reload-connect-toast.js} +0 -0
- /package/lib/{feature-flags.d.ts → src/feature-flags.d.ts} +0 -0
- /package/lib/{feature-flags.js → src/feature-flags.js} +0 -0
|
@@ -1,1723 +0,0 @@
|
|
|
1
|
-
import { r as reactExports, j as jsxRuntimeExports, a4 as Slot, a5 as cn$1, a6 as Provider, I as Icon, a7 as useId, a8 as Primitive, a9 as Root, aa as Portal, ab as Overlay, ac as Content$1, ad as composeRefs, R as React, ae as useMediaQuery, af as useDebounceCallback, ag as Popover, ah as PopoverAnchor, ai as PopoverContent, t as twMerge, aj as clsx, ak as PopoverTrigger, al as Root3, am as Trigger, an as Portal$1, ao as Content2, ap as objectType, aq as recordType, ar as stringType, as as capitalCase, at as getDriveSharingType, P as PowerhouseButton, M as Modal, E as connectConfig, G as useDrives, m as showPHModal, N as deleteDrive, s as setSelectedDrive, au as useVetraPackages, av as makeVetraPackageManifest, aw as addExternalPackage, ax as removeExternalPackage, a as usePHModal, i as t, e as closePHModal } from "./index-DK-Td17X.js";
|
|
2
|
-
import { D as Disclosure } from "./disclosure-Cdsd0yEm.js";
|
|
3
|
-
import { C as ConnectDropdownMenu } from "./dropdown-menu-BJNDsW2h.js";
|
|
4
|
-
import { a as useFormContext, b as useFormState, C as Controller } from "./index.esm-BTzn889G.js";
|
|
5
|
-
import { c as cva } from "./index-7h14d2-k.js";
|
|
6
|
-
import "./index-DXMjnAPx.js";
|
|
7
|
-
const PH_PACKAGES = [
|
|
8
|
-
{
|
|
9
|
-
packageName: "@sky-ph/atlas",
|
|
10
|
-
version: "latest",
|
|
11
|
-
provider: "npm",
|
|
12
|
-
url: "https://www.npmjs.com/package/@sky-ph/atlas"
|
|
13
|
-
}
|
|
14
|
-
];
|
|
15
|
-
const buttonVariants = cva(cn$1("inline-flex items-center justify-center gap-2", "whitespace-nowrap rounded-md text-sm font-medium", "transition-colors", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2", "disabled:pointer-events-none", "[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0"), {
|
|
16
|
-
variants: {
|
|
17
|
-
variant: {
|
|
18
|
-
default: "",
|
|
19
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
20
|
-
ghost: "hover:bg-accent hover:text-accent-foreground"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
defaultVariants: {
|
|
24
|
-
variant: "default"
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
const Button = reactExports.forwardRef(({ variant, className, asChild = false, ...props }, ref) => {
|
|
28
|
-
const Comp = asChild ? Slot : "button";
|
|
29
|
-
return jsxRuntimeExports.jsx(Comp, { className: cn$1(buttonVariants({ variant, className })), ref, ...props });
|
|
30
|
-
});
|
|
31
|
-
const FormLabel = ({ children, required, disabled, description: description2, hasError, inline, className, ...htmlLabelProps }) => {
|
|
32
|
-
const classes = cn$1("inline-flex items-center text-sm font-medium", inline ? "leading-[22px]" : "leading-4", `text-gray-900 ${inline ? "dark:text-gray-400" : "dark:text-gray-50"}`, hasError && "group-hover:!text-red-900 dark:group-hover:!text-red-900", hasError && inline && "text-red-800 dark:text-red-800", hasError && !inline && "text-red-900 dark:text-red-900", disabled && `cursor-not-allowed text-gray-700 ${inline ? "dark:text-gray-600" : "dark:text-gray-300"}`, inline ? !disabled && "group-hover:text-gray-900 dark:group-hover:text-slate-50" : "mb-[3px]", className);
|
|
33
|
-
if (!children) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
const extraProps = {
|
|
37
|
-
...htmlLabelProps
|
|
38
|
-
};
|
|
39
|
-
return jsxRuntimeExports.jsxs("label", { className: classes, ...extraProps, children: [children, required && jsxRuntimeExports.jsx("span", { className: cn$1("ml-1 text-gray-800 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-slate-50", hasError && `${inline ? "!text-red-800" : "!text-red-900"} group-hover:!text-red-900`), children: "*" }), description2 && jsxRuntimeExports.jsx(Provider, { children: jsxRuntimeExports.jsx(Tooltip, { content: description2, children: jsxRuntimeExports.jsx(Icon, { name: "CircleInfo", size: 16, className: cn$1("ml-1 cursor-pointer text-gray-600 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-500", disabled && "text-gray-500") }) }) })] });
|
|
40
|
-
};
|
|
41
|
-
const defaultElement = "p";
|
|
42
|
-
const FormMessage = ({ children, type: type2 = "info", as, className, ...props }) => {
|
|
43
|
-
const Component = as || defaultElement;
|
|
44
|
-
const typeClasses = {
|
|
45
|
-
error: "text-red-900 dark:text-red-900",
|
|
46
|
-
info: "text-blue-900 dark:text-blue-900",
|
|
47
|
-
warning: "text-yellow-900 dark:text-yellow-900"
|
|
48
|
-
};
|
|
49
|
-
const classes = cn$1("mb-0 inline-flex items-center text-xs font-medium", typeClasses[type2], className);
|
|
50
|
-
return jsxRuntimeExports.jsx(Component, { "data-type": type2, className: classes, ...props, children });
|
|
51
|
-
};
|
|
52
|
-
const FormMessageList = ({ messages, type: type2 = "info", className, ...props }) => {
|
|
53
|
-
if (messages.length === 0) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
if (messages.length === 1) {
|
|
57
|
-
return jsxRuntimeExports.jsx(FormMessage, { type: type2, ...props, children: messages[0] });
|
|
58
|
-
}
|
|
59
|
-
const typeClasses = {
|
|
60
|
-
error: "before:bg-red-900 dark:before:bg-red-900",
|
|
61
|
-
info: "before:bg-blue-900 dark:before:bg-blue-900",
|
|
62
|
-
warning: "before:bg-orange-900 dark:before:bg-orange-900"
|
|
63
|
-
};
|
|
64
|
-
return jsxRuntimeExports.jsx("ul", { className: cn$1("flex flex-col gap-1", className), ...props, children: messages.map((message) => jsxRuntimeExports.jsx(FormMessage, { as: "li", type: type2, className: cn$1(
|
|
65
|
-
// Layout
|
|
66
|
-
"relative pl-4",
|
|
67
|
-
// Visual styles
|
|
68
|
-
"before:absolute before:left-0 before:top-[0.4em] before:size-2 before:rounded-full",
|
|
69
|
-
typeClasses[type2]
|
|
70
|
-
), children: message }, message)) });
|
|
71
|
-
};
|
|
72
|
-
var U = 1, Y$1 = 0.9, H = 0.8, J = 0.17, p = 0.1, u = 0.999, $ = 0.9999;
|
|
73
|
-
var k$1 = 0.99, m = /[\\\/_+.#"@\[\(\{&]/, B$1 = /[\\\/_+.#"@\[\(\{&]/g, K$1 = /[\s-]/, X = /[\s-]/g;
|
|
74
|
-
function G(_, C, h, P2, A, f, O) {
|
|
75
|
-
if (f === C.length) return A === _.length ? U : k$1;
|
|
76
|
-
var T2 = `${A},${f}`;
|
|
77
|
-
if (O[T2] !== void 0) return O[T2];
|
|
78
|
-
for (var L2 = P2.charAt(f), c = h.indexOf(L2, A), S = 0, E, N2, R, M; c >= 0; ) E = G(_, C, h, P2, c + 1, f + 1, O), E > S && (c === A ? E *= U : m.test(_.charAt(c - 1)) ? (E *= H, R = _.slice(A, c - 1).match(B$1), R && A > 0 && (E *= Math.pow(u, R.length))) : K$1.test(_.charAt(c - 1)) ? (E *= Y$1, M = _.slice(A, c - 1).match(X), M && A > 0 && (E *= Math.pow(u, M.length))) : (E *= J, A > 0 && (E *= Math.pow(u, c - A))), _.charAt(c) !== C.charAt(f) && (E *= $)), (E < p && h.charAt(c - 1) === P2.charAt(f + 1) || P2.charAt(f + 1) === P2.charAt(f) && h.charAt(c - 1) !== P2.charAt(f)) && (N2 = G(_, C, h, P2, c + 1, f + 2, O), N2 * p > E && (E = N2 * p)), E > S && (S = E), c = h.indexOf(L2, c + 1);
|
|
79
|
-
return O[T2] = S, S;
|
|
80
|
-
}
|
|
81
|
-
function D(_) {
|
|
82
|
-
return _.toLowerCase().replace(X, " ");
|
|
83
|
-
}
|
|
84
|
-
function W(_, C, h) {
|
|
85
|
-
return _ = h && h.length > 0 ? `${_ + " " + h.join(" ")}` : _, G(_, C, D(_), D(C), 0, 0, {});
|
|
86
|
-
}
|
|
87
|
-
var N = '[cmdk-group=""]', Y = '[cmdk-group-items=""]', be = '[cmdk-group-heading=""]', le = '[cmdk-item=""]', ce = `${le}:not([aria-disabled="true"])`, Z = "cmdk-item-select", T = "data-value", Re = (r, o, n) => W(r, o, n), ue = reactExports.createContext(void 0), K = () => reactExports.useContext(ue), de = reactExports.createContext(void 0), ee = () => reactExports.useContext(de), fe = reactExports.createContext(void 0), me = reactExports.forwardRef((r, o) => {
|
|
88
|
-
let n = L(() => {
|
|
89
|
-
var e, a;
|
|
90
|
-
return { search: "", value: (a = (e = r.value) != null ? e : r.defaultValue) != null ? a : "", selectedItemId: void 0, filtered: { count: 0, items: /* @__PURE__ */ new Map(), groups: /* @__PURE__ */ new Set() } };
|
|
91
|
-
}), u2 = L(() => /* @__PURE__ */ new Set()), c = L(() => /* @__PURE__ */ new Map()), d = L(() => /* @__PURE__ */ new Map()), f = L(() => /* @__PURE__ */ new Set()), p2 = pe(r), { label: b, children: m2, value: R, onValueChange: x, filter: C, shouldFilter: S, loop: A, disablePointerSelection: ge = false, vimBindings: j = true, ...O } = r, $2 = useId(), q = useId(), _ = useId(), I = reactExports.useRef(null), v = ke();
|
|
92
|
-
k(() => {
|
|
93
|
-
if (R !== void 0) {
|
|
94
|
-
let e = R.trim();
|
|
95
|
-
n.current.value = e, E.emit();
|
|
96
|
-
}
|
|
97
|
-
}, [R]), k(() => {
|
|
98
|
-
v(6, ne);
|
|
99
|
-
}, []);
|
|
100
|
-
let E = reactExports.useMemo(() => ({ subscribe: (e) => (f.current.add(e), () => f.current.delete(e)), snapshot: () => n.current, setState: (e, a, s) => {
|
|
101
|
-
var i, l, g, y;
|
|
102
|
-
if (!Object.is(n.current[e], a)) {
|
|
103
|
-
if (n.current[e] = a, e === "search") J2(), z(), v(1, W2);
|
|
104
|
-
else if (e === "value") {
|
|
105
|
-
if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
|
|
106
|
-
let h = document.getElementById(_);
|
|
107
|
-
h ? h.focus() : (i = document.getElementById($2)) == null || i.focus();
|
|
108
|
-
}
|
|
109
|
-
if (v(7, () => {
|
|
110
|
-
var h;
|
|
111
|
-
n.current.selectedItemId = (h = M()) == null ? void 0 : h.id, E.emit();
|
|
112
|
-
}), s || v(5, ne), ((l = p2.current) == null ? void 0 : l.value) !== void 0) {
|
|
113
|
-
let h = a != null ? a : "";
|
|
114
|
-
(y = (g = p2.current).onValueChange) == null || y.call(g, h);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
E.emit();
|
|
119
|
-
}
|
|
120
|
-
}, emit: () => {
|
|
121
|
-
f.current.forEach((e) => e());
|
|
122
|
-
} }), []), U2 = reactExports.useMemo(() => ({ value: (e, a, s) => {
|
|
123
|
-
var i;
|
|
124
|
-
a !== ((i = d.current.get(e)) == null ? void 0 : i.value) && (d.current.set(e, { value: a, keywords: s }), n.current.filtered.items.set(e, te(a, s)), v(2, () => {
|
|
125
|
-
z(), E.emit();
|
|
126
|
-
}));
|
|
127
|
-
}, item: (e, a) => (u2.current.add(e), a && (c.current.has(a) ? c.current.get(a).add(e) : c.current.set(a, /* @__PURE__ */ new Set([e]))), v(3, () => {
|
|
128
|
-
J2(), z(), n.current.value || W2(), E.emit();
|
|
129
|
-
}), () => {
|
|
130
|
-
d.current.delete(e), u2.current.delete(e), n.current.filtered.items.delete(e);
|
|
131
|
-
let s = M();
|
|
132
|
-
v(4, () => {
|
|
133
|
-
J2(), (s == null ? void 0 : s.getAttribute("id")) === e && W2(), E.emit();
|
|
134
|
-
});
|
|
135
|
-
}), group: (e) => (c.current.has(e) || c.current.set(e, /* @__PURE__ */ new Set()), () => {
|
|
136
|
-
d.current.delete(e), c.current.delete(e);
|
|
137
|
-
}), filter: () => p2.current.shouldFilter, label: b || r["aria-label"], getDisablePointerSelection: () => p2.current.disablePointerSelection, listId: $2, inputId: _, labelId: q, listInnerRef: I }), []);
|
|
138
|
-
function te(e, a) {
|
|
139
|
-
var i, l;
|
|
140
|
-
let s = (l = (i = p2.current) == null ? void 0 : i.filter) != null ? l : Re;
|
|
141
|
-
return e ? s(e, n.current.search, a) : 0;
|
|
142
|
-
}
|
|
143
|
-
function z() {
|
|
144
|
-
if (!n.current.search || p2.current.shouldFilter === false) return;
|
|
145
|
-
let e = n.current.filtered.items, a = [];
|
|
146
|
-
n.current.filtered.groups.forEach((i) => {
|
|
147
|
-
let l = c.current.get(i), g = 0;
|
|
148
|
-
l.forEach((y) => {
|
|
149
|
-
let h = e.get(y);
|
|
150
|
-
g = Math.max(h, g);
|
|
151
|
-
}), a.push([i, g]);
|
|
152
|
-
});
|
|
153
|
-
let s = I.current;
|
|
154
|
-
V().sort((i, l) => {
|
|
155
|
-
var h, F;
|
|
156
|
-
let g = i.getAttribute("id"), y = l.getAttribute("id");
|
|
157
|
-
return ((h = e.get(y)) != null ? h : 0) - ((F = e.get(g)) != null ? F : 0);
|
|
158
|
-
}).forEach((i) => {
|
|
159
|
-
let l = i.closest(Y);
|
|
160
|
-
l ? l.appendChild(i.parentElement === l ? i : i.closest(`${Y} > *`)) : s.appendChild(i.parentElement === s ? i : i.closest(`${Y} > *`));
|
|
161
|
-
}), a.sort((i, l) => l[1] - i[1]).forEach((i) => {
|
|
162
|
-
var g;
|
|
163
|
-
let l = (g = I.current) == null ? void 0 : g.querySelector(`${N}[${T}="${encodeURIComponent(i[0])}"]`);
|
|
164
|
-
l == null || l.parentElement.appendChild(l);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
function W2() {
|
|
168
|
-
let e = V().find((s) => s.getAttribute("aria-disabled") !== "true"), a = e == null ? void 0 : e.getAttribute(T);
|
|
169
|
-
E.setState("value", a || void 0);
|
|
170
|
-
}
|
|
171
|
-
function J2() {
|
|
172
|
-
var a, s, i, l;
|
|
173
|
-
if (!n.current.search || p2.current.shouldFilter === false) {
|
|
174
|
-
n.current.filtered.count = u2.current.size;
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
n.current.filtered.groups = /* @__PURE__ */ new Set();
|
|
178
|
-
let e = 0;
|
|
179
|
-
for (let g of u2.current) {
|
|
180
|
-
let y = (s = (a = d.current.get(g)) == null ? void 0 : a.value) != null ? s : "", h = (l = (i = d.current.get(g)) == null ? void 0 : i.keywords) != null ? l : [], F = te(y, h);
|
|
181
|
-
n.current.filtered.items.set(g, F), F > 0 && e++;
|
|
182
|
-
}
|
|
183
|
-
for (let [g, y] of c.current) for (let h of y) if (n.current.filtered.items.get(h) > 0) {
|
|
184
|
-
n.current.filtered.groups.add(g);
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
n.current.filtered.count = e;
|
|
188
|
-
}
|
|
189
|
-
function ne() {
|
|
190
|
-
var a, s, i;
|
|
191
|
-
let e = M();
|
|
192
|
-
e && (((a = e.parentElement) == null ? void 0 : a.firstChild) === e && ((i = (s = e.closest(N)) == null ? void 0 : s.querySelector(be)) == null || i.scrollIntoView({ block: "nearest" })), e.scrollIntoView({ block: "nearest" }));
|
|
193
|
-
}
|
|
194
|
-
function M() {
|
|
195
|
-
var e;
|
|
196
|
-
return (e = I.current) == null ? void 0 : e.querySelector(`${le}[aria-selected="true"]`);
|
|
197
|
-
}
|
|
198
|
-
function V() {
|
|
199
|
-
var e;
|
|
200
|
-
return Array.from(((e = I.current) == null ? void 0 : e.querySelectorAll(ce)) || []);
|
|
201
|
-
}
|
|
202
|
-
function X2(e) {
|
|
203
|
-
let s = V()[e];
|
|
204
|
-
s && E.setState("value", s.getAttribute(T));
|
|
205
|
-
}
|
|
206
|
-
function Q(e) {
|
|
207
|
-
var g;
|
|
208
|
-
let a = M(), s = V(), i = s.findIndex((y) => y === a), l = s[i + e];
|
|
209
|
-
(g = p2.current) != null && g.loop && (l = i + e < 0 ? s[s.length - 1] : i + e === s.length ? s[0] : s[i + e]), l && E.setState("value", l.getAttribute(T));
|
|
210
|
-
}
|
|
211
|
-
function re(e) {
|
|
212
|
-
let a = M(), s = a == null ? void 0 : a.closest(N), i;
|
|
213
|
-
for (; s && !i; ) s = e > 0 ? we(s, N) : De(s, N), i = s == null ? void 0 : s.querySelector(ce);
|
|
214
|
-
i ? E.setState("value", i.getAttribute(T)) : Q(e);
|
|
215
|
-
}
|
|
216
|
-
let oe = () => X2(V().length - 1), ie = (e) => {
|
|
217
|
-
e.preventDefault(), e.metaKey ? oe() : e.altKey ? re(1) : Q(1);
|
|
218
|
-
}, se = (e) => {
|
|
219
|
-
e.preventDefault(), e.metaKey ? X2(0) : e.altKey ? re(-1) : Q(-1);
|
|
220
|
-
};
|
|
221
|
-
return reactExports.createElement(Primitive.div, { ref: o, tabIndex: -1, ...O, "cmdk-root": "", onKeyDown: (e) => {
|
|
222
|
-
var s;
|
|
223
|
-
(s = O.onKeyDown) == null || s.call(O, e);
|
|
224
|
-
let a = e.nativeEvent.isComposing || e.keyCode === 229;
|
|
225
|
-
if (!(e.defaultPrevented || a)) switch (e.key) {
|
|
226
|
-
case "n":
|
|
227
|
-
case "j": {
|
|
228
|
-
j && e.ctrlKey && ie(e);
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
case "ArrowDown": {
|
|
232
|
-
ie(e);
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
case "p":
|
|
236
|
-
case "k": {
|
|
237
|
-
j && e.ctrlKey && se(e);
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
|
-
case "ArrowUp": {
|
|
241
|
-
se(e);
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
244
|
-
case "Home": {
|
|
245
|
-
e.preventDefault(), X2(0);
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
case "End": {
|
|
249
|
-
e.preventDefault(), oe();
|
|
250
|
-
break;
|
|
251
|
-
}
|
|
252
|
-
case "Enter": {
|
|
253
|
-
e.preventDefault();
|
|
254
|
-
let i = M();
|
|
255
|
-
if (i) {
|
|
256
|
-
let l = new Event(Z);
|
|
257
|
-
i.dispatchEvent(l);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
} }, reactExports.createElement("label", { "cmdk-label": "", htmlFor: U2.inputId, id: U2.labelId, style: Te }, b), B(r, (e) => reactExports.createElement(de.Provider, { value: E }, reactExports.createElement(ue.Provider, { value: U2 }, e))));
|
|
262
|
-
}), he = reactExports.forwardRef((r, o) => {
|
|
263
|
-
var _, I;
|
|
264
|
-
let n = useId(), u2 = reactExports.useRef(null), c = reactExports.useContext(fe), d = K(), f = pe(r), p2 = (I = (_ = f.current) == null ? void 0 : _.forceMount) != null ? I : c == null ? void 0 : c.forceMount;
|
|
265
|
-
k(() => {
|
|
266
|
-
if (!p2) return d.item(n, c == null ? void 0 : c.id);
|
|
267
|
-
}, [p2]);
|
|
268
|
-
let b = ve(n, u2, [r.value, r.children, u2], r.keywords), m2 = ee(), R = P((v) => v.value && v.value === b.current), x = P((v) => p2 || d.filter() === false ? true : v.search ? v.filtered.items.get(n) > 0 : true);
|
|
269
|
-
reactExports.useEffect(() => {
|
|
270
|
-
let v = u2.current;
|
|
271
|
-
if (!(!v || r.disabled)) return v.addEventListener(Z, C), () => v.removeEventListener(Z, C);
|
|
272
|
-
}, [x, r.onSelect, r.disabled]);
|
|
273
|
-
function C() {
|
|
274
|
-
var v, E;
|
|
275
|
-
S(), (E = (v = f.current).onSelect) == null || E.call(v, b.current);
|
|
276
|
-
}
|
|
277
|
-
function S() {
|
|
278
|
-
m2.setState("value", b.current, true);
|
|
279
|
-
}
|
|
280
|
-
if (!x) return null;
|
|
281
|
-
let { disabled: A, value: ge, onSelect: j, forceMount: O, keywords: $2, ...q } = r;
|
|
282
|
-
return reactExports.createElement(Primitive.div, { ref: composeRefs(u2, o), ...q, id: n, "cmdk-item": "", role: "option", "aria-disabled": !!A, "aria-selected": !!R, "data-disabled": !!A, "data-selected": !!R, onPointerMove: A || d.getDisablePointerSelection() ? void 0 : S, onClick: A ? void 0 : C }, r.children);
|
|
283
|
-
}), Ee = reactExports.forwardRef((r, o) => {
|
|
284
|
-
let { heading: n, children: u2, forceMount: c, ...d } = r, f = useId(), p2 = reactExports.useRef(null), b = reactExports.useRef(null), m2 = useId(), R = K(), x = P((S) => c || R.filter() === false ? true : S.search ? S.filtered.groups.has(f) : true);
|
|
285
|
-
k(() => R.group(f), []), ve(f, p2, [r.value, r.heading, b]);
|
|
286
|
-
let C = reactExports.useMemo(() => ({ id: f, forceMount: c }), [c]);
|
|
287
|
-
return reactExports.createElement(Primitive.div, { ref: composeRefs(p2, o), ...d, "cmdk-group": "", role: "presentation", hidden: x ? void 0 : true }, n && reactExports.createElement("div", { ref: b, "cmdk-group-heading": "", "aria-hidden": true, id: m2 }, n), B(r, (S) => reactExports.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": n ? m2 : void 0 }, reactExports.createElement(fe.Provider, { value: C }, S))));
|
|
288
|
-
}), ye = reactExports.forwardRef((r, o) => {
|
|
289
|
-
let { alwaysRender: n, ...u2 } = r, c = reactExports.useRef(null), d = P((f) => !f.search);
|
|
290
|
-
return !n && !d ? null : reactExports.createElement(Primitive.div, { ref: composeRefs(c, o), ...u2, "cmdk-separator": "", role: "separator" });
|
|
291
|
-
}), Se = reactExports.forwardRef((r, o) => {
|
|
292
|
-
let { onValueChange: n, ...u2 } = r, c = r.value != null, d = ee(), f = P((m2) => m2.search), p2 = P((m2) => m2.selectedItemId), b = K();
|
|
293
|
-
return reactExports.useEffect(() => {
|
|
294
|
-
r.value != null && d.setState("search", r.value);
|
|
295
|
-
}, [r.value]), reactExports.createElement(Primitive.input, { ref: o, ...u2, "cmdk-input": "", autoComplete: "off", autoCorrect: "off", spellCheck: false, "aria-autocomplete": "list", role: "combobox", "aria-expanded": true, "aria-controls": b.listId, "aria-labelledby": b.labelId, "aria-activedescendant": p2, id: b.inputId, type: "text", value: c ? r.value : f, onChange: (m2) => {
|
|
296
|
-
c || d.setState("search", m2.target.value), n == null || n(m2.target.value);
|
|
297
|
-
} });
|
|
298
|
-
}), Ce = reactExports.forwardRef((r, o) => {
|
|
299
|
-
let { children: n, label: u2 = "Suggestions", ...c } = r, d = reactExports.useRef(null), f = reactExports.useRef(null), p2 = P((m2) => m2.selectedItemId), b = K();
|
|
300
|
-
return reactExports.useEffect(() => {
|
|
301
|
-
if (f.current && d.current) {
|
|
302
|
-
let m2 = f.current, R = d.current, x, C = new ResizeObserver(() => {
|
|
303
|
-
x = requestAnimationFrame(() => {
|
|
304
|
-
let S = m2.offsetHeight;
|
|
305
|
-
R.style.setProperty("--cmdk-list-height", S.toFixed(1) + "px");
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
return C.observe(m2), () => {
|
|
309
|
-
cancelAnimationFrame(x), C.unobserve(m2);
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
}, []), reactExports.createElement(Primitive.div, { ref: composeRefs(d, o), ...c, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": p2, "aria-label": u2, id: b.listId }, B(r, (m2) => reactExports.createElement("div", { ref: composeRefs(f, b.listInnerRef), "cmdk-list-sizer": "" }, m2)));
|
|
313
|
-
}), xe = reactExports.forwardRef((r, o) => {
|
|
314
|
-
let { open: n, onOpenChange: u2, overlayClassName: c, contentClassName: d, container: f, ...p2 } = r;
|
|
315
|
-
return reactExports.createElement(Root, { open: n, onOpenChange: u2 }, reactExports.createElement(Portal, { container: f }, reactExports.createElement(Overlay, { "cmdk-overlay": "", className: c }), reactExports.createElement(Content$1, { "aria-label": r.label, "cmdk-dialog": "", className: d }, reactExports.createElement(me, { ref: o, ...p2 }))));
|
|
316
|
-
}), Ie = reactExports.forwardRef((r, o) => P((u2) => u2.filtered.count === 0) ? reactExports.createElement(Primitive.div, { ref: o, ...r, "cmdk-empty": "", role: "presentation" }) : null), Pe = reactExports.forwardRef((r, o) => {
|
|
317
|
-
let { progress: n, children: u2, label: c = "Loading...", ...d } = r;
|
|
318
|
-
return reactExports.createElement(Primitive.div, { ref: o, ...d, "cmdk-loading": "", role: "progressbar", "aria-valuenow": n, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": c }, B(r, (f) => reactExports.createElement("div", { "aria-hidden": true }, f)));
|
|
319
|
-
}), _e = Object.assign(me, { List: Ce, Item: he, Input: Se, Group: Ee, Separator: ye, Dialog: xe, Empty: Ie, Loading: Pe });
|
|
320
|
-
function we(r, o) {
|
|
321
|
-
let n = r.nextElementSibling;
|
|
322
|
-
for (; n; ) {
|
|
323
|
-
if (n.matches(o)) return n;
|
|
324
|
-
n = n.nextElementSibling;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
function De(r, o) {
|
|
328
|
-
let n = r.previousElementSibling;
|
|
329
|
-
for (; n; ) {
|
|
330
|
-
if (n.matches(o)) return n;
|
|
331
|
-
n = n.previousElementSibling;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
function pe(r) {
|
|
335
|
-
let o = reactExports.useRef(r);
|
|
336
|
-
return k(() => {
|
|
337
|
-
o.current = r;
|
|
338
|
-
}), o;
|
|
339
|
-
}
|
|
340
|
-
var k = typeof window == "undefined" ? reactExports.useEffect : reactExports.useLayoutEffect;
|
|
341
|
-
function L(r) {
|
|
342
|
-
let o = reactExports.useRef();
|
|
343
|
-
return o.current === void 0 && (o.current = r()), o;
|
|
344
|
-
}
|
|
345
|
-
function P(r) {
|
|
346
|
-
let o = ee(), n = () => r(o.snapshot());
|
|
347
|
-
return reactExports.useSyncExternalStore(o.subscribe, n, n);
|
|
348
|
-
}
|
|
349
|
-
function ve(r, o, n, u2 = []) {
|
|
350
|
-
let c = reactExports.useRef(), d = K();
|
|
351
|
-
return k(() => {
|
|
352
|
-
var b;
|
|
353
|
-
let f = (() => {
|
|
354
|
-
var m2;
|
|
355
|
-
for (let R of n) {
|
|
356
|
-
if (typeof R == "string") return R.trim();
|
|
357
|
-
if (typeof R == "object" && "current" in R) return R.current ? (m2 = R.current.textContent) == null ? void 0 : m2.trim() : c.current;
|
|
358
|
-
}
|
|
359
|
-
})(), p2 = u2.map((m2) => m2.trim());
|
|
360
|
-
d.value(r, f, p2), (b = o.current) == null || b.setAttribute(T, f), c.current = f;
|
|
361
|
-
}), c;
|
|
362
|
-
}
|
|
363
|
-
var ke = () => {
|
|
364
|
-
let [r, o] = reactExports.useState(), n = L(() => /* @__PURE__ */ new Map());
|
|
365
|
-
return k(() => {
|
|
366
|
-
n.current.forEach((u2) => u2()), n.current = /* @__PURE__ */ new Map();
|
|
367
|
-
}, [r]), (u2, c) => {
|
|
368
|
-
n.current.set(u2, c), o({});
|
|
369
|
-
};
|
|
370
|
-
};
|
|
371
|
-
function Me(r) {
|
|
372
|
-
let o = r.type;
|
|
373
|
-
return typeof o == "function" ? o(r.props) : "render" in o ? o.render(r.props) : r;
|
|
374
|
-
}
|
|
375
|
-
function B({ asChild: r, children: o }, n) {
|
|
376
|
-
return r && reactExports.isValidElement(o) ? reactExports.cloneElement(Me(o), { ref: o.ref }, n(o.props.children)) : n(o);
|
|
377
|
-
}
|
|
378
|
-
var Te = { position: "absolute", width: "1px", height: "1px", padding: "0", margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0" };
|
|
379
|
-
const Command = React.forwardRef(({ className, ...props }, ref) => jsxRuntimeExports.jsx(_e, { ref, className: cn$1("flex size-full flex-col rounded-md [&_[cmdk-label]]:hidden", className), ...props }));
|
|
380
|
-
Command.displayName = _e.displayName;
|
|
381
|
-
const CommandInput = React.forwardRef(({ wrapperClassName, className, ...props }, ref) => jsxRuntimeExports.jsxs("div", { className: cn$1("group relative flex items-center border-b", "border-b-gray-300 dark:border-b-gray-900", "hover:border-b-gray-300 dark:hover:border-b-gray-800", "hover:bg-gray-100 dark:hover:bg-gray-900", "focus-within:border-b-gray-300 dark:focus-within:border-b-gray-800", "focus-within:bg-gray-100 dark:focus-within:bg-gray-900", wrapperClassName), "cmdk-input-wrapper": "", children: [jsxRuntimeExports.jsx(Icon, { name: "Search", size: 16, className: cn$1("pointer-events-none absolute left-2 top-3.5 text-gray-500 dark:text-gray-700", "group-hover:text-gray-700 dark:group-hover:text-gray-500", "group-focus-within:!text-gray-900 dark:group-focus-within:!text-gray-50") }), jsxRuntimeExports.jsx(_e.Input, { ref, className: cn$1("flex w-full bg-transparent pb-2 pl-8 pr-3 pt-3 text-[14px] font-normal leading-5 outline-none", "placeholder:text-gray-500 dark:placeholder:text-gray-700", "group-hover:placeholder:text-gray-700 dark:group-hover:placeholder:text-gray-500", "group-focus-within:placeholder:!text-gray-700 dark:group-focus-within:placeholder:!text-gray-300", "disabled:cursor-not-allowed", className), ...props })] }));
|
|
382
|
-
CommandInput.displayName = _e.Input.displayName;
|
|
383
|
-
const CommandList = React.forwardRef(({ className, ...props }, ref) => jsxRuntimeExports.jsx(_e.List, { ref, className: cn$1("max-h-[300px] overflow-y-auto overflow-x-hidden", "focus:outline-none", "scrollbar-thin scrollbar-gutter-stable", "scrollbar-track-transparent", "scrollbar-thumb-gray-300 hover:scrollbar-thumb-gray-300", "dark:scrollbar-thumb-charcoal-700 dark:hover:scrollbar-thumb-charcoal-700", "scrollbar-thumb-rounded-md", className), ...props }));
|
|
384
|
-
CommandList.displayName = _e.List.displayName;
|
|
385
|
-
const CommandLoading = React.forwardRef((props, ref) => jsxRuntimeExports.jsx(_e.Loading, { ref, ...props }));
|
|
386
|
-
CommandLoading.displayName = _e.Loading.displayName;
|
|
387
|
-
const CommandEmpty = React.forwardRef((props, ref) => jsxRuntimeExports.jsx(_e.Empty, { ref, ...props }));
|
|
388
|
-
CommandEmpty.displayName = _e.Empty.displayName;
|
|
389
|
-
const CommandGroup = React.forwardRef(({ className, ...props }, ref) => jsxRuntimeExports.jsx(_e.Group, { ref, className: cn$1("overflow-hidden px-0.5 py-1", "[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium", className), ...props }));
|
|
390
|
-
CommandGroup.displayName = _e.Group.displayName;
|
|
391
|
-
const CommandItem = React.forwardRef(({ className, ...props }, ref) => jsxRuntimeExports.jsx(_e.Item, { ref, className: cn$1("relative flex select-none items-center justify-between", "h-8 gap-2 rounded-md py-1.5 pl-1.5 pr-2.5", "text-[14px] leading-4 outline-none", "border-y-2 border-white dark:border-slate-600", "data-[disabled=true]:pointer-events-none", "[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", className), ...props }));
|
|
392
|
-
CommandItem.displayName = _e.Item.displayName;
|
|
393
|
-
const FormDescription = ({ children, as, className }) => {
|
|
394
|
-
const Component = as ?? "p";
|
|
395
|
-
return jsxRuntimeExports.jsx(Component, { className: cn$1("font-sans text-sm font-normal leading-5 text-gray-600 dark:text-gray-500", className), children });
|
|
396
|
-
};
|
|
397
|
-
const FormGroup = ({ children }) => {
|
|
398
|
-
return jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-2", children });
|
|
399
|
-
};
|
|
400
|
-
const IdAutocompleteInputContainer = React.forwardRef(({ id, name: name2, value, className, isLoading, haveFetchError, disabled, onChange, onBlur, onClick, selectedOption, optionsLength, handleOpenChange, onKeyDown, onMouseDown, placeholder, hasError, label, required, isPopoverOpen, maxLength, handlePaste, onPaste, ...props }, ref) => {
|
|
401
|
-
const [hasCopied, setHasCopied] = reactExports.useState(false);
|
|
402
|
-
const hasHover = useMediaQuery("(hover: hover) and (pointer: fine)");
|
|
403
|
-
const transformers = reactExports.useMemo(() => [
|
|
404
|
-
sharedValueTransformers.trimOnBlur(),
|
|
405
|
-
sharedValueTransformers.trimOnEnter()
|
|
406
|
-
], []);
|
|
407
|
-
return jsxRuntimeExports.jsxs("div", { className: cn$1("group relative"), children: [jsxRuntimeExports.jsx(ValueTransformer, { transformers, children: jsxRuntimeExports.jsx(_e.Input, { asChild: true, children: jsxRuntimeExports.jsx(Input, { id, name: name2, value, className: cn$1("pr-9", className), disabled, onChange, onBlur, onClick: (e) => {
|
|
408
|
-
const input = e.target;
|
|
409
|
-
if (!(isLoading || haveFetchError) && !selectedOption && input.value !== "") {
|
|
410
|
-
handleOpenChange?.(true);
|
|
411
|
-
}
|
|
412
|
-
onClick?.(e);
|
|
413
|
-
}, onKeyDown: (e) => {
|
|
414
|
-
onKeyDown?.(e);
|
|
415
|
-
const isOptionsRelatedKey = [
|
|
416
|
-
"ArrowUp",
|
|
417
|
-
"ArrowDown",
|
|
418
|
-
"Enter"
|
|
419
|
-
].includes(e.key);
|
|
420
|
-
if (e.key === "Enter" && isPopoverOpen && optionsLength === 0) {
|
|
421
|
-
handleOpenChange?.(false);
|
|
422
|
-
e.preventDefault();
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
if (!(isOptionsRelatedKey && isPopoverOpen && optionsLength > 0)) {
|
|
426
|
-
e.stopPropagation();
|
|
427
|
-
}
|
|
428
|
-
}, onMouseDown: (e) => {
|
|
429
|
-
const input = e.target;
|
|
430
|
-
if (!input.contains(document.activeElement)) {
|
|
431
|
-
requestAnimationFrame(() => {
|
|
432
|
-
input.select();
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
onMouseDown?.(e);
|
|
436
|
-
}, onPaste: (e) => {
|
|
437
|
-
handlePaste?.(e);
|
|
438
|
-
onPaste?.(e);
|
|
439
|
-
}, placeholder, "aria-invalid": hasError, "aria-label": !label ? "Id Autocomplete" : void 0, "aria-required": required, "aria-expanded": isPopoverOpen, maxLength, ...props, ref }) }) }), jsxRuntimeExports.jsxs("div", { className: cn$1("absolute right-3 top-1/2 flex size-4 -translate-y-1/2 items-center", !isLoading && !haveFetchError && !selectedOption && "pointer-events-none"), children: [isLoading && jsxRuntimeExports.jsx(Icon, { name: "Reload", size: 16, className: cn$1("animate-spin text-gray-500 dark:text-gray-600") }), haveFetchError && jsxRuntimeExports.jsx(Provider, { children: jsxRuntimeExports.jsx(Tooltip, { content: "Network error!", children: jsxRuntimeExports.jsx(Icon, { name: "Error", size: 16, className: cn$1("text-red-900") }) }) }), selectedOption && !isLoading && !haveFetchError && jsxRuntimeExports.jsx(Provider, { children: jsxRuntimeExports.jsx(Tooltip, { content: "Copied!", open: hasCopied, triggerAsChild: true, children: jsxRuntimeExports.jsx("button", { type: "button", onClick: () => {
|
|
440
|
-
navigator.clipboard.writeText(selectedOption.value).then(() => {
|
|
441
|
-
setHasCopied(true);
|
|
442
|
-
setTimeout(() => setHasCopied(false), 2e3);
|
|
443
|
-
}).catch((error) => {
|
|
444
|
-
console.error("Failed to copy value: ", error);
|
|
445
|
-
});
|
|
446
|
-
}, className: cn$1("focus-visible:outline-none [&_svg]:pointer-events-none", hasHover && "opacity-0 transition-opacity duration-500 group-hover:opacity-100"), children: jsxRuntimeExports.jsx(Icon, { name: "Copy", size: 16, className: cn$1("text-gray-500 dark:text-gray-600") }) }) }) })] })] });
|
|
447
|
-
});
|
|
448
|
-
const IconRenderer = ({ customIcon, asPlaceholder }) => {
|
|
449
|
-
if (typeof customIcon === "string") {
|
|
450
|
-
return jsxRuntimeExports.jsx(Icon, { name: customIcon, size: 24, className: cn$1("shrink-0", asPlaceholder ? "text-gray-400 dark:text-gray-700" : "text-gray-900 dark:text-gray-300") });
|
|
451
|
-
}
|
|
452
|
-
if (React.isValidElement(customIcon)) {
|
|
453
|
-
return jsxRuntimeExports.jsx("div", { className: "size-6 shrink-0 overflow-hidden", children: customIcon });
|
|
454
|
-
}
|
|
455
|
-
return null;
|
|
456
|
-
};
|
|
457
|
-
const ReloadButton = ({ isLoadingSelectedOption, handleFetchSelectedOption, isFetchSelectedOptionSync, value }) => jsxRuntimeExports.jsx("div", { children: jsxRuntimeExports.jsx("button", { type: "button", disabled: isLoadingSelectedOption || isFetchSelectedOptionSync, onClick: () => {
|
|
458
|
-
if (!isLoadingSelectedOption && !isFetchSelectedOptionSync) {
|
|
459
|
-
handleFetchSelectedOption(value);
|
|
460
|
-
}
|
|
461
|
-
}, className: cn$1("mt-0.5 focus-visible:outline-none", "disabled:pointer-events-none [&_svg]:pointer-events-none"), "aria-label": isLoadingSelectedOption ? "Loading" : isFetchSelectedOptionSync ? "Success" : "Reload", children: jsxRuntimeExports.jsx(Icon, { name: isFetchSelectedOptionSync ? "Checkmark" : "Reload", size: 16, className: cn$1("text-gray-500 dark:text-gray-600", isLoadingSelectedOption && "animate-spin", isFetchSelectedOptionSync && "animate-in fade-in duration-500") }) }) });
|
|
462
|
-
const IdAutocompleteListOption = ({ variant = "withValue", icon, title = "Title not available", path = "Path not available", value, description: description2 = "Description not available", asPlaceholder, showValue = true, isLoadingSelectedOption, handleFetchSelectedOption, isFetchSelectedOptionSync, className, placeholderIcon = "PowerhouseLogoSmall", ...extraProps }) => {
|
|
463
|
-
const renderWithValue = () => jsxRuntimeExports.jsx("div", { className: cn$1("flex w-full items-center"), children: jsxRuntimeExports.jsx("span", { className: cn$1("truncate text-xs leading-5", asPlaceholder ? "text-gray-400 dark:text-gray-700" : "text-gray-500 dark:text-gray-600"), children: value }) });
|
|
464
|
-
const renderWithValueTitleAndDescription = (showDescription = true) => jsxRuntimeExports.jsxs("div", { className: cn$1("flex w-full flex-col gap-1"), children: [jsxRuntimeExports.jsxs("div", { className: cn$1("flex gap-2"), children: [jsxRuntimeExports.jsx(IconRenderer, { customIcon: asPlaceholder ? placeholderIcon : icon, asPlaceholder }), jsxRuntimeExports.jsxs("div", { className: cn$1("flex min-w-0 grow flex-col gap-[-2px]"), children: [jsxRuntimeExports.jsx("span", { className: cn$1("truncate text-sm font-bold leading-5", asPlaceholder ? "text-gray-400 dark:text-gray-700" : "text-gray-900 dark:text-gray-300"), children: title }), !showValue && typeof path === "object" ? jsxRuntimeExports.jsx("a", { href: path.url, target: "_blank", rel: "noopener noreferrer", className: cn$1("truncate text-xs leading-5 text-blue-900 hover:underline focus-visible:outline-none"), children: path.text }) : jsxRuntimeExports.jsx("span", { className: cn$1("truncate text-xs leading-5", asPlaceholder ? "text-gray-400 dark:text-gray-700" : "text-gray-500 dark:text-gray-600"), children: typeof path === "object" ? path.text : path })] }), asPlaceholder === false && handleFetchSelectedOption && jsxRuntimeExports.jsx(ReloadButton, { isLoadingSelectedOption, handleFetchSelectedOption, isFetchSelectedOptionSync, value })] }), showValue && jsxRuntimeExports.jsx("div", { className: cn$1("flex max-w-full items-center"), children: jsxRuntimeExports.jsx("span", { className: cn$1("truncate text-xs leading-5", asPlaceholder ? "text-gray-400 dark:text-gray-700" : "text-gray-500 dark:text-gray-600"), children: value }) }), showDescription && jsxRuntimeExports.jsx("div", { className: cn$1("flex flex-col"), children: jsxRuntimeExports.jsx("p", { className: cn$1("line-clamp-2 text-xs leading-5", asPlaceholder ? "text-gray-400 dark:text-gray-700" : "text-gray-900 dark:text-gray-300"), children: description2 }) }), showDescription && "agentType" in extraProps && typeof extraProps.agentType === "string" && jsxRuntimeExports.jsx("div", { className: cn$1("flex max-w-full items-center justify-end"), children: jsxRuntimeExports.jsx("span", { className: cn$1("truncate text-xs leading-5", asPlaceholder ? "text-gray-400 dark:text-gray-700" : "text-gray-500 dark:text-gray-600"), children: extraProps.agentType }) })] });
|
|
465
|
-
return jsxRuntimeExports.jsxs("div", { className: cn$1("w-full max-w-full rounded-md bg-transparent px-3 pb-2", variant === "withValue" ? "pt-2" : "pt-3", className), children: [variant === "withValue" && renderWithValue(), variant === "withValueAndTitle" && renderWithValueTitleAndDescription(false), variant === "withValueTitleAndDescription" && renderWithValueTitleAndDescription()] });
|
|
466
|
-
};
|
|
467
|
-
const IdAutocompleteList = ({ variant, commandListRef, selectedValue, options = [], toggleOption, renderOption, previewPlaceholder }) => {
|
|
468
|
-
const cmdkSearch = P((state) => state.search);
|
|
469
|
-
const defaultOption = previewPlaceholder || {
|
|
470
|
-
value: "value not available",
|
|
471
|
-
title: "Title not available",
|
|
472
|
-
path: "Path not available",
|
|
473
|
-
description: "Description not available"
|
|
474
|
-
};
|
|
475
|
-
reactExports.useEffect(() => {
|
|
476
|
-
commandListRef?.current?.scrollTo({ top: 0, behavior: "instant" });
|
|
477
|
-
}, [commandListRef, cmdkSearch]);
|
|
478
|
-
return jsxRuntimeExports.jsxs(CommandList, { ref: commandListRef, children: [jsxRuntimeExports.jsx(CommandEmpty, { className: cn$1("h-full p-1"), children: renderOption ? renderOption(defaultOption, {
|
|
479
|
-
asPlaceholder: true,
|
|
480
|
-
showValue: true,
|
|
481
|
-
className: cn$1("pb-0")
|
|
482
|
-
}) : jsxRuntimeExports.jsx(IdAutocompleteListOption, { variant, icon: defaultOption.icon, title: defaultOption.title, path: defaultOption.path, value: defaultOption.value, description: defaultOption.description, asPlaceholder: true, className: cn$1("pb-0") }) }), jsxRuntimeExports.jsx(CommandGroup, { className: cn$1("px-1"), children: options.map((opt) => {
|
|
483
|
-
const isSelected = selectedValue === opt.value;
|
|
484
|
-
return jsxRuntimeExports.jsx(CommandItem, { value: opt.value, onSelect: () => toggleOption?.(opt.value), className: cn$1("h-full cursor-pointer border-y-0 p-0", "data-[selected=true]:bg-gray-100 dark:data-[selected=true]:bg-gray-900"), role: "option", "aria-selected": isSelected, children: renderOption ? renderOption(opt, {
|
|
485
|
-
asPlaceholder: false,
|
|
486
|
-
showValue: true
|
|
487
|
-
}) : jsxRuntimeExports.jsx(IdAutocompleteListOption, { variant, ...opt }) }, opt.value);
|
|
488
|
-
}) })] });
|
|
489
|
-
};
|
|
490
|
-
const IdAutocompleteContext = reactExports.createContext({});
|
|
491
|
-
const useIdAutocompleteContext = () => reactExports.useContext(IdAutocompleteContext);
|
|
492
|
-
function useIdAutocomplete({ autoComplete, defaultValue, value, isOpenByDefault, initialOptions, onChange, onBlur, fetchOptions, fetchSelectedOption }) {
|
|
493
|
-
const context = useIdAutocompleteContext();
|
|
494
|
-
const shouldFetchOptions = reactExports.useRef(false);
|
|
495
|
-
const isInternalChange = reactExports.useRef(false);
|
|
496
|
-
const commandListRef = reactExports.useRef(null);
|
|
497
|
-
const [isPopoverOpen, setIsPopoverOpen] = reactExports.useState(isOpenByDefault ?? false);
|
|
498
|
-
const [options, setOptions] = reactExports.useState(initialOptions ?? []);
|
|
499
|
-
const [isLoading, setIsLoading] = reactExports.useState(false);
|
|
500
|
-
const [isLoadingSelectedOption, setIsLoadingSelectedOption] = reactExports.useState(false);
|
|
501
|
-
const [haveFetchError, setHaveFetchError] = reactExports.useState(false);
|
|
502
|
-
const [selectedValue, setSelectedValue] = reactExports.useState(value ?? defaultValue ?? "");
|
|
503
|
-
const [selectedOption, setSelectedOption] = reactExports.useState(void 0);
|
|
504
|
-
const [commandValue, setCommandValue] = reactExports.useState("");
|
|
505
|
-
const [isFetchSelectedOptionSync, setIsFetchSelectedOptionSync] = reactExports.useState(false);
|
|
506
|
-
const clear = reactExports.useCallback(() => {
|
|
507
|
-
setHaveFetchError(false);
|
|
508
|
-
setIsLoading(false);
|
|
509
|
-
setIsLoadingSelectedOption(false);
|
|
510
|
-
setIsPopoverOpen(false);
|
|
511
|
-
}, []);
|
|
512
|
-
const debouncedFetchOptions = useDebounceCallback(reactExports.useCallback((newValue) => {
|
|
513
|
-
if (!autoComplete || !fetchOptions)
|
|
514
|
-
return;
|
|
515
|
-
if (newValue === "") {
|
|
516
|
-
clear();
|
|
517
|
-
setOptions([]);
|
|
518
|
-
setSelectedValue("");
|
|
519
|
-
setSelectedOption(void 0);
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
522
|
-
setHaveFetchError(false);
|
|
523
|
-
setIsLoading(true);
|
|
524
|
-
try {
|
|
525
|
-
const result = fetchOptions(newValue, context);
|
|
526
|
-
Promise.resolve(result).then((newOptions) => {
|
|
527
|
-
setOptions(newOptions);
|
|
528
|
-
const matchingOption = newOptions.find((opt) => opt.value === newValue);
|
|
529
|
-
if (matchingOption) {
|
|
530
|
-
setSelectedOption(matchingOption);
|
|
531
|
-
setIsPopoverOpen(false);
|
|
532
|
-
} else {
|
|
533
|
-
setSelectedOption(void 0);
|
|
534
|
-
setIsPopoverOpen(true);
|
|
535
|
-
}
|
|
536
|
-
setIsLoading(false);
|
|
537
|
-
}).catch(() => {
|
|
538
|
-
setHaveFetchError(true);
|
|
539
|
-
setIsLoading(false);
|
|
540
|
-
});
|
|
541
|
-
} catch {
|
|
542
|
-
setHaveFetchError(true);
|
|
543
|
-
setIsLoading(false);
|
|
544
|
-
}
|
|
545
|
-
}, [clear, autoComplete, fetchOptions, context]));
|
|
546
|
-
const handleFetchSelectedOption = reactExports.useCallback((value2) => {
|
|
547
|
-
if (!autoComplete || !fetchSelectedOption)
|
|
548
|
-
return;
|
|
549
|
-
setIsLoadingSelectedOption(true);
|
|
550
|
-
try {
|
|
551
|
-
const result = fetchSelectedOption(value2);
|
|
552
|
-
const isPromise = result instanceof Promise;
|
|
553
|
-
Promise.resolve(result).then((option) => {
|
|
554
|
-
if (option) {
|
|
555
|
-
setSelectedOption(option);
|
|
556
|
-
setOptions((prevOptions) => {
|
|
557
|
-
const optionIndex = prevOptions.findIndex((opt) => opt.value === value2);
|
|
558
|
-
if (optionIndex !== -1) {
|
|
559
|
-
const newOptions = [...prevOptions];
|
|
560
|
-
newOptions[optionIndex] = option;
|
|
561
|
-
return newOptions;
|
|
562
|
-
}
|
|
563
|
-
return prevOptions;
|
|
564
|
-
});
|
|
565
|
-
} else {
|
|
566
|
-
clear();
|
|
567
|
-
setOptions([]);
|
|
568
|
-
setSelectedValue("");
|
|
569
|
-
setSelectedOption(void 0);
|
|
570
|
-
}
|
|
571
|
-
setIsLoadingSelectedOption(false);
|
|
572
|
-
if (!isPromise) {
|
|
573
|
-
setIsFetchSelectedOptionSync(true);
|
|
574
|
-
setTimeout(() => {
|
|
575
|
-
setIsFetchSelectedOptionSync(false);
|
|
576
|
-
}, 1500);
|
|
577
|
-
}
|
|
578
|
-
}).catch(() => {
|
|
579
|
-
setIsLoadingSelectedOption(false);
|
|
580
|
-
});
|
|
581
|
-
} catch {
|
|
582
|
-
setIsLoadingSelectedOption(false);
|
|
583
|
-
}
|
|
584
|
-
}, [clear, autoComplete, fetchSelectedOption]);
|
|
585
|
-
const handleOpenChange = reactExports.useCallback((open) => {
|
|
586
|
-
if (!open) {
|
|
587
|
-
setCommandValue(options[0]?.value ?? "");
|
|
588
|
-
}
|
|
589
|
-
setIsPopoverOpen(open);
|
|
590
|
-
}, [options]);
|
|
591
|
-
const toggleOption = reactExports.useCallback((optionValue) => {
|
|
592
|
-
shouldFetchOptions.current = false;
|
|
593
|
-
isInternalChange.current = true;
|
|
594
|
-
setSelectedValue(optionValue);
|
|
595
|
-
setSelectedOption(options.find((opt) => opt.value === optionValue));
|
|
596
|
-
clear();
|
|
597
|
-
onChange?.(optionValue);
|
|
598
|
-
}, [onChange, clear, options]);
|
|
599
|
-
const handleChange = reactExports.useCallback((e) => {
|
|
600
|
-
const newValue = e.target.value;
|
|
601
|
-
shouldFetchOptions.current = true;
|
|
602
|
-
setSelectedValue(newValue);
|
|
603
|
-
setSelectedOption(void 0);
|
|
604
|
-
onChange?.(newValue);
|
|
605
|
-
}, [onChange]);
|
|
606
|
-
const handleCommandValue = reactExports.useCallback((value2) => {
|
|
607
|
-
setCommandValue(value2);
|
|
608
|
-
}, []);
|
|
609
|
-
const onTriggerBlur = reactExports.useCallback((e) => {
|
|
610
|
-
if (!isPopoverOpen) {
|
|
611
|
-
onBlur?.(e);
|
|
612
|
-
}
|
|
613
|
-
}, [onBlur, isPopoverOpen]);
|
|
614
|
-
const handlePaste = reactExports.useCallback((e) => {
|
|
615
|
-
const clipboardData = e.clipboardData.getData("text");
|
|
616
|
-
const trimmedValue = clipboardData.trim();
|
|
617
|
-
if (clipboardData !== trimmedValue) {
|
|
618
|
-
e.preventDefault();
|
|
619
|
-
const input = e.currentTarget;
|
|
620
|
-
const start = input.selectionStart || 0;
|
|
621
|
-
const end = input.selectionEnd || 0;
|
|
622
|
-
const currentValue = input.value;
|
|
623
|
-
const newValue = currentValue.substring(0, start) + trimmedValue + currentValue.substring(end);
|
|
624
|
-
onChange?.(newValue);
|
|
625
|
-
requestAnimationFrame(() => {
|
|
626
|
-
const newPosition = start + trimmedValue.length;
|
|
627
|
-
input.setSelectionRange(newPosition, newPosition);
|
|
628
|
-
debouncedFetchOptions(newValue);
|
|
629
|
-
});
|
|
630
|
-
} else if (clipboardData === selectedValue) {
|
|
631
|
-
debouncedFetchOptions(selectedValue);
|
|
632
|
-
}
|
|
633
|
-
}, [selectedValue, debouncedFetchOptions, onChange]);
|
|
634
|
-
reactExports.useEffect(() => {
|
|
635
|
-
if (autoComplete) {
|
|
636
|
-
if (shouldFetchOptions.current) {
|
|
637
|
-
debouncedFetchOptions(selectedValue);
|
|
638
|
-
}
|
|
639
|
-
} else {
|
|
640
|
-
clear();
|
|
641
|
-
setOptions([]);
|
|
642
|
-
setSelectedValue("");
|
|
643
|
-
setSelectedOption(void 0);
|
|
644
|
-
}
|
|
645
|
-
}, [autoComplete, selectedValue, debouncedFetchOptions, clear]);
|
|
646
|
-
reactExports.useEffect(() => {
|
|
647
|
-
if (!isInternalChange.current) {
|
|
648
|
-
shouldFetchOptions.current = false;
|
|
649
|
-
setSelectedValue(value ?? defaultValue ?? "");
|
|
650
|
-
setSelectedOption(void 0);
|
|
651
|
-
}
|
|
652
|
-
isInternalChange.current = false;
|
|
653
|
-
}, [value]);
|
|
654
|
-
reactExports.useEffect(() => {
|
|
655
|
-
if (initialOptions?.length && selectedValue) {
|
|
656
|
-
const matchingOption = initialOptions.find((opt) => opt.value === selectedValue);
|
|
657
|
-
if (matchingOption) {
|
|
658
|
-
setSelectedOption(matchingOption);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
}, []);
|
|
662
|
-
return {
|
|
663
|
-
selectedValue,
|
|
664
|
-
selectedOption,
|
|
665
|
-
isPopoverOpen,
|
|
666
|
-
commandListRef,
|
|
667
|
-
options,
|
|
668
|
-
isLoading,
|
|
669
|
-
isLoadingSelectedOption,
|
|
670
|
-
haveFetchError,
|
|
671
|
-
commandValue,
|
|
672
|
-
isFetchSelectedOptionSync,
|
|
673
|
-
toggleOption,
|
|
674
|
-
handleOpenChange,
|
|
675
|
-
onTriggerBlur,
|
|
676
|
-
handleChange,
|
|
677
|
-
handleCommandValue,
|
|
678
|
-
handleFetchSelectedOption,
|
|
679
|
-
handlePaste
|
|
680
|
-
};
|
|
681
|
-
}
|
|
682
|
-
const IdAutocomplete = React.forwardRef(({
|
|
683
|
-
id: idProp,
|
|
684
|
-
name: name2,
|
|
685
|
-
className,
|
|
686
|
-
label,
|
|
687
|
-
description: description2,
|
|
688
|
-
value,
|
|
689
|
-
defaultValue,
|
|
690
|
-
disabled,
|
|
691
|
-
placeholder,
|
|
692
|
-
required,
|
|
693
|
-
errors,
|
|
694
|
-
warnings,
|
|
695
|
-
onChange,
|
|
696
|
-
onBlur,
|
|
697
|
-
onClick,
|
|
698
|
-
onKeyDown,
|
|
699
|
-
onMouseDown,
|
|
700
|
-
autoComplete = true,
|
|
701
|
-
variant = "withValue",
|
|
702
|
-
maxLength,
|
|
703
|
-
fetchOptionsCallback,
|
|
704
|
-
fetchSelectedOptionCallback,
|
|
705
|
-
isOpenByDefault,
|
|
706
|
-
// to be used only in stories
|
|
707
|
-
initialOptions,
|
|
708
|
-
renderOption,
|
|
709
|
-
previewPlaceholder,
|
|
710
|
-
...props
|
|
711
|
-
}, ref) => {
|
|
712
|
-
const prefix = reactExports.useId();
|
|
713
|
-
const id = idProp ?? `${prefix}-id-autocomplete`;
|
|
714
|
-
const inputRef = reactExports.useRef(null);
|
|
715
|
-
const mergedRef = (node) => {
|
|
716
|
-
inputRef.current = node;
|
|
717
|
-
if (typeof ref === "function") {
|
|
718
|
-
ref(node);
|
|
719
|
-
} else if (ref) {
|
|
720
|
-
ref.current = node;
|
|
721
|
-
}
|
|
722
|
-
};
|
|
723
|
-
const hasWarning = Array.isArray(warnings) && warnings.length > 0;
|
|
724
|
-
const hasError = Array.isArray(errors) && errors.length > 0;
|
|
725
|
-
const { selectedValue, selectedOption, isPopoverOpen, commandListRef, options, isLoading, isLoadingSelectedOption, haveFetchError, commandValue, isFetchSelectedOptionSync, toggleOption, handleOpenChange, onTriggerBlur, handleChange, handleCommandValue, handleFetchSelectedOption, handlePaste } = useIdAutocomplete({
|
|
726
|
-
autoComplete,
|
|
727
|
-
defaultValue,
|
|
728
|
-
value,
|
|
729
|
-
isOpenByDefault,
|
|
730
|
-
initialOptions,
|
|
731
|
-
onChange,
|
|
732
|
-
onBlur,
|
|
733
|
-
fetchOptions: fetchOptionsCallback,
|
|
734
|
-
fetchSelectedOption: fetchSelectedOptionCallback
|
|
735
|
-
});
|
|
736
|
-
const handleOptionSelection = (optionValue) => {
|
|
737
|
-
toggleOption(optionValue);
|
|
738
|
-
inputRef.current?.focus();
|
|
739
|
-
};
|
|
740
|
-
const asCard = variant === "withValueAndTitle" || variant === "withValueTitleAndDescription";
|
|
741
|
-
const transformers = reactExports.useMemo(() => [
|
|
742
|
-
sharedValueTransformers.trimOnBlur(),
|
|
743
|
-
sharedValueTransformers.trimOnEnter()
|
|
744
|
-
], []);
|
|
745
|
-
return jsxRuntimeExports.jsxs(FormGroup, { children: [!!label && jsxRuntimeExports.jsx(FormLabel, { htmlFor: id, disabled, hasError, required, onClick: (e) => {
|
|
746
|
-
e.preventDefault();
|
|
747
|
-
e.target.control?.focus();
|
|
748
|
-
}, children: label }), autoComplete && fetchOptionsCallback ? jsxRuntimeExports.jsx(Popover, { open: isPopoverOpen, onOpenChange: handleOpenChange, children: jsxRuntimeExports.jsxs(Command, { shouldFilter: false, value: commandValue, onValueChange: handleCommandValue, className: cn$1("dark:bg-charcoal-900 bg-gray-100"), children: [jsxRuntimeExports.jsx(PopoverAnchor, { asChild: true, children: jsxRuntimeExports.jsx(IdAutocompleteInputContainer, { id, name: name2, value: selectedValue, className, isLoading, haveFetchError, disabled, onChange: handleChange, onBlur: onTriggerBlur, onClick, selectedOption, optionsLength: options.length, handleOpenChange, onKeyDown, onMouseDown, placeholder, hasError, label, required, isPopoverOpen, maxLength, handlePaste, ...props, ref: mergedRef }) }), asCard && (renderOption ? renderOption(selectedOption === void 0 && previewPlaceholder ? {
|
|
749
|
-
...previewPlaceholder
|
|
750
|
-
} : {
|
|
751
|
-
...selectedOption,
|
|
752
|
-
value: selectedOption?.value ?? ""
|
|
753
|
-
}, {
|
|
754
|
-
asPlaceholder: selectedOption === void 0,
|
|
755
|
-
showValue: false,
|
|
756
|
-
isLoadingSelectedOption,
|
|
757
|
-
handleFetchSelectedOption: fetchSelectedOptionCallback ? handleFetchSelectedOption : void 0,
|
|
758
|
-
isFetchSelectedOptionSync,
|
|
759
|
-
className: cn$1("rounded-t-none pt-2")
|
|
760
|
-
}) : jsxRuntimeExports.jsx(IdAutocompleteListOption, { variant, icon: selectedOption?.icon ?? previewPlaceholder?.icon, title: selectedOption?.title ?? previewPlaceholder?.title, path: selectedOption?.path ?? previewPlaceholder?.path, value: selectedOption?.value ?? previewPlaceholder?.value ?? "", description: selectedOption?.description ?? previewPlaceholder?.description, asPlaceholder: selectedOption === void 0, showValue: false, isLoadingSelectedOption, handleFetchSelectedOption: fetchSelectedOptionCallback ? handleFetchSelectedOption : void 0, isFetchSelectedOptionSync, className: cn$1("rounded-t-none pt-2") })), jsxRuntimeExports.jsx(PopoverContent, { align: "start", onOpenAutoFocus: (e) => e.preventDefault(), onInteractOutside: (e) => {
|
|
761
|
-
if (e.target instanceof Element && e.target.id === id) {
|
|
762
|
-
e.preventDefault();
|
|
763
|
-
}
|
|
764
|
-
}, children: jsxRuntimeExports.jsx(IdAutocompleteList, { variant, commandListRef, selectedValue, options, toggleOption: handleOptionSelection, renderOption, previewPlaceholder }) })] }) }) : jsxRuntimeExports.jsx(ValueTransformer, { transformers, children: jsxRuntimeExports.jsx(Input, { id, name: name2, value: selectedValue, className, disabled, onChange: handleChange, onBlur, onClick, onMouseDown, placeholder, "aria-invalid": hasError, "aria-label": !label ? "Id Autocomplete" : void 0, "aria-required": required, maxLength, ...props, ref: mergedRef }) }), !!description2 && jsxRuntimeExports.jsx(FormDescription, { children: description2 }), hasWarning && jsxRuntimeExports.jsx(FormMessageList, { messages: warnings, type: "warning" }), hasError && jsxRuntimeExports.jsx(FormMessageList, { messages: errors, type: "error" })] });
|
|
765
|
-
});
|
|
766
|
-
IdAutocomplete.displayName = "IdAutocomplete";
|
|
767
|
-
function cn(...inputs) {
|
|
768
|
-
return twMerge(clsx(inputs));
|
|
769
|
-
}
|
|
770
|
-
const inputBaseStyles = cn(
|
|
771
|
-
// Base styles
|
|
772
|
-
"flex h-9 w-full rounded-md text-sm font-normal leading-5 text-gray-900 dark:text-gray-50",
|
|
773
|
-
// Border & Background
|
|
774
|
-
"dark:border-charcoal-700 dark:bg-charcoal-900 border border-gray-300 bg-white",
|
|
775
|
-
// Padding
|
|
776
|
-
"px-3 py-2",
|
|
777
|
-
// Placeholder
|
|
778
|
-
"font-sans placeholder:text-gray-500 dark:placeholder:text-gray-600",
|
|
779
|
-
// Focus styles
|
|
780
|
-
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-900 focus-visible:ring-offset-0 focus-visible:ring-offset-white",
|
|
781
|
-
"dark:focus-visible:ring-charcoal-300 dark:focus-visible:ring-offset-charcoal-900 dark:focus:bg-charcoal-900 focus:bg-gray-50",
|
|
782
|
-
// Disabled state
|
|
783
|
-
"disabled:cursor-not-allowed",
|
|
784
|
-
"disabled:border-gray-300 disabled:bg-gray-50 disabled:text-gray-700",
|
|
785
|
-
"disabled:dark:border-charcoal-800 disabled:dark:bg-charcoal-900 disabled:dark:text-gray-300"
|
|
786
|
-
);
|
|
787
|
-
const Input = reactExports.forwardRef(({ className, type: type2, ...props }, ref) => {
|
|
788
|
-
return jsxRuntimeExports.jsx("input", { type: type2, className: cn(inputBaseStyles, className), ref, ...props });
|
|
789
|
-
});
|
|
790
|
-
Input.displayName = "Input";
|
|
791
|
-
const withFieldValidation = (Component, options) => {
|
|
792
|
-
return reactExports.forwardRef(({ value, name: name2, showErrorOnBlur, showErrorOnChange, validators: customValidators, ...props }, ref) => {
|
|
793
|
-
const { onChange: onChangeProp, onBlur: onBlurProp } = props;
|
|
794
|
-
const { control, formState: { errors: formErrors, defaultValues }, trigger, setValue, getValues } = useFormContext();
|
|
795
|
-
const { submitCount } = useFormState();
|
|
796
|
-
if (!name2) {
|
|
797
|
-
throw new Error(`[Field: ${Component.displayName}] The name prop is required.`);
|
|
798
|
-
}
|
|
799
|
-
const errors = [
|
|
800
|
-
...formErrors[name2]?.types ? Object.values(formErrors[name2].types ?? []) : []
|
|
801
|
-
];
|
|
802
|
-
if (errors.length === 0 && !!formErrors[name2]) {
|
|
803
|
-
errors.push("Invalid value");
|
|
804
|
-
}
|
|
805
|
-
reactExports.useEffect(() => {
|
|
806
|
-
if (submitCount > 0) {
|
|
807
|
-
void trigger(name2);
|
|
808
|
-
}
|
|
809
|
-
}, [props.required]);
|
|
810
|
-
reactExports.useEffect(() => {
|
|
811
|
-
if (props.errors && props.errors.length > 0) {
|
|
812
|
-
void trigger(name2);
|
|
813
|
-
}
|
|
814
|
-
}, [name2, props.errors, trigger]);
|
|
815
|
-
const [initialized, setInitialized] = reactExports.useState(false);
|
|
816
|
-
reactExports.useEffect(() => {
|
|
817
|
-
if (initialized) {
|
|
818
|
-
setValue(name2, value);
|
|
819
|
-
}
|
|
820
|
-
setInitialized(true);
|
|
821
|
-
}, [name2, value]);
|
|
822
|
-
if (value !== void 0 && !onChangeProp) {
|
|
823
|
-
console.warn(`[Field: ${name2}] Value prop provided without onChange so it will be ignored. Use disabled/readOnly if you want to prevent changes.`);
|
|
824
|
-
}
|
|
825
|
-
return jsxRuntimeExports.jsx(Controller, { control, name: name2, defaultValue: value ?? props.defaultValue, disabled: props.disabled, render: ({ field: {
|
|
826
|
-
// just preventing that onChange is included in the rest of the props
|
|
827
|
-
onChange: _,
|
|
828
|
-
onBlur: onBlurController,
|
|
829
|
-
value: internalValue,
|
|
830
|
-
...rest
|
|
831
|
-
} }) => {
|
|
832
|
-
const onBlurCallback = reactExports.useCallback((event) => {
|
|
833
|
-
if (showErrorOnBlur) {
|
|
834
|
-
void trigger(name2);
|
|
835
|
-
} else {
|
|
836
|
-
onBlurController();
|
|
837
|
-
}
|
|
838
|
-
if (onBlurProp) {
|
|
839
|
-
onBlurProp(event);
|
|
840
|
-
}
|
|
841
|
-
}, [onBlurController, showErrorOnBlur]);
|
|
842
|
-
const onChangeCallback = reactExports.useCallback(
|
|
843
|
-
(event) => {
|
|
844
|
-
if (onChangeProp) {
|
|
845
|
-
if (Object.hasOwn(event, "target")) {
|
|
846
|
-
setValue(name2, event.target.value);
|
|
847
|
-
} else {
|
|
848
|
-
setValue(name2, event);
|
|
849
|
-
}
|
|
850
|
-
onChangeProp(event);
|
|
851
|
-
} else {
|
|
852
|
-
let value2 = event;
|
|
853
|
-
if (event instanceof Event || event.target instanceof HTMLElement) {
|
|
854
|
-
value2 = event.target.value;
|
|
855
|
-
}
|
|
856
|
-
setValue(name2, value2);
|
|
857
|
-
}
|
|
858
|
-
if (showErrorOnChange === void 0 && showErrorOnBlur === void 0) {
|
|
859
|
-
if (submitCount > 0) {
|
|
860
|
-
void trigger(name2);
|
|
861
|
-
}
|
|
862
|
-
} else {
|
|
863
|
-
if (showErrorOnChange) {
|
|
864
|
-
void trigger(name2);
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
},
|
|
868
|
-
// `internalValue` is the value of the field that is controlled by the form
|
|
869
|
-
// it is used to trigger the validation on change, so we need to add it to the dependencies
|
|
870
|
-
// otherwise the validation will not be triggered on change
|
|
871
|
-
[internalValue, showErrorOnChange, showErrorOnBlur, submitCount]
|
|
872
|
-
);
|
|
873
|
-
const { ref: formFieldRef } = rest;
|
|
874
|
-
const combinedRef = (element) => {
|
|
875
|
-
if (typeof ref === "function") {
|
|
876
|
-
ref(element);
|
|
877
|
-
} else if (ref) {
|
|
878
|
-
ref.current = element;
|
|
879
|
-
}
|
|
880
|
-
formFieldRef(element);
|
|
881
|
-
};
|
|
882
|
-
return jsxRuntimeExports.jsx(Component, { ...props, ...rest, value: internalValue, onBlur: onBlurCallback, onChange: onChangeCallback, errors, ref: combinedRef });
|
|
883
|
-
}, rules: {
|
|
884
|
-
...props.required ? {
|
|
885
|
-
required: {
|
|
886
|
-
value: props.required,
|
|
887
|
-
message: "This field is required"
|
|
888
|
-
}
|
|
889
|
-
} : {
|
|
890
|
-
required: void 0
|
|
891
|
-
},
|
|
892
|
-
...props.pattern && {
|
|
893
|
-
pattern: {
|
|
894
|
-
value: new RegExp(props.pattern),
|
|
895
|
-
message: "This field does not match the required pattern"
|
|
896
|
-
}
|
|
897
|
-
},
|
|
898
|
-
...props.maxLength !== void 0 && props.maxLength >= 0 ? {
|
|
899
|
-
maxLength: {
|
|
900
|
-
value: props.maxLength,
|
|
901
|
-
message: `This field must be at most ${props.maxLength} characters`
|
|
902
|
-
}
|
|
903
|
-
} : {
|
|
904
|
-
maxLength: void 0
|
|
905
|
-
},
|
|
906
|
-
...props.minLength !== void 0 && props.minLength >= 0 ? {
|
|
907
|
-
minLength: {
|
|
908
|
-
value: props.minLength,
|
|
909
|
-
message: `This field must be at least ${props.minLength} characters`
|
|
910
|
-
}
|
|
911
|
-
} : {
|
|
912
|
-
minLength: void 0
|
|
913
|
-
},
|
|
914
|
-
...props.minValue && {
|
|
915
|
-
min: {
|
|
916
|
-
value: props.minValue,
|
|
917
|
-
message: `This field must be greater than or equal to ${props.minValue}`
|
|
918
|
-
}
|
|
919
|
-
},
|
|
920
|
-
...props.maxValue && {
|
|
921
|
-
max: {
|
|
922
|
-
value: props.maxValue,
|
|
923
|
-
message: `This field must be less than or equal to ${props.maxValue}`
|
|
924
|
-
}
|
|
925
|
-
},
|
|
926
|
-
validate: {
|
|
927
|
-
// custom errors provided as props
|
|
928
|
-
...props.errors ? Object.fromEntries(Array.isArray(props.errors) ? props.errors.map((error, index) => [
|
|
929
|
-
`_propError${index}`,
|
|
930
|
-
() => error
|
|
931
|
-
]) : []) : {},
|
|
932
|
-
// built in validations by the field in the library
|
|
933
|
-
...{},
|
|
934
|
-
// custom validations by the user/developer
|
|
935
|
-
...customValidators !== void 0 ? Object.fromEntries((Array.isArray(customValidators) ? customValidators : [customValidators]).map((validator, index) => [
|
|
936
|
-
`customValidation${index}`,
|
|
937
|
-
validator
|
|
938
|
-
])) : {}
|
|
939
|
-
}
|
|
940
|
-
} });
|
|
941
|
-
});
|
|
942
|
-
};
|
|
943
|
-
const renderIcon = (IconComponent) => {
|
|
944
|
-
if (typeof IconComponent === "string") {
|
|
945
|
-
return jsxRuntimeExports.jsx(Icon, { name: IconComponent, size: 16, className: cn$1("text-gray-700 dark:text-gray-400") });
|
|
946
|
-
}
|
|
947
|
-
return IconComponent && jsxRuntimeExports.jsx(IconComponent, { className: cn$1("size-4", "text-gray-700 dark:text-gray-400") });
|
|
948
|
-
};
|
|
949
|
-
const CommandItemList = ({ options = [], selectedValues, multiple, selectionIcon, selectionIconPosition, hasAnyIcon, toggleOption, tabIndex }) => {
|
|
950
|
-
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: options.map((opt) => {
|
|
951
|
-
const isSelected = selectedValues.includes(opt.value);
|
|
952
|
-
return jsxRuntimeExports.jsxs(CommandItem, { tabIndex, value: opt.label, onSelect: () => !opt.disabled && toggleOption(opt.value), disabled: opt.disabled, className: cn$1("cursor-pointer", "data-[selected=true]:bg-gray-100 dark:data-[selected=true]:bg-gray-900", opt.disabled && "!pointer-events-auto cursor-not-allowed hover:bg-transparent dark:hover:bg-transparent"), role: "option", "aria-selected": isSelected, children: [selectionIcon === "auto" && (multiple ? jsxRuntimeExports.jsx("div", { className: cn$1("flex size-4 items-center justify-center rounded-md border", "border-gray-700 dark:border-gray-400", isSelected && "bg-gray-900 text-slate-50 dark:bg-gray-400 dark:text-black"), children: isSelected && jsxRuntimeExports.jsx(Icon, { name: "Checkmark", size: 16 }) }) : jsxRuntimeExports.jsx("div", { className: cn$1("relative size-4 rounded-full border", isSelected ? "border-gray-900 dark:border-gray-400" : "border-gray-800 dark:border-gray-400", "bg-transparent dark:bg-transparent"), children: isSelected && jsxRuntimeExports.jsx("div", { className: "absolute left-1/2 top-1/2 size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-gray-900 dark:bg-gray-400" }) })), selectionIcon === "checkmark" && !(selectionIconPosition === "right" && hasAnyIcon) && jsxRuntimeExports.jsx("div", { className: "size-4", children: selectionIconPosition === "left" && isSelected && jsxRuntimeExports.jsx(Icon, { name: "Checkmark", size: 16, className: "text-gray-900 dark:text-gray-50" }) }), renderIcon(opt.icon), jsxRuntimeExports.jsx("span", { className: cn$1("flex-1 truncate text-[14px] font-normal leading-4", "text-gray-700 dark:text-gray-500", opt.disabled && "text-gray-600 dark:text-gray-600"), children: opt.label }), selectionIcon === "checkmark" && selectionIconPosition === "right" && jsxRuntimeExports.jsx("div", { className: "size-4", children: isSelected && jsxRuntimeExports.jsx(Icon, { name: "Checkmark", size: 16, className: "text-gray-900 dark:text-gray-50" }) })] }, `favorite-${opt.value}`);
|
|
953
|
-
}) });
|
|
954
|
-
};
|
|
955
|
-
const Content = ({ searchable, commandListRef, multiple, selectedValues, selectionIcon, selectionIconPosition, options = [], toggleAll, toggleOption, favoriteOptions = [] }) => {
|
|
956
|
-
const enabledOptions = options.filter((opt) => !opt.disabled);
|
|
957
|
-
const hasAnyIcon = options.some((opt) => opt.icon);
|
|
958
|
-
const cmdkSearch = P((state) => state.search);
|
|
959
|
-
reactExports.useEffect(() => {
|
|
960
|
-
commandListRef.current?.scrollTo({ top: 0, behavior: "instant" });
|
|
961
|
-
}, [commandListRef, cmdkSearch]);
|
|
962
|
-
return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [searchable && jsxRuntimeExports.jsx(CommandInput, { placeholder: "Search...", onKeyDown: (e) => {
|
|
963
|
-
const isOptionsRelatedKey = [
|
|
964
|
-
"ArrowUp",
|
|
965
|
-
"ArrowDown",
|
|
966
|
-
"Enter"
|
|
967
|
-
].includes(e.key);
|
|
968
|
-
if (!(isOptionsRelatedKey && enabledOptions.length > 0)) {
|
|
969
|
-
e.stopPropagation();
|
|
970
|
-
}
|
|
971
|
-
}, wrapperClassName: "rounded-t", className: "text-gray-900 dark:text-gray-50" }), jsxRuntimeExports.jsxs(CommandList, { ref: commandListRef, tabIndex: !searchable ? 0 : void 0, children: [jsxRuntimeExports.jsx(CommandEmpty, { className: "p-4 text-center text-[14px] font-normal leading-5 text-gray-700 dark:text-gray-400", children: "No results found." }), multiple && cmdkSearch === "" && jsxRuntimeExports.jsx(CommandGroup, { className: "pb-0", children: jsxRuntimeExports.jsx(CommandItem, { value: "select-all", onSelect: toggleAll, disabled: false, className: cn$1("cursor-pointer", "data-[selected=true]:bg-gray-100 dark:data-[selected=true]:bg-gray-900"), role: "option", "aria-selected": selectedValues.length === enabledOptions.length, children: jsxRuntimeExports.jsxs("div", { className: "flex w-full items-center gap-2", children: [selectionIcon === "auto" && jsxRuntimeExports.jsx("div", { className: cn$1("flex size-4 items-center justify-center rounded-md border", "border-gray-700 dark:border-gray-400", selectedValues.length === enabledOptions.length && "bg-gray-900 text-slate-50 dark:bg-gray-400 dark:text-black"), children: selectedValues.length === enabledOptions.length && jsxRuntimeExports.jsx(Icon, { name: "Checkmark", size: 16 }) }), selectionIcon === "checkmark" && !(selectionIconPosition === "right" && hasAnyIcon) && jsxRuntimeExports.jsx("div", { className: "size-4", children: selectionIconPosition === "left" && selectedValues.length === enabledOptions.length && jsxRuntimeExports.jsx(Icon, { name: "Checkmark", size: 16, className: "text-gray-900 dark:text-gray-50" }) }), jsxRuntimeExports.jsx("span", { className: "text-[14px] font-semibold leading-4 text-gray-900 dark:text-gray-50", children: selectedValues.length === enabledOptions.length ? "Deselect All" : "Select All" }), selectionIcon === "checkmark" && selectionIconPosition === "right" && jsxRuntimeExports.jsx("div", { className: "ml-auto size-4", children: selectedValues.length === enabledOptions.length && jsxRuntimeExports.jsx(Icon, { name: "Checkmark", size: 16, className: "text-gray-900 dark:text-gray-50" }) })] }) }) }), jsxRuntimeExports.jsxs(CommandGroup, { className: multiple && cmdkSearch === "" ? "pt-0" : void 0, children: [jsxRuntimeExports.jsx(CommandItemList, { options: favoriteOptions, selectedValues, multiple, selectionIcon, selectionIconPosition, hasAnyIcon, toggleOption, tabIndex: !searchable ? 0 : void 0 }), favoriteOptions.length > 0 && jsxRuntimeExports.jsx("div", { className: "my-1 border-b border-gray-300 dark:border-gray-600" }), jsxRuntimeExports.jsx(CommandItemList, { options, selectedValues, multiple, selectionIcon, selectionIconPosition, hasAnyIcon, toggleOption, tabIndex: !searchable ? 0 : void 0 })] })] })] });
|
|
972
|
-
};
|
|
973
|
-
const SelectedContent = ({ selectedValues, options = [], multiple, searchable, placeholder, handleClear }) => {
|
|
974
|
-
const renderIcon2 = (IconComponent) => {
|
|
975
|
-
if (typeof IconComponent === "string") {
|
|
976
|
-
return jsxRuntimeExports.jsx(Icon, { name: IconComponent, size: 16 });
|
|
977
|
-
}
|
|
978
|
-
return IconComponent && jsxRuntimeExports.jsx(IconComponent, { className: "size-4" });
|
|
979
|
-
};
|
|
980
|
-
if (selectedValues.length === 0) {
|
|
981
|
-
return jsxRuntimeExports.jsxs("div", { className: cn$1("mx-auto flex w-full items-center", placeholder ? "justify-between" : "justify-end"), children: [placeholder && jsxRuntimeExports.jsx("span", { className: "text-[14px] font-normal leading-5 text-gray-600 dark:text-gray-500", children: placeholder }), searchable ? jsxRuntimeExports.jsx(Icon, { name: "CaretSort", size: 16, className: "cursor-pointer text-gray-700 dark:text-gray-400" }) : jsxRuntimeExports.jsx(Icon, { name: "ChevronDown", size: 16, className: "cursor-pointer text-gray-700 dark:text-gray-400" })] });
|
|
982
|
-
}
|
|
983
|
-
return jsxRuntimeExports.jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [jsxRuntimeExports.jsx("div", { className: cn$1("max-w-full truncate text-gray-900 dark:text-gray-50", !multiple && "flex items-center gap-2"), children: selectedValues.map((value, index) => {
|
|
984
|
-
const option = options.find((o) => o.value === value);
|
|
985
|
-
return !multiple ? jsxRuntimeExports.jsxs(React.Fragment, { children: [renderIcon2(option?.icon), jsxRuntimeExports.jsx("span", { className: "truncate text-[14px] font-normal leading-5", children: option?.label })] }, value) : jsxRuntimeExports.jsx("span", { className: cn$1("text-[14px] font-normal leading-5", index !== selectedValues.length - 1 && "mr-1"), children: index !== selectedValues.length - 1 ? `${option?.label},` : option?.label }, value);
|
|
986
|
-
}) }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2", children: [multiple && selectedValues.length > 0 && jsxRuntimeExports.jsx("div", { onClick: (e) => {
|
|
987
|
-
e.preventDefault();
|
|
988
|
-
e.stopPropagation();
|
|
989
|
-
handleClear();
|
|
990
|
-
}, className: "size-4 p-0", children: jsxRuntimeExports.jsx(Icon, { name: "XmarkLight", size: 16, className: "cursor-pointer text-gray-700 dark:text-gray-400" }) }), searchable ? jsxRuntimeExports.jsx(Icon, { name: "CaretSort", size: 16, className: "cursor-pointer text-gray-700 dark:text-gray-400" }) : jsxRuntimeExports.jsx(Icon, { name: "ChevronDown", size: 16, className: "cursor-pointer text-gray-700 dark:text-gray-400" })] })] });
|
|
991
|
-
};
|
|
992
|
-
function useSelectField({ options = [], multiple = false, defaultValue, value, onChange }) {
|
|
993
|
-
const isInternalChange = reactExports.useRef(false);
|
|
994
|
-
const commandListRef = reactExports.useRef(null);
|
|
995
|
-
const [isPopoverOpen, setIsPopoverOpen] = reactExports.useState(false);
|
|
996
|
-
const [selectedValues, setSelectedValues] = reactExports.useState(() => {
|
|
997
|
-
const initialValue = value ?? defaultValue ?? [];
|
|
998
|
-
if (initialValue === "") {
|
|
999
|
-
return [];
|
|
1000
|
-
}
|
|
1001
|
-
return Array.isArray(initialValue) ? initialValue : [initialValue];
|
|
1002
|
-
});
|
|
1003
|
-
reactExports.useEffect(() => {
|
|
1004
|
-
if (isInternalChange.current) {
|
|
1005
|
-
isInternalChange.current = false;
|
|
1006
|
-
return;
|
|
1007
|
-
}
|
|
1008
|
-
const newValue = value ?? defaultValue ?? [];
|
|
1009
|
-
if (newValue === "") {
|
|
1010
|
-
setSelectedValues([]);
|
|
1011
|
-
} else {
|
|
1012
|
-
setSelectedValues(Array.isArray(newValue) ? newValue : [newValue]);
|
|
1013
|
-
}
|
|
1014
|
-
}, [value]);
|
|
1015
|
-
const handleOpenChange = reactExports.useCallback((open) => {
|
|
1016
|
-
setIsPopoverOpen(open);
|
|
1017
|
-
}, []);
|
|
1018
|
-
const toggleOption = reactExports.useCallback((optionValue) => {
|
|
1019
|
-
isInternalChange.current = true;
|
|
1020
|
-
let newValues;
|
|
1021
|
-
if (multiple) {
|
|
1022
|
-
newValues = selectedValues.includes(optionValue) ? selectedValues.filter((v) => v !== optionValue) : [...selectedValues, optionValue];
|
|
1023
|
-
} else {
|
|
1024
|
-
newValues = selectedValues[0] === optionValue ? [] : [optionValue];
|
|
1025
|
-
setIsPopoverOpen(false);
|
|
1026
|
-
}
|
|
1027
|
-
setSelectedValues(newValues);
|
|
1028
|
-
onChange?.(multiple ? newValues : newValues[0] ?? "");
|
|
1029
|
-
}, [multiple, selectedValues, options, onChange]);
|
|
1030
|
-
const handleClear = reactExports.useCallback(() => {
|
|
1031
|
-
isInternalChange.current = true;
|
|
1032
|
-
setSelectedValues([]);
|
|
1033
|
-
onChange?.(multiple ? [] : "");
|
|
1034
|
-
}, [multiple, onChange]);
|
|
1035
|
-
const toggleAll = reactExports.useCallback(() => {
|
|
1036
|
-
isInternalChange.current = true;
|
|
1037
|
-
const enabledOptions = options.filter((opt) => !opt.disabled).map((opt) => opt.value);
|
|
1038
|
-
const newValues = selectedValues.length === enabledOptions.length ? [] : enabledOptions;
|
|
1039
|
-
setSelectedValues(newValues);
|
|
1040
|
-
onChange?.(multiple ? newValues : newValues[0]);
|
|
1041
|
-
}, [options, selectedValues, multiple, onChange]);
|
|
1042
|
-
const prevMultiple = reactExports.useRef(multiple);
|
|
1043
|
-
reactExports.useEffect(() => {
|
|
1044
|
-
if (prevMultiple.current === multiple) {
|
|
1045
|
-
return;
|
|
1046
|
-
}
|
|
1047
|
-
prevMultiple.current = multiple;
|
|
1048
|
-
if (!multiple && selectedValues.length > 1) {
|
|
1049
|
-
isInternalChange.current = true;
|
|
1050
|
-
setSelectedValues([selectedValues[0]]);
|
|
1051
|
-
onChange?.(selectedValues[0]);
|
|
1052
|
-
return;
|
|
1053
|
-
}
|
|
1054
|
-
if (selectedValues.length > 0) {
|
|
1055
|
-
isInternalChange.current = true;
|
|
1056
|
-
onChange?.(multiple ? [selectedValues[0]] : selectedValues[0]);
|
|
1057
|
-
}
|
|
1058
|
-
}, [multiple]);
|
|
1059
|
-
return {
|
|
1060
|
-
selectedValues,
|
|
1061
|
-
isPopoverOpen,
|
|
1062
|
-
commandListRef,
|
|
1063
|
-
toggleOption,
|
|
1064
|
-
handleClear,
|
|
1065
|
-
toggleAll,
|
|
1066
|
-
handleOpenChange
|
|
1067
|
-
};
|
|
1068
|
-
}
|
|
1069
|
-
const SelectFieldRaw = React.forwardRef(({
|
|
1070
|
-
// core functionality props
|
|
1071
|
-
options = [],
|
|
1072
|
-
favoriteOptions = [],
|
|
1073
|
-
defaultValue,
|
|
1074
|
-
value,
|
|
1075
|
-
onChange,
|
|
1076
|
-
onBlur,
|
|
1077
|
-
// form-related props
|
|
1078
|
-
id: propId,
|
|
1079
|
-
name: name2,
|
|
1080
|
-
label,
|
|
1081
|
-
required,
|
|
1082
|
-
disabled,
|
|
1083
|
-
// validation props
|
|
1084
|
-
errors = [],
|
|
1085
|
-
warnings = [],
|
|
1086
|
-
// behavior props
|
|
1087
|
-
multiple,
|
|
1088
|
-
selectionIcon = "auto",
|
|
1089
|
-
selectionIconPosition = "left",
|
|
1090
|
-
searchable,
|
|
1091
|
-
// display props
|
|
1092
|
-
description: description2,
|
|
1093
|
-
placeholder,
|
|
1094
|
-
className,
|
|
1095
|
-
contentClassName,
|
|
1096
|
-
contentAlign = "start",
|
|
1097
|
-
...props
|
|
1098
|
-
}, ref) => {
|
|
1099
|
-
const prefix = reactExports.useId();
|
|
1100
|
-
const id = propId ?? `${prefix}-select`;
|
|
1101
|
-
const { selectedValues, isPopoverOpen, commandListRef, toggleOption, handleClear, toggleAll, handleOpenChange } = useSelectField({
|
|
1102
|
-
options,
|
|
1103
|
-
multiple,
|
|
1104
|
-
defaultValue,
|
|
1105
|
-
value,
|
|
1106
|
-
onChange
|
|
1107
|
-
});
|
|
1108
|
-
const onTriggerBlur = reactExports.useCallback((e) => {
|
|
1109
|
-
if (!isPopoverOpen) {
|
|
1110
|
-
onBlur?.(e);
|
|
1111
|
-
}
|
|
1112
|
-
}, [onBlur, isPopoverOpen]);
|
|
1113
|
-
return jsxRuntimeExports.jsxs(FormGroup, { children: [label && jsxRuntimeExports.jsx(FormLabel, { htmlFor: id, required, disabled, hasError: errors.length > 0, inline: false, onClick: (e) => {
|
|
1114
|
-
e.preventDefault();
|
|
1115
|
-
e.target.control?.focus();
|
|
1116
|
-
}, children: label }), jsxRuntimeExports.jsxs(Popover, { open: isPopoverOpen, onOpenChange: (open) => {
|
|
1117
|
-
handleOpenChange(open);
|
|
1118
|
-
if (!open && document.activeElement?.id !== id) {
|
|
1119
|
-
onBlur?.({ target: {} });
|
|
1120
|
-
}
|
|
1121
|
-
}, children: [jsxRuntimeExports.jsx(PopoverTrigger, { asChild: true, children: jsxRuntimeExports.jsx(Button, { id, name: name2, type: "button", role: "combobox", onBlur: onTriggerBlur, disabled, "aria-invalid": errors.length > 0, "aria-label": label ? void 0 : multiple ? "Multi select" : "Select", "aria-required": required, "aria-expanded": isPopoverOpen, className: cn$1("flex h-9 w-full items-center justify-between px-3 py-2", "dark:border-charcoal-700 dark:bg-charcoal-900 rounded-md border border-gray-300 bg-white", "hover:border-gray-300 hover:bg-gray-100", "dark:hover:border-charcoal-700 dark:hover:bg-charcoal-800", "dark:focus:ring-charcoal-300 focus:outline-none focus:ring-1 focus:ring-gray-900 focus:ring-offset-0", "dark:focus-visible:ring-charcoal-300 focus-visible:ring-1 focus-visible:ring-gray-900 focus-visible:ring-offset-0", disabled && [
|
|
1122
|
-
"!pointer-events-auto cursor-not-allowed bg-gray-50",
|
|
1123
|
-
"dark:hover:border-charcoal-700 dark:hover:bg-charcoal-900 hover:border-gray-300 hover:bg-gray-50"
|
|
1124
|
-
], className), ...props, ref, children: jsxRuntimeExports.jsx(SelectedContent, { selectedValues, options: [...favoriteOptions, ...options], multiple, searchable, placeholder, handleClear }) }) }), jsxRuntimeExports.jsx(PopoverContent, { align: contentAlign, onEscapeKeyDown: (e) => {
|
|
1125
|
-
e.preventDefault();
|
|
1126
|
-
handleOpenChange(false);
|
|
1127
|
-
}, className: contentClassName, children: jsxRuntimeExports.jsx(Command, { defaultValue: !multiple && selectedValues[0] ? options.find((opt) => opt.value === selectedValues[0])?.label : void 0, children: jsxRuntimeExports.jsx(Content, { favoriteOptions, searchable, commandListRef, multiple, selectedValues, selectionIcon, selectionIconPosition, options, toggleAll, toggleOption }) }) })] }), description2 && jsxRuntimeExports.jsx(FormDescription, { children: description2 }), warnings.length > 0 && jsxRuntimeExports.jsx(FormMessageList, { messages: warnings, type: "warning" }), errors.length > 0 && jsxRuntimeExports.jsx(FormMessageList, { messages: errors, type: "error" })] });
|
|
1128
|
-
});
|
|
1129
|
-
const SelectField = withFieldValidation(SelectFieldRaw);
|
|
1130
|
-
SelectField.displayName = "SelectField";
|
|
1131
|
-
const TooltipContent = reactExports.forwardRef(({ children, className, ...props }, ref) => {
|
|
1132
|
-
return jsxRuntimeExports.jsx(Content2, { ref, ...props, className: cn$1(
|
|
1133
|
-
// Base styles
|
|
1134
|
-
"z-50 overflow-hidden rounded-md text-sm",
|
|
1135
|
-
// Colors & Border
|
|
1136
|
-
"border border-gray-200 bg-white text-gray-900 dark:border-gray-900 dark:bg-slate-900 dark:text-gray-200",
|
|
1137
|
-
// Padding & Shadow
|
|
1138
|
-
"px-3 py-1.5 shadow-md",
|
|
1139
|
-
// Animations
|
|
1140
|
-
"data-[state=open]:animate-fade-in data-[state=open]:animate-zoom-in",
|
|
1141
|
-
"data-[state=closed]:animate-fade-out data-[state=closed]:animate-zoom-out",
|
|
1142
|
-
// Slide animations based on position
|
|
1143
|
-
"data-[side=bottom]:animate-slide-in-from-top",
|
|
1144
|
-
"data-[side=left]:animate-slide-in-from-right",
|
|
1145
|
-
"data-[side=right]:animate-slide-in-from-left",
|
|
1146
|
-
"data-[side=top]:animate-slide-in-from-bottom",
|
|
1147
|
-
className
|
|
1148
|
-
), children });
|
|
1149
|
-
});
|
|
1150
|
-
const Tooltip = ({ content, children, triggerAsChild = false, delayDuration = 0, ...props }) => {
|
|
1151
|
-
const { open, defaultOpen, onOpenChange, ...rest } = props;
|
|
1152
|
-
return jsxRuntimeExports.jsxs(Root3, { defaultOpen, delayDuration, onOpenChange, open, children: [jsxRuntimeExports.jsx(Trigger, { asChild: triggerAsChild, type: triggerAsChild ? void 0 : "button", children }), jsxRuntimeExports.jsx(Portal$1, { children: jsxRuntimeExports.jsx(TooltipContent, { sideOffset: 3, ...rest, children: content }) })] });
|
|
1153
|
-
};
|
|
1154
|
-
function setNativeValue(element, value) {
|
|
1155
|
-
const valueSetter = Object.getOwnPropertyDescriptor(element, "value")?.set;
|
|
1156
|
-
const prototype = Object.getPrototypeOf(element);
|
|
1157
|
-
const prototypeValueSetter = Object.getOwnPropertyDescriptor(prototype, "value")?.set;
|
|
1158
|
-
if (valueSetter && valueSetter !== prototypeValueSetter) {
|
|
1159
|
-
prototypeValueSetter?.call(element, value);
|
|
1160
|
-
} else {
|
|
1161
|
-
valueSetter?.call(element, value);
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
function _applyTransformers(transformers, value, filter = "blur") {
|
|
1165
|
-
return transformers.reduce((value2, transformer) => {
|
|
1166
|
-
if (typeof transformer === "function") {
|
|
1167
|
-
if (filter === "blur" || filter === "all") {
|
|
1168
|
-
return transformer(value2);
|
|
1169
|
-
}
|
|
1170
|
-
return value2;
|
|
1171
|
-
}
|
|
1172
|
-
if ((transformer.options?.trigger ?? "blur") !== filter && filter !== "all") {
|
|
1173
|
-
return value2;
|
|
1174
|
-
}
|
|
1175
|
-
if (transformer.options?.if === void 0 || transformer.options.if) {
|
|
1176
|
-
return transformer.transformer(value2);
|
|
1177
|
-
}
|
|
1178
|
-
return value2;
|
|
1179
|
-
}, value);
|
|
1180
|
-
}
|
|
1181
|
-
function ValueTransformer({ transformers, children }) {
|
|
1182
|
-
const formContext = useFormContext();
|
|
1183
|
-
const setValue = formContext?.setValue;
|
|
1184
|
-
reactExports.useEffect(() => {
|
|
1185
|
-
const value = children.props.value;
|
|
1186
|
-
const transformedValue = _applyTransformers(transformers, value, "all");
|
|
1187
|
-
if (!deepEqual(transformedValue, value)) {
|
|
1188
|
-
if (typeof setValue === "function") {
|
|
1189
|
-
setValue(children.props.name, transformedValue);
|
|
1190
|
-
} else {
|
|
1191
|
-
children.props.onChange?.({
|
|
1192
|
-
target: { value: transformedValue }
|
|
1193
|
-
});
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
}, [transformers, setValue]);
|
|
1197
|
-
return React.cloneElement(children, {
|
|
1198
|
-
// @ts-expect-error - React.HTMLAttributes is not typed
|
|
1199
|
-
...children.props,
|
|
1200
|
-
onChange: (event) => {
|
|
1201
|
-
const transformedValue = _applyTransformers(transformers, event.target.value, "change");
|
|
1202
|
-
if (transformedValue !== event.target.value && setValue) {
|
|
1203
|
-
setValue(children.props.name, transformedValue);
|
|
1204
|
-
setNativeValue(event.target, transformedValue);
|
|
1205
|
-
}
|
|
1206
|
-
children.props.onChange?.(event);
|
|
1207
|
-
},
|
|
1208
|
-
// apply transformers on blur
|
|
1209
|
-
onBlur: (event) => {
|
|
1210
|
-
children.props.onBlur?.(event);
|
|
1211
|
-
const target = event.target;
|
|
1212
|
-
const transformedValue = _applyTransformers(transformers, target.value, "blur");
|
|
1213
|
-
if (!deepEqual(transformedValue, target.value)) {
|
|
1214
|
-
setNativeValue(target, transformedValue);
|
|
1215
|
-
const changeEvent = new Event("change", { bubbles: true });
|
|
1216
|
-
target.dispatchEvent(changeEvent);
|
|
1217
|
-
}
|
|
1218
|
-
},
|
|
1219
|
-
onKeyDown: (event) => {
|
|
1220
|
-
children.props.onKeyDown?.(event);
|
|
1221
|
-
if (event.key === "Enter") {
|
|
1222
|
-
const target = event.target;
|
|
1223
|
-
const transformedValue = _applyTransformers(transformers, target.value, "keyDown");
|
|
1224
|
-
if (!deepEqual(transformedValue, target.value)) {
|
|
1225
|
-
setNativeValue(target, transformedValue);
|
|
1226
|
-
const changeEvent = new Event("change", { bubbles: true });
|
|
1227
|
-
target.dispatchEvent(changeEvent);
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
});
|
|
1232
|
-
}
|
|
1233
|
-
function deepEqual(a, b, visited = /* @__PURE__ */ new Map()) {
|
|
1234
|
-
if (a === b) {
|
|
1235
|
-
return true;
|
|
1236
|
-
}
|
|
1237
|
-
if (a === null || b === null || a === void 0 || b === void 0) {
|
|
1238
|
-
return false;
|
|
1239
|
-
}
|
|
1240
|
-
if (typeof a !== typeof b) {
|
|
1241
|
-
return false;
|
|
1242
|
-
}
|
|
1243
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
1244
|
-
if (visited.get(a) === b) {
|
|
1245
|
-
return true;
|
|
1246
|
-
}
|
|
1247
|
-
visited.set(a, b);
|
|
1248
|
-
return a.length === b.length && a.every((value, index) => deepEqual(value, b[index], visited));
|
|
1249
|
-
}
|
|
1250
|
-
if (typeof a === "object" && typeof b === "object" && !Array.isArray(a) && !Array.isArray(b)) {
|
|
1251
|
-
if (visited.get(a) === b) {
|
|
1252
|
-
return true;
|
|
1253
|
-
}
|
|
1254
|
-
visited.set(a, b);
|
|
1255
|
-
const aKeys = Object.keys(a);
|
|
1256
|
-
const bKeys = Object.keys(b);
|
|
1257
|
-
return aKeys.length === bKeys.length && aKeys.every((key) => {
|
|
1258
|
-
return key in b && deepEqual(a[key], b[key], visited);
|
|
1259
|
-
});
|
|
1260
|
-
}
|
|
1261
|
-
return false;
|
|
1262
|
-
}
|
|
1263
|
-
const sharedValueTransformers = {
|
|
1264
|
-
trimOnBlur: (ifParam = true) => ({
|
|
1265
|
-
transformer: (value) => value?.trim(),
|
|
1266
|
-
options: {
|
|
1267
|
-
trigger: "blur",
|
|
1268
|
-
if: ifParam
|
|
1269
|
-
}
|
|
1270
|
-
}),
|
|
1271
|
-
lowercaseOnChange: (ifParam = true) => ({
|
|
1272
|
-
transformer: (value) => value?.toLowerCase(),
|
|
1273
|
-
options: {
|
|
1274
|
-
trigger: "change",
|
|
1275
|
-
if: ifParam
|
|
1276
|
-
}
|
|
1277
|
-
}),
|
|
1278
|
-
uppercaseOnChange: (ifParam = true) => ({
|
|
1279
|
-
transformer: (value) => value?.toUpperCase(),
|
|
1280
|
-
options: {
|
|
1281
|
-
trigger: "change",
|
|
1282
|
-
if: ifParam
|
|
1283
|
-
}
|
|
1284
|
-
}),
|
|
1285
|
-
trimOnEnter: (ifParam = true) => ({
|
|
1286
|
-
transformer: (value) => value?.trim(),
|
|
1287
|
-
options: {
|
|
1288
|
-
trigger: "keyDown",
|
|
1289
|
-
if: ifParam
|
|
1290
|
-
}
|
|
1291
|
-
})
|
|
1292
|
-
};
|
|
1293
|
-
const PH_DEPENDENCIES = [
|
|
1294
|
-
/^@powerhousedao\/.+$/,
|
|
1295
|
-
"document-drive",
|
|
1296
|
-
"document-model"
|
|
1297
|
-
];
|
|
1298
|
-
const PackageJsonSchema = objectType({
|
|
1299
|
-
version: stringType({ message: "Missing version field in package.json" }),
|
|
1300
|
-
dependencies: recordType(stringType(), stringType()).nullable(),
|
|
1301
|
-
devDependencies: recordType(stringType(), stringType()).nullable()
|
|
1302
|
-
}).refine((data) => data.dependencies != null || data.devDependencies != null, "package.json must have either dependencies or devDependencies").transform((data) => {
|
|
1303
|
-
const allDependencies = {
|
|
1304
|
-
...data.dependencies,
|
|
1305
|
-
...data.devDependencies
|
|
1306
|
-
};
|
|
1307
|
-
return {
|
|
1308
|
-
version: data.version,
|
|
1309
|
-
dependencies: Object.fromEntries(Object.entries(allDependencies).filter(([key]) => PH_DEPENDENCIES.some((regexOrName) => typeof regexOrName === "string" ? regexOrName === key : regexOrName.test(key))))
|
|
1310
|
-
};
|
|
1311
|
-
});
|
|
1312
|
-
function verifyPackageJsonFields(packageJson2) {
|
|
1313
|
-
const parsed = PackageJsonSchema.safeParse(packageJson2);
|
|
1314
|
-
if (!parsed.success) {
|
|
1315
|
-
console.error("Package.json validation failed:", parsed.error.format());
|
|
1316
|
-
return false;
|
|
1317
|
-
}
|
|
1318
|
-
return parsed.data;
|
|
1319
|
-
}
|
|
1320
|
-
function DependencyVersions(props) {
|
|
1321
|
-
const [isOpen, setIsOpen] = reactExports.useState(false);
|
|
1322
|
-
const { packageJson: packageJson2, phCliVersion } = props;
|
|
1323
|
-
const validatedData = verifyPackageJsonFields(packageJson2);
|
|
1324
|
-
if (!validatedData) {
|
|
1325
|
-
console.error("Failed to validate package.json data");
|
|
1326
|
-
return null;
|
|
1327
|
-
}
|
|
1328
|
-
return jsxRuntimeExports.jsx(Disclosure, { isOpen, onOpenChange: () => setIsOpen(!isOpen), title: `App version: ${validatedData.version}`, toggleClassName: "text-gray-900 text-sm", children: jsxRuntimeExports.jsxs("ul", { className: "text-sm text-gray-600", children: [Object.entries(validatedData.dependencies).map(([dep, version2]) => jsxRuntimeExports.jsxs("li", { className: "my-1 flex justify-between pr-1", children: [jsxRuntimeExports.jsxs("span", { children: [dep.replace("@powerhousedao/", ""), ":"] }), jsxRuntimeExports.jsx("span", { className: "font-normal", children: version2 })] }, dep)), phCliVersion && jsxRuntimeExports.jsxs("li", { className: "my-1 flex justify-between pr-1", children: [jsxRuntimeExports.jsx("span", { children: "@powerhousedao/ph-cli:" }), jsxRuntimeExports.jsx("span", { className: "font-normal", children: phCliVersion })] }, "ph-cli")] }) });
|
|
1329
|
-
}
|
|
1330
|
-
function About$1(props) {
|
|
1331
|
-
const { packageJson: packageJson2, phCliVersion } = props;
|
|
1332
|
-
return jsxRuntimeExports.jsxs("div", { className: "bg-white p-3", children: [jsxRuntimeExports.jsx("h2", { className: "font-semibold", children: "About" }), jsxRuntimeExports.jsx("p", { className: "text-sm font-normal text-gray-600", children: "Connect is the hub for your most important documents and processes translated into software. Easily capture data in a structured way with Connect." }), jsxRuntimeExports.jsx("div", { className: "my-4", children: jsxRuntimeExports.jsx(DependencyVersions, { packageJson: packageJson2, phCliVersion }) })] });
|
|
1333
|
-
}
|
|
1334
|
-
function DangerZone$1(props) {
|
|
1335
|
-
const { className, ...rest } = props;
|
|
1336
|
-
return jsxRuntimeExports.jsxs("div", { className: cn$1("h-full rounded-lg bg-white p-3", className), children: [jsxRuntimeExports.jsx("h2", { className: "mb-4 font-semibold", children: "Modify Drives" }), jsxRuntimeExports.jsx(ModifyDrives, { ...rest }), jsxRuntimeExports.jsx("h2", { className: "my-4 font-semibold", children: "Local Storage" }), jsxRuntimeExports.jsx(LocalStorage, { ...rest })] });
|
|
1337
|
-
}
|
|
1338
|
-
function ModifyDrives(props) {
|
|
1339
|
-
const { className, ...rest } = props;
|
|
1340
|
-
return jsxRuntimeExports.jsx("div", { className, children: jsxRuntimeExports.jsx(DriveList, { ...rest }) });
|
|
1341
|
-
}
|
|
1342
|
-
function DriveList(props) {
|
|
1343
|
-
const { className, ...rest } = props;
|
|
1344
|
-
return jsxRuntimeExports.jsx("div", { className, children: props.drives.map((drive) => jsxRuntimeExports.jsx(Drive, { drive, ...rest }, drive.header.id)) });
|
|
1345
|
-
}
|
|
1346
|
-
function Drive(props) {
|
|
1347
|
-
const { drive, className, onDeleteDrive } = props;
|
|
1348
|
-
const [isDropdownMenuOpen, setIsDropdownMenuOpen] = reactExports.useState(false);
|
|
1349
|
-
const localDriveIcon = jsxRuntimeExports.jsx(Icon, { name: "Hdd", size: 16, className: "flex-none" });
|
|
1350
|
-
const cloudDriveIcon = jsxRuntimeExports.jsx(Icon, { name: "Server", size: 16, className: "flex-none" });
|
|
1351
|
-
const publicDriveIcon = drive.state.global.icon ? jsxRuntimeExports.jsx("img", { alt: "drive icon", className: "size-4 flex-none object-contain", src: drive.state.global.icon }) : jsxRuntimeExports.jsx(Icon, { name: "M", size: 16, className: "flex-none" });
|
|
1352
|
-
function getNodeIcon() {
|
|
1353
|
-
const sharingType = getDriveSharingType(drive);
|
|
1354
|
-
if (sharingType === "PUBLIC") {
|
|
1355
|
-
return publicDriveIcon;
|
|
1356
|
-
}
|
|
1357
|
-
if (sharingType === "CLOUD") {
|
|
1358
|
-
return cloudDriveIcon;
|
|
1359
|
-
}
|
|
1360
|
-
return localDriveIcon;
|
|
1361
|
-
}
|
|
1362
|
-
const icon = getNodeIcon();
|
|
1363
|
-
return jsxRuntimeExports.jsxs("div", { className: cn$1("mb-4 flex w-96 items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 shadow-sm last-of-type:mb-0", className), children: [icon, jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("span", { className: "block text-sm font-medium leading-[18px]", children: capitalCase(drive.header.name) }), jsxRuntimeExports.jsxs("div", { className: "flex items-baseline gap-x-2 leading-[18px]", children: [jsxRuntimeExports.jsxs("span", { className: "text-sm text-gray-600", children: [capitalCase(getDriveSharingType(drive)), " App"] }), jsxRuntimeExports.jsxs("a", { className: "group flex items-center gap-x-2 text-sm text-slate-500 transition-colors hover:text-[#9896FF]", children: ["By Powerhouse", jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 12", className: "size-4 text-gray-400 transition-colors group-hover:text-inherit", children: jsxRuntimeExports.jsx("path", { d: "M7.99365 11.9939C9.46632 11.9939 10.6603 10.7999 10.6603 9.32722V7.32722C10.6603 6.95922 10.3617 6.66056 9.99365 6.66056C9.62565 6.66056 9.32699 6.95922 9.32699 7.32722V9.32722C9.32699 10.0639 8.73032 10.6606 7.99365 10.6606H2.66032C1.92365 10.6606 1.32699 10.0639 1.32699 9.32722V3.99389C1.32699 3.25723 1.92365 2.66056 2.66032 2.66056H4.66032C5.02832 2.66056 5.32699 2.36189 5.32699 1.99389C5.32699 1.6259 5.02832 1.32723 4.66032 1.32723H2.66032C1.18765 1.32723 -0.00634766 2.52123 -0.00634766 3.99389V9.32722C-0.00634766 10.7999 1.18765 11.9939 2.66032 11.9939H7.99365ZM5.32699 7.32722C5.49765 7.32722 5.67565 7.26989 5.80632 7.13989L10.1396 2.80656L11.9937 4.66056V-0.00610352H7.32699L9.18099 1.8479L4.84766 6.18123C4.58766 6.4419 4.58766 6.87922 4.84766 7.13989C4.97832 7.26989 5.15632 7.32722 5.32699 7.32722Z", fill: "currentColor" }) })] })] })] }), jsxRuntimeExports.jsx(ConnectDropdownMenu, { items: [
|
|
1364
|
-
{
|
|
1365
|
-
id: "delete-drive",
|
|
1366
|
-
label: "Delete",
|
|
1367
|
-
icon: jsxRuntimeExports.jsx(Icon, { name: "Trash" }),
|
|
1368
|
-
className: "text-red-900"
|
|
1369
|
-
}
|
|
1370
|
-
], onItemClick: (id) => {
|
|
1371
|
-
if (id === "delete-drive") {
|
|
1372
|
-
onDeleteDrive(drive);
|
|
1373
|
-
}
|
|
1374
|
-
}, onOpenChange: setIsDropdownMenuOpen, open: isDropdownMenuOpen, children: jsxRuntimeExports.jsx("button", { className: "group ml-auto flex-none", onClick: (e) => {
|
|
1375
|
-
e.stopPropagation();
|
|
1376
|
-
setIsDropdownMenuOpen(true);
|
|
1377
|
-
}, children: jsxRuntimeExports.jsx(Icon, { className: "text-gray-600 group-hover:text-gray-900", name: "VerticalDots", size: 16 }) }) })] });
|
|
1378
|
-
}
|
|
1379
|
-
function LocalStorage(props) {
|
|
1380
|
-
const { onClearStorage } = props;
|
|
1381
|
-
return jsxRuntimeExports.jsx("div", { children: jsxRuntimeExports.jsxs("button", { className: "flex items-center gap-x-2 rounded-md border border-gray-300 bg-transparent px-3 py-1 text-sm font-medium text-red-900 transition-colors hover:bg-gray-100", onClick: onClearStorage, children: ["Clear Storage ", jsxRuntimeExports.jsx(Icon, { name: "Trash", size: 16 })] }) });
|
|
1382
|
-
}
|
|
1383
|
-
function DefaultEditor$1(props) {
|
|
1384
|
-
const { className, ...rest } = props;
|
|
1385
|
-
return jsxRuntimeExports.jsx("div", { className: twMerge("rounded-lg p-3", className), children: jsxRuntimeExports.jsx(DefaultEditorSelect, { ...rest }) });
|
|
1386
|
-
}
|
|
1387
|
-
function DefaultEditorSelect(props) {
|
|
1388
|
-
const { documentModelEditor, setDocumentModelEditor, documentModelEditorOptions: documentModelEditorOptions2, className } = props;
|
|
1389
|
-
return jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("h3", { className: "mb-4 font-semibold text-gray-900", children: "Default Editor Selection" }), jsxRuntimeExports.jsx(SelectFieldRaw, { className: twMerge("min-w-36 max-w-fit", className), name: "default-editor", required: true, value: documentModelEditor, options: documentModelEditorOptions2, multiple: false, onChange: (value) => setDocumentModelEditor(value) })] });
|
|
1390
|
-
}
|
|
1391
|
-
const ProviderIconMap = {
|
|
1392
|
-
npm: { icon: "Npm" },
|
|
1393
|
-
github: { icon: "Github", size: 28 },
|
|
1394
|
-
local: { icon: "Hdd" }
|
|
1395
|
-
};
|
|
1396
|
-
const PackageItem = ({ packageName, provider }) => {
|
|
1397
|
-
const icon = provider && ProviderIconMap[provider];
|
|
1398
|
-
return jsxRuntimeExports.jsxs("div", { className: "flex w-full items-center justify-between px-2 py-1", children: [jsxRuntimeExports.jsx("p", { className: "font-medium", children: packageName }), icon && jsxRuntimeExports.jsx(Icon, { name: icon.icon, size: icon.size })] });
|
|
1399
|
-
};
|
|
1400
|
-
const PackageManagerInput = (props) => {
|
|
1401
|
-
const { onInstall, packageOptions, className } = props;
|
|
1402
|
-
const [value, setValue] = reactExports.useState("");
|
|
1403
|
-
const [loading, setLoading] = reactExports.useState(false);
|
|
1404
|
-
const [error, setError] = reactExports.useState();
|
|
1405
|
-
const handleSubmit = reactExports.useCallback(() => {
|
|
1406
|
-
const result = onInstall(value);
|
|
1407
|
-
if (result) {
|
|
1408
|
-
setLoading(true);
|
|
1409
|
-
result.then(() => setValue("")).catch(setError).finally(() => setLoading(false));
|
|
1410
|
-
} else {
|
|
1411
|
-
setValue("");
|
|
1412
|
-
setError(void 0);
|
|
1413
|
-
}
|
|
1414
|
-
}, [onInstall, value]);
|
|
1415
|
-
const handleChange = reactExports.useCallback((e) => {
|
|
1416
|
-
setValue(e.target.value);
|
|
1417
|
-
}, []);
|
|
1418
|
-
const errorMessage = !error ? " " : typeof error === "string" ? error : error instanceof Error ? error.message : error;
|
|
1419
|
-
const autoCompleteOptions = reactExports.useMemo(() => {
|
|
1420
|
-
const initialOptions = packageOptions?.map((option) => ({
|
|
1421
|
-
...option,
|
|
1422
|
-
value: option.packageName
|
|
1423
|
-
}));
|
|
1424
|
-
return !packageOptions?.length ? {
|
|
1425
|
-
autoComplete: false
|
|
1426
|
-
} : {
|
|
1427
|
-
autoComplete: true,
|
|
1428
|
-
initialOptions,
|
|
1429
|
-
fetchOptionsCallback: (userInput) => initialOptions?.filter((o) => o.packageName.toLowerCase().includes(userInput.toLowerCase())) ?? [],
|
|
1430
|
-
renderOption: (option) => jsxRuntimeExports.jsx(PackageItem, { ...option })
|
|
1431
|
-
};
|
|
1432
|
-
}, [packageOptions]);
|
|
1433
|
-
return jsxRuntimeExports.jsxs("div", { className, children: [jsxRuntimeExports.jsx("h3", { className: "mb-4 font-semibold text-gray-900", children: "Install Package" }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4", children: [!packageOptions?.length ? jsxRuntimeExports.jsx(Input, { name: "package", className: "max-w-xs text-gray-700", value, onChange: handleChange, onSubmit: handleSubmit, disabled: loading }) : jsxRuntimeExports.jsx(IdAutocomplete, { ...autoCompleteOptions, onChange: setValue }), jsxRuntimeExports.jsx(PowerhouseButton, { className: "h-9 rounded-md text-sm", onClick: handleSubmit, disabled: loading, children: "Install" })] }), jsxRuntimeExports.jsx("p", { className: "mb-3 ml-2 h-3 text-sm text-red-800", children: errorMessage })] });
|
|
1434
|
-
};
|
|
1435
|
-
const PackageDetail = ({ label, value }) => {
|
|
1436
|
-
return jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 text-sm", children: [jsxRuntimeExports.jsxs("p", { className: "text-gray-600", children: [label, ":"] }), jsxRuntimeExports.jsx("p", { className: "text-gray-600", children: value })] });
|
|
1437
|
-
};
|
|
1438
|
-
const PackageManagerListItem = (props) => {
|
|
1439
|
-
const { package: { name: name2, description: description2, category, publisher, publisherUrl, modules, id, removable }, mutable, onUninstall, className } = props;
|
|
1440
|
-
const [isDropdownMenuOpen, setIsDropdownMenuOpen] = reactExports.useState(false);
|
|
1441
|
-
return jsxRuntimeExports.jsxs("li", { className: twMerge("relative flex flex-col items-start rounded-md border border-gray-200 p-3 text-sm leading-5 shadow-sm", className), children: [jsxRuntimeExports.jsx("h3", { className: "font-semibold text-gray-900", children: name2 }), jsxRuntimeExports.jsx(PackageDetail, { label: "Description", value: description2 }), jsxRuntimeExports.jsx(PackageDetail, { label: "Category", value: category }), jsxRuntimeExports.jsx(PackageDetail, { label: "Publisher", value: publisher }), jsxRuntimeExports.jsx(PackageDetail, { label: "Publisher URL", value: jsxRuntimeExports.jsx("a", { className: "underline", href: publisherUrl, children: publisherUrl }) }), jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: "Modules included:" }), jsxRuntimeExports.jsx("ul", { className: "list-disc pl-5", children: modules.map((module) => jsxRuntimeExports.jsx("li", { children: jsxRuntimeExports.jsx("span", { className: "text-gray-600", children: module }) }, module)) }), mutable && removable && jsxRuntimeExports.jsx(ConnectDropdownMenu, { items: [
|
|
1442
|
-
{
|
|
1443
|
-
id: "uninstall",
|
|
1444
|
-
label: "Uninstall",
|
|
1445
|
-
icon: jsxRuntimeExports.jsx(Icon, { name: "Trash" }),
|
|
1446
|
-
className: "text-red-900"
|
|
1447
|
-
}
|
|
1448
|
-
], onItemClick: (optionId) => {
|
|
1449
|
-
if (optionId === "uninstall") {
|
|
1450
|
-
onUninstall(id);
|
|
1451
|
-
}
|
|
1452
|
-
}, onOpenChange: setIsDropdownMenuOpen, open: isDropdownMenuOpen, children: jsxRuntimeExports.jsx("button", { className: "group absolute right-3 top-3", onClick: (e) => {
|
|
1453
|
-
e.stopPropagation();
|
|
1454
|
-
setIsDropdownMenuOpen(true);
|
|
1455
|
-
}, children: jsxRuntimeExports.jsx(Icon, { className: "text-gray-600 group-hover:text-gray-900", name: "VerticalDots" }) }) })] });
|
|
1456
|
-
};
|
|
1457
|
-
const PackageManagerList = (props) => {
|
|
1458
|
-
const { className, packages, onUninstall, mutable, ...rest } = props;
|
|
1459
|
-
const handleUninstall = reactExports.useCallback((id) => {
|
|
1460
|
-
onUninstall(id);
|
|
1461
|
-
}, [onUninstall]);
|
|
1462
|
-
return jsxRuntimeExports.jsxs("div", { ...rest, className: twMerge("flex max-h-[370px] flex-col items-stretch overflow-hidden", className), children: [jsxRuntimeExports.jsx("h3", { className: "mb-4 font-semibold text-gray-900", children: "Installed Packages" }), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-y-auto pr-2", children: jsxRuntimeExports.jsx("ul", { className: "flex flex-col items-stretch gap-4 pr-2", children: packages.map((pkg) => jsxRuntimeExports.jsx(PackageManagerListItem, { package: pkg, onUninstall: handleUninstall, mutable }, pkg.id)) }) })] });
|
|
1463
|
-
};
|
|
1464
|
-
const PackageManagerReactorSelect = (props) => {
|
|
1465
|
-
const { reactorOptions, reactor, onReactorChange, ...rest } = props;
|
|
1466
|
-
const handleChange = reactExports.useCallback((value) => {
|
|
1467
|
-
onReactorChange(Array.isArray(value) ? value.at(-1) : value);
|
|
1468
|
-
}, [onReactorChange]);
|
|
1469
|
-
return jsxRuntimeExports.jsxs("div", { ...rest, children: [jsxRuntimeExports.jsx("h3", { className: "mb-4 font-semibold text-gray-900", children: "Select Reactor" }), jsxRuntimeExports.jsx(SelectFieldRaw, { className: "min-w-36 max-w-fit", name: "reactor", required: true, value: reactor, options: reactorOptions, multiple: false, onChange: handleChange })] });
|
|
1470
|
-
};
|
|
1471
|
-
const PackageManager$1 = (props) => {
|
|
1472
|
-
const { className, reactorOptions, reactor, onReactorChange, onInstall, packages, onUninstall, mutable, packageOptions, ...rest } = props;
|
|
1473
|
-
const packageOptionsSet = reactExports.useMemo(() => packageOptions?.filter((o) => !packages.find((p2) => p2.name === o.packageName)), [packages, packageOptions]);
|
|
1474
|
-
return jsxRuntimeExports.jsxs("div", { ...rest, className: twMerge("flex h-full flex-1 flex-col rounded-lg p-3", className), children: [jsxRuntimeExports.jsx(PackageManagerReactorSelect, { reactor, reactorOptions, onReactorChange, className: "mb-4" }), mutable && jsxRuntimeExports.jsx(PackageManagerInput, { onInstall, packageOptions: packageOptionsSet }), jsxRuntimeExports.jsx(PackageManagerList, { packages, onUninstall, mutable })] });
|
|
1475
|
-
};
|
|
1476
|
-
function SettingsModal$1(props) {
|
|
1477
|
-
const { title, overlayProps, contentProps, onOpenChange, tabs, defaultTab, ...restProps } = props;
|
|
1478
|
-
const [selectedTab, setSelectedTab] = reactExports.useState(defaultTab ?? tabs.at(0)?.id);
|
|
1479
|
-
const tabsContent = tabs.map((tab) => jsxRuntimeExports.jsx("button", { type: "button", onClick: () => setSelectedTab(tab.id), children: jsxRuntimeExports.jsxs("div", { className: twMerge("flex h-9 w-48 cursor-pointer items-center gap-x-2 rounded-md pl-3 hover:bg-slate-50", selectedTab === tab.id ? "bg-slate-50" : "bg-transparent"), children: [tab.icon, jsxRuntimeExports.jsx("span", { children: tab.label })] }) }, tab.id));
|
|
1480
|
-
const selectedTabContent = tabs.find((tab) => tab.id === selectedTab)?.content;
|
|
1481
|
-
const SelectedTabComponent = selectedTabContent;
|
|
1482
|
-
return jsxRuntimeExports.jsxs(Modal, { contentProps: {
|
|
1483
|
-
...contentProps,
|
|
1484
|
-
className: twMerge("min-h-full w-full max-w-4xl rounded-xl", contentProps?.className),
|
|
1485
|
-
style: {
|
|
1486
|
-
...contentProps?.style,
|
|
1487
|
-
boxShadow: "0px 0px 16px 4px rgba(0, 0, 0, 0.04), 0px 33px 32px -16px rgba(0, 0, 0, 0.10)"
|
|
1488
|
-
}
|
|
1489
|
-
}, onOpenChange, overlayProps: {
|
|
1490
|
-
...overlayProps,
|
|
1491
|
-
className: twMerge("py-28", overlayProps?.className)
|
|
1492
|
-
}, ...restProps, children: [jsxRuntimeExports.jsxs("div", { className: "flex justify-between border-b border-slate-50 p-4", children: [jsxRuntimeExports.jsx("h1", { className: "text-center text-xl font-semibold", children: title }), jsxRuntimeExports.jsx("button", { type: "button", className: "flex size-6 items-center justify-center rounded-md outline-none", onClick: () => onOpenChange?.(false), children: jsxRuntimeExports.jsx(Icon, { name: "XmarkLight", size: 24 }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-1", children: [jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-y-1 p-3 pt-6", children: tabsContent }), jsxRuntimeExports.jsx("div", { className: "m-6 flex h-full flex-1 flex-col overflow-hidden rounded-lg border border-slate-50", children: typeof SelectedTabComponent === "function" ? jsxRuntimeExports.jsx(SelectedTabComponent, {}) : SelectedTabComponent })] })] });
|
|
1493
|
-
}
|
|
1494
|
-
const name = "@powerhousedao/connect";
|
|
1495
|
-
const productName = "Powerhouse-Connect";
|
|
1496
|
-
const version = "4.1.0-dev.105";
|
|
1497
|
-
const description = "Powerhouse Connect";
|
|
1498
|
-
const main = "dist/index.html";
|
|
1499
|
-
const type = "module";
|
|
1500
|
-
const engines = { "node": ">=22.0.0" };
|
|
1501
|
-
const files = ["dist", "lib", "nginx.conf", "nginx.sh", "scripts", "assets", "public", "heroku", ".env", "./src/index.css", "./package.copy.json"];
|
|
1502
|
-
const exports = { "./package.json": "./package.copy.json", ".": { "source": "./src/index.ts", "import": "./lib/src/index.js", "types": "./lib/src/index.d.ts" }, "./main.js": { "source": "./src/main.tsx", "import": "./lib/src/main.js", "types": "./lib/src/main.d.ts" }, "./config": { "source": "./src/connect.config.ts", "import": "./lib/src/connect.config.js", "types": "./lib/src/connect.config.d.ts" }, "./components": { "source": "./src/components/index.ts", "import": "./lib/src/components/index.js", "types": "./lib/src/components/index.d.ts" }, "./components/*": { "source": "./src/components/*", "import": "./lib/src/components/*.js", "types": "./lib/src/components/*.d.ts" }, "./hooks": { "source": "./src/hooks/index.ts", "import": "./lib/src/hooks/index.js", "types": "./lib/src/hooks/index.d.ts" }, "./hooks/*": { "source": "./src/hooks/*", "import": "./lib/src/hooks/*.js", "types": "./lib/src/hooks/*.d.ts" }, "./services": { "source": "./src/services/index.ts", "import": "./lib/src/services/index.js", "types": "./lib/src/services/index.d.ts" }, "./services/*": { "source": "./src/services/*", "import": "./lib/src/services/*.js", "types": "./lib/src/services/*.d.ts" }, "./store": { "source": "./src/store/index.ts", "import": "./lib/src/store/index.js", "types": "./lib/src/store/index.d.ts" }, "./store/*": { "source": "./src/store/*", "import": "./lib/src/store/*.js", "types": "./lib/src/store/*.d.ts" }, "./context": { "source": "./src/context/index.ts", "import": "./lib/src/context/index.js", "types": "./lib/src/context/index.d.ts" }, "./context/*": { "source": "./src/context/*", "import": "./lib/src/context/*.js", "types": "./lib/src/context/*.d.ts" }, "./utils": { "source": "./src/utils/index.ts", "import": "./lib/src/utils/index.js", "types": "./lib/src/utils/index.d.ts" }, "./utils/*": { "source": "./src/utils/*", "import": "./lib/src/utils/*.js", "types": "./lib/src/utils/*.d.ts" }, "./pages": { "source": "./src/pages/index.ts", "import": "./lib/src/pages/index.js", "types": "./lib/src/pages/index.d.ts" }, "./pages/*": { "source": "./src/pages/*", "import": "./lib/src/pages/*.js", "types": "./lib/src/pages/*.d.ts" }, "./i18n": { "source": "./src/i18n/index.ts", "import": "./lib/src/i18n/index.js", "types": "./lib/src/i18n/index.d.ts" }, "./custom.d.ts": "./lib/custom.d.ts", "./style.css": "./src/index.css", "./assets/*.mp4": "./assets/*.mp4", "./assets/*.png": "./assets/*.png", "./assets/*.svg": "./assets/*.svg", "./assets/*.jpg": "./assets/*.jpg", "./assets/*.jpeg": "./assets/*.jpeg", "./assets/*.gif": "./assets/*.gif", "./assets/*.webp": "./assets/*.webp", "./assets/*.avif": "./assets/*.avif", "./public/icon.ico": "./public/icon.ico" };
|
|
1503
|
-
const sideEffects = false;
|
|
1504
|
-
const license = "AGPL-3.0-only";
|
|
1505
|
-
const author = "powerhouse.inc";
|
|
1506
|
-
const repository = { "type": "git", "url": "https://github.com/powerhouse-inc/powerhouse" };
|
|
1507
|
-
const bugs = { "url": "https://github.com/powerhouse-inc/powerhouse/issues" };
|
|
1508
|
-
const homepage = "https://github.com/powerhouse-inc/powerhouse#readme";
|
|
1509
|
-
const scripts = { "tsc": "tsc", "lint": "eslint", "postinstall": "cp ./package.json ./package.copy.json", "dev": "vite dev", "build:vite": "vite build", "build:debug": "PH_DEBUG_BUILD=true vite build", "preview": "vite preview", "cy:open": "cypress open", "docker:build": "docker build -f ./Dockerfile --tag connect-test-dev --build-arg TAG=dev .", "docker:run": "docker run -it -p 4000:4000 -v $(realpath ../../../monorepo):/monorepo -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf.template -e PH_USE_LOCAL=true -e PH_CONNECT_BASE_PATH=/develop/powerhouse/connect -e PORT=4000 connect-test-dev" };
|
|
1510
|
-
const dependencies = { "@electric-sql/pglite": "0.2.17", "@openfeature/core": "^1.9.1", "@openfeature/web-sdk": "^1.6.2", "@powerhousedao/analytics-engine-core": "^0.5.0", "@powerhousedao/builder-tools": "workspace:*", "@powerhousedao/common": "workspace:*", "@powerhousedao/config": "workspace:*", "@powerhousedao/design-system": "workspace:*", "@powerhousedao/reactor-browser": "workspace:*", "@renown/sdk": "workspace:*", "@sentry/browser": "^10.17.0", "@sentry/react": "^10.17.0", "@sentry/vite-plugin": "^4.3.0", "@tailwindcss/vite": "^4.1.14", "@types/node": "^24.7.0", "@types/react": "^19.2.0", "@types/react-dom": "^19.2.0", "@types/wicg-file-system-access": "^2023.10.7", "@vitejs/plugin-react": "^5.0.4", "document-drive": "workspace:*", "document-model": "workspace:*", "fast-deep-equal": "^3.1.3", "graphql": "^16.11.0", "graphql-request": "^7.2.0", "i18next": "^25.5.3", "react": "^19.2.0", "react-dom": "^19.2.0", "react-error-boundary": "^4.0.11", "react-hotkeys-hook": "^4.5.0", "react-i18next": "^16.0.0", "react-router-dom": "^6.11.2", "tailwind-merge": "^3.0.2", "tailwindcss": "^4.1.14", "vite": "^7.1.9", "vite-plugin-html": "^3.2.2", "vite-plugin-node-polyfills": "^0.24.0", "vite-plugin-svgr": "^4.5.0" };
|
|
1511
|
-
const devDependencies = { "@types/cypress": "^1.1.6", "cypress": "^14.5.4", "vite-bundle-analyzer": "^1.2.3" };
|
|
1512
|
-
const packageJson = {
|
|
1513
|
-
name,
|
|
1514
|
-
productName,
|
|
1515
|
-
version,
|
|
1516
|
-
description,
|
|
1517
|
-
main,
|
|
1518
|
-
type,
|
|
1519
|
-
engines,
|
|
1520
|
-
files,
|
|
1521
|
-
exports,
|
|
1522
|
-
sideEffects,
|
|
1523
|
-
license,
|
|
1524
|
-
author,
|
|
1525
|
-
repository,
|
|
1526
|
-
bugs,
|
|
1527
|
-
homepage,
|
|
1528
|
-
scripts,
|
|
1529
|
-
dependencies,
|
|
1530
|
-
devDependencies
|
|
1531
|
-
};
|
|
1532
|
-
const About = () => {
|
|
1533
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1534
|
-
About$1,
|
|
1535
|
-
{
|
|
1536
|
-
packageJson,
|
|
1537
|
-
phCliVersion: typeof connectConfig.phCliVersion === "string" ? connectConfig.phCliVersion : void 0
|
|
1538
|
-
}
|
|
1539
|
-
);
|
|
1540
|
-
};
|
|
1541
|
-
const DangerZone = () => {
|
|
1542
|
-
const drives = useDrives();
|
|
1543
|
-
const handleDeleteDrive = async (drive) => {
|
|
1544
|
-
await deleteDrive(drive.header.id);
|
|
1545
|
-
setSelectedDrive(void 0);
|
|
1546
|
-
};
|
|
1547
|
-
const handleClearStorage = () => {
|
|
1548
|
-
showPHModal({ type: "clearStorage" });
|
|
1549
|
-
};
|
|
1550
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1551
|
-
DangerZone$1,
|
|
1552
|
-
{
|
|
1553
|
-
drives: drives ?? [],
|
|
1554
|
-
onDeleteDrive: handleDeleteDrive,
|
|
1555
|
-
onClearStorage: handleClearStorage
|
|
1556
|
-
}
|
|
1557
|
-
);
|
|
1558
|
-
};
|
|
1559
|
-
const documentModelEditorOptions = [
|
|
1560
|
-
{ label: "V1", value: "document-model-editor" },
|
|
1561
|
-
{ label: "V2", value: "document-model-editor-v2" }
|
|
1562
|
-
];
|
|
1563
|
-
const DefaultEditor = () => {
|
|
1564
|
-
const [documentModelEditor, setDocumentModelEditor] = reactExports.useState(documentModelEditorOptions[1]);
|
|
1565
|
-
const handleSetDocumentEditor = reactExports.useCallback((value) => {
|
|
1566
|
-
const option = documentModelEditorOptions.find((dm) => dm.value == value);
|
|
1567
|
-
if (option) {
|
|
1568
|
-
setDocumentModelEditor(option);
|
|
1569
|
-
}
|
|
1570
|
-
}, []);
|
|
1571
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1572
|
-
DefaultEditor$1,
|
|
1573
|
-
{
|
|
1574
|
-
documentModelEditor: documentModelEditor.value,
|
|
1575
|
-
setDocumentModelEditor: handleSetDocumentEditor,
|
|
1576
|
-
documentModelEditorOptions
|
|
1577
|
-
}
|
|
1578
|
-
);
|
|
1579
|
-
};
|
|
1580
|
-
const LOCAL_REACTOR_VALUE = "local-reactor";
|
|
1581
|
-
const LOCAL_REACTOR_LABEL = "Local Reactor";
|
|
1582
|
-
const PackageManager = () => {
|
|
1583
|
-
const vetraPackages = useVetraPackages();
|
|
1584
|
-
const drives = useDrives();
|
|
1585
|
-
const [reactor, setReactor] = reactExports.useState("");
|
|
1586
|
-
const options = reactExports.useMemo(() => {
|
|
1587
|
-
return drives?.reduce(
|
|
1588
|
-
(acc, drive) => {
|
|
1589
|
-
const trigger = drive.state.local.triggers.find(
|
|
1590
|
-
(trigger2) => trigger2.data?.url
|
|
1591
|
-
);
|
|
1592
|
-
if (!trigger?.data?.url) {
|
|
1593
|
-
return acc;
|
|
1594
|
-
}
|
|
1595
|
-
const value = trigger.data.url;
|
|
1596
|
-
const label = drive.state.global.name;
|
|
1597
|
-
acc.push({
|
|
1598
|
-
value,
|
|
1599
|
-
label,
|
|
1600
|
-
disabled: true
|
|
1601
|
-
});
|
|
1602
|
-
return acc;
|
|
1603
|
-
},
|
|
1604
|
-
[
|
|
1605
|
-
{
|
|
1606
|
-
value: LOCAL_REACTOR_VALUE,
|
|
1607
|
-
label: LOCAL_REACTOR_LABEL,
|
|
1608
|
-
disabled: false
|
|
1609
|
-
}
|
|
1610
|
-
]
|
|
1611
|
-
);
|
|
1612
|
-
}, [drives]);
|
|
1613
|
-
reactExports.useEffect(() => {
|
|
1614
|
-
setReactor((reactor2) => {
|
|
1615
|
-
const defaultOption = options?.find((option) => !option.disabled);
|
|
1616
|
-
if (reactor2 && options?.find((option) => option.value === reactor2)) {
|
|
1617
|
-
return reactor2;
|
|
1618
|
-
} else {
|
|
1619
|
-
return defaultOption?.value ?? "";
|
|
1620
|
-
}
|
|
1621
|
-
});
|
|
1622
|
-
}, [reactor, options]);
|
|
1623
|
-
const packagesInfo = vetraPackages?.map(
|
|
1624
|
-
(pkg) => makeVetraPackageManifest(pkg)
|
|
1625
|
-
);
|
|
1626
|
-
const handleReactorChange = reactExports.useCallback(
|
|
1627
|
-
(reactor2) => setReactor(reactor2 ?? ""),
|
|
1628
|
-
[]
|
|
1629
|
-
);
|
|
1630
|
-
const handleInstall = reactExports.useCallback(
|
|
1631
|
-
(packageName) => {
|
|
1632
|
-
if (reactor !== LOCAL_REACTOR_VALUE) {
|
|
1633
|
-
throw new Error("Cannot install external package on a remote reactor");
|
|
1634
|
-
}
|
|
1635
|
-
return addExternalPackage(packageName);
|
|
1636
|
-
},
|
|
1637
|
-
[reactor]
|
|
1638
|
-
);
|
|
1639
|
-
const handleUninstall = reactExports.useCallback(
|
|
1640
|
-
(packageName) => {
|
|
1641
|
-
if (reactor !== LOCAL_REACTOR_VALUE) {
|
|
1642
|
-
throw new Error("Cannot delete external package on a remote reactor");
|
|
1643
|
-
}
|
|
1644
|
-
return removeExternalPackage(packageName);
|
|
1645
|
-
},
|
|
1646
|
-
[reactor]
|
|
1647
|
-
);
|
|
1648
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1649
|
-
PackageManager$1,
|
|
1650
|
-
{
|
|
1651
|
-
mutable: true,
|
|
1652
|
-
reactorOptions: options ?? [],
|
|
1653
|
-
reactor,
|
|
1654
|
-
packages: packagesInfo?.map((pkg) => ({
|
|
1655
|
-
id: pkg.id,
|
|
1656
|
-
name: pkg.name,
|
|
1657
|
-
description: pkg.description,
|
|
1658
|
-
category: pkg.category,
|
|
1659
|
-
publisher: pkg.author.name,
|
|
1660
|
-
publisherUrl: pkg.author.website ?? "",
|
|
1661
|
-
modules: Object.values(pkg.modules).flatMap(
|
|
1662
|
-
(modules) => modules.map((module) => module.name)
|
|
1663
|
-
),
|
|
1664
|
-
removable: true
|
|
1665
|
-
})) ?? [],
|
|
1666
|
-
onReactorChange: handleReactorChange,
|
|
1667
|
-
onInstall: handleInstall,
|
|
1668
|
-
onUninstall: handleUninstall,
|
|
1669
|
-
packageOptions: PH_PACKAGES
|
|
1670
|
-
}
|
|
1671
|
-
);
|
|
1672
|
-
};
|
|
1673
|
-
const SettingsModal = () => {
|
|
1674
|
-
const phModal = usePHModal();
|
|
1675
|
-
const open = phModal?.type === "settings";
|
|
1676
|
-
function onRefresh() {
|
|
1677
|
-
window.location.reload();
|
|
1678
|
-
}
|
|
1679
|
-
const tabs = reactExports.useMemo(
|
|
1680
|
-
() => [
|
|
1681
|
-
{
|
|
1682
|
-
id: "package-manager",
|
|
1683
|
-
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "PackageManager", size: 12 }),
|
|
1684
|
-
label: "Package Manager",
|
|
1685
|
-
content: PackageManager
|
|
1686
|
-
},
|
|
1687
|
-
{
|
|
1688
|
-
id: "default-editors",
|
|
1689
|
-
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "Edit", size: 12 }),
|
|
1690
|
-
label: "Default Editors",
|
|
1691
|
-
content: DefaultEditor
|
|
1692
|
-
},
|
|
1693
|
-
{
|
|
1694
|
-
id: "danger-zone",
|
|
1695
|
-
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "Danger", size: 12, className: "text-red-900" }),
|
|
1696
|
-
label: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-900", children: "Danger Zone" }),
|
|
1697
|
-
content: () => /* @__PURE__ */ jsxRuntimeExports.jsx(DangerZone, {})
|
|
1698
|
-
},
|
|
1699
|
-
{
|
|
1700
|
-
id: "about",
|
|
1701
|
-
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { name: "QuestionSquare", size: 12 }),
|
|
1702
|
-
label: "About",
|
|
1703
|
-
content: About
|
|
1704
|
-
}
|
|
1705
|
-
],
|
|
1706
|
-
[onRefresh]
|
|
1707
|
-
);
|
|
1708
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1709
|
-
SettingsModal$1,
|
|
1710
|
-
{
|
|
1711
|
-
open,
|
|
1712
|
-
title: t("modals.connectSettings.title"),
|
|
1713
|
-
onOpenChange: (status) => {
|
|
1714
|
-
if (!status) return closePHModal();
|
|
1715
|
-
},
|
|
1716
|
-
tabs
|
|
1717
|
-
}
|
|
1718
|
-
);
|
|
1719
|
-
};
|
|
1720
|
-
export {
|
|
1721
|
-
SettingsModal
|
|
1722
|
-
};
|
|
1723
|
-
//# sourceMappingURL=SettingsModal-W6c3EI1V.js.map
|