nish-ui 2.0.1 → 2.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.
Files changed (63) hide show
  1. package/README.md +18 -8
  2. package/dist/chart.js +1 -1
  3. package/dist/elements-all.js +13 -13
  4. package/dist/elements-charts.js +1 -1
  5. package/dist/elements-data.js +1 -1
  6. package/dist/elements-forms.js +1 -1
  7. package/dist/elements.js +3 -3
  8. package/dist/esm/components/app-shell.js +145 -45
  9. package/dist/esm/components/breadcrumbs.js +1 -1
  10. package/dist/esm/components/calendar-classes.js +325 -0
  11. package/dist/esm/components/calendar.js +263 -0
  12. package/dist/esm/components/canvas/route.js +56 -20
  13. package/dist/esm/components/carousel-classes.js +27 -0
  14. package/dist/esm/components/carousel.js +317 -0
  15. package/dist/esm/components/command.js +2 -27
  16. package/dist/esm/components/context-menu.js +199 -0
  17. package/dist/esm/components/date-picker.js +208 -0
  18. package/dist/esm/components/display-classes.js +10 -13
  19. package/dist/esm/components/display.js +22 -19
  20. package/dist/esm/components/drawer.js +139 -0
  21. package/dist/esm/components/filters.js +1 -1
  22. package/dist/esm/components/flow.js +1 -1
  23. package/dist/esm/components/hooks.js +17 -6
  24. package/dist/esm/components/hover-card.js +221 -0
  25. package/dist/esm/components/icons.js +17 -0
  26. package/dist/esm/components/inbox.js +2 -1
  27. package/dist/esm/components/lazy-module.js +53 -0
  28. package/dist/esm/components/menu.js +344 -0
  29. package/dist/esm/components/modal.js +173 -0
  30. package/dist/esm/components/more-sheet.js +52 -0
  31. package/dist/esm/components/multi-select.js +420 -0
  32. package/dist/esm/components/nav-items.js +138 -0
  33. package/dist/esm/components/nav.js +13 -174
  34. package/dist/esm/components/navigate.js +33 -0
  35. package/dist/esm/components/overlay-core.js +221 -0
  36. package/dist/esm/components/overlay-dialog.js +255 -0
  37. package/dist/esm/components/overlay-position.js +163 -0
  38. package/dist/esm/components/overlay.js +7 -1441
  39. package/dist/esm/components/popover.js +92 -0
  40. package/dist/esm/components/segmented.js +2 -1
  41. package/dist/esm/components/split.js +1 -1
  42. package/dist/esm/components/strings.js +25 -0
  43. package/dist/esm/components/tooltip.js +177 -0
  44. package/dist/esm/components/tree-view-classes.js +57 -0
  45. package/dist/esm/components/tree-view.js +319 -0
  46. package/dist/esm/components/virtual-table.js +245 -0
  47. package/dist/esm/components/virtual.js +291 -0
  48. package/dist/esm/inbox.js +12 -0
  49. package/dist/esm/index.js +61 -2
  50. package/dist/esm/runtime.js +1 -1
  51. package/dist/esm/service-tokens.js +6 -0
  52. package/dist/esm/theme.js +2 -2
  53. package/dist/esm/virtual-range.js +73 -0
  54. package/dist/format.js +1 -1
  55. package/dist/inbox.d.ts +238 -0
  56. package/dist/index.d.ts +1032 -778
  57. package/dist/nish-components.css +2 -0
  58. package/dist/nish-components.min.css +1 -1
  59. package/dist/service-tokens.d.ts +60 -0
  60. package/dist/theme.d.ts +50 -0
  61. package/dist/theme.global.js +28 -3
  62. package/dist/theme.js +28 -3
  63. package/package.json +17 -1
