@aphexcms/ui 0.8.4 → 0.8.6

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/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # @aphexcms/ui
2
+
3
+ The shared [shadcn-svelte](https://shadcn-svelte.com) component library behind the [AphexCMS](https://github.com/IcelandicIcecream/aphex) admin.
4
+
5
+ This exists so `cms-core` and first-party plugins render the same controls, and so a plugin author can build a settings panel that looks like the rest of the admin without copying components in. It is a peer dependency of `@aphexcms/cms-core`, not an optional add-on.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @aphexcms/ui
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Each component has its own entry point — there is no root barrel, deliberately, so importing a button doesn't pull the whole library into your chunk:
16
+
17
+ ```svelte
18
+ <script lang="ts">
19
+ import { Button } from '@aphexcms/ui/shadcn/button';
20
+ import { Input } from '@aphexcms/ui/shadcn/input';
21
+ import * as Dialog from '@aphexcms/ui/shadcn/dialog';
22
+ </script>
23
+
24
+ <Button variant="outline">Save</Button>
25
+ ```
26
+
27
+ Styling is Tailwind CSS v4 with shared CSS variables. Import them once, in your root stylesheet:
28
+
29
+ ```css
30
+ @import '@aphexcms/ui/shadcn/css';
31
+ ```
32
+
33
+ ## What's in it
34
+
35
+ Roughly thirty-five components: the shadcn-svelte set (button, input, select, dialog, dropdown-menu, popover, sidebar, tabs, tooltip, calendar, command, …) plus a few Aphex additions used by the admin — `bubble`, `marker`, `message`, `message-scroller` and `attachment`, which back the in-admin agent's chat surface.
36
+
37
+ `@aphexcms/ui/utils` exports `cn()` and the `WithElementRef` helper type that the components share.
38
+
39
+ ## Adding a component
40
+
41
+ In the Aphex monorepo:
42
+
43
+ ```bash
44
+ pnpm shadcn <component-name>
45
+ ```
46
+
47
+ That runs `shadcn-svelte add` against this package and regenerates the export map. Don't hand-edit `exports` — `scripts/generate-exports.js` owns it, and the build regenerates it.
48
+
49
+ ## License
50
+
51
+ MIT
@@ -0,0 +1,5 @@
1
+ import Group from './input-otp-group.svelte';
2
+ import Separator from './input-otp-separator.svelte';
3
+ import Slot from './input-otp-slot.svelte';
4
+ import Root from './input-otp.svelte';
5
+ export { Root, Group, Slot, Separator, Root as InputOTP, Group as InputOTPGroup, Slot as InputOTPSlot, Separator as InputOTPSeparator };
@@ -0,0 +1,7 @@
1
+ import Group from './input-otp-group.svelte';
2
+ import Separator from './input-otp-separator.svelte';
3
+ import Slot from './input-otp-slot.svelte';
4
+ import Root from './input-otp.svelte';
5
+ export { Root, Group, Slot, Separator,
6
+ //
7
+ Root as InputOTP, Group as InputOTPGroup, Slot as InputOTPSlot, Separator as InputOTPSeparator };
@@ -0,0 +1,23 @@
1
+ <script lang="ts">
2
+ import { cn, type WithElementRef } from '../../../utils.js';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ children,
9
+ ...restProps
10
+ }: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
11
+ </script>
12
+
13
+ <div
14
+ bind:this={ref}
15
+ data-slot="input-otp-group"
16
+ class={cn(
17
+ 'has-aria-invalid:border-destructive has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40 flex items-center gap-2 rounded-lg has-aria-invalid:ring-[3px]',
18
+ className
19
+ )}
20
+ {...restProps}
21
+ >
22
+ {@render children?.()}
23
+ </div>
@@ -0,0 +1,5 @@
1
+ import { type WithElementRef } from '../../../utils.js';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ declare const InputOtpGroup: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>>, {}, "ref">;
4
+ type InputOtpGroup = ReturnType<typeof InputOtpGroup>;
5
+ export default InputOtpGroup;
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ import MinusIcon from '@lucide/svelte/icons/minus';
3
+ import { cn, type WithElementRef } from '../../../utils.js';
4
+ import type { HTMLAttributes } from 'svelte/elements';
5
+
6
+ let {
7
+ ref = $bindable(null),
8
+ class: className,
9
+ children,
10
+ ...restProps
11
+ }: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
12
+ </script>
13
+
14
+ <div
15
+ bind:this={ref}
16
+ data-slot="input-otp-separator"
17
+ role="separator"
18
+ class={cn("flex items-center [&_svg:not([class*='size-'])]:size-4", className)}
19
+ {...restProps}
20
+ >
21
+ {#if children}
22
+ {@render children?.()}
23
+ {:else}
24
+ <MinusIcon />
25
+ {/if}
26
+ </div>
@@ -0,0 +1,5 @@
1
+ import { type WithElementRef } from '../../../utils.js';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ declare const InputOtpSeparator: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>>, {}, "ref">;
4
+ type InputOtpSeparator = ReturnType<typeof InputOtpSeparator>;
5
+ export default InputOtpSeparator;
@@ -0,0 +1,47 @@
1
+ <script lang="ts">
2
+ import { PinInput as InputOTPPrimitive } from 'bits-ui';
3
+ import { cn } from '../../../utils.js';
4
+
5
+ // Deliberately diverges from upstream shadcn, which joins the slots into one
6
+ // segmented control (`border-y border-r`, rounded only at the ends). Each slot
7
+ // here is a standalone rounded box, so the group reads as "one character per
8
+ // box" at a glance. If this component is ever re-added via `pnpm shadcn`, the
9
+ // generated file will revert to the joined look.
10
+ //
11
+ // The size is `h-11 w-11`, not `size-11`: tailwind-merge only lets a later
12
+ // `size-*` override an earlier `w-*`/`h-*`, never the reverse, so a caller
13
+ // passing `h-12` would end up with both declarations and whichever the
14
+ // stylesheet happened to order last. Spelling the axes out keeps overrides
15
+ // per-axis and predictable.
16
+ let {
17
+ ref = $bindable(null),
18
+ cell,
19
+ class: className,
20
+ ...restProps
21
+ }: InputOTPPrimitive.CellProps = $props();
22
+ </script>
23
+
24
+ <InputOTPPrimitive.Cell
25
+ {cell}
26
+ bind:ref
27
+ data-slot="input-otp-slot"
28
+ class={cn(
29
+ // `h-11 w-11` rather than `size-11`: tailwind-merge only lets a later
30
+ // `size-*` override an earlier `w-*`/`h-*`, never the reverse, so a caller
31
+ // passing `h-12` would end up with both declarations and whichever the
32
+ // stylesheet happened to order last. Spelling the axes out keeps overrides
33
+ // per-axis and predictable.
34
+ 'border-input dark:bg-input/30 relative flex h-11 w-11 items-center justify-center rounded-lg border text-base font-medium transition-all outline-none',
35
+ 'data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:z-10 data-[active=true]:ring-[3px]',
36
+ 'aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40',
37
+ className
38
+ )}
39
+ {...restProps}
40
+ >
41
+ {cell.char}
42
+ {#if cell.hasFakeCaret}
43
+ <div class="pointer-events-none absolute inset-0 flex items-center justify-center">
44
+ <div class="animate-caret-blink bg-foreground h-5 w-px duration-1000"></div>
45
+ </div>
46
+ {/if}
47
+ </InputOTPPrimitive.Cell>
@@ -0,0 +1,4 @@
1
+ import { PinInput as InputOTPPrimitive } from 'bits-ui';
2
+ declare const InputOtpSlot: import("svelte").Component<InputOTPPrimitive.CellProps, {}, "ref">;
3
+ type InputOtpSlot = ReturnType<typeof InputOtpSlot>;
4
+ export default InputOtpSlot;
@@ -0,0 +1,23 @@
1
+ <script lang="ts">
2
+ import { PinInput as InputOTPPrimitive } from 'bits-ui';
3
+ import { cn } from '../../../utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ value = $bindable(''),
9
+ ...restProps
10
+ }: InputOTPPrimitive.RootProps = $props();
11
+ </script>
12
+
13
+ <InputOTPPrimitive.Root
14
+ bind:ref
15
+ bind:value
16
+ data-slot="input-otp"
17
+ spellcheck={false}
18
+ class={cn(
19
+ 'flex items-center gap-2 disabled:cursor-not-allowed has-disabled:opacity-50',
20
+ className
21
+ )}
22
+ {...restProps}
23
+ />
@@ -0,0 +1,4 @@
1
+ import { PinInput as InputOTPPrimitive } from 'bits-ui';
2
+ declare const InputOtp: import("svelte").Component<InputOTPPrimitive.RootProps, {}, "ref" | "value">;
3
+ type InputOtp = ReturnType<typeof InputOtp>;
4
+ export default InputOtp;
@@ -0,0 +1,7 @@
1
+ import { Tooltip as TooltipPrimitive } from 'bits-ui';
2
+ import Trigger from './tooltip-trigger.svelte';
3
+ import Content from './tooltip-content.svelte';
4
+ declare const Root: typeof TooltipPrimitive.Root;
5
+ declare const Provider: typeof TooltipPrimitive.Provider;
6
+ declare const Portal: typeof TooltipPrimitive.Portal;
7
+ export { Root, Trigger, Content, Provider, Portal, Root as Tooltip, Content as TooltipContent, Trigger as TooltipTrigger, Provider as TooltipProvider, Portal as TooltipPortal };
@@ -1,6 +1,13 @@
1
1
  import { Tooltip as TooltipPrimitive } from 'bits-ui';
2
2
  import Trigger from './tooltip-trigger.svelte';
3
3
  import Content from './tooltip-content.svelte';
4
+ // Explicitly annotated, unlike the sibling barrels (popover, dialog) that re-export their
5
+ // primitives bare. bits-ui implements these three as Svelte components, so their inferred
6
+ // type is the `$$IsomorphicComponent` declared inside `bits-ui/dist/.../tooltip.svelte` —
7
+ // a type with no importable name. `svelte-package` can't write that into a `.d.ts` and
8
+ // skips the file entirely, with a warning rather than a non-zero exit, so
9
+ // `./shadcn/tooltip` shipped a `types` path pointing at a file that wasn't in the tarball.
10
+ // Naming the type through the value import gives the emitter something it can write.
4
11
  const Root = TooltipPrimitive.Root;
5
12
  const Provider = TooltipPrimitive.Provider;
6
13
  const Portal = TooltipPrimitive.Portal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aphexcms/ui",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "Shared UI components for Aphex CMS (shadcn-svelte)",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -100,6 +100,11 @@
100
100
  "svelte": "./dist/components/ui/input/index.js",
101
101
  "default": "./dist/components/ui/input/index.js"
102
102
  },
