@widgetic/design-system 0.5.26 → 0.5.28

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 (41) hide show
  1. package/dist/components/CopyableHeader.svelte +29 -10
  2. package/dist/components/CopyableHeader.svelte.d.ts +3 -0
  3. package/dist/components/EmptyState.svelte +13 -3
  4. package/dist/components/modals/BaseModal.svelte +133 -11
  5. package/dist/components/modals/BaseModal.svelte.d.ts +1 -0
  6. package/dist/components/modals/NewItemDialog.svelte +2 -0
  7. package/dist/components/shad-editor/custom/Extentions/SearchAndReplace.js +0 -1
  8. package/dist/components/shad-editor/custom/utils.d.ts +1 -1
  9. package/dist/components/shad-editor/custom/utils.js +0 -1
  10. package/dist/components/shell/NavRow.svelte +5 -4
  11. package/dist/components/shell/NavRow.svelte.d.ts +3 -3
  12. package/dist/components/ui/accordion/accordion-content.svelte +5 -1
  13. package/dist/components/ui/accordion/accordion-item.svelte +2 -1
  14. package/dist/components/ui/accordion/accordion-trigger.svelte +38 -0
  15. package/dist/components/ui/button/button.svelte +1 -1
  16. package/dist/components/ui/button/button.svelte.d.ts +3 -3
  17. package/dist/components/ui/calendar/calendar.svelte.d.ts +1 -1
  18. package/dist/components/ui/checkbox/checkbox.svelte +1 -1
  19. package/dist/components/ui/dialog/dialog-overlay.svelte +8 -1
  20. package/dist/components/ui/icon-button/icon-button.svelte +1 -1
  21. package/dist/components/ui/icon-button/icon-button.svelte.d.ts +2 -2
  22. package/dist/components/ui/input-otp/input-otp-slot.svelte.d.ts +1 -1
  23. package/dist/components/ui/radio-group/radio-group-item.svelte +1 -1
  24. package/dist/components/ui/range-calendar/range-calendar.svelte.d.ts +1 -1
  25. package/dist/components/ui/select/select-content.svelte +2 -2
  26. package/dist/components/ui/select/select-scroll-down-button.svelte +1 -1
  27. package/dist/components/ui/select/select-scroll-up-button.svelte +1 -1
  28. package/dist/components/ui/select/select-trigger.svelte +1 -1
  29. package/dist/components/ui/stepper-button/stepper-button.svelte +1 -1
  30. package/dist/components/ui/tooltip/tooltip-content.svelte +1 -1
  31. package/dist/components/widget-system/Moveable.svelte +24 -21
  32. package/dist/styles/tokens.css +60 -1
  33. package/dist/utils/isEditableEventTarget.d.ts +5 -0
  34. package/dist/utils/isEditableEventTarget.js +25 -0
  35. package/dist/utils/modalFocusTrap.d.ts +28 -0
  36. package/dist/utils/modalFocusTrap.js +135 -0
  37. package/dist/utils/overlayMotion.d.ts +6 -0
  38. package/dist/utils/overlayMotion.js +7 -0
  39. package/dist/utils/overlayStacking.d.ts +47 -0
  40. package/dist/utils/overlayStacking.js +63 -0
  41. package/package.json +1 -1
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Stacked overlays blur the page once.
3
+ *
4
+ * Every dialog and modal draws a scrim: the muted foreground at 80% with a 3px backdrop blur (`overlayScrimClasses`). A
5
+ * dialog opened over another one (the settings dialog, then "Edit domain" on top of it) draws a second scrim over the
6
+ * first. Blurring a page that is already blurred adds nothing the eye can see, but the second scrim fades in, and a
7
+ * backdrop blur that fades is redrawn on every frame of the fade, over the first scrim's redrawn blur: two of them
8
+ * stacked are what made the background flicker when a second dialog opened.
9
+ *
10
+ * So a scrim drawn over another one only dims: it carries `data-stacked`, and the surface that draws it takes the blur
11
+ * off (the dialog overlay with `overlayStackedScrimClass`, the base modal with a rule of its own). The first scrim keeps
12
+ * the blur, so the page is blurred once, however many layers are above it.
13
+ *
14
+ * The mark is part of the scrim as it is created (`data-stacked={stackedScrimMark()}` in the template), not added a
15
+ * moment later: a scrim created with the blur and stripped of it after would first resolve its style with the blur, and
16
+ * the dialog overlay, which transitions every property over 200ms, would then animate the blur away.
17
+ *
18
+ * The decision is made from the page, not from the component tree: bits-ui knows a dialog is nested only when it is
19
+ * rendered inside the other dialog, and a dialog can be mounted somewhere else (the plan chooser, over the settings
20
+ * dialog) and still be drawn above it.
21
+ */
22
+ /** What marks a scrim that is drawn over another scrim. */
23
+ export const stackedScrimAttribute = 'data-stacked';
24
+ /** The scrims that blur the page: the backdrop of a dialog (bits-ui) and the backdrop of a base modal. */
25
+ export const blurringScrimSelector = '[data-widgetic-overlay="dialog-backdrop"], [data-widgetic-overlay="base-modal-backdrop"]';
26
+ /**
27
+ * Whether a scrim that still blurs the page is drawn.
28
+ *
29
+ * A scrim that is closing (`data-state="closed"`: the fade out of a dialog that was just closed) does not count. When
30
+ * a dialog closes and another opens in the same moment, the new one is the first, and keeps the blur the old one
31
+ * takes away with it.
32
+ *
33
+ * @param root - Where to look; the page by default.
34
+ * @returns "A scrim is drawn": `true` when the scrim about to be created has to dim only.
35
+ */
36
+ export function isAnotherScrimDrawn(root = document) {
37
+ for (const drawnScrim of root.querySelectorAll(blurringScrimSelector)) {
38
+ if (drawnScrim.getAttribute('data-state') === 'closed')
39
+ continue;
40
+ return true;
41
+ }
42
+ return false;
43
+ }
44
+ /**
45
+ * The value of `data-stacked` for a scrim that is being created: an empty string (the attribute is set) when another
46
+ * scrim is drawn, `undefined` (no attribute) when this one is the first. Called from the template, so it runs once, as
47
+ * the scrim is created, before its first frame.
48
+ *
49
+ * @param root - Where to look; the page by default.
50
+ */
51
+ export function stackedScrimMark(root) {
52
+ try {
53
+ // On the server there is no page, and no dialog is open.
54
+ if (root === undefined && typeof document === 'undefined')
55
+ return undefined;
56
+ return isAnotherScrimDrawn(root ?? document) ? '' : undefined;
57
+ }
58
+ catch (error) {
59
+ // The scrim keeps its blur: a double blur is only a flicker, not a broken dialog.
60
+ console.warn('[overlayStacking] Could not tell whether another scrim is drawn', error);
61
+ return undefined;
62
+ }
63
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/design-system",
3
- "version": "0.5.26",
3
+ "version": "0.5.28",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "svelte": "./dist/index.js",