@kystverket/styrbord 2.10.0 → 2.12.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/src/components/designsystemet/Avatar/Avatar.d.ts +6 -1
- package/dist/src/components/kystverket/Header/Header.d.ts +11 -1
- package/dist/src/components/kystverket/Header/Header.stories.d.ts +6 -0
- package/dist/src/components/kystverket/RichTextArea/components/Toolbar/toolbar.d.ts +3 -1
- package/dist/src/components/kystverket/RichTextArea/components/Toolbar/toolbar.stories.d.ts +3 -1
- package/dist/src/components/kystverket/RichTextArea/richTextArea.editor.d.ts +8 -2
- package/dist/src/components/kystverket/RichTextArea/richTextArea.editorFactory.d.ts +3 -1
- package/dist/src/components/kystverket/RichTextArea/richTextArea.stories.d.ts +3 -0
- package/dist/src/components/kystverket/RichTextArea/richTextArea.types.d.ts +4 -0
- package/dist/style.js +2001 -1977
- package/dist/style.umd.cjs +10 -10
- package/package.json +1 -1
|
@@ -13,6 +13,11 @@ type AriaHidden = Partial<AriaLabel> & {
|
|
|
13
13
|
'aria-hidden': true | 'true';
|
|
14
14
|
};
|
|
15
15
|
export type AvatarProps = MergeRight<DsAvatarProps, (AriaLabel | AriaHidden) & {
|
|
16
|
+
/**
|
|
17
|
+
* What `auto` seeds the generated color or pattern from, typically a user id. Use it when two
|
|
18
|
+
* people can share a name, or when `aria-label` holds more than the name. Falls back to
|
|
19
|
+
* `aria-label` when unset or blank.
|
|
20
|
+
*/
|
|
16
21
|
'auto-seed'?: string;
|
|
17
22
|
'data-color'?: DataColor;
|
|
18
23
|
'data-color-variant'?: DataColorVariant;
|
|
@@ -28,7 +33,7 @@ export type AvatarProps = MergeRight<DsAvatarProps, (AriaLabel | AriaHidden) & {
|
|
|
28
33
|
checked?: boolean;
|
|
29
34
|
/**
|
|
30
35
|
* Renders a generated [boring avatar](https://boringavatars.com) in Kystverket's colors,
|
|
31
|
-
* seeded from `aria-label
|
|
36
|
+
* seeded from `auto-seed`, or `aria-label` when that is unset. Ignored when `children` is set.
|
|
32
37
|
*
|
|
33
38
|
* Defaults to the `auto` of the nearest `AvatarProvider`. Set to `false` to opt this avatar
|
|
34
39
|
* out of a provider's default and render it without generated colors.
|
|
@@ -39,13 +39,23 @@ export interface HeaderProps {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
type HeaderProfile = {
|
|
42
|
+
/**
|
|
43
|
+
* A stable id for the user. Seeds the avatar's generated color or pattern, and is what an
|
|
44
|
+
* `AvatarProvider`'s `auto-reserved-seed` should be set to. Falls back to `name`.
|
|
45
|
+
*/
|
|
46
|
+
id?: string;
|
|
42
47
|
name: string;
|
|
43
48
|
department?: string;
|
|
44
49
|
/**
|
|
45
50
|
* URL of a profile picture. Falls back to initials when unset or when the image fails to load.
|
|
46
51
|
*/
|
|
47
52
|
image?: string;
|
|
48
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Props for the profile avatar. Every `Avatar` prop is accepted except those the header sets
|
|
55
|
+
* itself, so new `Avatar` props reach the header without changes here.
|
|
56
|
+
* Without it, the avatar is `data-color="success"` unless an `AvatarProvider` sets `auto`.
|
|
57
|
+
*/
|
|
58
|
+
avatarStyle?: Omit<AvatarProps, 'aria-label' | 'aria-hidden' | 'initials' | 'children' | 'data-size'>;
|
|
49
59
|
};
|
|
50
60
|
export declare const nameToInitials: (name?: string) => string;
|
|
51
61
|
export declare function MainLinkItem(props: HeaderLinkItemWithOnClick): React.JSX.Element;
|
|
@@ -28,4 +28,10 @@ export declare const medProfilOgMenyItems: Story;
|
|
|
28
28
|
export declare const medMenyItems: Story;
|
|
29
29
|
export declare const medProfil: Story;
|
|
30
30
|
export declare const medProfilbilde: Story;
|
|
31
|
+
/**
|
|
32
|
+
* Inside an `AvatarProvider` with `auto`, the header avatar gets a generated color seeded from
|
|
33
|
+
* `profile.id`. With `auto-reserved-seed` set to the same id, the logged-in user keeps a color
|
|
34
|
+
* no one else on the page gets, and looks the same in the header as in the list below.
|
|
35
|
+
*/
|
|
36
|
+
export declare const medAvatarProvider: Story;
|
|
31
37
|
export declare const medProfilLenker: Story;
|
|
@@ -13,6 +13,8 @@ type ToolbarProps = {
|
|
|
13
13
|
linkPopoverTarget?: string;
|
|
14
14
|
canUploadImage?: boolean;
|
|
15
15
|
showToolbar?: boolean;
|
|
16
|
+
allowHeading?: boolean;
|
|
17
|
+
allowLink?: boolean;
|
|
16
18
|
onBold: () => void;
|
|
17
19
|
onItalic: () => void;
|
|
18
20
|
onBulletList: () => void;
|
|
@@ -24,5 +26,5 @@ type ToolbarProps = {
|
|
|
24
26
|
onImageUpload?: () => void;
|
|
25
27
|
};
|
|
26
28
|
export declare const getToolbarItems: (toolbar: Element) => HTMLElement[];
|
|
27
|
-
export declare const Toolbar: ({ ref, disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, canUploadImage, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, onImageUpload, showToolbar, }: ToolbarProps) => React.JSX.Element | undefined;
|
|
29
|
+
export declare const Toolbar: ({ ref, disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, canUploadImage, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, onImageUpload, showToolbar, allowHeading, allowLink, }: ToolbarProps) => React.JSX.Element | undefined;
|
|
28
30
|
export {};
|
|
@@ -2,7 +2,7 @@ import type { StoryObj } from '@storybook/react-vite';
|
|
|
2
2
|
import { type BlockType } from './toolbar';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ ref, disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, canUploadImage, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, onImageUpload, showToolbar, }: {
|
|
5
|
+
component: ({ ref, disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, canUploadImage, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, onImageUpload, showToolbar, allowHeading, allowLink, }: {
|
|
6
6
|
ref?: React.Ref<HTMLDivElement>;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
isBoldActive: boolean;
|
|
@@ -14,6 +14,8 @@ declare const meta: {
|
|
|
14
14
|
linkPopoverTarget?: string;
|
|
15
15
|
canUploadImage?: boolean;
|
|
16
16
|
showToolbar?: boolean;
|
|
17
|
+
allowHeading?: boolean;
|
|
18
|
+
allowLink?: boolean;
|
|
17
19
|
onBold: () => void;
|
|
18
20
|
onItalic: () => void;
|
|
19
21
|
onBulletList: () => void;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { InlineImageConfig } from '@milkdown/components/image-inline';
|
|
2
|
+
import type { MilkdownPlugin } from '@milkdown/ctx';
|
|
2
3
|
import type { Node as ProseNode } from '@milkdown/prose/model';
|
|
3
4
|
import { Plugin } from '@milkdown/prose/state';
|
|
4
5
|
import type { EditorView } from '@milkdown/prose/view';
|
|
5
6
|
import type { ImageInsertHandler, UploadImageFn } from './richTextArea.types';
|
|
6
7
|
export declare const normalizeMarkdownBreakTags: (value: string) => string;
|
|
7
|
-
export declare const richTextCommonmarkPlugins:
|
|
8
|
-
export
|
|
8
|
+
export declare const richTextCommonmarkPlugins: MilkdownPlugin[];
|
|
9
|
+
export type RichTextFeatures = {
|
|
10
|
+
allowHeading: boolean;
|
|
11
|
+
allowLink: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const createRichTextCommonmarkPlugins: (features: RichTextFeatures) => MilkdownPlugin[];
|
|
14
|
+
export declare const richTextEditorPlugins: readonly [MilkdownPlugin[], MilkdownPlugin[], MilkdownPlugin[], MilkdownPlugin];
|
|
9
15
|
export declare const hasImageFile: (files: ArrayLike<File> | undefined) => File | null;
|
|
10
16
|
export declare const createRichTextAreaEditorEditable: (disabled: boolean) => () => boolean;
|
|
11
17
|
export declare const handleRichTextAreaEditorClick: (_view: EditorView, event: MouseEvent) => boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Editor } from '@milkdown/core';
|
|
2
2
|
import type { InlineImageConfig } from '@milkdown/components/image-inline';
|
|
3
3
|
import type { Ctx } from '@milkdown/ctx';
|
|
4
|
+
import type { RichTextFeatures } from './richTextArea.editor';
|
|
4
5
|
type CreateRichTextAreaEditorParams = {
|
|
5
6
|
root: HTMLElement;
|
|
6
7
|
disabled: boolean;
|
|
@@ -10,6 +11,7 @@ type CreateRichTextAreaEditorParams = {
|
|
|
10
11
|
/** Whether Alt+F10 has a toolbar item to go to; without one, Tab must be allowed to leave a list. */
|
|
11
12
|
canReachToolbar: () => boolean;
|
|
12
13
|
canUploadImage: boolean;
|
|
14
|
+
features: RichTextFeatures;
|
|
13
15
|
dispatchImageFromFile: (file: File) => void;
|
|
14
16
|
updateInlineImageConfig: (config: InlineImageConfig) => InlineImageConfig;
|
|
15
17
|
updateToolbarState: (ctx: Ctx) => void;
|
|
@@ -21,5 +23,5 @@ type CreateRichTextAreaEditorParams = {
|
|
|
21
23
|
getMaxLength: () => number | undefined;
|
|
22
24
|
isExternalUpdate: () => boolean;
|
|
23
25
|
};
|
|
24
|
-
export declare const createRichTextAreaEditor: ({ root, disabled, editorMarkdown, describedBy, canReachToolbar, canUploadImage, dispatchImageFromFile, updateInlineImageConfig, updateToolbarState, onMarkdownUpdated, onEmptyChange, toValue, onValueLengthChange, getMaxLength, isExternalUpdate, }: CreateRichTextAreaEditorParams) => Editor;
|
|
26
|
+
export declare const createRichTextAreaEditor: ({ root, disabled, editorMarkdown, describedBy, canReachToolbar, canUploadImage, features, dispatchImageFromFile, updateInlineImageConfig, updateToolbarState, onMarkdownUpdated, onEmptyChange, toValue, onValueLengthChange, getMaxLength, isExternalUpdate, }: CreateRichTextAreaEditorParams) => Editor;
|
|
25
27
|
export {};
|
|
@@ -18,6 +18,8 @@ declare const meta: {
|
|
|
18
18
|
maxLength?: number | undefined;
|
|
19
19
|
bottomToolbar?: React.ReactNode;
|
|
20
20
|
showToolbar?: boolean | undefined;
|
|
21
|
+
allowHeading?: boolean | undefined;
|
|
22
|
+
allowLink?: boolean | undefined;
|
|
21
23
|
onImageUpload?: import("./richTextArea.types").OnImageUploadFn | undefined;
|
|
22
24
|
onImageRemove?: ((ref: string) => Promise<void>) | undefined;
|
|
23
25
|
}>) => React.JSX.Element))[];
|
|
@@ -28,6 +30,7 @@ type Story = StoryObj<typeof meta>;
|
|
|
28
30
|
export declare const Default: Story;
|
|
29
31
|
export declare const Disabled: Story;
|
|
30
32
|
export declare const WithCodeFormatting: Story;
|
|
33
|
+
export declare const WithoutHeadingsAndLinks: Story;
|
|
31
34
|
export declare const WithError: Story;
|
|
32
35
|
export declare const WithMaxLength: Story;
|
|
33
36
|
export declare const WithBottomToolbar: Story;
|
|
@@ -18,6 +18,10 @@ export type RichTextAreaProps = {
|
|
|
18
18
|
bottomToolbar?: ReactNode;
|
|
19
19
|
/** Optional upload handler that returns a display src and optional stable image ref. */
|
|
20
20
|
showToolbar?: boolean;
|
|
21
|
+
/** Allow headings. When false, the format menu is hidden and headings in the value load as paragraphs. Defaults to true. */
|
|
22
|
+
allowHeading?: boolean;
|
|
23
|
+
/** Allow links. When false, the link button is hidden and links in the value load as their text. Defaults to true. */
|
|
24
|
+
allowLink?: boolean;
|
|
21
25
|
onImageUpload?: OnImageUploadFn;
|
|
22
26
|
/** Optional remove handler for deleting persisted images by stable ref. */
|
|
23
27
|
onImageRemove?: (ref: string) => Promise<void>;
|