fluent-svelte-extra 2.2.1 → 2.2.3

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.
@@ -28,6 +28,7 @@ let mousePosition = {
28
28
  x: 0,
29
29
  y: 0
30
30
  };
31
+ let justClosed = false;
31
32
  $: dispatch(open ? "open" : "close");
32
33
  $: if (menu && tabbable(menuElement).length > 0)
33
34
  tabbable(menuElement)[0].focus();
@@ -42,6 +43,8 @@ $: if (anchorElement) {
42
43
  menuPosition.y = 0;
43
44
  }
44
45
  async function handleContextMenu({ clientX, clientY }) {
46
+ if (justClosed)
47
+ return;
45
48
  open = true;
46
49
  mousePosition = {
47
50
  x: clientX,
@@ -58,6 +61,20 @@ function mountMenu(node) {
58
61
  destroy: () => node.remove()
59
62
  };
60
63
  }
64
+ function handleOuterMousedown() {
65
+ open = false;
66
+ justClosed = true;
67
+ const handleMouseUp = () => {
68
+ setTimeout(() => {
69
+ justClosed = false;
70
+ });
71
+ };
72
+ window.addEventListener("mouseup", handleMouseUp, { once: true, capture: true });
73
+ setTimeout(() => {
74
+ window.removeEventListener("mouseup", handleMouseUp, { capture: true });
75
+ justClosed = false;
76
+ }, 1000);
77
+ }
61
78
  if (closeOnSelect) {
62
79
  setContext("closeFlyout", () => {
63
80
  dispatch("select");
@@ -77,7 +94,6 @@ if (closeOnSelect) {
77
94
  on:click|preventDefault|stopPropagation={openBy.includes("leftClick")
78
95
  ? handleContextMenu
79
96
  : undefined}
80
- on:contextmenu={openBy.includes("rightClick") ? handleContextMenu : undefined}
81
97
  bind:this={wrapperElement}
82
98
  >
83
99
  <slot />
@@ -88,7 +104,7 @@ if (closeOnSelect) {
88
104
  use:externalMouseEvents={{ type: "mousedown" }}
89
105
  on:contextmenu|stopPropagation={e => e.preventDefault()}
90
106
  bind:this={anchorElement}
91
- on:outermousedown={() => (open = false)}
107
+ on:outermousedown={handleOuterMousedown}
92
108
  class="context-menu-anchor"
93
109
  style="top: {menuPosition.y}px; left: {menuPosition.x}px;"
94
110
  >
@@ -23,7 +23,7 @@ const highlight = tweened({
23
23
  left: 0
24
24
  }, {
25
25
  easing: expoOut,
26
- duration: 333
26
+ duration: getCSSDuration("--fds-control-slow-duration")
27
27
  });
28
28
  setKey(`${segmentId}-setValue`, target => {
29
29
  value = target;
@@ -42,10 +42,12 @@ $: {
42
42
  if (setSelected) {
43
43
  setSelected(value === buttonValue);
44
44
  if (value === buttonValue) {
45
- const { width, left } = button.getBoundingClientRect();
45
+ const htmlButton = button;
46
+ const width = htmlButton.offsetWidth;
47
+ const left = htmlButton.offsetLeft;
46
48
  highlight.set({
47
49
  width,
48
- left: left - containerElement.getBoundingClientRect().left - 1
50
+ left
49
51
  });
50
52
  isSelectedDisabled = button.classList.contains("disabled");
51
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluent-svelte-extra",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "A faithful implementation of Microsoft's Fluent Design System in Svelte.",
5
5
  "homepage": "https://github.com/OpenAnime/fluent-svelte-extra",
6
6
  "license": "MIT",