tera-system-ui 0.0.41 → 0.0.44

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.
@@ -4,7 +4,7 @@ export const styles = tv({
4
4
  base: '',
5
5
  dialog: 'bg-transparent text-inherit',
6
6
  dialogContainer: 'py-4 rounded-container',
7
- header: 'font-semibold px-4 mb-2',
7
+ header: 'font-bold px-4 mb-2',
8
8
  body: 'px-4',
9
9
  footer: 'mt-3 px-4 flex items-center justify-end gap-2.5'
10
10
  },
@@ -27,6 +27,6 @@
27
27
 
28
28
  <style>
29
29
  button[data-state="active"] {
30
- color: hsl(var(--tw---token-color-primary-token-6))
30
+ color: hsl(var(--tw---token-color-primary-token-5))
31
31
  }
32
32
  </style>
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
- import {cn} from "../../../utils/utils";
2
+ import {cn, consoleLog, observeVisibility} from "../../../utils/utils";
3
3
  import {getCtx} from "../Tabs";
4
+ import {onMount} from "svelte";
4
5
 
5
6
  let {
6
7
  children,
@@ -11,7 +12,9 @@
11
12
  let tabIndicator = $state()
12
13
  let tabsList = $state()
13
14
 
14
- function updateIndicator(button) {
15
+ function updateIndicator() {
16
+ let button = tabsList?.querySelector(`button[data-value="${context.state.currentTab}"]`)
17
+
15
18
  const rect = button.getBoundingClientRect();
16
19
  const containerRect = tabsList.getBoundingClientRect();
17
20
 
@@ -20,14 +23,27 @@
20
23
 
21
24
  tabIndicator.style.left = `${left}px`;
22
25
  tabIndicator.style.width = `${width}px`;
26
+
27
+ consoleLog('TabList', 'tabIndicator', tabIndicator)
23
28
  }
24
29
 
25
30
 
26
31
  let context = getCtx()
27
32
 
28
33
  $effect(() => {
29
- let tabButton = tabsList?.querySelector(`button[data-value="${context.state.currentTab}"]`)
30
- updateIndicator(tabButton);
34
+ context.state.currentTab
35
+ updateIndicator();
36
+ })
37
+
38
+ onMount(() => {
39
+ const stopObserving = observeVisibility(tabIndicator, (isVisible, entry) => {
40
+ if (isVisible) {
41
+ consoleLog('Element is visible:', entry.target);
42
+ updateIndicator()
43
+ }
44
+ });
45
+
46
+ return () => stopObserving()
31
47
  })
32
48
  </script>
33
49
 
@@ -0,0 +1 @@
1
+ export { cn, observeVisibility } from './utils';
@@ -0,0 +1 @@
1
+ export { cn, observeVisibility } from './utils';
@@ -1,2 +1,4 @@
1
1
  import { type ClassValue } from "clsx";
2
2
  export declare function cn(...inputs: ClassValue[]): string;
3
+ export declare function consoleLog(...params: any[]): void;
4
+ export declare function observeVisibility(element: HTMLElement, callback: any): () => void;
@@ -3,3 +3,22 @@ import { twMerge } from "tailwind-merge";
3
3
  export function cn(...inputs) {
4
4
  return twMerge(clsx(inputs));
5
5
  }
6
+ export function consoleLog(...params) {
7
+ console.log('tera-system-ui', ...params);
8
+ }
9
+ export function observeVisibility(element, callback) {
10
+ if (!element) {
11
+ throw new Error("Invalid element provided.");
12
+ }
13
+ // Create an Intersection Observer
14
+ const observer = new IntersectionObserver((entries) => {
15
+ entries.forEach((entry) => {
16
+ // Check if the element is visible
17
+ callback(entry.isIntersecting, entry);
18
+ });
19
+ });
20
+ // Start observing the element
21
+ observer.observe(element);
22
+ // Return a function to stop observing
23
+ return () => observer.disconnect();
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tera-system-ui",
3
- "version": "0.0.41",
3
+ "version": "0.0.44",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "npm run customPrepublish && npm run generate-index && vite build && npm run package && npm run postpublish",
@@ -38,6 +38,10 @@
38
38
  "svelte": "./dist/index.js",
39
39
  "default": "./dist/index.js"
40
40
  },
41
+ "./utils": {
42
+ "types": "./dist/utils/index.d.ts",
43
+ "default": "./dist/utils/index.js"
44
+ },
41
45
  "./i18n": {
42
46
  "types": "./dist/i18n/index.d.ts",
43
47
  "svelte": "./dist/i18n/index.js",