asma-ui-core 3.89.0 → 3.90.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.
Files changed (29) hide show
  1. package/Readme.md +56 -10
  2. package/dist/asma-ui-core.css +1 -1
  3. package/dist/components/utils/bottom-sheet/StyledBottomSheet.js +137 -0
  4. package/dist/components/utils/bottom-sheet/StyledBottomSheet.module.js +4 -0
  5. package/dist/components/utils/bottom-sheet/formatResultsLabel.js +4 -0
  6. package/dist/components/utils/bottom-sheet/useDragToDismiss.hook.js +40 -0
  7. package/dist/components/utils/popover/PopoverSheet.js +165 -0
  8. package/dist/datetime/components/date-picker/components/BaseDatePickerInput.js +1 -1
  9. package/dist/datetime/components/date-picker/components/DatePickerButton.js +5 -5
  10. package/dist/hooks/useBodyScrollLock.hook.js +13 -0
  11. package/dist/hooks/useDebouncedValue.hook.js +15 -0
  12. package/dist/hooks/useMediaQuery.hook.js +10 -9
  13. package/dist/index.js +184 -180
  14. package/dist/src/components/utils/bottom-sheet/StyledBottomSheet.d.ts +59 -0
  15. package/dist/src/components/utils/bottom-sheet/formatResultsLabel.d.ts +9 -0
  16. package/dist/src/components/utils/bottom-sheet/formatResultsLabel.test.d.ts +1 -0
  17. package/dist/src/components/utils/bottom-sheet/index.d.ts +2 -0
  18. package/dist/src/components/utils/bottom-sheet/story/BottomSheetCases.d.ts +1 -0
  19. package/dist/src/components/utils/bottom-sheet/story/BottomSheetDemo.d.ts +22 -0
  20. package/dist/src/components/utils/bottom-sheet/useDragToDismiss.hook.d.ts +22 -0
  21. package/dist/src/components/utils/popover/PopoverAnatomy.d.ts +1 -1
  22. package/dist/src/components/utils/popover/{StyledPopoverV2.d.ts → PopoverSheet.d.ts} +12 -2
  23. package/dist/src/components/utils/popover/index.d.ts +1 -1
  24. package/dist/src/hooks/useBodyScrollLock.hook.d.ts +7 -0
  25. package/dist/src/hooks/useDebouncedValue.hook.d.ts +2 -0
  26. package/dist/src/hooks/useMediaQuery.hook.d.ts +2 -0
  27. package/dist/src/index.d.ts +1 -0
  28. package/package.json +1 -1
  29. package/dist/components/utils/popover/StyledPopoverV2.js +0 -140
package/Readme.md CHANGED
@@ -240,14 +240,14 @@ the trigger itself is the combobox. Both are keyboard-operable and share one lis
240
240
 
241
241
  ### Popover
242
242
 
243
- `StyledPopoverV2` is the Design System popover (ASMA-8183): an anchored surface with an optional
243
+ `PopoverSheet` is the Design System popover (ASMA-8183): an anchored surface with an optional
244
244
  title, a close control and two optional footer rows. One implementation, two variants picked by
245
245
  **content** rather than by breakpoint.
246
246
 
247
247
  ```tsx
248
- import { StyledButton, StyledPopoverV2 } from 'asma-ui-core'
248
+ import { StyledButton, PopoverSheet } from 'asma-ui-core'
249
249
 
250
- <StyledPopoverV2
250
+ <PopoverSheet
251
251
  dataTest='case-filter'
252
252
  variant='action'
253
253
  title='Filtrer søknader'
@@ -268,7 +268,7 @@ import { StyledButton, StyledPopoverV2 } from 'asma-ui-core'
268
268
  }
269
269
  >
270
270
  <CaseFilterForm value={filters} onChange={setFilters} />
271
- </StyledPopoverV2>
271
+ </PopoverSheet>
272
272
  ```
273
273
 
274
274
  The two footer rows come straight from Figma. The **Reset filter** row is `space-between`:
@@ -291,13 +291,59 @@ trigger at an 8px offset.
291
291
 
292
292
  The consumer owns the trigger element (spread `triggerProps`, wire `ref` — `refLink` on
293
293
  `StyledButton`), the filter state, and the `aria-live` region that announces the new result count.
