@blakesteve/roster 5.7.0 → 5.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 +84 -4
- package/dist/components/atoms/Avatar/Avatar.cjs +1 -1
- package/dist/components/atoms/Avatar/Avatar.d.ts +4 -0
- package/dist/components/atoms/Avatar/Avatar.js +1 -1
- package/dist/components/atoms/AvatarStrip/AvatarStrip.cjs +1 -1
- package/dist/components/atoms/AvatarStrip/AvatarStrip.d.ts +10 -1
- package/dist/components/atoms/AvatarStrip/AvatarStrip.js +34 -30
- package/dist/components/atoms/Button/button-variants.cjs +1 -1
- package/dist/components/atoms/Button/button-variants.js +5 -3
- package/dist/components/atoms/Eyebrow/eyebrow-variants.cjs +1 -1
- package/dist/components/atoms/Eyebrow/eyebrow-variants.js +8 -4
- package/dist/components/atoms/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/atoms/MultiSelect/MultiSelect.d.ts +3 -1
- package/dist/components/atoms/MultiSelect/MultiSelect.js +87 -89
- package/dist/components/atoms/Progress/Progress.cjs +1 -1
- package/dist/components/atoms/Progress/Progress.d.ts +1 -0
- package/dist/components/atoms/Progress/Progress.js +28 -27
- package/dist/components/atoms/Stat/Stat.cjs +1 -1
- package/dist/components/atoms/Stat/Stat.js +5 -5
- package/dist/components/atoms/Stat/stat-variants.cjs +1 -1
- package/dist/components/atoms/Stat/stat-variants.js +10 -8
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.d.ts +10 -1
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.js +31 -29
- package/dist/components/molecules/CallToAction/CallToAction.cjs +1 -1
- package/dist/components/molecules/CallToAction/CallToAction.d.ts +8 -1
- package/dist/components/molecules/CallToAction/CallToAction.js +34 -29
- package/dist/components/molecules/Carousel/Carousel.cjs +1 -1
- package/dist/components/molecules/Carousel/Carousel.d.ts +7 -0
- package/dist/components/molecules/Carousel/Carousel.js +155 -155
- package/dist/components/molecules/ErrorState/ErrorState.cjs +1 -1
- package/dist/components/molecules/ErrorState/ErrorState.d.ts +8 -1
- package/dist/components/molecules/ErrorState/ErrorState.js +44 -39
- package/dist/components/molecules/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/molecules/FileUpload/FileUpload.js +23 -22
- package/dist/components/molecules/MediaPreview/MediaPreview.cjs +1 -1
- package/dist/components/molecules/MediaPreview/MediaPreview.d.ts +3 -1
- package/dist/components/molecules/MediaPreview/MediaPreview.js +13 -12
- package/dist/components/molecules/Pagination/Pagination.cjs +1 -1
- package/dist/components/molecules/Pagination/Pagination.d.ts +1 -0
- package/dist/components/molecules/Pagination/Pagination.js +47 -46
- package/dist/components/molecules/ProgressField/ProgressField.d.ts +1 -0
- package/dist/components/molecules/SkeletonPresets/SkeletonPresets.cjs +1 -1
- package/dist/components/molecules/SkeletonPresets/SkeletonPresets.d.ts +2 -2
- package/dist/components/molecules/SkeletonPresets/SkeletonPresets.js +17 -17
- package/dist/components/molecules/StepProgress/StepProgress.cjs +1 -1
- package/dist/components/molecules/StepProgress/StepProgress.d.ts +1 -0
- package/dist/components/molecules/StepProgress/StepProgress.js +9 -8
- package/dist/components/organisms/Countdown/Countdown.cjs +1 -1
- package/dist/components/organisms/Countdown/Countdown.d.ts +13 -0
- package/dist/components/organisms/Countdown/Countdown.js +54 -47
- package/dist/components/organisms/DataTable/DataTable.cjs +1 -1
- package/dist/components/organisms/DataTable/DataTable.d.ts +5 -3
- package/dist/components/organisms/DataTable/DataTable.js +27 -26
- package/dist/components/organisms/Dialog/Dialog.cjs +1 -1
- package/dist/components/organisms/Dialog/Dialog.d.ts +8 -1
- package/dist/components/organisms/Dialog/Dialog.js +25 -23
- package/dist/components/organisms/Footer/Footer.cjs +1 -1
- package/dist/components/organisms/Footer/Footer.d.ts +9 -0
- package/dist/components/organisms/Footer/Footer.js +21 -23
- package/dist/components/organisms/ModerationQueue/ModerationQueue.cjs +1 -1
- package/dist/components/organisms/ModerationQueue/ModerationQueue.d.ts +40 -1
- package/dist/components/organisms/ModerationQueue/ModerationQueue.js +262 -237
- package/dist/components/organisms/ModerationQueue/QueueEditDialog.cjs +1 -1
- package/dist/components/organisms/ModerationQueue/QueueEditDialog.d.ts +1 -1
- package/dist/components/organisms/ModerationQueue/QueueEditDialog.js +23 -21
- package/dist/components/organisms/ModerationQueue/QueueEditSheet.cjs +1 -1
- package/dist/components/organisms/ModerationQueue/QueueEditSheet.d.ts +1 -1
- package/dist/components/organisms/ModerationQueue/QueueEditSheet.js +22 -20
- package/dist/components/organisms/ModerationQueue/queue-actions.d.ts +29 -10
- package/dist/components/organisms/Navbar/Navbar.cjs +1 -1
- package/dist/components/organisms/Navbar/Navbar.d.ts +38 -3
- package/dist/components/organisms/Navbar/Navbar.js +210 -187
- package/dist/components/organisms/Navbar/navbar-variants.cjs +1 -1
- package/dist/components/organisms/Navbar/navbar-variants.js +4 -2
- package/dist/components/organisms/Sheet/Sheet.cjs +1 -1
- package/dist/components/organisms/Sheet/Sheet.d.ts +8 -1
- package/dist/components/organisms/Sheet/Sheet.js +65 -63
- package/dist/lib/labels.cjs +1 -0
- package/dist/lib/labels.d.ts +7 -0
- package/dist/lib/labels.js +12 -0
- package/dist/meta.json +3 -3
- package/dist/roster.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -113,6 +113,12 @@ import "@blakesteve/roster/style.css";
|
|
|
113
113
|
Skip it and components render against browser defaults: serif type, bulleted
|
|
114
114
|
lists, and `content-box` sizing.
|
|
115
115
|
|
|
116
|
+
One default Roster does undo itself: a `<button>`'s own border. A `link` or
|
|
117
|
+
`soft` Button sets its border to zero (`soft` since 5.8.0). In an app without a
|
|
118
|
+
reset, `link` drew the browser's 2px border, and `soft` kept it, transparent,
|
|
119
|
+
which took 4px of extra room and showed in forced colors. Zero is what an app
|
|
120
|
+
with Tailwind's reset already had, so no layout moves.
|
|
121
|
+
|
|
116
122
|
### Dark mode
|
|
117
123
|
|
|
118
124
|
Every component reads a `.dark` class on an ancestor, so dark mode is whatever
|
|
@@ -452,8 +458,15 @@ the supported way now.
|
|
|
452
458
|
rule stops matching.** Solid Button, Badge, Pill and Checkbox no longer carry
|
|
453
459
|
`rst:text-white` or `rst:text-gray-950`, so a selector naming either matches
|
|
454
460
|
nothing. It fails silently, and it fails *partially*: those classes are still on
|
|
455
|
-
`
|
|
456
|
-
|
|
461
|
+
`ActionBar`, `Avatar` and `Breadcrumbs`, so a themed foreground keeps working
|
|
462
|
+
there while reverting on every solid control. The `primary` fills of `Card`,
|
|
463
|
+
`Dialog` and, since 5.8.0, `Navbar` read their ink token too: Navbar's bar,
|
|
464
|
+
brand and active link take `--roster-primary-700-ink`, and its other links and
|
|
465
|
+
menu button the same ink at 80%. Each keeps white in dark mode, where its fill
|
|
466
|
+
is a dark step the ink doesn't describe. A primary Navbar looks different even
|
|
467
|
+
with no ink set: its links were `gray-300` and its active link `primary-400`,
|
|
468
|
+
which was 4.04:1 on Roster's own primary, under the 4.5 text needs. Now they
|
|
469
|
+
are white at 80% and white, the active one still semibold.
|
|
457
470
|
Replace the rule with the token:
|
|
458
471
|
|
|
459
472
|
```css
|
|
@@ -1258,6 +1271,12 @@ app supplies, inline by default or in a Dialog or Sheet (`QueueEditDialog`,
|
|
|
1258
1271
|
`QueueEditSheet`, separate exports so a queue that doesn't use them doesn't
|
|
1259
1272
|
ship them).
|
|
1260
1273
|
|
|
1274
|
+
**A reason outranks a confirm.** An action with both asks the reason's
|
|
1275
|
+
question, and its submit button is the confirmation. A `required` reason asks
|
|
1276
|
+
for one of its `options`, so the types refuse `required` without them: a
|
|
1277
|
+
reason that is only a note is `note: "required"`. That makes `QueueReasonStep`
|
|
1278
|
+
a type rather than an interface (5.8.0), so extend it with `&`, not `extends`.
|
|
1279
|
+
|
|
1261
1280
|
**Drafts are typed.** An edit's draft is whatever its `initial` returns, and
|
|
1262
1281
|
`validate`, the form and `run` all get that type. Inside JSX, pass `actions` as
|
|
1263
1282
|
a function and write edits with the `edit` it's handed, as above; outside it,
|
|
@@ -1623,6 +1642,65 @@ well as `next/link`, plus `className`, `children`, `aria-current`, `onClick` and
|
|
|
1623
1642
|
`Eyebrow` takes the other approach: `as` accepts any element and the props
|
|
1624
1643
|
follow it, so `<Eyebrow as="a" href="/work">` works, as does `as={NextLink}`.
|
|
1625
1644
|
|
|
1645
|
+
### Every built-in word is replaceable
|
|
1646
|
+
|
|
1647
|
+
Where a component writes words of its own (a close button's name, a menu
|
|
1648
|
+
button's, "Log In", a sentence a screen reader hears), each can be replaced
|
|
1649
|
+
and defaults to English. Most components take a `labels` prop; pass any entry
|
|
1650
|
+
and the rest stay:
|
|
1651
|
+
|
|
1652
|
+
```tsx
|
|
1653
|
+
<Navbar labels={{ openMainMenu: t("nav.open"), closeMainMenu: t("nav.close") }} … />
|
|
1654
|
+
<Sheet labels={{ close: t("common.close") }} … />
|
|
1655
|
+
<Countdown labels={{ days: (n) => t("units.days", { count: n }) }} … />
|
|
1656
|
+
```
|
|
1657
|
+
|
|
1658
|
+
Since 5.8.0 that covers `Navbar`, `Sheet`, `Dialog`, `Breadcrumbs`, `Footer`,
|
|
1659
|
+
`CallToAction`, `AvatarStrip`, `ErrorState`, `Countdown`, `Carousel` and
|
|
1660
|
+
`ModerationQueue` (whose `labels.close` names the close button of its edit
|
|
1661
|
+
Dialog or Sheet), alongside `Pagination`, the loading system and DataTable's
|
|
1662
|
+
`paginationLabels`. A few components name their words with single props
|
|
1663
|
+
instead, and 5.8.0 adds the ones that were missing: MultiSelect's
|
|
1664
|
+
`countLabel`, DataTable's `emptyMessage` and MediaPreview's `newTabLabel`, next
|
|
1665
|
+
to the existing `dismissLabel`, `placeholder`, `removeLabel`, `prevLabel` and
|
|
1666
|
+
the like. Words that take a number or a name are functions, so a language
|
|
1667
|
+
whose word changes with the count can say so. An entry passed as `undefined`
|
|
1668
|
+
(a catalog missing a key) keeps its English rather than leaving a control
|
|
1669
|
+
unnamed.
|
|
1670
|
+
|
|
1671
|
+
`src/labels.test.tsx` renders each of these, in the states where its words
|
|
1672
|
+
appear, with every word pseudo-localized, and fails on any English left. A
|
|
1673
|
+
default it can't reach: `Avatar`'s alt is "Avatar" unless you pass one (`""`
|
|
1674
|
+
marks it decorative, since 5.8.0), and a team without a name in
|
|
1675
|
+
`MatchupCard` is "Team" and its id.
|
|
1676
|
+
|
|
1677
|
+
**From a server component, pass only strings.** Every component is a client
|
|
1678
|
+
component, and functions can't cross the React Server Component boundary, so a
|
|
1679
|
+
function label (Footer's `copyright`, Countdown's units) has to be passed from
|
|
1680
|
+
a `"use client"` wrapper, as `linkComponent` does above.
|
|
1681
|
+
|
|
1682
|
+
### Eyebrow and Stat line height
|
|
1683
|
+
|
|
1684
|
+
An `Eyebrow`'s line is as tall as its letters, and so is a `Stat`'s figure and
|
|
1685
|
+
its label. Through 5.7.0 neither was: `leading-none` sat before the font size
|
|
1686
|
+
in their variant tables, and `cn()`'s tailwind-merge drops a line height that
|
|
1687
|
+
comes before a size. An Eyebrow drew a line 1.5 times its size (15px for the
|
|
1688
|
+
default `xs`, not 10), and a Stat's figure and label drew lines taller than
|
|
1689
|
+
their type.
|
|
1690
|
+
|
|
1691
|
+
**Upgrading to 5.8.0 moves layouts.** An Eyebrow that makes its own line, as
|
|
1692
|
+
a flex or grid item or rendered as a block (`as="p"`, `as="h2"`), is a third
|
|
1693
|
+
shorter: 10px for `xs`, not 15. One inline in running text sits on its
|
|
1694
|
+
parent's line and doesn't change. A Stat in its default markup loses more:
|
|
1695
|
+
its figure's line was the size's own (28px for `sm`'s 20px figure) or the
|
|
1696
|
+
page's 1.5 (`md`, `lg`), and its label sat on the page's line (24px on a 16px,
|
|
1697
|
+
1.5 body). So a `sm` Stat goes from 55px tall to 33, and an `lg` one at 48px
|
|
1698
|
+
from 99 to 61. In the `standalone` markup only the label moves, 15px to 10.
|
|
1699
|
+
`LabeledDivider` sets its label in an Eyebrow of its own, so every rule is 5px
|
|
1700
|
+
shorter whatever label it's given. An Eyebrow that wraps now sets solid, its
|
|
1701
|
+
lines as close as its size. Spacing an app tuned against the old lines (a
|
|
1702
|
+
margin that cleared them) may want retuning.
|
|
1703
|
+
|
|
1626
1704
|
## Quick start
|
|
1627
1705
|
|
|
1628
1706
|
```tsx
|
|
@@ -1715,11 +1793,13 @@ function App() {
|
|
|
1715
1793
|
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1716
1794
|
| `ActionBar` | Sticky bottom action strip |
|
|
1717
1795
|
| `Countdown` | Live countdown timer |
|
|
1718
|
-
| `DataTable` |
|
|
1796
|
+
| `DataTable` | Table with sorting and paging via TanStack Table v9. Its pager is built on `Pagination` (since 5.6.0, the arrows layout), worded through `paginationLabels`; the page size is fixed at 10, with no prop to change it yet. Imported from `@blakesteve/roster/data-table` (see [DataTable columns](#datatable-columns)) |
|
|
1719
1797
|
| `Dialog` | Modal dialog; `onAfterClose` runs once it has finished closing |
|
|
1720
1798
|
| `Footer` | Site footer |
|
|
1721
1799
|
| `ModerationQueue` | Items waiting for a decision: busy per action, confirm, reason and edit steps, focus after an item leaves, a live region. Never fetches (see [ModerationQueue](#moderationqueue)) |
|
|
1722
|
-
| `
|
|
1800
|
+
| `QueueEditDialog` | A ModerationQueue edit step in a Dialog: pass it as an edit's `surface`. A separate export, so a queue that never uses it doesn't ship it |
|
|
1801
|
+
| `QueueEditSheet` | A ModerationQueue edit step in a Sheet, for a long form: pass it as an edit's `surface`. A separate export, like `QueueEditDialog` |
|
|
1802
|
+
| `Navbar` | Responsive navigation bar with mobile slide-out. A wide logo keeps its own proportions through `logoHeight` and `logoWidth`; its built-in words are in `labels` |
|
|
1723
1803
|
| `Sheet` | Bottom sheet: drag, Escape or backdrop to dismiss; only its content scrolls; returns focus, even from a deep link; the title may be a node |
|
|
1724
1804
|
| `Table` | Static data table |
|
|
1725
1805
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("react"),o=require("../../../lib/utils.cjs"),h=require("./avatar-variants.cjs"),t=require("../../../node_modules/@headlessui/react/dist/components/popover/popover.cjs"),i=n.forwardRef(({className:c,size:l,colorScheme:u,shape:d,initials:g,src:s,alt:v,title:e,...m},f)=>{const[p,b]=n.useState(!1),x=s&&!p,a=r.jsx("div",{ref:f,className:o.cn(h.avatarVariants({size:l,colorScheme:u,shape:d}),c),...m,children:x?r.jsx("img",{src:s,alt:v
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("react"),o=require("../../../lib/utils.cjs"),h=require("./avatar-variants.cjs"),t=require("../../../node_modules/@headlessui/react/dist/components/popover/popover.cjs"),i=n.forwardRef(({className:c,size:l,colorScheme:u,shape:d,initials:g,src:s,alt:v,title:e,...m},f)=>{const[p,b]=n.useState(!1),x=s&&!p,a=r.jsx("div",{ref:f,className:o.cn(h.avatarVariants({size:l,colorScheme:u,shape:d}),c),...m,children:x?r.jsx("img",{src:s,alt:v??"Avatar",className:"rst:h-full rst:w-full rst:object-cover",onError:()=>b(!0)}):r.jsx("span",{className:"rst:leading-none rst:uppercase",children:g?.slice(0,2)})});return e?r.jsxs(t.Popover,{className:"rst:relative rst:inline-flex",children:[r.jsx(t.PopoverButton,{as:"div",className:"rst:cursor-pointer rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background rst:rounded-full",children:a}),r.jsx(t.PopoverPanel,{anchor:"bottom",className:o.cn("rst:z-50 rst:mt-2 rst:rounded-md rst:px-3 rst:py-1.5 rst:text-xs rst:font-medium rst:elevation-anchored rst:backdrop-blur-md rst:ring","rst:bg-gray-900/95 rst:text-white rst:ring-black/5 rst:dark:bg-gray-100/95 rst:dark:text-gray-900 rst:dark:ring-white/20","rst:transition rst:duration-200 rst:ease-in-out rst:data-closed:opacity-0 rst:data-closed:translate-y-1"),children:e})]}):a});i.displayName="Avatar";exports.Avatar=i;
|
|
@@ -4,6 +4,10 @@ import { avatarVariants } from './avatar-variants';
|
|
|
4
4
|
export interface AvatarProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof avatarVariants> {
|
|
5
5
|
initials?: string;
|
|
6
6
|
src?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The photo's text alternative. Defaults to "Avatar"; pass the person's
|
|
9
|
+
* name, or `""` where the avatar sits beside a name that already says who.
|
|
10
|
+
*/
|
|
7
11
|
alt?: string;
|
|
8
12
|
title?: string;
|
|
9
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("../../../lib/utils.cjs"),y=require("../../../lib/labels.cjs"),b=require("../Avatar/Avatar.cjs"),k={dismiss:"Dismiss",more:s=>`${s} more`};function m({items:s,maxDisplay:l=5,totalCount:n,excludeKey:c,onDismiss:o,trailingSlot:d,label:h,ringClass:v="rst:ring-white rst:dark:ring-gray-900",labels:f,className:g}){const x=y.withLabels(k,f),e=s.filter(t=>t.key!==c).slice(0,l),a=n!==void 0?Math.max(0,n-e.length):Math.max(0,s.filter(t=>t.key!==c).length-l);return e.length===0&&!d?null:r.jsxs("div",{"data-testid":"avatar-strip",className:i.cn("rst:font-ui rst:flex rst:items-center rst:gap-3",g),children:[o&&r.jsx("button",{type:"button",onClick:o,"aria-label":x.dismiss,"data-testid":"avatar-strip-dismiss",className:"rst:shrink-0 rst:text-gray-400/50 rst:dark:text-gray-500/50 rst:hover:text-gray-400 rst:dark:hover:text-gray-500 rst:transition-colors rst:cursor-pointer",children:"✕"}),r.jsxs("div",{"data-testid":"avatar-strip-stack",className:"rst:flex rst:items-center rst:-space-x-2",children:[e.map(t=>{const u=r.jsx(b.Avatar,{initials:t.label[0].toUpperCase(),src:t.src,alt:t.label,colorScheme:t.colorScheme??"neutral",size:"xs"}),p=i.cn("rst:relative rst:inline-flex rst:h-6 rst:w-6 rst:rounded-full rst:ring-2 rst:transition-transform rst:hover:z-10 rst:hover:scale-110",v);return t.href?r.jsx("a",{href:t.href,title:t.label,"data-testid":`avatar-strip-item-${t.key}`,className:p,children:u},t.key):r.jsx("span",{title:t.label,"data-testid":`avatar-strip-item-${t.key}`,className:p,children:u},t.key)}),a>0&&r.jsx("div",{title:x.more(a),"data-testid":"avatar-strip-overflow",className:i.cn("rst:relative rst:flex rst:h-6 rst:w-6 rst:items-center rst:justify-center rst:rounded-full rst:bg-gray-500/10 rst:ring-2",v),children:r.jsxs("span",{className:"rst:text-[9px] rst:font-bold rst:text-gray-500 rst:dark:text-gray-400 rst:select-none",children:["+",a]})}),d]}),h&&r.jsx("div",{"data-testid":"avatar-strip-label",children:h})]})}exports.AvatarStrip=m;
|
|
@@ -12,6 +12,13 @@ export interface AvatarStripItem {
|
|
|
12
12
|
/** When provided, the avatar is wrapped in an `<a>` tag with this href. */
|
|
13
13
|
href?: string;
|
|
14
14
|
}
|
|
15
|
+
/** Every word AvatarStrip says of its own. Pass any of them in `labels` to replace it. */
|
|
16
|
+
export interface AvatarStripLabels {
|
|
17
|
+
/** The dismiss button's name, with `onDismiss`. */
|
|
18
|
+
dismiss: string;
|
|
19
|
+
/** The overflow chip's title: how many more there are. */
|
|
20
|
+
more: (count: number) => string;
|
|
21
|
+
}
|
|
15
22
|
export interface AvatarStripProps {
|
|
16
23
|
/** Ordered list of avatar items. */
|
|
17
24
|
items: AvatarStripItem[];
|
|
@@ -35,6 +42,8 @@ export interface AvatarStripProps {
|
|
|
35
42
|
trailingSlot?: ReactNode;
|
|
36
43
|
/** Rendered to the right of the avatar stack. Accepts any React node. */
|
|
37
44
|
label?: ReactNode;
|
|
45
|
+
/** The component's own words, replaced; any left out stay English. */
|
|
46
|
+
labels?: Partial<AvatarStripLabels>;
|
|
38
47
|
/**
|
|
39
48
|
* Tailwind class that sets the ring color around each avatar and the overflow chip.
|
|
40
49
|
* Should match the background the strip is rendered on to produce the cutout stack effect.
|
|
@@ -56,4 +65,4 @@ export interface AvatarStripProps {
|
|
|
56
65
|
*
|
|
57
66
|
* Returns `null` when there are no visible items and no `trailingSlot`.
|
|
58
67
|
*/
|
|
59
|
-
export declare function AvatarStrip({ items, maxDisplay, totalCount, excludeKey, onDismiss, trailingSlot, label, ringClass, className, }: AvatarStripProps): import("react/jsx-runtime").JSX.Element | null;
|
|
68
|
+
export declare function AvatarStrip({ items, maxDisplay, totalCount, excludeKey, onDismiss, trailingSlot, label, ringClass, labels, className, }: AvatarStripProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,54 +1,58 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { cn as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { jsxs as i, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { cn as l } from "../../../lib/utils.js";
|
|
4
|
+
import { withLabels as y } from "../../../lib/labels.js";
|
|
5
|
+
import { Avatar as k } from "../Avatar/Avatar.js";
|
|
6
|
+
const b = { dismiss: "Dismiss", more: (s) => `${s} more` };
|
|
7
|
+
function L({
|
|
8
|
+
items: s,
|
|
7
9
|
maxDisplay: n = 5,
|
|
8
|
-
totalCount:
|
|
9
|
-
excludeKey:
|
|
10
|
+
totalCount: o,
|
|
11
|
+
excludeKey: c,
|
|
10
12
|
onDismiss: d,
|
|
11
13
|
trailingSlot: h,
|
|
12
|
-
label:
|
|
13
|
-
ringClass:
|
|
14
|
-
|
|
14
|
+
label: p,
|
|
15
|
+
ringClass: v = "rst:ring-white rst:dark:ring-gray-900",
|
|
16
|
+
labels: g,
|
|
17
|
+
className: u
|
|
15
18
|
}) {
|
|
16
|
-
const
|
|
17
|
-
return
|
|
19
|
+
const f = y(b, g), e = s.filter((t) => t.key !== c).slice(0, n), a = o !== void 0 ? Math.max(0, o - e.length) : Math.max(0, s.filter((t) => t.key !== c).length - n);
|
|
20
|
+
return e.length === 0 && !h ? null : /* @__PURE__ */ i(
|
|
18
21
|
"div",
|
|
19
22
|
{
|
|
20
23
|
"data-testid": "avatar-strip",
|
|
21
|
-
className:
|
|
24
|
+
className: l("rst:font-ui rst:flex rst:items-center rst:gap-3", u),
|
|
22
25
|
children: [
|
|
23
26
|
d && /* @__PURE__ */ r(
|
|
24
27
|
"button",
|
|
25
28
|
{
|
|
26
29
|
type: "button",
|
|
27
30
|
onClick: d,
|
|
28
|
-
"aria-label":
|
|
31
|
+
"aria-label": f.dismiss,
|
|
29
32
|
"data-testid": "avatar-strip-dismiss",
|
|
30
33
|
className: "rst:shrink-0 rst:text-gray-400/50 rst:dark:text-gray-500/50 rst:hover:text-gray-400 rst:dark:hover:text-gray-500 rst:transition-colors rst:cursor-pointer",
|
|
31
34
|
children: "✕"
|
|
32
35
|
}
|
|
33
36
|
),
|
|
34
|
-
/* @__PURE__ */
|
|
37
|
+
/* @__PURE__ */ i(
|
|
35
38
|
"div",
|
|
36
39
|
{
|
|
37
40
|
"data-testid": "avatar-strip-stack",
|
|
38
41
|
className: "rst:flex rst:items-center rst:-space-x-2",
|
|
39
42
|
children: [
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
+
e.map((t) => {
|
|
44
|
+
const m = /* @__PURE__ */ r(
|
|
45
|
+
k,
|
|
43
46
|
{
|
|
44
47
|
initials: t.label[0].toUpperCase(),
|
|
45
48
|
src: t.src,
|
|
49
|
+
alt: t.label,
|
|
46
50
|
colorScheme: t.colorScheme ?? "neutral",
|
|
47
51
|
size: "xs"
|
|
48
52
|
}
|
|
49
|
-
), x =
|
|
53
|
+
), x = l(
|
|
50
54
|
"rst:relative rst:inline-flex rst:h-6 rst:w-6 rst:rounded-full rst:ring-2 rst:transition-transform rst:hover:z-10 rst:hover:scale-110",
|
|
51
|
-
|
|
55
|
+
v
|
|
52
56
|
);
|
|
53
57
|
return t.href ? /* @__PURE__ */ r(
|
|
54
58
|
"a",
|
|
@@ -57,7 +61,7 @@ function b({
|
|
|
57
61
|
title: t.label,
|
|
58
62
|
"data-testid": `avatar-strip-item-${t.key}`,
|
|
59
63
|
className: x,
|
|
60
|
-
children:
|
|
64
|
+
children: m
|
|
61
65
|
},
|
|
62
66
|
t.key
|
|
63
67
|
) : /* @__PURE__ */ r(
|
|
@@ -66,23 +70,23 @@ function b({
|
|
|
66
70
|
title: t.label,
|
|
67
71
|
"data-testid": `avatar-strip-item-${t.key}`,
|
|
68
72
|
className: x,
|
|
69
|
-
children:
|
|
73
|
+
children: m
|
|
70
74
|
},
|
|
71
75
|
t.key
|
|
72
76
|
);
|
|
73
77
|
}),
|
|
74
|
-
|
|
78
|
+
a > 0 && /* @__PURE__ */ r(
|
|
75
79
|
"div",
|
|
76
80
|
{
|
|
77
|
-
title:
|
|
81
|
+
title: f.more(a),
|
|
78
82
|
"data-testid": "avatar-strip-overflow",
|
|
79
|
-
className:
|
|
83
|
+
className: l(
|
|
80
84
|
"rst:relative rst:flex rst:h-6 rst:w-6 rst:items-center rst:justify-center rst:rounded-full rst:bg-gray-500/10 rst:ring-2",
|
|
81
|
-
|
|
85
|
+
v
|
|
82
86
|
),
|
|
83
|
-
children: /* @__PURE__ */
|
|
87
|
+
children: /* @__PURE__ */ i("span", { className: "rst:text-[9px] rst:font-bold rst:text-gray-500 rst:dark:text-gray-400 rst:select-none", children: [
|
|
84
88
|
"+",
|
|
85
|
-
|
|
89
|
+
a
|
|
86
90
|
] })
|
|
87
91
|
}
|
|
88
92
|
),
|
|
@@ -90,11 +94,11 @@ function b({
|
|
|
90
94
|
]
|
|
91
95
|
}
|
|
92
96
|
),
|
|
93
|
-
|
|
97
|
+
p && /* @__PURE__ */ r("div", { "data-testid": "avatar-strip-label", children: p })
|
|
94
98
|
]
|
|
95
99
|
}
|
|
96
100
|
);
|
|
97
101
|
}
|
|
98
102
|
export {
|
|
99
|
-
|
|
103
|
+
L as AvatarStrip
|
|
100
104
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../../node_modules/class-variance-authority/dist/index.cjs"),t=r.cva("rst:font-ui rst:inline-flex rst:items-center rst:justify-center rst:cursor-pointer rst:whitespace-nowrap rst:rounded-md rst:text-sm rst:font-medium rst:ring-offset-background rst:transition-colors rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:disabled:pointer-events-none rst:disabled:opacity-50",{variants:{variant:{solid:"rst:border rst:border-transparent rst:elevation-control",soft:"rst:border-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../../node_modules/class-variance-authority/dist/index.cjs"),t=r.cva("rst:font-ui rst:inline-flex rst:items-center rst:justify-center rst:cursor-pointer rst:whitespace-nowrap rst:rounded-md rst:text-sm rst:font-medium rst:ring-offset-background rst:transition-colors rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:disabled:pointer-events-none rst:disabled:opacity-50",{variants:{variant:{solid:"rst:border rst:border-transparent rst:elevation-control",soft:"rst:border-0 rst:shadow-none",outline:"rst:border rst:bg-transparent rst:elevation-control",ghost:"rst:border rst:border-transparent rst:bg-transparent",link:"rst:border-0 rst:bg-transparent rst:underline-offset-4 rst:hover:underline"},colorScheme:{primary:"",orange:"",teal:"",purple:"",amber:"",success:"",error:"",neutral:""},size:{xs:"rst:h-7 rst:rounded-sm rst:px-2 rst:text-xs",sm:"rst:h-9 rst:rounded-md rst:px-3",default:"rst:h-10 rst:px-4 rst:py-2",lg:"rst:h-11 rst:rounded-md rst:px-8",icon:"rst:h-10 rst:w-10"}},compoundVariants:[{variant:"solid",colorScheme:"primary",className:"rst:bg-primary-600 rst:hover:bg-primary-700 rst:dark:bg-primary-600 rst:dark:hover:bg-primary-500 rst:text-primary-600-ink rst:hover:text-primary-700-ink rst:dark:hover:text-primary-500-ink"},{variant:"solid",colorScheme:"orange",className:"rst:bg-orange-600 rst:hover:bg-orange-700 rst:dark:bg-orange-600 rst:dark:hover:bg-orange-700 rst:text-orange-600-ink rst:hover:text-orange-700-ink rst:dark:hover:text-orange-700-ink"},{variant:"solid",colorScheme:"teal",className:"rst:bg-teal-600 rst:hover:bg-teal-500 rst:dark:bg-teal-600 rst:dark:hover:bg-teal-500 rst:text-teal-600-ink rst:hover:text-teal-500-ink rst:dark:hover:text-teal-500-ink"},{variant:"solid",colorScheme:"purple",className:"rst:bg-purple-600 rst:hover:bg-purple-700 rst:dark:bg-purple-600 rst:dark:hover:bg-purple-700 rst:text-purple-600-ink rst:hover:text-purple-700-ink rst:dark:hover:text-purple-700-ink"},{variant:"solid",colorScheme:"amber",className:"rst:bg-amber-400 rst:hover:bg-amber-500 rst:dark:bg-amber-500 rst:dark:hover:bg-amber-400 rst:text-amber-400-ink rst:hover:text-amber-500-ink rst:dark:text-amber-500-ink rst:dark:hover:text-amber-400-ink"},{variant:"solid",colorScheme:"success",className:"rst:bg-success-600 rst:hover:bg-success-700 rst:dark:bg-success-600 rst:dark:hover:bg-success-700 rst:text-success-600-ink rst:hover:text-success-700-ink rst:dark:hover:text-success-700-ink"},{variant:"solid",colorScheme:"error",className:"rst:bg-error-600 rst:hover:bg-error-700 rst:dark:bg-error-600 rst:dark:hover:bg-error-500 rst:text-error-600-ink rst:hover:text-error-700-ink rst:dark:hover:text-error-500-ink"},{variant:"solid",colorScheme:"neutral",className:"rst:bg-gray-600 rst:hover:bg-gray-700 rst:dark:bg-gray-600 rst:dark:hover:bg-gray-500 rst:text-gray-600-ink rst:hover:text-gray-700-ink rst:dark:hover:text-gray-500-ink"},{variant:"soft",colorScheme:"primary",className:"rst:bg-primary-50 rst:text-primary-700 rst:hover:bg-primary-100 rst:dark:bg-primary-900/40 rst:dark:text-primary-300 rst:dark:hover:bg-primary-900/60"},{variant:"soft",colorScheme:"orange",className:"rst:bg-orange-50 rst:text-orange-700 rst:hover:bg-orange-100 rst:dark:bg-orange-900/30 rst:dark:text-orange-300 rst:dark:hover:bg-orange-900/50"},{variant:"soft",colorScheme:"teal",className:"rst:bg-teal-100 rst:text-teal-800 rst:hover:bg-teal-200 rst:dark:bg-teal-900/30 rst:dark:text-teal-300 rst:dark:hover:bg-teal-900/50"},{variant:"soft",colorScheme:"purple",className:"rst:bg-purple-50 rst:text-purple-700 rst:hover:bg-purple-100 rst:dark:bg-purple-900/30 rst:dark:text-purple-300 rst:dark:hover:bg-purple-900/50"},{variant:"soft",colorScheme:"amber",className:"rst:bg-amber-50 rst:text-amber-800 rst:hover:bg-amber-100 rst:dark:bg-amber-900/30 rst:dark:text-amber-300 rst:dark:hover:bg-amber-900/50"},{variant:"soft",colorScheme:"success",className:"rst:bg-success-50 rst:text-success-700 rst:hover:bg-success-100 rst:dark:bg-success-900/30 rst:dark:text-success-300 rst:dark:hover:bg-success-900/50"},{variant:"soft",colorScheme:"error",className:"rst:bg-error-50 rst:text-error-700 rst:hover:bg-error-100 rst:dark:bg-error-900/30 rst:dark:text-error-300 rst:dark:hover:bg-error-900/50"},{variant:"soft",colorScheme:"neutral",className:"rst:bg-gray-100 rst:text-gray-700 rst:hover:bg-gray-200 rst:dark:bg-gray-800/50 rst:dark:text-gray-300 rst:dark:hover:bg-gray-800"},{variant:"outline",colorScheme:"primary",className:"rst:border-primary-600 rst:text-primary-600 rst:hover:bg-primary-50 rst:dark:border-primary-500 rst:dark:text-primary-400 rst:dark:hover:bg-primary-500/10"},{variant:"outline",colorScheme:"orange",className:"rst:border-orange-600 rst:text-orange-600 rst:hover:bg-orange-50 rst:dark:border-orange-500 rst:dark:text-orange-400 rst:dark:hover:bg-orange-500/10"},{variant:"outline",colorScheme:"teal",className:"rst:border-teal-600 rst:text-teal-600 rst:hover:bg-teal-50 rst:dark:border-teal-500 rst:dark:text-teal-400 rst:dark:hover:bg-teal-500/10"},{variant:"outline",colorScheme:"purple",className:"rst:border-purple-600 rst:text-purple-600 rst:hover:bg-purple-50 rst:dark:border-purple-500 rst:dark:text-purple-400 rst:dark:hover:bg-purple-500/10"},{variant:"outline",colorScheme:"amber",className:"rst:border-amber-600 rst:text-amber-600 rst:hover:bg-amber-50 rst:dark:border-amber-500 rst:dark:text-amber-400 rst:dark:hover:bg-amber-500/10"},{variant:"outline",colorScheme:"success",className:"rst:border-success-600 rst:text-success-600 rst:hover:bg-success-50 rst:dark:border-success-500 rst:dark:text-success-400 rst:dark:hover:bg-success-500/10"},{variant:"outline",colorScheme:"error",className:"rst:border-error-600 rst:text-error-600 rst:hover:bg-error-50 rst:dark:border-error-500 rst:dark:text-error-400 rst:dark:hover:bg-error-500/10"},{variant:"outline",colorScheme:"neutral",className:"rst:border-gray-300 rst:text-gray-700 rst:hover:bg-gray-50 rst:dark:border-gray-600 rst:dark:text-gray-300 rst:dark:hover:bg-gray-800/50"},{variant:"ghost",colorScheme:"primary",className:"rst:text-primary-600 rst:hover:bg-primary-500/10 rst:dark:text-primary-400 rst:dark:hover:bg-primary-400/15"},{variant:"ghost",colorScheme:"orange",className:"rst:text-orange-600 rst:hover:bg-orange-500/10 rst:dark:text-orange-400 rst:dark:hover:bg-orange-400/15"},{variant:"ghost",colorScheme:"teal",className:"rst:text-teal-600 rst:hover:bg-teal-500/10 rst:dark:text-teal-400 rst:dark:hover:bg-teal-400/15"},{variant:"ghost",colorScheme:"purple",className:"rst:text-purple-600 rst:hover:bg-purple-500/10 rst:dark:text-purple-400 rst:dark:hover:bg-purple-400/15"},{variant:"ghost",colorScheme:"amber",className:"rst:text-amber-600 rst:hover:bg-amber-500/10 rst:dark:text-amber-400 rst:dark:hover:bg-amber-400/15"},{variant:"ghost",colorScheme:"success",className:"rst:text-success-600 rst:hover:bg-success-500/10 rst:dark:text-success-400 rst:dark:hover:bg-success-400/15"},{variant:"ghost",colorScheme:"error",className:"rst:text-error-600 rst:hover:bg-error-500/10 rst:dark:text-error-400 rst:dark:hover:bg-error-400/15"},{variant:"ghost",colorScheme:"neutral",className:"rst:text-gray-600 rst:hover:bg-gray-500/10 rst:dark:text-gray-400 rst:dark:hover:bg-gray-400/15"},{variant:"link",colorScheme:"primary",className:"rst:text-primary-600 rst:hover:text-primary-700 rst:dark:text-primary-400 rst:dark:hover:text-primary-300"},{variant:"link",colorScheme:"orange",className:"rst:text-orange-600 rst:hover:text-orange-700 rst:dark:text-orange-400 rst:dark:hover:text-orange-300"},{variant:"link",colorScheme:"teal",className:"rst:text-teal-600 rst:hover:text-teal-700 rst:dark:text-teal-400 rst:dark:hover:text-teal-300"},{variant:"link",colorScheme:"purple",className:"rst:text-purple-600 rst:hover:text-purple-700 rst:dark:text-purple-400 rst:dark:hover:text-purple-300"},{variant:"link",colorScheme:"amber",className:"rst:text-amber-600 rst:hover:text-amber-700 rst:dark:text-amber-400 rst:dark:hover:text-amber-300"},{variant:"link",colorScheme:"success",className:"rst:text-success-600 rst:hover:text-success-700 rst:dark:text-success-400 rst:dark:hover:text-success-300"},{variant:"link",colorScheme:"error",className:"rst:text-error-600 rst:hover:text-error-700 rst:dark:text-error-400 rst:dark:hover:text-error-300"},{variant:"link",colorScheme:"neutral",className:"rst:text-gray-600 rst:hover:text-gray-900 rst:dark:text-gray-400 rst:dark:hover:text-gray-100"}],defaultVariants:{colorScheme:"primary",variant:"solid",size:"default"}});exports.buttonVariants=t;
|
|
@@ -6,11 +6,13 @@ const e = /* @__PURE__ */ r(
|
|
|
6
6
|
variants: {
|
|
7
7
|
variant: {
|
|
8
8
|
solid: "rst:border rst:border-transparent rst:elevation-control",
|
|
9
|
-
|
|
9
|
+
// `border-0`, here and on `link`: a <button> draws the browser's own
|
|
10
|
+
// border unless told otherwise, and an app without a reset would see
|
|
11
|
+
// it. Zero rather than the 1px the others have, because zero is what
|
|
12
|
+
// every app with a reset already draws: none of them moves.
|
|
13
|
+
soft: "rst:border-0 rst:shadow-none",
|
|
10
14
|
outline: "rst:border rst:bg-transparent rst:elevation-control",
|
|
11
15
|
ghost: "rst:border rst:border-transparent rst:bg-transparent",
|
|
12
|
-
// `border-0`: a <button> draws the browser's own border unless told
|
|
13
|
-
// otherwise, and an app without a reset would see it round a link.
|
|
14
16
|
link: "rst:border-0 rst:bg-transparent rst:underline-offset-4 rst:hover:underline"
|
|
15
17
|
},
|
|
16
18
|
colorScheme: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../node_modules/class-variance-authority/dist/index.cjs"),r=t.cva("rst:font-mono rst:uppercase
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../node_modules/class-variance-authority/dist/index.cjs"),r=t.cva("rst:font-mono rst:uppercase",{variants:{size:{xs:"rst:text-[0.625rem] rst:leading-none rst:tracking-[0.16em]",sm:"rst:text-[0.6875rem] rst:leading-none rst:tracking-[0.14em]",md:"rst:text-xs rst:leading-none rst:tracking-[0.12em]"},tone:{faint:"rst:text-gray-500 rst:dark:text-gray-400",default:"rst:text-gray-700 rst:dark:text-gray-300",strong:"rst:text-gray-900 rst:dark:text-gray-100",primary:"rst:text-primary-600 rst:dark:text-primary-400"},weight:{normal:"rst:font-normal",medium:"rst:font-medium",semibold:"rst:font-semibold"}},defaultVariants:{size:"xs",tone:"faint",weight:"normal"}});exports.eyebrowVariants=r;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { cva as t } from "../../../node_modules/class-variance-authority/dist/index.js";
|
|
2
2
|
const e = /* @__PURE__ */ t(
|
|
3
|
-
"rst:font-mono rst:uppercase
|
|
3
|
+
"rst:font-mono rst:uppercase",
|
|
4
4
|
{
|
|
5
5
|
variants: {
|
|
6
|
+
/* `leading-none` after each size, never before it: tailwind-merge
|
|
7
|
+
drops a line height that comes before a font size, because a size
|
|
8
|
+
can carry its own. Placed first, it was lost, and the line was 1.5
|
|
9
|
+
times the size instead of 1. */
|
|
6
10
|
size: {
|
|
7
|
-
xs: "rst:text-[0.625rem] rst:tracking-[0.16em]",
|
|
8
|
-
sm: "rst:text-[0.6875rem] rst:tracking-[0.14em]",
|
|
9
|
-
md: "rst:text-xs rst:tracking-[0.12em]"
|
|
11
|
+
xs: "rst:text-[0.625rem] rst:leading-none rst:tracking-[0.16em]",
|
|
12
|
+
sm: "rst:text-[0.6875rem] rst:leading-none rst:tracking-[0.14em]",
|
|
13
|
+
md: "rst:text-xs rst:leading-none rst:tracking-[0.12em]"
|
|
10
14
|
},
|
|
11
15
|
tone: {
|
|
12
16
|
faint: "rst:text-gray-500 rst:dark:text-gray-400",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),T=require("react"),W=require("../../../node_modules/@headlessui/react/dist/components/description/description.cjs"),X=require("../../../node_modules/@headlessui/react/dist/components/field/field.cjs"),G=require("../../../node_modules/@headlessui/react/dist/components/label/label.cjs"),h=require("../../../node_modules/@headlessui/react/dist/components/listbox/listbox.cjs"),J=require("../../../node_modules/@headlessui/react/dist/components/transition/transition.cjs"),F=require("../../../node_modules/@fortawesome/react-fontawesome/dist/index.cjs"),R=require("../../../node_modules/@fortawesome/free-solid-svg-icons/index.cjs"),n=require("../../../lib/utils.cjs"),_=require("../../../internal/field-invalid.cjs"),K=require("../Select/select-variants.cjs"),D=require("../Chip/Chip.cjs"),Q=require("../../../internal/PopupOption.cjs"),c=require("../../../internal/popup.cjs"),Z=({options:x,value:i,onChange:m,placeholder:v="Select options",disabled:l=!1,variant:f,size:o,error:L,className:A,triggerClassName:E,optionsClassName:U,helperText:b,errorMessage:p,label:g,display:u="chips",maxChips:N,clearable:j=!1,chipColorScheme:w="neutral",chipVariant:k="outline",clearLabel:$="Clear selection",removeLabel:C=e=>`Remove ${e}`,countLabel:I=e=>`${e} selected`,...P})=>{const e=!!p||L,V=_.isFieldInvalid(e,P),B=_.withoutInvalidProps(P),a=i.length>0,y=new Map(x.map((r,s)=>[r.value,s])),d=i.map(r=>({value:r,label:x.find(s=>s.value===r)?.label??String(r)})).sort((r,s)=>(y.get(r.value)??Number.POSITIVE_INFINITY)-(y.get(s.value)??Number.POSITIVE_INFINITY)),q=N===void 0?d:d.slice(0,N),O=d.length-q.length,{ref:H,inDarkScope:M}=c.useDarkScope(),S=T.useRef(null);return t.jsxs(X.Field,{disabled:l,className:n.cn("rst:flex rst:flex-col rst:gap-1.5",A),...B,children:[g&&t.jsx(G.Label,{className:"rst:block rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)] rst:text-left",children:g}),t.jsx(h.Listbox,{value:i,onChange:m,disabled:l,multiple:!0,children:t.jsxs("div",{ref:H,className:"rst:relative",children:[t.jsxs("div",{className:n.cn(K.selectTriggerVariants({variant:f,size:o,error:e}),"rst:h-auto rst:flex-wrap rst:items-center rst:gap-1.5 rst:py-1.5",o==="sm"?"rst:min-h-9":o==="lg"?"rst:min-h-11":"rst:min-h-10",j&&a&&"rst:pr-16","rst:focus-within:ring-[length:calc(var(--roster-border-width,1px)+1px)] rst:focus-within:ring-ring",l&&"rst:opacity-50 rst:cursor-not-allowed",E),children:[t.jsx(h.ListboxButton,{ref:S,"aria-invalid":V||void 0,className:"rst:absolute rst:inset-0 rst:h-full rst:w-full rst:cursor-pointer rst:rounded-md rst:focus:outline-hidden rst:disabled:cursor-not-allowed",children:t.jsx("span",{className:"rst:sr-only",children:a?u==="count"?I(i.length):d.map(r=>r.label).join(", "):v})}),!a&&t.jsx("span",{"aria-hidden":"true",className:"rst:pointer-events-none rst:relative rst:block rst:truncate rst:text-gray-500 rst:dark:text-gray-400",children:v}),a&&u==="count"&&t.jsx("span",{"aria-hidden":"true",className:"rst:pointer-events-none rst:relative rst:block rst:truncate",children:I(i.length)}),a&&u==="chips"&&q.map((r,s)=>t.jsx(D.Chip,{size:"sm",variant:k,colorScheme:w,disabled:l,onRemove:()=>m(i.filter(Y=>Y!==r.value)),removeLabel:C(r.label),className:n.cn("rst:relative rst:max-w-[12rem] rst:pointer-events-none","rst:[&_button]:pointer-events-auto","rst:text-inherit rst:border-current/70 rst:dark:text-inherit rst:dark:border-current/70"),children:t.jsx("span",{className:"rst:block rst:truncate",children:r.label})},`${s}-${String(r.value)}`)),O>0&&u==="chips"&&t.jsxs(D.Chip,{size:"sm",variant:k,colorScheme:w,"aria-hidden":"true",className:"rst:pointer-events-none rst:relative rst:text-inherit rst:border-current/70 rst:dark:text-inherit rst:dark:border-current/70",children:["+",O]}),t.jsx("span",{className:n.cn("rst:pointer-events-none rst:absolute rst:inset-y-0 rst:right-0 rst:flex rst:items-center",o==="sm"?"rst:pr-2.5":"rst:pr-3"),children:t.jsx(F.FontAwesomeIcon,{icon:R.faChevronDown,className:"rst:h-3.5 rst:w-3.5 rst:text-gray-400 rst:dark:text-gray-500","aria-hidden":"true"})}),j&&a&&t.jsx("button",{type:"button",disabled:l,onClick:()=>{m([]),S.current?.focus()},"aria-label":$,className:n.cn("rst:absolute rst:inset-y-0 rst:flex rst:w-6 rst:items-center rst:justify-center","rst:cursor-pointer rst:disabled:cursor-not-allowed","rst:text-current rst:opacity-70 rst:hover:opacity-100 rst:disabled:opacity-40","rst:focus:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:rounded-sm",o==="sm"?"rst:right-7":"rst:right-8"),children:t.jsx(F.FontAwesomeIcon,{icon:R.faXmark,className:"rst:h-3.5 rst:w-3.5","aria-hidden":"true"})})]}),t.jsx(J.Transition,{as:T.Fragment,leave:"rst:transition rst:ease-in rst:duration-100",leaveFrom:"rst:opacity-100",leaveTo:"rst:opacity-0",children:t.jsx(h.ListboxOptions,{anchor:c.POPUP_ANCHOR,className:n.cn(c.popupInDarkPalette(M,f)&&"dark",c.POPUP_PANEL,c.POPUP_WIDTH_OF_BUTTON,U),children:x.map(r=>t.jsx(Q.PopupOption,{as:h.ListboxOption,value:r.value,disabled:r.disabled,size:o,children:r.label},r.value))})})]})}),(b||p)&&t.jsx(W.Description,{className:n.cn("rst:text-xs rst:text-left",e?"rst:text-error-600 rst:dark:text-error-400 rst:font-medium":"rst:text-gray-500 rst:dark:text-gray-400"),children:p||b})]})};exports.MultiSelect=Z;
|
|
@@ -70,6 +70,8 @@ export interface MultiSelectProps extends Omit<React.HTMLAttributes<HTMLDivEleme
|
|
|
70
70
|
* tell apart, so this takes the label rather than being a constant.
|
|
71
71
|
*/
|
|
72
72
|
removeLabel?: (label: string) => string;
|
|
73
|
+
/** With `display="count"`, how many are chosen: "3 selected". Shown, and said. */
|
|
74
|
+
countLabel?: (count: number) => string;
|
|
73
75
|
}
|
|
74
|
-
declare const MultiSelect: ({ options, value, onChange, placeholder, disabled, variant, size, error, className, triggerClassName, optionsClassName, helperText, errorMessage, label, display, maxChips, clearable, chipColorScheme, chipVariant, clearLabel, removeLabel, ...props }: MultiSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
76
|
+
declare const MultiSelect: ({ options, value, onChange, placeholder, disabled, variant, size, error, className, triggerClassName, optionsClassName, helperText, errorMessage, label, display, maxChips, clearable, chipColorScheme, chipVariant, clearLabel, removeLabel, countLabel, ...props }: MultiSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
75
77
|
export { MultiSelect };
|