@khaos-systems/helm 0.1.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 +20 -0
- package/dist/components/matter/MtAlert.d.ts +11 -0
- package/dist/components/matter/MtAvatar.d.ts +10 -0
- package/dist/components/matter/MtAvatarGroup.d.ts +10 -0
- package/dist/components/matter/MtButton.d.ts +12 -0
- package/dist/components/matter/MtCheckbox.d.ts +17 -0
- package/dist/components/matter/MtContextMenu.d.ts +33 -0
- package/dist/components/matter/MtDialog.d.ts +15 -0
- package/dist/components/matter/MtDivider.d.ts +7 -0
- package/dist/components/matter/MtDropdown.d.ts +27 -0
- package/dist/components/matter/MtFilter.d.ts +37 -0
- package/dist/components/matter/MtIcon.d.ts +7 -0
- package/dist/components/matter/MtInlineToast.d.ts +11 -0
- package/dist/components/matter/MtInput.d.ts +11 -0
- package/dist/components/matter/MtPopover.d.ts +20 -0
- package/dist/components/matter/MtProgress.d.ts +8 -0
- package/dist/components/matter/MtSearch.d.ts +7 -0
- package/dist/components/matter/MtSelect.d.ts +32 -0
- package/dist/components/matter/MtSort.d.ts +20 -0
- package/dist/components/matter/MtStack.d.ts +20 -0
- package/dist/components/matter/MtTextarea.d.ts +6 -0
- package/dist/components/matter/MtToggletip.d.ts +11 -0
- package/dist/components/matter/MtTooltip.d.ts +9 -0
- package/dist/components/matter/MtTree.d.ts +49 -0
- package/dist/components/matter/experimental/collection/MtCollection.d.ts +92 -0
- package/dist/components/matter/experimental/collection/MtCollection.test.d.ts +1 -0
- package/dist/components/matter/experimental/collection/MtCollectionContext.d.ts +32 -0
- package/dist/components/matter/experimental/collection/MtCollectionEntryControls.d.ts +30 -0
- package/dist/components/matter/experimental/collection/MtCollectionEntryUtils.d.ts +27 -0
- package/dist/components/matter/experimental/collection/MtCollectionTaskListEntry.d.ts +10 -0
- package/dist/components/matter/experimental/collection/MtCollectionToolbar.d.ts +1 -0
- package/dist/components/matter/experimental/collection/MtCollectionViewSettings.d.ts +32 -0
- package/dist/components/matter/experimental/collection/MtIconSelect.d.ts +10 -0
- package/dist/components/matter/experimental/collection/index.d.ts +9 -0
- package/dist/components/matter/experimental/collection/layouts/MtCollectionBoardLayout.d.ts +2 -0
- package/dist/components/matter/experimental/collection/layouts/MtCollectionGanttLayout.d.ts +2 -0
- package/dist/components/matter/experimental/collection/layouts/MtCollectionGridLayout.d.ts +2 -0
- package/dist/components/matter/experimental/collection/layouts/MtCollectionListLayout.d.ts +2 -0
- package/dist/components/matter/experimental/collection/layouts/MtCollectionTableLayout.d.ts +2 -0
- package/dist/components/matter/storybook/StoryMatrix.d.ts +19 -0
- package/dist/components/matter/storybook/axis.d.ts +11 -0
- package/dist/lib.d.ts +25 -0
- package/dist/matter-brand-storybook.png +0 -0
- package/dist/matter.cjs +50 -0
- package/dist/matter.js +7522 -0
- package/dist/styles.css +1 -0
- package/package.json +68 -0
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Helm (Matter Design System)
|
|
2
|
+
|
|
3
|
+
This package contains the Matter design system and Storybook site extracted from `anchor`.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
- `npm install`
|
|
8
|
+
- `npm run storybook` - run Storybook locally
|
|
9
|
+
- `npm run build-storybook` - static Storybook build
|
|
10
|
+
- `npm run build` - build library output to `dist/`
|
|
11
|
+
- `npm run gen:tokens` - regenerate `src/tokens.css` from `tokens/tokens.dark.json`
|
|
12
|
+
|
|
13
|
+
## Usage in another app
|
|
14
|
+
|
|
15
|
+
Install from workspace and import:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { MtButton } from '@khaos/matter';
|
|
19
|
+
import '@khaos/matter/styles.css';
|
|
20
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type MtAlertSeverity = 'success' | 'info' | 'warning' | 'error';
|
|
3
|
+
interface MtAlertProps {
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
content: ReactNode;
|
|
6
|
+
severity?: MtAlertSeverity;
|
|
7
|
+
actions?: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function MtAlert({ title, content, severity, actions, className }: MtAlertProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export type MtAvatarSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
3
|
+
export interface MtAvatarProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
src?: string;
|
|
5
|
+
alt?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
initials?: string;
|
|
8
|
+
size?: MtAvatarSize;
|
|
9
|
+
}
|
|
10
|
+
export default function MtAvatar({ src, alt, name, initials, size, className, ...props }: MtAvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { MtAvatarProps, MtAvatarSize } from './MtAvatar';
|
|
3
|
+
export interface MtAvatarGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
avatars?: MtAvatarProps[];
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
max?: number;
|
|
7
|
+
size?: MtAvatarSize;
|
|
8
|
+
spacing?: number;
|
|
9
|
+
}
|
|
10
|
+
export default function MtAvatarGroup({ avatars, children, max, size, spacing, className, ...props }: MtAvatarGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type MtButtonSurface = 'default' | 'accent' | 'ghost';
|
|
4
|
+
interface MtButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
type?: 'button' | 'submit' | 'reset';
|
|
7
|
+
kind?: 'default' | 'icon';
|
|
8
|
+
size?: 'medium' | 'large';
|
|
9
|
+
variant?: MtButtonSurface;
|
|
10
|
+
}
|
|
11
|
+
export declare const MtButton: React.ForwardRefExoticComponent<MtButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
interface MtCheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {
|
|
3
|
+
/** The label for the checkbox */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Marks the checkbox as invalid */
|
|
6
|
+
invalid?: boolean;
|
|
7
|
+
/** A description for the checkbox */
|
|
8
|
+
description?: string;
|
|
9
|
+
/** Sets the checkbox to an intermediate state. This is only a visual state and does not affect the value. */
|
|
10
|
+
intermediate?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* TODO: Consider using `value` instead of `checked` to be more consistent with other input components. Not sure if it's better to be consistent with native checkboxes or with our other components. Maybe we can support both? If `value` is provided, it takes precedence over `checked`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function MtCheckbox({ label, checked, invalid, description, intermediate, disabled, onChange, className, ...inputProps }: MtCheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface MtContextMenuItem {
|
|
3
|
+
label: React.ReactNode;
|
|
4
|
+
onSelect?: () => void;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
shortcut?: React.ReactNode;
|
|
7
|
+
items?: MtContextMenuItem[];
|
|
8
|
+
separator?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface MtContextMenuProps {
|
|
11
|
+
open: boolean;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
items?: MtContextMenuItem[];
|
|
15
|
+
onOpenChange?: (open: boolean) => void;
|
|
16
|
+
onClose?: () => void;
|
|
17
|
+
focusOnOpen?: boolean;
|
|
18
|
+
renderMenuItems?: () => React.ReactNode;
|
|
19
|
+
renderHeader?: () => React.ReactNode;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
interface WithContextMenuProps {
|
|
23
|
+
children: (props: {
|
|
24
|
+
openMenu: React.MouseEventHandler<HTMLElement>;
|
|
25
|
+
}) => React.ReactElement;
|
|
26
|
+
getContextMenuItems?: () => MtContextMenuItem[];
|
|
27
|
+
renderMenuItems?: () => React.ReactNode;
|
|
28
|
+
renderHeader?: () => React.ReactNode;
|
|
29
|
+
focusOnOpen?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function MtContextMenu({ open, x, y, items, onOpenChange, onClose, renderMenuItems, renderHeader, className, }: MtContextMenuProps): import("react/jsx-runtime").JSX.Element | null;
|
|
32
|
+
export declare function WithContextMenu({ children, getContextMenuItems, renderMenuItems, renderHeader, }: WithContextMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Dialog } from 'radix-ui';
|
|
2
|
+
interface MtDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
title?: React.ReactNode;
|
|
6
|
+
description?: React.ReactNode;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
maxWidth?: string;
|
|
9
|
+
showCloseButton?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
contentClassName?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function MtDialog({ open, onOpenChange, title, description, children, maxWidth, showCloseButton, className, contentClassName, }: MtDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const MtDialogClose: import("react").ForwardRefExoticComponent<Dialog.DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DropdownMenu } from 'radix-ui';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type MtDropdownTriggerProps = {
|
|
4
|
+
children: React.ReactElement;
|
|
5
|
+
};
|
|
6
|
+
declare function MtDropdownTrigger({ children }: MtDropdownTriggerProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
7
|
+
export declare function MtDropdownItem({ children, className, ...props }: React.ComponentPropsWithoutRef<typeof DropdownMenu.Item>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
/**
|
|
9
|
+
* MtDropdown component
|
|
10
|
+
*
|
|
11
|
+
* Special features:
|
|
12
|
+
* - Shortcuts for each item. Press item index when opened to select it.
|
|
13
|
+
*/
|
|
14
|
+
interface MtDropdownProps {
|
|
15
|
+
title?: string | React.ReactNode;
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
className?: string;
|
|
18
|
+
kind?: 'default' | 'icon';
|
|
19
|
+
size?: 'medium' | 'large';
|
|
20
|
+
variant?: 'default' | 'ghost' | 'accent';
|
|
21
|
+
showCaret?: boolean;
|
|
22
|
+
}
|
|
23
|
+
type MtDropdownComponent = ((props: MtDropdownProps) => React.ReactElement) & {
|
|
24
|
+
Trigger: typeof MtDropdownTrigger;
|
|
25
|
+
};
|
|
26
|
+
export declare const MtDropdown: MtDropdownComponent;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type MtFilterConjunction = 'AND' | 'OR';
|
|
2
|
+
export type MtFilterRule = {
|
|
3
|
+
type: 'rule';
|
|
4
|
+
field: string;
|
|
5
|
+
operator: string;
|
|
6
|
+
value?: string | null;
|
|
7
|
+
};
|
|
8
|
+
export type MtFilterGroup = {
|
|
9
|
+
type: 'group';
|
|
10
|
+
conjunction: MtFilterConjunction;
|
|
11
|
+
children: MtFilterNode[];
|
|
12
|
+
};
|
|
13
|
+
export type MtFilterNode = MtFilterRule | MtFilterGroup;
|
|
14
|
+
export type MtFilterField = {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
icon?: React.ReactNode;
|
|
18
|
+
};
|
|
19
|
+
export type MtFilterOperator = {
|
|
20
|
+
value: string;
|
|
21
|
+
label: string;
|
|
22
|
+
requiresValue?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type MtFilterDropdownProps = {
|
|
25
|
+
title?: string | React.ReactNode;
|
|
26
|
+
value: MtFilterGroup;
|
|
27
|
+
onChange: (next: MtFilterGroup) => void;
|
|
28
|
+
fields: MtFilterField[];
|
|
29
|
+
operators: MtFilterOperator[];
|
|
30
|
+
advanced?: boolean;
|
|
31
|
+
onAdvancedChange?: (next: boolean) => void;
|
|
32
|
+
kind?: 'default' | 'icon';
|
|
33
|
+
size?: 'medium' | 'large';
|
|
34
|
+
variant?: 'default' | 'ghost' | 'accent';
|
|
35
|
+
showCaret?: boolean;
|
|
36
|
+
};
|
|
37
|
+
export declare function MtFilterDropdown({ title, value, onChange, fields, operators, advanced, onAdvancedChange, kind, size, variant, showCaret, }: MtFilterDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function MtLowIcon(): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function MtMediumIcon(): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function MtHighIcon(): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function MtBacklogIcon(): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function MtOpenIcon(): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function MtInProgressIcon(): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function MtCheckIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
interface MtInlineToastProps {
|
|
3
|
+
children: ReactElement;
|
|
4
|
+
message?: ReactNode;
|
|
5
|
+
durationMs?: number;
|
|
6
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
7
|
+
align?: 'start' | 'center' | 'end';
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function MtInlineToast({ children, message, durationMs, side, align, disabled, }: MtInlineToastProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
interface MtInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'variant'> {
|
|
3
|
+
size?: 'medium' | 'large';
|
|
4
|
+
variant?: 'default' | 'ghost';
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* TODO: Make it possible to edit inputs by hovering and typing. No pressing.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MtInput: import("react").ForwardRefExoticComponent<MtInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type MtPopoverTriggerProps = {
|
|
3
|
+
children: React.ReactElement;
|
|
4
|
+
};
|
|
5
|
+
declare function MtPopoverTrigger({ children }: MtPopoverTriggerProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
6
|
+
type MtPopoverProps = {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
content: React.ReactNode;
|
|
9
|
+
open?: boolean;
|
|
10
|
+
onOpenChange?: (open: boolean) => void;
|
|
11
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
12
|
+
align?: 'start' | 'center' | 'end';
|
|
13
|
+
sideOffset?: number;
|
|
14
|
+
className?: string;
|
|
15
|
+
};
|
|
16
|
+
type MtPopoverComponent = ((props: MtPopoverProps) => React.ReactElement) & {
|
|
17
|
+
Trigger: typeof MtPopoverTrigger;
|
|
18
|
+
};
|
|
19
|
+
export declare const MtPopover: MtPopoverComponent;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
interface MtSearchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'variant' | 'type'> {
|
|
3
|
+
size?: 'medium' | 'large';
|
|
4
|
+
variant?: 'default' | 'ghost';
|
|
5
|
+
}
|
|
6
|
+
export declare function MtSearch({ size, variant, className, value: propValue, onChange, placeholder, ...props }: MtSearchProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Select } from 'radix-ui';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type MtSelectTriggerProps = {
|
|
4
|
+
children: React.ReactElement;
|
|
5
|
+
};
|
|
6
|
+
declare function MtSelectTrigger({ children }: MtSelectTriggerProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
7
|
+
export declare const MtSelectItem: React.ForwardRefExoticComponent<Omit<Select.SelectItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
shortcut?: string;
|
|
10
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
interface MtSelectProps {
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
placeholder?: React.ReactNode;
|
|
15
|
+
kind?: 'default' | 'icon';
|
|
16
|
+
value?: string;
|
|
17
|
+
onValueChange?: (value: string) => void;
|
|
18
|
+
size?: 'medium' | 'large';
|
|
19
|
+
options?: {
|
|
20
|
+
value: string;
|
|
21
|
+
label: React.ReactNode;
|
|
22
|
+
icon?: React.ReactNode;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
}[];
|
|
25
|
+
variant?: 'default' | 'ghost';
|
|
26
|
+
showCaret?: boolean;
|
|
27
|
+
}
|
|
28
|
+
type MtSelectComponent = ((props: MtSelectProps) => React.ReactElement) & {
|
|
29
|
+
Trigger: typeof MtSelectTrigger;
|
|
30
|
+
};
|
|
31
|
+
export declare const MtSelect: MtSelectComponent;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type MtSortDirection = 'asc' | 'desc';
|
|
2
|
+
export type MtSortRule = {
|
|
3
|
+
property: string;
|
|
4
|
+
direction: MtSortDirection;
|
|
5
|
+
};
|
|
6
|
+
export type MtSortField = {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
};
|
|
10
|
+
export type MtSortDropdownProps = {
|
|
11
|
+
title?: string | React.ReactNode;
|
|
12
|
+
value: MtSortRule[];
|
|
13
|
+
onChange: (next: MtSortRule[]) => void;
|
|
14
|
+
fields: MtSortField[];
|
|
15
|
+
kind?: 'default' | 'icon';
|
|
16
|
+
size?: 'medium' | 'large';
|
|
17
|
+
variant?: 'default' | 'ghost' | 'accent';
|
|
18
|
+
showCaret?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare function MtSortDropdown({ title, value, onChange, fields, kind, size, variant, showCaret, }: MtSortDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface MtStackProps {
|
|
2
|
+
children: React.ReactNode;
|
|
3
|
+
gap?: number;
|
|
4
|
+
/**
|
|
5
|
+
* I am not sure if it's better to make this direction='row' | 'column'. That is way more text, so i kinda like just row,
|
|
6
|
+
* but when we start to want row-reverse and column-reverse it might be better to have a more explicit direction prop
|
|
7
|
+
* instead of multiple booleans. Alternative is to have a reverse boolean.
|
|
8
|
+
*/
|
|
9
|
+
row?: boolean;
|
|
10
|
+
/** Mirrors https://tailwindcss.com/docs/align-items */
|
|
11
|
+
align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch';
|
|
12
|
+
/** Mirrors https://tailwindcss.com/docs/justify-content */
|
|
13
|
+
justify?: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly' | 'stretch' | 'baseline' | 'normal';
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Ref: https://mui.com/material-ui/react-stack/
|
|
18
|
+
*/
|
|
19
|
+
export default function MtStack({ children, gap, row, align, justify, className, }: MtStackProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TextareaHTMLAttributes } from 'react';
|
|
2
|
+
interface MtTextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
3
|
+
variant?: 'default' | 'ghost';
|
|
4
|
+
}
|
|
5
|
+
export declare const MtTextarea: ({ variant, className, ...props }: MtTextareaProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface MtToggletipProps {
|
|
2
|
+
children: React.ReactNode;
|
|
3
|
+
title?: React.ReactNode;
|
|
4
|
+
content: React.ReactNode;
|
|
5
|
+
footer?: React.ReactNode;
|
|
6
|
+
closeButton?: boolean;
|
|
7
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
8
|
+
align?: 'start' | 'center' | 'end';
|
|
9
|
+
}
|
|
10
|
+
export declare function MtToggletip({ children, title, content, footer, closeButton, side, align, }: MtToggletipProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface MtTooltipProps {
|
|
2
|
+
children: React.ReactNode;
|
|
3
|
+
content: React.ReactNode;
|
|
4
|
+
variant: 'info' | 'error';
|
|
5
|
+
side: 'top' | 'right' | 'bottom' | 'left';
|
|
6
|
+
align: 'start' | 'center' | 'end';
|
|
7
|
+
}
|
|
8
|
+
export declare function MtTooltip(props: MtTooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
export interface MtTreeItem<TData = unknown> {
|
|
3
|
+
id: string;
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
trailing?: ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
data?: TData;
|
|
9
|
+
children?: MtTreeItem<TData>[];
|
|
10
|
+
}
|
|
11
|
+
type MtTreeRenderState = {
|
|
12
|
+
isSelected: boolean;
|
|
13
|
+
isExpanded: boolean;
|
|
14
|
+
hasChildren: boolean;
|
|
15
|
+
depth: number;
|
|
16
|
+
};
|
|
17
|
+
export interface MtTreeChildItemProps<TData = unknown> {
|
|
18
|
+
itemId: string;
|
|
19
|
+
label: ReactNode;
|
|
20
|
+
icon?: ReactNode;
|
|
21
|
+
trailing?: ReactNode;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
data?: TData;
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
export interface MtTreeProps<TData = unknown> {
|
|
27
|
+
items?: MtTreeItem<TData>[];
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
className?: string;
|
|
30
|
+
selectedId?: string;
|
|
31
|
+
defaultSelectedId?: string;
|
|
32
|
+
onSelectedIdChange?: (id: string, item: MtTreeItem<TData> | null) => void;
|
|
33
|
+
expandedIds?: string[];
|
|
34
|
+
defaultExpandedIds?: string[];
|
|
35
|
+
onExpandedIdsChange?: (ids: string[]) => void;
|
|
36
|
+
onItemClick?: (item: MtTreeItem<TData>) => void;
|
|
37
|
+
renderItem?: (item: MtTreeItem<TData>, state: MtTreeRenderState) => ReactNode;
|
|
38
|
+
indentPx?: number;
|
|
39
|
+
toggleOnItemClick?: boolean;
|
|
40
|
+
}
|
|
41
|
+
declare function MtTreeItemNode<TData = unknown>({ children }: MtTreeChildItemProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
declare namespace MtTreeItemNode {
|
|
43
|
+
var displayName: string;
|
|
44
|
+
}
|
|
45
|
+
type MtTreeComponent = (<TData = unknown>(props: MtTreeProps<TData>) => ReactElement) & {
|
|
46
|
+
Item: typeof MtTreeItemNode;
|
|
47
|
+
};
|
|
48
|
+
export declare const MtTree: MtTreeComponent;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic data view component for Visualizing large collections of items in multiple formats.
|
|
3
|
+
*
|
|
4
|
+
* Classes:
|
|
5
|
+
* - MtCollectionEntry: Minimal interface for an item represented in the collection. All entries must have this.
|
|
6
|
+
* - MtCollectionView: Determines how a collection is filtered and sorted.
|
|
7
|
+
*
|
|
8
|
+
* Components:
|
|
9
|
+
* - MtCollection: Main top-level component.
|
|
10
|
+
* - MtCollectionLayout: Determines how the collection is visually structured. Examples include table, kanban, gallery, etc.
|
|
11
|
+
*
|
|
12
|
+
* Inspirations:
|
|
13
|
+
* - Notion databases
|
|
14
|
+
* - [MUI DataGrid](https://mui.com/x/react-data-grid/)
|
|
15
|
+
*/
|
|
16
|
+
import React, { ReactNode } from 'react';
|
|
17
|
+
/**
|
|
18
|
+
* Minimal interface for an item represented in the collection.
|
|
19
|
+
*/
|
|
20
|
+
export interface MtCollectionEntry {
|
|
21
|
+
id: any;
|
|
22
|
+
}
|
|
23
|
+
export interface MtCollectionProperty {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
groupable?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface MtCollectionViewSettingsState {
|
|
29
|
+
visiblePropertyIds?: string[];
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface MtCollectionLayoutSettingsProps<T extends MtCollectionEntry> {
|
|
33
|
+
currentView: MtCollectionView<T>;
|
|
34
|
+
properties: MtCollectionProperty[];
|
|
35
|
+
viewSettings: MtCollectionViewSettingsState;
|
|
36
|
+
setViewSettings: (settings: Partial<MtCollectionViewSettingsState>) => void;
|
|
37
|
+
setCurrentView: (view: MtCollectionView<T> | null) => void;
|
|
38
|
+
}
|
|
39
|
+
export type MtCollectionLayoutComponent<T extends MtCollectionEntry = MtCollectionEntry> = React.FC<MtCollectionLayoutProps<T>> & {
|
|
40
|
+
SettingsMenu?: (props: MtCollectionLayoutSettingsProps<T>) => React.ReactElement | null;
|
|
41
|
+
ToolbarActions?: React.ComponentType;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Determines how a collection is filtered and sorted.
|
|
45
|
+
* Views are meant to be stored in database and be selectable, and configurable by the user.
|
|
46
|
+
*/
|
|
47
|
+
export interface MtCollectionView<T extends MtCollectionEntry> {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
icon?: string;
|
|
51
|
+
layout: MtCollectionLayoutComponent<T>;
|
|
52
|
+
groupBy?: string | null;
|
|
53
|
+
settings?: MtCollectionViewSettingsState;
|
|
54
|
+
/** Custom entry renderer for this specific view. Overrides the collection-level renderEntry. */
|
|
55
|
+
renderEntry?: MtCollectionEntryRenderer<T>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Render prop for a single entry. Layouts delegate rendering to this component.
|
|
59
|
+
*/
|
|
60
|
+
export type MtCollectionEntryRenderer<T extends MtCollectionEntry> = React.ComponentType<{
|
|
61
|
+
entry: T;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* MtCollectionLayout determines how the collection is visually structured.
|
|
65
|
+
*/
|
|
66
|
+
export interface MtCollectionLayoutProps<T extends MtCollectionEntry> {
|
|
67
|
+
entries: T[];
|
|
68
|
+
groupBy?: string | null;
|
|
69
|
+
properties?: MtCollectionProperty[];
|
|
70
|
+
viewSettings?: MtCollectionViewSettingsState;
|
|
71
|
+
/** Custom renderer for each entry. Layouts should fall back to their own default if omitted. */
|
|
72
|
+
renderEntry?: MtCollectionEntryRenderer<T>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Props for MtCollection component
|
|
76
|
+
*/
|
|
77
|
+
export interface MtCollectionProps<T extends MtCollectionEntry> {
|
|
78
|
+
entries: T[];
|
|
79
|
+
views: MtCollectionView<T>[];
|
|
80
|
+
properties?: MtCollectionProperty[];
|
|
81
|
+
/** Undefined will render default toolbar, null will render no toolbar. */
|
|
82
|
+
toolbar?: ReactNode | null;
|
|
83
|
+
/** Default entry renderer applied to all views. View-level renderEntry takes precedence. */
|
|
84
|
+
renderEntry?: MtCollectionEntryRenderer<T>;
|
|
85
|
+
showViewSettings?: boolean;
|
|
86
|
+
viewSettings?: ReactNode;
|
|
87
|
+
className?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* MtCollection component: top-level collection container.
|
|
91
|
+
*/
|
|
92
|
+
export declare function MtCollection<T extends MtCollectionEntry>({ entries, views, properties, toolbar, renderEntry, showViewSettings, viewSettings, className, }: MtCollectionProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MtCollectionEntry, MtCollectionProperty, MtCollectionView } from './MtCollection';
|
|
2
|
+
/**
|
|
3
|
+
* Context props for MtCollection.
|
|
4
|
+
* We use context here as I don’t want to assume anything
|
|
5
|
+
* about the structure of the views, layouts, or toolbars.
|
|
6
|
+
*/
|
|
7
|
+
interface MtCollectionContextProps<T extends MtCollectionEntry> {
|
|
8
|
+
entries: T[];
|
|
9
|
+
views: MtCollectionView<T>[];
|
|
10
|
+
currentView: MtCollectionView<T> | null;
|
|
11
|
+
showViewSettings: boolean;
|
|
12
|
+
setShowViewSettings: (show: boolean) => void;
|
|
13
|
+
viewSettingsPageId: string;
|
|
14
|
+
setViewSettingsPageId: (pageId: string) => void;
|
|
15
|
+
focusViewNameEditor: boolean;
|
|
16
|
+
setFocusViewNameEditor: (focus: boolean) => void;
|
|
17
|
+
openViewSettings: (pageId?: string, options?: {
|
|
18
|
+
focusViewNameEditor?: boolean;
|
|
19
|
+
}) => void;
|
|
20
|
+
properties: MtCollectionProperty[];
|
|
21
|
+
setProperties: (properties: MtCollectionProperty[]) => void;
|
|
22
|
+
setCurrentView: (view: MtCollectionView<T> | null) => void;
|
|
23
|
+
addView: (view: MtCollectionView<T>) => void;
|
|
24
|
+
updateView: (viewId: string, patch: Partial<MtCollectionView<T>>) => void;
|
|
25
|
+
deleteView: (viewId: string) => void;
|
|
26
|
+
hasCurrentViewUnsavedChanges: boolean;
|
|
27
|
+
saveCurrentViewAsDefault: () => void;
|
|
28
|
+
revertCurrentViewToDefault: () => void;
|
|
29
|
+
}
|
|
30
|
+
export declare const MtCollectionContext: import("react").Context<MtCollectionContextProps<any> | null>;
|
|
31
|
+
export declare function useMtCollection<T extends MtCollectionEntry>(): MtCollectionContextProps<T>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type MtCollectionAssigneeOption = {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function MtCollectionPriorityBadge({ priority }: {
|
|
6
|
+
priority?: string;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function MtPrioritySelect({ value, onChange }: {
|
|
9
|
+
value?: string;
|
|
10
|
+
onChange: (value: string) => void;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const MtPrioirtySelect: typeof MtPrioritySelect;
|
|
13
|
+
export declare function MtStateSelect({ value, onChange }: {
|
|
14
|
+
value?: string;
|
|
15
|
+
onChange: (value: string) => void;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function MtIssueTypeSelect({ value, onChange }: {
|
|
18
|
+
value?: string;
|
|
19
|
+
onChange: (value: string) => void;
|
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function MtCollectionSummaryInput({ value, onChange, placeholder, }: {
|
|
22
|
+
value: string;
|
|
23
|
+
onChange: (value: string) => void;
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare function MtCollectionAssigneeDropdown({ assignee, options, onChange, }: {
|
|
27
|
+
assignee?: string;
|
|
28
|
+
options: MtCollectionAssigneeOption[];
|
|
29
|
+
onChange: (value: string) => void;
|
|
30
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { MtFilterGroup } from '../../MtFilter';
|
|
2
|
+
import type { MtSortRule } from '../../MtSort';
|
|
3
|
+
type MtCollectionLegacyFilterState = {
|
|
4
|
+
query?: string;
|
|
5
|
+
status?: string[];
|
|
6
|
+
priority?: string[];
|
|
7
|
+
assignee?: string[];
|
|
8
|
+
};
|
|
9
|
+
export type MtCollectionQuickFilterState = {
|
|
10
|
+
status?: string[];
|
|
11
|
+
assignee?: string[];
|
|
12
|
+
search?: string;
|
|
13
|
+
};
|
|
14
|
+
export type MtCollectionFilterState = MtFilterGroup | MtCollectionLegacyFilterState;
|
|
15
|
+
export declare function getCollectionEntryId(entry: any): string;
|
|
16
|
+
export declare function getCollectionEntrySummary(entry: any): any;
|
|
17
|
+
export declare function getCollectionEntryPriority(entry: any): any;
|
|
18
|
+
export declare function getCollectionEntryAssignee(entry: any): any;
|
|
19
|
+
export declare function toggleCollectionFilterValue(values: string[] | undefined, value: string): string[];
|
|
20
|
+
export declare function getUniqueEntryValues(entries: any[], key: string): string[];
|
|
21
|
+
export declare function applyCollectionFilters(entries: any[], filterState: MtCollectionFilterState | undefined): any[];
|
|
22
|
+
export declare function getDefaultCollectionFilter(): MtFilterGroup;
|
|
23
|
+
export declare function getCollectionFilterRuleCount(filterState: MtCollectionFilterState | undefined): number;
|
|
24
|
+
export declare function isCollectionFilterActive(filterState: MtCollectionFilterState | undefined): boolean;
|
|
25
|
+
export declare function applyCollectionSort(entries: any[], sortRules: MtSortRule[] | undefined, fallbackSortBy?: string): any[];
|
|
26
|
+
export declare function applyCollectionQuickFilters(entries: any[], quickFilters: MtCollectionQuickFilterState | undefined): any[];
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type MtCollectionTaskListEntryProps = {
|
|
2
|
+
entry: any;
|
|
3
|
+
visiblePropertySet: Set<string>;
|
|
4
|
+
onSummaryChange?: (nextSummary: string) => void;
|
|
5
|
+
onPriorityChange?: (nextPriority: string) => void;
|
|
6
|
+
onStatusChange?: (nextStatus: string) => void;
|
|
7
|
+
onIssueTypeChange?: (nextType: string) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare function MtCollectionTaskListEntry({ entry, visiblePropertySet, onSummaryChange, onPriorityChange, onStatusChange, onIssueTypeChange, }: MtCollectionTaskListEntryProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function MtCollectionToolbar(): import("react/jsx-runtime").JSX.Element;
|