@webority/ui-react 0.24.0 → 0.25.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/types/components/AppBarChart.d.ts +31 -0
- package/dist/types/components/AppCalendar.d.ts +45 -0
- package/dist/types/components/AppChart.d.ts +56 -0
- package/dist/types/components/AppChartCard.d.ts +39 -0
- package/dist/types/components/AppContextMenu.d.ts +57 -0
- package/dist/types/components/AppDashboardCell.d.ts +14 -0
- package/dist/types/components/AppDashboardGrid.d.ts +22 -0
- package/dist/types/components/AppInput.d.ts +19 -0
- package/dist/types/components/AppLineChart.d.ts +50 -0
- package/dist/types/components/AppLogoPicker.d.ts +2 -1
- package/dist/types/components/AppRichText.d.ts +42 -0
- package/dist/types/components/AppSortableList.d.ts +32 -0
- package/dist/types/components/AppSparkline.d.ts +24 -0
- package/dist/types/components/AppTreeView.d.ts +44 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/ui-react.js +3791 -2897
- package/package.json +5 -5
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A bar chart of categories, each measured against its own maximum ("18 of 25"), such as the
|
|
3
|
+
* parts of a total score. Every bar fills toward its own `max`, so bars with different maxima
|
|
4
|
+
* compare as how complete each one is; the printed value carries the magnitude. Values are
|
|
5
|
+
* labelled directly on every bar, so there is no legend and no tooltip to discover. Each bar is
|
|
6
|
+
* a keyboard-focusable `role="meter"` inside a list, named by its label and value ("GST and tax, 11 of 15").
|
|
7
|
+
*
|
|
8
|
+
* @param {object} props
|
|
9
|
+
* @param {{ label: string, value: number, max: number }[]} props.data One entry per bar, in order.
|
|
10
|
+
* Labels must be unique. `value` is clamped into 0 to `max`.
|
|
11
|
+
* @param {(value: number) => string} [props.formatValue] Formats each value and maximum.
|
|
12
|
+
* Defaults to `String(value)`.
|
|
13
|
+
* @param {'horizontal'|'vertical'} [props.orientation='horizontal'] Horizontal stacks a row per
|
|
14
|
+
* bar (label and value above each bar) and reads best on a phone; vertical stands the bars
|
|
15
|
+
* side by side with the labels beneath.
|
|
16
|
+
* @param {string} [props.title] A visible caption above the chart; also names it for assistive tech.
|
|
17
|
+
* @param {string} [props.ariaLabel] Names the chart when there is no visible `title`.
|
|
18
|
+
* @param {string} [props.className]
|
|
19
|
+
*/
|
|
20
|
+
export default function AppBarChart({ data, formatValue, orientation, title, ariaLabel, className, ...rest }: {
|
|
21
|
+
data: {
|
|
22
|
+
label: string;
|
|
23
|
+
value: number;
|
|
24
|
+
max: number;
|
|
25
|
+
}[];
|
|
26
|
+
formatValue?: (value: number) => string;
|
|
27
|
+
orientation?: 'horizontal' | 'vertical';
|
|
28
|
+
title?: string;
|
|
29
|
+
ariaLabel?: string;
|
|
30
|
+
className?: string;
|
|
31
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shows events on a month, week, day or list view, in India Standard Time, with weeks starting on
|
|
3
|
+
* Monday. The calendar is the shared `<wui-calendar>` element, the same one the Razor
|
|
4
|
+
* `<app-calendar>` uses, with its calendar engine loaded the first time a calendar mounts: a page
|
|
5
|
+
* without a calendar never downloads it.
|
|
6
|
+
*
|
|
7
|
+
* Give it events as data (`events`), or an address (`eventsUrl`) it calls whenever the visible
|
|
8
|
+
* period changes, with `start` and `end` query parameters: IST `YYYY-MM-DD` days, `end` being the
|
|
9
|
+
* first day not shown. The address answers with a JSON list of events. An event is
|
|
10
|
+
* `{ id, title, start, end, allDay, tone, url }`: `start` and `end` are a `YYYY-MM-DD` day or an ISO
|
|
11
|
+
* date-time (an offset or Z is shifted to IST, no offset is already IST); `end` is the first moment
|
|
12
|
+
* after the event, so an all-day event on the 4th ends on the 5th; `tone` colours it from the theme
|
|
13
|
+
* (neutral, primary, success, warning, danger, info); `url` makes it a link.
|
|
14
|
+
*
|
|
15
|
+
* Every day can be reached by keyboard: one tab stop among the days, the arrow keys move between
|
|
16
|
+
* them, Home and End go to Monday and Sunday, Page Up and Page Down to the previous and next month,
|
|
17
|
+
* Enter opens the day. A calendar given no `view` opens as a list when it is narrower than a
|
|
18
|
+
* phone.
|
|
19
|
+
*
|
|
20
|
+
* ```jsx
|
|
21
|
+
* <AppCalendar
|
|
22
|
+
* label="Team leave"
|
|
23
|
+
* eventsUrl="/api/leave"
|
|
24
|
+
* onEventClick={(event) => openLeave(event.id)}
|
|
25
|
+
* onDateClick={({ date }) => startRequest(date)}
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param {object} props
|
|
30
|
+
* @param {string} [props.label='Calendar'] The name a screen reader hears for the calendar.
|
|
31
|
+
* @param {{ id?: string|number, title: string, start: string, end?: string, allDay?: boolean, tone?: 'neutral'|'primary'|'success'|'warning'|'danger'|'info', url?: string }[]} [props.events] The events, instead of `eventsUrl`. Extra keys are kept and come back in `onEventClick`.
|
|
32
|
+
* @param {string} [props.eventsUrl] Called with `start` and `end` (IST days) whenever the visible period changes; answers a JSON list of events.
|
|
33
|
+
* @param {'month'|'week'|'day'|'list'} [props.view] The view to show. Without it a calendar opens on the month, or on the list when it is narrower than a phone.
|
|
34
|
+
* @param {string} [props.date] The IST day (`YYYY-MM-DD`) to show; today when omitted. Changing it moves the calendar.
|
|
35
|
+
* @param {string} [props.emptyText] What a list with no events says.
|
|
36
|
+
* @param {string} [props.errorText] What is said when `eventsUrl` could not be loaded, and when the calendar's code could not.
|
|
37
|
+
* @param {(event: object) => (void|false)} [props.onEventClick] An event was clicked, or Enter was pressed on it. Gets the event as it was given. Return `false` to stop an event's own link.
|
|
38
|
+
* @param {(detail: { date: string, time: string|null, allDay: boolean }) => void} [props.onDateClick] A day was clicked, or Enter was pressed on it; `time` is set for a click on a time slot.
|
|
39
|
+
* @param {(detail: { view: string, date: string, start: string, end: string, title: string }) => void} [props.onRangeChange] The view or the visible period changed.
|
|
40
|
+
* @param {string} [props.className] Extra classes on the element.
|
|
41
|
+
* @param {import('react').CSSProperties} [props.style] Inline style on the element.
|
|
42
|
+
* @param {import('react').Ref<HTMLElement>} [ref] The `<wui-calendar>` element, which has `refetch()`.
|
|
43
|
+
*/
|
|
44
|
+
declare const AppCalendar: import("react").ForwardRefExoticComponent<import("react").RefAttributes<any>>;
|
|
45
|
+
export default AppCalendar;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Draws a line, area, column, horizontal bar, donut, heatmap, calendar heatmap, funnel, gauge,
|
|
3
|
+
* waterfall, treemap, sankey, scatter, bubble or small-multiples chart from rows of data. The chart is the
|
|
4
|
+
* shared `<wui-chart>` element, the same one the Razor `<app-chart>` uses, with its drawing engine
|
|
5
|
+
* loaded the first time a chart mounts: a page without a chart never downloads it.
|
|
6
|
+
*
|
|
7
|
+
* You describe the chart; you never touch the engine. Every chart comes with a legend that shows
|
|
8
|
+
* and hides series, tooltips, arrow-key movement between points (each value read aloud), a real
|
|
9
|
+
* data table behind the picture, a screen-reader summary, light and dark colours from the theme,
|
|
10
|
+
* resize, and PNG and CSV export through the element (see AppChartCard for the buttons).
|
|
11
|
+
*
|
|
12
|
+
* Money is rupees, or paise when `format.unit` says so. Dates show in IST. A `percent` value is a
|
|
13
|
+
* ratio: 0.125 shows as 12.5%.
|
|
14
|
+
*
|
|
15
|
+
* ```jsx
|
|
16
|
+
* <AppChart
|
|
17
|
+
* type="column"
|
|
18
|
+
* title="Revenue by month"
|
|
19
|
+
* data={[{ month: "Aug", revenue: 4120000 }, { month: "Sep", revenue: 4630000 }]}
|
|
20
|
+
* x={{ key: "month" }}
|
|
21
|
+
* series={[{ key: "revenue", label: "Revenue", format: { style: "currency" } }]}
|
|
22
|
+
* onSelect={(detail) => console.log(detail.x, detail.value)}
|
|
23
|
+
* />
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param {object} props
|
|
27
|
+
* @param {'line'|'area'|'column'|'bar'|'donut'|'heatmap'|'calendar'|'funnel'|'gauge'|'waterfall'|'treemap'|'sankey'|'scatter'|'bubble'|'multiples'} props.type `column` is vertical bars, `bar` horizontal. `multiples` draws each series as its own small chart under one shared x axis.
|
|
28
|
+
* @param {string} props.title Required. Names the chart for assistive tech and names exported files. An empty string counts as not given.
|
|
29
|
+
* @param {string} [props.description] One sentence a screen reader hears before the automatic summary.
|
|
30
|
+
* @param {Record<string, string|number|null>[]} props.data One row per x position, slice, cell, stage, flow or point: what a row is depends on the type.
|
|
31
|
+
* @param {{ key: string, kind?: 'category'|'time'|'value', format?: object, label?: string }} props.x The column holding the x value. `time` takes epoch ms, an ISO instant or a "YYYY-MM-DD" day; `value` (scatter and bubble) is a number. A calendar is always `time`, a scatter and a bubble always `value`.
|
|
32
|
+
* @param {{ key: string, label: string, format?: object }[]} props.series The value columns, in the order they take colours: at most 8. Every type but line, area, column, bar and multiples takes one.
|
|
33
|
+
* @param {{ key: string, label?: string }} [props.group] The second dimension: a heatmap's rows, a treemap's parents, a scatter or bubble's colour groups (at most 3). Required for a heatmap and a treemap.
|
|
34
|
+
* @param {{ key: string, label?: string }} [props.to] Where each sankey flow ends; `x` is where it starts. Required for a sankey.
|
|
35
|
+
* @param {{ key: string, label?: string, format?: object }} [props.size] A bubble's area. Required for a bubble.
|
|
36
|
+
* @param {boolean} [props.trend] A scatter or bubble's straight trend line through the visible points.
|
|
37
|
+
* @param {boolean} [props.zoom] A zoom slider under a line or area. On by default above 5,000 rows.
|
|
38
|
+
* @param {{ upTo: number, label: string }[]} [props.bands] A gauge's named stretches of its scale, each up to a value.
|
|
39
|
+
* @param {'none'|'stacked'|'percent'} [props.stack='none'] For area, column and bar.
|
|
40
|
+
* @param {{ label?: string, format?: object, min?: number, max?: number }} [props.y] The one value axis. There is no second axis: show another measure as its own chart.
|
|
41
|
+
* @param {{ value: number, label: string }} [props.target] A dashed reference line.
|
|
42
|
+
* @param {number} [props.height=320] In px, the axis labels included. A value that is not above 0 draws at the default.
|
|
43
|
+
* @param {'ready'|'loading'|'empty'|'error'} [props.state='ready'] `loading` after a first draw keeps that picture on screen, dimmed.
|
|
44
|
+
* @param {string} [props.emptyText] Replaces the default empty message.
|
|
45
|
+
* @param {string} [props.errorText] Replaces the default error message. Say what the person can do.
|
|
46
|
+
* @param {'auto'|'svg'|'canvas'} [props.renderer='auto'] `auto` draws SVG, and canvas above 5,000 points.
|
|
47
|
+
* @param {'chart'|'table'} [props.view='chart'] `table` shows the data table in the chart's place.
|
|
48
|
+
* @param {(detail: { series: string, label: string, x: unknown, value: number|null, row: object, index: number }) => void} [props.onSelect] A mark was clicked, or Enter was pressed on the focused point.
|
|
49
|
+
* @param {(detail: { visible: Record<string, boolean> }) => void} [props.onLegendChange] A legend button was pressed.
|
|
50
|
+
* @param {(detail: { renderer: string }) => void} [props.onReady] The first picture has finished drawing.
|
|
51
|
+
* @param {string} [props.className] Extra classes on the element.
|
|
52
|
+
* @param {import('react').CSSProperties} [props.style] Inline style on the element.
|
|
53
|
+
* @param {import('react').Ref<HTMLElement>} [ref] The `<wui-chart>` element, which has `toCsv()`, `toPng()`, `exportCsv()` and `exportPng()`.
|
|
54
|
+
*/
|
|
55
|
+
declare const AppChart: import("react").ForwardRefExoticComponent<import("react").RefAttributes<any>>;
|
|
56
|
+
export default AppChart;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A card around a chart: a title, a subtitle that says what the numbers are, and the view
|
|
3
|
+
* controls, which are all the card adds. A legend button, a Chart / Table switch, and a menu to
|
|
4
|
+
* download the chart as a PNG or the data as a CSV. Put an `AppChart` inside as `children`.
|
|
5
|
+
*
|
|
6
|
+
* The card has no date-range picker: a dashboard sets the range once, in its filter row, for
|
|
7
|
+
* every card on it.
|
|
8
|
+
*
|
|
9
|
+
* The Chart / Table switch follows the chart's own `view`: a chart that opens in `table` starts the switch
|
|
10
|
+
* on Table, and a chart that is replaced (a skeleton giving way to the chart, say) keeps the view the
|
|
11
|
+
* person chose unless the new chart sets its own.
|
|
12
|
+
*
|
|
13
|
+
* When the chart is in its error state the card shows a Try again button, if you pass `onRetry`.
|
|
14
|
+
* The chart only says what went wrong; fetching again is yours, so `onRetry` is where you do it.
|
|
15
|
+
*
|
|
16
|
+
* ```jsx
|
|
17
|
+
* <AppChartCard title="Revenue by month" subtitle="In rupees, 12 months to 30-Sep-2026" onRetry={reload}>
|
|
18
|
+
* <AppChart type="column" title="Revenue by month" data={rows} x={{ key: "month" }} series={series} />
|
|
19
|
+
* </AppChartCard>
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param {object} props
|
|
23
|
+
* @param {string} props.title The card's heading. Also names the menu button for assistive tech.
|
|
24
|
+
* @param {string} [props.subtitle] A muted line under the title: the unit or the period.
|
|
25
|
+
* @param {boolean} [props.toolbar=true] Show the view controls.
|
|
26
|
+
* @param {() => void} [props.onRetry] Adds a Try again button that shows while the chart is in its error state.
|
|
27
|
+
* @param {import('react').ReactNode} [props.footer] A row under the chart: a source, an updated-at time, a link.
|
|
28
|
+
* @param {import('react').ReactNode} props.children The chart.
|
|
29
|
+
* @param {string} [props.className] Extra classes on the card.
|
|
30
|
+
*/
|
|
31
|
+
export default function AppChartCard({ title, subtitle, toolbar, onRetry, footer, children, className, ...rest }: {
|
|
32
|
+
title: string;
|
|
33
|
+
subtitle?: string;
|
|
34
|
+
toolbar?: boolean;
|
|
35
|
+
onRetry?: () => void;
|
|
36
|
+
footer?: import('react').ReactNode;
|
|
37
|
+
children: import('react').ReactNode;
|
|
38
|
+
className?: string;
|
|
39
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import "@webority/ui-elements";
|
|
2
|
+
/**
|
|
3
|
+
* A right-click menu over a region of the page. The menu opens on right-click, on a long press
|
|
4
|
+
* of a finger, and on Shift+F10 or the ContextMenu key; it sits at the pointer (under the focused
|
|
5
|
+
* element for the keyboard), stays inside the viewport, and closes on Escape, an outside press,
|
|
6
|
+
* a scroll or a resize. The behaviour is the shared `<wui-context-menu>` element, the same one
|
|
7
|
+
* the Razor `<app-context-menu>` uses; the items are the `AppDropdown` item model.
|
|
8
|
+
*
|
|
9
|
+
* Two ways to name the region. Wrap it: `children` is the region, and any right-click inside
|
|
10
|
+
* it opens the menu. Or point at it: `target` is a CSS selector, and the menu serves every
|
|
11
|
+
* element that matches, including ones added later (put the menu beside a table, not inside
|
|
12
|
+
* it, and use `target="tbody tr"`). The browser's own menu stays on inside inputs, textareas
|
|
13
|
+
* and contenteditable content, with `disabled`, and on Shift+right-click.
|
|
14
|
+
*
|
|
15
|
+
* NOTE: the exported component must stay the FIRST destructured function in this file —
|
|
16
|
+
* the parity check reads the first signature it finds as the component's public props.
|
|
17
|
+
*
|
|
18
|
+
* @param {object} props
|
|
19
|
+
* @param {{ key: string, label?: string, icon?: string|import('react').ReactNode, image?: string, to?: string, onClick?: () => void, danger?: boolean, disabled?: boolean, divider?: true }[]} [props.items]
|
|
20
|
+
* The AppDropdown item model. `icon` is a glyph name or a node, `image` a picture URL. A
|
|
21
|
+
* `disabled` item is listed but skipped by the arrow keys and cannot be chosen. An item with
|
|
22
|
+
* `divider: true` renders a separator and needs only a unique `key`.
|
|
23
|
+
* @param {string} [props.target] CSS selector of the elements the menu serves. Without it, the
|
|
24
|
+
* menu serves `children`.
|
|
25
|
+
* @param {import('react').ReactNode} [props.children] The region to attach to, when `target` is not used.
|
|
26
|
+
* @param {string} [props.ariaLabel='Context menu'] Accessible name of the menu.
|
|
27
|
+
* @param {boolean} [props.disabled=false] Turns the menu off; the browser's own menu shows instead.
|
|
28
|
+
* @param {(detail: { region: Element, origin: Element, x: number, y: number }) => void} [props.onOpen]
|
|
29
|
+
* Called as the menu opens. `region` is the matched target, `origin` the element the user acted on inside it.
|
|
30
|
+
* @param {string} [props.menuClassName] Extra classes on the menu panel.
|
|
31
|
+
* @param {import('react').ElementType} [props.linkComponent] Component for `to` items (e.g. Link).
|
|
32
|
+
*/
|
|
33
|
+
export default function AppContextMenu({ items, target, children, ariaLabel, disabled, onOpen, menuClassName, linkComponent, ...rest }: {
|
|
34
|
+
items?: {
|
|
35
|
+
key: string;
|
|
36
|
+
label?: string;
|
|
37
|
+
icon?: string | import('react').ReactNode;
|
|
38
|
+
image?: string;
|
|
39
|
+
to?: string;
|
|
40
|
+
onClick?: () => void;
|
|
41
|
+
danger?: boolean;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
divider?: true;
|
|
44
|
+
}[];
|
|
45
|
+
target?: string;
|
|
46
|
+
children?: import('react').ReactNode;
|
|
47
|
+
ariaLabel?: string;
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
onOpen?: (detail: {
|
|
50
|
+
region: Element;
|
|
51
|
+
origin: Element;
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
}) => void;
|
|
55
|
+
menuClassName?: string;
|
|
56
|
+
linkComponent?: import('react').ElementType;
|
|
57
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One cell of an `AppDashboardGrid`: it spans 3, 4, 6 or 12 of the twelve columns, and takes the full
|
|
3
|
+
* width under 576px. A card or tile inside fills the cell's height.
|
|
4
|
+
*
|
|
5
|
+
* @param {object} props
|
|
6
|
+
* @param {3|4|6|12} [props.span=12] How many of the twelve columns the cell spans.
|
|
7
|
+
* @param {import('react').ReactNode} props.children The card or tile.
|
|
8
|
+
* @param {string} [props.className] Extra classes on the cell.
|
|
9
|
+
*/
|
|
10
|
+
export default function AppDashboardCell({ span, children, className, ...rest }: {
|
|
11
|
+
span?: 3 | 4 | 6 | 12;
|
|
12
|
+
children: import('react').ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The layout of a dashboard: twelve columns of `AppDashboardCell`s that each span 3, 4, 6 or 12 of
|
|
3
|
+
* them, and one column under 576px. There is no drag and drop and no saved layout: the page says
|
|
4
|
+
* where each card goes. Put KPI tiles at span 3, charts at 6 or 12, and a wide table at 12.
|
|
5
|
+
*
|
|
6
|
+
* The date range of a dashboard belongs in one filter row above the grid, not inside each card.
|
|
7
|
+
*
|
|
8
|
+
* ```jsx
|
|
9
|
+
* <AppDashboardGrid>
|
|
10
|
+
* <AppDashboardCell span={3}><AppKpiTile label="Revenue" value="₹38 L" /></AppDashboardCell>
|
|
11
|
+
* <AppDashboardCell span={6}><AppChartCard title="Revenue by month">…</AppChartCard></AppDashboardCell>
|
|
12
|
+
* </AppDashboardGrid>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param {object} props
|
|
16
|
+
* @param {import('react').ReactNode} props.children `AppDashboardCell`s.
|
|
17
|
+
* @param {string} [props.className] Extra classes on the grid.
|
|
18
|
+
*/
|
|
19
|
+
export default function AppDashboardGrid({ children, className, ...rest }: {
|
|
20
|
+
children: import('react').ReactNode;
|
|
21
|
+
className?: string;
|
|
22
|
+
}): import("react").JSX.Element;
|
|
@@ -50,6 +50,25 @@
|
|
|
50
50
|
* `@webority/ui-elements`, so both surfaces validate identically.
|
|
51
51
|
* @param {"auto"|"top"|"bottom"|"start"|"end"} [props.requirementsPlacement="auto"] Which side the
|
|
52
52
|
* requirements popover opens; `auto` flips to stay in view.
|
|
53
|
+
* @param {string} [props.mask] Format the value while it is typed. A named mask
|
|
54
|
+
* (`phone-in`, `pan`, `gstin`, `aadhaar`, `ifsc`, `pin-code`, `date` as DD-MM-YYYY, `amount` with
|
|
55
|
+
* Indian grouping) or a pattern, where `9` is a digit, `A` a letter, `*` a digit or letter and any
|
|
56
|
+
* other character a literal (`"(999) 999-9999"`). Paste is cleaned and re-formatted, Backspace and
|
|
57
|
+
* Delete step over literals, and the caret stays put; a keyboard that composes text (an Android IME) is
|
|
58
|
+
* left alone until it commits, and a value set from code (react-hook-form `setValue` / `reset`) is
|
|
59
|
+
* laid out too. The behaviour is the one `<app-input mask>` runs, from `@webority/ui-elements`. Use
|
|
60
|
+
* it on a `text`, `tel`, `search`, `url` or `password` field; any other `type` warns, and an unknown
|
|
61
|
+
* mask name warns. A controlled `value` (raw or formatted) is laid out under the mask. `onChange`
|
|
62
|
+
* and `onBlur` get an event whose `target.value` is the POSTED value (the raw characters, or ISO
|
|
63
|
+
* `yyyy-MM-dd` for `date`), so a controlled field and a zod rule see what the server will see;
|
|
64
|
+
* `onInput` sees the field as displayed. react-hook-form's `register` reads the element itself, so
|
|
65
|
+
* pair it with `setValueAs: (v) => postedMasked(mask, v)`. A named mask also marks the field invalid
|
|
66
|
+
* with a curated message while it is incomplete or wrong, shown as the field's error once the field
|
|
67
|
+
* has been left or a submit was tried (an `error` you pass wins).
|
|
68
|
+
* @param {boolean} [props.postFormatted=false] With a `mask`, a native form submit posts the
|
|
69
|
+
* formatted value instead of the raw one (the typed characters without the literals).
|
|
70
|
+
* @param {(raw: string, formatted: string) => void} [props.onMaskChange] Called with the raw and the
|
|
71
|
+
* formatted value whenever the raw value changes.
|
|
53
72
|
* @param {import('react').Ref<HTMLInputElement>} [ref]
|
|
54
73
|
*/
|
|
55
74
|
declare const AppInput: import("react").ForwardRefExoticComponent<import("react").RefAttributes<any>>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A line chart: one numeric series over categorical x labels (months, quarters, attempts).
|
|
3
|
+
* Hand-drawn SVG, no chart library. The x axis is laid out in percentages and the y axis in
|
|
4
|
+
* pixels, so the chart fills any width without a resize observer and without scaling its text.
|
|
5
|
+
* Each point is a focusable button that shows its value on hover and focus; a visually hidden
|
|
6
|
+
* table carries every value, the band and reference labels included, for screen readers.
|
|
7
|
+
*
|
|
8
|
+
* @param {object} props
|
|
9
|
+
* @param {{ label: string, value: number | null }[]} props.data The series, in x order. Labels must
|
|
10
|
+
* be unique. A `null` value leaves a gap in the line.
|
|
11
|
+
* @param {string} [props.name] The series name, read before each point's value ("Score, Mar: 72").
|
|
12
|
+
* @param {number} [props.yMin] Fixes the bottom of the y axis. Omitted: taken from the data,
|
|
13
|
+
* rounded down to a whole tick.
|
|
14
|
+
* @param {number} [props.yMax] Fixes the top of the y axis. Omitted: taken from the data,
|
|
15
|
+
* rounded up to a whole tick.
|
|
16
|
+
* @param {{ from: number, to: number, label?: string, tone?: 'neutral'|'info'|'success'|'warning'|'danger' }[]} [props.bands]
|
|
17
|
+
* Shaded y ranges behind the line, such as rating bands, each labelled at its top right.
|
|
18
|
+
* @param {{ value: number, label?: string }[]} [props.referenceLines] Dashed horizontal lines,
|
|
19
|
+
* such as a target or a threshold, each labelled at its right end.
|
|
20
|
+
* @param {(value: number) => string} [props.formatValue] Formats every value the chart prints:
|
|
21
|
+
* ticks, tooltips, the data table. Defaults to `String(value)`.
|
|
22
|
+
* @param {number} [props.height=240] Height of the plot area in px, x labels excluded.
|
|
23
|
+
* @param {string} [props.title] A visible caption above the chart; also names it for assistive tech.
|
|
24
|
+
* @param {string} [props.ariaLabel] Names the chart when there is no visible `title`.
|
|
25
|
+
* @param {string} [props.className]
|
|
26
|
+
*/
|
|
27
|
+
export default function AppLineChart({ data, name, yMin, yMax, bands, referenceLines, formatValue, height, title, ariaLabel, className, ...rest }: {
|
|
28
|
+
data: {
|
|
29
|
+
label: string;
|
|
30
|
+
value: number | null;
|
|
31
|
+
}[];
|
|
32
|
+
name?: string;
|
|
33
|
+
yMin?: number;
|
|
34
|
+
yMax?: number;
|
|
35
|
+
bands?: {
|
|
36
|
+
from: number;
|
|
37
|
+
to: number;
|
|
38
|
+
label?: string;
|
|
39
|
+
tone?: 'neutral' | 'info' | 'success' | 'warning' | 'danger';
|
|
40
|
+
}[];
|
|
41
|
+
referenceLines?: {
|
|
42
|
+
value: number;
|
|
43
|
+
label?: string;
|
|
44
|
+
}[];
|
|
45
|
+
formatValue?: (value: number) => string;
|
|
46
|
+
height?: number;
|
|
47
|
+
title?: string;
|
|
48
|
+
ariaLabel?: string;
|
|
49
|
+
className?: string;
|
|
50
|
+
}): import("react").JSX.Element;
|
|
@@ -3,11 +3,12 @@ fallback, // node shown when there's no image (e.g. initials)
|
|
|
3
3
|
name, onPick, // (file) => void — receives a validated File
|
|
4
4
|
onRemove, // () => void — clears the current logo
|
|
5
5
|
loading, // show a spinner + block interaction while the pick is uploading
|
|
6
|
-
disabled, accept, maxSizeMb, overlayIcon, overlayLabel, ariaLabel, label, hint, error, layout, title, subtitle, required, variant, size, shape, className, ...rest }: {
|
|
6
|
+
disabled, accept, maxSizeMb, crop, overlayIcon, overlayLabel, ariaLabel, label, hint, error, layout, title, subtitle, required, variant, size, shape, className, ...rest }: {
|
|
7
7
|
[x: string]: any;
|
|
8
8
|
accept?: string;
|
|
9
9
|
ariaLabel?: string;
|
|
10
10
|
className?: string;
|
|
11
|
+
crop: any;
|
|
11
12
|
disabled?: boolean;
|
|
12
13
|
error: any;
|
|
13
14
|
fallback: any;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A formatted-text field: a toolbar (bold, italic, inline code, link, headings, lists, quote, code
|
|
3
|
+
* block, undo, redo) over an editable surface, with the usual keyboard shortcuts. The field is the
|
|
4
|
+
* shared `<wui-rich-text>` element, the same one the Razor `<app-rich-text>` uses, with its editing
|
|
5
|
+
* engine loaded the first time an editor mounts: a page without one never downloads it.
|
|
6
|
+
*
|
|
7
|
+
* The value is a string in `format`, HTML by default or Markdown. It is always written out from a
|
|
8
|
+
* fixed set of allowed content (paragraphs, bold, italic, inline code, links, two heading levels,
|
|
9
|
+
* lists, quotes, code blocks), so pasted or seeded markup outside that set never reaches the value:
|
|
10
|
+
* a pasted script, style, class or table has nowhere to land. A link may point at http, https,
|
|
11
|
+
* mailto or tel only. An empty editor is the empty string. Still sanitise on the server: the
|
|
12
|
+
* browser is not a trust boundary.
|
|
13
|
+
*
|
|
14
|
+
* ```jsx
|
|
15
|
+
* <AppRichText label="Notes" value={notes} onChange={setNotes} hint="Shown on the invoice." />
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* `onChange` fires on every edit with the new string. `format` is read when the editor mounts; the
|
|
19
|
+
* wrapper remounts the editor when it changes, so the value you hold must be in the new format.
|
|
20
|
+
*
|
|
21
|
+
* @param {object} props
|
|
22
|
+
* @param {string} [props.value] The content, in `format`.
|
|
23
|
+
* @param {(value: string) => void} [props.onChange] Called with the new string on every edit.
|
|
24
|
+
* @param {'html'|'markdown'} [props.format='html'] What `value` is.
|
|
25
|
+
* @param {string} [props.placeholder] Shown while the editor is empty.
|
|
26
|
+
* @param {string} [props.name] Posted under this name with a form.
|
|
27
|
+
* @param {import('react').ReactNode} [props.label]
|
|
28
|
+
* @param {string} [props.error]
|
|
29
|
+
* @param {string} [props.hint]
|
|
30
|
+
* @param {boolean} [props.required=false] Marks the field required; an empty editor is invalid.
|
|
31
|
+
* @param {boolean} [props.disabled=false] Locks the editor and keeps it out of the form post.
|
|
32
|
+
* @param {boolean} [props.readOnly=false] Locks the editor; the value still posts.
|
|
33
|
+
* @param {string} [props.id]
|
|
34
|
+
* @param {string} [props.ariaLabel] Accessible name for the editor; defaults to a string `label`.
|
|
35
|
+
* @param {string} [props.className] Class on the `<wui-rich-text>` element.
|
|
36
|
+
* @param {string} [props.fieldClassName] Class on the wrapper field div.
|
|
37
|
+
* @param {import('react').ReactNode} [props.help] Help content shown in an info tip beside the label.
|
|
38
|
+
* @param {string} [props.helpLabel="More information"] Accessible name for that info tip.
|
|
39
|
+
* @param {import('react').Ref<HTMLElement>} [ref] The `<wui-rich-text>` element.
|
|
40
|
+
*/
|
|
41
|
+
declare const AppRichText: import("react").ForwardRefExoticComponent<import("react").RefAttributes<any>>;
|
|
42
|
+
export default AppRichText;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import "@webority/ui-elements";
|
|
2
|
+
/**
|
|
3
|
+
* A list whose items the person reorders: drag with a mouse or a finger (the list scrolls when
|
|
4
|
+
* the pointer nears its edge), or with the keyboard (focus an item's handle, Space to lift,
|
|
5
|
+
* arrow keys to move, Space to drop, Escape to cancel). Every move is announced to screen readers.
|
|
6
|
+
* Thin wrapper over the shared `<wui-sortable>` element; the list is controlled, so `items`
|
|
7
|
+
* is the truth and `onReorder` reports the new order.
|
|
8
|
+
*
|
|
9
|
+
* Lists that share a `group` accept each other's items by pointer drag. Each list then reports
|
|
10
|
+
* its own new order, so the parent moves the item from one `items` array to the other.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} props
|
|
13
|
+
* @param {{ id: string, label: string, content?: import('react').ReactNode, disabled?: boolean }[]} props.items
|
|
14
|
+
* `id` is what `onReorder` reports. `label` names the item to assistive tech (handle label and
|
|
15
|
+
* announcements) and is the visible text unless `content` is given. A `disabled` item cannot
|
|
16
|
+
* be picked up; other items can still move past it.
|
|
17
|
+
* @param {(ids: string[], detail: object) => void} [props.onReorder] Called with this list's new
|
|
18
|
+
* id order after a drop. `detail` is the element's event detail: `{ id, fromIndex, toIndex, from, to }`.
|
|
19
|
+
* @param {string} props.ariaLabel Names the list for assistive tech; also used in announcements
|
|
20
|
+
* when an item moves between lists.
|
|
21
|
+
* @param {boolean} [props.handle=false] Drag only from the handle. Without it an item can also be
|
|
22
|
+
* dragged from its body (links, buttons and inputs inside it keep working).
|
|
23
|
+
* @param {string} [props.group] Name shared by lists that accept each other's items.
|
|
24
|
+
* @param {string} [props.name] Form field name; posts the order as one hidden input per item.
|
|
25
|
+
* @param {boolean} [props.disabled] No item can be picked up.
|
|
26
|
+
* @param {'vertical'|'horizontal'} [props.orientation='vertical'] Direction the items run;
|
|
27
|
+
* horizontal also covers a wrapping row.
|
|
28
|
+
* @param {string} [props.className]
|
|
29
|
+
* @param {import('react').Ref<HTMLElement>} [ref]
|
|
30
|
+
*/
|
|
31
|
+
declare const AppSortableList: import("react").ForwardRefExoticComponent<import("react").RefAttributes<any>>;
|
|
32
|
+
export default AppSortableList;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small inline trend line: no axes, no tooltip, no chart engine. Drawn as plain SVG, so a
|
|
3
|
+
* table cell or a tile can hold one without loading anything. It is a picture of a trend, so it
|
|
4
|
+
* carries a text alternative that says where the line starts and ends. Pass your own `aria-label` to replace it,
|
|
5
|
+
* or `aria-hidden="true"` when the figure sits beside the trend in text.
|
|
6
|
+
*
|
|
7
|
+
* ```jsx
|
|
8
|
+
* <AppSparkline data={[12, 15, 14, 19]} label="Signups" />
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param {object} props
|
|
12
|
+
* @param {number[]} props.data The values, in order. A value that is not a finite number (null, NaN, a string) is left out, and a series with none left draws nothing.
|
|
13
|
+
* @param {string} [props.label] What the trend measures; it starts the text alternative ("Signups trend from 12 to 19 across 4 points.").
|
|
14
|
+
* @param {number} [props.width=48] Width in px.
|
|
15
|
+
* @param {number} [props.height=16] Height in px.
|
|
16
|
+
* @param {string} [props.className] Extra classes on the svg.
|
|
17
|
+
*/
|
|
18
|
+
export default function AppSparkline({ data, label, width, height, className, ...rest }: {
|
|
19
|
+
data: number[];
|
|
20
|
+
label?: string;
|
|
21
|
+
width?: number;
|
|
22
|
+
height?: number;
|
|
23
|
+
className?: string;
|
|
24
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import "@webority/ui-elements";
|
|
2
|
+
/**
|
|
3
|
+
* Thin React wrapper over the shared `<wui-tree>` element: a hierarchy in the WAI-ARIA tree
|
|
4
|
+
* pattern (arrow keys, Home/End, typeahead, Enter), with icons and badges, lazy children and an
|
|
5
|
+
* optional single or checkbox selection. The Razor `<app-tree-view>` renders the same element.
|
|
6
|
+
*
|
|
7
|
+
* `nodes` is `{ id, label, icon?, badge?, badgeTone?, children?, hasChildren?, expanded?,
|
|
8
|
+
* checked?, disabled? }[]`. `icon` is a library icon name and `badgeTone` an AppBadge tone. Ids are
|
|
9
|
+
* strings, unique across the whole tree. `children: []` is a leaf; `hasChildren: true` with no
|
|
10
|
+
* `children` is a node whose children are fetched the first time it opens, through `loadChildren`
|
|
11
|
+
* (or `loadUrl`). Labels are plain text. The tree keeps what the user opened and what it
|
|
12
|
+
* fetched when `nodes` is replaced with the same ids.
|
|
13
|
+
*
|
|
14
|
+
* Selection: `single` marks one row selected; `multiple` shows a tri-state checkbox per node (a
|
|
15
|
+
* parent is checked, unchecked or mixed from its children, and checking it checks every loaded
|
|
16
|
+
* child). `checked` is controlled by the ids it lists, parents included.
|
|
17
|
+
*
|
|
18
|
+
* @param {object} props
|
|
19
|
+
* @param {{ id: string, label: string, icon?: string, badge?: string,
|
|
20
|
+
* badgeTone?: 'neutral'|'primary'|'success'|'warning'|'danger'|'info', children?: object[],
|
|
21
|
+
* hasChildren?: boolean, expanded?: boolean, checked?: boolean, disabled?: boolean }[]} props.nodes
|
|
22
|
+
* @param {'none'|'single'|'multiple'} [props.selection='none']
|
|
23
|
+
* @param {string|null} [props.selected] Selected id (single mode, controlled: the tree shows this id
|
|
24
|
+
* whatever the user clicks until you change it; `null` selects nothing, and dropping the prop clears it).
|
|
25
|
+
* @param {(id: string, node: object) => void} [props.onSelect] A row was activated: clicked, or
|
|
26
|
+
* Enter / Space on it. `node` is the object you passed in.
|
|
27
|
+
* @param {string[]} [props.checked] Checked ids (multiple mode, controlled).
|
|
28
|
+
* @param {(ids: string[], detail: { id: string, checked: boolean }) => void} [props.onCheck] A
|
|
29
|
+
* check was toggled; `ids` is every checked id.
|
|
30
|
+
* @param {(node: object) => Promise<object[]>} [props.loadChildren] Fetches a lazy node's children.
|
|
31
|
+
* @param {string} [props.loadUrl] Children endpoint used when `loadChildren` is not set: a GET with
|
|
32
|
+
* `parentId=<id>` added, answering a JSON array of nodes.
|
|
33
|
+
* @param {(id: string, message: string) => void} [props.onLoadError] Children could not be loaded.
|
|
34
|
+
* @param {string} [props.name] Form field name: `multiple` posts one value per checked id, `single`
|
|
35
|
+
* the selected id.
|
|
36
|
+
* @param {string} [props.loadingText='Loading'] Announced while children load.
|
|
37
|
+
* @param {string} [props.errorText='Could not load. Try again.'] Announced when they fail.
|
|
38
|
+
* @param {string} [props.ariaLabel] Accessible name of the tree.
|
|
39
|
+
* @param {string} [props.id]
|
|
40
|
+
* @param {string} [props.className]
|
|
41
|
+
* @param {import('react').Ref<HTMLElement>} [ref]
|
|
42
|
+
*/
|
|
43
|
+
declare const AppTreeView: import("react").ForwardRefExoticComponent<import("react").RefAttributes<any>>;
|
|
44
|
+
export default AppTreeView;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { postedMasked } from "@webority/ui-elements";
|
|
1
2
|
export { default as AppAccordion } from "./components/AppAccordion.jsx";
|
|
2
3
|
export { default as AppActionIcon } from "./components/AppActionIcon.jsx";
|
|
3
4
|
export { default as AppAlert } from "./components/AppAlert.jsx";
|
|
@@ -7,9 +8,13 @@ export { default as AppAvatar } from "./components/AppAvatar.jsx";
|
|
|
7
8
|
export { default as AppAvatarGroup } from "./components/AppAvatarGroup.jsx";
|
|
8
9
|
export { default as AppBadge } from "./components/AppBadge.jsx";
|
|
9
10
|
export { default as AppBanner } from "./components/AppBanner.jsx";
|
|
11
|
+
export { default as AppBarChart } from "./components/AppBarChart.jsx";
|
|
10
12
|
export { default as AppBreadcrumbs } from "./components/AppBreadcrumbs.jsx";
|
|
11
13
|
export { default as AppButton } from "./components/AppButton.jsx";
|
|
14
|
+
export { default as AppCalendar } from "./components/AppCalendar.jsx";
|
|
12
15
|
export { default as AppCard } from "./components/AppCard.jsx";
|
|
16
|
+
export { default as AppChart } from "./components/AppChart.jsx";
|
|
17
|
+
export { default as AppChartCard } from "./components/AppChartCard.jsx";
|
|
13
18
|
export { default as AppCheckbox } from "./components/AppCheckbox.jsx";
|
|
14
19
|
export { default as AppChip } from "./components/AppChip.jsx";
|
|
15
20
|
export { default as AppChoiceCard } from "./components/AppChoiceCard.jsx";
|
|
@@ -20,8 +25,11 @@ export { default as AppCommandPalette } from "./components/AppCommandPalette.jsx
|
|
|
20
25
|
export { default as AppCompareTable } from "./components/AppCompareTable.jsx";
|
|
21
26
|
export { default as AppConfirmDialog } from "./components/AppConfirmDialog.jsx";
|
|
22
27
|
export { default as AppConsentBanner } from "./components/AppConsentBanner.jsx";
|
|
28
|
+
export { default as AppContextMenu } from "./components/AppContextMenu.jsx";
|
|
23
29
|
export { default as AppCopyButton } from "./components/AppCopyButton.jsx";
|
|
24
30
|
export { default as AppCountrySelect } from "./components/AppCountrySelect.jsx";
|
|
31
|
+
export { default as AppDashboardCell } from "./components/AppDashboardCell.jsx";
|
|
32
|
+
export { default as AppDashboardGrid } from "./components/AppDashboardGrid.jsx";
|
|
25
33
|
export { default as AppDataTable } from "./components/AppDataTable.jsx";
|
|
26
34
|
export { default as AppDatePicker } from "./components/AppDatePicker.jsx";
|
|
27
35
|
export { default as AppDateRangePicker } from "./components/AppDateRangePicker.jsx";
|
|
@@ -42,6 +50,7 @@ export { default as AppInfoList } from "./components/AppInfoList.jsx";
|
|
|
42
50
|
export { default as AppInfoTip } from "./components/AppInfoTip.jsx";
|
|
43
51
|
export { default as AppInput } from "./components/AppInput.jsx";
|
|
44
52
|
export { default as AppKpiTile } from "./components/AppKpiTile.jsx";
|
|
53
|
+
export { default as AppLineChart } from "./components/AppLineChart.jsx";
|
|
45
54
|
export { default as AppLink } from "./components/AppLink.jsx";
|
|
46
55
|
export { default as AppLogoPicker } from "./components/AppLogoPicker.jsx";
|
|
47
56
|
export { default as AppMeter } from "./components/AppMeter.jsx";
|
|
@@ -62,6 +71,7 @@ export { default as AppRepeater } from "./components/AppRepeater.jsx";
|
|
|
62
71
|
export { default as AppRequiredMark } from "./components/AppRequiredMark.jsx";
|
|
63
72
|
export { default as AppResourceCard } from "./components/AppResourceCard.jsx";
|
|
64
73
|
export { default as AppResult } from "./components/AppResult.jsx";
|
|
74
|
+
export { default as AppRichText } from "./components/AppRichText.jsx";
|
|
65
75
|
export { default as AppScrollbar } from "./components/AppScrollbar.jsx";
|
|
66
76
|
export { default as AppSearch } from "./components/AppSearch.jsx";
|
|
67
77
|
export { default as AppSegmented } from "./components/AppSegmented.jsx";
|
|
@@ -71,6 +81,8 @@ export { default as AppShell } from "./components/AppShell.jsx";
|
|
|
71
81
|
export { default as AppSidebarMenu } from "./components/AppSidebarMenu.jsx";
|
|
72
82
|
export { AppSkeletonRows, default as AppSkeleton } from "./components/AppSkeleton.jsx";
|
|
73
83
|
export { default as AppSlider } from "./components/AppSlider.jsx";
|
|
84
|
+
export { default as AppSortableList } from "./components/AppSortableList.jsx";
|
|
85
|
+
export { default as AppSparkline } from "./components/AppSparkline.jsx";
|
|
74
86
|
export { default as AppSpinner } from "./components/AppSpinner.jsx";
|
|
75
87
|
export { default as AppSplash } from "./components/AppSplash.jsx";
|
|
76
88
|
export { default as AppStatusBadge } from "./components/AppStatusBadge.jsx";
|
|
@@ -88,6 +100,7 @@ export { default as AppTimePicker } from "./components/AppTimePicker.jsx";
|
|
|
88
100
|
export { default as AppToast } from "./components/AppToast.jsx";
|
|
89
101
|
export { default as AppToolbar } from "./components/AppToolbar.jsx";
|
|
90
102
|
export { default as AppTooltip } from "./components/AppTooltip.jsx";
|
|
103
|
+
export { default as AppTreeView } from "./components/AppTreeView.jsx";
|
|
91
104
|
export { default as AppWizard } from "./components/AppWizard.jsx";
|
|
92
105
|
export { default as AppWorkspaceSwitcher } from "./components/AppWorkspaceSwitcher.jsx";
|
|
93
106
|
export { MODAL_ICONS } from "./components/ModalIcons.jsx";
|