@flux-ui/components 3.0.0-next.13 → 3.0.0-next.15

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.
@@ -1,4 +1,4 @@
1
- import { Component, RenderFunction, Slots, SetupContext } from 'vue';
1
+ import { Component, RenderFunction, SetupContext, Slots } from 'vue';
2
2
  type Emit = SetupContext<['close']>['emit'];
3
3
  type Props = {
4
4
  readonly isCloseable?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"createDialogRenderer.d.ts","sourceRoot":"","sources":["../../src/util/createDialogRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAsB,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAC3E,OAAO,EAAsC,YAAY,EAAmB,MAAM,KAAK,CAAC;AAGxF,KAAK,IAAI,GAAG,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5C,KAAK,KAAK,GAAG;IACT,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,GAAG,cAAc,CAqDxI"}
1
+ {"version":3,"file":"createDialogRenderer.d.ts","sourceRoot":"","sources":["../../src/util/createDialogRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,EAAS,MAAM,KAAK,CAAC;AAKjF,KAAK,IAAI,GAAG,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5C,KAAK,KAAK,GAAG;IACT,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAIF,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,GAAG,cAAc,CAiExI"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flux-ui/components",
3
3
  "description": "A set of opiniated UI components.",
4
- "version": "3.0.0-next.13",
4
+ "version": "3.0.0-next.15",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/basmilius",
@@ -52,8 +52,8 @@
52
52
  "sideEffects": false,
53
53
  "dependencies": {
54
54
  "@basmilius/utils": "^2.5.2",
55
- "@flux-ui/internals": "3.0.0-next.13",
56
- "@flux-ui/types": "3.0.0-next.13",
55
+ "@flux-ui/internals": "3.0.0-next.15",
56
+ "@flux-ui/types": "3.0.0-next.15",
57
57
  "@fortawesome/fontawesome-common-types": "^7.0.0",
58
58
  "clsx": "^2.1.1",
59
59
  "imask": "^7.6.1",
@@ -0,0 +1,39 @@
1
+ <template>
2
+ <div :class="$style.overlayProvider">
3
+ <div :class="$style.overlayShade"/>
4
+ </div>
5
+
6
+ <FluxOverlay size="medium">
7
+ <FluxAlert
8
+ v-for="alert of alerts"
9
+ :key="alert.id"
10
+ :alert="alert"/>
11
+ </FluxOverlay>
12
+
13
+ <FluxOverlay size="medium">
14
+ <FluxConfirm
15
+ v-for="confirm of confirms"
16
+ :key="confirm.id"
17
+ :confirm="confirm"/>
18
+ </FluxOverlay>
19
+
20
+ <FluxOverlay size="medium">
21
+ <FluxPrompt
22
+ v-for="prompt of prompts"
23
+ :key="prompt.id"
24
+ :prompt="prompt"/>
25
+ </FluxOverlay>
26
+ </template>
27
+
28
+ <script
29
+ lang="ts"
30
+ setup>
31
+ import { useFluxStore } from '$flux/data';
32
+ import FluxAlert from './FluxAlert.vue';
33
+ import FluxConfirm from './FluxConfirm.vue';
34
+ import FluxOverlay from './FluxOverlay.vue';
35
+ import FluxPrompt from './FluxPrompt.vue';
36
+ import $style from '$flux/css/component/Overlay.module.scss';
37
+
38
+ const {alerts, confirms, prompts} = useFluxStore();
39
+ </script>
@@ -6,27 +6,7 @@
6
6
  <slot/>
7
7
  </div>
8
8
 
9
- <FluxOverlay size="medium">
10
- <FluxAlert
11
- v-for="alert of alerts"
12
- :key="alert.id"
13
- :alert="alert"/>
14
- </FluxOverlay>
15
-
16
- <FluxOverlay size="medium">
17
- <FluxConfirm
18
- v-for="confirm of confirms"
19
- :key="confirm.id"
20
- :confirm="confirm"/>
21
- </FluxOverlay>
22
-
23
- <FluxOverlay size="medium">
24
- <FluxPrompt
25
- v-for="prompt of prompts"
26
- :key="prompt.id"
27
- :prompt="prompt"/>
28
- </FluxOverlay>
29
-
9
+ <FluxOverlayProvider/>
30
10
  <FluxSnackbarProvider/>
31
11
  <FluxTooltipProvider/>
32
12
  </template>
@@ -36,10 +16,7 @@
36
16
  setup>
37
17
  import { watch } from 'vue';
38
18
  import { useFluxStore } from '$flux/data';
39
- import FluxAlert from './FluxAlert.vue';
40
- import FluxConfirm from './FluxConfirm.vue';
41
- import FluxPrompt from './FluxPrompt.vue';
42
- import FluxOverlay from './FluxOverlay.vue';
19
+ import FluxOverlayProvider from './FluxOverlayProvider.vue';
43
20
  import FluxSnackbarProvider from './FluxSnackbarProvider.vue';
44
21
  import FluxTooltipProvider from './FluxTooltipProvider.vue';
45
22
  import $style from '$flux/css/component/Root.module.scss';
@@ -52,7 +29,7 @@
52
29
  default(): any;
53
30
  }>();
54
31
 
55
- const {alerts, confirms, inertMain, prompts} = useFluxStore();
32
+ const {inertMain} = useFluxStore();
56
33
 
57
34
  watch(inertMain, (inert, _, onCleanup): void => {
58
35
  if (!inert) {
@@ -84,6 +84,7 @@ export { default as FluxMenuTitle } from './FluxMenuTitle.vue';
84
84
  export { default as FluxNotice } from './FluxNotice.vue';
85
85
  export { default as FluxNoticeStack } from './FluxNoticeStack.vue';
86
86
  export { default as FluxOverlay } from './FluxOverlay.vue';
87
+ export { default as FluxOverlayProvider } from './FluxOverlayProvider.vue';
87
88
  export { default as FluxPagination } from './FluxPagination.vue';
88
89
  export { default as FluxPaginationBar } from './FluxPaginationBar.vue';
89
90
  export { default as FluxPane } from './FluxPane.vue';
package/src/css/base.scss CHANGED
@@ -12,6 +12,7 @@
12
12
  }
13
13
 
14
14
  [dark] {
15
+ @include variables.defaults-dark;
15
16
  @include variables.color-dark;
16
17
  @include variables.shadow-dark;
17
18
  }
@@ -459,7 +459,7 @@
459
459
  }
460
460
 
461
461
  .formSelectPopup {
462
- composes: basePaneStructure from './base/Pane.module.scss';
462
+ composes: basePane from './base/Pane.module.scss';
463
463
 
464
464
  position: fixed;
465
465
  display: block;
@@ -1,12 +1,37 @@
1
+ .overlayView {
2
+ position: fixed;
3
+ inset: 0;
4
+ height: 100dvh;
5
+ width: 100dvw;
6
+ }
7
+
8
+ .overlayProvider {
9
+ composes: overlayView;
10
+
11
+ pointer-events: none;
12
+ z-index: 10000;
13
+ }
14
+
15
+ .overlayShade {
16
+ composes: overlayView;
17
+
18
+ background: var(--overlay);
19
+ backdrop-filter: blur(3px) saturate(180%);
20
+ pointer-events: none;
21
+ transition: opacity 600ms var(--swift-out);
22
+ }
23
+
24
+ .overlayProvider:not(:has(.overlay:not(.overlayTransitionLeaveActive))) .overlayShade {
25
+ opacity: 0;
26
+ }
27
+
1
28
  .overlay {
2
29
  position: fixed;
3
30
  display: flex;
4
31
  inset: 0;
5
32
  height: 100dvh;
6
33
  width: 100dvw;
7
- background: oklch(from var(--gray-11) l c h / .6);
8
- backdrop-filter: blur(3px) saturate(180%);
9
- z-index: 10000;
34
+ outline: 0;
10
35
 
11
36
  > .basePaneStructure {
12
37
  display: flex;
@@ -16,17 +41,40 @@
16
41
  flex-flow: column nowrap;
17
42
  box-shadow: var(--shadow-lg);
18
43
  overflow: auto;
44
+ transition: 420ms var(--swift-out);
45
+ transition-property: filter, scale;
19
46
 
20
47
  .paneFooter {
21
48
  position: sticky;
22
49
  bottom: 0;
23
50
  margin-top: auto;
24
51
  }
52
+
53
+ &::after {
54
+ position: absolute;
55
+ display: block;
56
+ inset: 0;
57
+ content: '';
58
+ background: var(--overlay-secondary);
59
+ opacity: 0;
60
+ pointer-events: none;
61
+ transition: opacity 420ms var(--swift-out);
62
+ z-index: 1;
63
+ }
64
+ }
65
+
66
+ &.isCurrent > .basePaneStructure {
67
+ pointer-events: auto;
25
68
  }
26
- }
27
69
 
28
- [dark] .overlay {
29
- background: rgb(0 0 0 / .6);
70
+ &:not(.isCurrent) > .basePaneStructure {
71
+ filter: blur(3px);
72
+ scale: .95;
73
+
74
+ &::after {
75
+ opacity: 1;
76
+ }
77
+ }
30
78
  }
31
79
 
32
80
  .overlaySmall {
@@ -178,6 +178,14 @@
178
178
  --foreground: var(--gray-8);
179
179
  --foreground-prominent: var(--gray-10);
180
180
  --foreground-secondary: var(--gray-5);
181
+
182
+ --overlay: oklch(from var(--gray-11) l c h / .6);
183
+ --overlay-secondary: oklch(from var(--gray-11) l c h / .4);
184
+ }
185
+
186
+ @mixin defaults-dark {
187
+ --overlay: rgb(0 0 0 / .6);
188
+ --overlay-secondary: rgb(0 0 0 / .4);
181
189
  }
182
190
 
183
191
  @mixin shadow-light {
package/src/data/store.ts CHANGED
@@ -20,7 +20,7 @@ export type FluxStore = FluxState & {
20
20
  addPrompt(spec: Omit<FluxPromptObject, 'id'>): number;
21
21
  addSnackbar(spec: Omit<FluxSnackbarObject, 'id'>): number;
22
22
  addTooltip(spec: Omit<FluxTooltipObject, 'id'>): number;
23
- registerDialog(): VoidFunction;
23
+ registerDialog(): [number, VoidFunction];
24
24
  removeAlert(id: number): void;
25
25
  removeConfirm(id: number): void;
26
26
  removePrompt(id: number): void;
@@ -104,9 +104,11 @@ export function addTooltip(spec: Omit<FluxTooltipObject, 'id'>): number {
104
104
  return id;
105
105
  }
106
106
 
107
- export function registerDialog(): VoidFunction {
108
- ++state.dialogCount;
109
- return () => --state.dialogCount;
107
+ export function registerDialog(): [number, VoidFunction] {
108
+ return [
109
+ ++state.dialogCount,
110
+ () => --state.dialogCount
111
+ ];
110
112
  }
111
113
 
112
114
  export function removeAlert(id: number): void {
@@ -1,7 +1,8 @@
1
- import { flattenVNodeTree } from '@flux-ui/internals';
2
- import { Component, getCurrentInstance, RenderFunction, Slots } from 'vue';
3
- import { Comment, h, onMounted, onUnmounted, SetupContext, Teleport, VNode } from 'vue';
1
+ import { flattenVNodeTree, useFocusTrap } from '@flux-ui/internals';
2
+ import type { Component, RenderFunction, SetupContext, Slots, VNode } from 'vue';
3
+ import { Comment, h, onUnmounted, ref, Teleport, watch } from 'vue';
4
4
  import { registerDialog, useFluxStore } from '$flux/data';
5
+ import $style from '$flux/css/component/Overlay.module.scss';
5
6
 
6
7
  type Emit = SetupContext<['close']>['emit'];
7
8
  type Props = {
@@ -9,27 +10,38 @@ type Props = {
9
10
  readonly viewKey?: string;
10
11
  };
11
12
 
13
+ const TARGET_SELECTOR = `.${$style.overlayProvider.replaceAll(' ', '.')}`;
14
+
12
15
  export default function (attrs: object, props: Props, emit: Emit, slots: Slots, className: string, transition: Component): RenderFunction {
13
- const instance = getCurrentInstance();
14
16
  let unregister: Function | null = null;
15
17
  let zIndex = 0;
16
18
 
17
- onMounted(() => {
18
- window.addEventListener('keydown', onKeyDown);
19
- });
19
+ const dialogRef = ref<HTMLElement>();
20
+
21
+ useFocusTrap(dialogRef);
20
22
 
21
23
  onUnmounted(() => {
22
- window.removeEventListener('keydown', onKeyDown);
23
24
  unregister?.();
24
25
  });
25
26
 
27
+ watch(dialogRef, (dialog, _, onCleanup) => {
28
+ if (!dialog) {
29
+ return;
30
+ }
31
+
32
+ dialog.addEventListener('keydown', onKeyDown, {passive: true});
33
+ dialog.focus();
34
+
35
+ onCleanup(() => {
36
+ dialog.removeEventListener('keydown', onKeyDown);
37
+ });
38
+ });
39
+
26
40
  function onKeyDown(evt: KeyboardEvent): void {
27
41
  if (evt.key !== 'Escape' || !unregister || !props.isCloseable) {
28
42
  return;
29
43
  }
30
44
 
31
- evt.preventDefault();
32
- evt.stopPropagation();
33
45
  emit('close');
34
46
  }
35
47
 
@@ -38,25 +50,28 @@ export default function (attrs: object, props: Props, emit: Emit, slots: Slots,
38
50
 
39
51
  const children = flattenVNodeTree(slots.default?.() ?? []);
40
52
  const isVisible = children.length > 0 && children.some(child => child.type !== Comment);
41
- const content: VNode[] = [];
53
+ let content: VNode | undefined;
42
54
 
43
55
  if (isVisible) {
44
56
  if (!unregister) {
45
- unregister = registerDialog();
46
- zIndex = dialogCount + 1000;
57
+ [zIndex, unregister] = registerDialog();
47
58
  }
48
59
 
49
- content.push(h('div', {
60
+ content = h('div', {
50
61
  key: props.viewKey,
51
- class: className,
52
- style: {zIndex}
53
- }, children));
62
+ ref: dialogRef,
63
+ class: [className, zIndex === dialogCount && $style.isCurrent],
64
+ style: {
65
+ zIndex: zIndex + 1000
66
+ },
67
+ tabindex: 0
68
+ }, children);
54
69
  } else {
55
70
  unregister?.();
56
71
  unregister = null;
57
72
  }
58
73
 
59
- return h(Teleport, {disabled: content.length === 0, to: instance?.appContext.app._container}, [
74
+ return h(Teleport, {defer: true, disabled: !content, to: TARGET_SELECTOR}, [
60
75
  h(transition, attrs, {
61
76
  default: () => content
62
77
  })