@fuzdev/fuz_ui 0.201.0 → 0.202.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.
package/src/lib/svg.ts CHANGED
@@ -1,23 +1,84 @@
1
1
  import type {SvelteHTMLElements} from 'svelte/elements';
2
2
 
3
+ /**
4
+ * A structured icon definition rendered by `Svg.svelte`. Rendering is purely
5
+ * structural - typed fields, never raw markup - so untrusted data cannot
6
+ * introduce script execution or navigation. See `Svg.svelte` for the full
7
+ * security notes, including the residual `style` `url(...)` caveat.
8
+ */
3
9
  export interface SvgData {
4
10
  /**
5
- * Raw svg markup string that's inserted unsafely as a child of the `svg` element.
6
- * This is an escape hatch for non-`path` markup -
7
- * generally, you should instead use the `paths` property to avoid security/CSP implications.
11
+ * List of svg `path` attribute objects, spread onto each `path` element. The
12
+ * `d` attribute is required; a per-path `fill` overrides the resolved `fill`.
8
13
  */
9
- raw?: string | null;
14
+ paths?: Array<{d: string} & SvelteHTMLElements['path']> | null;
10
15
  /**
11
- * List of svg `path` attribute objects. The `d` attribute is required.
16
+ * Inline `style` applied to the root `svg` element, merged with any `style`
17
+ * passed as a component prop. Travels with the icon definition - per-instance
18
+ * svg attributes belong on the `Svg` component itself.
19
+ */
20
+ style?: string | null;
21
+ /**
22
+ * Default `fill` for every `path`, falling back to `var(--text_color, #000)`.
23
+ * Overridden by the component's `fill` prop, and per-path by a path's own `fill`.
12
24
  */
13
- paths?: Array<{d: string} & SvelteHTMLElements['path']> | null;
14
- attrs?: SvelteHTMLElements['svg'] | null;
15
25
  fill?: string | null;
16
- width?: string | null;
17
- height?: string | null;
26
+ /**
27
+ * Accessible name, applied as `aria-label`. Overridden by the component's `label` prop.
28
+ */
18
29
  label?: string | null;
19
30
  /**
20
31
  * Defaults to `"0 0 100 100"`.
21
32
  */
22
33
  viewBox?: string | null;
34
+ /**
35
+ * Gradient definitions rendered into the svg's `<defs>` block. This is the
36
+ * structured replacement for raw markup - reference a gradient from a
37
+ * path/shape `fill` or `stroke` with `url(#id)`. Most svgs need only `paths`.
38
+ */
39
+ gradients?: Array<SvgGradient> | null;
40
+ }
41
+
42
+ /**
43
+ * A gradient definition rendered into the svg's `<defs>` block. Reference it
44
+ * from a path/shape `fill` or `stroke` with `url(#id)`.
45
+ */
46
+ export interface SvgGradient {
47
+ /**
48
+ * Whether to render a `linearGradient` or `radialGradient` element.
49
+ */
50
+ type: 'linear' | 'radial';
51
+ /**
52
+ * The `id` referenced by a `fill`/`stroke` like `url(#id)`. Inline svgs share
53
+ * the document's id namespace, so pick a value unique to the icon - icons
54
+ * with colliding ids all resolve to whichever element renders first.
55
+ */
56
+ id: string;
57
+ /**
58
+ * The gradient's color stops.
59
+ */
60
+ stops: Array<SvgGradientStop>;
61
+ /**
62
+ * Additional attributes on the gradient element, e.g. `gradientUnits`,
63
+ * `gradientTransform`, `cx`/`cy`/`r` (radial), or `x1`/`y1`/`x2`/`y2` (linear).
64
+ */
65
+ attrs?: (SvelteHTMLElements['radialGradient'] & SvelteHTMLElements['linearGradient']) | null;
66
+ }
67
+
68
+ /**
69
+ * A single color stop of an `SvgGradient`.
70
+ */
71
+ export interface SvgGradientStop {
72
+ /**
73
+ * The stop's position along the gradient, e.g. `0.5` or `"50%"`.
74
+ */
75
+ offset: string | number;
76
+ /**
77
+ * The stop's color, applied as the `stop-color` attribute.
78
+ */
79
+ color: string;
80
+ /**
81
+ * The stop's opacity, applied as the `stop-opacity` attribute.
82
+ */
83
+ opacity?: string | number | null;
23
84
  }