@kystverket/styrbord 1.4.7 → 1.4.8

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.
@@ -1,2 +1,2 @@
1
- export declare const iconIdList: readonly ["add", "add_box", "add_location", "add_location_alt", "adjust", "anchor", "archive", "arrow_back", "arrow_forward", "arrow_right_alt", "article", "calendar_month", "change_history", "chat", "check", "check_circle", "chevron_left", "chevron_right", "circle", "close", "cloud_alert", "cloud_done", "code_blocks", "content_copy", "data_table", "delete", "description", "directions_boat", "distance", "domain", "download", "edit", "edit_document", "edit_location", "edit_location_alt", "edit_square", "error", "event", "explore", "explore_nearby", "export_notes", "favorite", "file_map", "file_save", "folder_open", "format_align_center", "format_align_left", "format_align_right", "globe_uk", "image", "inbox", "info", "info_i", "keyboard_arrow_down", "keyboard_arrow_up", "language", "layers", "lightbulb", "link", "location_chip", "lock", "login", "logout", "mail", "map", "map_pin_heart", "menu", "mode_cool", "more_vert", "move", "numbers", "open_in_new", "pan_zoom", "pending_actions", "person", "person_add", "person_pin", "person_pin_circle", "photo_camera", "picture_as_pdf", "pin_drop", "radio_button_checked", "radio_button_unchecked", "sailing", "save", "send", "settings", "settings_input_antenna", "severe_cold", "source_environment", "stylus", "timeline", "upload", "video_library", "videocam", "view_list", "warning", "zoom_in_map", "zoom_out_map"];
1
+ export declare const iconIdList: readonly ["add", "add_box", "add_location", "add_location_alt", "adjust", "anchor", "archive", "arrow_back", "arrow_forward", "arrow_right_alt", "article", "calendar_month", "change_history", "chat", "check", "check_circle", "chevron_left", "chevron_right", "circle", "close", "cloud_alert", "cloud_done", "code_blocks", "content_copy", "data_table", "delete", "description", "directions_boat", "distance", "domain", "download", "edit", "edit_document", "edit_location", "edit_location_alt", "edit_square", "error", "event", "explore", "explore_nearby", "export_notes", "favorite", "file_map", "file_save", "folder_open", "format_align_center", "format_align_left", "format_align_right", "globe_uk", "image", "inbox", "info", "info_i", "keyboard_arrow_down", "keyboard_arrow_up", "language", "layers", "lightbulb", "link", "location_chip", "lock", "login", "logout", "mail", "map", "map_pin_heart", "menu", "mode_cool", "more_vert", "move", "numbers", "open_in_new", "pan_zoom", "pending_actions", "person", "person_add", "person_pin", "person_pin_circle", "photo_camera", "picture_as_pdf", "pin_drop", "radio_button_checked", "radio_button_unchecked", "sailing", "save", "send", "settings", "settings_input_antenna", "severe_cold", "source_environment", "stylus", "timeline", "upload", "video_library", "videocam", "view_list", "warning", "zoom_in_map", "zoom_out_map", "format_italic", "format_bold", "format_list_bulleted", "format_list_numbered", "format_align_justify", "undo", "redo"];
2
2
  export type IconId = (typeof iconIdList)[number];