@@ -0,0 +1,238 @@
1
+ import * as react from 'react';
2
+ import { ComponentPropsWithoutRef, Ref } from 'react';
3
+
4
+ /** How loud an event is: `info` is listed only, `normal` is pushed, `urgent` is pushed even in quiet hours. */
5
+ type InboxSeverity = 'info' | 'normal' | 'urgent';
6
+ /** Which list the Inbox page shows. */
7
+ type InboxView = 'open' | 'snoozed' | 'handled';
8
+ /** Flat extra data attached to an event. */
9
+ type InboxData = Record<string, string | number | boolean | null>;
10
+ /** A button on an inbox item. Tapping it makes the inbox service POST an {@link InboxActionCall} to `target`,
11
+ * server to server, and records the outcome on the item. */
12
+ interface InboxAction {
13
+ /** Unique within the event, matching /^[a-z0-9][a-z0-9-]{0,31}$/, for example 'retry' or 'approve'. */
14
+ id: string;
15
+ /** Button text, trimmed, 1-40 characters. Longer text is cut to 39 plus an ellipsis. */
16
+ label: string;
17
+ /** Always 'POST'. May be left out when sending. */
18
+ method: 'POST';
19
+ /** Loopback only: `http://127.0.0.1:<port>/path`, with an explicit port, no credentials and no #hash. Up to 2000 characters. */
20
+ target: string;
21
+ }
22
+ /** The outcome of the last action run on an item. */
23
+ interface InboxActionResult {
24
+ /** Which action ran. */
25
+ actionId: string;
26
+ /** True when the target answered 2xx; the item is then handled by the user. */
27
+ ok: boolean;
28
+ /** The target's HTTP status, or null on a timeout or network error. */
29
+ status: number | null;
30
+ /** What went wrong, or null on success. */
31
+ error: string | null;
32
+ /** When it ran, ISO. */
33
+ at: string;
34
+ }
35
+ /** The JSON body the inbox service POSTs to an action's target, with the header `X-Inbox-Action: 1`.
36
+ * Answer 2xx within {@link INBOX_ACTION_TIMEOUT_MS} for success; anything else is recorded as a failure. */
37
+ interface InboxActionCall {
38
+ /** The inbox item's id. */
39
+ itemId: number;
40
+ /** Which action was tapped. */
41
+ actionId: string;
42
+ /** The item's source. */
43
+ source: string;
44
+ /** The item's kind. */
45
+ kind: string;
46
+ /** The item's dedupeKey, or null. */
47
+ dedupeKey: string | null;
48
+ /** The item's extra data, or null. */
49
+ data: InboxData | null;
50
+ }
51
+ /** Header the inbox service sends on every action call, with the value '1'. */
52
+ declare const INBOX_ACTION_HEADER = "X-Inbox-Action";
53
+ /** How long the inbox service waits for an action's target before recording a timeout. */
54
+ declare const INBOX_ACTION_TIMEOUT_MS = 8000;
55
+ /** What the service returns to the page. Times are ISO strings. */
56
+ interface InboxItem {
57
+ /** Row id. */
58
+ id: number;
59
+ /** Which app sent it. */
60
+ source: string;
61
+ /** What happened. */
62
+ kind: string;
63
+ /** Headline. */
64
+ title: string;
65
+ /** Details, or null. */
66
+ body: string | null;
67
+ /** Link, or null. */
68
+ url: string | null;
69
+ /** Current severity (the highest seen while open). */
70
+ severity: InboxSeverity;
71
+ /** How many events merged into this item. */
72
+ count: number;
73
+ /** When the item was first created. */
74
+ createdAt: string;
75
+ /** When the item last changed. */
76
+ updatedAt: string;
77
+ /** When the latest event happened. */
78
+ occurredAt: string;
79
+ /** When the item was handled, or null while open. */
80
+ handledAt: string | null;
81
+ /** Who handled it, or null while open. */
82
+ handledBy: 'user' | 'source' | 'expired' | null;
83
+ /** When a snoozed item comes back, or null. */
84
+ snoozedUntil: string | null;
85
+ /** Extra data, or null. */
86
+ data: InboxData | null;
87
+ /** Buttons from the latest event. The service always sends this ([] when none); optional for older services. */
88
+ actions?: InboxAction[];
89
+ /** The last action run on this item, or null. */
90
+ lastAction?: InboxActionResult | null;
91
+ }
92
+ /** Inbox settings, editable on the page. */
93
+ interface InboxSettings {
94
+ /** IANA time zone used for quiet hours and the digest. */
95
+ timezone: string;
96
+ /** Normal pushes are held between start and end; urgent ones still go. Times are 'HH:MM' 24h. */
97
+ quietHours: {
98
+ enabled: boolean;
99
+ start: string;
100
+ end: string;
101
+ };
102
+ /** One summary push a day at `time` ('HH:MM' 24h). */
103
+ digest: {
104
+ enabled: boolean;
105
+ time: string;
106
+ };
107
+ /** Sources that never push. */
108
+ mutedSources: string[];
109
+ }
110
+ /** Settings used until they are changed on the Inbox page. */
111
+ declare const INBOX_DEFAULT_SETTINGS: InboxSettings;
112
+ /** Display names for known sources; unknown ids show as-is. */
113
+ declare const INBOX_SOURCE_LABELS: Record<string, string>;
114
+ /** One page of the item list plus counts for the tabs and source filter. */
115
+ interface InboxListResponse {
116
+ /** Items in the requested view, newest first. */
117
+ items: InboxItem[];
118
+ /** Pass back to fetch the next page, or null at the end. */
119
+ nextCursor: string | null;
120
+ /** Item counts per view, and open items that are urgent. */
121
+ counts: {
122
+ open: number;
123
+ snoozed: number;
124
+ handled: number;
125
+ urgent: number;
126
+ };
127
+ /** Every source with any item in the last 30 days, with its open count for the current view filter. */
128
+ sources: Array<{
129
+ id: string;
130
+ open: number;
131
+ }>;
132
+ }
133
+
134
+ /** Text the Inbox shows that has no key in `NishStrings`. Give any of them to `Inbox` as `labels`;
135
+ * each one wins over its English default. */
136
+ interface InboxLabels {
137
+ /** Names of the severity dots. */
138
+ urgent: string;
139
+ normal: string;
140
+ info: string;
141
+ /** Snooze menu entries. */
142
+ snooze1h: string;
143
+ snooze4h: string;
144
+ snoozeTomorrow: string;
145
+ snoozeMonday: string;
146
+ /** Button of a snoozed item. */
147
+ unsnooze: string;
148
+ /** Button of a handled item. */
149
+ moveBack: string;
150
+ /** "Mark all handled" button, and the confirm dialog's title. */
151
+ markAllHandled: string;
152
+ markAllTitle: (count: number) => string;
153
+ /** The "All" chip of the source filter. */
154
+ all: string;
155
+ loadMore: string;
156
+ /** Collapses a long body. The expand button is the `more` string. */
157
+ less: string;
158
+ /** "Until 14:00" under a snoozed item. */
159
+ until: (when: string) => string;
160
+ /** "Handled 2 hours ago" under a handled item, then optionally the suffix for who handled it. */
161
+ handledAgo: (when: string) => string;
162
+ handledByApp: string;
163
+ handledAutomatically: string;
164
+ /** "Retry ran 14:02" and "Retry failed 14:02 · HTTP 500". `why` is null when nothing is known. */
165
+ actionRan: (label: string, at: string) => string;
166
+ actionFailed: (label: string, at: string, why: string | null) => string;
167
+ /** The empty list of each view; `source` is the name of the filtered source, or null. */
168
+ emptyOpen: (source: string | null) => string;
169
+ emptySnoozed: (source: string | null) => string;
170
+ emptyHandled: (source: string | null) => string;
171
+ }
172
+ declare const DEFAULT_INBOX_LABELS: InboxLabels;
173
+
174
+ interface InboxProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'onChange'> {
175
+ ref?: Ref<HTMLElement>;
176
+ /** The items of the current view, newest activity first. */
177
+ items: InboxItem[];
178
+ /** Which list is showing: open, snoozed or handled. */
179
+ view: InboxView;
180
+ /** Called when a tab is picked. */
181
+ onViewChange: (view: InboxView) => void;
182
+ /** Totals for the tabs. Open and snoozed show as counts on their tabs. */
183
+ counts: {
184
+ open: number;
185
+ snoozed: number;
186
+ handled: number;
187
+ };
188
+ /** Sources for the filter chips, each with its open count. The filter row is hidden with one source or fewer. */
189
+ sources: Array<{
190
+ id: string;
191
+ open: number;
192
+ }>;
193
+ /** The source the list is filtered to, or null for all. */
194
+ source: string | null;
195
+ /** Called when a source chip is picked; null means "All". */
196
+ onSourceChange: (source: string | null) => void;
197
+ /** Marks an item handled. */
198
+ onHandle: (id: number) => void;
199
+ /** Moves a handled item back to open. */
200
+ onUnhandle: (id: number) => void;
201
+ /** Snoozes an item until the given time. */
202
+ onSnooze: (id: number, until: Date) => void;
203
+ /** Brings a snoozed item back now. */
204
+ onUnsnooze: (id: number) => void;
205
+ /** Runs one of an item's actions (the inbox service's POST /api/items/:id/actions/:actionId). When given,
206
+ * each item's actions show as buttons in the open and snoozed views. While the promise is pending that
207
+ * button shows a spinner and the item's other actions are disabled. A rejection is ignored here; toast it. */
208
+ onAction?: (itemId: number, actionId: string) => Promise<void>;
209
+ /** Shows "Mark all handled" in the open view when given and there are items. A confirmation comes first. */
210
+ onHandleAll?: () => void;
211
+ /** First load: shows skeleton rows in place of the list. */
212
+ loading?: boolean;
213
+ /** A failed load: shows an ErrorState with this text as the body. */
214
+ error?: string | null;
215
+ /** Shows a Retry button on the error state. */
216
+ onRetry?: () => void;
217
+ /** More items exist after the last one: shows "Load more". */
218
+ hasMore?: boolean;
219
+ /** Called by "Load more". */
220
+ onLoadMore?: () => void;
221
+ /** "Load more" shows a spinner and is disabled while the next page loads. */
222
+ loadingMore?: boolean;
223
+ /** The item to highlight and scroll into view once (a link from a notification). */
224
+ selectedId?: number | null;
225
+ /** Display names per source id. Default INBOX_SOURCE_LABELS; unknown ids show as they are. */
226
+ sourceLabels?: Record<string, string>;
227
+ /** Text that has no key in the provider's strings (snooze options, messages). Each wins over its English default. */
228
+ labels?: Partial<InboxLabels>;
229
+ /** Classes for the card. */
230
+ className?: string;
231
+ }
232
+ /** One inbox for events from every app: Open, Snoozed and Handled views, a source filter, and per-item
233
+ * handle, snooze and undo actions. The page owns the data and the calls; this component only renders
234
+ * and reports what was picked. Rows wrap at phone widths and the actions collapse into one menu under 480px. */
235
+ declare function Inbox({ items, view, onViewChange, counts, sources, source, onSourceChange, onHandle, onUnhandle, onSnooze, onUnsnooze, onHandleAll, onAction, loading, error, onRetry, hasMore, onLoadMore, loadingMore, selectedId, sourceLabels, labels: labelOverrides, className, ref, ...rest }: InboxProps): react.JSX.Element;
236
+
237
+ export { DEFAULT_INBOX_LABELS, INBOX_ACTION_HEADER, INBOX_ACTION_TIMEOUT_MS, INBOX_DEFAULT_SETTINGS, INBOX_SOURCE_LABELS, Inbox };
238
+ export type { InboxAction, InboxActionCall, InboxActionResult, InboxItem, InboxLabels, InboxListResponse, InboxProps, InboxSettings, InboxSeverity, InboxView };