@esuiss/ui 0.7.0 → 0.8.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/README.md CHANGED
@@ -64,9 +64,10 @@ npx @esuiss/ui@latest init [options]
64
64
  ```bash
65
65
  npx @esuiss/ui@latest add <component...> [options]
66
66
  npx @esuiss/ui@latest add patterns <pattern...> [options]
67
+ npx @esuiss/ui@latest add interactions <interaction...> [options]
67
68
  ```
68
69
 
69
- Components are written to `components/ui/`, patterns to `components/patterns/` and hooks to `hooks/` under your `@/*` alias root. Components they depend on are added too, and missing npm packages are installed with your package manager (npm, pnpm, yarn, or bun).
70
+ Components are written to `components/ui/`, patterns to `components/patterns/`, interactions to `components/interactions/` and hooks to `hooks/` under your `@/*` alias root. Components they depend on are added too, and missing npm packages are installed with your package manager (npm, pnpm, yarn, or bun).
70
71
 
71
72
  ### Options
72
73
 
@@ -74,7 +75,7 @@ Components are written to `components/ui/`, patterns to `components/patterns/` a
74
75
  | --- | --- |
75
76
  | `-o, --overwrite` | Replace local files that differ from the registry |
76
77
  | `--diff` | Show how your local files differ from the registry |
77
- | `-a, --all` | Add every component, or every pattern with `add patterns` |
78
+ | `-a, --all` | Add every component, or every pattern or interaction with `add patterns` / `add interactions` |
78
79
  | `-y, --yes` | Skip confirmation prompts |
79
80
  | `-c, --cwd <dir>` | Run in another project directory |
80
81
  | `-h, --help` | Show help |
@@ -159,9 +160,9 @@ export default function RootLayout({ children }: { children: React.ReactNode })
159
160
 
160
161
  ## Components
161
162
 
162
- accordion, alert, alert-dialog, aspect-ratio, attachment, avatar, badge, breadcrumb, bubble, button, button-group, calendar, card, carousel, chart, checkbox, collapsible, combobox, command, context-menu, dialog, direction, drawer, dropdown-menu, empty, field, hover-card, input, input-group, input-otp, item, kbd, label, marker, menubar, message, message-scroller, native-select, navigation-menu, pagination, popover, progress, questionnaire, radio-group, resizable, scroll-area, select, separator, sheet, sidebar, skeleton, slider, spinner, switch, table, tabs, textarea, toast, toggle, toggle-group, tooltip, wheel-picker
163
+ accordion, alert, alert-dialog, alert-sheet, aspect-ratio, attachment, avatar, badge, breadcrumb, bubble, button, button-group, calendar, card, carousel, chart, checkbox, collapsible, combobox, command, context-menu, dialog, direction, drawer, dropdown-menu, empty, field, fullscreen-menu, hover-card, input, input-group, input-otp, item, kbd, label, marker, menubar, message, message-scroller, native-select, navigation-menu, pagination, popover, progress, questionnaire, radio-group, resizable, scroll-area, select, separator, sheet, sidebar, skeleton, slider, spinner, switch, tab-bar, table, tabs, textarea, toast, toggle, toggle-group, tooltip, wheel-picker
163
164
 
164
- Hooks: use-message-scroller, use-mobile, use-questionnaire
165
+ Hooks: use-message-scroller, use-mobile, use-platform, use-questionnaire
165
166
 
166
167
  ## Patterns
167
168
 
@@ -174,6 +175,17 @@ npx @esuiss/ui add patterns --all
174
175
 
175
176
  The components a pattern uses are added with it.
176
177
 
178
+ ## Interactions
179
+
180
+ Interactions add a behavior to something you already have, such as swiping a row to reveal actions. They are optional extras, so they are not added by `init` or `add --all`; add them by name, or all at once:
181
+
182
+ ```bash
183
+ npx @esuiss/ui add interactions swipe-actions
184
+ npx @esuiss/ui add interactions --all
185
+ ```
186
+
187
+ The components an interaction uses are added with it.
188
+
177
189
  ## Troubleshooting
178
190
 
179
191
  - **"Tailwind CSS 4.2 or later is required"**: upgrade with `npm install tailwindcss@latest` and run `init` again.
package/index.mjs CHANGED
@@ -15,12 +15,14 @@ const usage = `${name} ${version}
15
15
  Usage:
16
16
  npx ${name} init [options] set up Tailwind, the theme, and the button
17
17
  npx ${name} add <component...> [options] add components, e.g. add button sidebar
18
- npx ${name} add patterns <pattern...> add patterns, e.g. add patterns date-time-picker
18
+ npx ${name} add patterns <pattern...> add patterns, e.g. add patterns date-picker
19
+ npx ${name} add interactions <name...> add interactions, e.g. add interactions swipe-actions
19
20
 
20
21
  Options:
21
22
  -o, --overwrite replace local files that differ from the registry
22
23
  --diff show how local files differ from the registry
23
- -a, --all add every component, or every pattern after "patterns"
24
+ -a, --all add every component, or every pattern or interaction
25
+ after "patterns" or "interactions"
24
26
  -y, --yes skip confirmation prompts
25
27
  -c, --cwd <dir> project directory (defaults to the current directory)
26
28
  -h, --help show this help
@@ -28,6 +30,11 @@ Options:
28
30
 
29
31
  Supports Next.js and React (Vite) projects with TypeScript and Tailwind CSS v4.`
