@juninmd/sonido 1.0.0 → 1.1.0

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 +1 @@
1
- {"version":3,"file":"tokens.js","names":["color","space","radius","duration","easing","palette"],"sources":["../src/tokens/index.ts"],"sourcesContent":["/** Tokens em JS, espelhando tokens.css. Use em CSS-in-JS, gráficos ou testes. */\r\nexport const color = {\r\n bg: \"var(--sn-color-bg)\",\r\n surface: \"var(--sn-color-surface)\",\r\n surface2: \"var(--sn-color-surface-2)\",\r\n surfaceHover: \"var(--sn-color-surface-hover)\",\r\n border: \"var(--sn-color-border)\",\r\n text: \"var(--sn-color-text)\",\r\n textDim: \"var(--sn-color-text-dim)\",\r\n textFaint: \"var(--sn-color-text-faint)\",\r\n accent: \"var(--sn-color-accent)\",\r\n accent2: \"var(--sn-color-accent-2)\",\r\n aqua: \"var(--sn-color-aqua)\",\r\n gold: \"var(--sn-color-gold)\",\r\n success: \"var(--sn-color-success)\",\r\n warning: \"var(--sn-color-warning)\",\r\n danger: \"var(--sn-color-danger)\",\r\n info: \"var(--sn-color-info)\",\r\n} as const;\r\n\r\nexport const space = { 1: 4, 2: 8, 3: 12, 4: 16, 5: 24, 6: 40 } as const;\r\nexport const radius = { sm: 8, md: 14, lg: 20, pill: 999 } as const;\r\nexport const duration = { fast: 140, base: 220, slow: 420 } as const;\r\nexport const easing = {\r\n standard: \"cubic-bezier(0.22, 1, 0.36, 1)\",\r\n in: \"cubic-bezier(0.4, 0, 1, 1)\",\r\n spring: \"cubic-bezier(0.34, 1.56, 0.64, 1)\",\r\n} as const;\r\n\r\n/** Valores crus do tema escuro (padrão), úteis para docs e canvas. */\r\nexport const palette = {\r\n dark: {\r\n bg: \"#0a0b12\",\r\n surface: \"#12141f\",\r\n accent: \"#ff3d6e\",\r\n accent2: \"#7c5cff\",\r\n aqua: \"#3fe3d3\",\r\n gold: \"#f5b73d\",\r\n text: \"#f1f2f8\",\r\n },\r\n light: {\r\n bg: \"#eeedf6\",\r\n surface: \"#ffffff\",\r\n accent: \"#c81e45\",\r\n accent2: \"#5b3fd9\",\r\n aqua: \"#0b766c\",\r\n gold: \"#8f5c12\",\r\n text: \"#14122b\",\r\n },\r\n} as const;\r\n\r\nexport type ColorToken = keyof typeof color;\r\n"],"mappings":";AACA,IAAaA,IAAQ;CACnB,IAAI;CACJ,SAAS;CACT,UAAU;CACV,cAAc;CACd,QAAQ;CACR,MAAM;CACN,SAAS;CACT,WAAW;CACX,QAAQ;CACR,SAAS;CACT,MAAM;CACN,MAAM;CACN,SAAS;CACT,SAAS;CACT,QAAQ;CACR,MAAM;AACR,GAEaC,IAAQ;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAI,GAAG;CAAI,GAAG;CAAI,GAAG;AAAG,GACjDC,IAAS;CAAE,IAAI;CAAG,IAAI;CAAI,IAAI;CAAI,MAAM;AAAI,GAC5CC,IAAW;CAAE,MAAM;CAAK,MAAM;CAAK,MAAM;AAAI,GAC7CC,IAAS;CACpB,UAAU;CACV,IAAI;CACJ,QAAQ;AACV,GAGaC,IAAU;CACrB,MAAM;EACJ,IAAI;EACJ,SAAS;EACT,QAAQ;EACR,SAAS;EACT,MAAM;EACN,MAAM;EACN,MAAM;CACR;CACA,OAAO;EACL,IAAI;EACJ,SAAS;EACT,QAAQ;EACR,SAAS;EACT,MAAM;EACN,MAAM;EACN,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"tokens.js","names":["color","space","radius","duration","easing","palette"],"sources":["../src/tokens/index.ts"],"sourcesContent":["/** Tokens em JS, espelhando tokens.css. Use em CSS-in-JS, gráficos ou testes. */\nexport const color = {\n bg: \"var(--sn-color-bg)\",\n surface: \"var(--sn-color-surface)\",\n surface2: \"var(--sn-color-surface-2)\",\n surfaceHover: \"var(--sn-color-surface-hover)\",\n border: \"var(--sn-color-border)\",\n text: \"var(--sn-color-text)\",\n textDim: \"var(--sn-color-text-dim)\",\n textFaint: \"var(--sn-color-text-faint)\",\n accent: \"var(--sn-color-accent)\",\n accent2: \"var(--sn-color-accent-2)\",\n aqua: \"var(--sn-color-aqua)\",\n gold: \"var(--sn-color-gold)\",\n success: \"var(--sn-color-success)\",\n warning: \"var(--sn-color-warning)\",\n danger: \"var(--sn-color-danger)\",\n info: \"var(--sn-color-info)\",\n} as const;\n\nexport const space = { 1: 4, 2: 8, 3: 12, 4: 16, 5: 24, 6: 40 } as const;\nexport const radius = { sm: 8, md: 14, lg: 20, pill: 999 } as const;\nexport const duration = { fast: 140, base: 220, slow: 420 } as const;\nexport const easing = {\n standard: \"cubic-bezier(0.22, 1, 0.36, 1)\",\n in: \"cubic-bezier(0.4, 0, 1, 1)\",\n spring: \"cubic-bezier(0.34, 1.56, 0.64, 1)\",\n} as const;\n\n/** Valores crus do tema escuro (padrão), úteis para docs e canvas. */\nexport const palette = {\n dark: {\n bg: \"#0a0b12\",\n surface: \"#12141f\",\n accent: \"#ff3d6e\",\n accent2: \"#7c5cff\",\n aqua: \"#3fe3d3\",\n gold: \"#f5b73d\",\n text: \"#f1f2f8\",\n },\n light: {\n bg: \"#eeedf6\",\n surface: \"#ffffff\",\n accent: \"#c81e45\",\n accent2: \"#5b3fd9\",\n aqua: \"#0b766c\",\n gold: \"#8f5c12\",\n text: \"#14122b\",\n },\n} as const;\n\nexport type ColorToken = keyof typeof color;\n"],"mappings":";AACA,IAAaA,IAAQ;CACnB,IAAI;CACJ,SAAS;CACT,UAAU;CACV,cAAc;CACd,QAAQ;CACR,MAAM;CACN,SAAS;CACT,WAAW;CACX,QAAQ;CACR,SAAS;CACT,MAAM;CACN,MAAM;CACN,SAAS;CACT,SAAS;CACT,QAAQ;CACR,MAAM;AACR,GAEaC,IAAQ;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAI,GAAG;CAAI,GAAG;CAAI,GAAG;AAAG,GACjDC,IAAS;CAAE,IAAI;CAAG,IAAI;CAAI,IAAI;CAAI,MAAM;AAAI,GAC5CC,IAAW;CAAE,MAAM;CAAK,MAAM;CAAK,MAAM;AAAI,GAC7CC,IAAS;CACpB,UAAU;CACV,IAAI;CACJ,QAAQ;AACV,GAGaC,IAAU;CACrB,MAAM;EACJ,IAAI;EACJ,SAAS;EACT,QAAQ;EACR,SAAS;EACT,MAAM;EACN,MAAM;EACN,MAAM;CACR;CACA,OAAO;EACL,IAAI;EACJ,SAAS;EACT,QAAQ;EACR,SAAS;EACT,MAAM;EACN,MAAM;EACN,MAAM;CACR;AACF"}
@@ -0,0 +1,4 @@
1
+ /** Desacelera no fim; t é limitado a 0..1. */
2
+ export declare const easeOutCubic: (t: number) => number;
3
+ /** Valor de uma contagem de `from` a `to` após `elapsed` ms de `duration` ms. */
4
+ export declare function countValue(from: number, to: number, elapsed: number, duration: number, ease?: (t: number) => number): number;
@@ -0,0 +1,15 @@
1
+ export interface FlyToOptions {
2
+ /** Cor do cometa (qualquer cor CSS). Padrão: --sn-color-accent-2. */
3
+ color?: string;
4
+ /** Duração em ms. */
5
+ duration?: number;
6
+ }
7
+ /**
8
+ * Um cometa voa de `from` (elemento ou ponto na tela) até `to` (elemento ou seletor),
9
+ * para a marcação ir visivelmente para algum lugar. Não faz nada sem animação.
10
+ * Resolve quando o cometa chega.
11
+ */
12
+ export declare function flyTo(from: Element | {
13
+ x: number;
14
+ y: number;
15
+ }, to?: Element | string, { color, duration }?: FlyToOptions): Promise<void>;
@@ -0,0 +1,12 @@
1
+ /** 1536 → "1,5 KB". Base 1024; 1023,99 KB sobe para "1 MB" em vez de "1.024 KB". */
2
+ export declare function formatBytes(bytes: number, locale?: string): string;
3
+ /** Separa número e unidade ("12,4", "GB") para estilizar cada parte. */
4
+ export declare function splitBytes(bytes: number, locale?: string): [string, string];
5
+ /** 1240 → "1,2 mil"; 2_500_000 → "2,5 mi". */
6
+ export declare function formatCount(n: number, locale?: string): string;
7
+ /** Data (Date ou epoch em ms) → "há 3 dias". Sem data → "—". */
8
+ export declare function formatAge(date: Date | number | null | undefined, now?: number): string;
9
+ /** Segundos → "4:05" ou "1:02:05". */
10
+ export declare function formatElapsed(secs: number): string;
11
+ /** Último trecho de um caminho Windows ou Unix. */
12
+ export declare function baseName(path: string): string;
@@ -0,0 +1,9 @@
1
+ export interface TileRect<T> {
2
+ item: T;
3
+ x: number;
4
+ y: number;
5
+ w: number;
6
+ h: number;
7
+ }
8
+ /** Layout "squarified" de treemap (Bruls et al.) sem dependências. `items` já ordenado do maior ao menor. */
9
+ export declare function squarify<T>(items: T[], value: (item: T) => number, x: number, y: number, w: number, h: number): TileRect<T>[];
@@ -0,0 +1,28 @@
1
+ /** Nó de hierarquia usado por Treemap e Sunburst. Folhas têm `value`; pastas somam os filhos. */
2
+ export interface TreeNode {
3
+ name: string;
4
+ value?: number;
5
+ children?: TreeNode[];
6
+ /** Cor CSS opcional; sem ela o nó usa a paleta do tema. */
7
+ color?: string;
8
+ id?: string;
9
+ }
10
+ /** Nó com total calculado, filhos ordenados e caminho a partir da raiz. */
11
+ export interface SizedNode {
12
+ node: TreeNode;
13
+ name: string;
14
+ value: number;
15
+ path: string;
16
+ depth: number;
17
+ parent: SizedNode | null;
18
+ children: SizedNode[];
19
+ color?: string;
20
+ }
21
+ /** Soma os valores, ordena do maior ao menor e liga cada nó ao pai. */
22
+ export declare function sizeTree(node: TreeNode, parent?: SizedNode | null): SizedNode;
23
+ /** true quando `path` é `focus`, está dentro dele ou é um dos pais: os nós que ficam acesos. */
24
+ export declare function isRelated(path: string, focus: string): boolean;
25
+ /** Cores da paleta, em ordem, como variáveis do tema. */
26
+ export declare const TREE_PALETTE: string[];
27
+ /** Do mais próximo da raiz para o nó. */
28
+ export declare function ancestry(n: SizedNode): SizedNode[];
@@ -0,0 +1,18 @@
1
+ /** "system" segue o sistema; "always" anima mesmo com reduced-motion; "never" desliga tudo. */
2
+ export type MotionPref = "system" | "always" | "never";
3
+ export declare const MOTION_PREF_LABELS: Record<MotionPref, string>;
4
+ /** Lê a preferência salva (fora de React). */
5
+ export declare function getMotionPref(): MotionPref;
6
+ /** Salva a preferência e avisa todos os componentes que usam `useMotionPref`. */
7
+ export declare function setMotionPref(pref: MotionPref): void;
8
+ /** true quando deve animar, juntando a preferência salva e o reduced-motion do sistema. */
9
+ export declare function shouldAnimate(pref?: MotionPref): boolean;
10
+ /**
11
+ * Preferência de movimento do usuário, salva no navegador e compartilhada entre componentes.
12
+ * Estende o `useReducedMotion`: o usuário pode forçar animação ou desligar tudo.
13
+ */
14
+ export declare function useMotionPref(): {
15
+ readonly pref: MotionPref;
16
+ readonly setPref: (p: MotionPref) => void;
17
+ readonly animate: boolean;
18
+ };
@@ -0,0 +1,6 @@
1
+ export interface Size {
2
+ width: number;
3
+ height: number;
4
+ }
5
+ /** Mede a caixa de conteúdo de um elemento com ResizeObserver. Use o `ref` retornado. */
6
+ export declare function useSize<T extends HTMLElement = HTMLElement>(): readonly [(el: T | null) => void, Size];
package/package.json CHANGED
@@ -1,102 +1,102 @@
1
- {
2
- "name": "@juninmd/sonido",
3
- "version": "1.0.0",
4
- "description": "Design system e biblioteca de componentes React do juninmd: 78 componentes, 8 temas e animações.",
5
- "type": "module",
6
- "license": "MIT",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/juninmd/sonido.git"
10
- },
11
- "homepage": "https://juninmd.github.io/sonido/",
12
- "bugs": "https://github.com/juninmd/sonido/issues",
13
- "keywords": [
14
- "react",
15
- "design-system",
16
- "components",
17
- "ui",
18
- "tokens",
19
- "storybook",
20
- "themes",
21
- "animation"
22
- ],
23
- "sideEffects": [
24
- "**/*.css"
25
- ],
26
- "files": [
27
- "dist",
28
- "README.md",
29
- "LICENSE"
30
- ],
31
- "main": "./dist/index.js",
32
- "module": "./dist/index.js",
33
- "types": "./dist/index.d.ts",
34
- "exports": {
35
- ".": {
36
- "types": "./dist/index.d.ts",
37
- "import": "./dist/index.js"
38
- },
39
- "./styles.css": "./dist/sonido.css",
40
- "./tokens.css": "./dist/tokens.css",
41
- "./tokens": {
42
- "types": "./dist/tokens/index.d.ts",
43
- "import": "./dist/tokens.js"
44
- },
45
- "./package.json": "./package.json"
46
- },
47
- "publishConfig": {
48
- "access": "public",
49
- "provenance": true
50
- },
51
- "engines": {
52
- "node": ">=20"
53
- },
54
- "scripts": {
55
- "dev": "storybook dev -p 6006",
56
- "build": "vite build && tsc -p tsconfig.build.json && cp src/tokens/tokens.css dist/tokens.css",
57
- "build:docs": "storybook build -o storybook-static",
58
- "typecheck": "tsc --noEmit",
59
- "lint": "biome check .",
60
- "lint:fix": "biome check --write .",
61
- "test": "vitest run",
62
- "test:watch": "vitest",
63
- "audit:ds": "node scripts/audit.mjs",
64
- "check": "npm run lint && npm run typecheck && npm run audit:ds && npm run test",
65
- "prepare": "husky || true",
66
- "release": "semantic-release"
67
- },
68
- "peerDependencies": {
69
- "react": ">=18",
70
- "react-dom": ">=18"
71
- },
72
- "devDependencies": {
73
- "@biomejs/biome": "^2.6.8",
74
- "@commitlint/cli": "^21.2.4",
75
- "@commitlint/config-conventional": "^21.2.4",
76
- "@semantic-release/changelog": "^7.0.0",
77
- "@semantic-release/git": "^11.0.1",
78
- "@storybook/addon-a11y": "^10.6.8",
79
- "@storybook/addon-docs": "^10.6.8",
80
- "@storybook/react-vite": "^10.6.8",
81
- "@testing-library/jest-dom": "^8.0.0",
82
- "@testing-library/react": "^16.3.3",
83
- "@testing-library/user-event": "^14.6.13",
84
- "@types/react": "^19.3.0",
85
- "@types/react-dom": "^19.3.0",
86
- "@vitejs/plugin-react": "^6.3.0",
87
- "husky": "^9.1.7",
88
- "jsdom": "^31.0.1",
89
- "prettier": "^3.10.1",
90
- "prism-react-renderer": "^2.4.1",
91
- "react": "^19.3.1",
92
- "react-dom": "^19.3.1",
93
- "react-live": "^4.1.8",
94
- "semantic-release": "^25.0.9",
95
- "storybook": "^10.6.8",
96
- "sucrase": "^3.35.1",
97
- "typescript": "^5.9.3",
98
- "vite": "^8.3.8",
99
- "vitest": "^5.1.1"
100
- },
101
- "author": "juninmd"
102
- }
1
+ {
2
+ "name": "@juninmd/sonido",
3
+ "version": "1.1.0",
4
+ "description": "Design system e biblioteca de componentes React do juninmd: 83 componentes, 8 temas e animações.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/juninmd/sonido.git"
10
+ },
11
+ "homepage": "https://juninmd.github.io/sonido/",
12
+ "bugs": "https://github.com/juninmd/sonido/issues",
13
+ "keywords": [
14
+ "react",
15
+ "design-system",
16
+ "components",
17
+ "ui",
18
+ "tokens",
19
+ "storybook",
20
+ "themes",
21
+ "animation"
22
+ ],
23
+ "sideEffects": [
24
+ "**/*.css"
25
+ ],
26
+ "files": [
27
+ "dist",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "main": "./dist/index.js",
32
+ "module": "./dist/index.js",
33
+ "types": "./dist/index.d.ts",
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js"
38
+ },
39
+ "./styles.css": "./dist/sonido.css",
40
+ "./tokens.css": "./dist/tokens.css",
41
+ "./tokens": {
42
+ "types": "./dist/tokens/index.d.ts",
43
+ "import": "./dist/tokens.js"
44
+ },
45
+ "./package.json": "./package.json"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public",
49
+ "provenance": true
50
+ },
51
+ "engines": {
52
+ "node": ">=20"
53
+ },
54
+ "scripts": {
55
+ "dev": "storybook dev -p 6006",
56
+ "build": "vite build && tsc -p tsconfig.build.json && cp src/tokens/tokens.css dist/tokens.css",
57
+ "build:docs": "storybook build -o storybook-static",
58
+ "typecheck": "tsc --noEmit",
59
+ "lint": "biome check .",
60
+ "lint:fix": "biome check --write .",
61
+ "test": "vitest run",
62
+ "test:watch": "vitest",
63
+ "audit:ds": "node scripts/audit.mjs",
64
+ "check": "npm run lint && npm run typecheck && npm run audit:ds && npm run test",
65
+ "prepare": "husky || true",
66
+ "release": "semantic-release"
67
+ },
68
+ "peerDependencies": {
69
+ "react": ">=18",
70
+ "react-dom": ">=18"
71
+ },
72
+ "devDependencies": {
73
+ "@biomejs/biome": "^2.6.8",
74
+ "@commitlint/cli": "^21.2.4",
75
+ "@commitlint/config-conventional": "^21.2.4",
76
+ "@semantic-release/changelog": "^7.0.0",
77
+ "@semantic-release/git": "^11.0.1",
78
+ "@storybook/addon-a11y": "^10.6.8",
79
+ "@storybook/addon-docs": "^10.6.8",
80
+ "@storybook/react-vite": "^10.6.8",
81
+ "@testing-library/jest-dom": "^8.0.0",
82
+ "@testing-library/react": "^16.3.3",
83
+ "@testing-library/user-event": "^14.6.13",
84
+ "@types/react": "^19.3.0",
85
+ "@types/react-dom": "^19.3.0",
86
+ "@vitejs/plugin-react": "^6.3.0",
87
+ "husky": "^9.1.7",
88
+ "jsdom": "^31.0.1",
89
+ "prettier": "^3.10.1",
90
+ "prism-react-renderer": "^2.4.1",
91
+ "react": "^19.3.1",
92
+ "react-dom": "^19.3.1",
93
+ "react-live": "^4.1.8",
94
+ "semantic-release": "^25.0.9",
95
+ "storybook": "^10.6.8",
96
+ "sucrase": "^3.35.1",
97
+ "typescript": "^5.9.3",
98
+ "vite": "^8.3.8",
99
+ "vitest": "^5.1.1"
100
+ },
101
+ "author": "juninmd"
102
+ }