@flux-ui/visuals 4.0.0-beta.1 → 4.0.0-beta.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flux-ui/visuals",
3
3
  "description": "Visual effect components for the Flux UI library.",
4
- "version": "4.0.0-beta.1",
4
+ "version": "4.0.0-beta.3",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/basmilius",
@@ -48,24 +48,27 @@
48
48
  "module": "./dist/index.js",
49
49
  "types": "./dist/index.d.ts",
50
50
  "dependencies": {
51
- "@basmilius/common": "^3.55.0",
52
- "@basmilius/utils": "^3.55.0",
53
- "@flux-ui/internals": "4.0.0-beta.1",
54
- "@flux-ui/types": "4.0.0-beta.1",
51
+ "@flux-ui/types": "^4.0.0-beta.3",
55
52
  "clsx": "^2.1.1",
56
53
  "rough-notation": "^0.5.1"
57
54
  },
58
55
  "peerDependencies": {
56
+ "@basmilius/common": "^3.58.0",
57
+ "@basmilius/utils": "^3.58.0",
58
+ "@flux-ui/internals": "^4.0.0-beta.3",
59
+ "luxon": "^3.7.2",
59
60
  "vue": "^3.6.0-rc.2"
60
61
  },
61
62
  "devDependencies": {
62
- "@basmilius/vite-preset": "^3.55.0",
63
+ "@basmilius/common": "^3.58.0",
64
+ "@basmilius/utils": "^3.58.0",
65
+ "@basmilius/vite-preset": "^3.58.0",
63
66
  "@types/node": "^26.1.2",
64
67
  "@vitejs/plugin-vue": "^6.0.8",
65
68
  "@vue/tsconfig": "^0.9.1",
66
69
  "sass-embedded": "^1.100.0",
67
70
  "typescript": "6.0.3",
68
- "vite": "^8.1.5",
71
+ "vite": "^8.2.0",
69
72
  "vue-tsc": "^3.3.8"
70
73
  }
71
74
  }
@@ -8,10 +8,9 @@
8
8
  <script
9
9
  lang="ts"
10
10
  setup>
11
- import { useComponentId } from '@basmilius/common';
12
- import { mulberry32 } from '@basmilius/utils';
13
- import { prefersReducedMotion, useInView } from '@flux-ui/internals';
14
- import { computed, onBeforeUnmount, ref, unref, useTemplateRef, watch } from 'vue';
11
+ import { useInView } from '@basmilius/common';
12
+ import { mulberry32, prefersReducedMotion } from '@basmilius/utils';
13
+ import { computed, onBeforeUnmount, ref, unref, useId, useTemplateRef, watch } from 'vue';
15
14
  import $style from '~flux/visuals/css/component/Visual.module.scss';
16
15
 
17
16
  type Polygon = [number, number, string, PolygonPoint[]];
@@ -37,7 +36,7 @@
37
36
  const tick = ref(0);
38
37
  const size = ref<{ width: number; height: number; } | null>(null);
39
38
 
40
- const componentId = useComponentId();
39
+ const instanceId = useId();
41
40
  const inView = useInView(canvasRef, {initial: true});
42
41
  const reducedMotion = prefersReducedMotion();
43
42
 
@@ -46,7 +45,7 @@
46
45
  return [];
47
46
  }
48
47
 
49
- const mulberry = mulberry32(seed ?? componentId.value);
48
+ const mulberry = mulberry32(seed ?? hashId(instanceId));
50
49
  const polygons: Polygon[] = [];
51
50
 
52
51
  for (const color of colors) {
@@ -183,4 +182,15 @@
183
182
 
184
183
  schedule();
185
184
  }
185
+
186
+ // mulberry32 seeds on a number, so the id becomes one.
187
+ function hashId(value: string): number {
188
+ let hash = 0;
189
+
190
+ for (let index = 0; index < value.length; index++) {
191
+ hash = (hash * 31 + value.charCodeAt(index)) | 0;
192
+ }
193
+
194
+ return hash;
195
+ }
186
196
  </script>
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
- import { flattenVNodeTree, prefersReducedMotion } from '@flux-ui/internals';
2
+ import { prefersReducedMotion } from '@basmilius/utils';
3
+ import { flattenVNodeTree } from '@flux-ui/internals';
3
4
  import { clsx } from 'clsx';