30
32
 
33
+ const SUBCOMMANDS = {
34
+ patterns: "pattern",
35
+ interactions: "interaction",
36
+ }
37
+
31
38
  function parseArgs(args) {
32
39
  const options = {
33
40
  cwd: process.cwd(),
@@ -80,9 +87,11 @@ async function main() {
80
87
  await init(parseArgs(args).options)
81
88
  break
82
89
  case "add": {
83
- const patterns = args[0] === "patterns"
84
- const { options, names } = parseArgs(patterns ? args.slice(1) : args)
85
- await add(names, { ...options, patterns })
90
+ const scope = SUBCOMMANDS[args[0]] ?? "ui"
91
+ const { options, names } = parseArgs(
92
+ scope === "ui" ? args : args.slice(1)
93
+ )
94
+ await add(names, { ...options, scope })
86
95
  break
87
96
  }
88
97
  case "-v":
package/lib/add.mjs CHANGED
@@ -7,8 +7,9 @@ import { detectProject, findAliasRoot, install } from "./project.mjs"
7
7
  import {
8
8
  fetchRegistry,
9
9
  fetchText,
10
- isPattern,
11
10
  resolveItems,
11
+ SCOPES,
12
+ scopeOf,
12
13
  } from "./registry.mjs"
13
14
 
14
15
  async function fetchFiles(items) {
@@ -98,11 +99,10 @@ async function showDiff(project, root, registry, names) {
98
99
  if (!changes) step("No differences from the registry.")
99
100
  }
100
101
 
101
- function selectNames(registry, names, { all, patterns }) {
102
- const inScope = (item) => isPattern(item) === patterns
102
+ function selectNames(registry, names, { all, scope = "ui" }) {
103
+ const inScope = (item) => scopeOf(item) === scope
103
104
  const scoped = registry.items.filter(inScope)
104
- const kind = patterns ? "pattern" : "component"
105
- const command = patterns ? "add patterns" : "add"
105
+ const { kind, command, example } = SCOPES[scope]
106
106
 
107
107
  if (all) {
108
108
  if (!scoped.length) throw new CliError(`No ${kind}s are available yet.`)
@@ -111,7 +111,7 @@ function selectNames(registry, names, { all, patterns }) {
111
111
 
112
112
  if (!names.length) {
113
113
  throw new CliError(
114
- `Name at least one ${kind}, e.g. npx @esuiss/ui ${command} ${patterns ? "<name>" : "button"}`
114
+ `Name at least one ${kind}, e.g. npx @esuiss/ui ${command} ${example}`
115
115
  )
116
116
  }
117
117
 
@@ -120,9 +120,9 @@ function selectNames(registry, names, { all, patterns }) {
120
120
  const item = byName.get(name)
121
121
  if (item && inScope(item)) continue
122
122
  if (item) {
123
- const other = patterns ? "add" : "add patterns"
123
+ const other = SCOPES[scopeOf(item)]
124
124
  throw new CliError(
125
- `"${name}" is ${patterns ? "a component" : "a pattern"}. Run npx @esuiss/ui ${other} ${name}`
125
+ `"${name}" is ${other.kind === "interaction" ? "an" : "a"} ${other.kind}. Run npx @esuiss/ui ${other.command} ${name}`
126
126
  )
127
127
  }
128
128
  throw new CliError(
package/lib/registry.mjs CHANGED
@@ -20,8 +20,18 @@ export async function fetchRegistry() {
20
20
  return JSON.parse(await fetchText("registry.json"))
21
21
  }
22
22
 
23
- export function isPattern(item) {
24
- return item.type === "pattern"
23
+ export const SCOPES = {
24
+ ui: { kind: "component", command: "add", example: "button" },
25
+ pattern: { kind: "pattern", command: "add patterns", example: "<name>" },
26
+ interaction: {
27
+ kind: "interaction",
28
+ command: "add interactions",
29
+ example: "<name>",
30
+ },
31
+ }
32
+
33
+ export function scopeOf(item) {
34
+ return item.type in SCOPES ? item.type : "ui"
25
35
  }
26
36
 
27
37
  export function resolveItems(registry, names) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esuiss/ui",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Copy-paste React components with a clean, minimal design, built on Base UI and Tailwind CSS v4. CLI for Next.js and React (Vite).",
5
5
  "keywords": [
6
6
  "react",