fluentui-svelte 0.5.0 → 0.7.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.
Files changed (259) hide show
  1. package/dist/components/app-surface/app-surface.svelte +96 -0
  2. package/dist/components/app-surface/app-surface.svelte.d.ts +22 -0
  3. package/dist/components/app-surface/docs/llms.md +73 -0
  4. package/dist/components/app-surface/types.d.ts +19 -0
  5. package/dist/components/app-surface/types.js +1 -0
  6. package/dist/components/app-window/app-window.d.ts +3 -0
  7. package/dist/components/app-window/app-window.js +3 -0
  8. package/dist/components/app-window/app-window.svelte +193 -0
  9. package/dist/components/app-window/app-window.svelte.d.ts +25 -0
  10. package/dist/components/app-window/docs/llms.md +119 -0
  11. package/dist/components/app-window/types.d.ts +66 -0
  12. package/dist/components/app-window/types.js +1 -0
  13. package/dist/components/auto-suggest-box/auto-suggest-box.svelte +47 -31
  14. package/dist/components/auto-suggest-box/auto-suggest-box.svelte.d.ts +2 -2
  15. package/dist/components/auto-suggest-box/docs/llms.md +34 -33
  16. package/dist/components/auto-suggest-box/option.svelte +6 -4
  17. package/dist/components/auto-suggest-box/types.d.ts +13 -16
  18. package/dist/components/avatar/avatar.svelte +4 -3
  19. package/dist/components/avatar/docs/llms.md +1 -1
  20. package/dist/components/avatar/type.d.ts +1 -1
  21. package/dist/components/badge/badge-icon.svelte +2 -2
  22. package/dist/components/badge/badge.svelte +2 -2
  23. package/dist/components/badge/docs/llms.md +2 -2
  24. package/dist/components/badge/types.d.ts +2 -2
  25. package/dist/components/breadcrumb/breadcrumb-button.svelte +2 -2
  26. package/dist/components/breadcrumb/breadcrumb-divider.svelte +2 -2
  27. package/dist/components/breadcrumb/breadcrumb-item.svelte +2 -2
  28. package/dist/components/breadcrumb/breadcrumb.svelte +10 -5
  29. package/dist/components/breadcrumb/docs/llms.md +11 -11
  30. package/dist/components/breadcrumb/types.d.ts +7 -7
  31. package/dist/components/button/button.svelte +2 -2
  32. package/dist/components/button/docs/llms.md +17 -17
  33. package/dist/components/button/split-button.svelte +7 -7
  34. package/dist/components/button/types.d.ts +5 -5
  35. package/dist/components/calendar-date-picker/calendar-date-picker.svelte +98 -10
  36. package/dist/components/calendar-date-picker/calendar-date-picker.svelte.d.ts +1 -1
  37. package/dist/components/calendar-date-picker/docs/llms.md +19 -14
  38. package/dist/components/calendar-date-picker/types.d.ts +22 -8
  39. package/dist/components/calendar-view/calendar-view-days.svelte +3 -2
  40. package/dist/components/calendar-view/calendar-view-grid.js +8 -3
  41. package/dist/components/calendar-view/calendar-view-item.svelte +10 -4
  42. package/dist/components/calendar-view/calendar-view-months.svelte +3 -2
  43. package/dist/components/calendar-view/calendar-view-years.svelte +3 -2
  44. package/dist/components/calendar-view/calendar-view.svelte +11 -4
  45. package/dist/components/calendar-view/calendar-view.svelte.js +5 -0
  46. package/dist/components/calendar-view/docs/llms.md +20 -19
  47. package/dist/components/calendar-view/types.d.ts +6 -1
  48. package/dist/components/card/card-footer.svelte +2 -2
  49. package/dist/components/card/card-header.svelte +5 -4
  50. package/dist/components/card/card-preview.svelte +13 -2
  51. package/dist/components/card/card.svelte +5 -5
  52. package/dist/components/card/docs/llms.md +22 -21
  53. package/dist/components/card/types.d.ts +8 -4
  54. package/dist/components/checkbox/checkbox.svelte +47 -26
  55. package/dist/components/checkbox/checkbox.svelte.d.ts +3 -24
  56. package/dist/components/checkbox/docs/llms.md +24 -23
  57. package/dist/components/checkbox/types.d.ts +10 -23
  58. package/dist/components/date-picker/date-picker.svelte +98 -27
  59. package/dist/components/date-picker/date-picker.svelte.d.ts +1 -1
  60. package/dist/components/date-picker/docs/llms.md +23 -20
  61. package/dist/components/date-picker/types.d.ts +24 -15
  62. package/dist/components/dialog/dialog-actions.svelte +17 -2
  63. package/dist/components/dialog/dialog-content.svelte +2 -2
  64. package/dist/components/dialog/dialog-content.svelte.d.ts +1 -1
  65. package/dist/components/dialog/dialog-surface.svelte +130 -8
  66. package/dist/components/dialog/dialog-title.svelte +23 -6
  67. package/dist/components/dialog/dialog-trigger.svelte +8 -2
  68. package/dist/components/dialog/dialog-trigger.svelte.d.ts +1 -1
  69. package/dist/components/dialog/dialog.svelte +22 -11
  70. package/dist/components/dialog/docs/llms.md +56 -19
  71. package/dist/components/dialog/types.d.ts +31 -9
  72. package/dist/components/dialog/utils.d.ts +2 -0
  73. package/dist/components/dialog/utils.js +1 -0
  74. package/dist/components/divider/divider.svelte +6 -4
  75. package/dist/components/divider/types.d.ts +1 -1
  76. package/dist/components/dropdown/docs/llms.md +30 -28
  77. package/dist/components/dropdown/dropdown-option.svelte +17 -5
  78. package/dist/components/dropdown/dropdown.svelte +182 -84
  79. package/dist/components/dropdown/dropdown.svelte.d.ts +1 -1
  80. package/dist/components/dropdown/types.d.ts +26 -20
  81. package/dist/components/dropdown-select/docs/llms.md +24 -22
  82. package/dist/components/dropdown-select/dropdown-select-option.svelte +2 -2
  83. package/dist/components/dropdown-select/dropdown-select.svelte +42 -7
  84. package/dist/components/dropdown-select/types.d.ts +4 -4
  85. package/dist/components/expander/docs/llms.md +3 -3
  86. package/dist/components/expander/expander.svelte +13 -8
  87. package/dist/components/expander/types.d.ts +5 -5
  88. package/dist/components/flyout/docs/llms.md +1 -1
  89. package/dist/components/flyout/flyout.svelte +17 -6
  90. package/dist/components/flyout/types.d.ts +1 -1
  91. package/dist/components/hyperlink/docs/llms.md +6 -6
  92. package/dist/components/hyperlink/hyperlink.svelte +13 -4
  93. package/dist/components/hyperlink/types.d.ts +1 -1
  94. package/dist/components/info-bar/docs/llms.md +11 -10
  95. package/dist/components/info-bar/info-bar.svelte +3 -2
  96. package/dist/components/info-bar/types.d.ts +4 -0
  97. package/dist/components/label/docs/llms.md +75 -22
  98. package/dist/components/label/label-context.d.ts +14 -0
  99. package/dist/components/label/label-context.js +10 -0
  100. package/dist/components/label/label.svelte +153 -30
  101. package/dist/components/label/label.svelte.d.ts +1 -1
  102. package/dist/components/label/types.d.ts +48 -4
  103. package/dist/components/list-view/docs/llms.md +103 -33
  104. package/dist/components/list-view/list-view-item-branch.svelte +257 -0
  105. package/dist/components/list-view/list-view-item-branch.svelte.d.ts +4 -0
  106. package/dist/components/list-view/list-view-item.svelte +164 -46
  107. package/dist/components/list-view/list-view-item.svelte.d.ts +5 -5
  108. package/dist/components/list-view/list-view.svelte +73 -25
  109. package/dist/components/list-view/types.d.ts +71 -8
  110. package/dist/components/list-view/utils.d.ts +10 -0
  111. package/dist/components/list-view/utils.js +17 -1
  112. package/dist/components/menu/docs/llms.md +98 -15
  113. package/dist/components/menu/menu-command-bar-item.svelte +61 -0
  114. package/dist/components/menu/menu-command-bar-item.svelte.d.ts +14 -0
  115. package/dist/components/menu/menu-command-bar.svelte +218 -0
  116. package/dist/components/menu/menu-command-bar.svelte.d.ts +21 -0
  117. package/dist/components/menu/menu-group.svelte +6 -3
  118. package/dist/components/menu/menu-item-checkbox.svelte +5 -4
  119. package/dist/components/menu/menu-item-radio.svelte +5 -4
  120. package/dist/components/menu/menu-item-switch.svelte +5 -4
  121. package/dist/components/menu/menu-item.svelte +5 -5
  122. package/dist/components/menu/menu-item.svelte.d.ts +2 -3
  123. package/dist/components/menu/menu-list.svelte +10 -1
  124. package/dist/components/menu/menu-popover.svelte +9 -5
  125. package/dist/components/menu/menu-trigger.svelte +2 -1
  126. package/dist/components/menu/menu.svelte.js +1 -0
  127. package/dist/components/menu/types.d.ts +62 -7
  128. package/dist/components/number-box/docs/llms.md +6 -4
  129. package/dist/components/number-box/number-box.svelte +35 -29
  130. package/dist/components/number-box/number-box.svelte.d.ts +1 -1
  131. package/dist/components/number-box/types.d.ts +1 -1
  132. package/dist/components/persona/docs/llms.md +29 -25
  133. package/dist/components/persona/persona.svelte +8 -6
  134. package/dist/components/persona/types.d.ts +4 -3
  135. package/dist/components/progress-bar/docs/llms.md +13 -13
  136. package/dist/components/progress-bar/progress-bar.svelte +6 -6
  137. package/dist/components/progress-bar/types.d.ts +4 -4
  138. package/dist/components/progress-ring/docs/llms.md +14 -14
  139. package/dist/components/progress-ring/progress-ring.svelte +5 -5
  140. package/dist/components/progress-ring/types.d.ts +3 -3
  141. package/dist/components/radio-button/docs/llms.md +11 -8
  142. package/dist/components/radio-button/radio-button.svelte +38 -12
  143. package/dist/components/radio-button/radio-button.svelte.d.ts +1 -1
  144. package/dist/components/radio-button/types.d.ts +11 -8
  145. package/dist/components/rating/docs/llms.md +111 -0
  146. package/dist/components/rating/rating.svelte +247 -0
  147. package/dist/components/rating/rating.svelte.d.ts +19 -0
  148. package/dist/components/rating/types.d.ts +44 -0
  149. package/dist/components/rating/types.js +1 -0
  150. package/dist/components/side-nav/docs/llms.md +110 -0
  151. package/dist/components/side-nav/side-nav-branch.svelte +43 -0
  152. package/dist/components/side-nav/side-nav-branch.svelte.d.ts +4 -0
  153. package/dist/components/side-nav/side-nav-item.svelte +75 -0
  154. package/dist/components/side-nav/side-nav-item.svelte.d.ts +25 -0
  155. package/dist/components/side-nav/side-nav-list.svelte +32 -0
  156. package/dist/components/side-nav/side-nav-list.svelte.d.ts +7 -0
  157. package/dist/components/side-nav/side-nav.d.ts +2 -0
  158. package/dist/components/side-nav/side-nav.js +2 -0
  159. package/dist/components/side-nav/side-nav.svelte +355 -0
  160. package/dist/components/side-nav/side-nav.svelte.d.ts +24 -0
  161. package/dist/components/side-nav/types.d.ts +149 -0
  162. package/dist/components/side-nav/types.js +1 -0
  163. package/dist/components/skeleton/docs/llms.md +1 -1
  164. package/dist/components/skeleton/skeleton.svelte +2 -2
  165. package/dist/components/skeleton/types.d.ts +1 -1
  166. package/dist/components/slider/docs/llms.md +31 -28
  167. package/dist/components/slider/slider.svelte +126 -61
  168. package/dist/components/slider/slider.svelte.d.ts +1 -3
  169. package/dist/components/slider/types.d.ts +21 -14
  170. package/dist/components/tab-view/docs/llms.md +7 -7
  171. package/dist/components/tab-view/tab-view-tab.svelte +16 -14
  172. package/dist/components/tab-view/tab-view.svelte +16 -9
  173. package/dist/components/tab-view/types.d.ts +6 -6
  174. package/dist/components/table/docs/llms.md +38 -33
  175. package/dist/components/table/table-body.svelte +2 -2
  176. package/dist/components/table/table-cell-actions.svelte +8 -2
  177. package/dist/components/table/table-cell-layout.svelte +2 -2
  178. package/dist/components/table/table-cell.svelte +2 -2
  179. package/dist/components/table/table-header-cell.svelte +2 -2
  180. package/dist/components/table/table-header.svelte +2 -2
  181. package/dist/components/table/table-row.svelte +2 -2
  182. package/dist/components/table/table-selection-cell.svelte +6 -6
  183. package/dist/components/table/table.svelte +2 -2
  184. package/dist/components/table/types.d.ts +11 -11
  185. package/dist/components/tag/docs/llms.md +383 -0
  186. package/dist/components/tag/tag-group.d.ts +2 -0
  187. package/dist/components/tag/tag-group.js +2 -0
  188. package/dist/components/tag/tag-group.svelte +117 -0
  189. package/dist/components/tag/tag-group.svelte.d.ts +20 -0
  190. package/dist/components/tag/tag.svelte +459 -0
  191. package/dist/components/tag/tag.svelte.d.ts +19 -0
  192. package/dist/components/tag/types.d.ts +137 -0
  193. package/dist/components/tag/types.js +1 -0
  194. package/dist/components/tag-picker/docs/llms.md +298 -0
  195. package/dist/components/tag-picker/option-group.svelte +51 -0
  196. package/dist/components/tag-picker/option-group.svelte.d.ts +4 -0
  197. package/dist/components/tag-picker/option.svelte +82 -0
  198. package/dist/components/tag-picker/option.svelte.d.ts +4 -0
  199. package/dist/components/tag-picker/tag-picker.d.ts +2 -0
  200. package/dist/components/tag-picker/tag-picker.js +2 -0
  201. package/dist/components/tag-picker/tag-picker.svelte +716 -0
  202. package/dist/components/tag-picker/tag-picker.svelte.d.ts +21 -0
  203. package/dist/components/tag-picker/types.d.ts +142 -0
  204. package/dist/components/tag-picker/types.js +1 -0
  205. package/dist/components/text-box/docs/llms.md +31 -4
  206. package/dist/components/text-box/text-box-button.svelte +3 -3
  207. package/dist/components/text-box/text-box-button.svelte.d.ts +1 -1
  208. package/dist/components/text-box/text-box.svelte +41 -14
  209. package/dist/components/text-box/types.d.ts +5 -5
  210. package/dist/components/textarea/docs/llms.md +4 -3
  211. package/dist/components/textarea/textarea.svelte +14 -6
  212. package/dist/components/textarea/types.d.ts +2 -4
  213. package/dist/components/time-picker/docs/llms.md +18 -15
  214. package/dist/components/time-picker/time-picker.svelte +133 -33
  215. package/dist/components/time-picker/time-picker.svelte.d.ts +1 -1
  216. package/dist/components/time-picker/types.d.ts +23 -13
  217. package/dist/components/title-bar/docs/llms.md +382 -0
  218. package/dist/components/title-bar/title-bar-left-controls.svelte +215 -0
  219. package/dist/components/title-bar/title-bar-left-controls.svelte.d.ts +22 -0
  220. package/dist/components/title-bar/title-bar-right-controls.svelte +190 -0
  221. package/dist/components/title-bar/title-bar-right-controls.svelte.d.ts +27 -0
  222. package/dist/components/title-bar/title-bar.d.ts +3 -0
  223. package/dist/components/title-bar/title-bar.js +4 -0
  224. package/dist/components/title-bar/title-bar.svelte +224 -0
  225. package/dist/components/title-bar/title-bar.svelte.d.ts +26 -0
  226. package/dist/components/title-bar/types.d.ts +165 -0
  227. package/dist/components/title-bar/types.js +1 -0
  228. package/dist/components/toggle-switch/docs/llms.md +11 -9
  229. package/dist/components/toggle-switch/toggle-switch.svelte +23 -14
  230. package/dist/components/toggle-switch/toggle-switch.svelte.d.ts +1 -1
  231. package/dist/components/toggle-switch/types.d.ts +12 -10
  232. package/dist/components/tooltip/docs/llms.md +1 -1
  233. package/dist/components/tooltip/tooltip.svelte +5 -4
  234. package/dist/components/tooltip/types.d.ts +1 -1
  235. package/dist/components/top-nav/docs/llms.md +1 -1
  236. package/dist/components/top-nav/top-nav-item.svelte +2 -2
  237. package/dist/components/top-nav/top-nav.svelte +2 -2
  238. package/dist/components/top-nav/types.d.ts +2 -2
  239. package/dist/components/tree-view/docs/llms.md +11 -11
  240. package/dist/components/tree-view/tree-view-item-content.svelte +3 -3
  241. package/dist/components/tree-view/tree-view-item.svelte +13 -5
  242. package/dist/components/tree-view/tree-view.svelte +20 -5
  243. package/dist/components/tree-view/tree-view.svelte.d.ts +1 -1
  244. package/dist/components/tree-view/tree-view.svelte.js +31 -3
  245. package/dist/components/tree-view/types.d.ts +7 -3
  246. package/dist/index.d.ts +25 -0
  247. package/dist/index.js +32 -0
  248. package/dist/internal/components/dynamic-carousel/dynamic-carousel.svelte +26 -5
  249. package/dist/internal/components/dynamic-carousel/dynamic-carousel.svelte.d.ts +2 -0
  250. package/dist/internal/constants.d.ts +0 -4
  251. package/dist/internal/constants.js +0 -4002
  252. package/dist/internal/index.d.ts +1 -0
  253. package/dist/internal/index.js +1 -0
  254. package/dist/internal/native-field.svelte.d.ts +44 -0
  255. package/dist/internal/native-field.svelte.js +85 -0
  256. package/dist/internal/utils.d.ts +16 -2
  257. package/dist/internal/utils.js +25 -3
  258. package/dist/types/index.d.ts +3 -3
  259. package/package.json +51 -37
