fluentui-svelte 0.1.2 → 0.2.1

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 (87) hide show
  1. package/README.md +0 -6
  2. package/dist/components/auto-suggest-box/auto-suggest-box.svelte +74 -56
  3. package/dist/components/auto-suggest-box/docs/llms.md +46 -13
  4. package/dist/components/auto-suggest-box/option.svelte +2 -1
  5. package/dist/components/auto-suggest-box/types.d.ts +5 -0
  6. package/dist/components/avatar/avatar.svelte +1 -1
  7. package/dist/components/avatar/docs/llms.md +20 -14
  8. package/dist/components/badge/badge-icon.svelte +5 -8
  9. package/dist/components/badge/badge.svelte +6 -2
  10. package/dist/components/badge/docs/llms.md +29 -16
  11. package/dist/components/button/button.svelte +13 -7
  12. package/dist/components/button/docs/llms.md +33 -24
  13. package/dist/components/button/types.d.ts +5 -1
  14. package/dist/components/calendar-date-picker/docs/llms.md +17 -7
  15. package/dist/components/calendar-view/calendar-view-header.svelte +2 -2
  16. package/dist/components/calendar-view/calendar-view-header.svelte.d.ts +2 -17
  17. package/dist/components/calendar-view/calendar-view-months.svelte +1 -1
  18. package/dist/components/calendar-view/calendar-view-years.svelte +1 -1
  19. package/dist/components/calendar-view/calendar-view.svelte +66 -52
  20. package/dist/components/calendar-view/docs/llms.md +42 -30
  21. package/dist/components/card/card-context.svelte.d.ts +2 -0
  22. package/dist/components/card/card-context.svelte.js +2 -0
  23. package/dist/components/card/card-footer.svelte +37 -0
  24. package/dist/components/card/card-footer.svelte.d.ts +4 -0
  25. package/dist/components/card/card-header.svelte +81 -0
  26. package/dist/components/card/card-header.svelte.d.ts +4 -0
  27. package/dist/components/card/card-preview.svelte +64 -0
  28. package/dist/components/card/card-preview.svelte.d.ts +4 -0
  29. package/dist/components/card/card.svelte +242 -0
  30. package/dist/components/card/card.svelte.d.ts +39 -0
  31. package/dist/components/card/docs/llms.md +226 -0
  32. package/dist/components/card/types.d.ts +129 -0
  33. package/dist/components/card/types.js +1 -0
  34. package/dist/components/checkbox/checkbox.svelte +5 -3
  35. package/dist/components/checkbox/docs/llms.md +18 -12
  36. package/dist/components/date-picker/docs/llms.md +25 -15
  37. package/dist/components/dialog/dialog-surface.svelte +8 -8
  38. package/dist/components/dialog/dialog.svelte +41 -39
  39. package/dist/components/dialog/docs/llms.md +59 -34
  40. package/dist/components/divider/docs/llms.md +14 -9
  41. package/dist/components/dropdown/docs/llms.md +34 -15
  42. package/dist/components/dropdown/dropdown.svelte +4 -2
  43. package/dist/components/dropdown-select/docs/llms.md +28 -14
  44. package/dist/components/expander/docs/llms.md +19 -12
  45. package/dist/components/flyout/docs/llms.md +17 -11
  46. package/dist/components/hyperlink/docs/llms.md +11 -7
  47. package/dist/components/info-bar/docs/llms.md +15 -9
  48. package/dist/components/label/docs/llms.md +15 -11
  49. package/dist/components/list-view/docs/llms.md +34 -24
  50. package/dist/components/list-view/list-view-item.svelte +10 -4
  51. package/dist/components/list-view/list-view.svelte +68 -63
  52. package/dist/components/menu/context-menu-trigger.svelte +45 -40
  53. package/dist/components/menu/docs/llms.md +63 -34
  54. package/dist/components/menu/menu-item-checkbox.svelte +4 -2
  55. package/dist/components/menu/menu-item-radio.svelte +4 -2
  56. package/dist/components/menu/menu-item-switch.svelte +4 -2
  57. package/dist/components/menu/menu-item.svelte +6 -2
  58. package/dist/components/menu/menu-popover.svelte +21 -10
  59. package/dist/components/menu/menu-trigger.svelte +22 -9
  60. package/dist/components/menu/menu.svelte +98 -87
  61. package/dist/components/number-box/docs/llms.md +10 -6
  62. package/dist/components/persona/docs/llms.md +19 -14
  63. package/dist/components/progress-bar/docs/llms.md +18 -10
  64. package/dist/components/progress-ring/docs/llms.md +19 -12
  65. package/dist/components/radio-button/docs/llms.md +13 -8
  66. package/dist/components/skeleton/docs/llms.md +13 -8
  67. package/dist/components/slider/docs/llms.md +33 -21
  68. package/dist/components/slider/slider.svelte +13 -11
  69. package/dist/components/text-box/docs/llms.md +23 -17
  70. package/dist/components/textarea/docs/llms.md +16 -7
  71. package/dist/components/time-picker/docs/llms.md +20 -10
  72. package/dist/components/toggle-switch/docs/llms.md +13 -9
  73. package/dist/components/tooltip/docs/llms.md +24 -10
  74. package/dist/components/tree-view/docs/llms.md +53 -35
  75. package/dist/components/tree-view/tree-view-item-content.svelte +1 -1
  76. package/dist/components/tree-view/tree-view-item.svelte +3 -3
  77. package/dist/components/tree-view/tree-view.svelte +89 -93
  78. package/dist/css/class-darkmode.css +3 -1
  79. package/dist/css/media-darkmode.css +3 -1
  80. package/dist/css/theme.css +3 -1
  81. package/dist/index.d.ts +4 -0
  82. package/dist/index.js +6 -0
  83. package/dist/internal/components/render-soc/render-soc.svelte +17 -23
  84. package/dist/internal/components/render-soc/render-soc.svelte.d.ts +16 -16
  85. package/dist/providers/fluentui-svelte/fluentui-svelte.svelte +15 -15
  86. package/dist/types/index.d.ts +1 -0
  87. package/package.json +1 -1