294
- Below 744px the surface takes `100vw - 32px` and an `info` popover is pinned below its trigger;
295
- `action` should become a Bottom Sheet there, which is ASMA-8184 and not available yet.
294
+ Below 744px an `info` popover takes `100vw - 32px` and is pinned below its trigger, while an
295
+ `action` popover renders as a **Bottom Sheet** with the same props (see below).
296
296
 
297
- `StyledPopover` (no `V2`) is a different thing and stays: the MUI-`Popover`-parity positioning
298
- primitive that `StyledMenu`, `StyledFilterMenu`, the date-picker calendar and four table components
299
- still build on. New code should reach for `StyledPopoverV2`; those consumers migrate across
300
- gradually.
297
+ ### Bottom sheet
298
+
299
+ `StyledBottomSheet` (ASMA-8184) is the mobile (0–743px) form of the Action popover. You rarely use
300
+ it directly — `PopoverSheet variant='action'` switches to it below 744px — but it is exported for
301
+ screens that only ever show a sheet.
302
+
303
+ ```tsx
304
+ <StyledBottomSheet
305
+ dataTest='row-actions'
306
+ open={open}
307
+ onClose={() => setOpen(false)}
308
+ title='Handlinger — søknad 4417'
309
+ >
310
+ {({ close }) => <RowActionButtons onDone={close} />}
311
+ </StyledBottomSheet>
312
+ ```
313
+
314
+ A modal sheet on a native `<dialog>`: dimmed scrim, page scroll locked and made `inert`, top corners
315
+ 28px, width up to 640px, height fitting the content up to 90vh with an internally scrolling body (a
316
+ full-screen dialog at `max-height: 480px`). Five equivalent dismiss routes — close button, *Vis
317
+ resultater*, scrim, `Esc`, dragging down past 30% — and none of them commits anything. Focus goes to
318
+ the sheet on open so the title is read first, and back to the trigger on close; the grabber is
319
+ decorative.
320
+
321
+ Pass **`resultCount`** (to the sheet or the popover) for the standard *Vis resultater (N)* control:
322
+ debounced ~500ms, `Ingen treff` at zero and still enabled, capped at `9999+`, and announced from a
323
+ live region inside the sheet — the list behind is inert, so its own live region cannot. The label
324
+ comes from the exported `formatResultsLabel`. Title the sheet after the object, not the action: a
325
+ sheet detaches from its trigger, so `Handlinger` alone does not say which row was opened.
326
+
327
+ `StyledPopover` is a different, older thing and stays permanently: the MUI-`Popover`-parity
328
+ positioning primitive that `StyledMenu`, the date-picker calendar, `CountryCodeSelect` and four table
329
+ components (`RowActionMenu`, `HeaderActionMenu`, `TableRowCountSelect`, `TablePagination`) build on.
330
+ New code should reach for `PopoverSheet` — but it is **not** a drop-in replacement for
331
+ `StyledPopover`, and most of those consumers should never move to it:
332
+
333
+ - `StyledMenu`, `RowActionMenu` and (through it) `ToolbarActionGroup` render `role="menu"` with roving
334
+ tabindex and arrow-key navigation — semantics `PopoverSheet` deliberately excludes.
335
+ - `TableRowCountSelect`, `TablePagination` and `CountryCodeSelect`'s desktop panel are `role="listbox"`
336
+ / combobox pickers, not Info or Action content.
337
+ - The date-picker calendar is a day grid with its own mobile `Drawer` fallback already, which would
338
+ collide with `PopoverSheet`'s built-in <744px sheet swap.
339
+
340
+ `StyledFilterMenu` is the one real migration candidate — its `popoverContent({isOpen, onClose})` +
341
+ `anchorNode` render-props are exactly the shape `PopoverSheet`'s Filter pattern
342
+ (`resetAction`/`viewResultsAction`/`resultCount`) was modeled on — but the render-prop shapes differ
343
+ enough (`{isOpen, onClose}` vs `{close}`, `anchorNode` vs `renderTrigger`) that it needs its own
344
+ rewrite, not an import swap; tracked as a follow-up, not done here. `HeaderActionMenu` (plain
345
+ buttons/checkboxes, no menu role) is a plausible second candidate for the same reason, with its
346
+ drag-and-drop reordering needing its own verification inside a focus trap.
301
347
 
302
348
  ### Icons
303
349