@@ -0,0 +1,11 @@
1
+ type LinkEditorProps = {
2
+ open: boolean;
3
+ anchorId: string;
4
+ href: string;
5
+ hasSelection: boolean;
6
+ onSave: (href: string) => void;
7
+ onClose: () => void;
8
+ onRemove: () => void;
9
+ };
10
+ declare const LinkEditor: ({ href, open, hasSelection, onSave, onClose, anchorId, onRemove }: LinkEditorProps) => React.JSX.Element;
11
+ export default LinkEditor;
@@ -0,0 +1,35 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ declare const meta: {
3
+ title: string;
4
+ component: ({ href, open, hasSelection, onSave, onClose, anchorId, onRemove }: {
5
+ open: boolean;
6
+ anchorId: string;
7
+ href: string;
8
+ hasSelection: boolean;
9
+ onSave: (href: string) => void;
10
+ onClose: () => void;
11
+ onRemove: () => void;
12
+ }) => React.JSX.Element;
13
+ decorators: ((Story: import("storybook/internal/csf").PartialStoryFn) => React.JSX.Element)[];
14
+ tags: string[];
15
+ argTypes: {
16
+ onSave: {
17
+ action: string;
18
+ };
19
+ onClose: {
20
+ action: string;
21
+ };
22
+ onRemove: {
23
+ action: string;
24
+ };
25
+ hasSelection: {
26
+ control: "boolean";
27
+ };
28
+ };
29
+ };
30
+ export default meta;
31
+ type Story = StoryObj<typeof meta>;
32
+ export declare const Default: Story;
33
+ export declare const WithoutHref: Story;
34
+ export declare const WithHref: Story;
35
+ export declare const NoSelection: Story;
@@ -0,0 +1,22 @@
1
+ declare const BLOCK_TYPES: readonly ["paragraph", "h1", "h2", "h3"];
2
+ export type BlockType = (typeof BLOCK_TYPES)[number];
3
+ type ToolbarProps = {
4
+ disabled?: boolean;
5
+ isBoldActive: boolean;
6
+ isItalicActive: boolean;
7
+ isBulletListActive: boolean;
8
+ isOrderedListActive: boolean;
9
+ isLinkActive: boolean;
10
+ selectedFormat: BlockType;
11
+ linkPopoverTarget?: string;
12
+ onBold: () => void;
13
+ onItalic: () => void;
14
+ onBulletList: () => void;
15
+ onOrderedList: () => void;
16
+ onUndo: () => void;
17
+ onRedo: () => void;
18
+ onFormatChange: (format: BlockType) => void;
19
+ onLink: () => void;
20
+ };
21
+ export declare const Toolbar: ({ disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, }: ToolbarProps) => React.JSX.Element;
22
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ import { type BlockType } from './toolbar';
3
+ declare const meta: {
4
+ title: string;
5
+ component: ({ disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, }: {
6
+ disabled?: boolean;
7
+ isBoldActive: boolean;
8
+ isItalicActive: boolean;
9
+ isBulletListActive: boolean;
10
+ isOrderedListActive: boolean;
11
+ isLinkActive: boolean;
12
+ selectedFormat: BlockType;
13
+ linkPopoverTarget?: string;
14
+ onBold: () => void;
15
+ onItalic: () => void;
16
+ onBulletList: () => void;
17
+ onOrderedList: () => void;
18
+ onUndo: () => void;
19
+ onRedo: () => void;
20
+ onFormatChange: (format: BlockType) => void;
21
+ onLink: () => void;
22
+ }) => React.JSX.Element;
23
+ decorators: ((Story: import("storybook/internal/csf").PartialStoryFn) => React.JSX.Element)[];
24
+ tags: string[];
25
+ argTypes: {
26
+ onBold: {
27
+ action: string;
28
+ };
29
+ onItalic: {
30
+ action: string;
31
+ };
32
+ onBulletList: {
33
+ action: string;
34
+ };
35
+ onOrderedList: {
36
+ action: string;
37
+ };
38
+ onUndo: {
39
+ action: string;
40
+ };
41
+ onRedo: {
42
+ action: string;
43
+ };
44
+ onFormatChange: {
45
+ action: string;
46
+ };
47
+ onLink: {
48
+ action: string;
49
+ };
50
+ };
51
+ };
52
+ export default meta;
53
+ type Story = StoryObj<typeof meta>;
54
+ export declare const Default: Story;
55
+ export declare const Disabled: Story;
@@ -0,0 +1,21 @@
1
+ import type { Ctx } from '@milkdown/ctx';
2
+ export type LinkEditorState = {
3
+ from: number;
4
+ to: number;
5
+ href: string;
6
+ hasSelection: boolean;
7
+ };
8
+ type ExecuteInEditor = (fn: (ctx: Ctx) => void) => void;
9
+ type UseRichTextLinkEditorParams = {
10
+ disabled: boolean;
11
+ executeInEditor: ExecuteInEditor;
12
+ };
13
+ export declare const useRichTextLinkEditor: ({ disabled, executeInEditor }: UseRichTextLinkEditorParams) => {
14
+ linkEditorOpen: boolean;
15
+ linkEditorState: LinkEditorState | null;
16
+ closeLinkEditor: () => void;
17
+ openLinkEditor: () => void;
18
+ handleLinkSave: (nextHref: string) => void;
19
+ handleLinkRemove: () => void;
20
+ };
21
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { Ctx } from '@milkdown/ctx';
2
+ import type { BlockType } from '../components/Toolbar/toolbar';
3
+ export type ToolbarState = {
4
+ isBoldActive: boolean;
5
+ isItalicActive: boolean;
6
+ isBulletListActive: boolean;
7
+ isOrderedListActive: boolean;
8
+ selectedFormat: BlockType;
9
+ isLinkActive: boolean;
10
+ };
11
+ export declare const useRichTextToolbarState: () => {
12
+ toolbarState: ToolbarState;
13
+ updateToolbarState: (ctx: Ctx) => void;
14
+ };
@@ -0,0 +1,14 @@
1
+ import '@milkdown/prose/view/style/prosemirror.css';
2
+ export type RichTextAreaProps = {
3
+ value: string;
4
+ onChange: (markdown: string) => void;
5
+ placeholder?: string;
6
+ disabled?: boolean;
7
+ className?: string;
8
+ label?: string;
9
+ description?: string | React.ReactNode;
10
+ optional?: boolean | string | undefined;
11
+ required?: boolean | string | undefined;
12
+ error?: string;
13
+ };
14
+ export declare const RichTextArea: ({ className, ...props }: RichTextAreaProps) => React.JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ import { RichTextAreaProps } from './richTextArea';
3
+ declare const meta: {
4
+ title: string;
5
+ component: ({ className, ...props }: RichTextAreaProps) => React.JSX.Element;
6
+ decorators: ((Story: import("storybook/internal/csf").PartialStoryFn) => React.JSX.Element)[];
7
+ tags: string[];
8
+ };
9
+ export default meta;
10
+ type Story = StoryObj<typeof meta>;
11
+ export declare const Default: Story;
12
+ export declare const Disabled: Story;
13
+ export declare const WithError: Story;
@@ -0,0 +1,7 @@
1
+ import type { EditorState } from '@milkdown/prose/state';
2
+ export declare const normalizeHref: (rawHref: string) => string;
3
+ export declare const getSelectionLinkRange: (state: EditorState) => {
4
+ from: number;
5
+ to: number;
6
+ };
7
+ export declare const getLinkHrefInRange: (state: EditorState, from: number, to: number) => string;
@@ -48,6 +48,8 @@ export { NumberInput } from './components/designsystemet/NumberInput/NumberInput
48
48
  export type { NumberInputProps } from './components/designsystemet/NumberInput/NumberInput';
49
49
  export { TextArea } from './components/designsystemet/TextArea/TextArea';
50
50
  export type { TextAreaProps } from './components/designsystemet/TextArea/TextArea';
51
+ export { RichTextArea } from './components/kystverket/RichTextArea/richTextArea';
52
+ export type { RichTextAreaProps } from './components/kystverket/RichTextArea/richTextArea';
51
53
  export type { InputSize } from './utils/input/input';
52
54
  export { Select } from './components/designsystemet/Select/Select';
53
55
  export type { SelectProps, SelectOption } from './components/designsystemet/Select/Select';