4
5
  import { cloneVNode, defineComponent, Fragment, h, onBeforeUnmount, type PropType, ref, watch } from 'vue';
5
6
  import $style from '~flux/visuals/css/component/Attention.module.scss';
@@ -23,8 +23,9 @@
23
23
  <script
24
24
  lang="ts"
25
25
  setup>
26
- import { useInView } from '@flux-ui/internals';
27
- import type { BorderBeamVariant } from '@flux-ui/types';
26
+ import { useInView } from '@basmilius/common';
27
+ import { clamp } from '@basmilius/utils';
28
+ import type { FluxVisualBorderBeamVariant } from '@flux-ui/types';
28
29
  import { clsx } from 'clsx';
29
30
  import { computed, ref, unref, useTemplateRef, watch } from 'vue';
30
31
  import { useBorderBeamPulse } from '~flux/visuals/composable/private';
@@ -56,14 +57,14 @@
56
57
  readonly saturation?: number;
57
58
  readonly staticColors?: boolean;
58
59
  readonly strength?: number;
59
- readonly variant?: BorderBeamVariant;
60
+ readonly variant?: FluxVisualBorderBeamVariant;
60
61
  }>();
61
62
 
62
63
  defineSlots<{
63
64
  default(): any;
64
65
  }>();
65
66
 
