@sesamehr/react-design-system 3.7.0 → 3.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/dist/Data/KpiCard/KpiCard.d.ts +38 -0
- package/dist/Data/KpiCard/index.d.ts +6 -0
- package/dist/Display/CommentItem/CommentItem.d.ts +55 -0
- package/dist/Display/CommentItem/index.d.ts +1 -0
- package/dist/Display/ReactionBar/ReactionBar.d.ts +22 -0
- package/dist/Display/ReactionBar/index.d.ts +3 -0
- package/dist/Display/ReactionBar/overflow.d.ts +32 -0
- package/dist/Display/ReactionButton/ReactionButton.d.ts +26 -0
- package/dist/Display/ReactionButton/index.d.ts +18 -0
- package/dist/Display/ReactionPicker/ReactionPicker.d.ts +21 -0
- package/dist/Display/ReactionPicker/index.d.ts +18 -0
- package/dist/Forms/Inputs/RichTextEditor/commands.d.ts +11 -4
- package/dist/Forms/Inputs/RichTextEditor/extensions.d.ts +58 -15
- package/dist/Forms/Inputs/RichTextEditor/index.d.ts +1 -1
- package/dist/Forms/Inputs/RichTextEditor/useRichTextAdapter.d.ts +24 -4
- package/dist/main.d.ts +6 -1
- package/dist/react-design-system.css +1 -1
- package/dist/react-design-system.js +11404 -10616
- package/dist/react-design-system.umd.cjs +74 -59
- package/package.json +18 -8
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { KpiCardVariants } from './index.ts';
|
|
2
|
+
export interface KpiCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
3
|
+
/**
|
|
4
|
+
* `md` is the dashboard tile, stacked. `sm` is the compact row for a side
|
|
5
|
+
* panel, and it draws no chart, no description and no footer at all — pass
|
|
6
|
+
* those props at that size and nothing renders them.
|
|
7
|
+
*/
|
|
8
|
+
size?: KpiCardVariants['size'];
|
|
9
|
+
selected?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Swaps each region for an `OxSkeleton` the size of the region it stands in
|
|
12
|
+
* for, so the placeholder mirrors whichever nodes this caller passed. The
|
|
13
|
+
* value's is the exception and is always drawn, since a card that is still
|
|
14
|
+
* loading has no value to pass.
|
|
15
|
+
*/
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
icon?: React.ReactNode;
|
|
18
|
+
/** Vue's `#title` slot, which is why the native `title` attribute is omitted. */
|
|
19
|
+
title?: React.ReactNode;
|
|
20
|
+
chart?: React.ReactNode;
|
|
21
|
+
trend?: React.ReactNode;
|
|
22
|
+
description?: React.ReactNode;
|
|
23
|
+
footer?: React.ReactNode;
|
|
24
|
+
dataTestid: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* OxKpiCard — mirrors `@sesame/orxata-core` KpiCard.
|
|
28
|
+
*
|
|
29
|
+
* One metric on a dashboard: a number, what it is, and the context that makes
|
|
30
|
+
* it mean something. Every region is a node-valued prop, and one left out
|
|
31
|
+
* renders nothing. See the MDX guide for the rest.
|
|
32
|
+
*
|
|
33
|
+
* Fill `trend` with an `OxTag`. Figma draws `_KPI / Trend` as a full pill and
|
|
34
|
+
* `OxTag` is `rounded-md`, which is what ships: that difference is recorded as
|
|
35
|
+
* design errata, not a bug here. A caller who needs a pill passes
|
|
36
|
+
* `className="rounded-full"` on their own tag.
|
|
37
|
+
*/
|
|
38
|
+
export declare const KpiCard: import('react').ForwardRefExoticComponent<KpiCardProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
export { KpiCard, type KpiCardProps } from './KpiCard.tsx';
|
|
3
|
+
export declare const kpiCardVariants: (props?: ({
|
|
4
|
+
size?: "sm" | "md" | null | undefined;
|
|
5
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
6
|
+
export type KpiCardVariants = VariantProps<typeof kpiCardVariants>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface CommentItemProps extends React.HTMLAttributes<HTMLElement> {
|
|
2
|
+
/** Who wrote it. */
|
|
3
|
+
author: string;
|
|
4
|
+
/** When, already phrased — "2 h ago". Relative time is the caller's to format. */
|
|
5
|
+
time: string;
|
|
6
|
+
/** The full timestamp, as a tooltip on the relative time. */
|
|
7
|
+
timeTitle?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the reader has liked it.
|
|
10
|
+
*
|
|
11
|
+
* Controlled only, matching the Vue side — a plain prop plus an emit, with
|
|
12
|
+
* no `defineModel`. Do not add an uncontrolled fallback: that would be drift,
|
|
13
|
+
* and it is the shape this component is deliberately not in.
|
|
14
|
+
*/
|
|
15
|
+
liked?: boolean;
|
|
16
|
+
/** How many likes. Omit it and no count is rendered. */
|
|
17
|
+
likes?: number;
|
|
18
|
+
/** The avatar. The Vue port's `avatar` slot. */
|
|
19
|
+
avatar?: React.ReactNode;
|
|
20
|
+
/** The rows of the overflow menu. The Vue port's `actions` slot. */
|
|
21
|
+
actions?: React.ReactNode;
|
|
22
|
+
/** Replaces the three-dots control. The Vue port's `actions-trigger` slot. */
|
|
23
|
+
actionsTrigger?: React.ReactNode;
|
|
24
|
+
/** Nested replies, indented one level. The Vue port's `replies` slot. */
|
|
25
|
+
replies?: React.ReactNode;
|
|
26
|
+
/** The heart was pressed. Flip `liked` yourself once the write lands. */
|
|
27
|
+
onLike?: () => void;
|
|
28
|
+
/** Reply was pressed. Open a composer; this component renders none. */
|
|
29
|
+
onReply?: () => void;
|
|
30
|
+
dataTestid?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* CommentItem — mirrors `@sesame/orxata-core` CommentItem.
|
|
34
|
+
*
|
|
35
|
+
* One posted comment: who wrote it, when, what they said, and the two things
|
|
36
|
+
* you can do about it.
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <OxCommentItem
|
|
40
|
+
* author="Lucía Martín"
|
|
41
|
+
* time="2 h ago"
|
|
42
|
+
* liked={liked}
|
|
43
|
+
* likes={3}
|
|
44
|
+
* avatar={<OxAvatarRounded size="sm" dataTestid="avatar">LM</OxAvatarRounded>}
|
|
45
|
+
* actions={<OxDropdownMenuItem>Edit</OxDropdownMenuItem>}
|
|
46
|
+
* onLike={() => setLiked(!liked)}
|
|
47
|
+
* >
|
|
48
|
+
* Great work on the new remote-work policy.
|
|
49
|
+
* </OxCommentItem>
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* `CommentItem.mdx` has the API, what each prop is for, and why the design's
|
|
53
|
+
* four cells leave the rest to us.
|
|
54
|
+
*/
|
|
55
|
+
export declare const CommentItem: import('react').ForwardRefExoticComponent<CommentItemProps & import('react').RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CommentItem, type CommentItemProps } from './CommentItem.tsx';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactionPickerEmoji } from '../ReactionPicker/index.ts';
|
|
2
|
+
import { Reaction } from './overflow.ts';
|
|
3
|
+
export interface ReactionBarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** Every reaction on the thing being reacted to, in any order */
|
|
5
|
+
reactions: Reaction[];
|
|
6
|
+
/** How many to draw before the rest collapse into `+N`. Wraps above what fits */
|
|
7
|
+
max?: number;
|
|
8
|
+
/** Which emoji the `Add` picker offers. Defaults to `OxReactionPicker`'s six */
|
|
9
|
+
emojis?: ReactionPickerEmoji[];
|
|
10
|
+
/** An emoji was chosen, by pressing a pill or picking one from `Add` */
|
|
11
|
+
onReact?: (emoji: string) => void;
|
|
12
|
+
/** The reader asked for the full picker, which is the consumer's to open */
|
|
13
|
+
onShowMore?: () => void;
|
|
14
|
+
dataTestid: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Every reaction on one post, comment or message, plus the button that adds
|
|
18
|
+
* another. Mirrors `@sesame/orxata-core` ReactionBar; see `ReactionBar.mdx` for
|
|
19
|
+
* why it takes data rather than children, and for what Figma leaves
|
|
20
|
+
* unspecified.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ReactionBar: import('react').ForwardRefExoticComponent<ReactionBarProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One reaction type on one post, comment or message.
|
|
3
|
+
*
|
|
4
|
+
* The product's own shape, field for field
|
|
5
|
+
* (`community/domain/model/reaction.model.ts` in `app-mobile-v3`).
|
|
6
|
+
*/
|
|
7
|
+
export interface Reaction {
|
|
8
|
+
/** The emoji itself, as a grapheme */
|
|
9
|
+
reactionType: string;
|
|
10
|
+
/** How many people chose it */
|
|
11
|
+
total: number;
|
|
12
|
+
/** Whether the reader is one of them */
|
|
13
|
+
iReact: boolean;
|
|
14
|
+
/** The reader's own reaction id, for deleting it. `null` when they have not */
|
|
15
|
+
id: string | null;
|
|
16
|
+
}
|
|
17
|
+
/** What the bar draws, and what the `+N` pill hides. */
|
|
18
|
+
export interface ReactionSplit {
|
|
19
|
+
visible: Reaction[];
|
|
20
|
+
hidden: Reaction[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Which reactions fit, and which go behind the `+N` pill.
|
|
24
|
+
*
|
|
25
|
+
* **`iReact` keeps a visible slot even when it misses the cap**, taking the last
|
|
26
|
+
* one and pushing what it displaced into the hidden run. This is Figma's rule
|
|
27
|
+
* and the product's `topReactionEmojis` does *not* do it — that is a plain
|
|
28
|
+
* `slice`. Do not "align" the two: the divergence is the requirement. With more
|
|
29
|
+
* than one own reaction only the highest-ranked is guaranteed a slot, so a
|
|
30
|
+
* reader who pressed four emoji cannot push everyone else out of their own bar.
|
|
31
|
+
*/
|
|
32
|
+
export declare const splitReactions: (reactions: Reaction[], max: number) => ReactionSplit;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactionButtonVariants } from './index.ts';
|
|
2
|
+
export interface ReactionButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
3
|
+
/** Which of the three pills this is */
|
|
4
|
+
variant?: ReactionButtonVariants['variant'];
|
|
5
|
+
/** The emoji itself, as a grapheme. Only `reaction` draws one */
|
|
6
|
+
emoji?: string;
|
|
7
|
+
/** How many chose it, or how many reaction types `more` hides */
|
|
8
|
+
count?: number;
|
|
9
|
+
/** Whether the reader is one of them. Also what `aria-pressed` reports */
|
|
10
|
+
reacted?: boolean;
|
|
11
|
+
dataTestid: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* One reaction: an emoji and how many people chose it. Mirrors
|
|
15
|
+
* `@sesame/orxata-core` ReactionButton; see `ReactionButton.mdx`.
|
|
16
|
+
*
|
|
17
|
+
* The `...props` spread is load-bearing — `OxReactionBar` hands the `add` and
|
|
18
|
+
* `more` pills to a Radix `Popover.Trigger` through `asChild`, and the
|
|
19
|
+
* `aria-expanded` and `data-state` that trigger writes have to reach this
|
|
20
|
+
* element.
|
|
21
|
+
*
|
|
22
|
+
* The icon is `IconAddReaction`, which is the glyph Figma calls
|
|
23
|
+
* `icon-mood-plus` — same path, verified against the node, different name in
|
|
24
|
+
* our collection.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ReactionButton: import('react').ForwardRefExoticComponent<ReactionButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
export { ReactionButton } from './ReactionButton.tsx';
|
|
3
|
+
export type { ReactionButtonProps } from './ReactionButton.tsx';
|
|
4
|
+
/**
|
|
5
|
+
* One pill, three jobs — Figma's `Reaction button` set (node `1454:124`). See
|
|
6
|
+
* `ReactionButton.mdx` for why the three share one component.
|
|
7
|
+
*
|
|
8
|
+
* `Hover` and `Focus` are not here because the browser knows them; `Reacted` is
|
|
9
|
+
* a `data-` attribute so it composes with `variant`; and `More open` is the
|
|
10
|
+
* `data-state` the popover writes onto its trigger.
|
|
11
|
+
*
|
|
12
|
+
* Class names, not utilities: the declarations live in `ReactionButton.module.css`
|
|
13
|
+
* behind `@apply`. See `Button/index.ts` for the full reasoning.
|
|
14
|
+
*/
|
|
15
|
+
export declare const reactionButtonVariants: (props?: ({
|
|
16
|
+
variant?: "add" | "reaction" | "more" | null | undefined;
|
|
17
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
18
|
+
export type ReactionButtonVariants = VariantProps<typeof reactionButtonVariants>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactionPickerEmoji } from './index.ts';
|
|
2
|
+
export interface ReactionPickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'role' | 'onKeyDown' | 'onBlur'> {
|
|
3
|
+
/** Which emoji to offer, and optionally a better name than Unicode's */
|
|
4
|
+
emojis?: ReactionPickerEmoji[];
|
|
5
|
+
/** Whether to draw the separator and the full-picker button. Figma's `Show more` */
|
|
6
|
+
showMore?: boolean;
|
|
7
|
+
/** An emoji was chosen. The grapheme, which is what the API stores */
|
|
8
|
+
onReact?: (emoji: string) => void;
|
|
9
|
+
/** The reader asked for the full picker, which is the consumer's to open */
|
|
10
|
+
onShowMore?: () => void;
|
|
11
|
+
dataTestid: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The six frequent emoji, as a toolbar. Mirrors `@sesame/orxata-core`
|
|
15
|
+
* ReactionPicker; see `ReactionPicker.mdx`.
|
|
16
|
+
*
|
|
17
|
+
* It is its own floating surface and must not be wrapped in an
|
|
18
|
+
* `OxPopoverContent`: that draws `Surface`, an 8px card, where this is a
|
|
19
|
+
* full-radius pill — one inside the other is two borders and two shadows.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ReactionPicker: import('react').ForwardRefExoticComponent<ReactionPickerProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { ReactionPicker } from './ReactionPicker.tsx';
|
|
2
|
+
export type { ReactionPickerProps } from './ReactionPicker.tsx';
|
|
3
|
+
/**
|
|
4
|
+
* One entry in the picker: a bare grapheme, or an object carrying a better name
|
|
5
|
+
* than Unicode's. See `ReactionPicker.mdx`.
|
|
6
|
+
*/
|
|
7
|
+
export type ReactionPickerEmoji = string | {
|
|
8
|
+
emoji: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Figma's own six (node `1482:262`), in Figma's order, with no skin-tone
|
|
13
|
+
* modifiers — the backend treats `👍` and `👍🏻` as two different reactions, so
|
|
14
|
+
* seeding one would split a reaction in two for everyone who took the default.
|
|
15
|
+
*
|
|
16
|
+
* Here rather than in the component, to stay where the Vue twin keeps it.
|
|
17
|
+
*/
|
|
18
|
+
export declare const DEFAULT_REACTION_EMOJIS: ReactionPickerEmoji[];
|
|
@@ -13,16 +13,18 @@ import { ChainedCommands } from '@tiptap/core';
|
|
|
13
13
|
* undo with either would be a different control wearing the wrong sign. A
|
|
14
14
|
* code *block* has only `icon-code`, already spoken for by inline code, and
|
|
15
15
|
* a rule has only `icon-minus`. The commands themselves are all in the
|
|
16
|
-
* preset — `
|
|
17
|
-
*
|
|
18
|
-
* behaviour.
|
|
16
|
+
* preset — `history` and `horizontalRule` are StarterKit extensions on
|
|
17
|
+
* TipTap 2 (`history` is what 3.x renamed to `undoRedo`), and the keyboard
|
|
18
|
+
* shortcuts work — so what is missing is the buttons, not the behaviour.
|
|
19
19
|
* - **A link is not a toggle.** `toggleLink` needs an `href`, and a button
|
|
20
20
|
* whose whole API is `command` has nowhere to get one. Wiring a URL prompt
|
|
21
21
|
* in here would be deciding what that prompt looks like for everybody. The
|
|
22
22
|
* toolbar takes arbitrary children instead, so a caller puts their own
|
|
23
23
|
* control in it and calls `editor.chain().setLink(…)` — which is also how
|
|
24
24
|
* anything else outside this list gets into a toolbar. The mark is styled
|
|
25
|
-
* either way; see `RICH_TEXT_SCHEMA`.
|
|
25
|
+
* either way; see `RICH_TEXT_SCHEMA`. On TipTap 2 `setLink` arrives with
|
|
26
|
+
* `@tiptap/extension-link`, which StarterKit does not carry — so it only
|
|
27
|
+
* exists for a caller who passed `Link` to `oxRichTextExtensions`.
|
|
26
28
|
*/
|
|
27
29
|
export type RichTextCommand = 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'heading1' | 'heading2' | 'heading3' | 'bulletList' | 'orderedList' | 'blockquote';
|
|
28
30
|
export interface RichTextCommandSpec {
|
|
@@ -61,6 +63,11 @@ export interface RichTextCommandSpec {
|
|
|
61
63
|
*
|
|
62
64
|
* A record and not a function, because the button resolves its own icon, label
|
|
63
65
|
* and pressed state from it — the only thing a caller writes is `command`.
|
|
66
|
+
*
|
|
67
|
+
* Every entry is listed unconditionally, including `underline`, whose extension
|
|
68
|
+
* is optional on TipTap 2. What decides whether a button appears is the
|
|
69
|
+
* editor's schema at runtime rather than this record — see
|
|
70
|
+
* `RichTextAdapter.supports`.
|
|
64
71
|
*/
|
|
65
72
|
export declare const RICH_TEXT_COMMANDS: Record<RichTextCommand, RichTextCommandSpec>;
|
|
66
73
|
/** Every command, in toolbar order. */
|
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
import { Extensions } from '@tiptap/core';
|
|
2
|
+
import { default as Link } from '@tiptap/extension-link';
|
|
3
|
+
import { default as Underline } from '@tiptap/extension-underline';
|
|
2
4
|
import { default as StarterKit } from '@tiptap/starter-kit';
|
|
5
|
+
/**
|
|
6
|
+
* The two marks StarterKit does not carry, handed over the same way StarterKit
|
|
7
|
+
* itself is.
|
|
8
|
+
*
|
|
9
|
+
* **On TipTap 2, `StarterKit` contains neither `Underline` nor `Link`** —
|
|
10
|
+
* `@tiptap/starter-kit@2.27.3` does not even depend on them, where 3.x does.
|
|
11
|
+
* That difference is the reason this parameter exists rather than the preset
|
|
12
|
+
* configuring them through `starterKit.configure()`, and it is worth knowing
|
|
13
|
+
* exactly how badly that fails, because it fails quietly in both directions:
|
|
14
|
+
*
|
|
15
|
+
* - `configure({ link: … })` on TipTap 2 is accepted and **stored**. No error,
|
|
16
|
+
* no warning, `starterKit.options.link` reads back exactly what was passed —
|
|
17
|
+
* and nothing anywhere consumes it, because there is no Link extension to
|
|
18
|
+
* consume it. A test asserting on `options.link` passes. The document has no
|
|
19
|
+
* `link` mark in it.
|
|
20
|
+
* - `toggleUnderline` is a command an extension contributes, so with no
|
|
21
|
+
* Underline extension the name is simply absent from the command manager.
|
|
22
|
+
* `editor.can().chain().focus().toggleUnderline()` is a call on `undefined`.
|
|
23
|
+
*
|
|
24
|
+
* Both are optional: a caller who wants neither passes neither, and the
|
|
25
|
+
* `underline` toolbar button then does not render at all rather than render
|
|
26
|
+
* disabled or render and throw. See `useRichTextAdapter` for how that is
|
|
27
|
+
* decided — the editor's own schema, so it covers a caller who narrows
|
|
28
|
+
* StarterKit as well.
|
|
29
|
+
*
|
|
30
|
+
* The keys are capitalised to match the names TipTap's own documentation gives
|
|
31
|
+
* these imports, so the call site is `{ Underline, Link }` with no renaming.
|
|
32
|
+
*/
|
|
33
|
+
export interface RichTextExtras {
|
|
34
|
+
/** `@tiptap/extension-underline`. Without it there is no underline button. */
|
|
35
|
+
Underline?: typeof Underline;
|
|
36
|
+
/**
|
|
37
|
+
* `@tiptap/extension-link`. Without it a typed URL stays text, and
|
|
38
|
+
* `editor.chain().setLink(…)` — the documented way to add the one mark the
|
|
39
|
+
* toolbar deliberately has no button for — does not exist.
|
|
40
|
+
*/
|
|
41
|
+
Link?: typeof Link;
|
|
42
|
+
}
|
|
3
43
|
/**
|
|
4
44
|
* The extension list both ends of a rich text field agree on.
|
|
5
45
|
*
|
|
@@ -15,40 +55,43 @@ import { default as StarterKit } from '@tiptap/starter-kit';
|
|
|
15
55
|
*
|
|
16
56
|
* ---
|
|
17
57
|
*
|
|
18
|
-
* **Why this takes
|
|
58
|
+
* **Why this takes its extensions as arguments instead of importing them.** The
|
|
19
59
|
* intended design was a plain exported array. It cannot be one, and the reason
|
|
20
60
|
* is worth writing down because the signature otherwise looks like ceremony:
|
|
21
61
|
*
|
|
22
62
|
* `oxRichTextExtensions` is published from `src/main.ts`, the barrel every
|
|
23
63
|
* consumer imports — including the one who only wants `OxButton`. A static
|
|
24
64
|
* `import StarterKit from '@tiptap/starter-kit'` anywhere in that graph becomes
|
|
25
|
-
* a top-level import in the built `
|
|
65
|
+
* a top-level import in the built `react-design-system.js`, and a bundler resolves
|
|
26
66
|
* every import it finds before it decides what to tree-shake. For a consumer
|
|
27
67
|
* who has not installed TipTap that is a module-resolution failure in their
|
|
28
68
|
* build — webpack calls it an error, Rollup leaves a bare specifier that fails
|
|
29
69
|
* at runtime — over a feature they never touched. "TipTap is an optional peer
|
|
30
70
|
* dependency" would be false the moment anything imported it eagerly.
|
|
31
71
|
*
|
|
32
|
-
* An `async` factory that `import()`s
|
|
33
|
-
* where it matters: `useEditor` needs its extensions synchronously, so
|
|
34
|
-
* caller would need a top-level `await` and a `<Suspense>` around their
|
|
35
|
-
* component in order to use a text field.
|
|
72
|
+
* An `async` factory that `import()`s them was the other option, and it is
|
|
73
|
+
* worse where it matters: `useEditor` needs its extensions synchronously, so
|
|
74
|
+
* every caller would need a top-level `await` and a `<Suspense>` around their
|
|
75
|
+
* own component in order to use a text field.
|
|
36
76
|
*
|
|
37
|
-
* So the caller hands over the
|
|
38
|
-
* file that is already importing `useEditor` from TipTap — and this package
|
|
39
|
-
* contributes the part that is actually its own: the configuration.
|
|
40
|
-
* parameter's type is
|
|
41
|
-
*
|
|
77
|
+
* So the caller hands over the extensions they already have — three imports, in
|
|
78
|
+
* a file that is already importing `useEditor` from TipTap — and this package
|
|
79
|
+
* contributes the part that is actually its own: the configuration. Every
|
|
80
|
+
* parameter's type is erased, so this module has no runtime dependency on
|
|
81
|
+
* TipTap at all, and none of the four specifiers needs to be external in
|
|
82
|
+
* `vite.config.ts`.
|
|
42
83
|
*
|
|
43
84
|
* ```ts
|
|
85
|
+
* import Link from '@tiptap/extension-link';
|
|
86
|
+
* import Underline from '@tiptap/extension-underline';
|
|
44
87
|
* import StarterKit from '@tiptap/starter-kit';
|
|
45
|
-
* import { useEditor } from '@tiptap/
|
|
46
|
-
* import { oxRichTextExtensions } from '@
|
|
88
|
+
* import { useEditor } from '@tiptap/react';
|
|
89
|
+
* import { oxRichTextExtensions } from '@sesamehr/react-design-system';
|
|
47
90
|
*
|
|
48
91
|
* const editor = useEditor({
|
|
49
|
-
* extensions: oxRichTextExtensions(StarterKit),
|
|
92
|
+
* extensions: oxRichTextExtensions(StarterKit, { Underline, Link }),
|
|
50
93
|
* content: '<p>…</p>',
|
|
51
94
|
* });
|
|
52
95
|
* ```
|
|
53
96
|
*/
|
|
54
|
-
export declare const oxRichTextExtensions: (starterKit: typeof StarterKit) => Extensions;
|
|
97
|
+
export declare const oxRichTextExtensions: (starterKit: typeof StarterKit, extras?: RichTextExtras) => Extensions;
|
|
@@ -2,6 +2,6 @@ export { RichTextEditor } from './RichTextEditor.tsx';
|
|
|
2
2
|
export { RichTextToolbar } from './RichTextToolbar/index.ts';
|
|
3
3
|
export { RichTextToolbarButton } from './RichTextToolbarButton/index.ts';
|
|
4
4
|
export { RICH_TEXT_COMMANDS, RICH_TEXT_COMMAND_NAMES, type RichTextCommand, type RichTextCommandSpec, } from './commands.ts';
|
|
5
|
-
export { oxRichTextExtensions } from './extensions.ts';
|
|
5
|
+
export { type RichTextExtras, oxRichTextExtensions } from './extensions.ts';
|
|
6
6
|
export { type RichTextAdapter, type RichTextSource, isRichTextAdapter, useRichTextAdapter, } from './useRichTextAdapter.ts';
|
|
7
7
|
export { useRichTextToolbar } from './useRichTextToolbar.ts';
|
|
@@ -3,10 +3,10 @@ import { RichTextCommand } from './commands.ts';
|
|
|
3
3
|
/**
|
|
4
4
|
* What the toolbar talks to, and the only thing it talks to.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* run this, is it on, is it available
|
|
8
|
-
* second editor becomes an implementation of this
|
|
9
|
-
* second toolbar.
|
|
6
|
+
* Four questions, which between them are everything a toolbar button needs:
|
|
7
|
+
* run this, is it on, is it available, does it exist here at all. Nothing here
|
|
8
|
+
* mentions TipTap, so a second editor becomes an implementation of this
|
|
9
|
+
* interface rather than a second toolbar.
|
|
10
10
|
*
|
|
11
11
|
* **What this is deliberately not is an abstraction of the document.** The
|
|
12
12
|
* document stays TipTap JSON, read and written through the editor the caller
|
|
@@ -21,6 +21,26 @@ export interface RichTextAdapter {
|
|
|
21
21
|
isActive: (command: RichTextCommand) => boolean;
|
|
22
22
|
/** Whether the command can run at all — a disabled button if not. */
|
|
23
23
|
can: (command: RichTextCommand) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the command exists in this editor at all — **no button** if not,
|
|
26
|
+
* which is the difference between this and `can`.
|
|
27
|
+
*
|
|
28
|
+
* `can` is "not now": a list inside a code block, an empty selection. The
|
|
29
|
+
* reader waits and tries again. This is "not here": the extension behind the
|
|
30
|
+
* command was never loaded, so there is nothing to wait for, and a disabled
|
|
31
|
+
* button that will never enable is a control that lies about what the field
|
|
32
|
+
* can do.
|
|
33
|
+
*
|
|
34
|
+
* It exists because of TipTap 2. `StarterKit` there carries neither
|
|
35
|
+
* `Underline` nor `Link`, so `oxRichTextExtensions` takes them as optional
|
|
36
|
+
* arguments — and a caller who omits `Underline` would otherwise get an
|
|
37
|
+
* underline button whose `can` probe calls `toggleUnderline` on `undefined`.
|
|
38
|
+
*
|
|
39
|
+
* Optional, and absent means supported: an adapter written against an earlier
|
|
40
|
+
* version of this interface keeps working, and so does one for an editor
|
|
41
|
+
* whose command set is fixed.
|
|
42
|
+
*/
|
|
43
|
+
supports?: (command: RichTextCommand) => boolean;
|
|
24
44
|
}
|
|
25
45
|
/** Whatever `OxRichTextEditor` will accept as the thing the toolbar drives. */
|
|
26
46
|
export type RichTextSource = Editor | RichTextAdapter;
|
package/dist/main.d.ts
CHANGED
|
@@ -39,9 +39,13 @@ export { VoiceMessage as OxVoiceMessage, type AudiowaveformJson, type WaveformSo
|
|
|
39
39
|
export { FilePreviewCard as OxFilePreviewCard } from './Display/FilePreviewCard/index.ts';
|
|
40
40
|
export { ChatBubble as OxChatBubble, chatBubbleVariants, type ChatBubbleDelivery, type ChatBubbleVariants, } from './Display/ChatBubble/index.ts';
|
|
41
41
|
export { ChatBubbleStatus as OxChatBubbleStatus, chatBubbleStatusVariants, type ChatBubbleStatusVariants, } from './Display/ChatBubble/ChatBubbleStatus/index.ts';
|
|
42
|
+
export { CommentItem as OxCommentItem } from './Display/CommentItem/index.ts';
|
|
42
43
|
export { RichText as OxRichText, RICH_TEXT_SCHEMA, type RichTextSchemaMark, type RichTextSchemaNode, } from './Display/RichText/index.ts';
|
|
43
44
|
export { Mention as OxMention, mentionVariants, type MentionVariants, } from './Display/Mention/index.ts';
|
|
44
45
|
export { Chip as OxChip, chipVariants, type ChipVariants, } from './Display/Chip/index.ts';
|
|
46
|
+
export { ReactionBar as OxReactionBar, type Reaction, type ReactionSplit, } from './Display/ReactionBar/index.ts';
|
|
47
|
+
export { ReactionButton as OxReactionButton, reactionButtonVariants, type ReactionButtonVariants, } from './Display/ReactionButton/index.ts';
|
|
48
|
+
export { ReactionPicker as OxReactionPicker, type ReactionPickerEmoji, } from './Display/ReactionPicker/index.ts';
|
|
45
49
|
export { PlayerPill as OxPlayerPill, PlayerPillAction as OxPlayerPillAction, PlayerPillStatus as OxPlayerPillStatus, PlayerPillTime as OxPlayerPillTime, playerPillVariants, type PlayerPillActionName, type PlayerPillState, type PlayerPillVariants, } from './Display/PlayerPill/index.ts';
|
|
46
50
|
export { PointMarker as OxPointMarker, pointMarkerVariants, type PointMarkerVariants, } from './Display/PointMarker/index.ts';
|
|
47
51
|
export { Tag as OxTag, tagVariants, type TagVariants, } from './Display/Tag/index.ts';
|
|
@@ -70,6 +74,7 @@ export { Breadcrumb as OxBreadcrumb, BreadcrumbList as OxBreadcrumbList, Breadcr
|
|
|
70
74
|
export { Counter as OxCounter, counterVariants, type CounterVariants, } from './Forms/Field/Counter/index.ts';
|
|
71
75
|
export { FieldGroup as OxFieldGroup, FieldLabel as OxFieldLabel, FieldMessage as OxFieldMessage, useFieldControl, useFieldControlGroup, type FieldControlAttrs, type FieldControlGroupAttrs, type FieldGroupProps, type FieldVariant, } from './Forms/Field/index.ts';
|
|
72
76
|
export { AiSearch as OxAiSearch, AiSearchAsk as OxAiSearchAsk, AiSearchPanel as OxAiSearchPanel, AiSearchSend as OxAiSearchSend, AiSearchShortcut as OxAiSearchShortcut, AiSearchSuggestion as OxAiSearchSuggestion, } from './Forms/Inputs/AiSearch/index.ts';
|
|
73
|
-
export { InputGroup as OxInputGroup, InputText as OxInputText, InputNumber as OxInputNumber, InputNumberContent as OxInputNumberContent, InputNumberDecrement as OxInputNumberDecrement, InputNumberIncrement as OxInputNumberIncrement, InputNumberInput as OxInputNumberInput, InputPassword as OxInputPassword, InputPasswordInput as OxInputPasswordInput, InputPasswordToggle as OxInputPasswordToggle, useInputPassword, InputOtp as OxInputOtp, InputOtpGroup as OxInputOtpGroup, InputOtpSlot as OxInputOtpSlot, InputOtpSeparator as OxInputOtpSeparator, useInputOtp, Calendar as OxCalendar, CalendarRange as OxCalendarRange, CalendarDay as OxCalendarDay, calendarDayVariants, Combobox as OxCombobox, ComboboxCancel as OxComboboxCancel, ComboboxInput as OxComboboxInput, ComboboxChipsInput as OxComboboxChipsInput, ComboboxContent as OxComboboxContent, ComboboxItem as OxComboboxItem, ComboboxItemEdit as OxComboboxItemEdit, ComboboxEmpty as OxComboboxEmpty, ComboboxGroup as OxComboboxGroup, ComboboxSeparator as OxComboboxSeparator, ChatInput as OxChatInput, ColorPicker as OxColorPicker, ColorPickerTrigger as OxColorPickerTrigger, ColorPickerContent as OxColorPickerContent, ColorPickerSwatch as OxColorPickerSwatch, useColorPicker, IconPicker as OxIconPicker, IconPickerTrigger as OxIconPickerTrigger, IconPickerContent as OxIconPickerContent, IconPickerItem as OxIconPickerItem, useIconPicker, DatePicker as OxDatePicker, DateRangePicker as OxDateRangePicker, DatePickerTrigger as OxDatePickerTrigger, DatePickerHeader as OxDatePickerHeader, DatePickerMonthSelect as OxDatePickerMonthSelect, DatePickerYearSelect as OxDatePickerYearSelect, SearchBar as OxSearchBar, searchBarVariants, SearchPanel as OxSearchPanel, SearchPanelInput as OxSearchPanelInput, SearchPanelList as OxSearchPanelList, SearchPanelGroup as OxSearchPanelGroup, SearchPanelItem as OxSearchPanelItem, SearchPanelEmpty as OxSearchPanelEmpty, Select as OxSelect, SelectTrigger as OxSelectTrigger, SelectContent as OxSelectContent, SelectItem as OxSelectItem, SelectGroup as OxSelectGroup, SelectSeparator as OxSelectSeparator, TimePicker as OxTimePicker, TimePickerField as OxTimePickerField, TimePickerList as OxTimePickerList, TimePickerWheel as OxTimePickerWheel, TimePickerWheelColumn as OxTimePickerWheelColumn, Textarea as OxTextarea, RichTextEditor as OxRichTextEditor, RichTextToolbar as OxRichTextToolbar, RichTextToolbarButton as OxRichTextToolbarButton, RICH_TEXT_COMMANDS, RICH_TEXT_COMMAND_NAMES, isRichTextAdapter, oxRichTextExtensions, useRichTextAdapter, useRichTextToolbar, type RichTextAdapter, type RichTextCommand, type RichTextCommandSpec, type RichTextSource, Switch as OxSwitch, Checkbox as OxCheckbox, RadioButton as OxRadioButton, RadioGroup as OxRadioGroup, ToggleGroup as OxToggleGroup, ToggleLabel as OxToggleLabel, ToggleDescription as OxToggleDescription, SWITCH_SIZES, type InputNumberProps, type InputPasswordProps, type InputPasswordContext, type InputOtpProps, type InputOtpSlotProps, type InputOtpContext, type CalendarProps, type CalendarRangeProps, type CalendarDateRange, type CalendarDayProps, type CalendarDayState, type CalendarDayVariants, type CalendarConstraints, type CalendarNav, type ComboboxProps, type ChatInputActionLabels, type ChatInputState, type ColorPickerProps, type ColorPickerContext, type IconPickerProps, type IconPickerContext, type DatePickerProps, type DateRangePickerProps, type DatePickerTriggerProps, type DatePickerHeaderProps, type DatePickerMonthSelectProps, type DatePickerYearSelectProps, type SearchBarVariants, type SelectProps, type TimePickerProps, type TimeFormat, type TimePart, type TextareaCounterState, type RadioGroupProps, type ToggleGroupProps, type ToggleLabelProps, type ToggleDescriptionProps, } from './Forms/Inputs/index.ts';
|
|
77
|
+
export { InputGroup as OxInputGroup, InputText as OxInputText, InputNumber as OxInputNumber, InputNumberContent as OxInputNumberContent, InputNumberDecrement as OxInputNumberDecrement, InputNumberIncrement as OxInputNumberIncrement, InputNumberInput as OxInputNumberInput, InputPassword as OxInputPassword, InputPasswordInput as OxInputPasswordInput, InputPasswordToggle as OxInputPasswordToggle, useInputPassword, InputOtp as OxInputOtp, InputOtpGroup as OxInputOtpGroup, InputOtpSlot as OxInputOtpSlot, InputOtpSeparator as OxInputOtpSeparator, useInputOtp, Calendar as OxCalendar, CalendarRange as OxCalendarRange, CalendarDay as OxCalendarDay, calendarDayVariants, Combobox as OxCombobox, ComboboxCancel as OxComboboxCancel, ComboboxInput as OxComboboxInput, ComboboxChipsInput as OxComboboxChipsInput, ComboboxContent as OxComboboxContent, ComboboxItem as OxComboboxItem, ComboboxItemEdit as OxComboboxItemEdit, ComboboxEmpty as OxComboboxEmpty, ComboboxGroup as OxComboboxGroup, ComboboxSeparator as OxComboboxSeparator, ChatInput as OxChatInput, ColorPicker as OxColorPicker, ColorPickerTrigger as OxColorPickerTrigger, ColorPickerContent as OxColorPickerContent, ColorPickerSwatch as OxColorPickerSwatch, useColorPicker, IconPicker as OxIconPicker, IconPickerTrigger as OxIconPickerTrigger, IconPickerContent as OxIconPickerContent, IconPickerItem as OxIconPickerItem, useIconPicker, DatePicker as OxDatePicker, DateRangePicker as OxDateRangePicker, DatePickerTrigger as OxDatePickerTrigger, DatePickerHeader as OxDatePickerHeader, DatePickerMonthSelect as OxDatePickerMonthSelect, DatePickerYearSelect as OxDatePickerYearSelect, SearchBar as OxSearchBar, searchBarVariants, SearchPanel as OxSearchPanel, SearchPanelInput as OxSearchPanelInput, SearchPanelList as OxSearchPanelList, SearchPanelGroup as OxSearchPanelGroup, SearchPanelItem as OxSearchPanelItem, SearchPanelEmpty as OxSearchPanelEmpty, Select as OxSelect, SelectTrigger as OxSelectTrigger, SelectContent as OxSelectContent, SelectItem as OxSelectItem, SelectGroup as OxSelectGroup, SelectSeparator as OxSelectSeparator, TimePicker as OxTimePicker, TimePickerField as OxTimePickerField, TimePickerList as OxTimePickerList, TimePickerWheel as OxTimePickerWheel, TimePickerWheelColumn as OxTimePickerWheelColumn, Textarea as OxTextarea, RichTextEditor as OxRichTextEditor, RichTextToolbar as OxRichTextToolbar, RichTextToolbarButton as OxRichTextToolbarButton, RICH_TEXT_COMMANDS, RICH_TEXT_COMMAND_NAMES, isRichTextAdapter, oxRichTextExtensions, useRichTextAdapter, useRichTextToolbar, type RichTextAdapter, type RichTextCommand, type RichTextCommandSpec, type RichTextExtras, type RichTextSource, Switch as OxSwitch, Checkbox as OxCheckbox, RadioButton as OxRadioButton, RadioGroup as OxRadioGroup, ToggleGroup as OxToggleGroup, ToggleLabel as OxToggleLabel, ToggleDescription as OxToggleDescription, SWITCH_SIZES, type InputNumberProps, type InputPasswordProps, type InputPasswordContext, type InputOtpProps, type InputOtpSlotProps, type InputOtpContext, type CalendarProps, type CalendarRangeProps, type CalendarDateRange, type CalendarDayProps, type CalendarDayState, type CalendarDayVariants, type CalendarConstraints, type CalendarNav, type ComboboxProps, type ChatInputActionLabels, type ChatInputState, type ColorPickerProps, type ColorPickerContext, type IconPickerProps, type IconPickerContext, type DatePickerProps, type DateRangePickerProps, type DatePickerTriggerProps, type DatePickerHeaderProps, type DatePickerMonthSelectProps, type DatePickerYearSelectProps, type SearchBarVariants, type SelectProps, type TimePickerProps, type TimeFormat, type TimePart, type TextareaCounterState, type RadioGroupProps, type ToggleGroupProps, type ToggleLabelProps, type ToggleDescriptionProps, } from './Forms/Inputs/index.ts';
|
|
78
|
+
export { KpiCard as OxKpiCard, kpiCardVariants, type KpiCardVariants, } from './Data/KpiCard/index.ts';
|
|
74
79
|
export { Table as OxTable, TableVirtualized as OxTableVirtualized, TableHead as OxTableHead, TableBody as OxTableBody, TableRow as OxTableRow, TableCell as OxTableCell, TableHeaderCell as OxTableHeaderCell, TableSelectCell as OxTableSelectCell, TableDragCell as OxTableDragCell, TableBulkHeader as OxTableBulkHeader, TablePagination as OxTablePagination, TableEmpty as OxTableEmpty, TableRowExpanded as OxTableRowExpanded, TableExpandCell as OxTableExpandCell, TableColumnVisibility as OxTableColumnVisibility, useTable, useTableSelection, useTableSorting, useTablePagination, useTableDetailRow, useTablePinning, useTableColumns, useScrollShadow, useDragToScroll, useFixedColumns, useTableVirtual, } from './Data/Table/index.ts';
|
|
75
80
|
export type { UseTableOptions, UseTableReturn, UseTableSelectionReturn, UseTableSortingReturn, UseTablePaginationOptions, UseTablePaginationReturn, DetailRowInstance, DetailRowOptions, DetailRowPluginDef, UseTablePinningOptions, UseTablePinningReturn, CellInfo, HeaderInfo, UseTableVirtualOptions, UseTableVirtualReturn, UseTableColumnsOptions, UseTableColumnsReturn, UseScrollShadowOptions, UseScrollShadowReturn, UseDragToScrollOptions, UseDragToScrollReturn, UseFixedColumnsOptions, TableProps, TableMode, ColumnDef, ColumnAlign, CellContext, SortingState, PaginationState, PaginationChangePayload, SortingChangePayload, SelectionChangePayload, FilterChangePayload, ColumnResizeMode, ColumnVisibilityState, ColumnOrderState, ExpandedState, ColumnVisibilityChangePayload, ColumnOrderChangePayload, RowExpandChangePayload, ColumnResizePayload, ColumnPinningState, } from './Data/Table/index.ts';
|