@adea-ai/ui 0.153.0 → 0.154.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.
Files changed (40) hide show
  1. package/dist/NOTICE +10 -1
  2. package/dist/components/composites/model-selector/model-selector.d.ts +15 -1
  3. package/dist/components/composites/model-selector/model-selector.d.ts.map +1 -1
  4. package/dist/components/composites/model-selector/model-selector.js +263 -29
  5. package/dist/components/composites/model-selector/model-selector.js.map +1 -1
  6. package/dist/components/layout/side-rail/side-rail.d.ts.map +1 -1
  7. package/dist/components/layout/side-rail/side-rail.js +46 -42
  8. package/dist/components/layout/side-rail/side-rail.js.map +1 -1
  9. package/dist/components/layout/top-bar/top-bar.d.ts.map +1 -1
  10. package/dist/components/layout/top-bar/top-bar.js +13 -12
  11. package/dist/components/layout/top-bar/top-bar.js.map +1 -1
  12. package/dist/components/ui/dialog/dialog-layer.d.ts.map +1 -1
  13. package/dist/components/ui/dialog/dialog-layer.js +10 -10
  14. package/dist/components/ui/dialog/dialog-layer.js.map +1 -1
  15. package/dist/components/ui/kbd/kbd.d.ts +23 -10
  16. package/dist/components/ui/kbd/kbd.d.ts.map +1 -1
  17. package/dist/components/ui/kbd/kbd.js +42 -11
  18. package/dist/components/ui/kbd/kbd.js.map +1 -1
  19. package/dist/lib/overlay.d.ts +1 -1
  20. package/dist/lib/overlay.d.ts.map +1 -1
  21. package/dist/lib/overlay.js +1 -1
  22. package/dist/lib/overlay.js.map +1 -1
  23. package/dist/r/model-selector.json +1 -0
  24. package/dist/r/registry.json +3 -0
  25. package/dist/r/side-rail.json +1 -0
  26. package/dist/r/src/components/composites/model-selector/model-selector.tsx +186 -10
  27. package/dist/r/src/components/layout/side-rail/side-rail.tsx +16 -19
  28. package/dist/r/src/components/layout/top-bar/top-bar.tsx +3 -7
  29. package/dist/r/src/components/ui/dialog/dialog-layer.tsx +16 -18
  30. package/dist/r/src/components/ui/kbd/kbd.tsx +53 -12
  31. package/dist/r/src/lib/overlay.ts +1 -1
  32. package/dist/r/top-bar.json +1 -0
  33. package/package.json +1 -1
  34. package/registry.json +3 -0
  35. package/src/components/composites/model-selector/model-selector.tsx +186 -10
  36. package/src/components/layout/side-rail/side-rail.tsx +16 -19
  37. package/src/components/layout/top-bar/top-bar.tsx +3 -7
  38. package/src/components/ui/dialog/dialog-layer.tsx +16 -18
  39. package/src/components/ui/kbd/kbd.tsx +53 -12
  40. package/src/lib/overlay.ts +1 -1
@@ -6,21 +6,28 @@ import { cn } from '#lib/utils'
6
6
  /**
7
7
  * Kbd.
8
8
  *
9
- * A keyboard key, in the order the user presses them. The element is a real
10
- * `<kbd>` so the semantics survive copy-paste, and the mono face is what makes
11
- * a shortcut visually distinct from the sentence around it.
9
+ * A keyboard key, ported from shadcn/ui's `Kbd` (MIT, see NOTICE). The element
10
+ * is a real `<kbd>` so the semantics survive copy-paste.
11
+ *
12
+ * The cap is set in the UI face at `text-xs`, as shadcn draws it, not in the
13
+ * code face. Monospace faces carry letters but rarely the modifier glyphs, so
14
+ * a mono `⌘` fell back to another font and sat visibly smaller than the mono
15
+ * `K` beside it. The UI face draws `⌘ ⇧ ⌥ ⌃` and letters as one family, so
16
+ * every cap in a chord reads at the same size.
12
17
  *
13
18
  * `size="compact"` exists for the dense rows a default cap would outweigh, a
14
19
  * rail search row, a sidebar shortcut hint. It drops a height rung, and it
15
20
  * lightens the fill and weight with it because at that size a solid muted cap
16
- * reads heavier than the row text it sits in. The default rendering is every
17
- * cap that is not inside such a row, and it is untouched by the rung.
21
+ * reads heavier than the row text it sits in.
18
22
  *
19
23
  * `KbdGroup` exists because a shortcut is a sequence: typing `⌘` then `K`
20
24
  * needs a gap between them that is a layout concern, not punctuation.
21
25
  */
