@pixel-point/toolcraft 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +98 -0
- package/README.md +41 -0
- package/bin/create-toolcraft-app.mjs +8 -0
- package/bin/toolcraft.mjs +8 -0
- package/package.json +24 -0
- package/scripts/prepare-pack.mjs +29 -0
- package/src/cli.mjs +392 -0
- package/src/cli.test.mjs +284 -0
- package/src/copy-recursive.mjs +86 -0
- package/src/generate.mjs +212 -0
- package/src/generate.test.mjs +322 -0
- package/src/import-map.mjs +14 -0
- package/src/package-json.mjs +80 -0
- package/src/package-json.test.mjs +67 -0
- package/src/rewrite-imports.mjs +85 -0
- package/src/rewrite-imports.test.mjs +58 -0
- package/templates/runtime/contracts/component-contracts.test.ts +1165 -0
- package/templates/runtime/contracts/component-contracts.ts +1340 -0
- package/templates/runtime/contracts/decision-contracts.test.ts +206 -0
- package/templates/runtime/contracts/decision-contracts.ts +283 -0
- package/templates/runtime/contracts/index.test.ts +14 -0
- package/templates/runtime/contracts/index.ts +3 -0
- package/templates/runtime/contracts/types.ts +56 -0
- package/templates/runtime/export/export.test.ts +203 -0
- package/templates/runtime/export/export.ts +132 -0
- package/templates/runtime/export/index.ts +1 -0
- package/templates/runtime/index.ts +14 -0
- package/templates/runtime/react/canvas-shell.test.tsx +424 -0
- package/templates/runtime/react/canvas-shell.tsx +408 -0
- package/templates/runtime/react/control-renderers.ts +31 -0
- package/templates/runtime/react/controls-panel.test.tsx +3736 -0
- package/templates/runtime/react/controls-panel.tsx +2327 -0
- package/templates/runtime/react/curve-geometry.test.ts +70 -0
- package/templates/runtime/react/index.ts +15 -0
- package/templates/runtime/react/layer-tree.ts +96 -0
- package/templates/runtime/react/layers-panel.test.tsx +487 -0
- package/templates/runtime/react/layers-panel.tsx +1348 -0
- package/templates/runtime/react/media-file.ts +82 -0
- package/templates/runtime/react/panel-host-config.ts +80 -0
- package/templates/runtime/react/panel-host-geometry.test.ts +66 -0
- package/templates/runtime/react/panel-host-geometry.ts +109 -0
- package/templates/runtime/react/panel-host-types.ts +74 -0
- package/templates/runtime/react/panel-host.test.tsx +102 -0
- package/templates/runtime/react/panel-host.tsx +353 -0
- package/templates/runtime/react/runtime-public-api.test.tsx +132 -0
- package/templates/runtime/react/settings-transfer.test.ts +150 -0
- package/templates/runtime/react/settings-transfer.ts +279 -0
- package/templates/runtime/react/storage-key-migration.ts +48 -0
- package/templates/runtime/react/theme-runtime.tsx +177 -0
- package/templates/runtime/react/timeline-panel.test.tsx +668 -0
- package/templates/runtime/react/timeline-panel.tsx +2953 -0
- package/templates/runtime/react/toolbar-panel.test.tsx +212 -0
- package/templates/runtime/react/toolbar-panel.tsx +205 -0
- package/templates/runtime/react/toolcraft-app.integration.test.tsx +350 -0
- package/templates/runtime/react/toolcraft-app.test.tsx +339 -0
- package/templates/runtime/react/toolcraft-app.tsx +81 -0
- package/templates/runtime/react/toolcraft-root.test.tsx +347 -0
- package/templates/runtime/react/toolcraft-root.tsx +203 -0
- package/templates/runtime/react/use-toolcraft.ts +41 -0
- package/templates/runtime/schema/define-toolcraft.test.ts +1524 -0
- package/templates/runtime/schema/define-toolcraft.ts +1442 -0
- package/templates/runtime/schema/keyframe-capability.test.ts +90 -0
- package/templates/runtime/schema/keyframe-capability.ts +51 -0
- package/templates/runtime/schema/runtime-targets.ts +40 -0
- package/templates/runtime/schema/types.ts +370 -0
- package/templates/runtime/state/canvas-zoom.ts +8 -0
- package/templates/runtime/state/create-template-state.test.ts +242 -0
- package/templates/runtime/state/create-template-state.ts +95 -0
- package/templates/runtime/state/keyframe-evaluation.test.ts +141 -0
- package/templates/runtime/state/keyframe-evaluation.ts +203 -0
- package/templates/runtime/state/persistence.test.ts +217 -0
- package/templates/runtime/state/persistence.ts +511 -0
- package/templates/runtime/state/reducer.test.ts +937 -0
- package/templates/runtime/state/reducer.ts +1212 -0
- package/templates/runtime/state/timeline-readiness.ts +43 -0
- package/templates/runtime/state/types.ts +242 -0
- package/templates/runtime/styles.css +125 -0
- package/templates/runtime/testing/performance.test.ts +1058 -0
- package/templates/runtime/testing/performance.ts +1078 -0
- package/templates/starter/AGENTS.md +186 -0
- package/templates/starter/LICENSE.md +98 -0
- package/templates/starter/NOTICE.md +8 -0
- package/templates/starter/docs/toolcraft/README.md +41 -0
- package/templates/starter/docs/toolcraft/acceptance-testing.md +205 -0
- package/templates/starter/docs/toolcraft/agent-worklog.md +81 -0
- package/templates/starter/docs/toolcraft/assembly-workflow.md +206 -0
- package/templates/starter/docs/toolcraft/component-rules.md +299 -0
- package/templates/starter/docs/toolcraft/custom-controls.md +71 -0
- package/templates/starter/docs/toolcraft/decision-contract.md +71 -0
- package/templates/starter/docs/toolcraft/performance.md +112 -0
- package/templates/starter/docs/toolcraft/renderer-technique.md +48 -0
- package/templates/starter/docs/toolcraft/schema-reference.md +265 -0
- package/templates/starter/docs/toolcraft/workflow.md +87 -0
- package/templates/starter/e2e/app-browser-acceptance.spec.ts +785 -0
- package/templates/starter/e2e/app-controls.spec.ts +41 -0
- package/templates/starter/e2e/app-performance.spec.ts +326 -0
- package/templates/starter/e2e/canvas-handle-helpers.ts +244 -0
- package/templates/starter/e2e/performance-helpers.ts +612 -0
- package/templates/starter/e2e/product-observable-helpers.ts +170 -0
- package/templates/starter/index.html +12 -0
- package/templates/starter/package.json +52 -0
- package/templates/starter/playwright.config.ts +43 -0
- package/templates/starter/scripts/check-ai-skills.mjs +95 -0
- package/templates/starter/scripts/check-toolcraft-docs.mjs +159 -0
- package/templates/starter/scripts/check-toolcraft-integrity.mjs +232 -0
- package/templates/starter/scripts/run-vite-on-free-port.mjs +48 -0
- package/templates/starter/scripts/toolcraft-port.mjs +54 -0
- package/templates/starter/scripts/toolcraft-port.test.mjs +73 -0
- package/templates/starter/src/app/starter-acceptance.test.ts +5959 -0
- package/templates/starter/src/app/starter-acceptance.ts +2646 -0
- package/templates/starter/src/app/starter-performance.test.ts +1390 -0
- package/templates/starter/src/app/starter-performance.ts +12 -0
- package/templates/starter/src/app/starter-schema.test.ts +70 -0
- package/templates/starter/src/app/starter-schema.ts +15 -0
- package/templates/starter/src/main.tsx +18 -0
- package/templates/starter/src/router.tsx +16 -0
- package/templates/starter/src/routes/index.tsx +7 -0
- package/templates/starter/src/routes/root.tsx +19 -0
- package/templates/starter/src/styles.css +120 -0
- package/templates/starter/tsconfig.json +11 -0
- package/templates/starter/vite.config.ts +13 -0
- package/templates/ui/components/composites/accordion.tsx +73 -0
- package/templates/ui/components/composites/alert-dialog.tsx +190 -0
- package/templates/ui/components/composites/alert.tsx +74 -0
- package/templates/ui/components/composites/aspect-ratio.tsx +22 -0
- package/templates/ui/components/composites/avatar.tsx +98 -0
- package/templates/ui/components/composites/badge.tsx +69 -0
- package/templates/ui/components/composites/breadcrumb.tsx +106 -0
- package/templates/ui/components/composites/card.tsx +91 -0
- package/templates/ui/components/composites/combobox.tsx +486 -0
- package/templates/ui/components/composites/command.tsx +296 -0
- package/templates/ui/components/composites/context-menu.tsx +247 -0
- package/templates/ui/components/composites/dialog.tsx +282 -0
- package/templates/ui/components/composites/dropdown-menu.tsx +299 -0
- package/templates/ui/components/composites/empty.tsx +110 -0
- package/templates/ui/components/composites/hover-card.tsx +44 -0
- package/templates/ui/components/composites/index.ts +30 -0
- package/templates/ui/components/composites/menubar.tsx +214 -0
- package/templates/ui/components/composites/navigation-menu.tsx +167 -0
- package/templates/ui/components/composites/pagination.tsx +131 -0
- package/templates/ui/components/composites/progress.tsx +72 -0
- package/templates/ui/components/composites/radio-group.tsx +84 -0
- package/templates/ui/components/composites/resizable.tsx +42 -0
- package/templates/ui/components/composites/sheet.tsx +153 -0
- package/templates/ui/components/composites/sidebar-structural.tsx +310 -0
- package/templates/ui/components/composites/sidebar.tsx +431 -0
- package/templates/ui/components/composites/sonner.tsx +35 -0
- package/templates/ui/components/composites/spinner.tsx +43 -0
- package/templates/ui/components/composites/table.tsx +108 -0
- package/templates/ui/components/composites/tabs.tsx +83 -0
- package/templates/ui/components/control-layout/index.tsx +437 -0
- package/templates/ui/components/controls/actions/actions-control.tsx +139 -0
- package/templates/ui/components/controls/actions/index.ts +9 -0
- package/templates/ui/components/controls/anchor-grid/anchor-grid-control.tsx +107 -0
- package/templates/ui/components/controls/anchor-grid/index.ts +4 -0
- package/templates/ui/components/controls/boolean/boolean-controls.tsx +79 -0
- package/templates/ui/components/controls/boolean/index.ts +4 -0
- package/templates/ui/components/controls/channel-mixer/channel-mixer-control.tsx +95 -0
- package/templates/ui/components/controls/channel-mixer/index.ts +4 -0
- package/templates/ui/components/controls/channel-tabs/channel-tabs.tsx +42 -0
- package/templates/ui/components/controls/channel-tabs/index.ts +6 -0
- package/templates/ui/components/controls/code-textarea/code-textarea-control.tsx +90 -0
- package/templates/ui/components/controls/code-textarea/index.ts +4 -0
- package/templates/ui/components/controls/color/color-control.tsx +571 -0
- package/templates/ui/components/controls/color/color-picker-popover.tsx +104 -0
- package/templates/ui/components/controls/color/index.ts +41 -0
- package/templates/ui/components/controls/color/palette-control-data.ts +436 -0
- package/templates/ui/components/controls/color/palette-control.tsx +535 -0
- package/templates/ui/components/controls/color/style-guide-color-picker-channel-utils.ts +162 -0
- package/templates/ui/components/controls/color/style-guide-color-picker-interactions.ts +190 -0
- package/templates/ui/components/controls/color/style-guide-color-picker-logic.ts +485 -0
- package/templates/ui/components/controls/color/style-guide-color-picker-parts.tsx +710 -0
- package/templates/ui/components/controls/color/style-guide-color-picker.tsx +503 -0
- package/templates/ui/components/controls/control-types.ts +43 -0
- package/templates/ui/components/controls/curves/curve-geometry.ts +355 -0
- package/templates/ui/components/controls/curves/curve-graph.tsx +390 -0
- package/templates/ui/components/controls/curves/curves-control.tsx +445 -0
- package/templates/ui/components/controls/curves/index.ts +6 -0
- package/templates/ui/components/controls/file-drop/file-drop-control.tsx +191 -0
- package/templates/ui/components/controls/file-drop/index.ts +5 -0
- package/templates/ui/components/controls/font-picker/font-catalog.json +15360 -0
- package/templates/ui/components/controls/font-picker/font-catalog.ts +116 -0
- package/templates/ui/components/controls/font-picker/font-picker-control.tsx +1202 -0
- package/templates/ui/components/controls/font-picker/font-preview-loader.ts +336 -0
- package/templates/ui/components/controls/font-picker/index.ts +24 -0
- package/templates/ui/components/controls/font-picker/use-hover-intent.ts +46 -0
- package/templates/ui/components/controls/gradient/gradient-control-utils.ts +190 -0
- package/templates/ui/components/controls/gradient/gradient-control.tsx +612 -0
- package/templates/ui/components/controls/gradient/gradient-stop-list.tsx +400 -0
- package/templates/ui/components/controls/gradient/gradient-toolbar.tsx +152 -0
- package/templates/ui/components/controls/gradient/index.ts +4 -0
- package/templates/ui/components/controls/image-picker/image-picker-control.tsx +139 -0
- package/templates/ui/components/controls/image-picker/index.ts +7 -0
- package/templates/ui/components/controls/index.ts +192 -0
- package/templates/ui/components/controls/range-input/index.ts +4 -0
- package/templates/ui/components/controls/range-input/range-input-control.tsx +173 -0
- package/templates/ui/components/controls/range-slider/index.ts +4 -0
- package/templates/ui/components/controls/range-slider/range-slider-control.tsx +122 -0
- package/templates/ui/components/controls/range-slider/range-slider-value.ts +61 -0
- package/templates/ui/components/controls/segmented/index.ts +8 -0
- package/templates/ui/components/controls/segmented/segmented-control.tsx +94 -0
- package/templates/ui/components/controls/select/index.ts +4 -0
- package/templates/ui/components/controls/select/select-control.tsx +223 -0
- package/templates/ui/components/controls/slider/index.ts +4 -0
- package/templates/ui/components/controls/slider/slider-control.tsx +150 -0
- package/templates/ui/components/controls/slider/slider-value.ts +56 -0
- package/templates/ui/components/controls/text-input/index.ts +4 -0
- package/templates/ui/components/controls/text-input/text-input-control.tsx +158 -0
- package/templates/ui/components/controls/use-measured-element-width.ts +42 -0
- package/templates/ui/components/controls/vector/index.ts +8 -0
- package/templates/ui/components/controls/vector/vector-control.tsx +401 -0
- package/templates/ui/components/panel/index.ts +19 -0
- package/templates/ui/components/panel/panel-actions.tsx +165 -0
- package/templates/ui/components/panel/panel-header.tsx +61 -0
- package/templates/ui/components/panel/panel-icon-button.tsx +96 -0
- package/templates/ui/components/panel/panel-section.tsx +168 -0
- package/templates/ui/components/panel/panel-surface.tsx +206 -0
- package/templates/ui/components/panel/panel.tsx +210 -0
- package/templates/ui/components/primitives/animated-loader.tsx +61 -0
- package/templates/ui/components/primitives/button-group.tsx +134 -0
- package/templates/ui/components/primitives/button.tsx +429 -0
- package/templates/ui/components/primitives/checkbox.tsx +62 -0
- package/templates/ui/components/primitives/editable-slider-value-label.tsx +337 -0
- package/templates/ui/components/primitives/field.tsx +225 -0
- package/templates/ui/components/primitives/index.ts +82 -0
- package/templates/ui/components/primitives/input-group.tsx +298 -0
- package/templates/ui/components/primitives/input.tsx +61 -0
- package/templates/ui/components/primitives/internal/button-loading.tsx +178 -0
- package/templates/ui/components/primitives/label.tsx +16 -0
- package/templates/ui/components/primitives/popover.tsx +126 -0
- package/templates/ui/components/primitives/portal-layer-context.tsx +33 -0
- package/templates/ui/components/primitives/primitive-arrow-icon.tsx +38 -0
- package/templates/ui/components/primitives/scroll-fade-logic.ts +441 -0
- package/templates/ui/components/primitives/scroll-fade-render.tsx +75 -0
- package/templates/ui/components/primitives/scroll-fade-types.ts +41 -0
- package/templates/ui/components/primitives/scroll-fade.tsx +72 -0
- package/templates/ui/components/primitives/select.tsx +408 -0
- package/templates/ui/components/primitives/selection-state.ts +31 -0
- package/templates/ui/components/primitives/separator.tsx +21 -0
- package/templates/ui/components/primitives/slider/index.ts +4 -0
- package/templates/ui/components/primitives/slider/slider-interaction.tsx +96 -0
- package/templates/ui/components/primitives/slider/slider-parts.tsx +303 -0
- package/templates/ui/components/primitives/slider/slider-reset.ts +152 -0
- package/templates/ui/components/primitives/slider/slider-value.ts +114 -0
- package/templates/ui/components/primitives/slider/slider.tsx +511 -0
- package/templates/ui/components/primitives/switch.tsx +35 -0
- package/templates/ui/components/primitives/textarea.tsx +49 -0
- package/templates/ui/components/primitives/toggle-group.tsx +114 -0
- package/templates/ui/components/primitives/toggle.tsx +46 -0
- package/templates/ui/components/primitives/tooltip.tsx +100 -0
- package/templates/ui/hooks/use-mobile.ts +21 -0
- package/templates/ui/index.ts +31 -0
- package/templates/ui/lib/control-outline.ts +3 -0
- package/templates/ui/lib/input-control-style.ts +131 -0
- package/templates/ui/lib/style-guide-color-utils.ts +111 -0
- package/templates/ui/lib/utils.ts +6 -0
- package/templates/ui/styles.css +291 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
|
+
|
|
6
|
+
import { toggleSelectedItemClassName } from "./selection-state";
|
|
7
|
+
import { cn } from "../../lib/utils";
|
|
8
|
+
|
|
9
|
+
const toggleVariants = cva(
|
|
10
|
+
`group/toggle inline-flex cursor-pointer items-center justify-center gap-1 rounded-md text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-[color:color-mix(in_oklab,var(--foreground)_10%,transparent)] hover:text-[color:var(--foreground)] focus-visible:border-[color:var(--ring)] focus-visible:ring-[3px] focus-visible:ring-[color:color-mix(in_oklab,var(--ring)_50%,transparent)] disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-[color:var(--destructive)] aria-invalid:ring-[color:color-mix(in_oklab,var(--destructive)_20%,transparent)] ${toggleSelectedItemClassName} dark:aria-invalid:ring-[color:color-mix(in_oklab,var(--destructive)_40%,transparent)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,
|
|
11
|
+
{
|
|
12
|
+
variants: {
|
|
13
|
+
variant: {
|
|
14
|
+
default:
|
|
15
|
+
"bg-transparent text-[color:color-mix(in_oklab,var(--foreground)_72%,transparent)]",
|
|
16
|
+
outline: `border border-[color:color-mix(in_oklab,var(--border)_12%,transparent)] bg-[color:color-mix(in_oklab,var(--input)_5%,transparent)] text-[color:color-mix(in_oklab,var(--foreground)_72%,transparent)] hover:bg-[color:color-mix(in_oklab,var(--foreground)_10%,transparent)] hover:text-[color:var(--foreground)] ${toggleSelectedItemClassName} aria-pressed:hover:bg-[color:color-mix(in_oklab,var(--link)_12%,transparent)] aria-pressed:hover:text-[color:var(--foreground)] data-[pressed]:hover:bg-[color:color-mix(in_oklab,var(--link)_12%,transparent)] data-[pressed]:hover:text-[color:var(--foreground)] data-[state=on]:hover:bg-[color:color-mix(in_oklab,var(--link)_12%,transparent)] data-[state=on]:hover:text-[color:var(--foreground)]`,
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
default: "h-7 min-w-7 px-2",
|
|
20
|
+
sm: "h-6 min-w-6 rounded-[min(var(--radius-md),8px)] px-1.5 text-[0.625rem] [&_svg:not([class*='size-'])]:size-3",
|
|
21
|
+
lg: "h-8 min-w-8 px-2",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
variant: "default",
|
|
26
|
+
size: "default",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
function Toggle({
|
|
32
|
+
className,
|
|
33
|
+
variant = "default",
|
|
34
|
+
size = "default",
|
|
35
|
+
...props
|
|
36
|
+
}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
|
|
37
|
+
return (
|
|
38
|
+
<TogglePrimitive
|
|
39
|
+
data-slot="toggle"
|
|
40
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
import {
|
|
8
|
+
PortalLayerContainerProvider,
|
|
9
|
+
type PortalLayerContainer,
|
|
10
|
+
usePortalLayerContainer,
|
|
11
|
+
} from "./portal-layer-context";
|
|
12
|
+
|
|
13
|
+
function TooltipProvider({
|
|
14
|
+
delay = 0,
|
|
15
|
+
...props
|
|
16
|
+
}: TooltipPrimitive.Provider.Props) {
|
|
17
|
+
return (
|
|
18
|
+
<TooltipPrimitive.Provider
|
|
19
|
+
data-slot="tooltip-provider"
|
|
20
|
+
delay={delay}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function Tooltip({
|
|
27
|
+
disableHoverablePopup = true,
|
|
28
|
+
...props
|
|
29
|
+
}: TooltipPrimitive.Root.Props) {
|
|
30
|
+
return (
|
|
31
|
+
<TooltipPrimitive.Root
|
|
32
|
+
data-slot="tooltip"
|
|
33
|
+
disableHoverablePopup={disableHoverablePopup}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function TooltipTrigger({
|
|
40
|
+
className,
|
|
41
|
+
...props
|
|
42
|
+
}: TooltipPrimitive.Trigger.Props) {
|
|
43
|
+
return (
|
|
44
|
+
<TooltipPrimitive.Trigger
|
|
45
|
+
className={className}
|
|
46
|
+
data-slot="tooltip-trigger"
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function TooltipContent({
|
|
53
|
+
className,
|
|
54
|
+
side = "top",
|
|
55
|
+
sideOffset = 4,
|
|
56
|
+
align = "center",
|
|
57
|
+
alignOffset = 0,
|
|
58
|
+
children,
|
|
59
|
+
interactive = false,
|
|
60
|
+
portalContainer,
|
|
61
|
+
...props
|
|
62
|
+
}: TooltipPrimitive.Popup.Props &
|
|
63
|
+
Pick<
|
|
64
|
+
TooltipPrimitive.Positioner.Props,
|
|
65
|
+
"align" | "alignOffset" | "side" | "sideOffset"
|
|
66
|
+
> & {
|
|
67
|
+
interactive?: boolean;
|
|
68
|
+
portalContainer?: PortalLayerContainer;
|
|
69
|
+
}) {
|
|
70
|
+
const resolvedContainer = usePortalLayerContainer(portalContainer);
|
|
71
|
+
const portalNodeRef = React.useRef<HTMLDivElement | null>(null);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<TooltipPrimitive.Portal container={resolvedContainer} ref={portalNodeRef}>
|
|
75
|
+
<PortalLayerContainerProvider container={portalNodeRef}>
|
|
76
|
+
<TooltipPrimitive.Positioner
|
|
77
|
+
align={align}
|
|
78
|
+
alignOffset={alignOffset}
|
|
79
|
+
side={side}
|
|
80
|
+
sideOffset={sideOffset}
|
|
81
|
+
className="isolate z-50"
|
|
82
|
+
>
|
|
83
|
+
<TooltipPrimitive.Popup
|
|
84
|
+
data-slot="tooltip-content"
|
|
85
|
+
className={cn(
|
|
86
|
+
"z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-lg border border-[color:color-mix(in_oklab,var(--border)_10%,transparent)] bg-[color:color-mix(in_oklab,var(--muted)_95%,transparent)] px-1.5 py-1 popup-text-xs-plus text-[color:var(--foreground)] shadow-md has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
87
|
+
interactive ? null : "pointer-events-none",
|
|
88
|
+
className,
|
|
89
|
+
)}
|
|
90
|
+
{...props}
|
|
91
|
+
>
|
|
92
|
+
{children}
|
|
93
|
+
</TooltipPrimitive.Popup>
|
|
94
|
+
</TooltipPrimitive.Positioner>
|
|
95
|
+
</PortalLayerContainerProvider>
|
|
96
|
+
</TooltipPrimitive.Portal>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
const MOBILE_BREAKPOINT = 768;
|
|
4
|
+
|
|
5
|
+
export function useIsMobile(): boolean {
|
|
6
|
+
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
|
|
7
|
+
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
const mediaQueryList = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
10
|
+
const onChange = () => {
|
|
11
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
mediaQueryList.addEventListener("change", onChange);
|
|
15
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
16
|
+
|
|
17
|
+
return () => mediaQueryList.removeEventListener("change", onChange);
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
return !!isMobile;
|
|
21
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
export * from "./components/control-layout";
|
|
4
|
+
export * from "./components/composites";
|
|
5
|
+
export * from "./components/controls";
|
|
6
|
+
export * from "./components/panel";
|
|
7
|
+
export * from "./components/primitives";
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
Actions,
|
|
11
|
+
AnchorGrid,
|
|
12
|
+
ChannelMixer,
|
|
13
|
+
Checkbox,
|
|
14
|
+
CodeTextarea,
|
|
15
|
+
Color,
|
|
16
|
+
ColorOpacity,
|
|
17
|
+
ColorValue,
|
|
18
|
+
Curves,
|
|
19
|
+
FileDrop,
|
|
20
|
+
Gradient,
|
|
21
|
+
ImagePicker,
|
|
22
|
+
Palette,
|
|
23
|
+
RangeInput,
|
|
24
|
+
RangeSlider,
|
|
25
|
+
Segmented,
|
|
26
|
+
Select,
|
|
27
|
+
Slider,
|
|
28
|
+
Switch,
|
|
29
|
+
TextInput,
|
|
30
|
+
Vector,
|
|
31
|
+
} from "./components/controls";
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export type SharedInputControlSize = "sm" | "default" | "lg" | "xl";
|
|
2
|
+
|
|
3
|
+
export const SHARED_INPUT_CONTROL_SURFACE_CLASS_NAME =
|
|
4
|
+
"border-[color:color-mix(in_oklab,var(--border)_12%,transparent)] bg-[color:color-mix(in_oklab,var(--input)_5%,transparent)] bg-clip-padding text-[color:var(--foreground)]";
|
|
5
|
+
|
|
6
|
+
export const SHARED_INPUT_CONTROL_BASE_CLASS_NAME = [
|
|
7
|
+
"w-full min-w-0 cursor-text rounded-lg border transition-colors outline-none",
|
|
8
|
+
"file:inline-flex file:border-0 file:bg-transparent file:font-medium file:text-[color:var(--foreground)]",
|
|
9
|
+
"placeholder:text-[color:var(--muted-foreground)]",
|
|
10
|
+
"[&:not(:focus):hover]:!border-[color:color-mix(in_oklab,var(--border)_20%,transparent)] [&:not(:focus):hover]:text-[color:var(--foreground)]",
|
|
11
|
+
"focus:border-[color:color-mix(in_oklab,var(--border)_30%,transparent)]",
|
|
12
|
+
"focus-visible:border-[color:color-mix(in_oklab,var(--border)_30%,transparent)]",
|
|
13
|
+
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
14
|
+
"aria-invalid:border-[color:var(--destructive)]",
|
|
15
|
+
"dark:aria-invalid:border-[color:color-mix(in_oklab,var(--destructive)_50%,transparent)]",
|
|
16
|
+
SHARED_INPUT_CONTROL_SURFACE_CLASS_NAME,
|
|
17
|
+
].join(" ");
|
|
18
|
+
|
|
19
|
+
export const SHARED_INPUT_CONTROL_SIZE_CLASS_NAMES = {
|
|
20
|
+
default: "h-7 px-2 py-0.5 text-xs/relaxed file:h-6 file:text-xs/relaxed",
|
|
21
|
+
lg: "h-8 px-2.5 py-1 text-sm/relaxed file:h-7 file:text-sm/relaxed",
|
|
22
|
+
sm: "h-6 px-2 py-0 text-xs/relaxed file:h-5 file:text-xs/relaxed",
|
|
23
|
+
xl: "h-10 px-3 py-1.5 text-base/relaxed file:h-9 file:text-base/relaxed",
|
|
24
|
+
} as const satisfies Record<SharedInputControlSize, string>;
|
|
25
|
+
|
|
26
|
+
type SharedInputControlCssSizeValue = {
|
|
27
|
+
fontSize: string;
|
|
28
|
+
height: string;
|
|
29
|
+
lineHeight: string;
|
|
30
|
+
padding: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const SHARED_INPUT_CONTROL_SIZE_CSS_VALUES = {
|
|
34
|
+
default: {
|
|
35
|
+
fontSize: "0.75rem",
|
|
36
|
+
height: "1.75rem",
|
|
37
|
+
lineHeight: "1.625",
|
|
38
|
+
padding: "0.125rem 0.5rem",
|
|
39
|
+
},
|
|
40
|
+
lg: {
|
|
41
|
+
fontSize: "0.875rem",
|
|
42
|
+
height: "2rem",
|
|
43
|
+
lineHeight: "1.625",
|
|
44
|
+
padding: "0.25rem 0.625rem",
|
|
45
|
+
},
|
|
46
|
+
sm: {
|
|
47
|
+
fontSize: "0.75rem",
|
|
48
|
+
height: "1.5rem",
|
|
49
|
+
lineHeight: "1.625",
|
|
50
|
+
padding: "0 0.5rem",
|
|
51
|
+
},
|
|
52
|
+
xl: {
|
|
53
|
+
fontSize: "1rem",
|
|
54
|
+
height: "2.5rem",
|
|
55
|
+
lineHeight: "1.625",
|
|
56
|
+
padding: "0.375rem 0.75rem",
|
|
57
|
+
},
|
|
58
|
+
} as const satisfies Record<
|
|
59
|
+
SharedInputControlSize,
|
|
60
|
+
SharedInputControlCssSizeValue
|
|
61
|
+
>;
|
|
62
|
+
|
|
63
|
+
export function buildSharedInputControlCss({
|
|
64
|
+
extraDeclarations = [],
|
|
65
|
+
selector,
|
|
66
|
+
size = "default",
|
|
67
|
+
}: {
|
|
68
|
+
extraDeclarations?: readonly string[];
|
|
69
|
+
selector: string;
|
|
70
|
+
size?: SharedInputControlSize;
|
|
71
|
+
}): string {
|
|
72
|
+
const sizeValues = SHARED_INPUT_CONTROL_SIZE_CSS_VALUES[size];
|
|
73
|
+
const extraDeclarationCss =
|
|
74
|
+
extraDeclarations.length > 0
|
|
75
|
+
? `${extraDeclarations.map((declaration) => ` ${declaration}`).join("\n")}\n`
|
|
76
|
+
: "";
|
|
77
|
+
|
|
78
|
+
return `
|
|
79
|
+
${selector} {
|
|
80
|
+
width: 100%;
|
|
81
|
+
min-width: 0;
|
|
82
|
+
height: ${sizeValues.height};
|
|
83
|
+
box-sizing: border-box;
|
|
84
|
+
border: 1px solid color-mix(in oklab, var(--border) 12%, transparent);
|
|
85
|
+
border-radius: var(--radius-lg, 0.5rem);
|
|
86
|
+
background: color-mix(in oklab, var(--input) 5%, transparent);
|
|
87
|
+
background-clip: padding-box;
|
|
88
|
+
color: var(--foreground);
|
|
89
|
+
padding: ${sizeValues.padding};
|
|
90
|
+
font-family: inherit;
|
|
91
|
+
font-size: ${sizeValues.fontSize};
|
|
92
|
+
line-height: ${sizeValues.lineHeight};
|
|
93
|
+
outline: none;
|
|
94
|
+
cursor: text;
|
|
95
|
+
transition-property:
|
|
96
|
+
color,
|
|
97
|
+
background-color,
|
|
98
|
+
border-color,
|
|
99
|
+
outline-color,
|
|
100
|
+
text-decoration-color,
|
|
101
|
+
fill,
|
|
102
|
+
stroke,
|
|
103
|
+
--tw-gradient-from,
|
|
104
|
+
--tw-gradient-via,
|
|
105
|
+
--tw-gradient-to;
|
|
106
|
+
transition-duration: 150ms;
|
|
107
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
108
|
+
${extraDeclarationCss}}
|
|
109
|
+
${selector}::placeholder {
|
|
110
|
+
color: var(--muted-foreground);
|
|
111
|
+
opacity: 1;
|
|
112
|
+
}
|
|
113
|
+
${selector}:not(:disabled):not(:focus):hover {
|
|
114
|
+
border-color: color-mix(in oklab, var(--border) 20%, transparent);
|
|
115
|
+
color: var(--foreground);
|
|
116
|
+
}
|
|
117
|
+
${selector}:not(:disabled):focus {
|
|
118
|
+
border-color: color-mix(in oklab, var(--border) 30%, transparent);
|
|
119
|
+
}
|
|
120
|
+
[data-focus-visible-mode="keyboard"] ${selector}:focus-visible {
|
|
121
|
+
border-color: color-mix(in oklab, var(--border) 30%, transparent);
|
|
122
|
+
}
|
|
123
|
+
${selector}:disabled {
|
|
124
|
+
pointer-events: none;
|
|
125
|
+
cursor: not-allowed;
|
|
126
|
+
opacity: 0.5;
|
|
127
|
+
}
|
|
128
|
+
${selector}[aria-invalid="true"] {
|
|
129
|
+
border-color: var(--destructive);
|
|
130
|
+
}`;
|
|
131
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export type HsvColor = {
|
|
2
|
+
h: number;
|
|
3
|
+
s: number;
|
|
4
|
+
v: number;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
function normalizeHue(value: number): number {
|
|
8
|
+
if (!Number.isFinite(value)) return 0;
|
|
9
|
+
return ((value % 360) + 360) % 360;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function clampNumber(value: number, min: number, max: number): number {
|
|
13
|
+
if (!Number.isFinite(value)) return min;
|
|
14
|
+
return Math.max(min, Math.min(max, value));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function normalizeHexColor(hex: string | null | undefined): string | null {
|
|
18
|
+
if (typeof hex !== "string") return null;
|
|
19
|
+
|
|
20
|
+
const raw = hex.trim();
|
|
21
|
+
if (!raw) return null;
|
|
22
|
+
|
|
23
|
+
const hashless = raw.startsWith("#") ? raw.slice(1) : raw;
|
|
24
|
+
if (![3, 6].includes(hashless.length)) return null;
|
|
25
|
+
if (!/^[\da-f]+$/i.test(hashless)) return null;
|
|
26
|
+
|
|
27
|
+
if (hashless.length === 3) {
|
|
28
|
+
const expanded = hashless
|
|
29
|
+
.split("")
|
|
30
|
+
.map((char) => `${char}${char}`)
|
|
31
|
+
.join("");
|
|
32
|
+
return `#${expanded.toLowerCase()}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return `#${hashless.toLowerCase()}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function hexToHsv(hex: string): HsvColor {
|
|
39
|
+
const normalized = normalizeHexColor(hex);
|
|
40
|
+
if (!normalized) {
|
|
41
|
+
throw new Error(`Invalid hex color: ${hex}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const value = normalized.slice(1);
|
|
45
|
+
const r = Number.parseInt(value.slice(0, 2), 16) / 255;
|
|
46
|
+
const g = Number.parseInt(value.slice(2, 4), 16) / 255;
|
|
47
|
+
const b = Number.parseInt(value.slice(4, 6), 16) / 255;
|
|
48
|
+
const max = Math.max(r, g, b);
|
|
49
|
+
const min = Math.min(r, g, b);
|
|
50
|
+
const delta = max - min;
|
|
51
|
+
|
|
52
|
+
let hue = 0;
|
|
53
|
+
if (delta !== 0) {
|
|
54
|
+
if (max === r) {
|
|
55
|
+
hue = ((g - b) / delta) % 6;
|
|
56
|
+
} else if (max === g) {
|
|
57
|
+
hue = (b - r) / delta + 2;
|
|
58
|
+
} else {
|
|
59
|
+
hue = (r - g) / delta + 4;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
hue = normalizeHue(hue * 60);
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
h: hue,
|
|
67
|
+
s: max === 0 ? 0 : delta / max,
|
|
68
|
+
v: max,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function hsvToHex(color: HsvColor): string {
|
|
73
|
+
const hue = normalizeHue(color.h);
|
|
74
|
+
const saturation = clampNumber(color.s, 0, 1);
|
|
75
|
+
const value = clampNumber(color.v, 0, 1);
|
|
76
|
+
const chroma = value * saturation;
|
|
77
|
+
const hueSegment = hue / 60;
|
|
78
|
+
const x = chroma * (1 - Math.abs((hueSegment % 2) - 1));
|
|
79
|
+
const match = value - chroma;
|
|
80
|
+
|
|
81
|
+
let red = 0;
|
|
82
|
+
let green = 0;
|
|
83
|
+
let blue = 0;
|
|
84
|
+
|
|
85
|
+
if (hueSegment >= 0 && hueSegment < 1) {
|
|
86
|
+
red = chroma;
|
|
87
|
+
green = x;
|
|
88
|
+
} else if (hueSegment >= 1 && hueSegment < 2) {
|
|
89
|
+
red = x;
|
|
90
|
+
green = chroma;
|
|
91
|
+
} else if (hueSegment >= 2 && hueSegment < 3) {
|
|
92
|
+
green = chroma;
|
|
93
|
+
blue = x;
|
|
94
|
+
} else if (hueSegment >= 3 && hueSegment < 4) {
|
|
95
|
+
green = x;
|
|
96
|
+
blue = chroma;
|
|
97
|
+
} else if (hueSegment >= 4 && hueSegment < 5) {
|
|
98
|
+
red = x;
|
|
99
|
+
blue = chroma;
|
|
100
|
+
} else {
|
|
101
|
+
red = chroma;
|
|
102
|
+
blue = x;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const toHex = (channel: number) =>
|
|
106
|
+
Math.round((channel + match) * 255)
|
|
107
|
+
.toString(16)
|
|
108
|
+
.padStart(2, "0");
|
|
109
|
+
|
|
110
|
+
return `#${toHex(red)}${toHex(green)}${toHex(blue)}`;
|
|
111
|
+
}
|