@frontmcp/ui 0.5.0
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/LICENSE +201 -0
- package/README.md +438 -0
- package/package.json +147 -0
- package/src/adapters/index.d.ts +10 -0
- package/src/adapters/index.js +18 -0
- package/src/adapters/index.js.map +1 -0
- package/src/adapters/platform-meta.d.ts +165 -0
- package/src/adapters/platform-meta.js +310 -0
- package/src/adapters/platform-meta.js.map +1 -0
- package/src/base-template/bridge.d.ts +89 -0
- package/src/base-template/bridge.js +452 -0
- package/src/base-template/bridge.js.map +1 -0
- package/src/base-template/default-base-template.d.ts +91 -0
- package/src/base-template/default-base-template.js +435 -0
- package/src/base-template/default-base-template.js.map +1 -0
- package/src/base-template/index.d.ts +14 -0
- package/src/base-template/index.js +30 -0
- package/src/base-template/index.js.map +1 -0
- package/src/base-template/polyfills.d.ts +30 -0
- package/src/base-template/polyfills.js +190 -0
- package/src/base-template/polyfills.js.map +1 -0
- package/src/base-template/theme-styles.d.ts +73 -0
- package/src/base-template/theme-styles.js +95 -0
- package/src/base-template/theme-styles.js.map +1 -0
- package/src/bridge/adapters/base-adapter.d.ts +103 -0
- package/src/bridge/adapters/base-adapter.js +314 -0
- package/src/bridge/adapters/base-adapter.js.map +1 -0
- package/src/bridge/adapters/claude.adapter.d.ts +66 -0
- package/src/bridge/adapters/claude.adapter.js +145 -0
- package/src/bridge/adapters/claude.adapter.js.map +1 -0
- package/src/bridge/adapters/ext-apps.adapter.d.ts +142 -0
- package/src/bridge/adapters/ext-apps.adapter.js +416 -0
- package/src/bridge/adapters/ext-apps.adapter.js.map +1 -0
- package/src/bridge/adapters/gemini.adapter.d.ts +63 -0
- package/src/bridge/adapters/gemini.adapter.js +160 -0
- package/src/bridge/adapters/gemini.adapter.js.map +1 -0
- package/src/bridge/adapters/generic.adapter.d.ts +55 -0
- package/src/bridge/adapters/generic.adapter.js +108 -0
- package/src/bridge/adapters/generic.adapter.js.map +1 -0
- package/src/bridge/adapters/index.d.ts +25 -0
- package/src/bridge/adapters/index.js +65 -0
- package/src/bridge/adapters/index.js.map +1 -0
- package/src/bridge/adapters/openai.adapter.d.ts +64 -0
- package/src/bridge/adapters/openai.adapter.js +194 -0
- package/src/bridge/adapters/openai.adapter.js.map +1 -0
- package/src/bridge/core/adapter-registry.d.ts +121 -0
- package/src/bridge/core/adapter-registry.js +271 -0
- package/src/bridge/core/adapter-registry.js.map +1 -0
- package/src/bridge/core/bridge-factory.d.ts +198 -0
- package/src/bridge/core/bridge-factory.js +428 -0
- package/src/bridge/core/bridge-factory.js.map +1 -0
- package/src/bridge/core/index.d.ts +9 -0
- package/src/bridge/core/index.js +22 -0
- package/src/bridge/core/index.js.map +1 -0
- package/src/bridge/index.d.ts +61 -0
- package/src/bridge/index.js +94 -0
- package/src/bridge/index.js.map +1 -0
- package/src/bridge/runtime/iife-generator.d.ts +61 -0
- package/src/bridge/runtime/iife-generator.js +940 -0
- package/src/bridge/runtime/iife-generator.js.map +1 -0
- package/src/bridge/runtime/index.d.ts +8 -0
- package/src/bridge/runtime/index.js +16 -0
- package/src/bridge/runtime/index.js.map +1 -0
- package/src/bridge/types.d.ts +385 -0
- package/src/bridge/types.js +11 -0
- package/src/bridge/types.js.map +1 -0
- package/src/build/cdn-resources.d.ts +140 -0
- package/src/build/cdn-resources.js +314 -0
- package/src/build/cdn-resources.js.map +1 -0
- package/src/build/index.d.ts +294 -0
- package/src/build/index.js +325 -0
- package/src/build/index.js.map +1 -0
- package/src/build/widget-manifest.d.ts +212 -0
- package/src/build/widget-manifest.js +652 -0
- package/src/build/widget-manifest.js.map +1 -0
- package/src/bundler/bundler.d.ts +110 -0
- package/src/bundler/bundler.js +432 -0
- package/src/bundler/bundler.js.map +1 -0
- package/src/bundler/cache.d.ts +172 -0
- package/src/bundler/cache.js +250 -0
- package/src/bundler/cache.js.map +1 -0
- package/src/bundler/index.d.ts +41 -0
- package/src/bundler/index.js +73 -0
- package/src/bundler/index.js.map +1 -0
- package/src/bundler/sandbox/enclave-adapter.d.ts +120 -0
- package/src/bundler/sandbox/enclave-adapter.js +339 -0
- package/src/bundler/sandbox/enclave-adapter.js.map +1 -0
- package/src/bundler/sandbox/executor.d.ts +13 -0
- package/src/bundler/sandbox/executor.js +22 -0
- package/src/bundler/sandbox/executor.js.map +1 -0
- package/src/bundler/sandbox/policy.d.ts +61 -0
- package/src/bundler/sandbox/policy.js +238 -0
- package/src/bundler/sandbox/policy.js.map +1 -0
- package/src/bundler/types.d.ts +347 -0
- package/src/bundler/types.js +132 -0
- package/src/bundler/types.js.map +1 -0
- package/src/components/alert.d.ts +71 -0
- package/src/components/alert.js +189 -0
- package/src/components/alert.js.map +1 -0
- package/src/components/alert.schema.d.ts +114 -0
- package/src/components/alert.schema.js +105 -0
- package/src/components/alert.schema.js.map +1 -0
- package/src/components/avatar.d.ts +76 -0
- package/src/components/avatar.js +176 -0
- package/src/components/avatar.js.map +1 -0
- package/src/components/avatar.schema.d.ts +169 -0
- package/src/components/avatar.schema.js +103 -0
- package/src/components/avatar.schema.js.map +1 -0
- package/src/components/badge.d.ts +70 -0
- package/src/components/badge.js +149 -0
- package/src/components/badge.js.map +1 -0
- package/src/components/badge.schema.d.ts +109 -0
- package/src/components/badge.schema.js +96 -0
- package/src/components/badge.schema.js.map +1 -0
- package/src/components/button.d.ts +111 -0
- package/src/components/button.js +336 -0
- package/src/components/button.js.map +1 -0
- package/src/components/button.schema.d.ts +148 -0
- package/src/components/button.schema.js +121 -0
- package/src/components/button.schema.js.map +1 -0
- package/src/components/card.d.ts +60 -0
- package/src/components/card.js +117 -0
- package/src/components/card.js.map +1 -0
- package/src/components/card.schema.d.ts +113 -0
- package/src/components/card.schema.js +98 -0
- package/src/components/card.schema.js.map +1 -0
- package/src/components/form.d.ts +239 -0
- package/src/components/form.js +420 -0
- package/src/components/form.js.map +1 -0
- package/src/components/form.schema.d.ts +441 -0
- package/src/components/form.schema.js +406 -0
- package/src/components/form.schema.js.map +1 -0
- package/src/components/index.d.ts +29 -0
- package/src/components/index.js +98 -0
- package/src/components/index.js.map +1 -0
- package/src/components/list.d.ts +127 -0
- package/src/components/list.js +279 -0
- package/src/components/list.js.map +1 -0
- package/src/components/list.schema.d.ts +134 -0
- package/src/components/list.schema.js +168 -0
- package/src/components/list.schema.js.map +1 -0
- package/src/components/modal.d.ts +111 -0
- package/src/components/modal.js +260 -0
- package/src/components/modal.js.map +1 -0
- package/src/components/modal.schema.d.ts +186 -0
- package/src/components/modal.schema.js +167 -0
- package/src/components/modal.schema.js.map +1 -0
- package/src/components/table.d.ts +105 -0
- package/src/components/table.js +283 -0
- package/src/components/table.js.map +1 -0
- package/src/components/table.schema.d.ts +159 -0
- package/src/components/table.schema.js +173 -0
- package/src/components/table.schema.js.map +1 -0
- package/src/handlebars/helpers.d.ts +348 -0
- package/src/handlebars/helpers.js +605 -0
- package/src/handlebars/helpers.js.map +1 -0
- package/src/handlebars/index.d.ts +193 -0
- package/src/handlebars/index.js +350 -0
- package/src/handlebars/index.js.map +1 -0
- package/src/index.d.ts +50 -0
- package/src/index.js +192 -0
- package/src/index.js.map +1 -0
- package/src/layouts/base.d.ts +88 -0
- package/src/layouts/base.js +227 -0
- package/src/layouts/base.js.map +1 -0
- package/src/layouts/index.d.ts +7 -0
- package/src/layouts/index.js +25 -0
- package/src/layouts/index.js.map +1 -0
- package/src/layouts/presets.d.ts +133 -0
- package/src/layouts/presets.js +277 -0
- package/src/layouts/presets.js.map +1 -0
- package/src/pages/consent.d.ts +116 -0
- package/src/pages/consent.js +218 -0
- package/src/pages/consent.js.map +1 -0
- package/src/pages/error.d.ts +100 -0
- package/src/pages/error.js +263 -0
- package/src/pages/error.js.map +1 -0
- package/src/pages/index.d.ts +8 -0
- package/src/pages/index.js +27 -0
- package/src/pages/index.js.map +1 -0
- package/src/react/Alert.d.ts +101 -0
- package/src/react/Alert.js +51 -0
- package/src/react/Alert.js.map +1 -0
- package/src/react/Badge.d.ts +100 -0
- package/src/react/Badge.js +55 -0
- package/src/react/Badge.js.map +1 -0
- package/src/react/Button.d.ts +108 -0
- package/src/react/Button.js +52 -0
- package/src/react/Button.js.map +1 -0
- package/src/react/Card.d.ts +103 -0
- package/src/react/Card.js +55 -0
- package/src/react/Card.js.map +1 -0
- package/src/react/hooks/context.d.ts +178 -0
- package/src/react/hooks/context.js +287 -0
- package/src/react/hooks/context.js.map +1 -0
- package/src/react/hooks/index.d.ts +41 -0
- package/src/react/hooks/index.js +61 -0
- package/src/react/hooks/index.js.map +1 -0
- package/src/react/hooks/tools.d.ts +283 -0
- package/src/react/hooks/tools.js +465 -0
- package/src/react/hooks/tools.js.map +1 -0
- package/src/react/index.d.ts +80 -0
- package/src/react/index.js +113 -0
- package/src/react/index.js.map +1 -0
- package/src/react/types.d.ts +105 -0
- package/src/react/types.js +12 -0
- package/src/react/types.js.map +1 -0
- package/src/react/utils.d.ts +42 -0
- package/src/react/utils.js +99 -0
- package/src/react/utils.js.map +1 -0
- package/src/registry/index.d.ts +45 -0
- package/src/registry/index.js +67 -0
- package/src/registry/index.js.map +1 -0
- package/src/registry/render-template.d.ts +86 -0
- package/src/registry/render-template.js +239 -0
- package/src/registry/render-template.js.map +1 -0
- package/src/registry/tool-ui.registry.d.ts +260 -0
- package/src/registry/tool-ui.registry.js +438 -0
- package/src/registry/tool-ui.registry.js.map +1 -0
- package/src/registry/uri-utils.d.ts +55 -0
- package/src/registry/uri-utils.js +97 -0
- package/src/registry/uri-utils.js.map +1 -0
- package/src/render/index.d.ts +7 -0
- package/src/render/index.js +14 -0
- package/src/render/index.js.map +1 -0
- package/src/render/prerender.d.ts +56 -0
- package/src/render/prerender.js +98 -0
- package/src/render/prerender.js.map +1 -0
- package/src/renderers/cache.d.ts +144 -0
- package/src/renderers/cache.js +240 -0
- package/src/renderers/cache.js.map +1 -0
- package/src/renderers/html.renderer.d.ts +122 -0
- package/src/renderers/html.renderer.js +204 -0
- package/src/renderers/html.renderer.js.map +1 -0
- package/src/renderers/index.d.ts +35 -0
- package/src/renderers/index.js +70 -0
- package/src/renderers/index.js.map +1 -0
- package/src/renderers/mdx.renderer.d.ts +119 -0
- package/src/renderers/mdx.renderer.js +305 -0
- package/src/renderers/mdx.renderer.js.map +1 -0
- package/src/renderers/react.renderer.d.ts +95 -0
- package/src/renderers/react.renderer.js +260 -0
- package/src/renderers/react.renderer.js.map +1 -0
- package/src/renderers/registry.d.ts +133 -0
- package/src/renderers/registry.js +232 -0
- package/src/renderers/registry.js.map +1 -0
- package/src/renderers/types.d.ts +341 -0
- package/src/renderers/types.js +9 -0
- package/src/renderers/types.js.map +1 -0
- package/src/renderers/utils/detect.d.ts +106 -0
- package/src/renderers/utils/detect.js +267 -0
- package/src/renderers/utils/detect.js.map +1 -0
- package/src/renderers/utils/hash.d.ts +39 -0
- package/src/renderers/utils/hash.js +75 -0
- package/src/renderers/utils/hash.js.map +1 -0
- package/src/renderers/utils/index.d.ts +8 -0
- package/src/renderers/utils/index.js +28 -0
- package/src/renderers/utils/index.js.map +1 -0
- package/src/renderers/utils/transpiler.d.ts +88 -0
- package/src/renderers/utils/transpiler.js +215 -0
- package/src/renderers/utils/transpiler.js.map +1 -0
- package/src/runtime/adapters/html.adapter.d.ts +58 -0
- package/src/runtime/adapters/html.adapter.js +131 -0
- package/src/runtime/adapters/html.adapter.js.map +1 -0
- package/src/runtime/adapters/index.d.ts +25 -0
- package/src/runtime/adapters/index.js +54 -0
- package/src/runtime/adapters/index.js.map +1 -0
- package/src/runtime/adapters/mdx.adapter.d.ts +72 -0
- package/src/runtime/adapters/mdx.adapter.js +241 -0
- package/src/runtime/adapters/mdx.adapter.js.map +1 -0
- package/src/runtime/adapters/react.adapter.d.ts +69 -0
- package/src/runtime/adapters/react.adapter.js +245 -0
- package/src/runtime/adapters/react.adapter.js.map +1 -0
- package/src/runtime/adapters/types.d.ts +94 -0
- package/src/runtime/adapters/types.js +11 -0
- package/src/runtime/adapters/types.js.map +1 -0
- package/src/runtime/csp.d.ts +37 -0
- package/src/runtime/csp.js +140 -0
- package/src/runtime/csp.js.map +1 -0
- package/src/runtime/index.d.ts +16 -0
- package/src/runtime/index.js +72 -0
- package/src/runtime/index.js.map +1 -0
- package/src/runtime/mcp-bridge.d.ts +100 -0
- package/src/runtime/mcp-bridge.js +581 -0
- package/src/runtime/mcp-bridge.js.map +1 -0
- package/src/runtime/renderer-runtime.d.ts +132 -0
- package/src/runtime/renderer-runtime.js +389 -0
- package/src/runtime/renderer-runtime.js.map +1 -0
- package/src/runtime/sanitizer.d.ts +171 -0
- package/src/runtime/sanitizer.js +318 -0
- package/src/runtime/sanitizer.js.map +1 -0
- package/src/runtime/types.d.ts +414 -0
- package/src/runtime/types.js +12 -0
- package/src/runtime/types.js.map +1 -0
- package/src/runtime/wrapper.d.ts +375 -0
- package/src/runtime/wrapper.js +1793 -0
- package/src/runtime/wrapper.js.map +1 -0
- package/src/styles/index.d.ts +7 -0
- package/src/styles/index.js +11 -0
- package/src/styles/index.js.map +1 -0
- package/src/styles/variants.d.ts +50 -0
- package/src/styles/variants.js +175 -0
- package/src/styles/variants.js.map +1 -0
- package/src/theme/cdn.d.ts +194 -0
- package/src/theme/cdn.js +375 -0
- package/src/theme/cdn.js.map +1 -0
- package/src/theme/index.d.ts +17 -0
- package/src/theme/index.js +57 -0
- package/src/theme/index.js.map +1 -0
- package/src/theme/platforms.d.ts +106 -0
- package/src/theme/platforms.js +161 -0
- package/src/theme/platforms.js.map +1 -0
- package/src/theme/presets/github-openai.d.ts +49 -0
- package/src/theme/presets/github-openai.js +189 -0
- package/src/theme/presets/github-openai.js.map +1 -0
- package/src/theme/presets/index.d.ts +10 -0
- package/src/theme/presets/index.js +17 -0
- package/src/theme/presets/index.js.map +1 -0
- package/src/theme/theme.d.ts +395 -0
- package/src/theme/theme.js +332 -0
- package/src/theme/theme.js.map +1 -0
- package/src/tool-template/builder.d.ts +212 -0
- package/src/tool-template/builder.js +397 -0
- package/src/tool-template/builder.js.map +1 -0
- package/src/tool-template/index.d.ts +15 -0
- package/src/tool-template/index.js +38 -0
- package/src/tool-template/index.js.map +1 -0
- package/src/types/index.d.ts +13 -0
- package/src/types/index.js +26 -0
- package/src/types/index.js.map +1 -0
- package/src/types/ui-config.d.ts +357 -0
- package/src/types/ui-config.js +12 -0
- package/src/types/ui-config.js.map +1 -0
- package/src/types/ui-runtime.d.ts +965 -0
- package/src/types/ui-runtime.js +117 -0
- package/src/types/ui-runtime.js.map +1 -0
- package/src/validation/error-box.d.ts +55 -0
- package/src/validation/error-box.js +75 -0
- package/src/validation/error-box.js.map +1 -0
- package/src/validation/index.d.ts +12 -0
- package/src/validation/index.js +21 -0
- package/src/validation/index.js.map +1 -0
- package/src/validation/wrapper.d.ts +96 -0
- package/src/validation/wrapper.js +117 -0
- package/src/validation/wrapper.js.map +1 -0
- package/src/web-components/core/attribute-parser.d.ts +85 -0
- package/src/web-components/core/attribute-parser.js +189 -0
- package/src/web-components/core/attribute-parser.js.map +1 -0
- package/src/web-components/core/base-element.d.ts +197 -0
- package/src/web-components/core/base-element.js +289 -0
- package/src/web-components/core/base-element.js.map +1 -0
- package/src/web-components/core/index.d.ts +8 -0
- package/src/web-components/core/index.js +18 -0
- package/src/web-components/core/index.js.map +1 -0
- package/src/web-components/elements/fmcp-alert.d.ts +45 -0
- package/src/web-components/elements/fmcp-alert.js +93 -0
- package/src/web-components/elements/fmcp-alert.js.map +1 -0
- package/src/web-components/elements/fmcp-badge.d.ts +46 -0
- package/src/web-components/elements/fmcp-badge.js +99 -0
- package/src/web-components/elements/fmcp-badge.js.map +1 -0
- package/src/web-components/elements/fmcp-button.d.ts +124 -0
- package/src/web-components/elements/fmcp-button.js +233 -0
- package/src/web-components/elements/fmcp-button.js.map +1 -0
- package/src/web-components/elements/fmcp-card.d.ts +52 -0
- package/src/web-components/elements/fmcp-card.js +115 -0
- package/src/web-components/elements/fmcp-card.js.map +1 -0
- package/src/web-components/elements/fmcp-input.d.ts +95 -0
- package/src/web-components/elements/fmcp-input.js +248 -0
- package/src/web-components/elements/fmcp-input.js.map +1 -0
- package/src/web-components/elements/fmcp-select.d.ts +99 -0
- package/src/web-components/elements/fmcp-select.js +243 -0
- package/src/web-components/elements/fmcp-select.js.map +1 -0
- package/src/web-components/elements/index.d.ts +12 -0
- package/src/web-components/elements/index.js +34 -0
- package/src/web-components/elements/index.js.map +1 -0
- package/src/web-components/index.d.ts +49 -0
- package/src/web-components/index.js +75 -0
- package/src/web-components/index.js.map +1 -0
- package/src/web-components/register.d.ts +56 -0
- package/src/web-components/register.js +80 -0
- package/src/web-components/register.js.map +1 -0
- package/src/web-components/types.d.ts +121 -0
- package/src/web-components/types.js +25 -0
- package/src/web-components/types.js.map +1 -0
- package/src/widgets/index.d.ts +7 -0
- package/src/widgets/index.js +24 -0
- package/src/widgets/index.js.map +1 -0
- package/src/widgets/progress.d.ts +132 -0
- package/src/widgets/progress.js +303 -0
- package/src/widgets/progress.js.map +1 -0
- package/src/widgets/resource.d.ts +162 -0
- package/src/widgets/resource.js +340 -0
- package/src/widgets/resource.js.map +1 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bundler Types
|
|
4
|
+
*
|
|
5
|
+
* Type definitions for the in-memory bundler system.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.DEFAULT_BUNDLER_OPTIONS = exports.DEFAULT_BUNDLE_OPTIONS = exports.DEFAULT_SECURITY_POLICY = void 0;
|
|
11
|
+
// ============================================
|
|
12
|
+
// Default Values
|
|
13
|
+
// ============================================
|
|
14
|
+
/**
|
|
15
|
+
* Default security policy.
|
|
16
|
+
*/
|
|
17
|
+
exports.DEFAULT_SECURITY_POLICY = {
|
|
18
|
+
allowedImports: [/^react$/, /^react-dom$/, /^react\/jsx-runtime$/, /^react\/jsx-dev-runtime$/, /^@frontmcp\/ui/],
|
|
19
|
+
blockedImports: [
|
|
20
|
+
/^fs$/,
|
|
21
|
+
/^fs\//,
|
|
22
|
+
/^net$/,
|
|
23
|
+
/^child_process$/,
|
|
24
|
+
/^os$/,
|
|
25
|
+
/^path$/,
|
|
26
|
+
/^crypto$/,
|
|
27
|
+
/^http$/,
|
|
28
|
+
/^https$/,
|
|
29
|
+
/^dgram$/,
|
|
30
|
+
/^dns$/,
|
|
31
|
+
/^cluster$/,
|
|
32
|
+
/^readline$/,
|
|
33
|
+
/^repl$/,
|
|
34
|
+
/^tls$/,
|
|
35
|
+
/^vm$/,
|
|
36
|
+
/^worker_threads$/,
|
|
37
|
+
],
|
|
38
|
+
maxBundleSize: 512000, // 500KB
|
|
39
|
+
maxTransformTime: 5000, // 5s
|
|
40
|
+
noEval: true,
|
|
41
|
+
noDynamicImports: true,
|
|
42
|
+
noRequire: true,
|
|
43
|
+
allowedGlobals: [
|
|
44
|
+
'console',
|
|
45
|
+
'Math',
|
|
46
|
+
'JSON',
|
|
47
|
+
'Date',
|
|
48
|
+
'Array',
|
|
49
|
+
'Object',
|
|
50
|
+
'String',
|
|
51
|
+
'Number',
|
|
52
|
+
'Boolean',
|
|
53
|
+
'Promise',
|
|
54
|
+
'Map',
|
|
55
|
+
'Set',
|
|
56
|
+
'WeakMap',
|
|
57
|
+
'WeakSet',
|
|
58
|
+
'Symbol',
|
|
59
|
+
'Reflect',
|
|
60
|
+
'Proxy',
|
|
61
|
+
'Error',
|
|
62
|
+
'TypeError',
|
|
63
|
+
'RangeError',
|
|
64
|
+
'SyntaxError',
|
|
65
|
+
'ReferenceError',
|
|
66
|
+
'parseInt',
|
|
67
|
+
'parseFloat',
|
|
68
|
+
'isNaN',
|
|
69
|
+
'isFinite',
|
|
70
|
+
'encodeURI',
|
|
71
|
+
'encodeURIComponent',
|
|
72
|
+
'decodeURI',
|
|
73
|
+
'decodeURIComponent',
|
|
74
|
+
'setTimeout',
|
|
75
|
+
'clearTimeout',
|
|
76
|
+
'setInterval',
|
|
77
|
+
'clearInterval',
|
|
78
|
+
'atob',
|
|
79
|
+
'btoa',
|
|
80
|
+
'Intl',
|
|
81
|
+
'TextEncoder',
|
|
82
|
+
'TextDecoder',
|
|
83
|
+
'URL',
|
|
84
|
+
'URLSearchParams',
|
|
85
|
+
'Uint8Array',
|
|
86
|
+
'Int8Array',
|
|
87
|
+
'Uint16Array',
|
|
88
|
+
'Int16Array',
|
|
89
|
+
'Uint32Array',
|
|
90
|
+
'Int32Array',
|
|
91
|
+
'Float32Array',
|
|
92
|
+
'Float64Array',
|
|
93
|
+
'BigInt',
|
|
94
|
+
'BigInt64Array',
|
|
95
|
+
'BigUint64Array',
|
|
96
|
+
'ArrayBuffer',
|
|
97
|
+
'SharedArrayBuffer',
|
|
98
|
+
'DataView',
|
|
99
|
+
'queueMicrotask',
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Default bundle options.
|
|
104
|
+
*/
|
|
105
|
+
exports.DEFAULT_BUNDLE_OPTIONS = {
|
|
106
|
+
sourceType: 'auto',
|
|
107
|
+
format: 'iife',
|
|
108
|
+
minify: false,
|
|
109
|
+
sourceMaps: false,
|
|
110
|
+
externals: ['react', 'react-dom'],
|
|
111
|
+
jsx: {
|
|
112
|
+
runtime: 'automatic',
|
|
113
|
+
importSource: 'react',
|
|
114
|
+
},
|
|
115
|
+
target: 'es2020',
|
|
116
|
+
globalName: 'Widget',
|
|
117
|
+
skipCache: false,
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Default bundler options.
|
|
121
|
+
*/
|
|
122
|
+
exports.DEFAULT_BUNDLER_OPTIONS = {
|
|
123
|
+
defaultSecurity: exports.DEFAULT_SECURITY_POLICY,
|
|
124
|
+
cache: {
|
|
125
|
+
maxSize: 100,
|
|
126
|
+
ttl: 300000, // 5 minutes
|
|
127
|
+
disabled: false,
|
|
128
|
+
},
|
|
129
|
+
verbose: false,
|
|
130
|
+
esbuildOptions: {},
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/bundler/types.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAibH,+CAA+C;AAC/C,iBAAiB;AACjB,+CAA+C;AAE/C;;GAEG;AACU,QAAA,uBAAuB,GAAmB;IACrD,cAAc,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,gBAAgB,CAAC;IAChH,cAAc,EAAE;QACd,MAAM;QACN,OAAO;QACP,OAAO;QACP,iBAAiB;QACjB,MAAM;QACN,QAAQ;QACR,UAAU;QACV,QAAQ;QACR,SAAS;QACT,SAAS;QACT,OAAO;QACP,WAAW;QACX,YAAY;QACZ,QAAQ;QACR,OAAO;QACP,MAAM;QACN,kBAAkB;KACnB;IACD,aAAa,EAAE,MAAM,EAAE,QAAQ;IAC/B,gBAAgB,EAAE,IAAI,EAAE,KAAK;IAC7B,MAAM,EAAE,IAAI;IACZ,gBAAgB,EAAE,IAAI;IACtB,SAAS,EAAE,IAAI;IACf,cAAc,EAAE;QACd,SAAS;QACT,MAAM;QACN,MAAM;QACN,MAAM;QACN,OAAO;QACP,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,SAAS;QACT,SAAS;QACT,KAAK;QACL,KAAK;QACL,SAAS;QACT,SAAS;QACT,QAAQ;QACR,SAAS;QACT,OAAO;QACP,OAAO;QACP,WAAW;QACX,YAAY;QACZ,aAAa;QACb,gBAAgB;QAChB,UAAU;QACV,YAAY;QACZ,OAAO;QACP,UAAU;QACV,WAAW;QACX,oBAAoB;QACpB,WAAW;QACX,oBAAoB;QACpB,YAAY;QACZ,cAAc;QACd,aAAa;QACb,eAAe;QACf,MAAM;QACN,MAAM;QACN,MAAM;QACN,aAAa;QACb,aAAa;QACb,KAAK;QACL,iBAAiB;QACjB,YAAY;QACZ,WAAW;QACX,aAAa;QACb,YAAY;QACZ,aAAa;QACb,YAAY;QACZ,cAAc;QACd,cAAc;QACd,QAAQ;QACR,eAAe;QACf,gBAAgB;QAChB,aAAa;QACb,mBAAmB;QACnB,UAAU;QACV,gBAAgB;KACjB;CACF,CAAC;AAEF;;GAEG;AACU,QAAA,sBAAsB,GAK/B;IACF,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC;IACjC,GAAG,EAAE;QACH,OAAO,EAAE,WAAW;QACpB,YAAY,EAAE,OAAO;KACtB;IACD,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,KAAK;CACjB,CAAC;AAEF;;GAEG;AACU,QAAA,uBAAuB,GAA6B;IAC/D,eAAe,EAAE,+BAAuB;IACxC,KAAK,EAAE;QACL,OAAO,EAAE,GAAG;QACZ,GAAG,EAAE,MAAM,EAAE,YAAY;QACzB,QAAQ,EAAE,KAAK;KAChB;IACD,OAAO,EAAE,KAAK;IACd,cAAc,EAAE,EAAE;CACnB,CAAC","sourcesContent":["/**\n * Bundler Types\n *\n * Type definitions for the in-memory bundler system.\n *\n * @packageDocumentation\n */\n\n// ============================================\n// Source Types\n// ============================================\n\n/**\n * Source type for bundler input.\n */\nexport type SourceType = 'jsx' | 'tsx' | 'mdx' | 'html' | 'auto';\n\n/**\n * Output format for bundles.\n */\nexport type OutputFormat = 'iife' | 'esm' | 'cjs';\n\n// ============================================\n// Bundle Options\n// ============================================\n\n/**\n * Options for bundling source code.\n */\nexport interface BundleOptions {\n /**\n * Source code to bundle.\n */\n source: string;\n\n /**\n * Source type (jsx, tsx, mdx, html, or auto).\n * @default 'auto'\n */\n sourceType?: SourceType;\n\n /**\n * Output format.\n * @default 'iife'\n */\n format?: OutputFormat;\n\n /**\n * Minify output code.\n * @default false\n */\n minify?: boolean;\n\n /**\n * Generate source maps.\n * @default false\n */\n sourceMaps?: boolean | 'inline';\n\n /**\n * External modules (not bundled).\n * @default ['react', 'react-dom']\n */\n externals?: string[];\n\n /**\n * JSX configuration.\n */\n jsx?: {\n /**\n * JSX runtime mode.\n * @default 'automatic'\n */\n runtime?: 'automatic' | 'classic';\n\n /**\n * Import source for automatic runtime.\n * @default 'react'\n */\n importSource?: string;\n };\n\n /**\n * Security policy for bundling.\n */\n security?: SecurityPolicy;\n\n /**\n * Target environment.\n * @default 'es2020'\n */\n target?: string;\n\n /**\n * Global variable name for IIFE format.\n * @default 'Widget'\n */\n globalName?: string;\n\n /**\n * Cache key override. If not provided, computed from source hash.\n */\n cacheKey?: string;\n\n /**\n * Skip cache lookup.\n * @default false\n */\n skipCache?: boolean;\n}\n\n/**\n * Options specifically for SSR bundling.\n */\nexport interface SSRBundleOptions extends BundleOptions {\n /**\n * Context data to inject during SSR.\n */\n context?: Record<string, unknown>;\n\n /**\n * Component export name to render.\n * @default 'default'\n */\n componentExport?: string;\n\n /**\n * Whether to include hydration script.\n * @default false\n */\n includeHydration?: boolean;\n}\n\n// ============================================\n// Bundle Result\n// ============================================\n\n/**\n * Result of a bundle operation.\n */\nexport interface BundleResult {\n /**\n * Bundled/transformed code.\n */\n code: string;\n\n /**\n * Content hash of the bundle.\n */\n hash: string;\n\n /**\n * Whether result was served from cache.\n */\n cached: boolean;\n\n /**\n * Bundle size in bytes.\n */\n size: number;\n\n /**\n * Source map (if generated).\n */\n map?: string;\n\n /**\n * Performance metrics.\n */\n metrics: BundleMetrics;\n\n /**\n * Detected or specified source type.\n */\n sourceType: SourceType;\n\n /**\n * Output format used.\n */\n format: OutputFormat;\n}\n\n/**\n * Performance metrics for bundling.\n */\nexport interface BundleMetrics {\n /**\n * Time to transform source (ms).\n */\n transformTime: number;\n\n /**\n * Time to bundle (ms).\n */\n bundleTime: number;\n\n /**\n * Total processing time (ms).\n */\n totalTime: number;\n\n /**\n * Cache lookup time (ms).\n */\n cacheTime?: number;\n}\n\n// ============================================\n// SSR Result\n// ============================================\n\n/**\n * Result of SSR rendering.\n */\nexport interface SSRResult extends BundleResult {\n /**\n * Rendered HTML output.\n */\n html: string;\n\n /**\n * Hydration script (if included).\n */\n hydrationScript?: string;\n\n /**\n * SSR-specific metrics.\n */\n ssrMetrics: {\n /**\n * Time to render component (ms).\n */\n renderTime: number;\n };\n}\n\n// ============================================\n// Security Policy\n// ============================================\n\n/**\n * Security policy for bundler execution.\n */\nexport interface SecurityPolicy {\n /**\n * Allowed import patterns (regex).\n * @default [/^react/, /^@frontmcp\\/ui/]\n */\n allowedImports?: RegExp[];\n\n /**\n * Blocked import patterns (regex).\n * @default [/^fs/, /^net/, /^child_process/, /^os/, /^path/]\n */\n blockedImports?: RegExp[];\n\n /**\n * Maximum bundle size in bytes.\n * @default 512000 (500KB)\n */\n maxBundleSize?: number;\n\n /**\n * Maximum transform time in ms.\n * @default 5000 (5s)\n */\n maxTransformTime?: number;\n\n /**\n * Block eval() and Function() usage.\n * @default true\n */\n noEval?: boolean;\n\n /**\n * Block dynamic imports.\n * @default true\n */\n noDynamicImports?: boolean;\n\n /**\n * Block require() usage.\n * @default true\n */\n noRequire?: boolean;\n\n /**\n * Allowed global variables.\n * @default ['console', 'Math', 'JSON', 'Date', 'Array', 'Object', 'String', 'Number', 'Boolean', 'Promise', 'Map', 'Set', 'WeakMap', 'WeakSet', 'Symbol', 'Reflect', 'Proxy', 'Error', 'TypeError', 'RangeError', 'parseInt', 'parseFloat', 'isNaN', 'isFinite', 'encodeURI', 'encodeURIComponent', 'decodeURI', 'decodeURIComponent', 'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval']\n */\n allowedGlobals?: string[];\n}\n\n// ============================================\n// Security Violation\n// ============================================\n\n/**\n * Security violation details.\n */\nexport interface SecurityViolation {\n /**\n * Type of violation.\n */\n type:\n | 'blocked-import'\n | 'disallowed-import'\n | 'eval-usage'\n | 'dynamic-import'\n | 'require-usage'\n | 'size-exceeded'\n | 'timeout'\n | 'blocked-global';\n\n /**\n * Human-readable message.\n */\n message: string;\n\n /**\n * Location in source (if available).\n */\n location?: {\n line: number;\n column: number;\n };\n\n /**\n * Offending pattern/value.\n */\n value?: string;\n}\n\n// ============================================\n// Bundler Options\n// ============================================\n\n/**\n * Configuration options for creating a bundler instance.\n */\nexport interface BundlerOptions {\n /**\n * Default security policy.\n */\n defaultSecurity?: SecurityPolicy;\n\n /**\n * Cache configuration.\n */\n cache?: {\n /**\n * Maximum number of cached entries.\n * @default 100\n */\n maxSize?: number;\n\n /**\n * TTL for cache entries in ms.\n * @default 300000 (5 minutes)\n */\n ttl?: number;\n\n /**\n * Disable caching entirely.\n * @default false\n */\n disabled?: boolean;\n };\n\n /**\n * Enable verbose logging.\n * @default false\n */\n verbose?: boolean;\n\n /**\n * Custom esbuild options.\n */\n esbuildOptions?: Record<string, unknown>;\n}\n\n// ============================================\n// Cache Entry\n// ============================================\n\n/**\n * Cache entry for bundled results.\n */\nexport interface CacheEntry {\n /**\n * Bundle result.\n */\n result: BundleResult;\n\n /**\n * Creation timestamp.\n */\n createdAt: number;\n\n /**\n * Last access timestamp.\n */\n lastAccessedAt: number;\n\n /**\n * Access count.\n */\n accessCount: number;\n}\n\n// ============================================\n// Transform Context\n// ============================================\n\n/**\n * Context for transform operations.\n */\nexport interface TransformContext {\n /**\n * Source type being transformed.\n */\n sourceType: SourceType;\n\n /**\n * File path (for source maps).\n */\n filename?: string;\n\n /**\n * Source code.\n */\n source: string;\n\n /**\n * Active security policy.\n */\n security: SecurityPolicy;\n}\n\n// ============================================\n// Default Values\n// ============================================\n\n/**\n * Default security policy.\n */\nexport const DEFAULT_SECURITY_POLICY: SecurityPolicy = {\n allowedImports: [/^react$/, /^react-dom$/, /^react\\/jsx-runtime$/, /^react\\/jsx-dev-runtime$/, /^@frontmcp\\/ui/],\n blockedImports: [\n /^fs$/,\n /^fs\\//,\n /^net$/,\n /^child_process$/,\n /^os$/,\n /^path$/,\n /^crypto$/,\n /^http$/,\n /^https$/,\n /^dgram$/,\n /^dns$/,\n /^cluster$/,\n /^readline$/,\n /^repl$/,\n /^tls$/,\n /^vm$/,\n /^worker_threads$/,\n ],\n maxBundleSize: 512000, // 500KB\n maxTransformTime: 5000, // 5s\n noEval: true,\n noDynamicImports: true,\n noRequire: true,\n allowedGlobals: [\n 'console',\n 'Math',\n 'JSON',\n 'Date',\n 'Array',\n 'Object',\n 'String',\n 'Number',\n 'Boolean',\n 'Promise',\n 'Map',\n 'Set',\n 'WeakMap',\n 'WeakSet',\n 'Symbol',\n 'Reflect',\n 'Proxy',\n 'Error',\n 'TypeError',\n 'RangeError',\n 'SyntaxError',\n 'ReferenceError',\n 'parseInt',\n 'parseFloat',\n 'isNaN',\n 'isFinite',\n 'encodeURI',\n 'encodeURIComponent',\n 'decodeURI',\n 'decodeURIComponent',\n 'setTimeout',\n 'clearTimeout',\n 'setInterval',\n 'clearInterval',\n 'atob',\n 'btoa',\n 'Intl',\n 'TextEncoder',\n 'TextDecoder',\n 'URL',\n 'URLSearchParams',\n 'Uint8Array',\n 'Int8Array',\n 'Uint16Array',\n 'Int16Array',\n 'Uint32Array',\n 'Int32Array',\n 'Float32Array',\n 'Float64Array',\n 'BigInt',\n 'BigInt64Array',\n 'BigUint64Array',\n 'ArrayBuffer',\n 'SharedArrayBuffer',\n 'DataView',\n 'queueMicrotask',\n ],\n};\n\n/**\n * Default bundle options.\n */\nexport const DEFAULT_BUNDLE_OPTIONS: Required<\n Pick<\n BundleOptions,\n 'sourceType' | 'format' | 'minify' | 'sourceMaps' | 'externals' | 'jsx' | 'target' | 'globalName' | 'skipCache'\n >\n> = {\n sourceType: 'auto',\n format: 'iife',\n minify: false,\n sourceMaps: false,\n externals: ['react', 'react-dom'],\n jsx: {\n runtime: 'automatic',\n importSource: 'react',\n },\n target: 'es2020',\n globalName: 'Widget',\n skipCache: false,\n};\n\n/**\n * Default bundler options.\n */\nexport const DEFAULT_BUNDLER_OPTIONS: Required<BundlerOptions> = {\n defaultSecurity: DEFAULT_SECURITY_POLICY,\n cache: {\n maxSize: 100,\n ttl: 300000, // 5 minutes\n disabled: false,\n },\n verbose: false,\n esbuildOptions: {},\n};\n"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alert Component
|
|
3
|
+
*
|
|
4
|
+
* Notification and message display components.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Alert variant styles
|
|
8
|
+
*/
|
|
9
|
+
export type AlertVariant = 'info' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
10
|
+
/**
|
|
11
|
+
* Alert component options
|
|
12
|
+
*/
|
|
13
|
+
export interface AlertOptions {
|
|
14
|
+
/** Alert variant */
|
|
15
|
+
variant?: AlertVariant;
|
|
16
|
+
/** Alert title */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** Show icon */
|
|
19
|
+
showIcon?: boolean;
|
|
20
|
+
/** Custom icon (overrides default) */
|
|
21
|
+
icon?: string;
|
|
22
|
+
/** Dismissible alert */
|
|
23
|
+
dismissible?: boolean;
|
|
24
|
+
/** Additional CSS classes */
|
|
25
|
+
className?: string;
|
|
26
|
+
/** Alert ID */
|
|
27
|
+
id?: string;
|
|
28
|
+
/** Actions (buttons) */
|
|
29
|
+
actions?: string;
|
|
30
|
+
/** HTMX for dismiss */
|
|
31
|
+
onDismiss?: {
|
|
32
|
+
delete?: string;
|
|
33
|
+
target?: string;
|
|
34
|
+
swap?: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build an alert component
|
|
39
|
+
*/
|
|
40
|
+
export declare function alert(message: string, options?: AlertOptions): string;
|
|
41
|
+
/** Info alert shorthand */
|
|
42
|
+
export declare const infoAlert: (message: string, opts?: Omit<AlertOptions, "variant">) => string;
|
|
43
|
+
/** Success alert shorthand */
|
|
44
|
+
export declare const successAlert: (message: string, opts?: Omit<AlertOptions, "variant">) => string;
|
|
45
|
+
/** Warning alert shorthand */
|
|
46
|
+
export declare const warningAlert: (message: string, opts?: Omit<AlertOptions, "variant">) => string;
|
|
47
|
+
/** Danger/error alert shorthand */
|
|
48
|
+
export declare const dangerAlert: (message: string, opts?: Omit<AlertOptions, "variant">) => string;
|
|
49
|
+
/**
|
|
50
|
+
* Toast notification options
|
|
51
|
+
*/
|
|
52
|
+
export interface ToastOptions {
|
|
53
|
+
/** Toast variant */
|
|
54
|
+
variant?: AlertVariant;
|
|
55
|
+
/** Toast title */
|
|
56
|
+
title?: string;
|
|
57
|
+
/** Duration in ms (0 = no auto-dismiss) */
|
|
58
|
+
duration?: number;
|
|
59
|
+
/** Position */
|
|
60
|
+
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
|
|
61
|
+
/** Toast ID */
|
|
62
|
+
id?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build a toast notification
|
|
66
|
+
*/
|
|
67
|
+
export declare function toast(message: string, options?: ToastOptions): string;
|
|
68
|
+
/**
|
|
69
|
+
* Build a toast container (for multiple toasts)
|
|
70
|
+
*/
|
|
71
|
+
export declare function toastContainer(position?: ToastOptions['position'], id?: string): string;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Alert Component
|
|
4
|
+
*
|
|
5
|
+
* Notification and message display components.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.dangerAlert = exports.warningAlert = exports.successAlert = exports.infoAlert = void 0;
|
|
9
|
+
exports.alert = alert;
|
|
10
|
+
exports.toast = toast;
|
|
11
|
+
exports.toastContainer = toastContainer;
|
|
12
|
+
const base_1 = require("../layouts/base");
|
|
13
|
+
// ============================================
|
|
14
|
+
// Alert Icons
|
|
15
|
+
// ============================================
|
|
16
|
+
const alertIcons = {
|
|
17
|
+
info: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
18
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
19
|
+
</svg>`,
|
|
20
|
+
success: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
21
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
22
|
+
</svg>`,
|
|
23
|
+
warning: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
24
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
|
|
25
|
+
</svg>`,
|
|
26
|
+
danger: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
27
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
28
|
+
</svg>`,
|
|
29
|
+
neutral: `<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
30
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
31
|
+
</svg>`,
|
|
32
|
+
};
|
|
33
|
+
// ============================================
|
|
34
|
+
// Alert Builder
|
|
35
|
+
// ============================================
|
|
36
|
+
/**
|
|
37
|
+
* Get variant CSS classes
|
|
38
|
+
*/
|
|
39
|
+
function getVariantClasses(variant) {
|
|
40
|
+
const variants = {
|
|
41
|
+
info: {
|
|
42
|
+
container: 'bg-blue-50 border-blue-200 text-blue-800',
|
|
43
|
+
icon: 'text-blue-500',
|
|
44
|
+
},
|
|
45
|
+
success: {
|
|
46
|
+
container: 'bg-success/10 border-success/30 text-success',
|
|
47
|
+
icon: 'text-success',
|
|
48
|
+
},
|
|
49
|
+
warning: {
|
|
50
|
+
container: 'bg-warning/10 border-warning/30 text-warning',
|
|
51
|
+
icon: 'text-warning',
|
|
52
|
+
},
|
|
53
|
+
danger: {
|
|
54
|
+
container: 'bg-danger/10 border-danger/30 text-danger',
|
|
55
|
+
icon: 'text-danger',
|
|
56
|
+
},
|
|
57
|
+
neutral: {
|
|
58
|
+
container: 'bg-gray-50 border-gray-200 text-gray-800',
|
|
59
|
+
icon: 'text-gray-500',
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
return variants[variant];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build an alert component
|
|
66
|
+
*/
|
|
67
|
+
function alert(message, options = {}) {
|
|
68
|
+
const { variant = 'info', title, showIcon = true, icon, dismissible = false, className = '', id, actions, onDismiss, } = options;
|
|
69
|
+
const variantClasses = getVariantClasses(variant);
|
|
70
|
+
const baseClasses = ['rounded-lg border p-4', variantClasses.container, className].filter(Boolean).join(' ');
|
|
71
|
+
const iconHtml = showIcon
|
|
72
|
+
? `<div class="flex-shrink-0 ${variantClasses.icon}">
|
|
73
|
+
${icon || alertIcons[variant]}
|
|
74
|
+
</div>`
|
|
75
|
+
: '';
|
|
76
|
+
const titleHtml = title ? `<h3 class="font-semibold">${(0, base_1.escapeHtml)(title)}</h3>` : '';
|
|
77
|
+
const dismissHtml = dismissible
|
|
78
|
+
? `<button
|
|
79
|
+
type="button"
|
|
80
|
+
class="flex-shrink-0 ml-auto -mr-1 -mt-1 p-1 rounded hover:bg-black/5 transition-colors"
|
|
81
|
+
${onDismiss?.delete
|
|
82
|
+
? `hx-delete="${(0, base_1.escapeHtml)(onDismiss.delete)}"`
|
|
83
|
+
: `onclick="this.closest('.alert').remove()"`}
|
|
84
|
+
${onDismiss?.target ? `hx-target="${(0, base_1.escapeHtml)(onDismiss.target)}"` : ''}
|
|
85
|
+
${onDismiss?.swap ? `hx-swap="${(0, base_1.escapeHtml)(onDismiss.swap)}"` : ''}
|
|
86
|
+
aria-label="Dismiss"
|
|
87
|
+
>
|
|
88
|
+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
89
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
|
|
90
|
+
</svg>
|
|
91
|
+
</button>`
|
|
92
|
+
: '';
|
|
93
|
+
const actionsHtml = actions ? `<div class="mt-3">${actions}</div>` : '';
|
|
94
|
+
const idAttr = id ? `id="${(0, base_1.escapeHtml)(id)}"` : '';
|
|
95
|
+
return `<div class="alert ${baseClasses}" role="alert" ${idAttr}>
|
|
96
|
+
<div class="flex gap-3">
|
|
97
|
+
${iconHtml}
|
|
98
|
+
<div class="flex-1">
|
|
99
|
+
${titleHtml}
|
|
100
|
+
<div class="${title ? 'mt-1' : ''}">${(0, base_1.escapeHtml)(message)}</div>
|
|
101
|
+
${actionsHtml}
|
|
102
|
+
</div>
|
|
103
|
+
${dismissHtml}
|
|
104
|
+
</div>
|
|
105
|
+
</div>`;
|
|
106
|
+
}
|
|
107
|
+
// ============================================
|
|
108
|
+
// Alert Presets
|
|
109
|
+
// ============================================
|
|
110
|
+
/** Info alert shorthand */
|
|
111
|
+
const infoAlert = (message, opts) => alert(message, { ...opts, variant: 'info' });
|
|
112
|
+
exports.infoAlert = infoAlert;
|
|
113
|
+
/** Success alert shorthand */
|
|
114
|
+
const successAlert = (message, opts) => alert(message, { ...opts, variant: 'success' });
|
|
115
|
+
exports.successAlert = successAlert;
|
|
116
|
+
/** Warning alert shorthand */
|
|
117
|
+
const warningAlert = (message, opts) => alert(message, { ...opts, variant: 'warning' });
|
|
118
|
+
exports.warningAlert = warningAlert;
|
|
119
|
+
/** Danger/error alert shorthand */
|
|
120
|
+
const dangerAlert = (message, opts) => alert(message, { ...opts, variant: 'danger' });
|
|
121
|
+
exports.dangerAlert = dangerAlert;
|
|
122
|
+
/**
|
|
123
|
+
* Build a toast notification
|
|
124
|
+
*/
|
|
125
|
+
function toast(message, options = {}) {
|
|
126
|
+
const { variant = 'info', title, duration = 5000, position = 'top-right', id = `toast-${Date.now()}` } = options;
|
|
127
|
+
const variantClasses = getVariantClasses(variant);
|
|
128
|
+
const positionClasses = {
|
|
129
|
+
'top-right': 'top-4 right-4',
|
|
130
|
+
'top-left': 'top-4 left-4',
|
|
131
|
+
'bottom-right': 'bottom-4 right-4',
|
|
132
|
+
'bottom-left': 'bottom-4 left-4',
|
|
133
|
+
'top-center': 'top-4 left-1/2 -translate-x-1/2',
|
|
134
|
+
'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2',
|
|
135
|
+
};
|
|
136
|
+
const titleHtml = title ? `<h4 class="font-semibold">${(0, base_1.escapeHtml)(title)}</h4>` : '';
|
|
137
|
+
const autoDismissScript = duration > 0
|
|
138
|
+
? `<script>
|
|
139
|
+
setTimeout(() => {
|
|
140
|
+
const toast = document.getElementById('${id}');
|
|
141
|
+
if (toast) {
|
|
142
|
+
toast.classList.add('opacity-0', 'translate-x-2');
|
|
143
|
+
setTimeout(() => toast.remove(), 300);
|
|
144
|
+
}
|
|
145
|
+
}, ${duration});
|
|
146
|
+
</script>`
|
|
147
|
+
: '';
|
|
148
|
+
return `<div
|
|
149
|
+
id="${(0, base_1.escapeHtml)(id)}"
|
|
150
|
+
class="fixed ${positionClasses[position]} z-50 min-w-[300px] max-w-md rounded-lg border shadow-lg ${variantClasses.container} transition-all duration-300 transform"
|
|
151
|
+
role="alert"
|
|
152
|
+
>
|
|
153
|
+
<div class="flex gap-3 p-4">
|
|
154
|
+
<div class="flex-shrink-0 ${variantClasses.icon}">
|
|
155
|
+
${alertIcons[variant]}
|
|
156
|
+
</div>
|
|
157
|
+
<div class="flex-1">
|
|
158
|
+
${titleHtml}
|
|
159
|
+
<p class="${title ? 'mt-1 text-sm opacity-90' : ''}">${(0, base_1.escapeHtml)(message)}</p>
|
|
160
|
+
</div>
|
|
161
|
+
<button
|
|
162
|
+
type="button"
|
|
163
|
+
class="flex-shrink-0 p-1 rounded hover:bg-black/5 transition-colors"
|
|
164
|
+
onclick="this.closest('#${id}').remove()"
|
|
165
|
+
aria-label="Close"
|
|
166
|
+
>
|
|
167
|
+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
168
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
|
|
169
|
+
</svg>
|
|
170
|
+
</button>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
${autoDismissScript}`;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Build a toast container (for multiple toasts)
|
|
177
|
+
*/
|
|
178
|
+
function toastContainer(position = 'top-right', id = 'toast-container') {
|
|
179
|
+
const positionClasses = {
|
|
180
|
+
'top-right': 'top-4 right-4',
|
|
181
|
+
'top-left': 'top-4 left-4',
|
|
182
|
+
'bottom-right': 'bottom-4 right-4',
|
|
183
|
+
'bottom-left': 'bottom-4 left-4',
|
|
184
|
+
'top-center': 'top-4 left-1/2 -translate-x-1/2',
|
|
185
|
+
'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2',
|
|
186
|
+
};
|
|
187
|
+
return `<div id="${(0, base_1.escapeHtml)(id)}" class="fixed ${positionClasses[position]} z-50 flex flex-col gap-2"></div>`;
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=alert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../../src/components/alert.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Alert Component\n *\n * Notification and message display components.\n */\n\nimport { escapeHtml } from '../layouts/base';\n\n// ============================================\n// Alert Types\n// ============================================\n\n/**\n * Alert variant styles\n */\nexport type AlertVariant = 'info' | 'success' | 'warning' | 'danger' | 'neutral';\n\n/**\n * Alert component options\n */\nexport interface AlertOptions {\n /** Alert variant */\n variant?: AlertVariant;\n /** Alert title */\n title?: string;\n /** Show icon */\n showIcon?: boolean;\n /** Custom icon (overrides default) */\n icon?: string;\n /** Dismissible alert */\n dismissible?: boolean;\n /** Additional CSS classes */\n className?: string;\n /** Alert ID */\n id?: string;\n /** Actions (buttons) */\n actions?: string;\n /** HTMX for dismiss */\n onDismiss?: {\n delete?: string;\n target?: string;\n swap?: string;\n };\n}\n\n// ============================================\n// Alert Icons\n// ============================================\n\nconst alertIcons: Record<AlertVariant, string> = {\n info: `<svg class=\"w-5 h-5\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z\"/>\n </svg>`,\n success: `<svg class=\"w-5 h-5\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z\"/>\n </svg>`,\n warning: `<svg class=\"w-5 h-5\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"/>\n </svg>`,\n danger: `<svg class=\"w-5 h-5\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z\"/>\n </svg>`,\n neutral: `<svg class=\"w-5 h-5\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z\"/>\n </svg>`,\n};\n\n// ============================================\n// Alert Builder\n// ============================================\n\n/**\n * Get variant CSS classes\n */\nfunction getVariantClasses(variant: AlertVariant): { container: string; icon: string } {\n const variants: Record<AlertVariant, { container: string; icon: string }> = {\n info: {\n container: 'bg-blue-50 border-blue-200 text-blue-800',\n icon: 'text-blue-500',\n },\n success: {\n container: 'bg-success/10 border-success/30 text-success',\n icon: 'text-success',\n },\n warning: {\n container: 'bg-warning/10 border-warning/30 text-warning',\n icon: 'text-warning',\n },\n danger: {\n container: 'bg-danger/10 border-danger/30 text-danger',\n icon: 'text-danger',\n },\n neutral: {\n container: 'bg-gray-50 border-gray-200 text-gray-800',\n icon: 'text-gray-500',\n },\n };\n return variants[variant];\n}\n\n/**\n * Build an alert component\n */\nexport function alert(message: string, options: AlertOptions = {}): string {\n const {\n variant = 'info',\n title,\n showIcon = true,\n icon,\n dismissible = false,\n className = '',\n id,\n actions,\n onDismiss,\n } = options;\n\n const variantClasses = getVariantClasses(variant);\n\n const baseClasses = ['rounded-lg border p-4', variantClasses.container, className].filter(Boolean).join(' ');\n\n const iconHtml = showIcon\n ? `<div class=\"flex-shrink-0 ${variantClasses.icon}\">\n ${icon || alertIcons[variant]}\n </div>`\n : '';\n\n const titleHtml = title ? `<h3 class=\"font-semibold\">${escapeHtml(title)}</h3>` : '';\n\n const dismissHtml = dismissible\n ? `<button\n type=\"button\"\n class=\"flex-shrink-0 ml-auto -mr-1 -mt-1 p-1 rounded hover:bg-black/5 transition-colors\"\n ${\n onDismiss?.delete\n ? `hx-delete=\"${escapeHtml(onDismiss.delete)}\"`\n : `onclick=\"this.closest('.alert').remove()\"`\n }\n ${onDismiss?.target ? `hx-target=\"${escapeHtml(onDismiss.target)}\"` : ''}\n ${onDismiss?.swap ? `hx-swap=\"${escapeHtml(onDismiss.swap)}\"` : ''}\n aria-label=\"Dismiss\"\n >\n <svg class=\"w-4 h-4\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"/>\n </svg>\n </button>`\n : '';\n\n const actionsHtml = actions ? `<div class=\"mt-3\">${actions}</div>` : '';\n\n const idAttr = id ? `id=\"${escapeHtml(id)}\"` : '';\n\n return `<div class=\"alert ${baseClasses}\" role=\"alert\" ${idAttr}>\n <div class=\"flex gap-3\">\n ${iconHtml}\n <div class=\"flex-1\">\n ${titleHtml}\n <div class=\"${title ? 'mt-1' : ''}\">${escapeHtml(message)}</div>\n ${actionsHtml}\n </div>\n ${dismissHtml}\n </div>\n </div>`;\n}\n\n// ============================================\n// Alert Presets\n// ============================================\n\n/** Info alert shorthand */\nexport const infoAlert = (message: string, opts?: Omit<AlertOptions, 'variant'>) =>\n alert(message, { ...opts, variant: 'info' });\n\n/** Success alert shorthand */\nexport const successAlert = (message: string, opts?: Omit<AlertOptions, 'variant'>) =>\n alert(message, { ...opts, variant: 'success' });\n\n/** Warning alert shorthand */\nexport const warningAlert = (message: string, opts?: Omit<AlertOptions, 'variant'>) =>\n alert(message, { ...opts, variant: 'warning' });\n\n/** Danger/error alert shorthand */\nexport const dangerAlert = (message: string, opts?: Omit<AlertOptions, 'variant'>) =>\n alert(message, { ...opts, variant: 'danger' });\n\n// ============================================\n// Toast Component\n// ============================================\n\n/**\n * Toast notification options\n */\nexport interface ToastOptions {\n /** Toast variant */\n variant?: AlertVariant;\n /** Toast title */\n title?: string;\n /** Duration in ms (0 = no auto-dismiss) */\n duration?: number;\n /** Position */\n position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';\n /** Toast ID */\n id?: string;\n}\n\n/**\n * Build a toast notification\n */\nexport function toast(message: string, options: ToastOptions = {}): string {\n const { variant = 'info', title, duration = 5000, position = 'top-right', id = `toast-${Date.now()}` } = options;\n\n const variantClasses = getVariantClasses(variant);\n\n const positionClasses: Record<string, string> = {\n 'top-right': 'top-4 right-4',\n 'top-left': 'top-4 left-4',\n 'bottom-right': 'bottom-4 right-4',\n 'bottom-left': 'bottom-4 left-4',\n 'top-center': 'top-4 left-1/2 -translate-x-1/2',\n 'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2',\n };\n\n const titleHtml = title ? `<h4 class=\"font-semibold\">${escapeHtml(title)}</h4>` : '';\n\n const autoDismissScript =\n duration > 0\n ? `<script>\n setTimeout(() => {\n const toast = document.getElementById('${id}');\n if (toast) {\n toast.classList.add('opacity-0', 'translate-x-2');\n setTimeout(() => toast.remove(), 300);\n }\n }, ${duration});\n </script>`\n : '';\n\n return `<div\n id=\"${escapeHtml(id)}\"\n class=\"fixed ${positionClasses[position]} z-50 min-w-[300px] max-w-md rounded-lg border shadow-lg ${\n variantClasses.container\n } transition-all duration-300 transform\"\n role=\"alert\"\n >\n <div class=\"flex gap-3 p-4\">\n <div class=\"flex-shrink-0 ${variantClasses.icon}\">\n ${alertIcons[variant]}\n </div>\n <div class=\"flex-1\">\n ${titleHtml}\n <p class=\"${title ? 'mt-1 text-sm opacity-90' : ''}\">${escapeHtml(message)}</p>\n </div>\n <button\n type=\"button\"\n class=\"flex-shrink-0 p-1 rounded hover:bg-black/5 transition-colors\"\n onclick=\"this.closest('#${id}').remove()\"\n aria-label=\"Close\"\n >\n <svg class=\"w-4 h-4\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"/>\n </svg>\n </button>\n </div>\n </div>\n ${autoDismissScript}`;\n}\n\n/**\n * Build a toast container (for multiple toasts)\n */\nexport function toastContainer(position: ToastOptions['position'] = 'top-right', id = 'toast-container'): string {\n const positionClasses: Record<string, string> = {\n 'top-right': 'top-4 right-4',\n 'top-left': 'top-4 left-4',\n 'bottom-right': 'bottom-4 right-4',\n 'bottom-left': 'bottom-4 left-4',\n 'top-center': 'top-4 left-1/2 -translate-x-1/2',\n 'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2',\n };\n\n return `<div id=\"${escapeHtml(id)}\" class=\"fixed ${positionClasses[position]} z-50 flex flex-col gap-2\"></div>`;\n}\n"]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file alert.schema.ts
|
|
3
|
+
* @description Zod schemas for Alert and Toast component options validation.
|
|
4
|
+
*
|
|
5
|
+
* Provides strict validation schemas for alert options including variants,
|
|
6
|
+
* dismissible alerts, and toast notifications with positioning.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { AlertOptionsSchema, ToastOptionsSchema } from '@frontmcp/ui';
|
|
11
|
+
*
|
|
12
|
+
* const alertResult = AlertOptionsSchema.safeParse({ variant: 'success' });
|
|
13
|
+
* const toastResult = ToastOptionsSchema.safeParse({ position: 'top-right' });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @module @frontmcp/ui/components/alert.schema
|
|
17
|
+
*/
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
/**
|
|
20
|
+
* Alert variant enum schema
|
|
21
|
+
*/
|
|
22
|
+
export declare const AlertVariantSchema: z.ZodEnum<{
|
|
23
|
+
neutral: "neutral";
|
|
24
|
+
success: "success";
|
|
25
|
+
warning: "warning";
|
|
26
|
+
danger: "danger";
|
|
27
|
+
info: "info";
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Alert variant type
|
|
31
|
+
*/
|
|
32
|
+
export type AlertVariant = z.infer<typeof AlertVariantSchema>;
|
|
33
|
+
/**
|
|
34
|
+
* Dismiss button HTMX options schema
|
|
35
|
+
*/
|
|
36
|
+
export declare const AlertOnDismissSchema: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
delete: z.ZodOptional<z.ZodString>;
|
|
38
|
+
target: z.ZodOptional<z.ZodString>;
|
|
39
|
+
swap: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strict>>;
|
|
41
|
+
/**
|
|
42
|
+
* Alert onDismiss type
|
|
43
|
+
*/
|
|
44
|
+
export type AlertOnDismiss = z.infer<typeof AlertOnDismissSchema>;
|
|
45
|
+
/**
|
|
46
|
+
* Complete alert options schema
|
|
47
|
+
*/
|
|
48
|
+
export declare const AlertOptionsSchema: z.ZodObject<{
|
|
49
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
50
|
+
neutral: "neutral";
|
|
51
|
+
success: "success";
|
|
52
|
+
warning: "warning";
|
|
53
|
+
danger: "danger";
|
|
54
|
+
info: "info";
|
|
55
|
+
}>>;
|
|
56
|
+
title: z.ZodOptional<z.ZodString>;
|
|
57
|
+
showIcon: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
59
|
+
dismissible: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
+
className: z.ZodOptional<z.ZodString>;
|
|
61
|
+
id: z.ZodOptional<z.ZodString>;
|
|
62
|
+
actions: z.ZodOptional<z.ZodString>;
|
|
63
|
+
onDismiss: z.ZodOptional<z.ZodObject<{
|
|
64
|
+
delete: z.ZodOptional<z.ZodString>;
|
|
65
|
+
target: z.ZodOptional<z.ZodString>;
|
|
66
|
+
swap: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strict>>;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
/**
|
|
70
|
+
* Alert options type (derived from schema)
|
|
71
|
+
*/
|
|
72
|
+
export type AlertOptions = z.infer<typeof AlertOptionsSchema>;
|
|
73
|
+
/**
|
|
74
|
+
* Toast position enum schema
|
|
75
|
+
*/
|
|
76
|
+
export declare const ToastPositionSchema: z.ZodEnum<{
|
|
77
|
+
"top-right": "top-right";
|
|
78
|
+
"top-left": "top-left";
|
|
79
|
+
"bottom-right": "bottom-right";
|
|
80
|
+
"bottom-left": "bottom-left";
|
|
81
|
+
"top-center": "top-center";
|
|
82
|
+
"bottom-center": "bottom-center";
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* Toast position type
|
|
86
|
+
*/
|
|
87
|
+
export type ToastPosition = z.infer<typeof ToastPositionSchema>;
|
|
88
|
+
/**
|
|
89
|
+
* Complete toast options schema
|
|
90
|
+
*/
|
|
91
|
+
export declare const ToastOptionsSchema: z.ZodObject<{
|
|
92
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
93
|
+
neutral: "neutral";
|
|
94
|
+
success: "success";
|
|
95
|
+
warning: "warning";
|
|
96
|
+
danger: "danger";
|
|
97
|
+
info: "info";
|
|
98
|
+
}>>;
|
|
99
|
+
title: z.ZodOptional<z.ZodString>;
|
|
100
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
position: z.ZodOptional<z.ZodEnum<{
|
|
102
|
+
"top-right": "top-right";
|
|
103
|
+
"top-left": "top-left";
|
|
104
|
+
"bottom-right": "bottom-right";
|
|
105
|
+
"bottom-left": "bottom-left";
|
|
106
|
+
"top-center": "top-center";
|
|
107
|
+
"bottom-center": "bottom-center";
|
|
108
|
+
}>>;
|
|
109
|
+
id: z.ZodOptional<z.ZodString>;
|
|
110
|
+
}, z.core.$strict>;
|
|
111
|
+
/**
|
|
112
|
+
* Toast options type (derived from schema)
|
|
113
|
+
*/
|
|
114
|
+
export type ToastOptions = z.infer<typeof ToastOptionsSchema>;
|