@shlinkio/shlink-frontend-kit 1.4.0 → 1.5.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 +25 -1
- package/dist/content/Details.d.ts +9 -0
- package/dist/content/Details.stories.d.ts +11 -0
- package/dist/content/Listbox.d.ts +25 -0
- package/dist/content/Table.d.ts +33 -0
- package/dist/content/Table.stories.d.ts +20 -0
- package/dist/content/index.d.ts +3 -0
- package/dist/feedback/CardModal.d.ts +40 -0
- package/dist/feedback/CardModal.stories.d.ts +25 -0
- package/dist/feedback/Message.d.ts +11 -0
- package/dist/feedback/Message.stories.d.ts +11 -0
- package/dist/feedback/ModalDialog.d.ts +8 -0
- package/dist/feedback/Result.d.ts +11 -0
- package/dist/feedback/Result.stories.d.ts +12 -0
- package/dist/feedback/Tooltip.d.ts +897 -0
- package/dist/feedback/Tooltip.stories.d.ts +10 -0
- package/dist/feedback/index.d.ts +5 -0
- package/dist/form/BooleanControl.d.ts +6 -0
- package/dist/form/Button.d.ts +17 -0
- package/dist/form/Button.stories.d.ts +26 -0
- package/dist/form/Checkbox.d.ts +4 -0
- package/dist/form/Checkbox.stories.d.ts +9 -0
- package/dist/form/CloseButton.d.ts +11 -0
- package/dist/form/CloseButton.stories.d.ts +12 -0
- package/dist/form/FormControlWithFeedback.d.ts +12 -0
- package/dist/form/Input.d.ts +16 -0
- package/dist/form/Input.stories.d.ts +20 -0
- package/dist/form/Label.d.ts +5 -0
- package/dist/form/Label.stories.d.ts +9 -0
- package/dist/form/LabelledInput.d.ts +14 -0
- package/dist/form/LabelledInput.stories.d.ts +12 -0
- package/dist/form/LabelledRevealablePasswordInput.d.ts +14 -0
- package/dist/form/LabelledRevealablePasswordInput.stories.d.ts +8 -0
- package/dist/form/LabelledSelect.d.ts +11 -0
- package/dist/form/LabelledSelect.stories.d.ts +15 -0
- package/dist/form/RevealablePasswordInput.d.ts +9 -0
- package/dist/form/RevealablePasswordInput.stories.d.ts +8 -0
- package/dist/form/SearchCombobox.d.ts +35 -0
- package/dist/form/SearchCombobox.stories.d.ts +15 -0
- package/dist/form/SearchInput.d.ts +15 -0
- package/dist/form/SearchInput.stories.d.ts +19 -0
- package/dist/form/Select.d.ts +8 -0
- package/dist/form/Select.stories.d.ts +17 -0
- package/dist/form/TagsAutocomplete.d.ts +33 -0
- package/dist/form/TagsAutocomplete.stories.d.ts +14 -0
- package/dist/form/ToggleSwitch.d.ts +4 -0
- package/dist/form/ToggleSwitch.stories.d.ts +9 -0
- package/dist/form/index.d.ts +14 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/normalize-tag.d.ts +4 -0
- package/dist/helpers/numbers.d.ts +2 -0
- package/dist/helpers/pagination.d.ts +8 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/use-arrow-key-navigation.d.ts +18 -0
- package/dist/hooks/use-go-back.d.ts +1 -0
- package/dist/hooks/use-parsed-query.d.ts +1 -0
- package/dist/hooks/use-tags-search.d.ts +34 -0
- package/dist/hooks/use-timeout-toggle.d.ts +14 -0
- package/dist/hooks/use-timeout.d.ts +15 -0
- package/dist/hooks/use-toggle.d.ts +7 -0
- package/dist/index.d.ts +11 -1645
- package/dist/index.js +1311 -1639
- package/dist/navigation/Dropdown.d.ts +32 -0
- package/dist/navigation/Dropdown.stories.d.ts +36 -0
- package/dist/navigation/LinkButton.d.ts +8 -0
- package/dist/navigation/LinkButton.stories.d.ts +10 -0
- package/dist/navigation/Menu.d.ts +35 -0
- package/dist/navigation/Menu.stories.d.ts +16 -0
- package/dist/navigation/NavBar.d.ts +16 -0
- package/dist/navigation/NavBar.stories.d.ts +18 -0
- package/dist/navigation/NavPills.d.ts +10 -0
- package/dist/navigation/NavPills.stories.d.ts +13 -0
- package/dist/navigation/Paginator.d.ts +10 -0
- package/dist/navigation/Paginator.stories.d.ts +18 -0
- package/dist/navigation/RowDropdown.d.ts +11 -0
- package/dist/navigation/RowDropdown.stories.d.ts +24 -0
- package/dist/navigation/index.d.ts +7 -0
- package/dist/ordering/OrderingDropdown.d.ts +12 -0
- package/dist/ordering/OrderingDropdown.stories.d.ts +17 -0
- package/dist/ordering/index.d.ts +2 -0
- package/dist/ordering/ordering.d.ts +25 -0
- package/dist/surfaces/Card.d.ts +7 -0
- package/dist/surfaces/Card.stories.d.ts +12 -0
- package/dist/surfaces/SimpleCard.d.ts +16 -0
- package/dist/surfaces/SimpleCard.stories.d.ts +11 -0
- package/dist/surfaces/index.d.ts +2 -0
- package/dist/theme/index.d.ts +15 -0
- package/dist/types.d.ts +3 -0
- package/dist/utils/CopyToClipboardButton.d.ts +13 -0
- package/dist/utils/CopyToClipboardButton.stories.d.ts +8 -0
- package/dist/utils/colors.d.ts +9 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/query.d.ts +12 -0
- package/package.json +25 -20
package/README.md
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
# Shlink frontend kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Design system, component library and utilities for Shlink React frontend projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
npm install @shlinkio/shlink-frontend-kit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Button, useToggle } from '@shlinkio/shlink-frontend-kit';
|
|
15
|
+
import './tailwind.css';
|
|
16
|
+
|
|
17
|
+
export const App = () => {
|
|
18
|
+
const { flag, toggle } = useToggle();
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className="flex flex-col gap-3">
|
|
22
|
+
<p>The flag is {flag ? 'true' : 'false'}</p>
|
|
23
|
+
<Button onClick={toggle}>Click me</Button>
|
|
24
|
+
</>
|
|
25
|
+
)
|
|
26
|
+
};
|
|
27
|
+
```
|
|
4
28
|
|
|
5
29
|
## Tailwind
|
|
6
30
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC, HTMLProps, ReactNode } from 'react';
|
|
2
|
+
export type DetailsProps = Omit<HTMLProps<HTMLDetailsElement>, 'ref'> & {
|
|
3
|
+
summary: ReactNode;
|
|
4
|
+
summaryClasses?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Hide extended details under a collapsible area with an always-visible summary.
|
|
8
|
+
*/
|
|
9
|
+
export declare const Details: FC<DetailsProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
component: import('react').FC<import('./Details').DetailsProps>;
|
|
4
|
+
tags: string[];
|
|
5
|
+
argTypes: {
|
|
6
|
+
children: import('storybook/internal/csf').InputType;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof meta>;
|
|
11
|
+
export declare const Base: Story;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
import { CardProps } from '../surfaces';
|
|
3
|
+
export type ListboxProps<Item> = Omit<CardProps, 'id' | 'role' | 'aria-orientation'> & {
|
|
4
|
+
/** Map of items in the listbox, with a key representing them uniquely */
|
|
5
|
+
items: Map<string, Item>;
|
|
6
|
+
/** Invoked when the active item is selected via click or `Enter` */
|
|
7
|
+
onSelectItem: (item: Item) => void;
|
|
8
|
+
/** Invoked when the active item changes via vertical arrows or hover */
|
|
9
|
+
onActiveItemChange?: (key: string, item: Item) => void;
|
|
10
|
+
/** To customize the shape of an item */
|
|
11
|
+
renderItem: (item: Item) => ReactNode;
|
|
12
|
+
/** Used to link with the element controlling this listbox */
|
|
13
|
+
id: string;
|
|
14
|
+
/**
|
|
15
|
+
* Allows to optionally anchor this listbox to another element.
|
|
16
|
+
* If provided, it will attach arrow key and Enter press listeners to interact with the listbox.
|
|
17
|
+
*/
|
|
18
|
+
anchor?: RefObject<HTMLElement | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Message to display when the list of items is empty.
|
|
21
|
+
* Defaults to 'No items'.
|
|
22
|
+
*/
|
|
23
|
+
noItemsMessage?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function Listbox<Item>({ id, items, onSelectItem, onActiveItemChange, renderItem, className, noItemsMessage, anchor, 'aria-label': label, ...rest }: ListboxProps<Item>): import("react").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FC, HTMLProps, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import { Size } from '../types';
|
|
3
|
+
export type SectionType = 'head' | 'body' | 'footer';
|
|
4
|
+
export type TableElementProps = PropsWithChildren & {
|
|
5
|
+
className?: string;
|
|
6
|
+
};
|
|
7
|
+
export type CellProps = HTMLProps<HTMLTableCellElement> & {
|
|
8
|
+
/**
|
|
9
|
+
* The name of the column to be displayed in small resolutions when the table is responsive, where the cells collapse.
|
|
10
|
+
* It is ignored for non-responsive tables.
|
|
11
|
+
*/
|
|
12
|
+
columnName?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to use a th or td tag. If not provided, it is inferred based on the section, using td when inside tbody,
|
|
15
|
+
* and th when inside thead or tfoot
|
|
16
|
+
*/
|
|
17
|
+
type?: 'td' | 'th';
|
|
18
|
+
};
|
|
19
|
+
export type TableProps = Omit<HTMLProps<HTMLTableElement>, 'size'> & {
|
|
20
|
+
header: ReactNode;
|
|
21
|
+
footer?: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* By default, the table rows will collapse under large resolutions, and the headers will be hidden.
|
|
24
|
+
* Set `responsive={false}` to avoid this behavior.
|
|
25
|
+
*/
|
|
26
|
+
responsive?: boolean;
|
|
27
|
+
/** Determines the padding in every cell. Defaults to md */
|
|
28
|
+
size?: Size;
|
|
29
|
+
};
|
|
30
|
+
export declare const Table: FC<TableProps> & {
|
|
31
|
+
Row: FC<HTMLProps<HTMLTableRowElement>>;
|
|
32
|
+
Cell: FC<CellProps>;
|
|
33
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
component: import('react').FC<import('./Table').TableProps> & {
|
|
4
|
+
Row: import('react').FC<import('react').HTMLProps<HTMLTableRowElement>>;
|
|
5
|
+
Cell: import('react').FC<import('./Table').CellProps>;
|
|
6
|
+
};
|
|
7
|
+
tags: string[];
|
|
8
|
+
argTypes: {
|
|
9
|
+
children: import('storybook/internal/csf').InputType;
|
|
10
|
+
header: import('storybook/internal/csf').InputType;
|
|
11
|
+
footer: import('storybook/internal/csf').InputType;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
type Story = StoryObj<typeof meta>;
|
|
16
|
+
export declare const Responsive: Story;
|
|
17
|
+
export declare const NonResponsiveInCard: Story;
|
|
18
|
+
export declare const WithFooter: Story;
|
|
19
|
+
export declare const Small: Story;
|
|
20
|
+
export declare const Large: Story;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { RequiredReactNode, Size } from '../types';
|
|
3
|
+
import { ModalDialogProps } from './ModalDialog';
|
|
4
|
+
type CommonCardModalProps = {
|
|
5
|
+
/** Modal header title */
|
|
6
|
+
title: RequiredReactNode;
|
|
7
|
+
};
|
|
8
|
+
type CoverCardModalProps = CommonCardModalProps & {
|
|
9
|
+
/**
|
|
10
|
+
* Cover dialogs have a body that span the whole dialog, and no buttons.
|
|
11
|
+
* The header overlaps the body with semi-transparent background.
|
|
12
|
+
*/
|
|
13
|
+
variant: 'cover';
|
|
14
|
+
};
|
|
15
|
+
export type ExitAction = 'confirm' | 'cancel';
|
|
16
|
+
type RegularCardModalProps = CommonCardModalProps & {
|
|
17
|
+
/** Danger dialogs use danger variants in title and confirm button */
|
|
18
|
+
variant?: 'default' | 'danger';
|
|
19
|
+
/** Determines the horizontal size of the dialog */
|
|
20
|
+
size?: Size | 'xl';
|
|
21
|
+
/** Value to display in confirm button. Defaults to 'Confirm' */
|
|
22
|
+
confirmText?: ReactNode;
|
|
23
|
+
/** Value to display in cancel button. Defaults to 'Cancel' */
|
|
24
|
+
cancelText?: ReactNode;
|
|
25
|
+
/** Whether the confirm button is disabled or not */
|
|
26
|
+
confirmDisabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* A footer with confirm and cancel buttons will be rendered if provided.
|
|
29
|
+
* Invoked when the confirm button is actioned.
|
|
30
|
+
*/
|
|
31
|
+
onConfirm?: () => void;
|
|
32
|
+
/** Invoked after finishing the close transition */
|
|
33
|
+
onClosed?: (exitAction: ExitAction) => void;
|
|
34
|
+
};
|
|
35
|
+
export type CardModalProps = Omit<ModalDialogProps, 'title' | 'size'> & (CoverCardModalProps | RegularCardModalProps);
|
|
36
|
+
/**
|
|
37
|
+
* A `ModalDialog` that renders a `Card` as its content
|
|
38
|
+
*/
|
|
39
|
+
export declare const CardModal: FC<CardModalProps>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { CardModalProps } from './CardModal';
|
|
3
|
+
declare const meta: {
|
|
4
|
+
component: import('react').FC<CardModalProps>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
argTypes: {
|
|
7
|
+
variant: {
|
|
8
|
+
control: "radio";
|
|
9
|
+
options: string[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
export declare const Base: Story;
|
|
16
|
+
export declare const Small: Story;
|
|
17
|
+
export declare const Large: Story;
|
|
18
|
+
export declare const ExtraLarge: Story;
|
|
19
|
+
export declare const Danger: Story;
|
|
20
|
+
export declare const Confirm: Story;
|
|
21
|
+
export declare const DisabledConfirm: Story;
|
|
22
|
+
export declare const DangerConfirm: Story;
|
|
23
|
+
export declare const WithForm: Story;
|
|
24
|
+
export declare const WithALotOfContent: Story;
|
|
25
|
+
export declare const Cover: Story;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
export type MessageProps = PropsWithChildren<{
|
|
3
|
+
className?: string;
|
|
4
|
+
variant?: 'default' | 'error' | 'loading';
|
|
5
|
+
/** @deprecated Use loading variant instead */
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* Component used to display a card with general information, about current page status, loading, etc.
|
|
10
|
+
*/
|
|
11
|
+
export declare const Message: FC<MessageProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
component: import('react').FC<import('./Message').MessageProps>;
|
|
4
|
+
tags: string[];
|
|
5
|
+
};
|
|
6
|
+
export default meta;
|
|
7
|
+
type Story = StoryObj<typeof meta>;
|
|
8
|
+
export declare const DefaultMessage: Story;
|
|
9
|
+
export declare const ErrorMessage: Story;
|
|
10
|
+
export declare const LoadingMessage: Story;
|
|
11
|
+
export declare const LoadingMessageWithCustomText: Story;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC, HTMLProps } from 'react';
|
|
2
|
+
export type ModalDialogProps = HTMLProps<HTMLDialogElement> & {
|
|
3
|
+
/** Whether the dialog is open or not */
|
|
4
|
+
open: boolean;
|
|
5
|
+
/** Invoked when the dialog is closed for any reason */
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const ModalDialog: FC<ModalDialogProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { Size } from '../types';
|
|
3
|
+
export type ResultProps = PropsWithChildren<{
|
|
4
|
+
variant: 'success' | 'error' | 'warning';
|
|
5
|
+
className?: string;
|
|
6
|
+
size?: Size;
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* Component used to display the result of an operation, which can be a success, failure or warning.
|
|
10
|
+
*/
|
|
11
|
+
export declare const Result: FC<ResultProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
component: import('react').FC<import('./Result').ResultProps>;
|
|
4
|
+
tags: string[];
|
|
5
|
+
};
|
|
6
|
+
export default meta;
|
|
7
|
+
type Story = StoryObj<typeof meta>;
|
|
8
|
+
export declare const Success: Story;
|
|
9
|
+
export declare const Warning: Story;
|
|
10
|
+
export declare const Error: Story;
|
|
11
|
+
export declare const Small: Story;
|
|
12
|
+
export declare const Large: Story;
|