fluentui-svelte 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/table/docs/llms.md +531 -0
- package/dist/components/table/table-body.svelte +31 -0
- package/dist/components/table/table-body.svelte.d.ts +25 -0
- package/dist/components/table/table-cell-actions.svelte +48 -0
- package/dist/components/table/table-cell-actions.svelte.d.ts +17 -0
- package/dist/components/table/table-cell-layout.svelte +88 -0
- package/dist/components/table/table-cell-layout.svelte.d.ts +14 -0
- package/dist/components/table/table-cell.svelte +74 -0
- package/dist/components/table/table-cell.svelte.d.ts +25 -0
- package/dist/components/table/table-header-cell.svelte +257 -0
- package/dist/components/table/table-header-cell.svelte.d.ts +25 -0
- package/dist/components/table/table-header.svelte +28 -0
- package/dist/components/table/table-header.svelte.d.ts +25 -0
- package/dist/components/table/table-row.svelte +57 -0
- package/dist/components/table/table-row.svelte.d.ts +25 -0
- package/dist/components/table/table-selection-cell.svelte +89 -0
- package/dist/components/table/table-selection-cell.svelte.d.ts +25 -0
- package/dist/components/table/table.svelte +189 -0
- package/dist/components/table/table.svelte.d.ts +49 -0
- package/dist/components/table/table.svelte.js +138 -0
- package/dist/components/table/types.d.ts +287 -0
- package/dist/components/table/types.js +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import type { FSContext } from '../../internal/index.js';
|
|
2
|
+
import type { PolymorphicProps } from '../../types/index.js';
|
|
3
|
+
import type { Component, Snippet } from 'svelte';
|
|
4
|
+
import type { CheckboxProps } from '../checkbox/types.ts';
|
|
5
|
+
import type { RadioButtonProps } from '../radio-button/types.ts';
|
|
6
|
+
export type TableSize = 'extra-small' | 'small' | 'medium';
|
|
7
|
+
export type CellFocusMode = 'cell' | 'group' | 'none';
|
|
8
|
+
export type TableRowAppearance = 'none' | 'brand' | 'neutral';
|
|
9
|
+
export type SortDirection = 'ascending' | 'descending';
|
|
10
|
+
export type SelectionType = 'checkbox' | 'radio';
|
|
11
|
+
export type TableDOM = {
|
|
12
|
+
table: HTMLTableElement;
|
|
13
|
+
thead: HTMLTableSectionElement;
|
|
14
|
+
tbody: HTMLTableSectionElement;
|
|
15
|
+
tr: HTMLTableRowElement;
|
|
16
|
+
th: HTMLTableCellElement;
|
|
17
|
+
td: HTMLTableCellElement;
|
|
18
|
+
div: HTMLDivElement;
|
|
19
|
+
};
|
|
20
|
+
/** @propsmith TableProps */
|
|
21
|
+
export type TableProps<Tag extends 'table' | 'div' = 'table'> = {
|
|
22
|
+
/** The HTML element to render the table as. Defaults to a `div` when `noNativeElements` is set.
|
|
23
|
+
* @type 'table' | 'div'
|
|
24
|
+
* @default 'table'
|
|
25
|
+
*/
|
|
26
|
+
as?: Tag;
|
|
27
|
+
/** The DOM reference of the table element.
|
|
28
|
+
* @type HTMLTableElement | HTMLDivElement
|
|
29
|
+
* @bindable
|
|
30
|
+
*/
|
|
31
|
+
ref?: TableDOM[Tag] | HTMLDivElement;
|
|
32
|
+
/** Affects the sizes of all table subcomponents.
|
|
33
|
+
* @default 'medium'
|
|
34
|
+
*/
|
|
35
|
+
size?: TableSize;
|
|
36
|
+
/** Renders every table part as a `div` instead of a semantic table element. The layout switches
|
|
37
|
+
* from `display: table` to `display: flex`, which virtualization and sticky headers need.
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
noNativeElements?: boolean;
|
|
41
|
+
/** Turns every header cell into a sort button. Individual cells can still opt in on their own.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
sortable?: boolean;
|
|
45
|
+
/** Drops the line that separates one row from the next.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
noRowBorders?: boolean;
|
|
49
|
+
/** Moves the focus between cells with the arrow keys, through a single tab stop. It also
|
|
50
|
+
* switches the table over to the `role="grid"` pattern, which that navigation requires.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
enableTabspot?: boolean;
|
|
54
|
+
/** Lets the arrow keys reach rows a windowed list has not rendered. Only read when
|
|
55
|
+
* `enableTabspot` is set, and the rows need an `aria-rowindex` for it to find them again.
|
|
56
|
+
* @type TableVirtualizer
|
|
57
|
+
*/
|
|
58
|
+
virtualizer?: TableVirtualizer;
|
|
59
|
+
/** Gives every header cell a handle that drags its column wider or narrower. It also pins the
|
|
60
|
+
* table to a fixed layout, so a column keeps the width it was given.
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
resizableColumns?: boolean;
|
|
64
|
+
/** The width of each column in pixels, by column position. Columns left out keep their own size.
|
|
65
|
+
* @bindable
|
|
66
|
+
*/
|
|
67
|
+
columnWidths?: number[];
|
|
68
|
+
/** Per column limits, by column position.
|
|
69
|
+
* @type ColumnSizing[]
|
|
70
|
+
*/
|
|
71
|
+
columnSizing?: ColumnSizing[];
|
|
72
|
+
/** Called whenever a column is dragged or nudged to a new width.
|
|
73
|
+
* @type (e: Event, data: { index: number; width: number }) => void
|
|
74
|
+
*/
|
|
75
|
+
onColumnResize?: (e: Event, data: {
|
|
76
|
+
index: number;
|
|
77
|
+
width: number;
|
|
78
|
+
}) => void;
|
|
79
|
+
} & PolymorphicProps<Tag>;
|
|
80
|
+
export type ColumnSizing = {
|
|
81
|
+
/** Narrowest the column may be dragged, in pixels.
|
|
82
|
+
* @default 40
|
|
83
|
+
*/
|
|
84
|
+
minWidth?: number;
|
|
85
|
+
/** Width the column starts at, in pixels. Without it the browser sizes the column. */
|
|
86
|
+
defaultWidth?: number;
|
|
87
|
+
};
|
|
88
|
+
export type TableVirtualizer = {
|
|
89
|
+
/** Total number of real rows, the whole data set rather than the rendered window. */
|
|
90
|
+
size: number;
|
|
91
|
+
/** Scroll so the row at `index` renders. May be async. */
|
|
92
|
+
scrollToIndex?: (index: number) => void | Promise<void>;
|
|
93
|
+
};
|
|
94
|
+
/** @propsmith TableHeaderProps */
|
|
95
|
+
export type TableHeaderProps<Tag extends 'thead' | 'div' = 'thead'> = {
|
|
96
|
+
/** The HTML element to render the header as. Inherited from the table by default.
|
|
97
|
+
* @type 'thead' | 'div'
|
|
98
|
+
* @default 'thead'
|
|
99
|
+
*/
|
|
100
|
+
as?: Tag;
|
|
101
|
+
/** The DOM reference of the header element.
|
|
102
|
+
* @type HTMLTableSectionElement | HTMLDivElement
|
|
103
|
+
* @bindable
|
|
104
|
+
*/
|
|
105
|
+
ref?: TableDOM[Tag] | HTMLDivElement;
|
|
106
|
+
} & PolymorphicProps<Tag>;
|
|
107
|
+
/** @propsmith TableHeaderCellProps */
|
|
108
|
+
export type TableHeaderCellProps<Tag extends 'th' | 'div' = 'th'> = {
|
|
109
|
+
/** The HTML element to render the header cell as. Inherited from the table by default.
|
|
110
|
+
* @type 'th' | 'div'
|
|
111
|
+
* @default 'th'
|
|
112
|
+
*/
|
|
113
|
+
as?: Tag;
|
|
114
|
+
/** The DOM reference of the header cell element.
|
|
115
|
+
* @type HTMLTableCellElement | HTMLDivElement
|
|
116
|
+
* @bindable
|
|
117
|
+
*/
|
|
118
|
+
ref?: TableDOM[Tag] | HTMLDivElement;
|
|
119
|
+
/** Whether the column is sortable. Inherited from the table by default. */
|
|
120
|
+
sortable?: boolean;
|
|
121
|
+
/** The direction the column is currently sorted in. Also sets `aria-sort`. */
|
|
122
|
+
sortDirection?: SortDirection;
|
|
123
|
+
/** The indicator rendered next to the label of a sortable column.
|
|
124
|
+
* @type Snippet | Component
|
|
125
|
+
*/
|
|
126
|
+
sortIcon?: Snippet<[{
|
|
127
|
+
class: string;
|
|
128
|
+
}]> | Component<{
|
|
129
|
+
class: string;
|
|
130
|
+
}>;
|
|
131
|
+
/** Content placed after the label, outside the sort button.
|
|
132
|
+
* @type Snippet | Component
|
|
133
|
+
*/
|
|
134
|
+
aside?: Snippet<[{
|
|
135
|
+
class: string;
|
|
136
|
+
}]> | Component<{
|
|
137
|
+
class: string;
|
|
138
|
+
}>;
|
|
139
|
+
/** How the arrow keys treat the cell. `'group'` holds the focusable content of the cell out of
|
|
140
|
+
* the tab order until `Enter` steps in, and `Escape` steps back out. `'none'` skips the cell
|
|
141
|
+
* altogether. Only read when the table sets `enableTabspot`. A resizable header cell defaults to
|
|
142
|
+
* `'group'`, so the arrows reach its handle instead of leaving the column behind.
|
|
143
|
+
* @default 'cell'
|
|
144
|
+
*/
|
|
145
|
+
focusMode?: CellFocusMode;
|
|
146
|
+
/** Whether the column can be resized. Inherited from the table by default. */
|
|
147
|
+
resizable?: boolean;
|
|
148
|
+
/** The accessible name of the resize handle. Give it a translated, and ideally per column, string
|
|
149
|
+
* — the attributes of the cell reach the cell, never the handle inside it.
|
|
150
|
+
* @default 'Resize column'
|
|
151
|
+
*/
|
|
152
|
+
resizeLabel?: string;
|
|
153
|
+
} & PolymorphicProps<Tag>;
|
|
154
|
+
/** @propsmith TableBodyProps */
|
|
155
|
+
export type TableBodyProps<Tag extends 'tbody' | 'div' = 'tbody'> = {
|
|
156
|
+
/** The HTML element to render the body as. Inherited from the table by default.
|
|
157
|
+
* @type 'tbody' | 'div'
|
|
158
|
+
* @default 'tbody'
|
|
159
|
+
*/
|
|
160
|
+
as?: Tag;
|
|
161
|
+
/** The DOM reference of the body element.
|
|
162
|
+
* @type HTMLTableSectionElement | HTMLDivElement
|
|
163
|
+
* @bindable
|
|
164
|
+
*/
|
|
165
|
+
ref?: TableDOM[Tag] | HTMLDivElement;
|
|
166
|
+
} & PolymorphicProps<Tag>;
|
|
167
|
+
/** @propsmith TableRowProps */
|
|
168
|
+
export type TableRowProps<Tag extends 'tr' | 'div' = 'tr'> = {
|
|
169
|
+
/** The HTML element to render the row as. Inherited from the table by default.
|
|
170
|
+
* @type 'tr' | 'div'
|
|
171
|
+
* @default 'tr'
|
|
172
|
+
*/
|
|
173
|
+
as?: Tag;
|
|
174
|
+
/** The DOM reference of the row element.
|
|
175
|
+
* @type HTMLTableRowElement | HTMLDivElement
|
|
176
|
+
* @bindable
|
|
177
|
+
*/
|
|
178
|
+
ref?: TableDOM[Tag] | HTMLDivElement;
|
|
179
|
+
/** How the row is filled. Intended to mark a selected row.
|
|
180
|
+
* @default 'none'
|
|
181
|
+
*/
|
|
182
|
+
appearance?: TableRowAppearance;
|
|
183
|
+
} & PolymorphicProps<Tag>;
|
|
184
|
+
/** @propsmith TableCellProps */
|
|
185
|
+
export type TableCellProps<Tag extends 'td' | 'div' = 'td'> = {
|
|
186
|
+
/** The HTML element to render the cell as. Inherited from the table by default.
|
|
187
|
+
* @type 'td' | 'div'
|
|
188
|
+
* @default 'td'
|
|
189
|
+
*/
|
|
190
|
+
as?: Tag;
|
|
191
|
+
/** The DOM reference of the cell element.
|
|
192
|
+
* @type HTMLTableCellElement | HTMLDivElement
|
|
193
|
+
* @bindable
|
|
194
|
+
*/
|
|
195
|
+
ref?: TableDOM[Tag] | HTMLDivElement;
|
|
196
|
+
/** How the arrow keys treat the cell. `'group'` holds the focusable content of the cell out of
|
|
197
|
+
* the tab order until `Enter` steps in, and `Escape` steps back out. `'none'` skips the cell
|
|
198
|
+
* altogether. Only read when the table sets `enableTabspot`.
|
|
199
|
+
* @default 'cell'
|
|
200
|
+
*/
|
|
201
|
+
focusMode?: CellFocusMode;
|
|
202
|
+
} & PolymorphicProps<Tag>;
|
|
203
|
+
/** @propsmith TableSelectionCellProps */
|
|
204
|
+
export type TableSelectionCellProps<Tag extends 'td' | 'div' = 'td'> = {
|
|
205
|
+
/** The HTML element to render the cell as. Inherited from the table by default.
|
|
206
|
+
* @type 'td' | 'div'
|
|
207
|
+
* @default 'td'
|
|
208
|
+
*/
|
|
209
|
+
as?: Tag;
|
|
210
|
+
/** The DOM reference of the cell element.
|
|
211
|
+
* @type HTMLTableCellElement | HTMLDivElement
|
|
212
|
+
* @bindable
|
|
213
|
+
*/
|
|
214
|
+
ref?: TableDOM[Tag] | HTMLDivElement;
|
|
215
|
+
/** A table can have two kinds of selection modes.
|
|
216
|
+
* @default 'checkbox'
|
|
217
|
+
*/
|
|
218
|
+
type?: SelectionType;
|
|
219
|
+
/** Whether the row is selected. `'mixed'` renders the indeterminate state.
|
|
220
|
+
* @type boolean | 'mixed'
|
|
221
|
+
* @default false
|
|
222
|
+
*/
|
|
223
|
+
checked?: boolean | 'mixed';
|
|
224
|
+
/** Only shows the indicator when it is checked, or the row is hovered or focused.
|
|
225
|
+
* @default false
|
|
226
|
+
*/
|
|
227
|
+
subtle?: boolean;
|
|
228
|
+
/** Hides the indicator while it keeps taking up the same space.
|
|
229
|
+
* @default false
|
|
230
|
+
*/
|
|
231
|
+
invisible?: boolean;
|
|
232
|
+
/** The props to spread on the checkbox rendered when `type` is `'checkbox'`.
|
|
233
|
+
* @type CheckboxProps
|
|
234
|
+
*/
|
|
235
|
+
checkboxIndicator?: Omit<CheckboxProps<'div'>, 'wrapperAs' | 'checked' | 'indeterminate' | 'children'>;
|
|
236
|
+
/** The props to spread on the radio button rendered when `type` is `'radio'`.
|
|
237
|
+
* @type RadioButtonProps
|
|
238
|
+
*/
|
|
239
|
+
radioIndicator?: Omit<RadioButtonProps, 'checked' | 'group'>;
|
|
240
|
+
} & PolymorphicProps<Tag>;
|
|
241
|
+
/** @propsmith TableCellLayoutProps */
|
|
242
|
+
export type TableCellLayoutProps = {
|
|
243
|
+
/** The DOM reference of the layout element.
|
|
244
|
+
* @bindable
|
|
245
|
+
*/
|
|
246
|
+
ref?: HTMLDivElement;
|
|
247
|
+
/** An icon, an avatar or any other visual element placed before the main content.
|
|
248
|
+
* @type Snippet | Component
|
|
249
|
+
*/
|
|
250
|
+
media?: Snippet<[{
|
|
251
|
+
class: string;
|
|
252
|
+
}]> | Component<{
|
|
253
|
+
class: string;
|
|
254
|
+
}>;
|
|
255
|
+
/** A second line of text that describes or complements the main content. */
|
|
256
|
+
description?: string;
|
|
257
|
+
/** Emphasizes the cell by enlarging the media and bolding the main content. */
|
|
258
|
+
appearance?: 'primary';
|
|
259
|
+
/** Clips the content with an ellipsis instead of letting it wrap. */
|
|
260
|
+
truncate?: boolean;
|
|
261
|
+
} & PolymorphicProps<'div'>;
|
|
262
|
+
/** @propsmith TableCellActionsProps */
|
|
263
|
+
export type TableCellActionsProps = {
|
|
264
|
+
/** The DOM reference of the actions element.
|
|
265
|
+
* @bindable
|
|
266
|
+
*/
|
|
267
|
+
ref?: HTMLDivElement;
|
|
268
|
+
/** Keeps the actions on screen instead of waiting for the row to be hovered or focused. */
|
|
269
|
+
visible?: boolean;
|
|
270
|
+
} & PolymorphicProps<'div'>;
|
|
271
|
+
export type TableContextConfig = {
|
|
272
|
+
size: TableSize;
|
|
273
|
+
noNativeElements: boolean;
|
|
274
|
+
sortable: boolean;
|
|
275
|
+
enableTabspot: boolean;
|
|
276
|
+
resizableColumns: boolean;
|
|
277
|
+
};
|
|
278
|
+
export type TableContextState = {
|
|
279
|
+
columnWidths: number[];
|
|
280
|
+
};
|
|
281
|
+
export type TableContextMethods = {
|
|
282
|
+
/** The width a column should render at, or `undefined` to let the browser decide. */
|
|
283
|
+
getColumnWidth: (index: number) => number | undefined;
|
|
284
|
+
/** Records a new width for a column, clamped to the minimum it was given. */
|
|
285
|
+
resizeColumn: (e: Event, index: number, width: number) => void;
|
|
286
|
+
};
|
|
287
|
+
export type TableContext = FSContext<TableContextConfig, TableContextState, null, TableContextMethods>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,15 @@ export { default as ProgressRing } from './components/progress-ring/progress-rin
|
|
|
55
55
|
export { default as RadioButton } from './components/radio-button/radio-button.svelte';
|
|
56
56
|
export { default as Skeleton } from './components/skeleton/skeleton.svelte';
|
|
57
57
|
export { default as Slider } from './components/slider/slider.svelte';
|
|
58
|
+
export { default as Table } from './components/table/table.svelte';
|
|
59
|
+
export { default as TableHeader } from './components/table/table-header.svelte';
|
|
60
|
+
export { default as TableHeaderCell } from './components/table/table-header-cell.svelte';
|
|
61
|
+
export { default as TableBody } from './components/table/table-body.svelte';
|
|
62
|
+
export { default as TableRow } from './components/table/table-row.svelte';
|
|
63
|
+
export { default as TableCell } from './components/table/table-cell.svelte';
|
|
64
|
+
export { default as TableSelectionCell } from './components/table/table-selection-cell.svelte';
|
|
65
|
+
export { default as TableCellLayout } from './components/table/table-cell-layout.svelte';
|
|
66
|
+
export { default as TableCellActions } from './components/table/table-cell-actions.svelte';
|
|
58
67
|
export { default as TextArea } from './components/textarea/textarea.svelte';
|
|
59
68
|
export { default as TextBox } from './components/text-box/text-box.svelte';
|
|
60
69
|
export { default as TextBoxButton } from './components/text-box/text-box-button.svelte';
|
package/dist/index.js
CHANGED
|
@@ -109,6 +109,17 @@ export { default as Skeleton } from './components/skeleton/skeleton.svelte';
|
|
|
109
109
|
// Start Slider Component
|
|
110
110
|
export { default as Slider } from './components/slider/slider.svelte';
|
|
111
111
|
// End Slider Component
|
|
112
|
+
// Start Table Component
|
|
113
|
+
export { default as Table } from './components/table/table.svelte';
|
|
114
|
+
export { default as TableHeader } from './components/table/table-header.svelte';
|
|
115
|
+
export { default as TableHeaderCell } from './components/table/table-header-cell.svelte';
|
|
116
|
+
export { default as TableBody } from './components/table/table-body.svelte';
|
|
117
|
+
export { default as TableRow } from './components/table/table-row.svelte';
|
|
118
|
+
export { default as TableCell } from './components/table/table-cell.svelte';
|
|
119
|
+
export { default as TableSelectionCell } from './components/table/table-selection-cell.svelte';
|
|
120
|
+
export { default as TableCellLayout } from './components/table/table-cell-layout.svelte';
|
|
121
|
+
export { default as TableCellActions } from './components/table/table-cell-actions.svelte';
|
|
122
|
+
// End Table Component
|
|
112
123
|
// Start TextArea Component
|
|
113
124
|
export { default as TextArea } from './components/textarea/textarea.svelte';
|
|
114
125
|
// End TextArea Component
|