@@ -40,7 +40,11 @@ export type ButtonProps<T extends ButtonGenerics = 'button'> = {
40
40
  /** The icon used to indicate the button triggers a menu.
41
41
  * @type Snippet | Component
42
42
  */
43
- indicatorIcon?: Snippet<unknown[]> | Component<Record<string, unknown>>;
43
+ indicatorIcon?: Snippet<[{
44
+ class: string;
45
+ }]> | Component<{
46
+ class: string;
47
+ }>;
44
48
  } & PolymorphicProps<T>;
45
49
  export type ButtonElementDOMType = {
46
50
  button: HTMLButtonElement;
@@ -20,13 +20,23 @@ The `CalendarDatePicker` combines a button trigger with a `CalendarView` popup.
20
20
 
21
21
  ## Component Props
22
22
 
23
- | Name | Type | Default | Description |
24
- | ------------------ | -------------------------------- | ------------------------------------------------------- | --------------------------------------------------------- |
25
- | `ref` | bindable `HTMLDivElement` | | The DOM reference of the picker element. |
26
- | `value` | bindable `Date \| null` | `null` | The selected date. |
27
- | `format` | `Intl.DateTimeFormatOptions` | `{ year: 'numeric', month: 'numeric', day: 'numeric' }` | The options used to format the date shown on the trigger. |
28
- | `calendarPosition` | `Partial<ComputePositionConfig>` | | The floating UI configuration object of the popup. |
29
- | `onChange` | `(event, value) => void` | | Called whenever the selected date changes. |
23
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
24
+ <!-- props:CalendarDatePickerProps -->
25
+
26
+ | Name | Type | Default | Description |
27
+ | ------------------------------------------------------------------------------------------------ | --------------------------------------------------- | ------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
28
+ | `ref` _bindable_ | `HTMLDivElement` | | The DOM reference of the picker element. |
29
+ | `value` _bindable_ | `Date` &#124; `null` | `null` | The selected date. |
30
+ | `format` | `Intl.DateTimeFormatOptions` | `{ year: 'numeric', month: 'numeric', day: 'numeric' }` | The options used to format the date rendered on the trigger. |
31
+ | `calendarPosition` | `Partial<ComputePositionConfig>` | | The floating UI configuration object of the calendar popup. Keys left out keep their default. |
32
+ | `onChange` | `(event: Event, value: Date` &#124; `null) => void` | | Called whenever the selected date changes. |
33
+ | `popupLabel` | `string` | `'Choose a date'` | The accessible name of the calendar popup, which is announced as a dialog. |
34
+ | `triggerRef` _bindable_ | `HTMLButtonElement` | | The DOM reference of the trigger button. |
35
+ | `popupRef` _bindable_ | `HTMLDivElement` | | The DOM reference of the calendar popup. |
36
+ | `locale`, `blackoutDates`, `headers`, `minDate`, `maxDate`, `weekStart` from `CalendarViewProps` | | | |
37
+ | Element Attributes (`div`) | | | |
38
+
39
+ <!-- /props:CalendarDatePickerProps -->
30
40
 
31
41
  `locale`, `blackoutDates`, `headers`, `minDate`, `maxDate` and `weekStart` are forwarded
32
42
  straight to the underlying `CalendarView`. All `div` HTML attributes are forwarded to the
@@ -7,9 +7,9 @@
7
7
  throw new Error('CalendarViewHeader must be used within a CalendarView');
8
8
  }
