valtech-components 2.0.772 → 2.0.774
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/esm2022/lib/components/atoms/pattern/motifs.mjs +147 -0
- package/esm2022/lib/components/atoms/pattern/pattern.component.mjs +164 -0
- package/esm2022/lib/components/atoms/pattern/types.mjs +2 -0
- package/esm2022/lib/version.mjs +2 -2
- package/esm2022/public-api.mjs +4 -1
- package/fesm2022/valtech-components.mjs +309 -4
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/atoms/pattern/motifs.d.ts +60 -0
- package/lib/components/atoms/pattern/pattern.component.d.ts +68 -0
- package/lib/components/atoms/pattern/types.d.ts +61 -0
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +3 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Valtech Pattern System — motifs + palettes.
|
|
3
|
+
*
|
|
4
|
+
* Pure data + helpers, sin dependencias Angular. Reusable desde Node/scripts
|
|
5
|
+
* (e.g., generate static thumbnails) o desde el componente `val-pattern`.
|
|
6
|
+
*
|
|
7
|
+
* Original spec: `assets/Valtech Pattern System.html` (single-page demo).
|
|
8
|
+
* Cada motif es función `(fill: string) => string` que devuelve SVG inner
|
|
9
|
+
* markup. Tile es 100×100 unidades; el motif se renderiza dentro de un `<g
|
|
10
|
+
* transform="translate(col*100 row*100)">` con un `<rect width=100 height=100
|
|
11
|
+
* fill=bg/>` de fondo.
|
|
12
|
+
*/
|
|
13
|
+
export type PatternMotifKey = 'chev-r' | 'chev-l' | 'chev-d' | 'chev-u' | 'tri-tl' | 'tri-tr' | 'tri-bl' | 'tri-br' | 'solid' | 'diamond' | 'small-r' | 'small-l' | 'arrow-r' | 'arrow-l' | 'house-d' | 'half-l' | 'half-t';
|
|
14
|
+
export declare const PATTERN_MOTIFS: Record<PatternMotifKey, (fg: string) => string>;
|
|
15
|
+
export declare const MOTIF_KEYS: PatternMotifKey[];
|
|
16
|
+
/** Chevron family — orientations + size variants + arrows. */
|
|
17
|
+
export declare const CHEV_KEYS: PatternMotifKey[];
|
|
18
|
+
/** Triangle / half-fill family. */
|
|
19
|
+
export declare const TRI_KEYS: PatternMotifKey[];
|
|
20
|
+
/** Center shape family (currently solo diamond). */
|
|
21
|
+
export declare const SHAPE_KEYS: PatternMotifKey[];
|
|
22
|
+
/** No-foreground tiles — solo el rect de fondo. */
|
|
23
|
+
export declare const SOLID_KEYS: PatternMotifKey[];
|
|
24
|
+
/** Built-in palettes — dark → light (8 colors). */
|
|
25
|
+
export type PatternPaletteKey = 'purple' | 'ink' | 'lavender';
|
|
26
|
+
export declare const PATTERN_PALETTES: Record<PatternPaletteKey, string[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Mulberry32 seeded RNG — devuelve función `()=>[0,1)`.
|
|
29
|
+
* Deterministic: mismo seed → misma secuencia. Útil para patrones reproducibles.
|
|
30
|
+
*/
|
|
31
|
+
export declare function mulberry32(seed: number): () => number;
|
|
32
|
+
/**
|
|
33
|
+
* Densidad de chevrons (0..1). El resto se reparte entre solid (20%), shape
|
|
34
|
+
* (15%) y tri (resto), proporcional al gap left después del threshold.
|
|
35
|
+
*/
|
|
36
|
+
export interface PatternGenConfig {
|
|
37
|
+
cols: number;
|
|
38
|
+
rows: number;
|
|
39
|
+
seed: number;
|
|
40
|
+
palette: string[];
|
|
41
|
+
chevronDensity?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface PatternTile {
|
|
44
|
+
motif: PatternMotifKey;
|
|
45
|
+
bg: string;
|
|
46
|
+
fg: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Genera UN tile con motif/bg/fg respetando densidades + contraste.
|
|
50
|
+
* Caller pasa rng (Math.random o seeded) — útil para reshuffle individual de
|
|
51
|
+
* tiles en `val-pattern` sin regenerar la grid completa.
|
|
52
|
+
*/
|
|
53
|
+
export declare function generateRandomTile(palette: string[], chevronDensity?: number, rng?: () => number): PatternTile;
|
|
54
|
+
/** Genera matriz de tiles aplicando densidades + reglas de contraste. */
|
|
55
|
+
export declare function generatePatternTiles(cfg: PatternGenConfig): PatternTile[];
|
|
56
|
+
/**
|
|
57
|
+
* Renderiza el inner SVG (sin el `<svg>` root) para una matriz de tiles.
|
|
58
|
+
* Caller wraps en `<svg viewBox="0 0 {cols*100} {rows*100}" preserveAspectRatio="xMidYMid slice">`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function renderPatternSvgInner(tiles: PatternTile[], cols: number, baseColor: string): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { OnDestroy } from '@angular/core';
|
|
2
|
+
import { SafeHtml } from '@angular/platform-browser';
|
|
3
|
+
import { PatternMetadata } from './types';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* `val-pattern`
|
|
7
|
+
*
|
|
8
|
+
* Componente de fondo geométrico inspirado en el sistema Valtech. Renderiza un
|
|
9
|
+
* grid de tiles 100×100 con motifs (chevrons, triangles, diamonds, arrows) en
|
|
10
|
+
* un SVG inline. Determinista vía `seed` o animado vía `reshuffle`.
|
|
11
|
+
*
|
|
12
|
+
* Cero dependencias externas — todo SVG.
|
|
13
|
+
*
|
|
14
|
+
* @example Como fondo de card (CSS absolute):
|
|
15
|
+
* ```scss
|
|
16
|
+
* .card { position: relative; overflow: hidden; }
|
|
17
|
+
* .card val-pattern { position: absolute; inset: 0; z-index: 0; opacity: 0.4; }
|
|
18
|
+
* .card .content { position: relative; z-index: 1; }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* ```html
|
|
22
|
+
* <div class="card">
|
|
23
|
+
* <val-pattern [props]="{ palette: 'purple', cols: 6, rows: 3, seed: 42 }" />
|
|
24
|
+
* <div class="content">Tu contenido aquí</div>
|
|
25
|
+
* </div>
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example Como background animado (hero/login):
|
|
29
|
+
* ```html
|
|
30
|
+
* <val-pattern [props]="{ palette: 'lavender', cols: 16, rows: 8, animated: true }" />
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class PatternComponent implements OnDestroy {
|
|
34
|
+
private sanitizer;
|
|
35
|
+
private readonly cols;
|
|
36
|
+
private readonly rows;
|
|
37
|
+
private readonly seed;
|
|
38
|
+
private readonly paletteRef;
|
|
39
|
+
private readonly chevronDensity;
|
|
40
|
+
private readonly preserveAspect;
|
|
41
|
+
private readonly animated;
|
|
42
|
+
/** ms entre updates individuales de tiles (modo animated). Default 1200ms. */
|
|
43
|
+
private readonly reshuffleInterval;
|
|
44
|
+
/** Cuántos tiles cambiar por tick (default 1 → cambio sutil). */
|
|
45
|
+
private readonly tilesPerTick;
|
|
46
|
+
private timer?;
|
|
47
|
+
/** Object-first input. Cambios disparan re-render por signals. */
|
|
48
|
+
set props(value: PatternMetadata | undefined);
|
|
49
|
+
/**
|
|
50
|
+
* Tiles signal — mutable. Se regenera completa cuando cambia seed/cols/rows/
|
|
51
|
+
* palette/density. En modo animated, tiles individuales se sobrescriben sin
|
|
52
|
+
* tocar el resto (efecto staggered).
|
|
53
|
+
*/
|
|
54
|
+
private readonly tiles;
|
|
55
|
+
/** SVG completo como string sanitized para `[innerHTML]`. */
|
|
56
|
+
readonly svgHtml: import("@angular/core").Signal<SafeHtml>;
|
|
57
|
+
constructor();
|
|
58
|
+
/**
|
|
59
|
+
* Reemplaza `count` tiles random del grid actual con tiles nuevos generados.
|
|
60
|
+
* Usado por el modo animated para staggered reshuffle.
|
|
61
|
+
*/
|
|
62
|
+
private mutateRandomTiles;
|
|
63
|
+
ngOnDestroy(): void;
|
|
64
|
+
private resolvePalette;
|
|
65
|
+
private randomSeed;
|
|
66
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PatternComponent, never>;
|
|
67
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<PatternComponent, "val-pattern", never, { "props": { "alias": "props"; "required": false; }; }, {}, never, never, true, never>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PatternPaletteKey } from './motifs';
|
|
2
|
+
/**
|
|
3
|
+
* Configuración del componente `val-pattern`.
|
|
4
|
+
*
|
|
5
|
+
* @example Static (seed fijo, reproducible):
|
|
6
|
+
* ```html
|
|
7
|
+
* <val-pattern [props]="{ palette: 'purple', cols: 12, rows: 4, seed: 42 }" />
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @example Animated staggered (1 tile cada 1.2s, sutil):
|
|
11
|
+
* ```html
|
|
12
|
+
* <val-pattern [props]="{ palette: 'ink', cols: 16, rows: 8, animated: true }" />
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @example Animated más activo (2 tiles cada 800ms):
|
|
16
|
+
* ```html
|
|
17
|
+
* <val-pattern [props]="{ animated: true, reshuffleInterval: 800, tilesPerTick: 2 }" />
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export interface PatternMetadata {
|
|
21
|
+
/**
|
|
22
|
+
* Palette built-in (`'purple' | 'ink' | 'lavender'`) o array custom de 8
|
|
23
|
+
* colores dark → light. Default: `'purple'`.
|
|
24
|
+
*/
|
|
25
|
+
palette?: PatternPaletteKey | string[];
|
|
26
|
+
/** Columnas del grid. Default: 12. */
|
|
27
|
+
cols?: number;
|
|
28
|
+
/** Filas del grid. Default: 4. */
|
|
29
|
+
rows?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Seed para Mulberry32 — determina el patrón. Si no se pasa, genera uno random
|
|
32
|
+
* al mount y queda fijo (a menos que `animated: true`).
|
|
33
|
+
*/
|
|
34
|
+
seed?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Densidad de chevrons (0..1). El resto se reparte entre solid/shape/tri.
|
|
37
|
+
* Default: `0.55`.
|
|
38
|
+
*/
|
|
39
|
+
chevronDensity?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Si `true`, el patrón hace **staggered reshuffle**: cada `reshuffleInterval`
|
|
42
|
+
* ms se reemplazan `tilesPerTick` tiles random — NO la grid entera.
|
|
43
|
+
* Default: `false`.
|
|
44
|
+
*/
|
|
45
|
+
animated?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* ms entre updates individuales de tiles (modo animated).
|
|
48
|
+
* Default: `1200` (~1 tile cada 1.2s con `tilesPerTick: 1`).
|
|
49
|
+
*/
|
|
50
|
+
reshuffleInterval?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Cuántos tiles cambiar por tick (modo animated). Default: `1` (cambio sutil).
|
|
53
|
+
* Subir a 2-4 para efecto más vivo.
|
|
54
|
+
*/
|
|
55
|
+
tilesPerTick?: number;
|
|
56
|
+
/**
|
|
57
|
+
* `slice` (default) — el patrón cubre todo el contenedor manteniendo aspect,
|
|
58
|
+
* cropeando si necesario. `meet` — fit completo sin crop, deja espacio.
|
|
59
|
+
*/
|
|
60
|
+
preserveAspect?: 'slice' | 'meet';
|
|
61
|
+
}
|
package/lib/version.d.ts
CHANGED
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -41,6 +41,9 @@ export * from './lib/components/atoms/horizontal-scroll/horizontal-scroll.compon
|
|
|
41
41
|
export * from './lib/components/atoms/horizontal-scroll/types';
|
|
42
42
|
export * from './lib/components/atoms/rights-footer/rights-footer.component';
|
|
43
43
|
export * from './lib/components/atoms/rights-footer/types';
|
|
44
|
+
export * from './lib/components/atoms/pattern/pattern.component';
|
|
45
|
+
export * from './lib/components/atoms/pattern/types';
|
|
46
|
+
export * from './lib/components/atoms/pattern/motifs';
|
|
44
47
|
export * from './lib/components/molecules/alert-box/alert-box.component';
|
|
45
48
|
export * from './lib/components/molecules/alert-box/types';
|
|
46
49
|
export * from './lib/components/molecules/button-group/button-group.component';
|