@@ -0,0 +1,96 @@
1
+ <script lang="ts">
2
+ import { onDestroy } from 'svelte';
3
+ import { getAppWindowContext } from '../app-window/app-window.js';
4
+ import type { AppSurfaceProps } from './types.js';
5
+
6
+ let {
7
+ ref = $bindable(),
8
+ mode = 'layer',
9
+ active,
10
+ class: classes,
11
+ children,
12
+ ...attributes
13
+ }: AppSurfaceProps = $props();
14
+
15
+ const appWindow = getAppWindowContext();
16
+ const effectiveActive = $derived(active ?? appWindow?.state.active ?? false);
17
+ const noRadius = $derived(!!appWindow?.state.sideNav?.floating && appWindow.state.sideNav.collapsed);
18
+ const navPosition = $derived(appWindow?.state.sideNav?.position);
19
+
20
+ const unregister = appWindow?.methods.registerAppSurface({
21
+ get ref() {
22
+ return ref ?? null;
23
+ }
24
+ });
25
+
26
+ onDestroy(() => unregister?.());
27
+ </script>
28
+
29
+ <!--
30
+ @component
31
+ An app surface is the area of an app that holds its content, next to the navigation. It is square on its own;
32
+ next to a `SideNav` it rounds the corner that faces it and the one across from it. It is either a `layer` over the
33
+ window or the `mica` of the window itself, in the colors of an active or an inactive window.
34
+
35
+ - Usage:
36
+ ```tsx
37
+ <script>
38
+ import { AppSurface, AppWindow } from 'fluentui-svelte';
39
+ </script>
40
+
41
+ <AppWindow width={480} height={320}>
42
+ <AppSurface>
43
+ <p>The content of the app.</p>
44
+ </AppSurface>
45
+ </AppWindow>
46
+ ```
47
+ -->
48
+ <div
49
+ bind:this={ref}
50
+ class={[
51
+ 'fs-app-surface',
52
+ mode,
53
+ effectiveActive ? 'active' : 'inactive',
54
+ { 'nav-left': navPosition === 'left', 'nav-right': navPosition === 'right', 'no-radius': noRadius },
55
+ classes
56
+ ]}
57
+ {...attributes}
58
+ >
59
+ {@render children?.()}
60
+ </div>
61
+
62
+ <style>
63
+ .fs-app-surface {
64
+ box-sizing: border-box;
65
+ flex: 1 1 auto;
66
+ min-block-size: 0;
67
+ overflow: auto;
68
+ color: var(--fs-text-primary);
69
+ background: var(--fs-app-surface-background);
70
+ background-clip: padding-box;
71
+ border: 1px solid var(--fs-app-surface-stroke);
72
+ /* Square unless a SideNav is next to it: then the corner that faces it and the one across from it are rounded. They swap sides with the navigation, and with the writing direction. */
73
+ &.nav-left {
74
+ border-start-start-radius: var(--fs-control-overlay-border-radius);
75
+ border-end-end-radius: var(--fs-control-overlay-border-radius);
76
+ }
77
+ &.nav-right {
78
+ border-start-end-radius: var(--fs-control-overlay-border-radius);
79
+ border-end-start-radius: var(--fs-control-overlay-border-radius);
80
+ }
81
+ &.no-radius {
82
+ border-radius: 0;
83
+ }
84
+ &.layer {
85
+ --fs-app-surface-background: var(--fs-solid-background-tertiary);
86
+ --fs-app-surface-stroke: var(--fs-card-stroke-default);
87
+ &.inactive {
88
+ --fs-app-surface-background: var(--fs-layer-default);
89
+ }
90
+ }
91
+ &.mica {
92
+ --fs-app-surface-background: var(--fs-solid-background-base);
93
+ --fs-app-surface-stroke: var(--fs-control-surface-stroke-default);
94
+ }
95
+ }
96
+ </style>
@@ -0,0 +1,22 @@
1
+ import type { AppSurfaceProps } from './types.ts';
2
+ /**
3
+ * An app surface is the area of an app that holds its content, next to the navigation. It is square on its own;
4
+ * next to a `SideNav` it rounds the corner that faces it and the one across from it. It is either a `layer` over the
5
+ * window or the `mica` of the window itself, in the colors of an active or an inactive window.
6
+ *
7
+ * - Usage:
8
+ * ```tsx
9
+ * <script>
10
+ * import { AppSurface, AppWindow } from 'fluentui-svelte';
11
+ * </script>
12
+ *
13
+ * <AppWindow width={480} height={320}>
14
+ * <AppSurface>
15
+ * <p>The content of the app.</p>
16
+ * </AppSurface>
17
+ * </AppWindow>
18
+ * ```
19
+ */
20
+ declare const AppSurface: import("svelte").Component<AppSurfaceProps, {}, "ref">;
21
+ type AppSurface = ReturnType<typeof AppSurface>;
22
+ export default AppSurface;
@@ -0,0 +1,73 @@
1
+ # AppSurface
2
+
3
+ An app surface is the area of an app that holds its content, next to the navigation. It is square on its own; next to a SideNav it rounds the corner that faces it and the one across from it. It is either a `layer` over the window or the `mica` of the window itself, in the colors of an active or an inactive window.
4
+
5
+ ## Usage
6
+
7
+ Inside AppWindow, the surface inherits the window's active state unless active is explicitly set. Without a SideNav in the window, or on its own, it has no corner radius. With one it rounds the corner that faces the SideNav and the one across from it, following its `position`; a floating and collapsed SideNav removes the radii until either state changes.
8
+
9
+ Put the content of the app inside the surface, usually in the space an `AppWindow` has left once the navigation takes its place. The surface grows to fill the room its container leaves it, scrolls its content when it does not fit, and is a `layer` unless you set another `mode`.
10
+
11
+ ```svelte
12
+ <script>
13
+ import { AppSurface, AppWindow } from 'fluentui-svelte';
14
+ </script>
15
+
16
+ <AppWindow width={400} height={160}>
17
+ <AppSurface style="padding: 1rem">This is the content of the app.</AppSurface>
18
+ </AppWindow>
19
+ ```
20
+
21
+ ## Examples
22
+
23
+ ### Mode
24
+
25
+ `layer`, the default, is a layer over the window, with the stroke of a card. `mica` paints the base of the window itself, with the stroke of a control surface.
26
+
27
+ ```svelte
28
+ <AppWindow width={400} height={120}>
29
+ <div style="display: flex; flex: 1; min-height: 0">
30
+ <div style="flex: none; width: 3rem"></div>
31
+ <AppSurface mode="layer" style="padding: 1rem">Layer</AppSurface>
32
+ </div>
33
+ </AppWindow>
34
+
35
+ <AppWindow width={400} height={120}>
36
+ <div style="display: flex; flex: 1; min-height: 0">
37
+ <div style="flex: none; width: 3rem"></div>
38
+ <AppSurface mode="mica" style="padding: 1rem">Mica</AppSurface>
39
+ </div>
40
+ </AppWindow>
41
+ ```
42
+
43
+ ### Active and Inactive
44
+
45
+ `active` tells whether the window the surface lives in is the active one. A `layer` is solid while active and translucent while inactive, which is the default; `mica` paints the same base in both states. Set it from the same focus state as the window.
46
+
47
+ ```svelte
48
+ <script>
49
+ let active = $state(false);
50
+ </script>
51
+
52
+ <AppWindow {active} width={400} height={120}>
53
+ <div style="display: flex; flex: 1; min-height: 0">
54
+ <div style="flex: none; width: 3rem"></div>
55
+ <AppSurface {active} style="padding: 1rem">Layer</AppSurface>
56
+ </div>
57
+ </AppWindow>
58
+ ```
59
+
60
+ ## Component Props
61
+
62
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
63
+ <!-- props:AppSurfaceProps -->
64
+
65
+ | Name | Type | Default | Description |
66
+ | --------------------------------------------------- | ------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
67
+ | `ref` _bindable_ | `HTMLElement` | | The DOM reference of the surface element. |
68
+ | `mode` | `'layer'` &#124; `'mica'` | `'layer'` | The material of the surface: a `layer` over the window, or the `mica` of the window itself. |
69
+ | `active` | `boolean` | `false` | Whether the window the surface lives in is active, which picks the surface color. Inherits AppWindow's active state when omitted, or false when standalone. |
70
+ | `children` | `Snippet` | | The content of the surface. |
71
+ | `HTMLAttributes<HTMLDivElement>` without `children` | | | |
72
+
73
+ <!-- /props:AppSurfaceProps -->
@@ -0,0 +1,19 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ /** @propsmith AppSurfaceProps */
4
+ export type AppSurfaceProps = {
5
+ /** The DOM reference of the surface element.
6
+ * @bindable
7
+ */
8
+ ref?: HTMLElement;
9
+ /** The material of the surface: a `layer` over the window, or the `mica` of the window itself.
10
+ * @default 'layer'
11
+ */
12
+ mode?: 'layer' | 'mica';
13
+ /** Whether the window the surface lives in is active, which picks the surface color. Inherits AppWindow's active state when omitted, or false when standalone.
14
+ * @default false
15
+ */
16
+ active?: boolean;
17
+ /** The content of the surface. */
18
+ children?: Snippet;
19
+ } & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { AppWindowContext } from './types.ts';
2
+ /** Returns the nearest AppWindow context, or null for standalone components. */
3
+ export declare const getAppWindowContext: () => AppWindowContext | null, setAppWindowContext: (context: AppWindowContext) => void;
@@ -0,0 +1,3 @@
1
+ import { createFSContext } from '../../internal/index.js';
2
+ /** Returns the nearest AppWindow context, or null for standalone components. */
3
+ export const [getAppWindowContext, setAppWindowContext] = createFSContext();
@@ -0,0 +1,193 @@
1
+ <script lang="ts">
2
+ import { Flyout } from '../../index.js';
3
+ import { toLength } from '../../internal/index.js';
4
+ import { setAppWindowContext } from './app-window.js';
5
+ import type {
6
+ AppWindowContext,
7
+ AppWindowGlobalNav,
8
+ AppWindowPart,
9
+ AppWindowProps,
10
+ AppWindowSideNav
11
+ } from './types.js';
12
+
13
+ let {
14
+ ref = $bindable(null),
15
+ width = '100%',
16
+ height = '100%',
17
+ active = false,
18
+ maximized = $bindable(false),
19
+ minimized = $bindable(false),
20
+ class: classes,
21
+ style,
22
+ children,
23
+ ...attributes
24
+ }: AppWindowProps = $props();
25
+
26
+ let sideNav = $state.raw<AppWindowSideNav | null>(null);
27
+ let titleBar = $state.raw<AppWindowPart | null>(null);
28
+ let globalNav = $state.raw<AppWindowGlobalNav | null>(null);
29
+ let appSurface = $state.raw<AppWindowPart | null>(null);
30
+
31
+ const context: AppWindowContext = {
32
+ config: {
33
+ get width() {
34
+ return width;
35
+ },
36
+ get height() {
37
+ return height;
38
+ }
39
+ },
40
+ state: {
41
+ get ref() {
42
+ return ref;
43
+ },
44
+ get active() {
45
+ return active;
46
+ },
47
+ get maximized() {
48
+ return maximized;
49
+ },
50
+ get minimized() {
51
+ return minimized;
52
+ },
53
+ get sideNav() {
54
+ return sideNav;
55
+ },
56
+ get titleBar() {
57
+ return titleBar;
58
+ },
59
+ get globalNav() {
60
+ return globalNav;
61
+ },
62
+ get appSurface() {
63
+ return appSurface;
64
+ }
65
+ },
66
+ events: null,
67
+ methods: {
68
+ registerSideNav: (part) => {
69
+ sideNav = part;
70
+ return () => {
71
+ if (sideNav === part) sideNav = null;
72
+ };
73
+ },
74
+ registerTitleBar: (part) => {
75
+ titleBar = part;
76
+ return () => {
77
+ if (titleBar === part) titleBar = null;
78
+ };
79
+ },
80
+ registerGlobalNav: (part) => {
81
+ globalNav = part;
82
+ return () => {
83
+ if (globalNav === part) globalNav = null;
84
+ };
85
+ },
86
+ registerAppSurface: (part) => {
87
+ appSurface = part;
88
+ return () => {
89
+ if (appSurface === part) appSurface = null;
90
+ };
91
+ }
92
+ }
93
+ };
94
+ setAppWindowContext(context);
95
+ </script>
96
+
97
+ <!--
98
+ @component
99
+ An app window is the surface of an app: a Mica window with its own border and a shell shadow that tells whether it is
100
+ the active window. It is a `Flyout` underneath, sized with `width` and `height`, which are `100%` unless you say otherwise.
101
+ Place page content in an `AppSurface` or another scrollable container; the window itself clips overflow.
102
+
103
+ - Usage:
104
+ ```tsx
105
+ <script>
106
+ import { AppSurface, AppWindow, TitleBar, TitleBarRightControls } from 'fluentui-svelte';
107
+ </script>
108
+
109
+ <AppWindow width={480} height={320}>
110
+ <TitleBar>
111
+ {#snippet rightControls()}
112
+ <TitleBarRightControls />
113
+ {/snippet}
114
+ </TitleBar>
115
+ <AppSurface>The content of the app.</AppSurface>
116
+ </AppWindow>
117
+ ```
118
+ -->
119
+ <Flyout
120
+ bind:ref
121
+ class={['fs-app-window', active ? 'active' : 'inactive', classes]}
122
+ style="width: {toLength(width)}; height: {toLength(height)}; {style ?? ''}"
123
+ {...attributes}
124
+ >
125
+ {@render children?.()}
126
+ </Flyout>
127
+
128
+ <style>
129
+ /* The window restyles the `Flyout` it is made of, which is why every selector is one class more specific than its own. */
130
+ :global(.fs-flyout.fs-app-window.active),
131
+ :global(.fs-flyout.fs-app-window.inactive) {
132
+ box-sizing: border-box;
133
+ flex-direction: column;
134
+ padding: 0;
135
+ overflow: hidden;
136
+ background: var(--fs-solid-background-base);
137
+ border-color: var(--fs-control-surface-stroke-default);
138
+ }
139
+ :global(.fs-flyout.fs-app-window.active) {
140
+ box-shadow: var(--fs-shell-shadow-active);
141
+ }
142
+ :global(.fs-flyout.fs-app-window.inactive) {
143
+ box-shadow: var(--fs-shell-shadow-inactive);
144
+ }
145
+ /* A direct SideNav and AppSurface share the body row below an optional TitleBar. */
146
+ :global(.fs-flyout.fs-app-window:has(> .fs-side-nav)) {
147
+ display: grid;
148
+ grid-template-columns: auto minmax(0, 1fr);
149
+ grid-template-rows: auto minmax(0, 1fr);
150
+ }
151
+ :global(.fs-flyout.fs-app-window:has(> .fs-side-nav) > .fs-title-bar) {
152
+ grid-column: 1 / -1;
153
+ grid-row: 1;
154
+ }
155
+ :global(.fs-flyout.fs-app-window > .fs-side-nav) {
156
+ grid-column: 1;
157
+ grid-row: 2;
158
+ }
159
+ /* A navigation on the right swaps the columns with the surface. */
160
+ :global(.fs-flyout.fs-app-window:has(> .fs-side-nav.position-right)) {
161
+ grid-template-columns: minmax(0, 1fr) auto;
162
+ }
163
+ :global(.fs-flyout.fs-app-window > .fs-side-nav.position-right) {
164
+ grid-column: 2;
165
+ }
166
+ :global(.fs-flyout.fs-app-window:has(> .fs-side-nav.position-right) > .fs-app-surface) {
167
+ grid-column: 1;
168
+ }
169
+ :global(.fs-flyout.fs-app-window > .fs-side-nav.floating) {
170
+ grid-column: 1 / -1;
171
+ }
172
+ :global(.fs-flyout.fs-app-window:has(> .fs-side-nav) > .fs-app-surface) {
173
+ grid-column: 2;
174
+ grid-row: 2;
175
+ min-inline-size: 0;
176
+ }
177
+ /* Keep server-rendered corners in sync before the parts register during hydration. */
178
+ :global(.fs-flyout.fs-app-window:has(> .fs-side-nav.floating.collapsed) > .fs-app-surface) {
179
+ border-radius: 0;
180
+ }
181
+ /* Mica has no acrylic noise. */
182
+ :global(.fs-flyout.fs-app-window.active::before),
183
+ :global(.fs-flyout.fs-app-window.inactive::before) {
184
+ display: none;
185
+ }
186
+ @media (forced-colors: active) {
187
+ :global(.fs-flyout.fs-app-window.active),
188
+ :global(.fs-flyout.fs-app-window.inactive) {
189
+ background: ButtonFace;
190
+ border-color: GrayText;
191
+ }
192
+ }
193
+ </style>
@@ -0,0 +1,25 @@
1
+ import type { AppWindowProps } from './types.ts';
2
+ /**
3
+ * An app window is the surface of an app: a Mica window with its own border and a shell shadow that tells whether it is
4
+ * the active window. It is a `Flyout` underneath, sized with `width` and `height`, which are `100%` unless you say otherwise.
5
+ * Place page content in an `AppSurface` or another scrollable container; the window itself clips overflow.
6
+ *
7
+ * - Usage:
8
+ * ```tsx
9
+ * <script>
10
+ * import { AppSurface, AppWindow, TitleBar, TitleBarRightControls } from 'fluentui-svelte';
11
+ * </script>
12
+ *
13
+ * <AppWindow width={480} height={320}>
14
+ * <TitleBar>
15
+ * {#snippet rightControls()}
16
+ * <TitleBarRightControls />
17
+ * {/snippet}
18
+ * </TitleBar>
19
+ * <AppSurface>The content of the app.</AppSurface>
20
+ * </AppWindow>
21
+ * ```
22
+ */
23
+ declare const AppWindow: import("svelte").Component<AppWindowProps, {}, "ref" | "maximized" | "minimized">;
24
+ type AppWindow = ReturnType<typeof AppWindow>;
25
+ export default AppWindow;
@@ -0,0 +1,119 @@
1
+ # AppWindow
2
+
3
+ An app window is the surface of an app: a Mica window with its own border and a shell shadow that tells the active window from the inactive ones. It is built on the Flyout, so it takes its content the same way, and it fills the space around it unless you give it a size.
4
+
5
+ ## Usage
6
+
7
+ Start with a `TitleBar` if the window has one, then place page content in an `AppSurface` or another scrollable container. The window itself clips overflow. It is `100%` wide and tall unless you give it a `width` and a `height`.
8
+
9
+ ```svelte
10
+ <script>
11
+ import {
12
+ AppSurface,
13
+ AppWindow,
14
+ AutoSuggestBox,
15
+ TitleBar,
16
+ TitleBarLeftControls,
17
+ TitleBarRightControls
18
+ } from 'fluentui-svelte';
19
+ import { AppsRegular } from 'fluentui-icons-svelte';
20
+ </script>
21
+
22
+ <AppWindow width={400} height={200}>
23
+ <TitleBar>
24
+ {#snippet leftControls()}
25
+ <TitleBarLeftControls appIcon={AppsRegular} appName="FluentUI App" />
26
+ {/snippet}
27
+ {#snippet rightControls()}
28
+ <TitleBarRightControls />
29
+ {/snippet}
30
+ </TitleBar>
31
+ <AppSurface style="padding: 1rem">This is the content of the window.</AppSurface>
32
+ </AppWindow>
33
+ ```
34
+
35
+ ## Examples
36
+
37
+ ### Size
38
+
39
+ `width` and `height` take a number in pixels or any CSS length. By default they take `100%` of their container.
40
+
41
+ ```svelte
42
+ <AppWindow width={200} height={100} />
43
+ <AppWindow width="14rem" height="6rem" />
44
+
45
+ <div style="width: 260px; height: 120px">
46
+ <AppWindow />
47
+ </div>
48
+ ```
49
+
50
+ ### Active and Inactive
51
+
52
+ `active` picks the shell shadow the window casts: the lighter one of an inactive window, which is the default, or the deeper one of the active window. Set it from the focus state of the window your app lives in.
53
+
54
+ ```svelte
55
+ <script>
56
+ let active = $state(false);
57
+ </script>
58
+
59
+ <AppWindow {active} width={400} height={160} />
60
+ ```
61
+
62
+ ### With a Title Bar
63
+
64
+ The window paints the Mica background, so a `TitleBar` inside it stays transparent and sits right on it.
65
+
66
+ ```svelte
67
+ <AppWindow width={400} height={220}>
68
+ <TitleBar searchMinWidth={120}>
69
+ {#snippet leftControls()}
70
+ <TitleBarLeftControls appIcon={AppsRegular} appName="FluentUI App" />
71
+ {/snippet}
72
+ {#snippet search()}
73
+ <AutoSuggestBox placeholder="Search" aria-label="Search" />
74
+ {/snippet}
75
+ {#snippet rightControls()}
76
+ <TitleBarRightControls />
77
+ {/snippet}
78
+ </TitleBar>
79
+ <AppSurface style="padding: 1rem">This is the content of the window.</AppSurface>
80
+ </AppWindow>
81
+ ```
82
+
83
+ ## Shared window context
84
+
85
+ AppWindow creates a context per instance. Descendant components can call the exported `getAppWindowContext()` during initialization; it returns null outside AppWindow. Call it inside a child component, rather than in the parent that renders AppWindow.
86
+
87
+ `config.width` and `config.height` expose window dimensions. `state` contains the window `ref`, `active`, `maximized`, `minimized`, and registered `sideNav`, `titleBar`, `globalNav` and `appSurface` parts. Parts are null until mounted and are cleared on unmount. SideNav exposes live `collapsed`, `floating`, `position` and `ref` getters, and `setCollapsed(event, collapsed)`. `globalNav` is the global navigation button of the TitleBar (`TitleBarLeftControls`): its `ref` and `enabled`, which tells SideNav to hide its own hamburger. Nested AppWindow instances have independent contexts.
88
+
89
+ The host reports maximized/minimized through AppWindow props; these flags do not invoke native APIs or hide the window. TitleBarRightControls inherits maximized unless explicitly overridden. AppSurface inherits active unless overridden and removes its corner radii while its window's SideNav is floating and collapsed.
90
+
91
+ ```svelte
92
+ <!-- WindowStatus.svelte -->
93
+ <script>
94
+ import { getAppWindowContext } from 'fluentui-svelte';
95
+ const appWindow = getAppWindowContext();
96
+ </script>
97
+
98
+ <p>Maximized: {appWindow?.state.maximized ?? false}</p>
99
+ <p>Minimized: {appWindow?.state.minimized ?? false}</p>
100
+ <p>Navigation collapsed: {appWindow?.state.sideNav?.collapsed ?? false}</p>
101
+ ```
102
+
103
+ ## Component Props
104
+
105
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
106
+ <!-- props:AppWindowProps -->
107
+
108
+ | Name | Type | Default | Description |
109
+ | --------------------------------------------------- | --------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
110
+ | `ref` _bindable_ | `HTMLElement` &#124; `null` | | The DOM reference of the window element. |
111
+ | `width` | `number` &#124; `string` | `'100%'` | The width of the window. A number is in pixels, a string is any CSS length. |
112
+ | `height` | `number` &#124; `string` | `'100%'` | The height of the window. A number is in pixels, a string is any CSS length. |
113
+ | `active` | `boolean` | `false` | Whether the window is the active one, which picks the shell shadow it casts: a deeper one while active, a lighter one while inactive. |
114
+ | `maximized` _bindable_ | `boolean` | `false` | The maximized state reported by the host. Shared through AppWindow context and inherited by TitleBarRightControls when its maximized prop is omitted. |
115
+ | `minimized` _bindable_ | `boolean` | `false` | The minimized state reported by the host. Shared with window descendants; it does not call a native window API or hide the component. |
116
+ | `children` | `Snippet` | | The content of the window, such as a `TitleBar` and the page below it. |
117
+ | `HTMLAttributes<HTMLDivElement>` without `children` | | | |
118
+
119
+ <!-- /props:AppWindowProps -->
@@ -0,0 +1,66 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { FSContext } from '../../internal/index.js';
4
+ export type AppWindowPart = {
5
+ readonly ref: HTMLElement | null;
6
+ };
7
+ export type AppWindowSideNav = AppWindowPart & {
8
+ readonly collapsed: boolean;
9
+ readonly floating: boolean;
10
+ readonly position: 'left' | 'right';
11
+ /** Expands or collapses the navigation, as its own toggle does. */
12
+ setCollapsed: (event: Event, collapsed: boolean) => void;
13
+ };
14
+ /** The global navigation button of the title bar, which controls the SideNav of the window. */
15
+ export type AppWindowGlobalNav = AppWindowPart & {
16
+ readonly enabled: boolean;
17
+ };
18
+ export type AppWindowContext = FSContext<{
19
+ readonly width: number | string;
20
+ readonly height: number | string;
21
+ }, {
22
+ readonly ref: HTMLElement | null;
23
+ readonly active: boolean;
24
+ readonly maximized: boolean;
25
+ readonly minimized: boolean;
26
+ readonly sideNav: AppWindowSideNav | null;
27
+ readonly titleBar: AppWindowPart | null;
28
+ readonly globalNav: AppWindowGlobalNav | null;
29
+ readonly appSurface: AppWindowPart | null;
30
+ }, null, {
31
+ registerSideNav: (part: AppWindowSideNav) => () => void;
32
+ registerTitleBar: (part: AppWindowPart) => () => void;
33
+ registerGlobalNav: (part: AppWindowGlobalNav) => () => void;
34
+ registerAppSurface: (part: AppWindowPart) => () => void;
35
+ }>;
36
+ /** @propsmith AppWindowProps */
37
+ export type AppWindowProps = {
38
+ /** The DOM reference of the window element.
39
+ * @bindable
40
+ */
41
+ ref?: HTMLElement | null;
42
+ /** The width of the window. A number is in pixels, a string is any CSS length.
43
+ * @default '100%'
44
+ */
45
+ width?: number | string;
46
+ /** The height of the window. A number is in pixels, a string is any CSS length.
47
+ * @default '100%'
48
+ */
49
+ height?: number | string;
50
+ /** Whether the window is the active one, which picks the shell shadow it casts: a deeper one while active, a lighter one while inactive.
51
+ * @default false
52
+ */
53
+ active?: boolean;
54
+ /** The maximized state reported by the host. Shared through AppWindow context and inherited by TitleBarRightControls when its maximized prop is omitted.
55
+ * @default false
56
+ * @bindable
57
+ */
58
+ maximized?: boolean;
59
+ /** The minimized state reported by the host. Shared with window descendants; it does not call a native window API or hide the component.
60
+ * @default false
61
+ * @bindable
62
+ */
63
+ minimized?: boolean;
64
+ /** The content of the window, such as a `TitleBar` and the page below it. */
65
+ children?: Snippet;
66
+ } & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
@@ -0,0 +1 @@
1
+ export {};