22
26
  export const kbdVariants = cva(
23
- 'bg-muted text-muted-foreground pointer-events-none inline-flex min-h-5 min-w-5 items-center justify-center gap-1 rounded-sm border border-border px-1 font-code text-code font-medium select-none',
27
+ [
28
+ 'bg-muted text-muted-foreground pointer-events-none inline-flex min-h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none',
29
+ "[&_svg:not([class*='size-'])]:size-3",
30
+ ],
24
31
  {
25
32
  variants: {
26
33
  size: {
@@ -57,6 +64,10 @@ export const kbdGroupVariants = cva('inline-flex items-center gap-1', {
57
64
  },
58
65
  })
59
66
 
67
+ /**
68
+ * shadcn renders the group as a `<kbd>`; it stays a `<span>` here so a
69
+ * `kbd` selector still finds exactly the caps, which hosts and tests count.
70
+ */
60
71
  export function KbdGroup(props: ComponentProps<'span'> & { size?: KbdSize }) {
61
72
  const [local, rest] = splitProps(props, ['size', 'class'])
62
73
 
@@ -69,17 +80,47 @@ export function KbdGroup(props: ComponentProps<'span'> & { size?: KbdSize }) {
69
80
  )
70
81
  }
71
82
 
83
+ /** Key names that are drawn as one word on one cap. */
84
+ const NAMED_KEY =
85
+ /^(?:Ctrl|Control|Alt|Option|Opt|Shift|Cmd|Command|Meta|Super|Win|Fn|Enter|Return|Escape|Esc|Tab|Space|Backspace|Delete|Del|Insert|Home|End|PageUp|PageDown|PgUp|PgDn|Up|Down|Left|Right|F(?:1\d|2[0-4]|[1-9]))/
86
+
72
87
  /**
73
- * Split a written chord into one entry per key cap. Every character is a key:
74
- * `⌘K` renders as `⌘` + `K`, and a longer chord like `⇧⌘P` stays three caps
75
- * wide, which matches how the system draws chords in menus.
88
+ * Split a written chord into one entry per key cap.
89
+ *
90
+ * - Glyph chords draw one cap per character: `⌘K` is `⌘` + `K`, and `⇧⌘P`
91
+ * stays three caps wide, which matches how the system draws chords in menus.
92
+ * - Spelled-out names stay whole: `CtrlK` is `Ctrl` + `K`, `⇧Enter` is
93
+ * `⇧` + `Enter`.
94
+ * - `+` and spaces separate keys and are not drawn (`Ctrl+K`, `Ctrl Shift P`),
95
+ * except a `+` that is itself the key (`Ctrl++`, `⌘+`).
76
96
  */
77
97
  export function kbdChordKeys(keys: string): string[] {
78
- return [...keys]
98
+ const caps: string[] = []
99
+ let rest = keys
100
+ let separated = true
101
+ while (rest.length > 0) {
102
+ const first = rest[0]!
103
+ if (first === ' ' || (first === '+' && !separated && rest.length > 1)) {
104
+ rest = rest.slice(1)
105
+ separated = true
106
+ continue
107
+ }
108
+ const named = NAMED_KEY.exec(rest)?.[0]
109
+ // A name only counts when a lowercase letter does not continue it: `Tab`
110
+ // in `Table` is not a key, so a caller's literal text is drawn as written.
111
+ const cap =
112
+ named && !/^[a-z]/.test(rest.charAt(named.length))
113
+ ? named
114
+ : String.fromCodePoint(rest.codePointAt(0)!)
115
+ caps.push(cap)
116
+ rest = rest.slice(cap.length)
117
+ separated = false
118
+ }
119
+ return caps
79
120
  }
80
121
 
81
122
  export type KbdChordProps = Omit<ComponentProps<'span'>, 'children'> & {
82
- /** The chord as it is drawn, e.g. `"⌘K"` or `"⇧⌘P"`. One cap per character. */
123
+ /** The chord as it is drawn, e.g. `"⌘K"`, `"⇧⌘P"` or `"Ctrl+K"`. See `kbdChordKeys`. */
83
124
  keys: string
84
125
  size?: KbdSize
85
126
  }
@@ -87,7 +128,7 @@ export type KbdChordProps = Omit<ComponentProps<'span'>, 'children'> & {
87
128
  /**
88
129
  * KbdChord.
89
130
  *
90
- * A written chord drawn as caps, one per character. Decoration only: the
131
+ * A written chord drawn as caps, one per key (see `kbdChordKeys`). Decoration only: the
91
132
  * composition renders `aria-hidden`, so the accessible name and the parseable
92
133
  * `aria-keyshortcuts` stay on the control the chord belongs to. That is why
93
134
  * there is no children, the chord says what was drawn, nothing more.
@@ -130,7 +130,7 @@ export const menuLabel =
130
130
  'px-2 py-1.5 text-2xs font-medium tracking-wide text-muted-foreground uppercase'
131
131
 
132
132
  /** The chord drawn at a row's trailing edge: menus and the command palette. */
133
- export const menuShortcut = 'text-muted-foreground ms-auto font-code text-code tracking-widest'
133
+ export const menuShortcut = 'text-muted-foreground ms-auto text-xs tracking-widest'
134
134
 
135
135
  /** The rule between menu groups. */
136
136
  export const menuSeparator = 'bg-border -mx-1 my-1 h-px'