9
9
 
10
- let locale = context.config.locale;
10
+ let locale = $derived(context.config.locale);
11
11
 
12
- let weekStart = context.config.weekStart;
12
+ let weekStart = $derived(context.config.weekStart);
13
13
  </script>
14
14
 
15
15
  <!--
@@ -1,18 +1,3 @@
1
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
- $$bindings?: Bindings;
4
- } & Exports;
5
- (internal: unknown, props: {
6
- $$events?: Events;
7
- $$slots?: Slots;
8
- }): Exports & {
9
- $set?: any;
10
- $on?: any;
11
- };
12
- z_$$bindings?: Bindings;
13
- }
14
- declare const CalendarViewHeader: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
- [evt: string]: CustomEvent<any>;
16
- }, {}, {}, string>;
17
- type CalendarViewHeader = InstanceType<typeof CalendarViewHeader>;
1
+ declare const CalendarViewHeader: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type CalendarViewHeader = ReturnType<typeof CalendarViewHeader>;
18
3
  export default CalendarViewHeader;
@@ -22,7 +22,7 @@
22
22
 
23
23
  const { selectMonth, updatePage } = CalendarContext.methods;
24
24
 
25
- let { locale, minDate, headers, maxDate, selectionMode } = CalendarContext.config;
25
+ let { locale, minDate, headers, maxDate, selectionMode } = $derived(CalendarContext.config);
26
26
 
27
27
  let { value, range, page, pageAnimationDirection } = $derived(CalendarContext.state);
28
28
 
@@ -21,7 +21,7 @@
21
21
 
22
22
  const { selectYear, updatePage } = CalendarContext.methods;
23
23
 
24
- let { locale, minDate, maxDate, selectionMode } = CalendarContext.config;
24
+ let { locale, minDate, maxDate, selectionMode } = $derived(CalendarContext.config);
25
25
 
26
26
  let { value, range, page, pageAnimationDirection } = $derived(CalendarContext.state);
27
27
 
@@ -31,8 +31,8 @@
31
31
  import { getReducedMotion } from '../../providers/fluentui-svelte/fluentui-svelte.js';
32
32
  import type {
33
33
  AnimationDirection,
34
+ CalendarViewContext,
34
35
  CalendarViewProps,
35
- CalendarViewState,
36
36
  DateComparisonPrecision,
37
37
  View
38
38
  } from './types.js';
@@ -197,59 +197,70 @@
197
197
  updateView(e, 'months', year);
198
198
  }
199
199
 