66
- const VARIANT_CLASSES: Record<BorderBeamVariant, string> = {
67
+ const VARIANT_CLASSES: Record<FluxVisualBorderBeamVariant, string> = {
67
68
  'sm': $style.sm,
68
69
  'md': $style.md,
69
70
  'line': $style.line,
@@ -131,8 +132,6 @@
131
132
  return;
132
133
  }
133
134
 
134
- const clamp = (value: number): number => Math.max(.35, Math.min(4, value));
135
-
136
135
  const measure = (): void => {
137
136
  const rect = child.getBoundingClientRect();
138
137
 
@@ -140,8 +139,8 @@
140
139
  return;
141
140
  }
142
141
 
143
- const x = +clamp(rect.width / 350).toFixed(3);
144
- const y = +clamp(rect.height / 140).toFixed(3);
142
+ const x = +clamp(rect.width / 350, .35, 4).toFixed(3);
143
+ const y = +clamp(rect.height / 140, .35, 4).toFixed(3);
145
144
 
146
145
  if (glowScale.value?.x !== x || glowScale.value?.y !== y) {
147
146
  glowScale.value = {x, y};
@@ -8,8 +8,8 @@
8
8
  <script
9
9
  lang="ts"
10
10
  setup>
11
- import { mulberry32 } from '@basmilius/utils';
12
- import { prefersReducedMotion, useInView } from '@flux-ui/internals';
11
+ import { useInView } from '@basmilius/common';
12
+ import { mulberry32, prefersReducedMotion } from '@basmilius/utils';
13
13
  import { computed, unref, useTemplateRef, watch } from 'vue';
14
14
  import $style from '~flux/visuals/css/component/Visual.module.scss';
15
15
 
@@ -9,8 +9,9 @@
9
9
  <script
10
10
  lang="ts"
11
11
  setup>
12
- import { prefersReducedMotion, useInView } from '@flux-ui/internals';
13
- import type { HighlighterVariant } from '@flux-ui/types';
12
+ import { useInView } from '@basmilius/common';
13
+ import { prefersReducedMotion } from '@basmilius/utils';
14
+ import type { FluxVisualHighlighterVariant } from '@flux-ui/types';
14
15
  import { annotate } from 'rough-notation';
15
16
  import { computed, onBeforeUnmount, onMounted, shallowRef, useTemplateRef, watch } from 'vue';
16
17
  import { type HighlighterGroupEntry, useHighlighterGroupInjection } from '~flux/visuals/composable/private';
@@ -34,7 +35,7 @@
34
35
  multiline,
35
36
  whenInView = false
36
37
  } = defineProps<{
37
- readonly variant?: HighlighterVariant;
38
+ readonly variant?: FluxVisualHighlighterVariant;
38
39
  readonly color?: string;
39
40
  readonly strokeWidth?: number;
40
41
  readonly animationDuration?: number;
@@ -7,11 +7,11 @@
7
7
  <script
8
8
  lang="ts"
9
9
  setup>
10
- import type { HighlighterGroupProps } from '@flux-ui/types';
10
+ import type { FluxVisualHighlighterGroupProps } from '@flux-ui/types';
11
11
  import { useHighlighterGroup } from '~flux/visuals/composable/private';
12
12
  import $style from '~flux/visuals/css/component/Highlighter.module.scss';
13
13
 
14
- const props = defineProps<HighlighterGroupProps>();
14
+ const props = defineProps<FluxVisualHighlighterGroupProps>();
15
15
 
16
16
  defineSlots<{
17
17
  default(): any;
@@ -8,7 +8,7 @@
8
8
  <script
9
9
  lang="ts"
10
10
  setup>
11
- import { prefersReducedMotion } from '@flux-ui/internals';
11
+ import { prefersReducedMotion } from '@basmilius/utils';
12
12
  import { computed, onBeforeUnmount, onMounted, useTemplateRef, watch } from 'vue';
13
13
  import $style from '~flux/visuals/css/component/NumberFlow.module.scss';
14
14
 
@@ -7,7 +7,7 @@
7
7
  <script
8
8
  lang="ts"
9
9
  setup>
10
- import { prefersReducedMotion } from '@flux-ui/internals';
10
+ import { prefersReducedMotion } from '@basmilius/utils';
11
11
  import { onBeforeUnmount, onMounted, useTemplateRef, watch } from 'vue';
12
12
  import $style from '~flux/visuals/css/component/SlotText.module.scss';
13
13
 
@@ -8,7 +8,7 @@
8
8
  <script
9
9
  lang="ts"
10
10
  setup>
11
- import { prefersReducedMotion } from '@flux-ui/internals';
11
+ import { prefersReducedMotion } from '@basmilius/utils';
12
12
  import { onBeforeUnmount, useTemplateRef, watch } from 'vue';
13
13
  import $style from '~flux/visuals/css/component/TextScramble.module.scss';
14
14
 
@@ -1,5 +1,5 @@
1
- import { prefersReducedMotion } from '@flux-ui/internals';
2
- import type { BorderBeamVariant } from '@flux-ui/types';
1
+ import { prefersReducedMotion } from '@basmilius/utils';
2
+ import type { FluxVisualBorderBeamVariant } from '@flux-ui/types';
3
3
  import { type Ref, unref, watchEffect } from 'vue';
4
4
 
5
5
  type PulseOscillator = {
@@ -163,7 +163,7 @@ type UseBorderBeamPulseOptions = {
163
163
  readonly elementRef: Ref<HTMLElement | null>;
164
164
  readonly enabled: Ref<boolean>;
165
165
  readonly staticColors: Ref<boolean>;
166
- readonly variant: Ref<BorderBeamVariant>;
166
+ readonly variant: Ref<FluxVisualBorderBeamVariant>;
167
167
  };
168
168
 
169
169
  /**
@@ -1,4 +1,4 @@
1
- import type { HighlighterGroupProps } from '@flux-ui/types';
1
+ import type { FluxVisualHighlighterGroupProps } from '@flux-ui/types';
2
2
  import { annotationGroup } from 'rough-notation';
3
3
  import { inject, type InjectionKey, onScopeDispose, provide } from 'vue';
4
4
 
@@ -10,7 +10,7 @@ export type HighlighterGroupEntry = {
10
10
  };
11
11
 
12
12
  export type HighlighterGroupContext = {
13
- readonly defaults: HighlighterGroupProps;
13
+ readonly defaults: FluxVisualHighlighterGroupProps;
14
14
  add(entry: HighlighterGroupEntry): void;
15
15
  remove(entry: HighlighterGroupEntry): void;
16
16
  notify(): void;
@@ -47,7 +47,7 @@ export function useHighlighterGroupInjection(): HighlighterGroupContext | null {
47
47
  * @author Bas Milius <bas@mili.us>
48
48
  * @since 1.0.0
49
49
  */
50
- export default function useHighlighterGroup(props: HighlighterGroupProps): void {
50
+ export default function useHighlighterGroup(props: FluxVisualHighlighterGroupProps): void {
51
51
  const whenInView = props.whenInView ?? false;
52
52
  const entries = new Set<HighlighterGroupEntry>();
53
53