@luxalgo/vela-ui 0.2.0 → 0.4.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/CHANGELOG.md +153 -91
- package/LICENSE +201 -201
- package/NOTICE +28 -28
- package/README.md +86 -86
- package/cli/engine.mjs +282 -282
- package/cli/index.mjs +154 -154
- package/dist/badge.js +1 -1
- package/dist/bar-chart.d.ts +1 -1
- package/dist/bar-chart.js +1 -1
- package/dist/button.d.ts +1 -1
- package/dist/button.js +4 -4
- package/dist/callout-bubble.d.ts +1 -1
- package/dist/callout-bubble.js +4 -4
- package/dist/card.d.ts +52 -0
- package/dist/card.js +179 -0
- package/dist/checkbox.js +5 -5
- package/dist/{chunk-B5ZSRUDQ.js → chunk-BWSOMG3G.js} +2 -2
- package/dist/{chunk-G7IQLY3A.js → chunk-C3PXY2SW.js} +5 -0
- package/dist/{chunk-CC3DDNFC.js → chunk-DXDCKZ2M.js} +4 -4
- package/dist/chunk-GUIYFQ27.js +30 -0
- package/dist/{chunk-WGULXRWD.js → chunk-KUWTI2PE.js} +4 -4
- package/dist/{chunk-Z5PINFQO.js → chunk-QGWAN3EP.js} +5 -5
- package/dist/{chunk-V2Q4MRMS.js → chunk-RH53NQGE.js} +30 -4
- package/dist/{chunk-WBGSYCV2.js → chunk-SKFAYTDK.js} +4 -4
- package/dist/{chunk-MJ4RUGX7.js → chunk-TGJNHUYV.js} +3 -3
- package/dist/{chunk-WXH3EFV5.js → chunk-VC7SVSDK.js} +4 -4
- package/dist/{chunk-7VMN7NKJ.js → chunk-YT2BSP7O.js} +3 -3
- package/dist/collapsible.d.ts +1 -1
- package/dist/collapsible.js +3 -3
- package/dist/color-picker.js +5 -5
- package/dist/context-menu.js +5 -5
- package/dist/data-table.d.ts +1 -1
- package/dist/data-table.js +1 -1
- package/dist/date-picker.d.ts +1 -1
- package/dist/date-picker.js +2 -2
- package/dist/dialog.d.ts +9 -1
- package/dist/dialog.js +15 -5
- package/dist/donut.d.ts +1 -1
- package/dist/donut.js +1 -1
- package/dist/drawer.d.ts +1 -1
- package/dist/drawer.js +2 -2
- package/dist/dropdown-menu.d.ts +1 -1
- package/dist/dropdown-menu.js +5 -5
- package/dist/empty.d.ts +1 -1
- package/dist/empty.js +2 -2
- package/dist/field.js +13 -13
- package/dist/{stat.d.ts → figure.d.ts} +9 -9
- package/dist/figure.js +41 -0
- package/dist/glyph-select.js +5 -5
- package/dist/hover-card.d.ts +1 -1
- package/dist/hover-card.js +3 -3
- package/dist/icons.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -3
- package/dist/input-group.d.ts +1 -1
- package/dist/input-group.js +4 -4
- package/dist/input.js +2 -2
- package/dist/item.d.ts +1 -1
- package/dist/item.js +2 -2
- package/dist/kbd.d.ts +1 -1
- package/dist/kbd.js +2 -2
- package/dist/line-chart.d.ts +1 -1
- package/dist/line-chart.js +1 -1
- package/dist/manifest.json +691 -74
- package/dist/month-grid.js +1 -1
- package/dist/number-input.d.ts +1 -1
- package/dist/number-input.js +5 -5
- package/dist/popover.js +3 -3
- package/dist/scatter-chart.d.ts +1 -1
- package/dist/scatter-chart.js +1 -1
- package/dist/select.d.ts +1 -1
- package/dist/select.js +7 -7
- package/dist/slider.d.ts +1 -1
- package/dist/slider.js +2 -2
- package/dist/sort-button.js +4 -4
- package/dist/sparkline.d.ts +1 -1
- package/dist/sparkline.js +1 -1
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +3 -3
- package/dist/tabs.d.ts +1 -1
- package/dist/tabs.js +4 -4
- package/dist/text-area.d.ts +1 -1
- package/dist/text-area.js +2 -2
- package/dist/theme-TefB8vtl.d.ts +341 -0
- package/dist/theme.d.ts +42 -192
- package/dist/theme.js +1 -1
- package/dist/theme.schema.json +321 -30
- package/dist/toast.d.ts +49 -0
- package/dist/toast.js +463 -0
- package/dist/toggle-group.d.ts +1 -1
- package/dist/toggle-group.js +4 -4
- package/dist/tooltip.js +2 -2
- package/dist/treemap.d.ts +80 -0
- package/dist/treemap.js +470 -0
- package/dist/zag.d.ts +11 -2
- package/dist/zag.js +1 -1
- package/docs/theming.md +217 -217
- package/docs/what-to-change.md +20 -20
- package/docs/writing-a-component.md +250 -250
- package/llms.txt +6 -3
- package/package.json +90 -90
- package/registry/badge.ts +119 -119
- package/registry/bar-chart.ts +215 -215
- package/registry/button.ts +387 -379
- package/registry/callout-bubble.ts +347 -347
- package/registry/card.ts +379 -0
- package/registry/checkbox.ts +234 -234
- package/registry/collapsible.ts +271 -271
- package/registry/color-picker.ts +582 -582
- package/registry/context-menu.ts +208 -208
- package/registry/data-table.ts +215 -215
- package/registry/date-picker.ts +483 -483
- package/registry/dialog.ts +551 -535
- package/registry/donut.ts +145 -145
- package/registry/drawer.ts +636 -636
- package/registry/dropdown-menu.ts +762 -762
- package/registry/empty.ts +91 -91
- package/registry/field.ts +584 -584
- package/registry/{stat.ts → figure.ts} +96 -96
- package/registry/glyph-select.ts +268 -268
- package/registry/hover-card.ts +222 -222
- package/registry/input-group.ts +229 -229
- package/registry/input.ts +181 -181
- package/registry/item.ts +376 -376
- package/registry/kbd.ts +64 -64
- package/registry/line-chart.ts +218 -218
- package/registry/month-grid.ts +328 -328
- package/registry/number-input.ts +443 -443
- package/registry/popover.ts +368 -368
- package/registry/scatter-chart.ts +221 -221
- package/registry/select.ts +620 -620
- package/registry/slider.ts +259 -259
- package/registry/sort-button.ts +189 -189
- package/registry/sparkline.ts +114 -114
- package/registry/switch.ts +205 -205
- package/registry/tabs.ts +426 -426
- package/registry/text-area.ts +186 -186
- package/registry/toast.ts +965 -0
- package/registry/toggle-group.ts +295 -295
- package/registry/tooltip.ts +156 -156
- package/registry/treemap.ts +847 -0
- package/skills/theming-vela-ui/SKILL.md +137 -137
- package/skills/using-vela-ui-components/SKILL.md +139 -137
- package/skills/writing-vela-ui-components/SKILL.md +163 -163
- package/src/components/badge.ts +119 -119
- package/src/components/bar-chart.ts +215 -215
- package/src/components/button.ts +387 -379
- package/src/components/callout-bubble.ts +347 -347
- package/src/components/card.ts +379 -0
- package/src/components/checkbox.ts +234 -234
- package/src/components/collapsible.ts +271 -271
- package/src/components/color-picker.ts +582 -582
- package/src/components/context-menu.ts +208 -208
- package/src/components/data-table.ts +215 -215
- package/src/components/date-picker.ts +483 -483
- package/src/components/dialog.ts +551 -535
- package/src/components/donut.ts +145 -145
- package/src/components/drawer.ts +636 -636
- package/src/components/dropdown-menu.ts +762 -762
- package/src/components/empty.ts +91 -91
- package/src/components/field.ts +584 -584
- package/src/components/{stat.ts → figure.ts} +96 -96
- package/src/components/glyph-select.ts +268 -268
- package/src/components/hover-card.ts +222 -222
- package/src/components/input-group.ts +229 -229
- package/src/components/input.ts +181 -181
- package/src/components/item.ts +376 -376
- package/src/components/kbd.ts +64 -64
- package/src/components/line-chart.ts +218 -218
- package/src/components/month-grid.ts +328 -328
- package/src/components/number-input.ts +443 -443
- package/src/components/popover.ts +368 -368
- package/src/components/scatter-chart.ts +221 -221
- package/src/components/select.ts +620 -620
- package/src/components/slider.ts +259 -259
- package/src/components/sort-button.ts +189 -189
- package/src/components/sparkline.ts +114 -114
- package/src/components/switch.ts +205 -205
- package/src/components/tabs.ts +426 -426
- package/src/components/text-area.ts +186 -186
- package/src/components/toast.ts +965 -0
- package/src/components/toggle-group.ts +295 -295
- package/src/components/tooltip.ts +156 -156
- package/src/components/treemap.ts +847 -0
- package/src/index.ts +24 -24
- package/src/lib/calendar.ts +117 -117
- package/src/lib/chart.ts +72 -72
- package/src/lib/color.ts +89 -89
- package/src/lib/component-index.ts +163 -151
- package/src/lib/css.ts +48 -48
- package/src/lib/define.ts +45 -45
- package/src/lib/dispose.ts +36 -36
- package/src/lib/h.ts +55 -55
- package/src/lib/headless.ts +16 -16
- package/src/lib/i18n.ts +30 -30
- package/src/lib/icons.ts +244 -237
- package/src/lib/kit-text.ts +26 -26
- package/src/lib/page.ts +24 -24
- package/src/lib/palette.ts +81 -81
- package/src/lib/placement.ts +188 -188
- package/src/lib/scope.ts +135 -135
- package/src/lib/styles.ts +53 -53
- package/src/lib/surface-events.ts +31 -31
- package/src/lib/surface-exit.ts +87 -87
- package/src/lib/t.ts +68 -68
- package/src/lib/theme.ts +684 -664
- package/src/lib/tokens.ts +110 -110
- package/src/lib/variants.ts +32 -32
- package/src/lib/zag.ts +61 -46
- package/stylelint/index.mjs +60 -60
- package/stylelint/lint.mjs +81 -81
- package/stylelint/plugin.mjs +115 -115
- package/dist/chunk-P4MTEMT7.js +0 -23
- package/dist/stat.js +0 -41
- package/dist/{chunk-U3EH42YY.js → chunk-5BJV5FY5.js} +1 -1
- package/dist/{chunk-E2FE6V2N.js → chunk-ALAHGSLC.js} +1 -1
- package/dist/{chunk-C3ICYMI3.js → chunk-FYVQO5TN.js} +1 -1
package/src/lib/icons.ts
CHANGED
|
@@ -1,237 +1,244 @@
|
|
|
1
|
-
// The icon registry — self-contained inline SVGs, no icon font, no CDN, as PURE STRING DATA so
|
|
2
|
-
// the kit, a chart's own chrome and its widget all draw from one set instead of each keeping
|
|
3
|
-
// its own inline copies. `iconEl` at the end is the DOM helper.
|
|
4
|
-
//
|
|
5
|
-
// The registry is page-wide (see `page.ts`): an icon registered through one copy of the kit
|
|
6
|
-
// draws through every other.
|
|
7
|
-
//
|
|
8
|
-
// TWO TIERS, one apparent weight:
|
|
9
|
-
// tier A — 16×16 grid, stroke 1.2 ({@link svg16}): UI chrome (menus, panels, top bar).
|
|
10
|
-
// tier B — 24×24 grid, stroke 1.8 ({@link svg24}): drawing tools and the toolbars around
|
|
11
|
-
// them, where the glyph is a miniature of the geometry it draws.
|
|
12
|
-
// 1.2/16 and 1.8/24 are the same fraction of the grid, so a tier-A and a tier-B icon at the
|
|
13
|
-
// same rendered size read equally heavy. Every icon strokes `currentColor` and inherits its
|
|
14
|
-
// size from the slot (`1em`), so callers style icons by color and font-size alone.
|
|
15
|
-
|
|
16
|
-
import { pageState } from './page';
|
|
17
|
-
|
|
18
|
-
const registry = pageState('icons@1', () => new Map<string, string>());
|
|
19
|
-
|
|
20
|
-
/** Register (or replace) an icon's raw `<svg>` markup under an id. */
|
|
21
|
-
export function registerIcon(id: string, svg: string): void {
|
|
22
|
-
registry.set(id, svg);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** The raw `<svg>` markup for an id, or null. */
|
|
26
|
-
export function iconMarkup(id: string): string | null {
|
|
27
|
-
return registry.get(id) ?? null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** The markup for an id, or empty markup — for the `innerHTML` sites that always want a
|
|
31
|
-
* string. An unknown id renders nothing rather than breaking the surrounding chrome. */
|
|
32
|
-
export function icon(id: string): string {
|
|
33
|
-
return registry.get(id) ?? '';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** {@link icon} pinned to an explicit pixel size, for slots that cannot inherit one (a
|
|
37
|
-
* glyph dropped into a row whose font-size belongs to the text beside it). */
|
|
38
|
-
export function iconAt(id: string, px: number): string {
|
|
39
|
-
return icon(id).replace('<svg ', `<svg width="${px}" height="${px}" `);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// `extra` is emitted BEFORE the tier defaults: HTML keeps the first of a duplicated
|
|
43
|
-
// attribute, so an icon that needs a filled root or a heavier stroke overrides the tier
|
|
44
|
-
// rather than being silently ignored.
|
|
45
|
-
|
|
46
|
-
/** Tier A: a 16×16 chrome icon. `extra` overrides root attributes (e.g. a filled variant). */
|
|
47
|
-
export function svg16(body: string, extra = ''): string {
|
|
48
|
-
return `<svg viewBox="0 0 16 16" width="1em" height="1em" ${extra ? extra + ' ' : ''}fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">${body}</svg>`;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Tier B: a 24×24 drawing-tool icon. `extra` overrides root attributes. */
|
|
52
|
-
export function svg24(body: string, extra = ''): string {
|
|
53
|
-
return `<svg viewBox="0 0 24 24" width="1em" height="1em" ${extra ? extra + ' ' : ''}fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">${body}</svg>`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** A tier-B glyph drawn as a solid shape rather than a stroke (grips, dots, carets). */
|
|
57
|
-
export function svg24Solid(body: string): string {
|
|
58
|
-
return `<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none">${body}</svg>`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const S = svg16;
|
|
62
|
-
|
|
63
|
-
// ── chart-type icons (style-<id>) ──
|
|
64
|
-
registerIcon(
|
|
65
|
-
'style-candles',
|
|
66
|
-
S('<path d="M4.5 2v2M4.5 12v2M11.5 2v1.5M11.5 11v3"/><rect x="2.8" y="4" width="3.4" height="8" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="3.5" width="3.4" height="7.5" rx="0.6" fill="currentColor"/>'),
|
|
67
|
-
);
|
|
68
|
-
registerIcon(
|
|
69
|
-
'style-bars',
|
|
70
|
-
S('<path d="M4.5 2.5v11M2.5 5h2M4.5 11h2"/><path d="M11.5 2.5v11M9.5 4.5h2M11.5 10.5h2"/>'),
|
|
71
|
-
);
|
|
72
|
-
registerIcon('style-line', S('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/>'));
|
|
73
|
-
registerIcon(
|
|
74
|
-
'style-area',
|
|
75
|
-
S('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/><path d="M1.5 11.5 5.5 7l3 2.5 5-6V13.5h-12z" fill="currentColor" fill-opacity="0.25" stroke="none"/>'),
|
|
76
|
-
);
|
|
77
|
-
registerIcon(
|
|
78
|
-
'style-baseline',
|
|
79
|
-
S('<path d="M1.5 8h13" stroke-dasharray="2 2"/><path d="M2.5 8 5.25 4.5 8 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M2.5 8 5.25 4.5 8 8"/><path d="M8 8l2.75 3.5L13.5 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M8 8l2.75 3.5L13.5 8"/>'),
|
|
80
|
-
);
|
|
81
|
-
registerIcon(
|
|
82
|
-
'style-heikinashi',
|
|
83
|
-
S('<path d="M4.5 12v2M11.5 2v2"/><rect x="2.8" y="5" width="3.4" height="7" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="4" width="3.4" height="7" rx="0.6" fill="currentColor"/>'),
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// ── widget chrome icons ──
|
|
87
|
-
registerIcon('indicators', S('<path d="M1.5 12.5 5 7l2.5 3.5L11 4l3.5 5"/><circle cx="11" cy="4" r="1.4" fill="currentColor" stroke="none"/>'));
|
|
88
|
-
registerIcon('undo', S('<path d="M6.2 9.5 2.7 6l3.5-3.5"/><path d="M2.7 6h6.8a3.65 3.65 0 0 1 0 7.3H7.5"/>'));
|
|
89
|
-
registerIcon('redo', S('<path d="M9.8 9.5 13.3 6 9.8 2.5"/><path d="M13.3 6H6.5a3.65 3.65 0 0 0 0 7.3h2"/>'));
|
|
90
|
-
registerIcon(
|
|
91
|
-
'objects',
|
|
92
|
-
S('<path d="M8 1.8 14 5 8 8.2 2 5z"/><path d="M2 8l6 3.2L14 8" opacity="0.7"/><path d="M2 11l6 3.2 6-3.2" opacity="0.4"/>'),
|
|
93
|
-
);
|
|
94
|
-
registerIcon('clock', S('<circle cx="8" cy="8" r="6.2"/><path d="M8 4.8V8l2.4 1.6"/>'));
|
|
95
|
-
registerIcon(
|
|
96
|
-
'calendar',
|
|
97
|
-
S('<rect x="2.2" y="3.2" width="11.6" height="10.6" rx="1.4"/><path d="M5.2 1.8v2.8M10.8 1.8v2.8M2.2 6.8h11.6"/>'),
|
|
98
|
-
);
|
|
99
|
-
registerIcon('datawindow', S('<rect x="1.8" y="2.5" width="12.4" height="11" rx="1.5"/><path d="M4.5 5.5h4M4.5 8h7M4.5 10.5h5.5"/>'));
|
|
100
|
-
registerIcon('camera', S('<path d="M5.5 4 6.5 2.5h3L10.5 4h3A1 1 0 0 1 14.5 5v7.5a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1z"/><circle cx="8" cy="8.5" r="2.6"/>'));
|
|
101
|
-
registerIcon(
|
|
102
|
-
'gear',
|
|
103
|
-
S('<path d="M6.55 1.4h2.9l.32 1.72c.48.14.92.38 1.3.7l1.66-.55 1.45 2.5-1.35 1.1c.08.34.12.7.12 1.07s-.04.73-.12 1.07l1.35 1.1-1.45 2.5-1.66-.55a4.3 4.3 0 0 1-1.3.7L9.45 14.6h-2.9l-.32-1.72a4.3 4.3 0 0 1-1.3-.7l-1.66.55-1.45-2.5 1.35-1.1A4.4 4.4 0 0 1 3.05 7.94c0-.37.04-.73.12-1.07l-1.35-1.1 1.45-2.5 1.66.55c.38-.32.82-.56 1.3-.7L6.55 1.4z"/><circle cx="8" cy="8" r="2.2"/>'),
|
|
104
|
-
);
|
|
105
|
-
registerIcon('search', S('<circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/>'));
|
|
106
|
-
registerIcon('bell', S('<path d="M8 2a4 4 0 0 0-4 4v2.5L2.5 11v1h11v-1L12 8.5V6a4 4 0 0 0-4-4z"/><path d="M6.5 13.5a1.5 1.5 0 0 0 3 0"/>'));
|
|
107
|
-
|
|
108
|
-
// ── market status (statusline badge): sun / sunrise / sunset / moon / holiday ──
|
|
109
|
-
// 24-grid bodies at the tier-B stroke — 1.8/24 carries the same apparent weight as the
|
|
110
|
-
// 16-grid chrome icons, so the badge glyph sits evenly beside them.
|
|
111
|
-
registerIcon(
|
|
112
|
-
'market-open',
|
|
113
|
-
svg24('<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>'),
|
|
114
|
-
);
|
|
115
|
-
registerIcon(
|
|
116
|
-
'market-pre',
|
|
117
|
-
svg24('<path d="M12 2v8"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m8 6 4-4 4 4"/><path d="M16 18a4 4 0 0 0-8 0"/>'),
|
|
118
|
-
);
|
|
119
|
-
registerIcon(
|
|
120
|
-
'market-post',
|
|
121
|
-
svg24('<path d="M12 10V2"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m16 14-4 4-4-4"/><path d="M16 6a4 4 0 0 0-8 0"/>'),
|
|
122
|
-
);
|
|
123
|
-
registerIcon(
|
|
124
|
-
'market-extended',
|
|
125
|
-
svg24('<path d="M22 22H2"/><path d="M12 3a5 5 0 0 0 7.5 7.5A7.5 7.5 0 1 1 12 3Z"/>'),
|
|
126
|
-
);
|
|
127
|
-
registerIcon('market-closed', svg24('<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>'));
|
|
128
|
-
registerIcon(
|
|
129
|
-
'market-holiday',
|
|
130
|
-
svg24('<path d="m10 20-1.25-2.5L6 16"/><path d="M10 4 8.75 6.5 6 8"/><path d="m14 20 1.25-2.5L18 16"/><path d="m14 4 1.25 2.5L18 8"/><path d="m17 10-5 5-5-5"/><path d="M4 12h16"/>'),
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
// ── disclosure, row actions and menu verbs (side panels, nested menus) ──
|
|
134
|
-
registerIcon('chevron-right', S('<path d="m6 3.5 4.5 4.5L6 12.5"/>'));
|
|
135
|
-
registerIcon('chevron-left', S('<path d="M10 3.5 5.5 8l4.5 4.5"/>'));
|
|
136
|
-
registerIcon('chevron-down', S('<path d="M3.5 6 8 10.5 12.5 6"/>'));
|
|
137
|
-
registerIcon('chevron-up', S('<path d="M3.5 10 8 5.5 12.5 10"/>'));
|
|
138
|
-
registerIcon('chevrons-right', S('<path d="m4 3.5 4.5 4.5L4 12.5"/><path d="m8.5 3.5 4.5 4.5-4.5 4.5"/>'));
|
|
139
|
-
registerIcon('chevrons-left', S('<path d="M12 3.5 7.5 8l4.5 4.5"/><path d="M7.5 3.5 3 8l4.5 4.5"/>'));
|
|
140
|
-
// Bar replay: two left-pointing triangles.
|
|
141
|
-
registerIcon('replay', S('<path d="M14 4.2v7.6L8.6 8z"/><path d="M7.4 4.2v7.6L2 8z"/>'));
|
|
142
|
-
registerIcon('check', S('<path d="m2.8 8.4 3.4 3.4 7-7.6"/>'));
|
|
143
|
-
registerIcon('close', S('<path d="m3.8 3.8 8.4 8.4M12.2 3.8l-8.4 8.4"/>'));
|
|
144
|
-
// A pushpin — outline while something floats (press to pin it), filled once pinned.
|
|
145
|
-
registerIcon('pin', S('<path d="M5.6 2.5h4.8M6.4 2.5v3.6L4.4 8.4v.9h7.2v-.9L9.6 6.1V2.5M8 9.3v4.2"/>'));
|
|
146
|
-
registerIcon('pin-filled', S('<path d="M5.6 2.5h4.8M6.4 2.5v3.6L4.4 8.4v.9h7.2v-.9L9.6 6.1V2.5M8 9.3v4.2"/><path d="M6.4 2.5h3.2v3.6l2 2.3v.9H4.4v-.9l2-2.3z" fill="currentColor" stroke="none"/>'));
|
|
147
|
-
registerIcon('eye', S('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>'));
|
|
148
|
-
registerIcon('eye-off', S('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z" opacity="0.45"/><path d="m3 13 10-10"/>'));
|
|
149
|
-
registerIcon('lock', S('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.8 0V7"/>'));
|
|
150
|
-
registerIcon('unlock', S('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.7-.7"/>'));
|
|
151
|
-
registerIcon('trash', S('<path d="M2.5 4.3h11M6.2 4.3V3.1a1 1 0 0 1 1-1h1.6a1 1 0 0 1 1 1v1.2M4.2 4.3l.5 9.1a1.15 1.15 0 0 0 1.15 1.1h4.3a1.15 1.15 0 0 0 1.15-1.1l.5-9.1M6.5 7v4.5M9.5 7v4.5"/>'));
|
|
152
|
-
registerIcon('group', S('<path d="M1.8 4.5V2.4a.6.6 0 0 1 .6-.6h2.1M11.5 1.8h2.1a.6.6 0 0 1 .6.6v2.1M14.2 11.5v2.1a.6.6 0 0 1-.6.6h-2.1M4.5 14.2H2.4a.6.6 0 0 1-.6-.6v-2.1"/><rect x="4" y="4" width="4.2" height="4.2" rx="0.7"/><rect x="7.8" y="7.8" width="4.2" height="4.2" rx="0.7"/>'));
|
|
153
|
-
registerIcon('ungroup', S('<rect x="1.6" y="1.6" width="6.2" height="6.2" rx="0.9"/><rect x="8.2" y="8.2" width="6.2" height="6.2" rx="0.9" stroke-dasharray="2 1.5"/>'));
|
|
154
|
-
registerIcon('clone', S('<rect x="5.5" y="5.5" width="9" height="9" rx="1.2"/><path d="M11 5.5v-3a1 1 0 0 0-1-1H2.5a1 1 0 0 0-1 1V10a1 1 0 0 0 1 1h3"/>'));
|
|
155
|
-
registerIcon('arrow-up', S('<path d="M8 13.2V3M4.2 6.8 8 3l3.8 3.8"/>'));
|
|
156
|
-
registerIcon('arrow-down', S('<path d="M8 2.8V13M4.2 9.2 8 13l3.8-3.8"/>'));
|
|
157
|
-
registerIcon('move-vertical', S('<path d="M8 2.5v11M5 5.5 8 2.5l3 3M5 10.5l3 3 3-3"/>'));
|
|
158
|
-
registerIcon('move', S('<path d="M8 1.8v12.4M1.8 8h12.4M5.6 4.2 8 1.8l2.4 2.4M5.6 11.8 8 14.2l2.4-2.4M4.2 5.6 1.8 8l2.4 2.4M11.8 5.6 14.2 8l-2.4 2.4"/>'));
|
|
159
|
-
registerIcon('pen', S('<path d="m10.8 2.2 3 3-8 8-3.6.6.6-3.6z"/><path d="m9.2 3.8 3 3"/>'));
|
|
160
|
-
registerIcon('wave', S('<path d="M1.5 10.4c1.6 0 1.9-4.8 3.4-4.8s1.8 4.8 3.4 4.8 1.8-4.8 3.4-4.8 1.6 4.8 2.8 4.8"/>'));
|
|
161
|
-
registerIcon('folder-plus', S('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M8 7.6v3.6M6.2 9.4h3.6"/>'));
|
|
162
|
-
registerIcon('folder-minus', S('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M6.2 9.4h3.6"/>'));
|
|
163
|
-
registerIcon('collapse', S('<path d="M3 8h10"/>'));
|
|
164
|
-
registerIcon('expand', S('<rect x="2.2" y="2.2" width="11.6" height="11.6" rx="1.4"/><path d="M8 5.4v5.2M5.4 8h5.2"/>'));
|
|
165
|
-
registerIcon('plus', S('<path d="M8 2.8v10.4M2.8 8h10.4"/>'));
|
|
166
|
-
registerIcon('minus', S('<path d="M2.8 8h10.4"/>'));
|
|
167
|
-
registerIcon('maximize', S('<path d="M2.5 6V3a.5.5 0 0 1 .5-.5h3M10 2.5h3a.5.5 0 0 1 .5.5v3M13.5 10v3a.5.5 0 0 1-.5.5h-3M6 13.5H3a.5.5 0 0 1-.5-.5v-3"/>'));
|
|
168
|
-
// The inverse of `maximize`: the four corners turned inward.
|
|
169
|
-
registerIcon('restore', S('<path d="M6 2.5v3a.5.5 0 0 1-.5.5h-3M13.5 6h-3a.5.5 0 0 1-.5-.5v-3M10 13.5v-3a.5.5 0 0 1 .5-.5h3M2.5 10h3a.5.5 0 0 1 .5.5v3"/>'));
|
|
170
|
-
registerIcon('restore', S('<path d="M6.2 2.5v3.7H2.5M9.8 13.5V9.8h3.7M13.5 6.2H9.8V2.5M2.5 9.8h3.7v3.7"/>'));
|
|
171
|
-
registerIcon('star', S('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>'));
|
|
172
|
-
registerIcon('star-filled', S('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>', 'fill="currentColor"'));
|
|
173
|
-
registerIcon('grip', S('<circle cx="6" cy="3.5" r="1"/><circle cx="10" cy="3.5" r="1"/><circle cx="6" cy="8" r="1"/><circle cx="10" cy="8" r="1"/><circle cx="6" cy="12.5" r="1"/><circle cx="10" cy="12.5" r="1"/>', 'fill="currentColor" stroke="none"'));
|
|
174
|
-
registerIcon('kebab', S('<circle cx="8" cy="3.2" r="1.2"/><circle cx="8" cy="8" r="1.2"/><circle cx="8" cy="12.8" r="1.2"/>', 'fill="currentColor" stroke="none"'));
|
|
175
|
-
registerIcon('burger', S('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));
|
|
176
|
-
// The ⓘ hint glyph: an "i" drawn as geometry (dot + stem) so it centers exactly in its
|
|
177
|
-
// badge — a text "i" would sit at the font's mercy. The badge draws the circle.
|
|
178
|
-
registerIcon('info', S('<path d="M8 7.4v4.4"/><circle cx="8" cy="4.6" r="0.9" fill="currentColor" stroke="none"/>'));
|
|
179
|
-
registerIcon('reset', S('<path d="M2 8a6 6 0 1 0 6-6 6.5 6.5 0 0 0-4.5 1.83L2 5.33"/><path d="M2 2v3.33h3.33"/>'));
|
|
180
|
-
|
|
181
|
-
// ──
|
|
182
|
-
registerIcon('
|
|
183
|
-
registerIcon('
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
registerIcon('
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
'
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
'
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
'
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
registerIcon('
|
|
216
|
-
registerIcon(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
);
|
|
223
|
-
registerIcon('
|
|
224
|
-
registerIcon('
|
|
225
|
-
registerIcon('
|
|
226
|
-
registerIcon(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
1
|
+
// The icon registry — self-contained inline SVGs, no icon font, no CDN, as PURE STRING DATA so
|
|
2
|
+
// the kit, a chart's own chrome and its widget all draw from one set instead of each keeping
|
|
3
|
+
// its own inline copies. `iconEl` at the end is the DOM helper.
|
|
4
|
+
//
|
|
5
|
+
// The registry is page-wide (see `page.ts`): an icon registered through one copy of the kit
|
|
6
|
+
// draws through every other.
|
|
7
|
+
//
|
|
8
|
+
// TWO TIERS, one apparent weight:
|
|
9
|
+
// tier A — 16×16 grid, stroke 1.2 ({@link svg16}): UI chrome (menus, panels, top bar).
|
|
10
|
+
// tier B — 24×24 grid, stroke 1.8 ({@link svg24}): drawing tools and the toolbars around
|
|
11
|
+
// them, where the glyph is a miniature of the geometry it draws.
|
|
12
|
+
// 1.2/16 and 1.8/24 are the same fraction of the grid, so a tier-A and a tier-B icon at the
|
|
13
|
+
// same rendered size read equally heavy. Every icon strokes `currentColor` and inherits its
|
|
14
|
+
// size from the slot (`1em`), so callers style icons by color and font-size alone.
|
|
15
|
+
|
|
16
|
+
import { pageState } from './page';
|
|
17
|
+
|
|
18
|
+
const registry = pageState('icons@1', () => new Map<string, string>());
|
|
19
|
+
|
|
20
|
+
/** Register (or replace) an icon's raw `<svg>` markup under an id. */
|
|
21
|
+
export function registerIcon(id: string, svg: string): void {
|
|
22
|
+
registry.set(id, svg);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The raw `<svg>` markup for an id, or null. */
|
|
26
|
+
export function iconMarkup(id: string): string | null {
|
|
27
|
+
return registry.get(id) ?? null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The markup for an id, or empty markup — for the `innerHTML` sites that always want a
|
|
31
|
+
* string. An unknown id renders nothing rather than breaking the surrounding chrome. */
|
|
32
|
+
export function icon(id: string): string {
|
|
33
|
+
return registry.get(id) ?? '';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** {@link icon} pinned to an explicit pixel size, for slots that cannot inherit one (a
|
|
37
|
+
* glyph dropped into a row whose font-size belongs to the text beside it). */
|
|
38
|
+
export function iconAt(id: string, px: number): string {
|
|
39
|
+
return icon(id).replace('<svg ', `<svg width="${px}" height="${px}" `);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// `extra` is emitted BEFORE the tier defaults: HTML keeps the first of a duplicated
|
|
43
|
+
// attribute, so an icon that needs a filled root or a heavier stroke overrides the tier
|
|
44
|
+
// rather than being silently ignored.
|
|
45
|
+
|
|
46
|
+
/** Tier A: a 16×16 chrome icon. `extra` overrides root attributes (e.g. a filled variant). */
|
|
47
|
+
export function svg16(body: string, extra = ''): string {
|
|
48
|
+
return `<svg viewBox="0 0 16 16" width="1em" height="1em" ${extra ? extra + ' ' : ''}fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">${body}</svg>`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Tier B: a 24×24 drawing-tool icon. `extra` overrides root attributes. */
|
|
52
|
+
export function svg24(body: string, extra = ''): string {
|
|
53
|
+
return `<svg viewBox="0 0 24 24" width="1em" height="1em" ${extra ? extra + ' ' : ''}fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">${body}</svg>`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A tier-B glyph drawn as a solid shape rather than a stroke (grips, dots, carets). */
|
|
57
|
+
export function svg24Solid(body: string): string {
|
|
58
|
+
return `<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none">${body}</svg>`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const S = svg16;
|
|
62
|
+
|
|
63
|
+
// ── chart-type icons (style-<id>) ──
|
|
64
|
+
registerIcon(
|
|
65
|
+
'style-candles',
|
|
66
|
+
S('<path d="M4.5 2v2M4.5 12v2M11.5 2v1.5M11.5 11v3"/><rect x="2.8" y="4" width="3.4" height="8" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="3.5" width="3.4" height="7.5" rx="0.6" fill="currentColor"/>'),
|
|
67
|
+
);
|
|
68
|
+
registerIcon(
|
|
69
|
+
'style-bars',
|
|
70
|
+
S('<path d="M4.5 2.5v11M2.5 5h2M4.5 11h2"/><path d="M11.5 2.5v11M9.5 4.5h2M11.5 10.5h2"/>'),
|
|
71
|
+
);
|
|
72
|
+
registerIcon('style-line', S('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/>'));
|
|
73
|
+
registerIcon(
|
|
74
|
+
'style-area',
|
|
75
|
+
S('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/><path d="M1.5 11.5 5.5 7l3 2.5 5-6V13.5h-12z" fill="currentColor" fill-opacity="0.25" stroke="none"/>'),
|
|
76
|
+
);
|
|
77
|
+
registerIcon(
|
|
78
|
+
'style-baseline',
|
|
79
|
+
S('<path d="M1.5 8h13" stroke-dasharray="2 2"/><path d="M2.5 8 5.25 4.5 8 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M2.5 8 5.25 4.5 8 8"/><path d="M8 8l2.75 3.5L13.5 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M8 8l2.75 3.5L13.5 8"/>'),
|
|
80
|
+
);
|
|
81
|
+
registerIcon(
|
|
82
|
+
'style-heikinashi',
|
|
83
|
+
S('<path d="M4.5 12v2M11.5 2v2"/><rect x="2.8" y="5" width="3.4" height="7" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="4" width="3.4" height="7" rx="0.6" fill="currentColor"/>'),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
// ── widget chrome icons ──
|
|
87
|
+
registerIcon('indicators', S('<path d="M1.5 12.5 5 7l2.5 3.5L11 4l3.5 5"/><circle cx="11" cy="4" r="1.4" fill="currentColor" stroke="none"/>'));
|
|
88
|
+
registerIcon('undo', S('<path d="M6.2 9.5 2.7 6l3.5-3.5"/><path d="M2.7 6h6.8a3.65 3.65 0 0 1 0 7.3H7.5"/>'));
|
|
89
|
+
registerIcon('redo', S('<path d="M9.8 9.5 13.3 6 9.8 2.5"/><path d="M13.3 6H6.5a3.65 3.65 0 0 0 0 7.3h2"/>'));
|
|
90
|
+
registerIcon(
|
|
91
|
+
'objects',
|
|
92
|
+
S('<path d="M8 1.8 14 5 8 8.2 2 5z"/><path d="M2 8l6 3.2L14 8" opacity="0.7"/><path d="M2 11l6 3.2 6-3.2" opacity="0.4"/>'),
|
|
93
|
+
);
|
|
94
|
+
registerIcon('clock', S('<circle cx="8" cy="8" r="6.2"/><path d="M8 4.8V8l2.4 1.6"/>'));
|
|
95
|
+
registerIcon(
|
|
96
|
+
'calendar',
|
|
97
|
+
S('<rect x="2.2" y="3.2" width="11.6" height="10.6" rx="1.4"/><path d="M5.2 1.8v2.8M10.8 1.8v2.8M2.2 6.8h11.6"/>'),
|
|
98
|
+
);
|
|
99
|
+
registerIcon('datawindow', S('<rect x="1.8" y="2.5" width="12.4" height="11" rx="1.5"/><path d="M4.5 5.5h4M4.5 8h7M4.5 10.5h5.5"/>'));
|
|
100
|
+
registerIcon('camera', S('<path d="M5.5 4 6.5 2.5h3L10.5 4h3A1 1 0 0 1 14.5 5v7.5a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1z"/><circle cx="8" cy="8.5" r="2.6"/>'));
|
|
101
|
+
registerIcon(
|
|
102
|
+
'gear',
|
|
103
|
+
S('<path d="M6.55 1.4h2.9l.32 1.72c.48.14.92.38 1.3.7l1.66-.55 1.45 2.5-1.35 1.1c.08.34.12.7.12 1.07s-.04.73-.12 1.07l1.35 1.1-1.45 2.5-1.66-.55a4.3 4.3 0 0 1-1.3.7L9.45 14.6h-2.9l-.32-1.72a4.3 4.3 0 0 1-1.3-.7l-1.66.55-1.45-2.5 1.35-1.1A4.4 4.4 0 0 1 3.05 7.94c0-.37.04-.73.12-1.07l-1.35-1.1 1.45-2.5 1.66.55c.38-.32.82-.56 1.3-.7L6.55 1.4z"/><circle cx="8" cy="8" r="2.2"/>'),
|
|
104
|
+
);
|
|
105
|
+
registerIcon('search', S('<circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/>'));
|
|
106
|
+
registerIcon('bell', S('<path d="M8 2a4 4 0 0 0-4 4v2.5L2.5 11v1h11v-1L12 8.5V6a4 4 0 0 0-4-4z"/><path d="M6.5 13.5a1.5 1.5 0 0 0 3 0"/>'));
|
|
107
|
+
|
|
108
|
+
// ── market status (statusline badge): sun / sunrise / sunset / moon / holiday ──
|
|
109
|
+
// 24-grid bodies at the tier-B stroke — 1.8/24 carries the same apparent weight as the
|
|
110
|
+
// 16-grid chrome icons, so the badge glyph sits evenly beside them.
|
|
111
|
+
registerIcon(
|
|
112
|
+
'market-open',
|
|
113
|
+
svg24('<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>'),
|
|
114
|
+
);
|
|
115
|
+
registerIcon(
|
|
116
|
+
'market-pre',
|
|
117
|
+
svg24('<path d="M12 2v8"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m8 6 4-4 4 4"/><path d="M16 18a4 4 0 0 0-8 0"/>'),
|
|
118
|
+
);
|
|
119
|
+
registerIcon(
|
|
120
|
+
'market-post',
|
|
121
|
+
svg24('<path d="M12 10V2"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m16 14-4 4-4-4"/><path d="M16 6a4 4 0 0 0-8 0"/>'),
|
|
122
|
+
);
|
|
123
|
+
registerIcon(
|
|
124
|
+
'market-extended',
|
|
125
|
+
svg24('<path d="M22 22H2"/><path d="M12 3a5 5 0 0 0 7.5 7.5A7.5 7.5 0 1 1 12 3Z"/>'),
|
|
126
|
+
);
|
|
127
|
+
registerIcon('market-closed', svg24('<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>'));
|
|
128
|
+
registerIcon(
|
|
129
|
+
'market-holiday',
|
|
130
|
+
svg24('<path d="m10 20-1.25-2.5L6 16"/><path d="M10 4 8.75 6.5 6 8"/><path d="m14 20 1.25-2.5L18 16"/><path d="m14 4 1.25 2.5L18 8"/><path d="m17 10-5 5-5-5"/><path d="M4 12h16"/>'),
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// ── disclosure, row actions and menu verbs (side panels, nested menus) ──
|
|
134
|
+
registerIcon('chevron-right', S('<path d="m6 3.5 4.5 4.5L6 12.5"/>'));
|
|
135
|
+
registerIcon('chevron-left', S('<path d="M10 3.5 5.5 8l4.5 4.5"/>'));
|
|
136
|
+
registerIcon('chevron-down', S('<path d="M3.5 6 8 10.5 12.5 6"/>'));
|
|
137
|
+
registerIcon('chevron-up', S('<path d="M3.5 10 8 5.5 12.5 10"/>'));
|
|
138
|
+
registerIcon('chevrons-right', S('<path d="m4 3.5 4.5 4.5L4 12.5"/><path d="m8.5 3.5 4.5 4.5-4.5 4.5"/>'));
|
|
139
|
+
registerIcon('chevrons-left', S('<path d="M12 3.5 7.5 8l4.5 4.5"/><path d="M7.5 3.5 3 8l4.5 4.5"/>'));
|
|
140
|
+
// Bar replay: two left-pointing triangles.
|
|
141
|
+
registerIcon('replay', S('<path d="M14 4.2v7.6L8.6 8z"/><path d="M7.4 4.2v7.6L2 8z"/>'));
|
|
142
|
+
registerIcon('check', S('<path d="m2.8 8.4 3.4 3.4 7-7.6"/>'));
|
|
143
|
+
registerIcon('close', S('<path d="m3.8 3.8 8.4 8.4M12.2 3.8l-8.4 8.4"/>'));
|
|
144
|
+
// A pushpin — outline while something floats (press to pin it), filled once pinned.
|
|
145
|
+
registerIcon('pin', S('<path d="M5.6 2.5h4.8M6.4 2.5v3.6L4.4 8.4v.9h7.2v-.9L9.6 6.1V2.5M8 9.3v4.2"/>'));
|
|
146
|
+
registerIcon('pin-filled', S('<path d="M5.6 2.5h4.8M6.4 2.5v3.6L4.4 8.4v.9h7.2v-.9L9.6 6.1V2.5M8 9.3v4.2"/><path d="M6.4 2.5h3.2v3.6l2 2.3v.9H4.4v-.9l2-2.3z" fill="currentColor" stroke="none"/>'));
|
|
147
|
+
registerIcon('eye', S('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>'));
|
|
148
|
+
registerIcon('eye-off', S('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z" opacity="0.45"/><path d="m3 13 10-10"/>'));
|
|
149
|
+
registerIcon('lock', S('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.8 0V7"/>'));
|
|
150
|
+
registerIcon('unlock', S('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.7-.7"/>'));
|
|
151
|
+
registerIcon('trash', S('<path d="M2.5 4.3h11M6.2 4.3V3.1a1 1 0 0 1 1-1h1.6a1 1 0 0 1 1 1v1.2M4.2 4.3l.5 9.1a1.15 1.15 0 0 0 1.15 1.1h4.3a1.15 1.15 0 0 0 1.15-1.1l.5-9.1M6.5 7v4.5M9.5 7v4.5"/>'));
|
|
152
|
+
registerIcon('group', S('<path d="M1.8 4.5V2.4a.6.6 0 0 1 .6-.6h2.1M11.5 1.8h2.1a.6.6 0 0 1 .6.6v2.1M14.2 11.5v2.1a.6.6 0 0 1-.6.6h-2.1M4.5 14.2H2.4a.6.6 0 0 1-.6-.6v-2.1"/><rect x="4" y="4" width="4.2" height="4.2" rx="0.7"/><rect x="7.8" y="7.8" width="4.2" height="4.2" rx="0.7"/>'));
|
|
153
|
+
registerIcon('ungroup', S('<rect x="1.6" y="1.6" width="6.2" height="6.2" rx="0.9"/><rect x="8.2" y="8.2" width="6.2" height="6.2" rx="0.9" stroke-dasharray="2 1.5"/>'));
|
|
154
|
+
registerIcon('clone', S('<rect x="5.5" y="5.5" width="9" height="9" rx="1.2"/><path d="M11 5.5v-3a1 1 0 0 0-1-1H2.5a1 1 0 0 0-1 1V10a1 1 0 0 0 1 1h3"/>'));
|
|
155
|
+
registerIcon('arrow-up', S('<path d="M8 13.2V3M4.2 6.8 8 3l3.8 3.8"/>'));
|
|
156
|
+
registerIcon('arrow-down', S('<path d="M8 2.8V13M4.2 9.2 8 13l3.8-3.8"/>'));
|
|
157
|
+
registerIcon('move-vertical', S('<path d="M8 2.5v11M5 5.5 8 2.5l3 3M5 10.5l3 3 3-3"/>'));
|
|
158
|
+
registerIcon('move', S('<path d="M8 1.8v12.4M1.8 8h12.4M5.6 4.2 8 1.8l2.4 2.4M5.6 11.8 8 14.2l2.4-2.4M4.2 5.6 1.8 8l2.4 2.4M11.8 5.6 14.2 8l-2.4 2.4"/>'));
|
|
159
|
+
registerIcon('pen', S('<path d="m10.8 2.2 3 3-8 8-3.6.6.6-3.6z"/><path d="m9.2 3.8 3 3"/>'));
|
|
160
|
+
registerIcon('wave', S('<path d="M1.5 10.4c1.6 0 1.9-4.8 3.4-4.8s1.8 4.8 3.4 4.8 1.8-4.8 3.4-4.8 1.6 4.8 2.8 4.8"/>'));
|
|
161
|
+
registerIcon('folder-plus', S('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M8 7.6v3.6M6.2 9.4h3.6"/>'));
|
|
162
|
+
registerIcon('folder-minus', S('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M6.2 9.4h3.6"/>'));
|
|
163
|
+
registerIcon('collapse', S('<path d="M3 8h10"/>'));
|
|
164
|
+
registerIcon('expand', S('<rect x="2.2" y="2.2" width="11.6" height="11.6" rx="1.4"/><path d="M8 5.4v5.2M5.4 8h5.2"/>'));
|
|
165
|
+
registerIcon('plus', S('<path d="M8 2.8v10.4M2.8 8h10.4"/>'));
|
|
166
|
+
registerIcon('minus', S('<path d="M2.8 8h10.4"/>'));
|
|
167
|
+
registerIcon('maximize', S('<path d="M2.5 6V3a.5.5 0 0 1 .5-.5h3M10 2.5h3a.5.5 0 0 1 .5.5v3M13.5 10v3a.5.5 0 0 1-.5.5h-3M6 13.5H3a.5.5 0 0 1-.5-.5v-3"/>'));
|
|
168
|
+
// The inverse of `maximize`: the four corners turned inward.
|
|
169
|
+
registerIcon('restore', S('<path d="M6 2.5v3a.5.5 0 0 1-.5.5h-3M13.5 6h-3a.5.5 0 0 1-.5-.5v-3M10 13.5v-3a.5.5 0 0 1 .5-.5h3M2.5 10h3a.5.5 0 0 1 .5.5v3"/>'));
|
|
170
|
+
registerIcon('restore', S('<path d="M6.2 2.5v3.7H2.5M9.8 13.5V9.8h3.7M13.5 6.2H9.8V2.5M2.5 9.8h3.7v3.7"/>'));
|
|
171
|
+
registerIcon('star', S('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>'));
|
|
172
|
+
registerIcon('star-filled', S('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>', 'fill="currentColor"'));
|
|
173
|
+
registerIcon('grip', S('<circle cx="6" cy="3.5" r="1"/><circle cx="10" cy="3.5" r="1"/><circle cx="6" cy="8" r="1"/><circle cx="10" cy="8" r="1"/><circle cx="6" cy="12.5" r="1"/><circle cx="10" cy="12.5" r="1"/>', 'fill="currentColor" stroke="none"'));
|
|
174
|
+
registerIcon('kebab', S('<circle cx="8" cy="3.2" r="1.2"/><circle cx="8" cy="8" r="1.2"/><circle cx="8" cy="12.8" r="1.2"/>', 'fill="currentColor" stroke="none"'));
|
|
175
|
+
registerIcon('burger', S('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));
|
|
176
|
+
// The ⓘ hint glyph: an "i" drawn as geometry (dot + stem) so it centers exactly in its
|
|
177
|
+
// badge — a text "i" would sit at the font's mercy. The badge draws the circle.
|
|
178
|
+
registerIcon('info', S('<path d="M8 7.4v4.4"/><circle cx="8" cy="4.6" r="0.9" fill="currentColor" stroke="none"/>'));
|
|
179
|
+
registerIcon('reset', S('<path d="M2 8a6 6 0 1 0 6-6 6.5 6.5 0 0 0-4.5 1.83L2 5.33"/><path d="M2 2v3.33h3.33"/>'));
|
|
180
|
+
|
|
181
|
+
// ── status glyphs (toasts, notices) ──
|
|
182
|
+
registerIcon('circle-check', S('<circle cx="8" cy="8" r="6.2"/><path d="m5.4 8.2 1.8 1.8 3.4-3.7"/>'));
|
|
183
|
+
registerIcon('circle-info', S('<circle cx="8" cy="8" r="6.2"/><path d="M8 7.4v3.6"/><circle cx="8" cy="5.1" r="0.8" fill="currentColor" stroke="none"/>'));
|
|
184
|
+
registerIcon('triangle-alert', S('<path d="M7.1 2.6a1 1 0 0 1 1.8 0l5.3 9.6a1 1 0 0 1-.9 1.5H2.7a1 1 0 0 1-.9-1.5z"/><path d="M8 6.3v3.2"/><circle cx="8" cy="11.4" r="0.8" fill="currentColor" stroke="none"/>'));
|
|
185
|
+
registerIcon('circle-x', S('<circle cx="8" cy="8" r="6.2"/><path d="m5.9 5.9 4.2 4.2M10.1 5.9l-4.2 4.2"/>'));
|
|
186
|
+
registerIcon('loader', S('<path d="M8 1.8a6.2 6.2 0 1 0 6.2 6.2"/>'));
|
|
187
|
+
|
|
188
|
+
// ── pane chrome (stack order, collapse, maximize) ──
|
|
189
|
+
registerIcon('pane-collapse', S('<path d="M2.6 9.4h4v4M13.4 6.6h-4v-4"/><path d="m9.4 6.6 4.2-4.2M2.4 13.6l4.2-4.2"/>'));
|
|
190
|
+
registerIcon('pane-expand', S('<path d="M9.8 2.4h3.8v3.8M6.2 13.6H2.4V9.8"/><path d="m13.6 2.4-4.4 4.4M2.4 13.6l4.4-4.4"/>'));
|
|
191
|
+
|
|
192
|
+
// ── drawing tools and their toolbars (tier B) ──
|
|
193
|
+
registerIcon('cursor', svg24('<path d="M5 3l6 16 2-6 6-2z"/>', 'fill="currentColor" stroke="none"'));
|
|
194
|
+
registerIcon(
|
|
195
|
+
'ruler',
|
|
196
|
+
svg24('<path d="M21.3 15.3 8.7 2.7a1 1 0 0 0-1.4 0L2.7 7.3a1 1 0 0 0 0 1.4l12.6 12.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4Z"/><path d="m7.5 10.5 2 2"/><path d="m10.5 7.5 2 2"/><path d="m13.5 4.5 2 2"/><path d="m4.5 13.5 2 2"/>'),
|
|
197
|
+
);
|
|
198
|
+
registerIcon(
|
|
199
|
+
'magnet',
|
|
200
|
+
svg24('<path d="m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15"/><path d="m5 8 4 4"/><path d="m12 15 4 4"/>'),
|
|
201
|
+
);
|
|
202
|
+
registerIcon(
|
|
203
|
+
'eraser',
|
|
204
|
+
svg24('<path d="m7 21-4.3-4.3a1 1 0 0 1 0-1.4L13 5a2 2 0 0 1 2.8 0l4.2 4.2a2 2 0 0 1 0 2.8L12 20"/><path d="M22 21H7"/><path d="m5 11 9 9"/>'),
|
|
205
|
+
);
|
|
206
|
+
registerIcon(
|
|
207
|
+
'pen-lock',
|
|
208
|
+
svg24('<path d="M13.8 4.2a2.1 2.1 0 0 1 3 3L8.5 15.5l-3.5 1 1-3.5Z"/><rect x="13" y="14.5" width="8" height="6" rx="1.2"/><path d="M15 14.5v-1.6a2 2 0 0 1 4 0v1.6"/>'),
|
|
209
|
+
);
|
|
210
|
+
registerIcon(
|
|
211
|
+
'pen-sync',
|
|
212
|
+
// Pen + two stacked panes — drawing onto every linked chart at once.
|
|
213
|
+
svg24('<path d="M13.8 4.2a2.1 2.1 0 0 1 3 3L8.5 15.5l-3.5 1 1-3.5Z"/><rect x="12.5" y="13.5" width="6" height="4.8" rx="1"/><path d="M15.5 18.3v1a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-2.8a1 1 0 0 0-1-1h-1"/>'),
|
|
214
|
+
);
|
|
215
|
+
registerIcon('brush', svg24('<path d="M9.5 12 17 4.5a2.12 2.12 0 0 1 3 3L12.5 15"/><path d="M7 14a3 3 0 0 0-3 3c0 1.3-1.2 1.5-1.5 2 .8.9 2 1.5 3.5 1.5a3.5 3.5 0 0 0 3.5-3.5 3 3 0 0 0-2.5-3Z"/>'));
|
|
216
|
+
registerIcon(
|
|
217
|
+
'bucket',
|
|
218
|
+
svg24('<path d="m18.5 11.5-7-7L4 12a1.8 1.8 0 0 0 0 2.5l5 5a1.8 1.8 0 0 0 2.5 0Z"/><path d="m5 5 4 4"/><path d="M3.5 13.5h13"/><path d="M21 17.5c0 1.1-.9 2-2 2s-2-.9-2-2c0-1 1.2-1.7 2-3 .8 1.3 2 2 2 3Z"/>'),
|
|
219
|
+
);
|
|
220
|
+
registerIcon('type', svg24('<path d="M5 6V4.5h14V6"/><path d="M12 4.5v15"/><path d="M9.5 19.5h5"/>'));
|
|
221
|
+
registerIcon('bold', svg24('<path d="M7 5h6a3.5 3.5 0 0 1 0 7H7Z"/><path d="M7 12h7a3.5 3.5 0 0 1 0 7H7Z"/>', 'stroke-width="2.4"'));
|
|
222
|
+
registerIcon('italic', svg24('<path d="M15 5h-5M14 19H9M14.5 5 10 19"/>', 'stroke-width="2.2"'));
|
|
223
|
+
registerIcon('price-delta', svg24('<path d="M12 4v16"/><path d="M8 8l4-4 4 4"/><path d="M8 16l4 4 4-4"/>'));
|
|
224
|
+
registerIcon('date-delta', svg24('<path d="M4 12h16"/><path d="M8 8l-4 4 4 4"/><path d="M16 8l4 4-4 4"/>'));
|
|
225
|
+
registerIcon('bring-front', svg24('<rect x="8.5" y="8.5" width="7" height="7" rx="1.5"/><path d="M4.5 10.5V6a1.5 1.5 0 0 1 1.5-1.5h4.5"/><path d="M19.5 13.5V18a1.5 1.5 0 0 1-1.5 1.5h-4.5"/>'));
|
|
226
|
+
registerIcon(
|
|
227
|
+
'send-back',
|
|
228
|
+
svg24('<rect x="8.5" y="8.5" width="7" height="7" rx="1.5" fill="currentColor" stroke="none" opacity="0.35"/><path d="M4.5 10.5V6a1.5 1.5 0 0 1 1.5-1.5h4.5"/><path d="M19.5 13.5V18a1.5 1.5 0 0 1-1.5 1.5h-4.5"/><rect x="8.5" y="8.5" width="7" height="7" rx="1.5"/>'),
|
|
229
|
+
);
|
|
230
|
+
registerIcon('r-squared', '<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none"><text x="2.5" y="17.5" font-size="14" font-family="serif">R²</text></svg>');
|
|
231
|
+
registerIcon('bands', svg24('<path d="M3 6h18"/><path d="M3 18h18"/><path d="M3 12h18" stroke-dasharray="3 3"/>'));
|
|
232
|
+
registerIcon('dedekind', svg24('<path d="M2 20h20"/><path d="M4 20a8 8 0 0 1 16 0"/><path d="M8 20a4 4 0 0 1 8 0"/><path d="M12 4v16"/>'));
|
|
233
|
+
registerIcon('sonic', svg24('<circle cx="15" cy="12" r="4"/><circle cx="12" cy="12" r="2.5"/><path d="M8 5v14"/>'));
|
|
234
|
+
registerIcon('supersonic', svg24('<circle cx="16" cy="12" r="3.5"/><path d="M6 12 15 6M6 12 15 18"/>'));
|
|
235
|
+
|
|
236
|
+
/** A ready-to-insert element rendering the icon (empty span when unknown). */
|
|
237
|
+
export function iconEl(id: string, doc: Document = document): HTMLElement {
|
|
238
|
+
const span = doc.createElement('span');
|
|
239
|
+
span.className = 'vela-icon';
|
|
240
|
+
span.setAttribute('aria-hidden', 'true');
|
|
241
|
+
const svg = iconMarkup(id);
|
|
242
|
+
if (svg) span.innerHTML = svg;
|
|
243
|
+
return span;
|
|
244
|
+
}
|
package/src/lib/kit-text.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
// The language of the UI kit's own words: a stepper's name, the color picker's opacity
|
|
2
|
-
// label, a menu star's name. A kit control takes a translator in its options; a chart
|
|
3
|
-
// building many controls at once (a settings dialog) runs the build inside
|
|
4
|
-
// `withKitTranslator`, and each control built there keeps that translator, so a popover
|
|
5
|
-
// it opens later speaks the same language. Anywhere else the kit speaks English. The scope is
|
|
6
|
-
// page-wide, so controls from another copy of the kit built inside it speak it too.
|
|
7
|
-
import type { Translator } from './i18n';
|
|
8
|
-
import { pageState } from './page';
|
|
9
|
-
|
|
10
|
-
const scope = pageState('kit-text@1', () => ({ current: null as Translator | null }));
|
|
11
|
-
|
|
12
|
-
/** Run `build` with `i18n` as the translator of every kit control it creates. */
|
|
13
|
-
export function withKitTranslator<T>(i18n: Translator | null | undefined, build: () => T): T {
|
|
14
|
-
const previous = scope.current;
|
|
15
|
-
scope.current = i18n ?? null;
|
|
16
|
-
try {
|
|
17
|
-
return build();
|
|
18
|
-
} finally {
|
|
19
|
-
scope.current = previous;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** The translator of the kit build in progress, or null (English) outside one. */
|
|
24
|
-
export function kitTranslator(): Translator | null {
|
|
25
|
-
return scope.current;
|
|
26
|
-
}
|
|
1
|
+
// The language of the UI kit's own words: a stepper's name, the color picker's opacity
|
|
2
|
+
// label, a menu star's name. A kit control takes a translator in its options; a chart
|
|
3
|
+
// building many controls at once (a settings dialog) runs the build inside
|
|
4
|
+
// `withKitTranslator`, and each control built there keeps that translator, so a popover
|
|
5
|
+
// it opens later speaks the same language. Anywhere else the kit speaks English. The scope is
|
|
6
|
+
// page-wide, so controls from another copy of the kit built inside it speak it too.
|
|
7
|
+
import type { Translator } from './i18n';
|
|
8
|
+
import { pageState } from './page';
|
|
9
|
+
|
|
10
|
+
const scope = pageState('kit-text@1', () => ({ current: null as Translator | null }));
|
|
11
|
+
|
|
12
|
+
/** Run `build` with `i18n` as the translator of every kit control it creates. */
|
|
13
|
+
export function withKitTranslator<T>(i18n: Translator | null | undefined, build: () => T): T {
|
|
14
|
+
const previous = scope.current;
|
|
15
|
+
scope.current = i18n ?? null;
|
|
16
|
+
try {
|
|
17
|
+
return build();
|
|
18
|
+
} finally {
|
|
19
|
+
scope.current = previous;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The translator of the kit build in progress, or null (English) outside one. */
|
|
24
|
+
export function kitTranslator(): Translator | null {
|
|
25
|
+
return scope.current;
|
|
26
|
+
}
|