200
- const CALENDAR_STATE: CalendarViewState = {
201
- get value() {
202
- return value;
203
- },
204
- set value(v) {
205
- value = v;
206
- },
207
- get range() {
208
- return range;
209
- },
210
- set range(v) {
211
- range = v;
212
- },
213
- get view() {
214
- return view;
215
- },
216
- set view(v) {
217
- view = v;
218
- },
219
- get page() {
220
- return page;
221
- },
222
- set page(v) {
223
- page = v;
224
- },
225
- get viewAnimationDirection() {
226
- return viewAnimationDirection;
227
- },
228
- set viewAnimationDirection(v) {
229
- viewAnimationDirection = v;
230
- },
231
- get pageAnimationDirection() {
232
- return pageAnimationDirection;
233
- },
234
- set pageAnimationDirection(v) {
235
- pageAnimationDirection = v;
236
- }
237
- };
238
-
239
- // svelte-ignore state_referenced_locally
240
- setCalendarViewContext({
200
+ const context: CalendarViewContext = $state({
241
201
  config: {
242
- minDate,
243
- maxDate,
244
- locale,
245
- weekStart,
246
- blackoutDates,
247
- selectionMode,
248
- blackoutBreaksRange,
249
- headers
202
+ get minDate() {
203
+ return minDate;
204
+ },
205
+ get maxDate() {
206
+ return maxDate;
207
+ },
208
+ get locale() {
209
+ return locale;
210
+ },
211
+ get weekStart() {
212
+ return weekStart;
213
+ },
214
+ get blackoutDates() {
215
+ return blackoutDates;
216
+ },
217
+ get selectionMode() {
218
+ return selectionMode;
219
+ },
220
+ get blackoutBreaksRange() {
221
+ return blackoutBreaksRange;
222
+ },
223
+ get headers() {
224
+ return headers;
225
+ }
250
226
  },
251
- get state() {
252
- return CALENDAR_STATE;
227
+ state: {
228
+ get value() {
229
+ return value;
230
+ },
231
+ set value(v) {
232
+ value = v;
233
+ },
234
+ get range() {
235
+ return range;
236
+ },
237
+ set range(v) {
238
+ range = v;
239
+ },
240
+ get view() {
241
+ return view;
242
+ },
243
+ set view(v) {
244
+ view = v;
245
+ },
246
+ get page() {
247
+ return page;
248
+ },
249
+ set page(v) {
250
+ page = v;
251
+ },
252
+ get viewAnimationDirection() {
253
+ return viewAnimationDirection;
254
+ },
255
+ set viewAnimationDirection(v) {
256
+ viewAnimationDirection = v;
257
+ },
258
+ get pageAnimationDirection() {
259
+ return pageAnimationDirection;
260
+ },
261
+ set pageAnimationDirection(v) {
262
+ pageAnimationDirection = v;
263
+ }
253
264
  },
254
265
  events: {
255
266
  onChange: (e, value) => onChange?.(e, value),
@@ -264,6 +275,9 @@
264
275
  clearSelection
265
276
  }
266
277
  });
278
+
279
+ setCalendarViewContext(context);
280
+
267
281
  $effect.pre(() => {
268
282
  pageAnimationDuration = getCSSDuration('--fs-normal-duration') || 333;
269
283
 
@@ -82,40 +82,52 @@ changing it from the header button leaves focus on the button.
82
82
 
83
83
  ## CalendarView Props
84
84
 
85
- | Name | Type | Default | Description |
86
- | --------------------- | ----------------------------------------------------- | ---------------------------- | ------------------------------------------------------------------------------ |
87
- | `ref` | bindable `HTMLDivElement` | | The DOM reference of the calendar element. |
88
- | `value` | bindable `Date \| Date[] \| null` | `null` | The selected date, or an array of dates in `multiple` mode. Unused by `range`. |
89
- | `selectionMode` | `'single' \| 'multiple' \| 'range'` | `'single'` | How many dates the grid hands out, and in what shape. |
90
- | `range` | bindable `{ start: Date \| null; end: Date \| null }` | `{ start: null, end: null }` | The picked range. `end` is `null` until the range is closed. |
91
- | `blackoutBreaksRange` | `boolean` | `false` | Stop a range from spanning a blacked-out date. |
92
- | `blackoutDates` | `Date[]` | | Dates that are rendered but cannot be selected. |
93
- | `headers` | `boolean` | | Labels the first cell of a month or a year with its name. |
94
- | `minDate` | `Date` | | The earliest selectable date. |
95
- | `maxDate` | `Date` | | The latest selectable date. |
96
- | `view` | `'days' \| 'months' \| 'years'` | `'days'` | The calendar page the view opens on. |
97
- | `locale` | `string` | `'en-US'` | The locale used to format weekday and month names. |
98
- | `weekStart` | `number` | `1` | The first day of the week, where 0 is Sunday. |
99
- | `floating` | `CalendarViewFloating` | | Renders the calendar as a popup anchored to a reference element. |
100
- | `onChange` | `(event, value) => void` | | Called whenever the selection changes. Not called in `range` mode. |
101
- | `onRangeChange` | `(event, range) => void` | | Fired on every step of a range, including the one that leaves `end` null. |
102
- | `onViewChange` | `(event, view) => void` | | Called whenever the active calendar page changes. |
85
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
86
+ <!-- props:CalendarViewProps -->
87
+
88
+ | Name | Type | Default | Description |
89
+ | -------------------------- | ------------------------------------------------------------------- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
90
+ | `ref` _bindable_ | `HTMLDivElement` | | The DOM reference of the calendar element. |
91
+ | `value` _bindable_ | `Date` &#124; `Date[]` &#124; `null` | `null` | The selected date, or an array of dates when `selectionMode` is `'multiple'`. Unused by `'range'`. |
92
+ | `selectionMode` | `'single'` &#124; `'multiple'` &#124; `'range'` | `'single'` | How many dates the grid hands out, and in what shape. |
93
+ | `range` _bindable_ | `{ start: Date` &#124; `null; end: Date` &#124; `null; }` | `{ start: null, end: null }` | The picked range. Only read and written when `selectionMode` is `'range'`, and `end` stays `null` until the range is closed. |
94
+ | `blackoutBreaksRange` | `boolean` | `false` | Stop a range from spanning a blacked-out date. |
95
+ | `blackoutDates` | `Date[]` | | Dates that are rendered but cannot be selected. |
96
+ | `headers` | `boolean` | | Labels the first cell of a month or a year with its name. |
97
+ | `minDate` | `Date` | | The earliest selectable date. |
98
+ | `maxDate` | `Date` | | The latest selectable date. |
99
+ | `view` | `'days'` &#124; `'months'` &#124; `'years'` | `'days'` | The calendar page the view opens on. |
100
+ | `locale` | `string` | `'en-US'` | The locale used to format weekday and month names. |
101
+ | `weekStart` | `number` | `1` | The first day of the week, where 0 is Sunday. |
102
+ | `floating` | `CalendarViewFloating` | | Renders the calendar as a popup anchored to a reference element instead of inline. |
103
+ | `onChange` | `(event: Event, value: Date` &#124; `Date[]` &#124; `null) => void` | | Called whenever the selection changes. Not called in `'range'` mode. |
104
+ | `onRangeChange` | `(event: Event, range: CalendarDateRange) => void` | | Fired on every step of a range, including the one that leaves `end` null. |
105
+ | `onViewChange` | `(event: Event, view: View) => void` | | Called whenever the active calendar page changes. |
106
+ | Element Attributes (`div`) | | | |
107
+
108
+ <!-- /props:CalendarViewProps -->
103
109
 
104
110
  All `div` HTML attributes are forwarded to the root element.
105
111
 
106
112
  ## CalendarViewItem Props
107
113
 
108
- | Name | Type | Default | Description |
109
- | ------------------ | ------------------------------- | ------- | --------------------------------------------------------------------------------- |
110
- | `selected` | `boolean` | | Renders the cell as the selected one. |
111
- | `disabled` | `boolean` | | Disables the user interaction. |
112
- | `current` | `boolean` | | Marks the cell as the current date. |
113
- | `outOfRange` | `boolean` | | Renders the cell as belonging to a neighbouring page. |
114
- | `blackout` | `boolean` | | Renders the cell as blacked out, so it reads as unavailable rather than disabled. |
115
- | `rangePosition` | `'start' \| 'between' \| 'end'` | | Set on the days a range covers, which paints the band behind them. |
116
- | `header` | `string` | | A small label rendered above the cell content. |
117
- | `variant` | `'day' \| 'monthYear'` | `'day'` | Which shape the cell takes: a circle for a day, a rounded rectangle otherwise. |
118
- | `children` | `Snippet` | | The content of the cell. |
119
- | `buttonAttributes` | `HTMLButtonAttributes` | | The attributes to spread on the inner button element. |
114
+ <!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
115
+ <!-- props:CalendarViewItemProps -->
116
+
117
+ | Name | Type | Default | Description |
118
+ | -------------------------- | ------------------------------------------- | ------- | ------------------------------------------------------------------------------------------ |
119
+ | `selected` | `boolean` | | Renders the cell as the selected one. |
120
+ | `disabled` | `boolean` | | Disables the user interaction. |
121
+ | `current` | `boolean` | | Marks the cell as the current date. |
122
+ | `outOfRange` | `boolean` | | Renders the cell as belonging to a neighbouring page. |
123
+ | `blackout` | `boolean` | | Renders the cell as blacked out, so it reads as unavailable rather than disabled. |
124
+ | `rangePosition` | `'start'` &#124; `'between'` &#124; `'end'` | | Set on the days a range covers, which paints the band behind them. |
125
+ | `header` | `string` | | A small label rendered above the cell content. |
126
+ | `variant` | `'day'` &#124; `'monthYear'` | `'day'` | Which shape the cell takes: a circle for a day, a rounded rectangle for a month or a year. |
127
+ | `children` | `Snippet` | | The content of the cell. |
128
+ | `buttonAttributes` | `HTMLButtonAttributes` | | The attributes to spread on the inner button element. |
129
+ | Element Attributes (`div`) | | | |
130
+
131
+ <!-- /props:CalendarViewItemProps -->
120
132
 
121
133
  All `div` HTML attributes are forwarded to the cell element.
@@ -0,0 +1,2 @@
1
+ import type { CardContext } from './types.ts';
2
+ export declare const getCardContext: () => CardContext | null, setCardContext: (context: CardContext) => void;
@@ -0,0 +1,2 @@
1
+ import { createFSContext } from '../../internal/index.js';
2
+ export const [getCardContext, setCardContext] = createFSContext();
@@ -0,0 +1,37 @@
1
+ <script lang="ts">
2
+ import type { CardFooterProps } from './types.js';
3
+ import { RenderSoC } from '../../internal/index.js';
4
+ import { getCardContext } from './card-context.svelte.js';
5
+
6
+ let { ref = $bindable(), class: classes, action, ...attributes }: CardFooterProps = $props();
7
+
8
+ const context = getCardContext();
9
+
10
+ if (!context) throw new Error('Card context is not available. Make sure this component is used within a Card.');
11
+
12
+ const { config } = context;
13
+
14
+ const showFloatingAction = $derived(config.showFloatingAction);
15
+ const selectable = $derived(config.selectable);
16
+
17
+ // Rendered through `_action`, so the invariant is enforced during SSR and on every prop update.
18
+ const _action = $derived.by(() => {
19
+ if (action && selectable) throw new Error('Action cannot be used with selectable cards.');
20
+ return action;
21
+ });
22
+ </script>
23
+
24
+ <div bind:this={ref} class={['fs-card-footer', showFloatingAction && 'with-action', classes]} {...attributes}>
25
+ {#if _action}
26
+ <RenderSoC SoC={_action} />
27
+ {/if}
28
+ </div>
29
+
30
+ <style>
31
+ .fs-card-footer {
32
+ display: flex;
33
+ gap: 0.5rem;
34
+ padding: 0.5rem;
35
+ justify-content: space-between;
36
+ }
37
+ </style>
@@ -0,0 +1,4 @@
1
+ import type { CardFooterProps } from './types.ts';
2
+ declare const CardFooter: import("svelte").Component<CardFooterProps, {}, "ref">;
3
+ type CardFooter = ReturnType<typeof CardFooter>;
4
+ export default CardFooter;
@@ -0,0 +1,81 @@
1
+ <script lang="ts">
2
+ import type { CardHeaderProps } from './types.js';
3
+ import { RenderSoC } from '../../internal/index.js';
4
+ import { getCardContext } from './card-context.svelte.js';
5
+
6
+ let {
7
+ ref = $bindable(),
8
+ class: classes,
9
+ title,
10
+ image,
11
+ imageAlt = '',
12
+ description,
13
+ action,
14
+ ...attributes
15
+ }: CardHeaderProps = $props();
16
+
17
+ const context = getCardContext();
18
+
19
+ if (!context) throw new Error('Card context is not available. Make sure this component is used within a Card.');
20
+
21
+ const { config } = context;
22
+
23
+ const showFloatingAction = $derived(config.showFloatingAction);
24
+ const selectable = $derived(config.selectable);
25
+ const id = $derived(config.id);
26
+
27
+ // Rendered through `_action`, so the invariant is enforced during SSR and on every prop update.
28
+ const _action = $derived.by(() => {
29
+ if (action && selectable) throw new Error('Action cannot be used with selectable cards.');
30
+ return action;
31
+ });
32
+ </script>
33
+
34
+ <div bind:this={ref} class={['fs-card-header', showFloatingAction && 'with-action', classes]} {...attributes}>
35
+ {#if typeof image === 'string'}
36
+ <img src={image} alt={imageAlt} />
37
+ {:else if image}
38
+ <RenderSoC SoC={image} />
39
+ {/if}
40
+ {#if description}
41
+ <div class="fs-card-header-content">
42
+ {#if typeof title === 'string'}
43
+ <h4 class="body" id={`${id}-title`}>{title}</h4>
44
+ {:else if title}
45
+ <RenderSoC SoC={title} id={`${id}-title`} />
46
+ {/if}
47
+ {#if typeof description === 'string'}
48
+ <p class="caption">{description}</p>
49
+ {:else if description}
50
+ <RenderSoC SoC={description} />
51
+ {/if}
52
+ </div>
53
+ {:else if typeof title === 'string'}
54
+ <h4 class="body" id={`${id}-title`}>{title}</h4>
55
+ {:else if title}
56
+ <RenderSoC SoC={title} id={`${id}-title`} />
57
+ {/if}
58
+ {#if _action}
59
+ <RenderSoC SoC={_action} />
60
+ {/if}
61
+ </div>
62
+
63
+ <style>
64
+ .fs-card-header {
65
+ display: flex;
66
+ align-items: center;
67
+ gap: 0.5rem;
68
+ padding: 0.5rem;
69
+ &.with-action:nth-child(2) {
70
+ padding-right: 2.4rem;
71
+ }
72
+ & :global(img) {
73
+ width: 48px;
74
+ }
75
+ & .fs-card-header-content {
76
+ display: flex;
77
+ flex-direction: column;
78
+ margin-right: auto;
79
+ }
80
+ }
81
+ </style>
@@ -0,0 +1,4 @@
1
+ import type { CardHeaderProps } from './types.ts';
2
+ declare const CardHeader: import("svelte").Component<CardHeaderProps, {}, "ref">;
3
+ type CardHeader = ReturnType<typeof CardHeader>;
4
+ export default CardHeader;
@@ -0,0 +1,64 @@
1
+ <script lang="ts">
2
+ import type { CardPreviewProps } from './types.js';
3
+ import { getCardContext } from './card-context.svelte.js';
4
+
5
+ let { ref = $bindable(), logoSrc, logoAlt = '', class: classes, children, ...attrs }: CardPreviewProps = $props();
6
+
7
+ const context = getCardContext();
8
+
9
+ if (!context) throw new Error('Card context is not available. Make sure this component is used within a Card.');
10
+
11
+ const { config, state: _state } = context;
12
+
13
+ const showFloatingAction = $derived(config.showFloatingAction);
14
+
15
+ const orientation = $derived(_state.orientation);
16
+ </script>
17
+
18
+ <div class={['fs-card-preview', showFloatingAction && 'with-action', orientation, classes]} bind:this={ref} {...attrs}>
19
+ {@render children?.()}
20
+ <img src={logoSrc} alt={logoAlt} class="fs-card-preview-logo" />
21
+ </div>
22
+
23
+ <style>
24
+ .fs-card-preview {
25
+ display: flex;
26
+ flex-direction: column;
27
+ align-items: center;
28
+ justify-content: center;
29
+ position: relative;
30
+ overflow: hidden;
31
+ /* 2nd child (After floating Checkbox) */
32
+ &:first-child,
33
+ &.with-action:nth-child(2) {
34
+ border-radius: var(--fs-control-overlay-border-radius) var(--fs-control-overlay-border-radius) 0 0;
35
+ }
36
+ &:last-child {
37
+ border-radius: 0 0 var(--fs-control-overlay-border-radius) var(--fs-control-overlay-border-radius);
38
+ }
39
+ &.horizontal {
40
+ &:first-child,
41
+ &.with-action:nth-child(2) {
42
+ border-radius: var(--fs-control-overlay-border-radius) 0 0 var(--fs-control-overlay-border-radius);
43
+ }
44
+ &:last-child {
45
+ border-radius: 0 var(--fs-control-overlay-border-radius) var(--fs-control-overlay-border-radius) 0;
46
+ }
47
+ }
48
+ &:only-child {
49
+ border-radius: var(--fs-control-overlay-border-radius);
50
+ }
51
+ & :global(img:not(.fs-card-preview-logo)) {
52
+ width: 100%;
53
+ height: auto;
54
+ }
55
+ & .fs-card-preview-logo {
56
+ width: 32px;
57
+ height: auto;
58
+ position: absolute;
59
+ bottom: 0.5rem;
60
+ left: 0.5rem;
61
+ z-index: 1;
62
+ }
63
+ }
64
+ </style>
@@ -0,0 +1,4 @@
1
+ import type { CardPreviewProps } from './types.ts';
2
+ declare const CardPreview: import("svelte").Component<CardPreviewProps, {}, "ref">;
3
+ type CardPreview = ReturnType<typeof CardPreview>;
4
+ export default CardPreview;