@wirecore/wirelayer-react 0.9.2 → 0.11.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/dist/index.js CHANGED
@@ -4209,99 +4209,103 @@ function Qf({ classes: t, menus: r, onSelect: i, onCheckedChange: a, onValueChan
4209
4209
  }
4210
4210
  //#endregion
4211
4211
  //#region src/components/AppShell/context.ts
4212
- var $f = Vl(null), ep = (e) => !!e.current || !!e.children?.some(ep);
4213
- function tp({ classes: e, items: t, label: r, onNavigate: i, rail: a, expandOnHover: o, header: s, footer: c, className: l, style: u }) {
4214
- let d = n("sidebarNav", No, e), f = Wl($f), p = a ?? f?.rail ?? !1, m = p && (o ?? f?.expandOnHover ?? !1), h = d(p ? {
4212
+ var $f = Vl(null), ep = (e, t) => t(e) || !!e.children?.some((e) => ep(e, t));
4213
+ function tp({ classes: e, items: t, label: r, onNavigate: i, linkAs: a = "a", currentHref: o, isCurrent: s, rail: c, expandOnHover: l, header: u, footer: d, className: f, style: p }) {
4214
+ let m = n("sidebarNav", No, e), h = Wl($f), g = c ?? h?.rail ?? !1, _ = g && (l ?? h?.expandOnHover ?? !1), v = m(g ? {
4215
4215
  rail: !0,
4216
- expandOnHover: m
4216
+ expandOnHover: _
4217
4217
  } : void 0);
4218
4218
  return /* @__PURE__ */ $("nav", {
4219
4219
  "aria-label": r,
4220
- className: h.base({ class: l }),
4221
- style: u,
4222
- "data-rail": p ? "" : void 0,
4220
+ className: v.base({ class: f }),
4221
+ style: p,
4222
+ "data-rail": g ? "" : void 0,
4223
4223
  children: [
4224
- s && /* @__PURE__ */ Q("div", {
4225
- className: h.header(),
4226
- children: s
4224
+ u && /* @__PURE__ */ Q("div", {
4225
+ className: v.header(),
4226
+ children: u
4227
4227
  }),
4228
4228
  /* @__PURE__ */ Q("ul", {
4229
- className: h.list(),
4229
+ className: v.list(),
4230
4230
  children: /* @__PURE__ */ Q(np, {
4231
4231
  items: t,
4232
4232
  depth: 0,
4233
4233
  onNavigate: i,
4234
- rail: p,
4235
- expandOnHover: m
4234
+ linkAs: a,
4235
+ check: (e) => Qr(e, o, s),
4236
+ rail: g,
4237
+ expandOnHover: _
4236
4238
  })
4237
4239
  }),
4238
- c && /* @__PURE__ */ Q("div", {
4239
- className: h.footer(),
4240
- children: c
4240
+ d && /* @__PURE__ */ Q("div", {
4241
+ className: v.footer(),
4242
+ children: d
4241
4243
  })
4242
4244
  ]
4243
4245
  });
4244
4246
  }
4245
- function np({ items: e, depth: t, onNavigate: r, rail: i, expandOnHover: a }) {
4246
- let o = n("sidebarNav", No)(i ? {
4247
+ function np({ items: e, depth: t, onNavigate: r, linkAs: i, check: a, rail: o, expandOnHover: s }) {
4248
+ let c = n("sidebarNav", No)(o ? {
4247
4249
  rail: !0,
4248
- expandOnHover: a
4249
- } : void 0), s = (e, t) => i && !a ? /* @__PURE__ */ Q(Qd, {
4250
+ expandOnHover: s
4251
+ } : void 0), l = (e, t) => o && !s ? /* @__PURE__ */ Q(Qd, {
4250
4252
  content: e,
4251
4253
  placement: "right",
4252
4254
  children: t
4253
4255
  }) : t;
4254
4256
  return e.map((e) => {
4255
- let n = e.icon, c = { "--depth": t }, l = /* @__PURE__ */ $(Zl, { children: [
4257
+ let n = e.icon, u = { "--depth": t }, d = /* @__PURE__ */ $(Zl, { children: [
4256
4258
  n ? /* @__PURE__ */ Q(n, {
4257
- className: o.icon(),
4259
+ className: c.icon(),
4258
4260
  "aria-hidden": "true"
4259
- }) : i && /* @__PURE__ */ Q("span", {
4260
- className: o.monogram(),
4261
+ }) : o && /* @__PURE__ */ Q("span", {
4262
+ className: c.monogram(),
4261
4263
  "aria-hidden": "true",
4262
4264
  children: e.label[0]
4263
4265
  }),
4264
4266
  /* @__PURE__ */ Q("span", {
4265
- className: o.label(),
4267
+ className: c.label(),
4266
4268
  children: e.label
4267
4269
  }),
4268
4270
  e.badge !== void 0 && /* @__PURE__ */ Q("span", {
4269
- className: o.badge(),
4271
+ className: c.badge(),
4270
4272
  children: typeof e.badge == "number" ? Gn(e.badge) : e.badge
4271
4273
  })
4272
4274
  ] });
4273
4275
  return /* @__PURE__ */ Q("li", { children: e.children ? /* @__PURE__ */ $(Fu.Root, {
4274
- defaultOpen: ep(e),
4275
- children: [s(e.label, /* @__PURE__ */ $(Fu.Trigger, {
4276
- className: o.link(),
4277
- style: c,
4278
- children: [l, /* @__PURE__ */ Q(Fu.Indicator, {
4276
+ defaultOpen: ep(e, a),
4277
+ children: [l(e.label, /* @__PURE__ */ $(Fu.Trigger, {
4278
+ className: c.link(),
4279
+ style: u,
4280
+ children: [d, /* @__PURE__ */ Q(Fu.Indicator, {
4279
4281
  asChild: !0,
4280
4282
  children: /* @__PURE__ */ Q(Dc, {
4281
- className: o.indicator(),
4283
+ className: c.indicator(),
4282
4284
  "aria-hidden": "true"
4283
4285
  })
4284
4286
  })]
4285
4287
  })), /* @__PURE__ */ Q(Fu.Content, {
4286
- className: o.content(),
4288
+ className: c.content(),
4287
4289
  children: /* @__PURE__ */ Q("ul", {
4288
- className: o.sublist(),
4290
+ className: c.sublist(),
4289
4291
  children: /* @__PURE__ */ Q(np, {
4290
4292
  items: e.children,
4291
4293
  depth: t + 1,
4292
4294
  onNavigate: r,
4293
- rail: i,
4294
- expandOnHover: a
4295
+ linkAs: i,
4296
+ check: a,
4297
+ rail: o,
4298
+ expandOnHover: s
4295
4299
  })
4296
4300
  })
4297
4301
  })]
4298
- }) : s(e.label, /* @__PURE__ */ Q("a", {
4299
- href: e.href,
4300
- className: o.link(),
4301
- style: c,
4302
- "aria-current": e.current ? "page" : void 0,
4302
+ }) : l(e.label, /* @__PURE__ */ Q(i, {
4303
+ ...xi(e.href, e.to),
4304
+ className: c.link(),
4305
+ style: u,
4306
+ "aria-current": a(e) ? "page" : void 0,
4303
4307
  onClick: (t) => r?.(e, t),
4304
- children: l
4308
+ children: d
4305
4309
  })) }, e.label);
4306
4310
  });
4307
4311
  }
@@ -9412,17 +9416,19 @@ function Oh({ classes: e, ratio: t = 16 / 9, className: r, style: i, ...a }) {
9412
9416
  }
9413
9417
  //#endregion
9414
9418
  //#region src/components/Affix/Affix.tsx
9415
- function kh({ classes: e, position: t, offset: r, className: i, style: a, ...o }) {
9416
- let s = n("affix", Ee, e);
9419
+ function kh({ classes: e, position: t, offset: r, offsetX: i, offsetY: a, className: o, style: s, ...c }) {
9420
+ let l = n("affix", Ee, e);
9417
9421
  return /* @__PURE__ */ Q("div", {
9418
- ...o,
9419
- className: s({
9422
+ ...c,
9423
+ className: l({
9420
9424
  position: t,
9421
- class: i
9425
+ class: o
9422
9426
  }),
9423
9427
  style: {
9424
9428
  ...r ? { "--wc-affix-offset": r } : {},
9425
- ...a
9429
+ ...i ? { "--wc-affix-offset-x": i } : {},
9430
+ ...a ? { "--wc-affix-offset-y": a } : {},
9431
+ ...s
9426
9432
  }
9427
9433
  });
9428
9434
  }
@@ -9853,6 +9859,11 @@ function Uh({ items: r, unread: i, hasMore: a, loading: o, now: s, emptyText: c,
9853
9859
  className: n.title({ class: g.titleLink() }),
9854
9860
  onClick: (e) => f?.(t, e),
9855
9861
  children: i
9862
+ }) : t.clickable ? /* @__PURE__ */ Q("button", {
9863
+ type: "button",
9864
+ className: n.title({ class: [g.titleLink(), g.titleButton()] }),
9865
+ onClick: (e) => f?.(t, e),
9866
+ children: i
9856
9867
  }) : /* @__PURE__ */ Q("span", {
9857
9868
  className: n.title(),
9858
9869
  children: i
@@ -9913,7 +9924,8 @@ function Gh({ classes: t, items: r = Wh, dataSource: i, pageSize: a = 20, unread
9913
9924
  } : e) : k, M = T.active ? T.state.hasMore : s, N = !!c || T.active && T.state.status === "loading", P = (e) => {
9914
9925
  T.active && O((t) => /* @__PURE__ */ new Set([...t, e])), h?.(e);
9915
9926
  }, F = () => {
9916
- T.active && O(new Set(A.map((e) => e.id))), g?.();
9927
+ let e = A.filter((e) => !e.read).map((e) => e.id);
9928
+ T.active && O(new Set(A.map((e) => e.id))), g?.(e);
9917
9929
  }, I = r, L = o ?? A.filter((e) => !e.read).length, [R, z] = Z(!1), B = u ?? R, V = (e) => {
9918
9930
  z(e), d?.(e);
9919
9931
  }, H = (e) => C.notificationCenter.unreadCount(e ?? ""), [U, W] = Z(""), G = X(null);
package/llms-full.txt CHANGED
@@ -82,6 +82,8 @@ Fixed in a corner of the window, e.g. a help or chat button
82
82
  | --- | --- | --- |
83
83
  | position? | `'bottom-end' \| 'bottom-start' \| 'top-end' \| 'top-start'` | Corner of the window (default bottom-end) |
84
84
  | offset? | `string` | Distance from the edges, e.g. "1rem" (default 1.5rem) |
85
+ | offsetX? | `string` | Distance from the side edge (start/end) only, e.g. "1rem" – instead of `offset` |
86
+ | offsetY? | `string` | Distance from the top or bottom edge only, e.g. "4rem" above a banner – instead of `offset` |
85
87
  | classes? | `RecipeClasses<typeof affixRecipe>` | Extra classes per part of the component, e.g. { base: "…" } (see the recipe) |
86
88
 
87
89
  ### AiLabel
@@ -1413,7 +1415,7 @@ Data table on TanStack Table: sorting (also by several columns), search, filter
1413
1415
  - Import: `import { DataTable } from '@wirecore/wirelayer-react/data-table'`
1414
1416
  - Category: Data
1415
1417
  - Example: https://wirecore.github.io/WireLayer/?path=/story/react_data-datatable--playground
1416
- - Also takes: Omit< ComponentProps<'div'>, 'children' | 'ref' | 'contextMenu' | 'onScrollEnd' | 'onRowClick' >
1418
+ - Also takes: Omit< ComponentProps<'div'>, 'children' | 'ref' | 'contextMenu' | 'onScroll' | 'onScrollEnd' | 'onRowClick' >
1417
1419
 
1418
1420
  | Prop | Type | Description |
1419
1421
  | --- | --- | --- |
@@ -1519,6 +1521,7 @@ Data table on TanStack Table: sorting (also by several columns), search, filter
1519
1521
  | wrapHeaders? | `boolean` | Long header texts wrap instead of being shortened |
1520
1522
  | verticalHeaders? | `boolean` | Header texts read from bottom to top (narrow columns) |
1521
1523
  | editMode? | `'cell' \| 'row' \| 'batch'` | `cell`: one cell at a time (Tab moves on); `row`: a whole row with save and cancel; `batch`: like `cell`, but the changes are collected (marked) until "Save" (`onSave`) or "Discard", with undo and redo |
1524
+ | editTrigger? | `'click' \| 'dblclick'` | What starts editing a cell with the pointer: `click` (default) or `dblclick` – then a single click only focuses the cell. The keyboard always starts editing (Enter or Space on the cell, Enter/F2 in the grid navigation). |
1522
1525
  | onCellEdit? | `(edit: DataTableCellEdit<TData>) => void` | An editable cell was changed (`editMode="cell"`) |
1523
1526
  | onRowEdit? | `(edit: DataTableRowEdit<TData>) => void` | A row was saved (`editMode="row"`) |
1524
1527
  | size? | `Density` | Row height (`densityToggle`) |
@@ -1534,6 +1537,7 @@ Data table on TanStack Table: sorting (also by several columns), search, filter
1534
1537
  | rowHeight? | `number` | Estimated row height in px for `virtual` |
1535
1538
  | onLoadMore? | `() => void` | Scrolled near the end (`scrollHeight`) – load more rows (infinite scrolling) |
1536
1539
  | onScrollEnd? | `() => void` | |
1540
+ | onScroll? | `(event: UIEvent<HTMLDivElement>) => void` | The table's scroll area scrolled (down/up with `scrollHeight`, sideways when wider) – e.g. to close a popover anchored in a row that virtual scrolling removes |
1537
1541
  | stateKey? | `string` | Keeps sorting, filters, page, widths, order and the other settings in the browser under this key |
1538
1542
  | stateStorage? | `'local' \| 'session'` | |
1539
1543
  | stateExclude? | `readonly DataTableStateKey[]` | Parts of the state that `stateKey` does not keep – default: the selection (`[]` keeps it, too) |
@@ -3347,9 +3351,9 @@ Bell with the unread count (part of its name) that opens the notifications in a
3347
3351
  | now? | `Date \| string` | Reference time for "Today"/"Yesterday" (default: now) |
3348
3352
  | emptyText? | `string` | Text without notifications (default "No notifications") |
3349
3353
  | onMarkRead? | `(id: string) => void` | Mark one item as read |
3350
- | onMarkAllRead? | `() => void` | |
3354
+ | onMarkAllRead? | `(ids: string[]) => void` | "Mark all as read": the ids of the unread items shown – e.g. for one request to the server |
3351
3355
  | onLoadMore? | `() => void` | Load the next page (hasMore) |
3352
- | onSelect? | `(item: NotificationItem, event: MouseEvent<HTMLAnchorElement>) => void` | The title link of an item was clicked |
3356
+ | onSelect? | `(item: NotificationItem, event: MouseEvent<HTMLAnchorElement \| HTMLButtonElement>) => void` | The title of an item was clicked: its link, or its button (`clickable` without `href`) |
3353
3357
  | renderActions? | `(item: NotificationItem) => ReactNode` | Own buttons per item (before "mark as read") |
3354
3358
  | classes? | `RecipeClasses<typeof notificationCenterRecipe>` | Extra classes per part of the component, e.g. { base: "…" } (see the recipe) |
3355
3359
 
@@ -4382,7 +4386,10 @@ Navigation landmark with links and expandable groups (buttons with aria-expanded
4382
4386
  | --- | --- | --- |
4383
4387
  | items | `readonly SidebarNavItem[]` | |
4384
4388
  | label | `string` | Name of the navigation landmark, e.g. "Main navigation" |
4385
- | onNavigate? | `(item: SidebarNavItem, event: MouseEvent<HTMLAnchorElement>) => void` | A link was clicked – call event.preventDefault() and route yourself in a single-page app |
4389
+ | onNavigate? | `(item: SidebarNavItem, event: MouseEvent<HTMLAnchorElement>) => void` | A link was clicked – call event.preventDefault() and route yourself in a single-page app (or use `linkAs`) |
4390
+ | linkAs? | `ElementType` | Component for the links, e.g. Link of React Router or Next.js (gets `to` for items with `to`, else `href`); default <a> |
4391
+ | currentHref? | `string` | Path of the current page – the item with exactly this href gets aria-current="page" (its groups start open) |
4392
+ | isCurrent? | `(item: SidebarNavItem) => boolean` | Own check for the current page, e.g. with the router |
4386
4393
  | rail? | `boolean` | Icons only, the labels as tooltips (and for screen readers). Default: the collapsed state of a surrounding AppShell (navbarCollapsed) |
4387
4394
  | expandOnHover? | `boolean` | With `rail`: hovering or focusing the rail shows the labels (no tooltips) – default from the AppShell |
4388
4395
  | header? | `ReactNode` | Above the links, e.g. a logo or a switcher |
@@ -6465,6 +6472,59 @@ suggestThemeFixes(brand);
6465
6472
  // on: { token: 'on-primary', value: '#050505', ratio: 8.1 } }, …]
6466
6473
  ```
6467
6474
 
6475
+ ### Second brand color and hover color
6476
+
6477
+ Three more tokens are optional – a theme sets them only when it needs them. Without them they follow another token, so
6478
+ a theme without them looks as before:
6479
+
6480
+ | Token | Without it | Used by |
6481
+ | --------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
6482
+ | `accent` | `primary` | A second brand color for your own markup: `bg-accent`, `text-accent`, `border-accent` (no component uses it) |
6483
+ | `on-accent` | `on-primary` | Text on the accent: `text-on-accent` |
6484
+ | `primary-hover` | see right | Hover of the primary color: the fill of solid primary buttons (else the fill fades to 85 %) and the text of tinted ones (else it stays `primary`) |
6485
+
6486
+ `primary-hover` is the answer to a strong brand color: a fill that fades on hover, or a tint behind the text, can drop
6487
+ it below 4.5:1 although the color itself passes. Tinted means `soft`, `outline` and `text` buttons in the primary color
6488
+ and avatar buttons with `color="primary"`.
6489
+
6490
+ ```ts
6491
+ export const brand = defineTheme({
6492
+ name: 'brand',
6493
+ label: 'Brand',
6494
+ colors: {
6495
+ light: {
6496
+ primary: '#a33d00',
6497
+ 'on-primary': '#FFFFFF',
6498
+ 'primary-hover': '#8a3300',
6499
+ accent: '#00696d',
6500
+ 'on-accent': '#FFFFFF',
6501
+ },
6502
+ dark: {
6503
+ primary: '#e95a00',
6504
+ 'on-primary': '#050505',
6505
+ 'primary-hover': '#f5772a',
6506
+ accent: '#2aa0a5',
6507
+ 'on-accent': '#050505',
6508
+ },
6509
+ },
6510
+ });
6511
+ ```
6512
+
6513
+ `checkTheme` checks the accent (text on it, and as text on `bg`, `bg-2` and `card`) once a theme sets `accent` or
6514
+ `on-accent` in a mode. The hover pairs of the primary color use `primary-hover` when it is set, and `suggestThemeFixes`
6515
+ suggests one `primary-hover` that meets all of them, before it would change `primary` itself.
6516
+
6517
+ **Changed with `@wirecore/wirelayer-tokens` 0.6 and `@wirecore/wirelayer-recipes` 0.9:**
6518
+
6519
+ - Solid primary buttons without `primary-hover` fade only their fill on hover (`color-mix`, 85 %); before, the whole
6520
+ button faded with `opacity`, the text included. In the bundled themes this looks the same – the text has the color
6521
+ of the page – and the contrast is never lower. Solid success, danger, info, warn and contrast buttons still fade with
6522
+ `opacity`.
6523
+ - `checkTheme` checks tinted primary text at rest as well: `soft primary: text-primary on bg-primary/10` (on `bg`,
6524
+ `bg-2`, `card`) and `avatar primary: text-primary on primary/14 (card)`. Before, the stricter hover pairs covered
6525
+ them; with `primary-hover` the hover has a text color of its own. A theme that missed a tinted hover may therefore be
6526
+ reported for these pairs as well.
6527
+
6468
6528
  ### Component sizes and shapes
6469
6529
 
6470
6530
  Besides the colors, a few measures that a brand usually changes are CSS variables. Without them every component looks as
package/llms.txt CHANGED
@@ -313,4 +313,5 @@ Full API (props, events, slots, examples) in llms-full.txt next to this file. MC
313
313
  - Pitfalls
314
314
  - Desktop apps (dense UI, many dialogs)
315
315
  - Custom theme
316
+ - Second brand color and hover color
316
317
  - Component sizes and shapes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecore/wirelayer-react",
3
- "version": "0.9.2",
3
+ "version": "0.11.0",
4
4
  "description": "WireLayer components for React",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -166,8 +166,8 @@
166
166
  "dependencies": {
167
167
  "@ark-ui/react": "^5.39.3",
168
168
  "@internationalized/date": "^3.12.4",
169
- "@wirecore/wirelayer-recipes": "^0.8.1",
170
- "@wirecore/wirelayer-tokens": "^0.5.1",
169
+ "@wirecore/wirelayer-recipes": "^0.9.0",
170
+ "@wirecore/wirelayer-tokens": "^0.6.0",
171
171
  "lucide-react": "^1.59.0"
172
172
  },
173
173
  "devDependencies": {