@ohseungik/maru-ui 0.1.0 → 0.1.1

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 CHANGED
@@ -34,12 +34,12 @@ export function Example() {
34
34
 
35
35
  ## Components
36
36
 
37
- Button, Checkbox, Dialog, Field, Heading, Input, Select, Stack, Switch, Tabs, Text, Tooltip.
37
+ Button, Checkbox, Dialog, Field, Heading, Input, Popover, Select, Skeleton, Stack, Switch, Table (with TableHead, TableBody, TableRow, TableHeader and TableCell), Tabs, Text, Tooltip.
38
38
 
39
39
  ## Requirements
40
40
 
41
41
  - React 18 or newer
42
- - A current browser. Dialog uses the native `<dialog>` element and Tooltip uses the Popover API (it degrades to a plain element without it).
42
+ - A current browser. Dialog uses the native `<dialog>` element and Tooltip and Popover use the Popover API (it degrades to a plain element without it).
43
43
  - Works with Next.js App Router: the build starts with `"use client"`.
44
44
 
45
45
  ## Links
@@ -0,0 +1,48 @@
1
+ import { type MouseEventHandler, type ReactElement, type ReactNode } from 'react';
2
+ import { type Placement } from '../../utils/position';
3
+ export type PopoverPlacement = Placement;
4
+ /** The props Popover adds to its trigger element. */
5
+ interface TriggerProps {
6
+ onClick?: MouseEventHandler<Element>;
7
+ 'aria-expanded'?: boolean;
8
+ 'aria-controls'?: string;
9
+ 'aria-haspopup'?: 'dialog';
10
+ }
11
+ export interface PopoverProps {
12
+ /** What the panel shows. Unlike a tooltip it may be interactive: links, buttons, fields. */
13
+ content: ReactNode;
14
+ /** The one element that opens the popover. It must be a focusable control, such as a button. */
15
+ children: ReactElement<TriggerProps>;
16
+ /** Visible heading of the panel. It is also the panel's accessible name. */
17
+ title?: ReactNode;
18
+ /** The panel's accessible name when there is no visible `title`. One of the two is required. */
19
+ 'aria-label'?: string;
20
+ /** Preferred side. It flips to the opposite side when there is no room. */
21
+ placement?: PopoverPlacement;
22
+ /** Controlled open state. */
23
+ open?: boolean;
24
+ /** Initial open state when uncontrolled. */
25
+ defaultOpen?: boolean;
26
+ /** Called with the next state when the user opens or dismisses the popover. */
27
+ onOpenChange?: (open: boolean) => void;
28
+ /** Render only the trigger. */
29
+ disabled?: boolean;
30
+ className?: string;
31
+ }
32
+ /**
33
+ * A small non-modal panel that opens from a button and can hold interactive content.
34
+ * It is the interactive sibling of Tooltip: a Tooltip is a hint on hover, a Popover is
35
+ * something the user opens on purpose and works inside.
36
+ *
37
+ * The trigger gets `aria-expanded`, `aria-controls` and `aria-haspopup="dialog"`; the panel is
38
+ * a `role="dialog"` that is not modal, so the rest of the page stays reachable.
39
+ *
40
+ * - Opening moves focus to the first control in the panel (or the panel itself).
41
+ * - Esc closes it and returns focus to the trigger.
42
+ * - Clicking outside, or moving focus out of it (for example with Tab), closes it.
43
+ *
44
+ * It is drawn in the browser's top layer with the Popover API, so no ancestor can clip it.
45
+ * The trigger must render one DOM element, because the panel is positioned against it.
46
+ */
47
+ export declare function Popover({ content, children, title, 'aria-label': ariaLabel, placement, open: openProp, defaultOpen, onOpenChange, disabled, className, }: PopoverProps): import("react").JSX.Element;
48
+ export {};
@@ -0,0 +1,2 @@
1
+ export { Popover } from './Popover';
2
+ export type { PopoverPlacement, PopoverProps } from './Popover';
@@ -0,0 +1,20 @@
1
+ import { type HTMLAttributes } from 'react';
2
+ export type SkeletonVariant = 'text' | 'rect' | 'circle';
3
+ export interface SkeletonProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
4
+ /**
5
+ * The shape: a line of text, a block, or a circle (an avatar). Defaults to `text`.
6
+ */
7
+ variant?: SkeletonVariant;
8
+ /** A number is read as pixels; a string is any CSS length. */
9
+ width?: number | string;
10
+ /** A number is read as pixels; a string is any CSS length. Ignored by `text`, which follows the line height. */
11
+ height?: number | string;
12
+ /** For `text`: how many lines to draw. The last one is shorter, like the end of a paragraph. */
13
+ lines?: number;
14
+ }
15
+ /**
16
+ * A placeholder for content that is still loading. It is decorative: it is hidden from assistive
17
+ * technology, so say that something is loading on the region instead (`aria-busy` and a status
18
+ * message), not on the placeholder.
19
+ */
20
+ export declare const Skeleton: import("react").ForwardRefExoticComponent<SkeletonProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,2 @@
1
+ export { Skeleton } from './Skeleton';
2
+ export type { SkeletonProps, SkeletonVariant } from './Skeleton';
@@ -0,0 +1,21 @@
1
+ import { type ReactNode, type TableHTMLAttributes } from 'react';
2
+ export type TableSize = 'sm' | 'md';
3
+ export interface TableProps extends TableHTMLAttributes<HTMLTableElement> {
4
+ /**
5
+ * What the table is about. It is a native `<caption>`, so it names the table for assistive
6
+ * technology. Give the table either a caption or an `aria-label`.
7
+ */
8
+ caption?: ReactNode;
9
+ /** Keep the caption for assistive technology only. */
10
+ hideCaption?: boolean;
11
+ size?: TableSize;
12
+ /** Shade every other row. */
13
+ striped?: boolean;
14
+ }
15
+ /**
16
+ * A data table on the native `<table>` elements, inside a wrapper that scrolls sideways when the
17
+ * table is wider than its container. A scroll area is only reachable by keyboard when it can take
18
+ * focus, so the wrapper becomes a focusable, named region exactly while it overflows and is a
19
+ * plain element otherwise (no extra Tab stop).
20
+ */
21
+ export declare const Table: import("react").ForwardRefExoticComponent<TableProps & import("react").RefAttributes<HTMLTableElement>>;
@@ -0,0 +1,30 @@
1
+ import { type HTMLAttributes, type TdHTMLAttributes, type ThHTMLAttributes } from 'react';
2
+ export type TableSort = 'ascending' | 'descending' | 'none';
3
+ export type TableHeadProps = HTMLAttributes<HTMLTableSectionElement>;
4
+ export type TableBodyProps = HTMLAttributes<HTMLTableSectionElement>;
5
+ export type TableRowProps = HTMLAttributes<HTMLTableRowElement>;
6
+ export declare const TableHead: import("react").ForwardRefExoticComponent<TableHeadProps & import("react").RefAttributes<HTMLTableSectionElement>>;
7
+ export declare const TableBody: import("react").ForwardRefExoticComponent<TableBodyProps & import("react").RefAttributes<HTMLTableSectionElement>>;
8
+ export declare const TableRow: import("react").ForwardRefExoticComponent<TableRowProps & import("react").RefAttributes<HTMLTableRowElement>>;
9
+ export interface TableHeaderProps extends Omit<ThHTMLAttributes<HTMLTableCellElement>, 'scope'> {
10
+ /** `col` for a column heading (the default), `row` for the first cell of a row. */
11
+ scope?: 'col' | 'row';
12
+ /** Right-align numbers and use equal-width digits. */
13
+ numeric?: boolean;
14
+ /**
15
+ * The current sort of this column. Set it on the sorted column and on the other sortable ones
16
+ * (`none`); it is exposed as `aria-sort`. Leave it out for columns that cannot be sorted.
17
+ */
18
+ sort?: TableSort;
19
+ /**
20
+ * Makes the heading a button that asks for a new sort. The table does not sort anything itself:
21
+ * change the rows and the `sort` prop in this handler.
22
+ */
23
+ onSort?: () => void;
24
+ }
25
+ export declare const TableHeader: import("react").ForwardRefExoticComponent<TableHeaderProps & import("react").RefAttributes<HTMLTableCellElement>>;
26
+ export interface TableCellProps extends TdHTMLAttributes<HTMLTableCellElement> {
27
+ /** Right-align numbers and use equal-width digits. */
28
+ numeric?: boolean;
29
+ }
30
+ export declare const TableCell: import("react").ForwardRefExoticComponent<TableCellProps & import("react").RefAttributes<HTMLTableCellElement>>;
@@ -0,0 +1,4 @@
1
+ export { Table } from './Table';
2
+ export type { TableProps, TableSize } from './Table';
3
+ export { TableBody, TableCell, TableHead, TableHeader, TableRow } from './TableParts';
4
+ export type { TableBodyProps, TableCellProps, TableHeadProps, TableHeaderProps, TableRowProps, TableSort, } from './TableParts';
@@ -1,5 +1,5 @@
1
1
  import { type FocusEventHandler, type KeyboardEventHandler, type MouseEventHandler, type ReactElement, type ReactNode } from 'react';
