neba 1.1.0 → 1.2.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 +9 -6
- package/dist/components/avatar/Avatar.d.ts +100 -0
- package/dist/components/avatar/Avatar.js +1 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts +92 -0
- package/dist/components/breadcrumb/Breadcrumb.js +1 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/chat-bubble/ChatBubble.d.ts +114 -0
- package/dist/components/chat-bubble/ChatBubble.js +1 -0
- package/dist/components/chat-bubble/index.d.ts +2 -0
- package/dist/components/chat-bubble/index.js +1 -0
- package/dist/components/otp-field/OtpField.d.ts +85 -0
- package/dist/components/otp-field/OtpField.js +1 -0
- package/dist/components/otp-field/index.d.ts +2 -0
- package/dist/components/otp-field/index.js +1 -0
- package/dist/components/panes/Panes.d.ts +78 -0
- package/dist/components/panes/Panes.js +1 -0
- package/dist/components/panes/index.d.ts +2 -0
- package/dist/components/panes/index.js +1 -0
- package/dist/components/spoiler/Spoiler.d.ts +95 -0
- package/dist/components/spoiler/Spoiler.js +1 -0
- package/dist/components/spoiler/index.d.ts +2 -0
- package/dist/components/spoiler/index.js +1 -0
- package/dist/components/text-link/TextLink.d.ts +82 -0
- package/dist/components/text-link/TextLink.js +1 -0
- package/dist/components/text-link/index.d.ts +2 -0
- package/dist/components/text-link/index.js +1 -0
- package/dist/components/tree-view/TreeView.d.ts +115 -0
- package/dist/components/tree-view/TreeView.js +1 -0
- package/dist/components/tree-view/index.d.ts +2 -0
- package/dist/components/tree-view/index.js +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -1
- package/dist/internal/i18n.d.ts +78 -0
- package/dist/internal/i18n.js +1 -0
- package/dist/internal/icons.d.ts +23 -0
- package/dist/internal/icons.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +125 -0
- package/package.json +9 -9
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { NebaColor, NebaDensity, NebaElevation, NebaSize, NebaVariant } from '../../types';
|
|
3
|
+
export interface SpoilerProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'onChange'> {
|
|
4
|
+
/** Whether the content is uncovered. Pass it to drive the Spoiler yourself. */
|
|
5
|
+
revealed?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Where an uncontrolled Spoiler starts.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
defaultRevealed?: boolean;
|
|
11
|
+
/** Called when the reveal or hide button is pressed. */
|
|
12
|
+
onRevealedChange?: (revealed: boolean) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Which language the default label and notice are written in — a BCP 47 tag
|
|
15
|
+
* such as `ko`, `pt-BR` or `zh-Hant`. Unsupported tags fall back to English.
|
|
16
|
+
*
|
|
17
|
+
* Both strings can be written out instead, in `label` and `description`; this
|
|
18
|
+
* is for the far more common case where the page already knows its language
|
|
19
|
+
* and nobody should have to translate a button that says "Reveal".
|
|
20
|
+
*/
|
|
21
|
+
locale?: string;
|
|
22
|
+
/** The reveal button's label. Defaults to the `locale`'s word for it. */
|
|
23
|
+
label?: React.ReactNode;
|
|
24
|
+
/** The hide button's label, when `reversible` is on. */
|
|
25
|
+
hideLabel?: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* The line above the button, saying why the content is covered. Defaults to
|
|
28
|
+
* the `locale`'s wording; pass `false` for a cover with nothing written on it.
|
|
29
|
+
*/
|
|
30
|
+
description?: React.ReactNode | false;
|
|
31
|
+
/**
|
|
32
|
+
* Replaces the default reveal button entirely.
|
|
33
|
+
*
|
|
34
|
+
* The replacement is yours to wire up: pass `revealed` and
|
|
35
|
+
* `onRevealedChange` and drive it from your own control. `label` is the prop
|
|
36
|
+
* for the far commoner case of wanting different words on the button that is
|
|
37
|
+
* already there.
|
|
38
|
+
*/
|
|
39
|
+
action?: React.ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Keeps the content coverable: once revealed, a hide button appears under it.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
reversible?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Clamps the covered box to this height — a CSS length, or a number in
|
|
47
|
+
* pixels. Revealing releases it and the content takes whatever height it
|
|
48
|
+
* needs.
|
|
49
|
+
*
|
|
50
|
+
* Left out, the box is exactly as tall as what it holds, which is the right
|
|
51
|
+
* default for a paragraph or a picture. Set it for something long enough that
|
|
52
|
+
* a page of blurred content would be a page of nothing.
|
|
53
|
+
*/
|
|
54
|
+
maxHeight?: number | string;
|
|
55
|
+
/**
|
|
56
|
+
* How hard the content is blurred, in pixels.
|
|
57
|
+
* @default 10
|
|
58
|
+
*/
|
|
59
|
+
blur?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Inner padding around the content, on Box's own `size`/`density` scale. Turn
|
|
62
|
+
* it off for something that should reach the edges — a picture, a video.
|
|
63
|
+
* @default true
|
|
64
|
+
*/
|
|
65
|
+
padded?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Weight of the box's surface. `text` draws no box at all, which is what a
|
|
68
|
+
* spoiler sitting inside running prose usually wants.
|
|
69
|
+
* @default 'outline'
|
|
70
|
+
*/
|
|
71
|
+
variant?: NebaVariant;
|
|
72
|
+
/** The sheet's radius, and the size of the button on it. @default 'md' */
|
|
73
|
+
size?: NebaSize;
|
|
74
|
+
/** @default 'primary' */
|
|
75
|
+
color?: NebaColor;
|
|
76
|
+
/** Padding around the cover's own text and button. @default 'default' */
|
|
77
|
+
density?: NebaDensity;
|
|
78
|
+
/** Drop shadow depth. `0` (the default) is flat. @default 0 */
|
|
79
|
+
elevation?: NebaElevation;
|
|
80
|
+
/** What is being covered. */
|
|
81
|
+
children?: React.ReactNode;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Content that is covered until somebody asks for it.
|
|
85
|
+
*
|
|
86
|
+
* The cover is a blur rather than a `display: none`, which is the whole point:
|
|
87
|
+
* a reader can see that there is something there, roughly how much of it there
|
|
88
|
+
* is, and — with `maxHeight` — that it has been clamped. What they cannot do is
|
|
89
|
+
* read it by accident, which is the one thing a spoiler is for.
|
|
90
|
+
*
|
|
91
|
+
* While it is covered the content is `inert`, so it is not tabbable, not
|
|
92
|
+
* readable by a screen reader and not selectable by a drag across the page. A
|
|
93
|
+
* spoiler that could be defeated by Ctrl-A is not a spoiler.
|
|
94
|
+
*/
|
|
95
|
+
export declare const Spoiler: React.ForwardRefExoticComponent<SpoilerProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as i from"react";import{Button as n}from"../button/Button";import{useMessages as o}from"../../internal/i18n";import{boxPaddingClasses as a,boxPaddingXClasses as l,boxPaddingYClasses as t}from"../box/Box";import{hasContent as s,metaTextClasses as d,radiusClasses as c,surfaceClasses as m,surfaceSlots as v,transitionClasses as f}from"../../internal/styles";const p={solid:[m,"bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[m,"border bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"bg-transparent"},u="[background-color:color-mix(in_oklab,var(--neba-surface)_55%,transparent)]";export const Spoiler=i.forwardRef(function({revealed:m,defaultRevealed:b=!1,onRevealedChange:x,locale:h,label:j,hideLabel:g,description:y,action:w,reversible:N=!1,maxHeight:k,blur:z=10,padded:B=!0,variant:_="outline",size:C="md",color:R="primary",density:H="default",elevation:S=0,className:$,style:I,children:L,...q},A){const D=o(h),E=i.useId(),[F,G]=i.useState(b),J=m??F,K=e=>{void 0===m&&G(e),x?.(e)},M=!1===y?null:y??D.spoiler.notice;return r("div",{ref:A,className:["relative isolate overflow-hidden",c[C],p[_],f,$??""].filter(Boolean).join(" "),style:{...v(R,S),...I},...q,children:[e("div",{id:E,className:["min-w-0",B?a[H][C]:"","[transition:filter_var(--neba-duration-fill)_var(--neba-ease)]","motion-reduce:[transition-duration:0ms]",J?"":"select-none"].filter(Boolean).join(" "),style:{filter:J?void 0:`blur(${z}px)`,maxHeight:J?void 0:k,overflow:J?void 0:"hidden"},inert:!J,children:L}),J?null:r("div",{className:["absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 text-center",a[H][C],u].join(" "),children:[s(M)?e("p",{className:`m-0 text-(--neba-muted-fg) ${d[C]}`,children:M}):null,w??e(n,{size:C,color:R,density:H,onClick:()=>K(!0),"aria-expanded":!1,"aria-controls":E,children:j??D.spoiler.reveal})]}),J&&N?e("div",{className:["flex justify-end",l[H][C],t[H][C],"pt-0"].join(" "),children:e(n,{variant:"text",size:C,color:R,density:H,onClick:()=>K(!1),"aria-expanded":!0,"aria-controls":E,children:g??D.spoiler.hide})}):null]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{Spoiler}from"./Spoiler";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type { NebaColor, NebaSize } from '../../types';
|
|
4
|
+
/**
|
|
5
|
+
* When the line under a link is drawn.
|
|
6
|
+
*
|
|
7
|
+
* `always` is the default, and the reason is `color`: a TextLink takes no
|
|
8
|
+
* colour family unless one is asked for, so with the line off there would be
|
|
9
|
+
* nothing at all distinguishing a link from the sentence it sits in. That is
|
|
10
|
+
* also why this is not a boolean — "no underline" is a real choice for a link
|
|
11
|
+
* in a nav bar or a footer, where position already says what it is, and it
|
|
12
|
+
* should have to be spelled out rather than fallen into.
|
|
13
|
+
*/
|
|
14
|
+
export type TextLinkUnderline = 'always' | 'hover' | 'none';
|
|
15
|
+
export interface TextLinkProps extends Omit<React.ComponentPropsWithoutRef<'a'>, 'color'> {
|
|
16
|
+
/** Where the link goes. */
|
|
17
|
+
href: string;
|
|
18
|
+
/**
|
|
19
|
+
* When the underline is drawn.
|
|
20
|
+
* @default 'always'
|
|
21
|
+
*/
|
|
22
|
+
underline?: TextLinkUnderline;
|
|
23
|
+
/**
|
|
24
|
+
* Semantic colour role. Like [Typography](../display/typography) and unlike
|
|
25
|
+
* every control in the library this has **no default** — a link in a
|
|
26
|
+
* paragraph is usually the paragraph's own colour with a line under it, and a
|
|
27
|
+
* component that arrived pre-dyed is one a page has to undo.
|
|
28
|
+
*/
|
|
29
|
+
color?: NebaColor;
|
|
30
|
+
/**
|
|
31
|
+
* The type scale. Also no default: a link inside a sentence is the size of
|
|
32
|
+
* the sentence. Set it for a link that stands on its own.
|
|
33
|
+
*/
|
|
34
|
+
size?: NebaSize;
|
|
35
|
+
/**
|
|
36
|
+
* Opens the link in a new tab, with the `rel` that keeps the new page from
|
|
37
|
+
* reaching back into this one.
|
|
38
|
+
*
|
|
39
|
+
* A window changing under the reader is the one thing about a link that
|
|
40
|
+
* cannot be seen before it happens, so this also turns `icon` on by default
|
|
41
|
+
* and adds a line for a screen reader — see `locale`.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
newTab?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The mark after the label. `true` draws the arrow leaving its box when
|
|
47
|
+
* `newTab` is on and the chain otherwise, `false` draws nothing, and a node
|
|
48
|
+
* of your own replaces the glyph.
|
|
49
|
+
*
|
|
50
|
+
* Left out, it follows `newTab`.
|
|
51
|
+
*/
|
|
52
|
+
icon?: React.ReactNode | boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Which language the line for a screen reader is written in — a BCP 47 tag
|
|
55
|
+
* such as `ko`, `pt-BR` or `zh-Hant`. Unsupported tags fall back to English.
|
|
56
|
+
*
|
|
57
|
+
* Only `newTab` produces that line; a link without it says nothing of its
|
|
58
|
+
* own, so this changes nothing.
|
|
59
|
+
*/
|
|
60
|
+
locale?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Renders something other than an `<a>` — the `Link` a router brings, most
|
|
63
|
+
* of the time. `href` still goes through, so `render={<NextLink href="…" />}`
|
|
64
|
+
* needs it written once, on the TextLink.
|
|
65
|
+
*/
|
|
66
|
+
render?: useRender.RenderProp;
|
|
67
|
+
/** The label. */
|
|
68
|
+
children?: React.ReactNode;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A link, in a sentence or on its own.
|
|
72
|
+
*
|
|
73
|
+
* Everything about it is deliberately smaller than a Button. It has no surface,
|
|
74
|
+
* no height of its own and no colour unless asked — what it has is a line under
|
|
75
|
+
* it, which is the one mark a reader already knows means "this goes somewhere".
|
|
76
|
+
*
|
|
77
|
+
* The three things it does that a bare `<a>` does not: it draws that line on a
|
|
78
|
+
* schedule (`always`, or only under the pointer), it marks a link that opens a
|
|
79
|
+
* new tab both visibly and for a screen reader, and it takes `render`, so the
|
|
80
|
+
* `Link` a router brings can wear all of it.
|
|
81
|
+
*/
|
|
82
|
+
export declare const TextLink: React.ForwardRefExoticComponent<TextLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as n,Fragment as e,jsxs as r}from"react/jsx-runtime";import*as i from"react";import{useRender as o}from"@base-ui/react/use-render";import{useMessages as a}from"../../internal/i18n";import{ExternalLinkIcon as t,LinkIcon as l}from"../../internal/icons";import{controlTextLeadingClasses as s,focusRingClasses as c,srOnlyClasses as m}from"../../internal/styles";const d={always:"[&.neba-link]:underline",hover:"[&.neba-link]:no-underline [&.neba-link]:hover:underline",none:"[&.neba-link]:no-underline"},u=["neba-link","cursor-pointer","[&_svg]:pointer-events-none [&_svg]:inline [&_svg]:size-[0.95em] [&_svg]:shrink-0",["[transition-property:color,text-decoration-color]","[transition-duration:var(--neba-duration)]","[transition-timing-function:var(--neba-ease)]"].join(" "),c,"focus-visible:rounded-[0.25rem]"].join(" ");export const TextLink=i.forwardRef(function({href:i,underline:c="always",color:p,size:b,newTab:f=!1,icon:v,locale:h,render:k,className:g,style:x,children:y,...j},w){const _=a(h),N=v??f,T=!0===N?n(f?t:l,{}):N,z=[u,b?s[b]:"",d[c],p?"[&.neba-link]:text-(--n-accent)":"[&.neba-link]:text-inherit",g??""].filter(Boolean).join(" "),C={"--n-underline":"color-mix(in oklab, currentColor 45%, transparent)","--n-underline-hover":"currentColor","--n-ring":`var(--neba-${p??"primary"}-ring)`,...p?{"--n-accent":`var(--neba-${p}-accent)`}:null};return o({render:k??n("a",{}),ref:w,props:{href:i,target:f?"_blank":void 0,rel:f?"noopener noreferrer":void 0,className:z,style:{...C,...x},children:r(e,{children:[y,T?n("span",{className:"ms-[0.25em]",children:T}):null,f?r(e,{children:[" ",n("span",{className:m,children:_.link.newTab})]}):null]}),...j}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{TextLink}from"./TextLink";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { NebaElevation, NebaStyleProps } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* How the hierarchy is drawn.
|
|
5
|
+
*
|
|
6
|
+
* - `none` — indentation only. The quietest, and usually right for a navigation
|
|
7
|
+
* sidebar, where the tree is two levels deep and the labels say what the
|
|
8
|
+
* structure is.
|
|
9
|
+
* - `simple` — one hairline rail per level, running the full height of the
|
|
10
|
+
* group. Enough to follow a column of rows back to the branch it belongs to.
|
|
11
|
+
* - `folder` — the rail plus an elbow into every row, and the rail under a last
|
|
12
|
+
* child stops at that row. The file-manager drawing, and the one to reach for
|
|
13
|
+
* when the tree is deep.
|
|
14
|
+
*/
|
|
15
|
+
export type TreeViewLines = 'none' | 'simple' | 'folder';
|
|
16
|
+
/** A row's identity, and what `expanded` and `selected` are lists of. */
|
|
17
|
+
export type TreeViewValue = string | number;
|
|
18
|
+
export interface TreeViewProps extends NebaStyleProps, Omit<React.ComponentPropsWithoutRef<'ul'>, 'color' | 'defaultValue' | 'onSelect'> {
|
|
19
|
+
/**
|
|
20
|
+
* Drop shadow depth. `0` (the default) is flat.
|
|
21
|
+
* @default 0
|
|
22
|
+
*/
|
|
23
|
+
elevation?: NebaElevation;
|
|
24
|
+
/**
|
|
25
|
+
* How the hierarchy is drawn between the rows.
|
|
26
|
+
* @default 'simple'
|
|
27
|
+
*/
|
|
28
|
+
lines?: TreeViewLines;
|
|
29
|
+
/** Which branches are open. Use with `onExpandedChange` for a controlled tree. */
|
|
30
|
+
expanded?: TreeViewValue[];
|
|
31
|
+
/** Which start open, for an uncontrolled one. */
|
|
32
|
+
defaultExpanded?: TreeViewValue[];
|
|
33
|
+
onExpandedChange?: (expanded: TreeViewValue[]) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Which rows are chosen. An array even when only one row may be chosen at a
|
|
36
|
+
* time — the same shape Accordion's `value` takes, so turning `multiple` on
|
|
37
|
+
* does not also change the type of the value.
|
|
38
|
+
*/
|
|
39
|
+
selected?: TreeViewValue[];
|
|
40
|
+
/** Which start chosen, for an uncontrolled one. */
|
|
41
|
+
defaultSelected?: TreeViewValue[];
|
|
42
|
+
onSelectedChange?: (selected: TreeViewValue[]) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Whether more than one row may be chosen at a time.
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
multiple?: boolean;
|
|
48
|
+
/** Unavailable. Every row stops answering. */
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
/** The name the tree is announced by. */
|
|
51
|
+
label?: string;
|
|
52
|
+
/** The top-level TreeItems. */
|
|
53
|
+
children?: React.ReactNode;
|
|
54
|
+
}
|
|
55
|
+
export interface TreeItemProps extends Omit<React.ComponentPropsWithoutRef<'li'>, 'color' | 'onClick'> {
|
|
56
|
+
/**
|
|
57
|
+
* Identifies the row to `expanded` and `selected`. One is generated when it is
|
|
58
|
+
* left out, which is fine for a tree nobody drives from code.
|
|
59
|
+
*/
|
|
60
|
+
value?: TreeViewValue;
|
|
61
|
+
/**
|
|
62
|
+
* The row's text. Its own prop rather than `children`, because in a tree the
|
|
63
|
+
* children are the rows underneath it.
|
|
64
|
+
*/
|
|
65
|
+
label?: React.ReactNode;
|
|
66
|
+
/** Content before the label — a folder glyph, a file type, a status dot. */
|
|
67
|
+
startIcon?: React.ReactNode;
|
|
68
|
+
/** Content after the label, inside the pressable area — a count, a badge. */
|
|
69
|
+
endIcon?: React.ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* A control pinned to the end of the row.
|
|
72
|
+
*
|
|
73
|
+
* Deliberately outside the pressable area, the same shape ListItem uses: a
|
|
74
|
+
* row that both opens and holds a menu button has two things to press.
|
|
75
|
+
*/
|
|
76
|
+
action?: React.ReactNode;
|
|
77
|
+
/** Renders the row as a link, for a tree that is navigation. */
|
|
78
|
+
href?: string;
|
|
79
|
+
/** Fires when the row is pressed, before it opens or is chosen. */
|
|
80
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
81
|
+
/**
|
|
82
|
+
* Forces the disclosure arrow onto a row with no children yet — the branch
|
|
83
|
+
* that is fetched the first time it is opened.
|
|
84
|
+
*/
|
|
85
|
+
expandable?: boolean;
|
|
86
|
+
/** Unavailable. Its branch, if it is open, keeps working. */
|
|
87
|
+
disabled?: boolean;
|
|
88
|
+
/** The rows underneath this one. */
|
|
89
|
+
children?: React.ReactNode;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A tree of rows that open and shut.
|
|
93
|
+
*
|
|
94
|
+
* There is no Base UI primitive under this: the library has no tree, and the
|
|
95
|
+
* three things a tree owes — the `tree`/`treeitem`/`group` roles, one tab stop
|
|
96
|
+
* for the whole widget, and the arrow keys that walk it — are most of the
|
|
97
|
+
* component.
|
|
98
|
+
*
|
|
99
|
+
* The keyboard is handled once, here, rather than on every row. A tree's arrow
|
|
100
|
+
* keys are questions about the *tree* ("what is the next visible row", "where is
|
|
101
|
+
* my parent"), and the only element that can answer them is the one holding all
|
|
102
|
+
* of them. The rows the query returns are in document order, which is reading
|
|
103
|
+
* order, because a shut branch is unmounted rather than hidden.
|
|
104
|
+
*/
|
|
105
|
+
export declare const TreeView: React.ForwardRefExoticComponent<TreeViewProps & React.RefAttributes<HTMLUListElement>>;
|
|
106
|
+
/**
|
|
107
|
+
* One row, and everything under it.
|
|
108
|
+
*
|
|
109
|
+
* The `<li>` is the `treeitem` and it is what takes focus — not the row drawn
|
|
110
|
+
* inside it. That is the ARIA pattern, and it is also why the disclosure arrow
|
|
111
|
+
* is a plain span with a click handler rather than a button: a button inside the
|
|
112
|
+
* focusable row would be a second tab stop in a widget that is supposed to have
|
|
113
|
+
* exactly one, and the keyboard already opens a branch with ArrowRight.
|
|
114
|
+
*/
|
|
115
|
+
export declare const TreeItem: React.ForwardRefExoticComponent<TreeItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{ChevronIcon as a}from"../../internal/icons";import{controlTextClasses as l,cx as s,gapClasses as o,hasContent as i,iconClasses as c,radiusClasses as d,surfaceClasses as u,surfaceSlots as m,transitionClasses as f}from"../../internal/styles";const p=n.createContext({size:"md",density:"default",disabled:!1,expandedKeys:new Set,selectedKeys:new Set,activeKey:null,toggle:()=>{},select:()=>{},activate:()=>{},register:()=>()=>{}}),x={solid:[u,"text-(--neba-fg) bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[u,"border text-(--neba-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"text-(--neba-fg) bg-transparent"},g={xs:"0.875rem",sm:"1rem",md:"1.25rem",lg:"1.5rem",xl:"1.75rem"},b={xs:"1.375rem",sm:"1.625rem",md:"2rem",lg:"2.5rem",xl:"3rem"},h={default:{xs:"px-1.5",sm:"px-2",md:"px-2.5",lg:"px-3",xl:"px-3.5"},compact:{xs:"px-1",sm:"px-1",md:"px-1.5",lg:"px-2",xl:"px-2.5"}},v={xs:"rounded-[0.3125rem]",sm:"rounded-[0.375rem]",md:"rounded-[0.5rem]",lg:"rounded-[0.625rem]",xl:"rounded-[0.75rem]"},y={none:"",simple:"neba-tree-simple",folder:"neba-tree-folder"};function w(e){return Array.from(e.querySelectorAll('[role="treeitem"]'))}const k=e=>String(e);export const TreeView=n.forwardRef(function({variant:t="outline",size:r="md",color:a="primary",density:l="default",elevation:o=0,lines:i="simple",expanded:c,defaultExpanded:u,onExpandedChange:h,selected:v,defaultSelected:C,onSelectedChange:N,multiple:S=!1,disabled:K=!1,label:A,className:D,style:R,children:E,onKeyDown:j,...I},P){const[V,z]=n.useState(u??[]),[_,O]=n.useState(C??[]),[J,L]=n.useState(null),M=c??V,T=v??_,q=n.useRef(null),F=n.useCallback(e=>{q.current=e,"function"==typeof P?P(e):P&&(P.current=e)},[P]),H=n.useCallback(e=>{const t=k(e),r=c??V,n=r.some(e=>k(e)===t)?r.filter(e=>k(e)!==t):[...r,e];void 0===c&&z(n),h?.(n)},[c,V,h]),U=n.useCallback(e=>{const t=k(e),r=v??_,n=r.some(e=>k(e)===t),a=S?n?r.filter(e=>k(e)!==t):[...r,e]:[e];void 0===v&&O(a),N?.(a)},[S,v,_,N]),B=n.useRef(new Map),G=n.useCallback((e,t)=>(B.current.set(e,t),()=>{B.current.delete(e)}),[]),Q=JSON.stringify(M.map(k)),W=JSON.stringify(T.map(k)),X=n.useMemo(()=>({size:r,density:l,disabled:K,expandedKeys:new Set(M.map(k)),selectedKeys:new Set(T.map(k)),activeKey:J,toggle:H,select:U,activate:L,register:G}),[r,l,K,Q,W,J,H,U,G]);n.useEffect(()=>{const e=q.current;if(!e)return;const t=w(e);0!==t.length&&(null!==J&&t.some(e=>e.dataset.nebaValue===J)||L(t[0].dataset.nebaValue??null))});const Y=s("flex list-none flex-col p-1",d[r],x[t],f,y[i],D);return e(p.Provider,{value:X,children:e("ul",{ref:F,role:"tree","aria-label":A,"aria-multiselectable":S||void 0,className:Y,style:{...m(a,o),"--n-tree-indent":g[r],"--n-tree-row":b[r],...R},onKeyDown:function(e){if(j?.(e),e.defaultPrevented)return;const t=q.current,r=e.target?.closest?.('[role="treeitem"]');if(!t||!r||!t.contains(r))return;const n=w(t),a=n.indexOf(r);if(-1===a)return;const l=t=>{t&&(e.preventDefault(),L(t.dataset.nebaValue??null),t.focus())},s=e=>{const t=e.dataset.nebaValue;t&&B.current.get(t)?.toggle()},o="rtl"===getComputedStyle(t).direction,i=o?"ArrowLeft":"ArrowRight",c=o?"ArrowRight":"ArrowLeft",d=r.getAttribute("aria-expanded");switch(e.key){case"ArrowDown":l(n[a+1]);break;case"ArrowUp":l(n[a-1]);break;case"Home":l(n[0]);break;case"End":l(n[n.length-1]);break;case i:"false"===d?(e.preventDefault(),s(r)):"true"===d&&l(n[a+1]);break;case c:"true"===d?(e.preventDefault(),s(r)):l(r.parentElement?.closest('[role="treeitem"]'));break;case"Enter":case" ":e.preventDefault(),r.click()}},...I,children:E})})});export const TreeItem=n.forwardRef(function({value:d,label:u,startIcon:m,endIcon:x,action:g,href:b,expandable:y,disabled:w=!1,className:C,children:N,onClick:S,...K},A){const{size:D,density:R,disabled:E,expandedKeys:j,selectedKeys:I,activeKey:P,toggle:V,select:z,activate:_,register:O}=n.useContext(p),J=n.useId(),L=d??J,M=k(L),T=n.useRef(null),q=n.useCallback(e=>{T.current=e,"function"==typeof A?A(e):A&&(A.current=e)},[A]),F=n.Children.toArray(N),H=y??F.length>0,U=H&&j.has(M),B=I.has(M),G=w||E,Q=n.useRef({toggle:()=>{}});Q.current.toggle=()=>{!G&&H&&V(L)},n.useEffect(()=>O(M,Q.current),[M,O]);const W=s("flex min-w-0 flex-1 cursor-pointer items-center text-start","h-(--n-tree-row)",h[R][D],v[D],o[D],l[D],f,c,"group-focus-visible/tree-item:[outline:2px_solid_var(--n-ring)]","group-focus-visible/tree-item:outline-offset-[-2px]",G?"cursor-not-allowed text-(--neba-disabled-fg)":B?"bg-(--n-soft-press) font-medium text-(--n-accent) hover:bg-(--n-soft-press)":"hover:bg-(--n-soft)"),X=r(t,{children:[e("span",{"aria-hidden":"true",onClick:e=>{!G&&H&&(e.stopPropagation(),e.preventDefault(),T.current?.focus(),_(M),V(L))},className:s("flex h-[1lh] w-[1.15em] shrink-0 items-center justify-center","[transition:rotate_var(--neba-duration)_var(--neba-ease)]",H?"text-(--neba-muted-fg)":"",U?"rotate-0":"-rotate-90 rtl:rotate-90"),children:H?e(a,{}):null}),i(m)?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--neba-muted-fg)",children:m}):null,e("span",{className:"min-w-0 flex-1 truncate",children:u}),i(x)?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--neba-muted-fg)",children:x}):null]});return r("li",{ref:q,role:"treeitem","aria-expanded":H?U:void 0,"aria-selected":!!B||void 0,"aria-disabled":G||void 0,"data-neba-value":M,tabIndex:P===M?0:-1,className:s("group/tree-item relative block [outline:none]",C),onClick:function(e){e.stopPropagation(),G?e.preventDefault():(T.current?.focus(),_(M),S?.(e),e.defaultPrevented||(H&&V(L),z(L)))},...K,children:[r("div",{className:"flex w-full items-center",children:[b&&!G?e("a",{href:b,tabIndex:-1,className:W,"aria-current":B?"page":void 0,children:X}):e("div",{className:W,children:X}),i(g)?e("span",{className:s("flex shrink-0 items-center",h[R][D]),onClick:e=>e.stopPropagation(),children:g}):null]}),H&&U&&F.length>0?e("ul",{role:"group",className:"list-none ps-(--n-tree-indent)",children:N}):null]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{TreeItem,TreeView}from"./TreeView";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
export * from './types';
|
|
2
2
|
export * from './components/accordion';
|
|
3
3
|
export * from './components/alert';
|
|
4
|
+
export * from './components/avatar';
|
|
4
5
|
export * from './components/badge';
|
|
5
6
|
export * from './components/blockquote';
|
|
6
7
|
export * from './components/box';
|
|
8
|
+
export * from './components/breadcrumb';
|
|
7
9
|
export * from './components/button';
|
|
8
10
|
export * from './components/button-group';
|
|
9
11
|
export * from './components/card';
|
|
10
12
|
export * from './components/carousel';
|
|
13
|
+
export * from './components/chat-bubble';
|
|
11
14
|
export * from './components/checkbox';
|
|
12
15
|
export * from './components/chip';
|
|
13
16
|
export * from './components/combobox';
|
|
@@ -26,8 +29,10 @@ export * from './components/icon-button';
|
|
|
26
29
|
export * from './components/list';
|
|
27
30
|
export * from './components/menu';
|
|
28
31
|
export * from './components/number-field';
|
|
32
|
+
export * from './components/otp-field';
|
|
29
33
|
export * from './components/overlay';
|
|
30
34
|
export * from './components/pagination';
|
|
35
|
+
export * from './components/panes';
|
|
31
36
|
export * from './components/pill';
|
|
32
37
|
export * from './components/progress-box';
|
|
33
38
|
export * from './components/progress-circular';
|
|
@@ -37,14 +42,17 @@ export * from './components/segmented-button';
|
|
|
37
42
|
export * from './components/select';
|
|
38
43
|
export * from './components/shortcut';
|
|
39
44
|
export * from './components/slider';
|
|
45
|
+
export * from './components/spoiler';
|
|
40
46
|
export * from './components/statistic';
|
|
41
47
|
export * from './components/switch';
|
|
42
48
|
export * from './components/table';
|
|
43
49
|
export * from './components/tabs';
|
|
44
50
|
export * from './components/text-field';
|
|
51
|
+
export * from './components/text-link';
|
|
45
52
|
export * from './components/time-picker';
|
|
46
53
|
export * from './components/timeline';
|
|
47
54
|
export * from './components/toast';
|
|
48
55
|
export * from './components/toolbar';
|
|
49
56
|
export * from './components/tooltip';
|
|
57
|
+
export * from './components/tree-view';
|
|
50
58
|
export * from './components/typography';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./types";export*from"./components/accordion";export*from"./components/alert";export*from"./components/badge";export*from"./components/blockquote";export*from"./components/box";export*from"./components/button";export*from"./components/button-group";export*from"./components/card";export*from"./components/carousel";export*from"./components/checkbox";export*from"./components/chip";export*from"./components/combobox";export*from"./components/container";export*from"./components/date-picker";export*from"./components/date-range-picker";export*from"./components/date-time-picker";export*from"./components/dialog";export*from"./components/divider";export*from"./components/file-picker";export*from"./components/grid";export*from"./components/grid-container";export*from"./components/highlight";export*from"./components/icon";export*from"./components/icon-button";export*from"./components/list";export*from"./components/menu";export*from"./components/number-field";export*from"./components/overlay";export*from"./components/pagination";export*from"./components/pill";export*from"./components/progress-box";export*from"./components/progress-circular";export*from"./components/progress-linear";export*from"./components/radio-group";export*from"./components/segmented-button";export*from"./components/select";export*from"./components/shortcut";export*from"./components/slider";export*from"./components/statistic";export*from"./components/switch";export*from"./components/table";export*from"./components/tabs";export*from"./components/text-field";export*from"./components/time-picker";export*from"./components/timeline";export*from"./components/toast";export*from"./components/toolbar";export*from"./components/tooltip";export*from"./components/typography";
|
|
1
|
+
export*from"./types";export*from"./components/accordion";export*from"./components/alert";export*from"./components/avatar";export*from"./components/badge";export*from"./components/blockquote";export*from"./components/box";export*from"./components/breadcrumb";export*from"./components/button";export*from"./components/button-group";export*from"./components/card";export*from"./components/carousel";export*from"./components/chat-bubble";export*from"./components/checkbox";export*from"./components/chip";export*from"./components/combobox";export*from"./components/container";export*from"./components/date-picker";export*from"./components/date-range-picker";export*from"./components/date-time-picker";export*from"./components/dialog";export*from"./components/divider";export*from"./components/file-picker";export*from"./components/grid";export*from"./components/grid-container";export*from"./components/highlight";export*from"./components/icon";export*from"./components/icon-button";export*from"./components/list";export*from"./components/menu";export*from"./components/number-field";export*from"./components/otp-field";export*from"./components/overlay";export*from"./components/pagination";export*from"./components/panes";export*from"./components/pill";export*from"./components/progress-box";export*from"./components/progress-circular";export*from"./components/progress-linear";export*from"./components/radio-group";export*from"./components/segmented-button";export*from"./components/select";export*from"./components/shortcut";export*from"./components/slider";export*from"./components/spoiler";export*from"./components/statistic";export*from"./components/switch";export*from"./components/table";export*from"./components/tabs";export*from"./components/text-field";export*from"./components/text-link";export*from"./components/time-picker";export*from"./components/timeline";export*from"./components/toast";export*from"./components/toolbar";export*from"./components/tooltip";export*from"./components/tree-view";export*from"./components/typography";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words the library says on its own behalf.
|
|
3
|
+
*
|
|
4
|
+
* Almost nothing in Neba writes text a reader sees — a Button says whatever it
|
|
5
|
+
* was handed, a Card's title is the caller's. The exceptions are the strings a
|
|
6
|
+
* component has to invent because there is nowhere else for them to come from:
|
|
7
|
+
* the sentence behind a link that opens a new tab, the label on the button that
|
|
8
|
+
* uncovers a Spoiler, the word under a chat message that says it was read.
|
|
9
|
+
*
|
|
10
|
+
* Those are collected here rather than defaulted inside each component, for the
|
|
11
|
+
* reason every other table in `internal/` exists: they are a set. A product in
|
|
12
|
+
* Korean does not want eight components each defaulting to English and each
|
|
13
|
+
* needing its own override prop, and the next component that needs a word —
|
|
14
|
+
* a picker's "Today", a Pagination's "Next page" — should get it from the same
|
|
15
|
+
* place rather than starting a second table beside this one.
|
|
16
|
+
*
|
|
17
|
+
* What is *not* in here is anything `Intl` already knows. Month names, weekday
|
|
18
|
+
* names, AM/PM and number formats come from the platform, which speaks more
|
|
19
|
+
* languages than this file ever will. This is only for the words the platform
|
|
20
|
+
* has no opinion about.
|
|
21
|
+
*
|
|
22
|
+
* Every component that reads this takes a `locale` and an override prop for the
|
|
23
|
+
* string itself, so an unsupported language is never a dead end: `locale` gets
|
|
24
|
+
* you a translation for free, and the prop gets you one for anything else.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* One namespace per component, rather than one flat list of keys.
|
|
28
|
+
*
|
|
29
|
+
* A namespace is what makes a partial translation possible: a locale supplies
|
|
30
|
+
* whatever it has and the rest falls back to English one namespace at a time,
|
|
31
|
+
* so adding a namespace here does not silently blank the strings in every
|
|
32
|
+
* language that has not caught up with it yet.
|
|
33
|
+
*/
|
|
34
|
+
export interface NebaMessages {
|
|
35
|
+
/** TextLink. */
|
|
36
|
+
link: {
|
|
37
|
+
/**
|
|
38
|
+
* What is read out after a link that opens a new tab, and never drawn. A
|
|
39
|
+
* window changing under the reader is the one thing about a link that is
|
|
40
|
+
* invisible until it has already happened.
|
|
41
|
+
*/
|
|
42
|
+
newTab: string;
|
|
43
|
+
};
|
|
44
|
+
/** Spoiler. */
|
|
45
|
+
spoiler: {
|
|
46
|
+
/** The button that uncovers the content. */
|
|
47
|
+
reveal: string;
|
|
48
|
+
/** And the one that covers it again, when the Spoiler is reversible. */
|
|
49
|
+
hide: string;
|
|
50
|
+
/** The line above the button, saying why the content is covered. */
|
|
51
|
+
notice: string;
|
|
52
|
+
};
|
|
53
|
+
/** ChatBubble. */
|
|
54
|
+
chat: {
|
|
55
|
+
/** The four steps a message goes through, as the mark under it. */
|
|
56
|
+
sending: string;
|
|
57
|
+
sent: string;
|
|
58
|
+
delivered: string;
|
|
59
|
+
read: string;
|
|
60
|
+
/** And the fifth, which is not a step: it did not go. */
|
|
61
|
+
failed: string;
|
|
62
|
+
/** What the three dots mean. */
|
|
63
|
+
typing: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The strings for a locale, merged over English.
|
|
68
|
+
*
|
|
69
|
+
* `undefined` is English rather than the runtime's own locale, and that is
|
|
70
|
+
* deliberate: `navigator.language` differs between the server that renders the
|
|
71
|
+
* markup and the browser that hydrates it, and text that changes between those
|
|
72
|
+
* two is a hydration mismatch in the one part of the page a reader is looking
|
|
73
|
+
* at. A component that should follow the reader is told which language to
|
|
74
|
+
* follow.
|
|
75
|
+
*/
|
|
76
|
+
export declare function resolveMessages(locale?: string): NebaMessages;
|
|
77
|
+
/** The same, as a hook, for the components that read it during a render. */
|
|
78
|
+
export declare function useMessages(locale?: string): NebaMessages;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";const n={link:{newTab:"(opens in a new tab)"},spoiler:{reveal:"Reveal",hide:"Hide",notice:"This may contain spoilers"},chat:{sending:"Sending",sent:"Sent",delivered:"Delivered",read:"Read",failed:"Not sent",typing:"Typing…"}},i={ko:{link:{newTab:"(새 창에서 열림)"},spoiler:{reveal:"내용 보기",hide:"숨기기",notice:"스포일러가 포함되어 있을 수 있습니다"},chat:{sending:"보내는 중",sent:"보냄",delivered:"전달됨",read:"읽음",failed:"전송 실패",typing:"입력 중…"}},ja:{link:{newTab:"(新しいタブで開きます)"},spoiler:{reveal:"表示する",hide:"隠す",notice:"ネタバレを含む可能性があります"},chat:{sending:"送信中",sent:"送信済み",delivered:"配信済み",read:"既読",failed:"送信できませんでした",typing:"入力中…"}},"zh-hans":{link:{newTab:"(在新标签页中打开)"},spoiler:{reveal:"显示内容",hide:"隐藏",notice:"此内容可能包含剧透"},chat:{sending:"发送中",sent:"已发送",delivered:"已送达",read:"已读",failed:"发送失败",typing:"正在输入…"}},"zh-hant":{link:{newTab:"(在新分頁中開啟)"},spoiler:{reveal:"顯示內容",hide:"隱藏",notice:"此內容可能包含劇透"},chat:{sending:"傳送中",sent:"已傳送",delivered:"已送達",read:"已讀",failed:"傳送失敗",typing:"正在輸入…"}},es:{link:{newTab:"(se abre en una pestaña nueva)"},spoiler:{reveal:"Mostrar",hide:"Ocultar",notice:"Puede contener spoilers"},chat:{sending:"Enviando",sent:"Enviado",delivered:"Entregado",read:"Leído",failed:"No enviado",typing:"Escribiendo…"}},pt:{link:{newTab:"(abre em uma nova aba)"},spoiler:{reveal:"Mostrar",hide:"Ocultar",notice:"Pode conter spoilers"},chat:{sending:"Enviando",sent:"Enviado",delivered:"Entregue",read:"Lido",failed:"Não enviado",typing:"Digitando…"}},fr:{link:{newTab:"(s’ouvre dans un nouvel onglet)"},spoiler:{reveal:"Afficher",hide:"Masquer",notice:"Peut contenir des spoilers"},chat:{sending:"Envoi en cours",sent:"Envoyé",delivered:"Distribué",read:"Lu",failed:"Non envoyé",typing:"En train d’écrire…"}},de:{link:{newTab:"(wird in einem neuen Tab geöffnet)"},spoiler:{reveal:"Anzeigen",hide:"Ausblenden",notice:"Kann Spoiler enthalten"},chat:{sending:"Wird gesendet",sent:"Gesendet",delivered:"Zugestellt",read:"Gelesen",failed:"Nicht gesendet",typing:"Schreibt…"}},it:{link:{newTab:"(si apre in una nuova scheda)"},spoiler:{reveal:"Mostra",hide:"Nascondi",notice:"Può contenere spoiler"},chat:{sending:"Invio in corso",sent:"Inviato",delivered:"Consegnato",read:"Letto",failed:"Non inviato",typing:"Sta scrivendo…"}},nl:{link:{newTab:"(opent in een nieuw tabblad)"},spoiler:{reveal:"Tonen",hide:"Verbergen",notice:"Kan spoilers bevatten"},chat:{sending:"Wordt verzonden",sent:"Verzonden",delivered:"Afgeleverd",read:"Gelezen",failed:"Niet verzonden",typing:"Aan het typen…"}},pl:{link:{newTab:"(otwiera się w nowej karcie)"},spoiler:{reveal:"Pokaż",hide:"Ukryj",notice:"Może zawierać spoilery"},chat:{sending:"Wysyłanie",sent:"Wysłano",delivered:"Dostarczono",read:"Przeczytano",failed:"Nie wysłano",typing:"Pisze…"}},ru:{link:{newTab:"(откроется в новой вкладке)"},spoiler:{reveal:"Показать",hide:"Скрыть",notice:"Может содержать спойлеры"},chat:{sending:"Отправляется",sent:"Отправлено",delivered:"Доставлено",read:"Прочитано",failed:"Не отправлено",typing:"Печатает…"}},tr:{link:{newTab:"(yeni sekmede açılır)"},spoiler:{reveal:"Göster",hide:"Gizle",notice:"Spoiler içerebilir"},chat:{sending:"Gönderiliyor",sent:"Gönderildi",delivered:"İletildi",read:"Okundu",failed:"Gönderilemedi",typing:"Yazıyor…"}},ar:{link:{newTab:"(يفتح في علامة تبويب جديدة)"},spoiler:{reveal:"إظهار",hide:"إخفاء",notice:"قد يحتوي على حرق للأحداث"},chat:{sending:"جارٍ الإرسال",sent:"تم الإرسال",delivered:"تم التسليم",read:"تمت القراءة",failed:"لم يتم الإرسال",typing:"يكتب الآن…"}},hi:{link:{newTab:"(नए टैब में खुलता है)"},spoiler:{reveal:"दिखाएँ",hide:"छिपाएँ",notice:"इसमें स्पॉइलर हो सकते हैं"},chat:{sending:"भेजा जा रहा है",sent:"भेजा गया",delivered:"डिलीवर हुआ",read:"पढ़ा गया",failed:"नहीं भेजा गया",typing:"टाइप कर रहे हैं…"}},id:{link:{newTab:"(terbuka di tab baru)"},spoiler:{reveal:"Tampilkan",hide:"Sembunyikan",notice:"Mungkin mengandung spoiler"},chat:{sending:"Mengirim",sent:"Terkirim",delivered:"Diterima",read:"Dibaca",failed:"Gagal terkirim",typing:"Sedang mengetik…"}},vi:{link:{newTab:"(mở trong tab mới)"},spoiler:{reveal:"Hiện nội dung",hide:"Ẩn",notice:"Có thể chứa nội dung tiết lộ"},chat:{sending:"Đang gửi",sent:"Đã gửi",delivered:"Đã nhận",read:"Đã xem",failed:"Chưa gửi được",typing:"Đang nhập…"}},th:{link:{newTab:"(เปิดในแท็บใหม่)"},spoiler:{reveal:"แสดงเนื้อหา",hide:"ซ่อน",notice:"อาจมีการเปิดเผยเนื้อหา"},chat:{sending:"กำลังส่ง",sent:"ส่งแล้ว",delivered:"ส่งถึงแล้ว",read:"อ่านแล้ว",failed:"ส่งไม่สำเร็จ",typing:"กำลังพิมพ์…"}}},a={zh:"zh-hans","zh-cn":"zh-hans","zh-my":"zh-hans","zh-sg":"zh-hans","zh-hk":"zh-hant","zh-mo":"zh-hant","zh-tw":"zh-hant"};const t=new Map([["",n]]);export function resolveMessages(e){const r=e?.trim()??"",d=t.get(r);if(d)return d;const l=function(e){const n=e.toLowerCase().split(/[-_]/).filter(Boolean),i=n[0];if(!i)return[];const a=n.slice(1),t=a.find(e=>/^[a-z]{4}$/.test(e)),r=a.find(e=>/^([a-z]{2}|\d{3})$/.test(e));return[t?`${i}-${t}`:"",r?`${i}-${r}`:"",i].filter(Boolean)}(r).map(e=>i[e]??i[a[e]??""]).find(Boolean),o=l?{link:{...n.link,...l.link},spoiler:{...n.spoiler,...l.spoiler},chat:{...n.chat,...l.chat}}:n;return t.set(r,o),o}export function useMessages(n){return e.useMemo(()=>resolveMessages(n),[n])}
|
package/dist/internal/icons.d.ts
CHANGED
|
@@ -67,6 +67,29 @@ export declare function ClockIcon(): React.JSX.Element;
|
|
|
67
67
|
* reason the chevron is: it is a glyph, and there is no text in it to resample.
|
|
68
68
|
*/
|
|
69
69
|
export declare function ArrowRightIcon(): React.JSX.Element;
|
|
70
|
+
/**
|
|
71
|
+
* The two marks a link wears.
|
|
72
|
+
*
|
|
73
|
+
* A pair for the same reason the steppers are: they answer the same question —
|
|
74
|
+
* "where does this go" — and a chain drawn at one weight beside an arrow drawn
|
|
75
|
+
* at another reads as two icon sets in one paragraph. The chain says "this is a
|
|
76
|
+
* link", the arrow leaving its box says "and it leaves this page", which is the
|
|
77
|
+
* one thing about a link that is invisible until it has already happened.
|
|
78
|
+
*
|
|
79
|
+
* TextLink draws whichever one matches its `newTab`; a ChatBubble's link
|
|
80
|
+
* preview draws the chain beside the site it points at.
|
|
81
|
+
*/
|
|
82
|
+
export declare function LinkIcon(): React.JSX.Element;
|
|
83
|
+
export declare function ExternalLinkIcon(): React.JSX.Element;
|
|
84
|
+
/**
|
|
85
|
+
* The three dots that stand for what has been left out.
|
|
86
|
+
*
|
|
87
|
+
* Drawn rather than typed: `…` is a single glyph whose dots are spaced by
|
|
88
|
+
* whatever font the page happens to load, and it sits on the baseline rather
|
|
89
|
+
* than in the middle of the row it is standing in for. Breadcrumb draws it on
|
|
90
|
+
* the button that opens the collapsed middle of a trail.
|
|
91
|
+
*/
|
|
92
|
+
export declare function EllipsisIcon(): React.JSX.Element;
|
|
70
93
|
/** The filled dot: the chosen one of a set, where a tick would say "and". */
|
|
71
94
|
export declare function DotIcon(): React.JSX.Element;
|
|
72
95
|
/**
|
package/dist/internal/icons.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r,jsxs as e}from"react/jsx-runtime";export function CloseIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"m4.5 4.5 7 7m0-7-7 7",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})})}export function ChevronIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"m4.5 6.5 3.5 3.5 3.5-3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}export function CheckIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"m3.5 8.5 3 3 6-6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}export function MinusIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"M3.5 8h9",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})})}export function PlusIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"M8 3.5v9M3.5 8h9",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})})}export function TrendUpIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("path",{d:"M3 11 6.5 7.5 9 10l4-4",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"}),r("path",{d:"M9.5 6h3.5v3.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})]})}export function TrendDownIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("path",{d:"M3 5 6.5 8.5 9 6l4 4",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"}),r("path",{d:"M9.5 10h3.5V6.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})]})}export function CalendarIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("rect",{x:"2",y:"3.25",width:"12",height:"10.75",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M2 6.75h12",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M5.25 1.75v2.5M10.75 1.75v2.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}export function ClockIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M8 4.5V8l2.4 1.6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}export function ArrowRightIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"M3 8h10m-3.5-3.5L13 8l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}export function DotIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("circle",{cx:"8",cy:"8",r:"3.25",fill:"currentColor"})})}function o(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M8 7.25v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r("circle",{cx:"8",cy:"4.9",r:"0.85",fill:"currentColor"})]})}export const severityIcons={primary:r(o,{}),secondary:r(o,{}),info:r(o,{}),success:e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"m5.25 8.25 1.9 1.9 3.6-3.9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),warning:e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("path",{d:"M7.13 2.6 1.9 11.7a1 1 0 0 0 .87 1.5h10.46a1 1 0 0 0 .87-1.5L8.87 2.6a1 1 0 0 0-1.74 0Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),r("path",{d:"M8 6.1v3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r("circle",{cx:"8",cy:"11.2",r:"0.85",fill:"currentColor"})]}),danger:e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"m5.9 5.9 4.2 4.2m0-4.2-4.2 4.2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})};
|
|
1
|
+
import{jsx as r,jsxs as e}from"react/jsx-runtime";export function CloseIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"m4.5 4.5 7 7m0-7-7 7",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})})}export function ChevronIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"m4.5 6.5 3.5 3.5 3.5-3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}export function CheckIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"m3.5 8.5 3 3 6-6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}export function MinusIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"M3.5 8h9",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})})}export function PlusIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"M8 3.5v9M3.5 8h9",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})})}export function TrendUpIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("path",{d:"M3 11 6.5 7.5 9 10l4-4",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"}),r("path",{d:"M9.5 6h3.5v3.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})]})}export function TrendDownIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("path",{d:"M3 5 6.5 8.5 9 6l4 4",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"}),r("path",{d:"M9.5 10h3.5V6.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})]})}export function CalendarIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("rect",{x:"2",y:"3.25",width:"12",height:"10.75",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M2 6.75h12",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M5.25 1.75v2.5M10.75 1.75v2.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}export function ClockIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M8 4.5V8l2.4 1.6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}export function ArrowRightIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("path",{d:"M3 8h10m-3.5-3.5L13 8l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}export function LinkIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("path",{d:"M6.5 9.5a2.75 2.75 0 0 0 4 .25l1.75-1.75a2.75 2.75 0 0 0-3.9-3.9L7.75 5.2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r("path",{d:"M9.5 6.5a2.75 2.75 0 0 0-4-.25L3.75 8a2.75 2.75 0 0 0 3.9 3.9l.6-.6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}export function ExternalLinkIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("path",{d:"M12.75 9.25v2.5a1.5 1.5 0 0 1-1.5 1.5h-7a1.5 1.5 0 0 1-1.5-1.5v-7a1.5 1.5 0 0 1 1.5-1.5h2.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r("path",{d:"M9.5 2.75h3.75V6.5M7.25 8.75l5.75-5.75",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}export function EllipsisIcon(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"3.5",cy:"8",r:"1.15",fill:"currentColor"}),r("circle",{cx:"8",cy:"8",r:"1.15",fill:"currentColor"}),r("circle",{cx:"12.5",cy:"8",r:"1.15",fill:"currentColor"})]})}export function DotIcon(){return r("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r("circle",{cx:"8",cy:"8",r:"3.25",fill:"currentColor"})})}function o(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"M8 7.25v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r("circle",{cx:"8",cy:"4.9",r:"0.85",fill:"currentColor"})]})}export const severityIcons={primary:r(o,{}),secondary:r(o,{}),info:r(o,{}),success:e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"m5.25 8.25 1.9 1.9 3.6-3.9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),warning:e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("path",{d:"M7.13 2.6 1.9 11.7a1 1 0 0 0 .87 1.5h10.46a1 1 0 0 0 .87-1.5L8.87 2.6a1 1 0 0 0-1.74 0Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),r("path",{d:"M8 6.1v3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r("circle",{cx:"8",cy:"11.2",r:"0.85",fill:"currentColor"})]}),danger:e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r("circle",{cx:"8",cy:"8",r:"6.25",stroke:"currentColor",strokeWidth:"1.5"}),r("path",{d:"m5.9 5.9 4.2 4.2m0-4.2-4.2 4.2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})};
|