tosijs-ui 1.5.10 → 1.5.12
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/dist/icons.d.ts +4 -0
- package/dist/icons.js +21 -6
- package/dist/iife.js +17 -17
- package/dist/iife.js.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
package/dist/icons.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ export interface IconRule {
|
|
|
9
9
|
apply: (baseName: string, match: RegExpMatchArray | string, parts: ElementPart[]) => Element | string | null;
|
|
10
10
|
}
|
|
11
11
|
export declare const iconRules: IconRule[];
|
|
12
|
+
/** Wrap icon elements in a composite container (for custom function rules) */
|
|
13
|
+
export declare function wrapIcon(prop: string, parts: ElementPart[], ...children: Element[]): HTMLSpanElement;
|
|
14
|
+
/** Resolve an icon name through the full pipeline (redirects, suffixes, rules, stacking) */
|
|
15
|
+
export declare function resolveIcon(prop: string, parts: ElementPart[]): Element;
|
|
12
16
|
export declare const icons: SVGIconMap;
|
|
13
17
|
export declare class SvgIcon extends WebComponent {
|
|
14
18
|
static preferredTagName: string;
|
package/dist/icons.js
CHANGED
|
@@ -428,7 +428,9 @@ viewBox** for best results on non-square base icons.
|
|
|
428
428
|
`iconRules` is a mutable array. Each rule has a `prefix` (string or
|
|
429
429
|
RegExp) and an `apply` function that returns a **string** (resolved
|
|
430
430
|
through the full pipeline), an **Element** (used directly), or **null**
|
|
431
|
-
(skip to next rule)
|
|
431
|
+
(skip to next rule).
|
|
432
|
+
|
|
433
|
+
String rewrites are the simplest — just return a composition string:
|
|
432
434
|
|
|
433
435
|
// String rewrite: addFoo → plus75o_0000ffS$foo75s50o
|
|
434
436
|
iconRules.push({
|
|
@@ -436,16 +438,24 @@ through the full pipeline), an **Element** (used directly), or **null**
|
|
|
436
438
|
apply: (baseName) => `plus75o_0000ffS$${baseName}75s50o`,
|
|
437
439
|
})
|
|
438
440
|
|
|
439
|
-
|
|
441
|
+
Function rules can use `resolveIcon()` and `wrapIcon()` (both exported)
|
|
442
|
+
for more control:
|
|
443
|
+
|
|
444
|
+
// Function rule: glowNNFoo → foo with brightness filter
|
|
440
445
|
iconRules.push({
|
|
441
446
|
prefix: /^glow(\d+)/,
|
|
442
447
|
apply: (baseName, match, parts) => {
|
|
443
448
|
const icon = resolveIcon(baseName, parts)
|
|
444
449
|
icon.style.filter = `brightness(${match[1]}%)`
|
|
445
|
-
return icon
|
|
450
|
+
return wrapIcon(baseName, parts, icon)
|
|
446
451
|
},
|
|
447
452
|
})
|
|
448
453
|
|
|
454
|
+
- `resolveIcon(name, parts)` — resolve any icon name through the full
|
|
455
|
+
pipeline (redirects, suffixes, rules, stacking)
|
|
456
|
+
- `wrapIcon(name, parts, ...children)` — wrap elements in a composite
|
|
457
|
+
container with proper sizing, `pointer-events: none`, and `data-icon`
|
|
458
|
+
|
|
449
459
|
### Building an icon vocabulary
|
|
450
460
|
|
|
451
461
|
You don't need to spell out the DSL every time. The real power is in
|
|
@@ -632,7 +642,8 @@ function makeIcon(spec, parts) {
|
|
|
632
642
|
svg.style.height = varDefault.tosiIconSize('16px');
|
|
633
643
|
return svg;
|
|
634
644
|
}
|
|
635
|
-
|
|
645
|
+
/** Wrap icon elements in a composite container (for custom function rules) */
|
|
646
|
+
export function wrapIcon(prop, parts, ...children) {
|
|
636
647
|
const wrapper = elements.span({
|
|
637
648
|
class: 'tosi-icon-composite',
|
|
638
649
|
dataIcon: prop,
|
|
@@ -783,7 +794,8 @@ function parseStyleSuffixes(name) {
|
|
|
783
794
|
}
|
|
784
795
|
return { baseName, style };
|
|
785
796
|
}
|
|
786
|
-
|
|
797
|
+
/** Resolve an icon name through the full pipeline (redirects, suffixes, rules, stacking) */
|
|
798
|
+
export function resolveIcon(prop, parts) {
|
|
787
799
|
if (prop.endsWith('_'))
|
|
788
800
|
prop = prop.slice(0, -1);
|
|
789
801
|
const data = iconData;
|
|
@@ -813,7 +825,10 @@ function resolveIcon(prop, parts) {
|
|
|
813
825
|
const segments = prop.split('$');
|
|
814
826
|
// Last segment is the base (sets the size), rest are overlays
|
|
815
827
|
const base = resolveIcon(segments[segments.length - 1], []);
|
|
816
|
-
const overlays = segments
|
|
828
|
+
const overlays = segments
|
|
829
|
+
.slice(0, -1)
|
|
830
|
+
.reverse()
|
|
831
|
+
.map((name) => {
|
|
817
832
|
const icon = resolveIcon(name, []);
|
|
818
833
|
Object.assign(icon.style, {
|
|
819
834
|
position: 'absolute',
|