svelte-fluentui 1.5.0 β 1.6.0-rc02
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/README.md +8 -14
- package/dist/components/QuickGrid.svelte +9 -3
- package/dist/components/QuickGrid.svelte.d.ts +8 -4
- package/dist/components/Tab.svelte +18 -0
- package/dist/components/Tab.svelte.d.ts +14 -0
- package/dist/components/Tabs.svelte +45 -3
- package/dist/components/Tabs.svelte.d.ts +15 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/vite/vite-plugin-fluentui-icons.d.ts +10 -0
- package/dist/vite/vite-plugin-fluentui-icons.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,23 +4,17 @@ A comprehensive Svelte component library for the Microsoft FluentUI design syste
|
|
|
4
4
|
|
|
5
5
|
π **[Live documentation & showcase β svelte-fluentui.keenmate.dev](https://svelte-fluentui.keenmate.dev)**
|
|
6
6
|
|
|
7
|
-
## What's New in v1.
|
|
7
|
+
## What's New in v1.6.0-rc02
|
|
8
8
|
|
|
9
|
-
The
|
|
9
|
+
- **Icons β library-internal icons (like the QuickGrid toolbar) now bundle automatically** β The `svelteFluentUI()` build plugin scans your project for `<Icon>` usage and deliberately skips `node_modules`, so icons that svelte-fluentui's *own* components render β chiefly the QuickGrid row toolbar's `add`/`delete`/`copy`/`arrow_up`/`arrow_down` β were invisible to detection and never shipped, leaving the toolbar an empty row unless you hand-listed every glyph in `fluentui-icons.config.json`. The plugin now also scans its own `components` directory (located relative to the plugin file via `import.meta.url`, so it resolves from both a published `dist/` install and source in dev) and merges those internal icon requirements into the bundle. The whole library statically references only a handful of icons, so the added cost is negligible. Controlled by the new `iconsScanLibrary` option (default `true`); set it `false` to opt out.
|
|
10
|
+
- **`QuickGrid` β row-toolbar items accept a custom `iconSnippet` for Font Awesome, inline SVG, or any markup** β Each `rowToolbar` item previously rendered its icon strictly through the built-in `<Icon name={item.icon} />`, so its `icon` field only accepted a FluentUI icon name with no path to a Font Awesome glyph or arbitrary SVG. `RowToolbarItem` now has an optional `iconSnippet?: Snippet` that takes precedence over `icon` when present (and `icon` becomes optional when a snippet is supplied); predefined string items like `'add'`/`'delete'` and existing `icon:`-based items are unchanged. Pass `rowToolbar={[{ id: 'del', title: 'Delete', iconSnippet: trashIcon, onclick }]}` with a `{#snippet trashIcon()}...{/snippet}`.
|
|
11
|
+
- **Docs β new "Working with Icons" guide** β A dedicated page walks through how icon detection and bundling actually work, what the scanner can and can't see, the `fluentui-icons.config.json` allowlist in full, the new library-internal auto-detection, and a live `iconSnippet` demo β plus a troubleshooting checklist for blank icons and empty toolbars.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
- **`Accordion` / `AccordionItem` β reworked into a fully custom control** β Both dropped their `<fluent-accordion>` / `<fluent-accordion-item>` wrappers for plain themed elements (no shadow-DOM upgrade cost) behind a drop-in API, unlocking real control over layout: `togglePosition` (chevron side), `gap`, a per-item `disabled`, and an animated expand/collapse whose collapsed region is `inert`.
|
|
13
|
-
- **`Icon` β delivered through the new `svelteFluentUI` Vite plugin** β Icons no longer `fetch()` from a `/node_modules/β¦` URL that 404'd only in production; the plugin generates a `virtual:fluentui-icons` module so only the icons you use ship as part of normal `/_app/*` output, in either `inline` (baked into a cached chunk) or `asset` (hashed files) mode. The scanner is size/variant-aware and reads dynamic `name={β¦}` literals, and the plugin plus its options were renamed under the `svelteFluentUI` / `icons*` namespace.
|
|
14
|
-
- **New badge family β `Label`, `CompositeBadge`, `BadgeGroup`, and a beefed-up `Badge`** β Three new tag/chip components (a tinted-outline `Label`, a three-section `[icon][label][button]` `CompositeBadge`, and an overflow-collapsing `BadgeGroup` with an optional expand toggle), plus `Badge` gains `size` / `pill` / `icon` and text truncation (including start-side ellipsis for paths and hierarchies) β all on a shared `--fluent-color-*` semantic palette.
|
|
15
|
-
- **`CommandPalette` β promoted to a published, data-driven component** β The docs-only, `goto`-wired palette is now a first-class library export (with a `CommandPaletteTrigger` search pill): framework-agnostic navigation/action items, layered fuzzy scoring with highlighting, grouped results, `bind:open`, and a configurable global shortcut.
|
|
16
|
-
- **`Grid` β container-query breakpoints** β An opt-in `container` mode resolves `xs`/`sm`/`md`β¦ against a Grid's own width instead of the viewport, so it reflows inside sidebars, panels, and splitters, with app-wide and per-Grid breakpoint configuration delivered CSP-safely via constructed stylesheets.
|
|
17
|
-
- **`Dialog` β focus-trap freeze and modal scroll-lock fixes** β Two open dialogs no longer ping-pong focus into a stack-overflow `RangeError` (browser freeze), and modal dialogs now lock body scroll so wheeling over the dialog no longer scrolls the page behind it.
|
|
13
|
+
## What's New in v1.6.0-rc01
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- **`
|
|
22
|
-
- **`Accordion` β `end`-slot content no longer sits flush against the card edge with `togglePosition="start"`** β The heading is a 4-column grid whose order flips with `togglePosition`: in the default (`end`) mode the chevron was the rightmost cell and its margin supplied the right-edge inset. With the toggle on the leading edge, the `end` slot becomes rightmost but had no trailing inset of its own, so chips / badges / buttons in it pressed against the card border. The `end` slot now carries a matching `padding-inline-end` (8px, via `--design-unit`) in start-toggle mode, restoring the inset the chevron used to provide.
|
|
23
|
-
- **`Label` β resolved a `.fluent-label` class-name collision that shifted the tag chip off-centre** β The `Label` tag/chip component and the canonical form-field label helper (bold, block, sits above stacked inputs) both used the class `.fluent-label`; the helper's `margin-bottom: 0.25rem` leaked into every `<Label>`, nudging the chip up off the centre line inside a flex row. The form-field helper is renamed to **`.fluent-field-label`** (the honest name), freeing `.fluent-label` for the `Label` component alone and removing the collision at the source. **Potentially breaking** for anyone who hand-wrote `class="fluent-label"` to borrow the form-field label styling β switch those to `class="fluent-field-label"`.
|
|
15
|
+
- **`Tabs` β `canLeave` guard to block switching away from a tab with unsaved changes** β Give the active `<Tab>` a `canLeave` callback and `Tabs` calls it before navigating anywhere else, cancelling the switch if it returns `false`. Because `Tabs` renders its own tablist and owns every switch, there was no veto point before β clicking another tab simply switched, even mid-edit. The guard now sits at a single chokepoint that covers click, keyboard, swipe, and overflow-menu navigation, and it's async, so you can `await confirm(...)` or a save prompt instead of only blocking synchronously. Assigning `activeId` directly still bypasses it by design β that's your own navigation to gate.
|
|
16
|
+
- **`Tabs` β `canClose` guard to confirm before a tab's Γ button destroys it** β Separate from `canLeave` because leaving keeps a tab alive while closing throws it away: `canClose` runs before the close button fires `oncloseclick`, and a `false` (or a `Promise<boolean>` resolving false) cancels the close. It guards the specific tab being closed rather than the active one, and it's async-capable for confirm dialogs. The closable-tabs demo now confirms on close for every file except `Notes.txt`, which is left unguarded to show the opt-out.
|
|
17
|
+
- **`Tabs` β docs corrected and the dead `overflow` prop removed** β The page used to claim Tabs are "built on `<fluent-tab>`", but the Svelte rewrite renders native `<button role="tab">` elements and only reaches for a FluentUI web component (`<fluent-menu>`) in the overflow menu β the description now reflects that. The long-deprecated `overflow` prop (it warned and did nothing, replaced by `responsive="menu"`) is gone from both API tables and its redundant demo, and new `canLeave` / `canClose` rows and demos were added.
|
|
24
18
|
|
|
25
19
|
For the full history, see the [CHANGELOG](https://github.com/KeenMate/svelte-fluentui/blob/prod/CHANGELOG.md).
|
|
26
20
|
|
|
@@ -176,7 +176,8 @@
|
|
|
176
176
|
id: string
|
|
177
177
|
|
|
178
178
|
// Display
|
|
179
|
-
icon
|
|
179
|
+
icon?: string // FluentUI icon name (e.g. 'delete', 'arrow_up'), rendered via <Icon />. Optional when iconSnippet is given.
|
|
180
|
+
iconSnippet?: Snippet // Custom icon renderer (Font Awesome, inline SVG, etc.); takes precedence over `icon`
|
|
180
181
|
title: string
|
|
181
182
|
label?: string // Optional text label next to icon
|
|
182
183
|
|
|
@@ -1722,7 +1723,8 @@
|
|
|
1722
1723
|
// Full object - fill in defaults
|
|
1723
1724
|
return {
|
|
1724
1725
|
id: config.id,
|
|
1725
|
-
icon: config.icon,
|
|
1726
|
+
icon: config.icon ?? '',
|
|
1727
|
+
iconSnippet: config.iconSnippet,
|
|
1726
1728
|
title: config.title,
|
|
1727
1729
|
label: config.label,
|
|
1728
1730
|
row: config.row ?? 1,
|
|
@@ -2134,7 +2136,11 @@
|
|
|
2134
2136
|
disabled={isDisabled}
|
|
2135
2137
|
onclick={() => handleToolbarItemClick(item)}
|
|
2136
2138
|
>
|
|
2137
|
-
|
|
2139
|
+
{#if item.iconSnippet}
|
|
2140
|
+
{@render item.iconSnippet()}
|
|
2141
|
+
{:else}
|
|
2142
|
+
<Icon name={item.icon} size={16} />
|
|
2143
|
+
{/if}
|
|
2138
2144
|
{#if item.label}
|
|
2139
2145
|
<span class="row-toolbar-label">{item.label}</span>
|
|
2140
2146
|
{/if}
|
|
@@ -135,7 +135,8 @@ declare function $$render<T>(): {
|
|
|
135
135
|
showRowToolbar?: boolean;
|
|
136
136
|
rowToolbar?: (("delete" | "duplicate" | "add" | "moveUp" | "moveDown") | {
|
|
137
137
|
id: string;
|
|
138
|
-
icon
|
|
138
|
+
icon?: string;
|
|
139
|
+
iconSnippet?: Snippet;
|
|
139
140
|
title: string;
|
|
140
141
|
label?: string;
|
|
141
142
|
row?: number;
|
|
@@ -153,7 +154,8 @@ declare function $$render<T>(): {
|
|
|
153
154
|
showRowActions?: boolean;
|
|
154
155
|
rowActions?: (("delete" | "duplicate" | "add" | "moveUp" | "moveDown") | {
|
|
155
156
|
id: string;
|
|
156
|
-
icon
|
|
157
|
+
icon?: string;
|
|
158
|
+
iconSnippet?: Snippet;
|
|
157
159
|
title: string;
|
|
158
160
|
label?: string;
|
|
159
161
|
row?: number;
|
|
@@ -752,7 +754,8 @@ declare function $$render<T>(): {
|
|
|
752
754
|
ontoolbarclick?: ((detail: {
|
|
753
755
|
item: Required<Pick<{
|
|
754
756
|
id: string;
|
|
755
|
-
icon
|
|
757
|
+
icon?: string;
|
|
758
|
+
iconSnippet?: Snippet;
|
|
756
759
|
title: string;
|
|
757
760
|
label?: string;
|
|
758
761
|
row?: number;
|
|
@@ -766,7 +769,8 @@ declare function $$render<T>(): {
|
|
|
766
769
|
}) => void | Promise<void>) | undefined;
|
|
767
770
|
}, "group" | "title" | "icon" | "id" | "row">> & Omit<{
|
|
768
771
|
id: string;
|
|
769
|
-
icon
|
|
772
|
+
icon?: string;
|
|
773
|
+
iconSnippet?: Snippet;
|
|
770
774
|
title: string;
|
|
771
775
|
label?: string;
|
|
772
776
|
row?: number;
|
|
@@ -19,6 +19,20 @@
|
|
|
19
19
|
visible?: boolean
|
|
20
20
|
/** Arbitrary context data passed to `ontabchange` when this tab becomes active. */
|
|
21
21
|
data?: Record<string, unknown>
|
|
22
|
+
/**
|
|
23
|
+
* Guard called before Tabs navigates away from this tab while it is
|
|
24
|
+
* active. Return `false` (or a Promise resolving to `false`) to veto
|
|
25
|
+
* the switch β e.g. when the tab has unsaved changes. May be async so
|
|
26
|
+
* it can await a confirm dialog.
|
|
27
|
+
*/
|
|
28
|
+
canLeave?: () => boolean | Promise<boolean>
|
|
29
|
+
/**
|
|
30
|
+
* Guard called before this tab's close (Γ) button fires `oncloseclick`.
|
|
31
|
+
* Return `false` (or a Promise resolving to `false`) to veto the close β
|
|
32
|
+
* e.g. to confirm discarding unsaved data. Independent of `canLeave`.
|
|
33
|
+
* May be async so it can await a confirm dialog.
|
|
34
|
+
*/
|
|
35
|
+
canClose?: () => boolean | Promise<boolean>
|
|
22
36
|
oncloseclick?: () => void
|
|
23
37
|
}
|
|
24
38
|
|
|
@@ -37,6 +51,8 @@
|
|
|
37
51
|
showClose = false,
|
|
38
52
|
visible = true,
|
|
39
53
|
data = undefined,
|
|
54
|
+
canLeave = undefined,
|
|
55
|
+
canClose = undefined,
|
|
40
56
|
oncloseclick = undefined
|
|
41
57
|
}: Props = $props()
|
|
42
58
|
|
|
@@ -78,6 +94,8 @@
|
|
|
78
94
|
showClose,
|
|
79
95
|
visible,
|
|
80
96
|
data,
|
|
97
|
+
canLeave,
|
|
98
|
+
canClose,
|
|
81
99
|
oncloseclick,
|
|
82
100
|
class: className,
|
|
83
101
|
style
|
|
@@ -15,6 +15,20 @@ type Props = {
|
|
|
15
15
|
visible?: boolean;
|
|
16
16
|
/** Arbitrary context data passed to `ontabchange` when this tab becomes active. */
|
|
17
17
|
data?: Record<string, unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* Guard called before Tabs navigates away from this tab while it is
|
|
20
|
+
* active. Return `false` (or a Promise resolving to `false`) to veto
|
|
21
|
+
* the switch β e.g. when the tab has unsaved changes. May be async so
|
|
22
|
+
* it can await a confirm dialog.
|
|
23
|
+
*/
|
|
24
|
+
canLeave?: () => boolean | Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Guard called before this tab's close (Γ) button fires `oncloseclick`.
|
|
27
|
+
* Return `false` (or a Promise resolving to `false`) to veto the close β
|
|
28
|
+
* e.g. to confirm discarding unsaved data. Independent of `canLeave`.
|
|
29
|
+
* May be async so it can await a confirm dialog.
|
|
30
|
+
*/
|
|
31
|
+
canClose?: () => boolean | Promise<boolean>;
|
|
18
32
|
oncloseclick?: () => void;
|
|
19
33
|
};
|
|
20
34
|
declare const Tab: import("svelte").Component<Props, {}, "">;
|
|
@@ -19,6 +19,21 @@
|
|
|
19
19
|
showClose?: boolean
|
|
20
20
|
visible?: boolean
|
|
21
21
|
data?: Record<string, unknown>
|
|
22
|
+
/**
|
|
23
|
+
* Guard invoked on the *currently active* tab before Tabs navigates
|
|
24
|
+
* away from it. Return `false` (or a Promise resolving to `false`) to
|
|
25
|
+
* veto the switch β e.g. when the tab holds unsaved/dirty data. May be
|
|
26
|
+
* async so it can await a confirm dialog.
|
|
27
|
+
*/
|
|
28
|
+
canLeave?: () => boolean | Promise<boolean>
|
|
29
|
+
/**
|
|
30
|
+
* Guard invoked before this tab's close (Γ) button fires `oncloseclick`.
|
|
31
|
+
* Return `false` (or a Promise resolving to `false`) to veto the close β
|
|
32
|
+
* e.g. to confirm discarding unsaved data. Independent of `canLeave`:
|
|
33
|
+
* leaving keeps the tab alive, closing destroys it. Guards the tab being
|
|
34
|
+
* closed (not necessarily the active one). May be async.
|
|
35
|
+
*/
|
|
36
|
+
canClose?: () => boolean | Promise<boolean>
|
|
22
37
|
oncloseclick?: () => void
|
|
23
38
|
class?: string
|
|
24
39
|
style?: string
|
|
@@ -310,10 +325,27 @@
|
|
|
310
325
|
}
|
|
311
326
|
}
|
|
312
327
|
|
|
313
|
-
|
|
328
|
+
/*
|
|
329
|
+
* A tab can veto being navigated away from: before switching off the
|
|
330
|
+
* current tab we call its registered `canLeave()` guard (if any). A
|
|
331
|
+
* falsy resolve cancels the switch, so a tab with dirty data can prompt
|
|
332
|
+
* the user and stay put. The guard may be sync or async (return a
|
|
333
|
+
* Promise) so it can await a confirm dialog. Only interaction-driven
|
|
334
|
+
* switches (click, keyboard, swipe, overflow menu) route through here β
|
|
335
|
+
* a consumer assigning `activeId` directly bypasses the guard by design.
|
|
336
|
+
*/
|
|
337
|
+
async function canLeaveCurrent(targetId: string): Promise<boolean> {
|
|
338
|
+
if (!activeId || activeId === targetId) return true
|
|
339
|
+
const current = orderedTabs.find(t => t.id === activeId)
|
|
340
|
+
if (!current?.canLeave) return true
|
|
341
|
+
return (await current.canLeave()) !== false
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
async function selectTab(tabId: string, focus = false) {
|
|
314
345
|
const tab = orderedTabs.find(t => t.id === tabId)
|
|
315
346
|
if (!tab || tab.disabled) return
|
|
316
347
|
if (activeId !== tabId) {
|
|
348
|
+
if (!(await canLeaveCurrent(tabId))) return
|
|
317
349
|
activeId = tabId
|
|
318
350
|
ontabchange?.({ tabId, data: tab.data })
|
|
319
351
|
}
|
|
@@ -357,9 +389,16 @@
|
|
|
357
389
|
}
|
|
358
390
|
}
|
|
359
391
|
|
|
360
|
-
|
|
392
|
+
/*
|
|
393
|
+
* Close is guarded independently of navigation: a tab can allow being left
|
|
394
|
+
* (kept in memory) yet still confirm before being destroyed. We await the
|
|
395
|
+
* closed tab's `canClose()` (if any) before firing `oncloseclick`; a falsy
|
|
396
|
+
* resolve cancels the close.
|
|
397
|
+
*/
|
|
398
|
+
async function handleCloseClick(tab: TabEntry, e: MouseEvent) {
|
|
361
399
|
e.stopPropagation()
|
|
362
400
|
e.preventDefault()
|
|
401
|
+
if (tab.canClose && (await tab.canClose()) === false) return
|
|
363
402
|
tab.oncloseclick?.()
|
|
364
403
|
}
|
|
365
404
|
|
|
@@ -556,9 +595,12 @@
|
|
|
556
595
|
* position with the clicked tab, so the selection stays in the strip after
|
|
557
596
|
* it's activated. The displaced tab falls off into the overflow menu.
|
|
558
597
|
*/
|
|
559
|
-
function onOverflowTabClick(tabId: string) {
|
|
598
|
+
async function onOverflowTabClick(tabId: string) {
|
|
560
599
|
const tab = orderedTabs.find(t => t.id === tabId)
|
|
561
600
|
if (!tab || tab.disabled) return
|
|
601
|
+
// Guard before reordering/activating. When called from the auto-swap
|
|
602
|
+
// effect the tab is already active, so canLeaveCurrent short-circuits.
|
|
603
|
+
if (!(await canLeaveCurrent(tabId))) return
|
|
562
604
|
|
|
563
605
|
const currentOrder = displayOrder.length > 0
|
|
564
606
|
? [...displayOrder]
|
|
@@ -17,6 +17,21 @@ export type TabEntry = {
|
|
|
17
17
|
showClose?: boolean;
|
|
18
18
|
visible?: boolean;
|
|
19
19
|
data?: Record<string, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Guard invoked on the *currently active* tab before Tabs navigates
|
|
22
|
+
* away from it. Return `false` (or a Promise resolving to `false`) to
|
|
23
|
+
* veto the switch β e.g. when the tab holds unsaved/dirty data. May be
|
|
24
|
+
* async so it can await a confirm dialog.
|
|
25
|
+
*/
|
|
26
|
+
canLeave?: () => boolean | Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Guard invoked before this tab's close (Γ) button fires `oncloseclick`.
|
|
29
|
+
* Return `false` (or a Promise resolving to `false`) to veto the close β
|
|
30
|
+
* e.g. to confirm discarding unsaved data. Independent of `canLeave`:
|
|
31
|
+
* leaving keeps the tab alive, closing destroys it. Guards the tab being
|
|
32
|
+
* closed (not necessarily the active one). May be async.
|
|
33
|
+
*/
|
|
34
|
+
canClose?: () => boolean | Promise<boolean>;
|
|
20
35
|
oncloseclick?: () => void;
|
|
21
36
|
class?: string;
|
|
22
37
|
style?: string;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.6.0-rc02";
|
package/dist/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Auto-generated by scripts/pre-package.js β do NOT edit by hand.
|
|
2
2
|
// In dev this file holds whatever value was committed last; on each `npm run package`
|
|
3
3
|
// the pre-package script overwrites it with the current package.json version.
|
|
4
|
-
export const VERSION = "1.
|
|
4
|
+
export const VERSION = "1.6.0-rc02";
|
|
@@ -77,6 +77,16 @@ export interface SvelteFluentUIOptions {
|
|
|
77
77
|
* @default ['regular', 'filled']
|
|
78
78
|
*/
|
|
79
79
|
iconsVariants?: ('regular' | 'filled')[];
|
|
80
|
+
/**
|
|
81
|
+
* Also scan svelte-fluentui's own components for the icons they render
|
|
82
|
+
* internally (e.g. the QuickGrid row-toolbar's `add`/`delete`/`copy`/
|
|
83
|
+
* `arrow_up`/`arrow_down`). Those `<Icon>` usages live inside the library
|
|
84
|
+
* package, which the project scan skips (`node_modules` is ignored), so
|
|
85
|
+
* without this they'd never ship and render as blank. Costs a handful of
|
|
86
|
+
* extra icons β the whole library statically references only a few.
|
|
87
|
+
* @default true
|
|
88
|
+
*/
|
|
89
|
+
iconsScanLibrary?: boolean;
|
|
80
90
|
/**
|
|
81
91
|
* Enable verbose logging
|
|
82
92
|
* @default false
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import {} from 'vite';
|
|
26
26
|
import fs from 'fs';
|
|
27
27
|
import path from 'path';
|
|
28
|
+
import { fileURLToPath } from 'node:url';
|
|
28
29
|
const VIRTUAL_ID = 'virtual:fluentui-icons';
|
|
29
30
|
const RESOLVED_VIRTUAL_ID = '\0' + VIRTUAL_ID;
|
|
30
31
|
const DEFAULT_CONFIG_FILES = [
|
|
@@ -39,8 +40,15 @@ const DEFAULT_OPTIONS = {
|
|
|
39
40
|
iconsScanExtensions: ['.svelte', '.ts', '.js'],
|
|
40
41
|
iconsSizes: [16, 20, 24, 28, 32, 48],
|
|
41
42
|
iconsVariants: ['regular', 'filled'],
|
|
43
|
+
iconsScanLibrary: true,
|
|
42
44
|
verbose: false
|
|
43
45
|
};
|
|
46
|
+
// svelte-fluentui's own components live next to this plugin: in a published
|
|
47
|
+
// install the plugin sits at `dist/vite/β¦` and components at `dist/components`;
|
|
48
|
+
// in this repo's dev it's `src/lib/vite/β¦` and `src/lib/components`. Either way
|
|
49
|
+
// `../components` relative to this file is the library's component source, so we
|
|
50
|
+
// find its internal <Icon> usage without walking node_modules.
|
|
51
|
+
const LIBRARY_COMPONENTS_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'components');
|
|
44
52
|
// Directories that never contain first-party <Icon> usage worth scanning.
|
|
45
53
|
const IGNORED_DIRS = new Set([
|
|
46
54
|
'node_modules',
|
|
@@ -261,6 +269,8 @@ export function svelteFluentUI(options = {}) {
|
|
|
261
269
|
let config;
|
|
262
270
|
let iconsSourcePath = null;
|
|
263
271
|
let isBuild = false;
|
|
272
|
+
// The library's own components never change during a session β scan once.
|
|
273
|
+
let libraryRequests = null;
|
|
264
274
|
return {
|
|
265
275
|
name: 'vite-plugin-fluentui-icons',
|
|
266
276
|
async configResolved(resolvedConfig) {
|
|
@@ -307,6 +317,21 @@ export function svelteFluentUI(options = {}) {
|
|
|
307
317
|
// `include` entry (a name pulls every size/variant; an object entry caps
|
|
308
318
|
// the sizes/variants for that name β even for its auto-detected usage).
|
|
309
319
|
const requests = scanProjectForIcons(config.root, opts.iconsScanExtensions);
|
|
320
|
+
// Also pull in the icons svelte-fluentui's own components render (e.g.
|
|
321
|
+
// the QuickGrid row toolbar). These live inside the library package,
|
|
322
|
+
// which the project scan skips, so without this they'd render blank.
|
|
323
|
+
if (opts.iconsScanLibrary) {
|
|
324
|
+
if (libraryRequests === null) {
|
|
325
|
+
libraryRequests = fs.existsSync(LIBRARY_COMPONENTS_DIR)
|
|
326
|
+
? scanProjectForIcons(LIBRARY_COMPONENTS_DIR, opts.iconsScanExtensions)
|
|
327
|
+
: [];
|
|
328
|
+
if (opts.verbose) {
|
|
329
|
+
console.log(`[fluentui-icons] scanned library components at ${LIBRARY_COMPONENTS_DIR}: ` +
|
|
330
|
+
`${libraryRequests.length} internal icon request(s)`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
requests.push(...libraryRequests);
|
|
334
|
+
}
|
|
310
335
|
const overrides = new Map();
|
|
311
336
|
for (const entry of includeEntries) {
|
|
312
337
|
const name = typeof entry === 'string' ? entry : entry.name;
|