2
- import { type TooltipPlacement } from './position';
2
+ import { type Placement } from '../../utils/position';
3
3
  /** The props Tooltip adds to its trigger element. */
4
4
  interface TriggerProps {
5
5
  onMouseEnter?: MouseEventHandler<Element>;
@@ -9,6 +9,7 @@ interface TriggerProps {
9
9
  onKeyDown?: KeyboardEventHandler<Element>;
10
10
  'aria-describedby'?: string;
11
11
  }
12
+ export type TooltipPlacement = Placement;
12
13
  export interface TooltipProps {
13
14
  /** Short, plain text. A tooltip cannot contain anything interactive. */
14
15
  content: ReactNode;
@@ -1,3 +1,2 @@
1
1
  export { Tooltip } from './Tooltip';
2
- export type { TooltipProps } from './Tooltip';
3
- export type { TooltipPlacement } from './position';
2
+ export type { TooltipPlacement, TooltipProps } from './Tooltip';
package/dist/index.d.ts CHANGED
@@ -10,12 +10,18 @@ export { Heading } from './components/Heading';
10
10
  export type { HeadingLevel, HeadingProps, HeadingSize, HeadingTone } from './components/Heading';
11
11
  export { Input } from './components/Input';
12
12
  export type { InputProps, InputSize } from './components/Input';
13
+ export { Popover } from './components/Popover';
14
+ export type { PopoverPlacement, PopoverProps } from './components/Popover';
13
15
  export { Select } from './components/Select';
14
16
  export type { SelectProps, SelectSize } from './components/Select';
17
+ export { Skeleton } from './components/Skeleton';
18
+ export type { SkeletonProps, SkeletonVariant } from './components/Skeleton';
15
19
  export { Stack } from './components/Stack';
16
20
  export type { StackElement, StackGap, StackProps } from './components/Stack';
17
21
  export { Switch } from './components/Switch';
18
22
  export type { SwitchProps, SwitchSize } from './components/Switch';
23
+ export { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from './components/Table';
24
+ export type { TableBodyProps, TableCellProps, TableHeadProps, TableHeaderProps, TableProps, TableRowProps, TableSize, TableSort, } from './components/Table';
19
25
  export { Tab, TabList, TabPanel, Tabs } from './components/Tabs';
20
26
  export type { TabListProps, TabPanelProps, TabProps, TabsActivation, TabsOrientation, TabsProps, } from './components/Tabs';
21
27
  export { Text } from './components/Text';