103
+ "./shadcn/input-otp": {
104
+ "types": "./dist/components/ui/input-otp/index.d.ts",
105
+ "svelte": "./dist/components/ui/input-otp/index.js",
106
+ "default": "./dist/components/ui/input-otp/index.js"
107
+ },
103
108
  "./shadcn/label": {
104
109
  "types": "./dist/components/ui/label/index.d.ts",
105
110
  "svelte": "./dist/components/ui/label/index.js",
@@ -205,7 +210,7 @@
205
210
  "devDependencies": {
206
211
  "@internationalized/date": "^3.12.2",
207
212
  "@lucide/svelte": "^0.561.0",
208
- "@sveltejs/kit": "^2.59.1",
213
+ "@sveltejs/kit": "^2.70.2",
209
214
  "@sveltejs/package": "^2.5.6",
210
215
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
211
216
  "@tailwindcss/vite": "^4.3.0",
package/src/app.css CHANGED
@@ -191,6 +191,17 @@
191
191
  body {
192
192
  @apply bg-background text-foreground;
193
193
  }
194
+
195
+ /* Tailwind v4 dropped preflight's `button { cursor: pointer }` — buttons now
196
+ inherit the browser default arrow. Restored here once rather than adding
197
+ `cursor-pointer` at every call site: the admin has hundreds of buttons and
198
+ they had drifted badly (MediaBrowser 0/21 had it, ArrayField 4/17), so
199
+ whether a control looked clickable depended on which file it lived in.
200
+ Disabled controls keep the default cursor, which is the correct signal. */
201
+ button:not(:disabled),
202
+ [role='button']:not([aria-disabled='true']) {
203
+ cursor: pointer;
204
+ }
194
205
  }
195
206
 
196
207
  @layer components {
@@ -465,6 +476,26 @@
465
476
  }
466
477
  }
467
478
 
479
+ /* The blinking caret in `input-otp`'s slots. shadcn's component reaches for
480
+ `animate-caret-blink` but the animation itself isn't part of any preset — in
481
+ Tailwind v4 an undefined `animate-*` is simply dropped, so without this the
482
+ caret renders as a static bar and the field looks frozen. */
483
+ @theme inline {
484
+ --animate-caret-blink: caret-blink 1.25s ease-out infinite;
485
+
486
+ @keyframes caret-blink {
487
+ 0%,
488
+ 70%,
489
+ 100% {
490
+ opacity: 1;
491
+ }
492
+ 20%,
493
+ 50% {
494
+ opacity: 0;
495
+ }
496
+ }
497
+ }
498
+
468
499
  @utility shimmer {
469
500
  --_spread: var(--shimmer-spread, calc(3ch + 40px));
470
501
  --_base: currentColor;