diff --git a/.agents/skills/fyrst-ui-0.5-migration/SKILL.md b/.agents/skills/fyrst-ui-0.5-migration/SKILL.md new file mode 100644 index 0000000..e332aaa --- /dev/null +++ b/.agents/skills/fyrst-ui-0.5-migration/SKILL.md @@ -0,0 +1,337 @@ +--- +name: fyrst-ui-0.5-migration +description: >- + Migrate a consumer project from @fyrst/ui 0.3.x / 0.4.x to 0.5.x. Use when the + app bumps @fyrst/ui to 0.5, or still uses any of: classRoot / classIcon / + classContent / classClose (AlertRoot, CardRoot), :classes on AccordionRoot, + classWrapper / classCarousel (CarouselRoot), classTrigger (FlyoutRoot), + CardRoot borderColor, useFormData(...).jsonData / .formData, useCarousel(props, el, slots), inject('handleNext') or other + carousel string keys, Flyout #trigger / #dropdown slots, the flyout-enter / + flyout-leave transition classes, or SwitchCssMap / ProgressCssMap / + SwitchStyles / ProgressStyles / ListStyles / PricingCardStyles types. +--- + +# Migrate a @fyrst/ui consumer from 0.4.x to 0.5.x + +You are migrating a **consuming** project (app, storefront, or library) that renders `@fyrst/ui` Vue components, directly or through `@fyrst/ui/nuxt`. + +0.5.0 is a breaking **minor** (0.x semver). The Panda contract from 0.3.x stays: `designSystem: '@fyrst/ui'`, Panda `^2.4`. If the app is on 0.2.x or Panda 1, run [`../panda-v2-migration/SKILL.md`](../panda-v2-migration/SKILL.md) first, then this skill. + +Work through the sections in order. Each one says how to find affected code, what to change, and how to check it. Skip a section only after its search comes back empty. + +## Sources + +- Repo `CHANGELOG.md`, section `[0.5.0]`, and `changelog/2026-10-31-0.5.0-overrides-and-cleanup.md`. +- Root `README.md`: "Styling components". +- Panda: [Consume with Panda](https://panda-css.com/docs/design-systems/consume-with-panda), [`cva` / `sva`](https://panda-css.com/docs/concepts/recipes). + +Do not invent `@fyrst/ui` props. If this skill and the installed package's `.d.ts` disagree, the `.d.ts` wins. Read them under `node_modules/@fyrst/ui/dist/`. + +## Hard rules + +- Keep `designSystem: '@fyrst/ui'` in every `panda.config.*`. Do not add a fyrst preset to `presets`, do not `include` the package, and do not add `@pandacss/preset-base`. +- Every value in a component `css` prop goes through `css.raw()` from the app's own `styled-system/css`. A bare object compiles and type-checks but produces **no CSS**. +- Do not re-declare `@fyrst/ui` component styles (`cva`, `sva`, copied style objects) in the app. Use the `css` prop (section 3). +- Public-repo hygiene: no customer names, client domains, or screenshots of customer UIs in commits or PRs. + +## What changed (summary) + +| Area | 0.4.x | 0.5.x | +| --- | --- | --- | +| Style overrides | `classRoot`, `classIcon`, `classContent`, `classClose`, `classes`, `classWrapper`, `classCarousel`, `classTrigger`, plus `css` on some components | One `css` prop on every component, keyed by slot (`root` = outermost element) | +| Component CSS | Atomic classes from `cva` / `sva` | Still atomic `cva` / `sva`. Some color classes change where a semantic token replaced a `_light` override (section 4) | +| Override precedence | `css` merged into the style object; `class*` props appended as extra classes and could lose | Every `css` slot is merged into the style object: one class per property, the override wins | +| `CardRoot` `borderColor` | Deprecated no-op | Removed | +| `useFormData` | `{ formData, jsonData }` readonly refs, cached at first read | `{ getFormData(), getJson() }`, read on each call; accepts element, ref, or getter | +| `useCarousel` | `(props, carouselRef, slots)` | `(options, carouselRef)`; `carouselItems` is `HTMLElement[]` | +| Carousel children | `inject('handleNext')` and other string keys | `inject(CarouselContextKey)` | +| Carousel wheel | Always hijacked vertical wheel | Off. `wheel-navigation` turns it on | +| Flyout | Hover div plus `v-if` panel, `flyout-*` Transition | Reka Popover: Escape, outside click, focus handling. `#trigger` must render one element | +| Removed types | `SwitchCssMap`, `ProgressCssMap`, `SwitchStyles`, `ProgressStyles`, `ListStyles`, `PricingCardStyles` | `CssMap` and per-component `*Css` types | +| Component `name` | `FyButton`, `FyLoader` | `FyrstButton`, `FyrstLoader` | +| `@fyrst/ui/vue/*` `require` | Resolved the ESM `.js` | Resolves the `.cjs` build | +| Peers | `vue ^3.5.44`, `reka-ui ^2.11`, `nuxt ^4.6.3` | Unchanged | + +Additive, no action needed: semantic colors `surface`, `surface.raised`, `border`, `border.hover`, `border.subtle`, `text.muted`; base `brand.50`, `brand.200`; `CssMap` and `*Css` type exports; `CarouselContextKey`; `FieldSharedProps`; `FlyoutRoot` `direction` and `openOnHover`; `CarouselNavigation` `prevLabel` / `nextLabel`; plain Node can now import the package. + +# Step-by-step + +## 0. Preconditions + +1. Clean git tree. Note the current `@fyrst/ui` version. +2. Run the app's build and test once and keep the output as the "before" baseline. +3. If the app has visual regression tests, record a baseline now. + +## 1. Upgrade + +```bash +bun add @fyrst/ui@^0.5.0 # or npm / pnpm / yarn equivalent +panda codegen --clean +``` + +Peer ranges are unchanged from 0.4.x (`vue ^3.5.44`, `reka-ui ^2.11.0`, `nuxt ^4.6.3`, `@pandacss/dev ^2.4.0`). + +## 2. Content props: no change + +Content props still render as HTML (`v-html`), as in 0.4.x: `Button` `label`, `CardHeader` `title` / `subtitle`, `HeroLead` `headline` / `description`, list items and `PricingCard` features, accordion items, tab labels, `FlyoutRoot` `label`, and field `message` / `error`. There is no `html` prop. Nothing to migrate. + +Sanitizing those strings is the app's job (README "Text and HTML content"). If the upgrade is a chance to check, look for props fed from user input, server responses (validation messages), CMS content, or external translations, and sanitize them, or pass them through the component's slot where one exists (see the README). Do not change these call sites as part of the 0.5 migration unless the app asks for it. + +The one visible change: `Button`'s `title` attribute is now the label without tags (it showed raw markup before). + +## 3. Style overrides: one `css` prop, values through `css.raw()` + +**Find.** + +```bash +rg -n -e 'class-(root|icon|content|close|wrapper|carousel|trigger)\b' \ + -e '\bclass(Root|Icon|Content|Close|Wrapper|Carousel|Trigger)\b' \ + -e ':classes=' -g '*.vue' -g '*.ts' -g '*.tsx' +rg -n ':css="' -g '*.vue' +rg -n '\bcss:\s*\{' -g '*.ts' -g '*.vue' +``` + +**Rename.** + +| Component | 0.4.x | 0.5.x | +| --- | --- | --- | +| `AlertRoot` | `classRoot`, `classIcon`, `classContent`, `classClose` | `css.root`, `css.icon`, `css.content`, `css.close` (also `message`, `title`, `description`) | +| `CardRoot` | `classRoot` | `css.root` | +| `AccordionRoot` | `classes.icon` (a **class string**, applied to the item icon) | `css.icon` (a style object). The caret is `css.indicator`. Other slots: `root`, `item`, `trigger`, `title`, `content` | +| `CarouselRoot` | `classWrapper`, `classCarousel` | `css.root`, `css.viewport` | +| `FlyoutRoot` | `classTrigger` | `css.trigger` (also `root`, `content`) | + +```vue + + + + + + + + + +``` + +`AccordionRoot` `classes.icon` took a class name. If the app passed a non-Panda class (global CSS), move that rule to the `#icon` slot instead: + +```vue + + + +``` + +**Wrap every existing `css` value in `css.raw()`.** 0.4.x already had `css` on `PricingCard*`, `ListRoot`, `ListItem`, `ProgressRoot`, `SwitchRoot`, `FieldUrl`, and `FieldSwitch`. A bare object there never generated CSS (unless the same atomic class happened to exist). This is the likeliest silent styling bug in the app: + +```vue + + + + +``` + +`css` comes from the app's own codegen: `import { css } from 'styled-system/css'` (or the app's `importMap` path), not from `@fyrst/ui`. + +**Types.** Use the exported per-component types (`AlertCss`, `CarouselRootCss`, `FlyoutRootCss`, …) or `CssMap<'root' | …>` from `@fyrst/ui`. + +**Check.** `rg` from "Find" returns nothing for the old names. Overridden elements look as intended in light and dark. + +## 4. Component class names (mostly unchanged) + +Component styles are still atomic Panda classes (`d_inline_flex`, `bg-c_primary`, …). Two kinds of class names change: + +- Colors that now use a semantic token: fields, select menus, checkboxes, radios, the dialog, and the prompt form use `surface`, `border`, `border.hover`, `border.subtle`, and `text.muted` (for example `bg-c_surface` instead of `bg-c_grey.black` plus `light:bg-c_white`). The rendered colors are the same, apart from the notes in section 9. +- Styles that were inline `css()` calls in controls, the carousel, and the flyout are now `cva` / `sva` definitions. Values are unchanged, but class order and a few class names differ (for example a disabled checkbox uses a `_disabled` condition instead of a runtime `opacity` class). + +**Find code that depends on exact class names.** + +```bash +rg -n -e '\b(bg|bg-c|bd-c|c|d|op|cursor)_[A-Za-z0-9.%\\-]+' \ + -g '*.spec.*' -g '*.test.*' -g '*.css' -g '*.scss' -g '__snapshots__/**' -g '*.snap' +``` + +- Snapshots or selectors that match `@fyrst/ui` classes: review the diff, then update. Prefer selecting by role, label, or `data-*` over atomic classes. +- Global CSS that targeted library classes: replace it with a `css` override (section 3). + +**Precedence.** `AlertRoot` `classRoot` and the other `class*` props were appended as separate classes, so overriding a property the component also set could lose, depending on stylesheet order. The `css` prop is merged into the component's style object first, so the override always replaces that property. Re-check places that worked around the old behavior with `!important`. + +## 5. Composables + +### `useFormData` + +```bash +rg -n 'useFormData' -g '*.vue' -g '*.ts' +``` + +```ts +// before +const { jsonData, formData } = useFormData(formEl) +send(jsonData.value) +// after +const { getJson, getFormData } = useFormData(formEl) // element, ref, or getter +send(getJson()) +``` + +0.4.x cached the first read and returned `null` when called in `setup` before mount. Calls that worked around this (calling it inside the submit handler) still work after the rename. Calls in `setup` with a template ref now work as written. + +### `useCarousel` + +```bash +rg -n 'useCarousel' -g '*.vue' -g '*.ts' +``` + +```ts +// before +const carousel = useCarousel(props, carouselEl, useSlots()) +carousel.carouselItems.value?.length // NodeListOf | null +// after +const carousel = useCarousel({ scrollMode: () => props.scrollMode }, carouselEl) +carousel.carouselItems.value.length // HTMLElement[] +``` + +Return names are unchanged. `handleWheel` now follows the dominant axis, calls `preventDefault()` itself, and moves at most one step per gesture. It no longer logs `console.warn` at the ends. + +### `useFlyout` + +`useFlyout({ el })` still returns `{ open, toggle }` and still opens on hover. It now listens to `pointerenter` / `pointerleave` and ignores touch and pen. New: `openOnHover`, `closeDelay`, `setOpen`, `pin`, `openedBy`, `onPointerEnter`, `onPointerLeave`. No change needed unless the app relied on `mouseenter` firing for touch. + +## 6. Carousel + +```bash +rg -n -e "inject\((['\"])(carousel|handleNext|handlePrev|carouselItems|carouselItem|visibleCarouselItems|currentCarouselItemIndex|scrollDirection|allItemsVisible)\1" \ + -e 'CarouselRoot|Carousel\.Root' -g '*.vue' -g '*.ts' +``` + +**Custom children** that injected string keys: + +```ts +// before +const handleNext = inject<() => void>('handleNext') +const index = inject>('currentCarouselItemIndex') +// after +import { CarouselContextKey } from '@fyrst/ui' +const carousel = inject(CarouselContextKey) +carousel?.handleNext() +carousel?.currentCarouselItemIndex.value +``` + +The context has every `useCarousel` return plus `carousel` (the scroller ref). + +**Wheel.** The carousel no longer scrolls on the mouse wheel, and the page scrolls normally over it. Keep the old behavior only where product asks for it: + +```vue +… +``` + +**Navigation buttons** now have `type="button"`, so they no longer submit an enclosing form. Labels: `prev-label` / `next-label`. + +## 7. Flyout + +```bash +rg -n -e 'FlyoutRoot|FlyoutDropdown|Flyout\.(Root|Dropdown)' -e 'flyout-(enter|leave)' -g '*.vue' -g '*.ts' -g '*.css' -g '*.scss' +``` + +The flyout is a Reka Popover now. Behavior: mouse hover opens and leaving closes after 150 ms; click toggles; click while hover-open pins it open; Escape and an outside click close it. The trigger gets `aria-expanded`, `aria-controls`, and `aria-haspopup="dialog"` (was `"true"`). + +- **`#trigger` slot:** render exactly **one** element (component or tag). It becomes the Popover trigger, so it toggles on click without extra code. Slot props are `{ open, toggle }`. Remove any `@click="toggle"` you added on it, or it toggles twice. + + ```vue + + + … + + ``` + +- **`#dropdown` slot:** keep the panel inside `` and drop `v-if="open"` and the wrapping ``; the dropdown handles presence and animation. `FlyoutDropdown` only works inside `FlyoutRoot`. + + ```vue + + + + + ``` + +- **Transition CSS:** delete app CSS for `.flyout-enter-*` / `.flyout-leave-*`. Restyle the animation with `css.content`. +- **Positioning:** the panel is positioned by Reka (floating-ui) and stays in the flyout's DOM, below the trigger, aligned `start` (`direction="left"`, default) or `end` (`"right"`). The positioning wrapper gets inline styles on the client while open. SSR HTML has none. +- Hover-only menus that should only open on click: `:open-on-hover="false"`. + +## 8. Removed props, types, and names + +```bash +rg -n -e 'SwitchCssMap|ProgressCssMap|SwitchStyles|ProgressStyles|ListStyles|PricingCardStyles' \ + -e 'FyButton|FyLoader' -g '*.vue' -g '*.ts' +rg -n -B2 -A2 'border-color=|borderColor' -g '*.vue' | rg -i 'card' +``` + +| Removed | Use | +| --- | --- | +| `CardRoot` `borderColor` (no-op since 0.3.0) | delete it; use `color` or `css.root` | +| `SwitchCssMap`, `ProgressCssMap` | `CssMap` | +| `SwitchStyles`, `ProgressStyles`, `ListStyles`, `PricingCardStyles` | none. Style objects are no longer exposed. Use `css` | +| Component name `FyButton` / `FyLoader` (KeepAlive `include`, devtools filters, `findComponent({ name })`) | `FyrstButton` / `FyrstLoader` | + +## 9. Behavior and visual notes (check, usually no code change) + +- `Button` with `to` and `disabled` renders `` **without `href`**. It no longer navigates. Tests that expected an `href` on a disabled link need updating. +- `ListItem` `size` / `state` / `icon` now win over `ListRoot` (0.4.x ignored them inside a root). +- `FieldError` dropped `aria-live` (it keeps `role="alert"`). `FieldRequired` is `aria-hidden`; `required` on the control already announces it. +- `Loader` dropped `aria-live` (it keeps `role="status"`). +- Field helper text (`message`) in light mode is `grey.600` (was `grey.500`). Checkbox and radio hover borders in light mode are `grey.300` (was `grey.400`). +- Radio options dim individually when `disabled` is set on the option. +- `@fyrst/ui/style.css` is icons only (the flyout transition CSS moved into its `sva` styles). +- CommonJS `require('@fyrst/ui/vue/')` now loads the `.cjs` build. + +# Verification (required) + +```bash +# no old APIs left +rg -n -e 'class-(root|icon|content|close|wrapper|carousel|trigger)\b' -e '\bclass(Root|Icon|Content|Close|Wrapper|Carousel|Trigger)\b' -e ':classes=' -g '*.vue' -g '*.ts' +rg -n -e "inject\((['\"])(handleNext|handlePrev|carouselItems|currentCarouselItemIndex|allItemsVisible)\1" -e '\.jsonData\b|\.formData\.value' -e 'SwitchCssMap|ProgressCssMap|SwitchStyles|ProgressStyles|ListStyles|PricingCardStyles' -g '*.vue' -g '*.ts' + +panda codegen --clean +panda cssgen --outfile /tmp/fyrst-check.css +rg -c 'd_inline_flex' /tmp/fyrst-check.css # > 0: component styles reach the app + + && && && +``` + +Then check by hand, in light and dark: + +1. Content with markup still renders as before. +2. Every element with a `css` override: the override applies. If it does not, the value is missing `css.raw()`. +3. Flyouts: hover, click, click-while-hovered (stays open), Escape, outside click, keyboard (Tab to trigger, Enter, Escape returns focus). +4. Carousels: page scroll over the carousel works; buttons move; `wheel-navigation` only where intended. +5. Forms: inputs with an error get `aria-invalid="true"`, and the error and helper text are linked through `aria-describedby`. +6. CSP / SSR: server HTML from `@fyrst/ui` components has no `style=""` attributes. + +# Common errors and fixes + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Override has no effect | Bare object in `css`, or old `class*` prop name | `css.raw()`, new slot key (section 3) | +| TS error: `Property 'classRoot' does not exist` / `'classes'` / `'classWrapper'` / `'classTrigger'` / `'borderColor'` | Removed props | Section 3 / 8 | +| TS error: `Expected 2 arguments, but got 3` on `useCarousel` | `slots` argument removed | Section 5 | +| TS error: `Property 'jsonData' does not exist` | `useFormData` API | `getJson()` / `getFormData()` | +| Custom carousel buttons do nothing | String-key `inject` returns `undefined` | `inject(CarouselContextKey)` | +| Flyout opens and closes in one click | Extra `@click="toggle"` on the `#trigger` slot element | Remove it; the slot element is the trigger | +| Flyout trigger slot warns about multiple root nodes / does nothing | Slot renders a fragment or text | Render exactly one element | +| `FlyoutDropdown` throws ``Injection `Symbol(PopoverRootContext)` not found. Component must be used within `PopoverRoot` `` | Used outside `FlyoutRoot` | Keep it inside `FlyoutRoot` (`#dropdown` or default slot) | +| Snapshot tests fail on class names | Token-based colors and moved inline styles (section 4) | Review the diff and update; select by role / label | +| Token conflict warning for `surface`, `border`, or `text` | App already defines a semantic color with that name | Keep the app's if it is used app-wide; otherwise rename the app token. Library components use the library's values only through `designSystem` | +| Page no longer scrolls into a carousel on wheel | That is the fix | Add `wheel-navigation` only if product requires it | + +# Do not + +- Do not pass bare objects to `css`. +- Do not copy `@fyrst/ui` `cva` / `sva` definitions into the app; use the `css` prop. +- Do not pin `@fyrst/ui` to 0.4.x "for now" while other packages in the same app use 0.5.x; the design-system manifest is per install. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fe2e49..9d70361 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,9 @@ jobs: - name: Lint run: bun run lint + - name: Typecheck + run: bun run typecheck + - name: Build run: bun run build diff --git a/.gitignore b/.gitignore index 91b1efe..45eb866 100644 --- a/.gitignore +++ b/.gitignore @@ -16,17 +16,6 @@ logs _.log report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json -# reset build folders -/packages/preset/css -/packages/preset/jsx -/packages/preset/patterns -/packages/preset/tokens -/packages/preset/types -/packages/preset/recipes -/packages/preset/helpers.js -/packages/preset/helpers.d.ts -/packages/preset/helpers.mjs - # dotenv environment variable files .env .env.development.local diff --git a/AGENTS.md b/AGENTS.md index d611bcc..589b2db 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,7 +9,7 @@ Workspace packages (private, not published): Uses Bun as package manager and build tool, full TypeScript support. -First-party agent skills live in `.agents/skills//SKILL.md`. Consumer apps on `@fyrst/ui` 0.2.x (`panda.buildinfo.json` in `include`) or still on Panda CSS 1.x should follow [`.agents/skills/panda-v2-migration/SKILL.md`](.agents/skills/panda-v2-migration/SKILL.md). +First-party agent skills live in `.agents/skills//SKILL.md`. Consumer apps on `@fyrst/ui` 0.2.x (`panda.buildinfo.json` in `include`) or still on Panda CSS 1.x should follow [`.agents/skills/panda-v2-migration/SKILL.md`](.agents/skills/panda-v2-migration/SKILL.md). Consumer apps on 0.3.x / 0.4.x upgrading to 0.5.x should follow [`.agents/skills/fyrst-ui-0.5-migration/SKILL.md`](.agents/skills/fyrst-ui-0.5-migration/SKILL.md). Every breaking change to the public API needs a matching section in a migration skill. ## Package Structure @@ -17,7 +17,7 @@ First-party agent skills live in `.agents/skills//SKILL.md`. Consumer apps packages/ ├── preset/ # @fyrst/design-preset - Panda CSS Preset │ └── src/ -│ ├── index.ts # Main preset export +│ ├── index.ts # Token preset (`@fyrst/ui/design-preset`) │ └── tokens/ # Base & semantic tokens ├── components/ # @fyrst/ui-components - Vue 3 UI Components └── nuxt/ # @fyrst/ui-nuxt - Nuxt Module @@ -39,13 +39,14 @@ bun run dev:components # Components dev server bun run dev:nuxt # Link @fyrst/ui, panda lib, then Nuxt module playground bun run dev:nuxt:prepare # Link @fyrst/ui, panda lib, then stub/prepare the Nuxt module + playground bun run dev:nuxt:build # Link @fyrst/ui, then build the Nuxt playground (dev check, not publish) +bun run typecheck # tsc on the preset, vue-tsc on the components bun run clean # Clean all dist folders ``` ## Lint Commands ```bash -bun run lint # Run ESLint on all packages +bun run lint # ESLint on sources, tests, and build scripts bun run lint:fix # Auto-fix lint issues bun run --filter='@fyrst/ui-nuxt' lint # Lint specific package ``` @@ -110,67 +111,68 @@ bun run --filter='@fyrst/ui-nuxt' test:types # Type checking - Use Panda CSS for styling - Follow patterns in `packages/components/src/` -### CVA/SVA Styling Pattern +### Component Styling (CVA/SVA) -New components using CVA (or SVA for multi-slot) must follow this pattern: +Component styles are `cva` (one element) or `sva` (several slots) definitions in the component's folder. Panda extracts them from the published JS and generates every variant. -**1. Create component folder** (e.g., `packages/components/src/components/Badge/`): +**1. Component folder** (e.g. `packages/components/src/components/Badge/`): ``` Badge/ ├── BadgeRoot.vue ├── styles.ts └── index.ts ``` +Standalone exceptions (`Button`, `Loader`) keep those public names (not `ButtonRoot` / `LoaderRoot`) but still use a folder + `styles.ts`. Internal controls keep their styles next to them in `src/internal/controls/` (`controlStyles.ts`, `choiceStyles.ts`, …). -Standalone exceptions (`Button`, `Loader`) keep those public names (not `ButtonRoot` / `LoaderRoot`) but still use a folder + `styles.ts`: -``` -Button/ -├── Button.vue -├── styles.ts -└── index.ts -``` - -**2. styles.ts** - Define CVA/SVA with slots if needed: +**2. styles.ts** — a static object literal. Panda reads it at build time, so do not build variants with loops, spreads of shared constants, or `Object.fromEntries`; write them out. ```typescript -import { cva } from 'styled-system/css' -// or for multi-slot: import { sva } from 'styled-system/css' +import { sva } from 'styled-system/css' -export const badgeStyles = cva({ - base: { ... }, - variants: { ... }, - defaultVariants: { ... }, +export const badgeStyles = sva({ + slots: ['root', 'icon'], + base: { root: { ... } }, + variants: { size: { sm: { root: { ... } } } }, + defaultVariants: { size: 'md' }, }) ``` -**3. Component.vue** - Use computed with `.raw()` (typically wrapped in `css(...)`): -```typescript +**3. Component** — every component takes a `css` prop typed `CssMap<…>`; `root` is always the outermost element. For each slot that accepts an override, take the style object with `.raw()` and merge the override with `withCss`: +```vue + -```vue ``` -**4. index.ts** - Named parts plus default namespace `{ Root, … }`: +- `withCss(style, override)` is `css(style, override)`: one class per property, the override wins. Never append an override class to a finished class string; both atomic classes would stay on the element and stylesheet order would decide. +- Parts without an override (internal chrome) may call the definition directly: `fieldStyles().footer`. +- Share style objects between parts through a typed `createInjectionKey` context (see `Card/types.ts`), never string keys. +- Calling `.raw()` with runtime variants in another file triggers Panda's `imported_recipe_raw_dynamic` warning. It is expected: the definition itself still generates every variant. +- Prefer semantic tokens (`surface`, `border`, `text.muted`, `neutral`) over `_light` overrides. Keep a `_light` block only when state selectors must beat light-mode colors on specificity (see `switchStyles.ts`). + +**4. Content.** Content props (labels, titles, descriptions, item content, field message / error) render with `v-html`, as documented in the README. Sanitizing untrusted strings is the consuming app's job, not the library's; `vue/no-v-html` is off for that reason. Where practical, offer a slot for the same content so apps can pass escaped text or their own nodes. + +**5. index.ts** — named parts plus default namespace `{ Root, … }`, and export the component's `*Css` types: ```typescript import BadgeRoot from './BadgeRoot.vue' export { BadgeRoot } +export type { BadgeCss } from './BadgeRoot.vue' export default { Root: BadgeRoot } ``` -Register the same named exports in `vue-components.ts` and `vue-entries.ts` (`vueLibEntries` and `nuxtComponents` are 1:1; no alias table). `Button` / `Loader` export the SFC by those names and do not use a `{ Root }` namespace. +Register the entry in `vue-entries.ts` (`vueLibEntries`; `nuxtComponents` is derived) and the named export in `vue-components.ts`. `Button` / `Loader` export the SFC by those names and do not use a `{ Root }` namespace. -Do not export `Control*` from `@fyrst/ui`. Bare controls stay under `src/internal/controls/` for Field/Switch. Public form API is `Field.*` / `FyrstField*`. Re-export `FieldOption` from Field. +Do not export `Control*` from `@fyrst/ui`. Bare controls stay under `src/internal/controls/` and share `useFieldControl()` (id, ARIA links, validity from the Field context). Public form API is `Field.*` / `FyrstField*`; composed fields use `FieldSharedProps` and `FieldFooter`. Re-export `FieldOption` from Field. ### Panda CSS @@ -236,4 +238,4 @@ describe('ssr', async () => { 3. Build order: Nuxt module requires preset built first (automatic) 4. Peer dependencies: `vue`, `reka-ui`, and `@pandacss/dev` are required. `@pandacss/preset-base` is a published `dependency` (the design-system preset inlines the module; apps on `designSystem` do not install it). `nuxt` and `@nuxt/kit` are optional (only `@fyrst/ui/nuxt`). Do not put `@nuxt/kit` in published `dependencies`. 5. No Prettier: ESLint used for formatting (stylistic rules) -6. Do not ship compiled Panda CSS (`panda cssgen`, `styles.css`, `panda.css`). Publish only the root `@fyrst/ui` package. Consuming apps must depend on `@pandacss/dev`, keep their own `panda.config.ts`, and set `designSystem: '@fyrst/ui'` (no fyrst preset, no `include` into the package). The library build runs `panda lib --outdir dist --files './**/*.{js,mjs}' --panda '^2.4.0'` after assembling `dist/`. That command owns `./panda/*`, `./css`, `./tokens`, `./types`, and other generated subpaths — do not hand-edit them. Custom exports (`./design-preset`, `./preset`, `./nuxt`, `./vue/*`, `./style.css`) stay in `package.json`. `@fyrst/ui/style.css` is Iconify icons only. Pack root `dist/` only (assembled from workspace build outputs, including `dist/panda/` and `dist/styled-system/`) — do not include nested `packages/*/dist`. +6. Do not ship compiled Panda CSS (`panda cssgen`, `styles.css`, `panda.css`). Publish only the root `@fyrst/ui` package. Consuming apps must depend on `@pandacss/dev`, keep their own `panda.config.ts`, and set `designSystem: '@fyrst/ui'` (no fyrst preset, no `include` into the package). The library build runs `panda lib --outdir dist --files './**/*.{js,mjs}' --panda '^2.4.0'` after assembling `dist/`. That command owns `./panda/*`, `./css`, `./tokens`, `./types`, and other generated subpaths — do not hand-edit them. Custom exports (`./design-preset`, `./preset`, `./nuxt`, `./vue/*`, `./style.css`) stay in `package.json`. `@fyrst/ui/style.css` is Iconify icons only: do not add ` diff --git a/packages/components/src/components/Flyout/index.ts b/packages/components/src/components/Flyout/index.ts index 44ab08a..56ea669 100644 --- a/packages/components/src/components/Flyout/index.ts +++ b/packages/components/src/components/Flyout/index.ts @@ -1,10 +1,10 @@ import FlyoutRoot from './FlyoutRoot.vue' import FlyoutDropdown from './FlyoutDropdown.vue' -// Named exports for direct imports export { FlyoutRoot, FlyoutDropdown } -// Default export for namespaced usage: , +export type { FlyoutRootCss, FlyoutDropdownCss } from './types' + export default { Root: FlyoutRoot, Dropdown: FlyoutDropdown, diff --git a/packages/components/src/components/Flyout/styles.ts b/packages/components/src/components/Flyout/styles.ts new file mode 100644 index 0000000..872453e --- /dev/null +++ b/packages/components/src/components/Flyout/styles.ts @@ -0,0 +1,30 @@ +import { sva } from 'styled-system/css' + +export const flyoutStyles = sva({ + slots: ['root', 'trigger', 'content'], + base: { + root: { + position: 'relative', + zIndex: 20, + }, + trigger: { + cursor: 'pointer', + fontFamily: 'inherit', + }, + content: { + 'zIndex': 50, + // Transparent gap between trigger and panel: the pointer stays inside the + // flyout while it moves down, so hover does not close it. + 'paddingTop': 'sm', + 'outline': 'none', + '&[data-state="open"]': { + animationName: 'flyoutIn', + animationDuration: '200ms', + }, + '&[data-state="closed"]': { + animationName: 'flyoutOut', + animationDuration: '200ms', + }, + }, + }, +}) diff --git a/packages/components/src/components/Flyout/types.ts b/packages/components/src/components/Flyout/types.ts new file mode 100644 index 0000000..d411dae --- /dev/null +++ b/packages/components/src/components/Flyout/types.ts @@ -0,0 +1,14 @@ +import type { DeepReadonly, Ref } from 'vue' +import { createInjectionKey } from '../../composables/injection-key' +import type { FlyoutOpenReason } from '../../composables/flyout' +import type { CssMap } from '../../internal/css' + +export interface FlyoutContext { + openedBy: DeepReadonly> + direction: Ref<'left' | 'right'> +} + +export const FlyoutContextKey = createInjectionKey('Flyout') + +export type FlyoutRootCss = CssMap<'root' | 'trigger' | 'content'> +export type FlyoutDropdownCss = CssMap<'root'> diff --git a/packages/components/src/components/Form/FormPrompt.vue b/packages/components/src/components/Form/FormPrompt.vue index 1a04294..91e9a7d 100644 --- a/packages/components/src/components/Form/FormPrompt.vue +++ b/packages/components/src/components/Form/FormPrompt.vue @@ -1,6 +1,9 @@