@estiva-app/ui 0.92.1 → 0.93.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/ui",
3
- "version": "0.92.1",
3
+ "version": "0.93.0",
4
4
  "description": "Estiva's design tokens (the contract) and a small set of primitives (a convenience) for every Estiva app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/registry.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "kind": "package",
5
5
  "repo": "estiva-ui",
6
6
  "package": "@estiva-app/ui",
7
- "packageVersion": "0.92.1",
7
+ "packageVersion": "0.93.0",
8
8
  "exports": 210,
9
9
  "typeExports": 213,
10
10
  "files": null
@@ -5890,7 +5890,7 @@
5890
5890
  },
5891
5891
  {
5892
5892
  "name": "action",
5893
- "takes": "SectionAction",
5893
+ "takes": "a handler",
5894
5894
  "required": false,
5895
5895
  "note": "One button beside the ⋮, shown with it: any 16px icon, its tooltip and its handler — a `SectionHeader` action's shape."
5896
5896
  },
package/src/NavItem.tsx CHANGED
@@ -69,7 +69,7 @@ export interface NavItemProps extends Omit<ComponentPropsWithoutRef<'a'>, 'href'
69
69
  /** The ⋮'s accessible name and tooltip. Default "More options for {label}". */
70
70
  menuLabel?: string
71
71
  /** One button beside the ⋮, shown with it: any 16px icon, its tooltip and its handler — a `SectionHeader` action's shape. With a menu too, it sits before the ⋮. */
72
- action?: SectionAction
72
+ action?: SectionAction & { onClick: () => void }
73
73
  /** Shown only while the row is pointed at or focused, left of the count: a neutral `Chip`, typically. */
74
74
  hint?: ReactNode
75
75
  /** A sentence about the item, in the package's tooltip while the label is pointed at; the row stays one line. Absent or blank, no tooltip. */
@@ -25,6 +25,8 @@ title the toggle — that is where a section folds.
25
25
 
26
26
  <Canvas of={SectionHeaderStories.PersistentActions} />
27
27
 
28
+ - An action with `menu` in place of `onClick` opens those items: a Sort or a
29
+ filter, where the choice is the action. The row stays lit while it is open.
28
30
  - `menu` gives the section a "More options" ⋮ after its actions, with what
29
31
  acts on the whole section — a folder's Rename, Archive. It is **NavItem**'s
30
32
  ⋮, revealed with the actions, and stays while its menu is open.
@@ -35,12 +35,18 @@ import { SectionLabel } from './SectionLabel'
35
35
  * old shape yet: the two hard-wired action slots (add, sort) became
36
36
  * `actions` — the caller brings the icon, the tooltip and the handler.
37
37
  */
38
- export interface SectionAction {
38
+ export type SectionAction = {
39
39
  /** 16px, stroke 1.5. */
40
40
  icon: ReactNode
41
41
  tooltip: string
42
- onClick: () => void
43
- }
42
+ } & (
43
+ | { onClick: () => void; menu?: undefined }
44
+ /**
45
+ * The button opens a menu of these items instead: a choice that is the
46
+ * action, a sort or a filter (Katerina, 30 October: Open work's Sort).
47
+ */
48
+ | { menu: ReactNode; onClick?: undefined }
49
+ )
44
50
 
45
51
  export interface SectionHeaderProps {
46
52
  title: string
@@ -225,11 +231,27 @@ export function SectionHeader({ title, chevron = false, icon, isExpanded = true,
225
231
  className="-mr-1 flex shrink-0 items-center"
226
232
  >
227
233
  <div className={cn('flex items-center gap-1', reveal)}>
228
- {actions?.map((action) => (
229
- <IconButton key={action.tooltip} tooltip={action.tooltip} aria-label={action.tooltip} onClick={action.onClick}>
230
- {action.icon}
231
- </IconButton>
232
- ))}
234
+ {actions?.map((action) =>
235
+ action.menu != null ? (
236
+ // `data-section-menu`, as the ⋮ has: the row stays lit while its menu is open.
237
+ <div key={action.tooltip} data-section-menu className="flex items-center">
238
+ <Menu
239
+ align="right"
240
+ trigger={
241
+ <IconButton tooltip={action.tooltip} aria-label={action.tooltip}>
242
+ {action.icon}
243
+ </IconButton>
244
+ }
245
+ >
246
+ {action.menu}
247
+ </Menu>
248
+ </div>
249
+ ) : (
250
+ <IconButton key={action.tooltip} tooltip={action.tooltip} aria-label={action.tooltip} onClick={action.onClick}>
251
+ {action.icon}
252
+ </IconButton>
253
+ ),
254
+ )}
233
255
  {menu != null && (
234
256
  <div data-section-menu className="flex items-center">
235
257
  <Menu
package/src/Toast.mdx CHANGED
@@ -57,6 +57,9 @@ showToast({ label: 'Link copied', type: 'success' })
57
57
  - **The action closes its own toast.** Pressing it runs `onAction`, if you
58
58
  gave one, then closes that toast and no other. A Dismiss is just
59
59
  `actionLabel: 'Dismiss'`.
60
+ - `onClose` is told once when the toast closes, however it closes. An Undo
61
+ that is a wait — the write held until the toast goes — writes there, so the
62
+ toast's own timer, which pauses while it is pointed at, is the only one.
60
63
  - `showToast` returns the toast's id. `dismissToast(id)` closes that toast;
61
64
  `dismissToast()` with no id closes **every** toast on screen.
62
65
  - A toast can be swiped away towards its corner — left or down.
package/src/Toast.tsx CHANGED
@@ -133,6 +133,12 @@ export interface ToastOptions {
133
133
  leadingIcon?: boolean
134
134
  /** Auto-dismiss after this many ms. Defaults to 5000. Pass 0 to disable. */
135
135
  durationMs?: number
136
+ /**
137
+ * Told once when the toast closes, however it closes: its own timer, its
138
+ * action, a swipe, Escape or `dismissToast`. For an action whose Undo is a
139
+ * wait — the write happens here, unless the Undo was pressed first.
140
+ */
141
+ onClose?: () => void
136
142
  }
137
143
 
138
144
  interface ToastValue {
@@ -163,11 +169,12 @@ export function ToastProvider({ children }: { children: ReactNode }) {
163
169
  const manager = useMemo(() => BaseToast.createToastManager<ToastData>(), [])
164
170
  const value = useMemo<ToastValue>(
165
171
  () => ({
166
- showToast: ({ label, type = 'neutral', leadingIcon = true, actionLabel, onAction, durationMs = 5000 }) =>
172
+ showToast: ({ label, type = 'neutral', leadingIcon = true, actionLabel, onAction, durationMs = 5000, onClose }) =>
167
173
  manager.add({
168
174
  title: label,
169
175
  type,
170
176
  timeout: durationMs,
177
+ onClose,
171
178
  // A failure interrupts; everything else waits for a pause.
172
179
  priority: type === 'error' ? 'high' : 'low',
173
180
  data: { leadingIcon, actionLabel, onAction },