跳到主要内容

ui/build/utils

ui/build/utils

Classes

RenderComponentConfig

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:39

A helper class to make it easy to identify Svelte components in columnDef.cell and columnDef.header properties.

NOTE: This class should only be used internally by the adapter. If you're reading this and you don't know what this is for, you probably don't need it.

Example

The cast below is illustrative for the JSDoc snippet only — not runtime code.

{@const result = content(context as any)}
{#if result instanceof RenderComponentConfig}
  {@const { component: Component, props } = result}
  <Component {...props} />
{/if}

Type Parameters

Type Parameter
TComponent extends Component<Record<string, never>>

Constructors

Constructor
new RenderComponentConfig<TComponent>(component, props?): RenderComponentConfig<TComponent>;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:42

Parameters
Parameter Type
component TComponent
props? Record<string, never> | ComponentProps<TComponent>
Returns

RenderComponentConfig<TComponent>

Properties

component
component: TComponent;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:40

props
props: Record<string, never> | ComponentProps<TComponent>;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:41


RenderSnippetConfig

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:60

A helper class to make it easy to identify Svelte Snippets in columnDef.cell and columnDef.header properties.

NOTE: This class should only be used internally by the adapter. If you're reading this and you don't know what this is for, you probably don't need it.

Example

The cast below is illustrative for the JSDoc snippet only — not runtime code.

{@const result = content(context as any)}
{#if result instanceof RenderSnippetConfig}
  {@const { snippet, params } = result}
  {@render snippet(params)}
{/if}

Type Parameters

Type Parameter
TProps

Constructors

Constructor
new RenderSnippetConfig<TProps>(snippet, params): RenderSnippetConfig<TProps>;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:63

Parameters
Parameter Type
snippet Snippet<[TProps]>
params TProps
Returns

RenderSnippetConfig<TProps>

Properties

params
params: TProps;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:62

snippet
snippet: Snippet<[TProps]>;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:61

Type Aliases

WithElementRef

type WithElementRef<T, U> = T & object;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:19

Type Declaration

ref?
optional ref?: U | null;

Type Parameters

Type Parameter Default type
T -
U extends HTMLElement HTMLElement

WithoutChild

type WithoutChild<T> = T extends object ? Omit<T, "child"> : T;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:12

Type Parameters

Type Parameter
T

WithoutChildren

type WithoutChildren<T> = T extends object ? Omit<T, "children"> : T;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:15

Type Parameters

Type Parameter
T

WithoutChildrenOrChild

type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:18

Type Parameters

Type Parameter
T

Variables

DEFAULT_CSS

const DEFAULT_CSS: object;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:5

Type Declaration

INPUT_ELEMENT
INPUT_ELEMENT: object;
INPUT_ELEMENT.PX
PX: number;
INPUT_ELEMENT.REM
REM: number;
INPUT_ELEMENT.TW_UNIT
TW_UNIT: number;

Functions

cn()

function cn(...inputs): string;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:3

Parameters

Parameter Type
...inputs ClassValue[]

Returns

string


formatFileSize()

function formatFileSize(bytes): string;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:4

Parameters

Parameter Type
bytes number

Returns

string


parseServerTimestamp()

function parseServerTimestamp(input): Date | null;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:114

Parses a stored UTC ISO instant for display in the local timezone.

Parameters

Parameter Type
input string

Returns

Date | null


parseUtcInstantZoned()

function parseUtcInstantZoned(value): any;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:116

Parse a stored UTC ISO instant for calendar/time pickers (local timezone).

Parameters

Parameter Type
value string

Returns

any


renderComponent()

function renderComponent<T, Props>(component, props): RenderComponentConfig<T>;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:87

A helper function to help create cells from Svelte components through ColumnDef's cell and header properties.

This is only to be used with Svelte Components - use renderSnippet for Svelte Snippets.

Type Parameters

Type Parameter
T extends Component<Record<string, never>, { }, string>
Props extends Record<string, never>

Parameters

Parameter Type Description
component T A Svelte component
props Props The props to pass to component

Returns

RenderComponentConfig<T>

A RenderComponentConfig object that helps svelte-table know how to render the header/cell component.

Example

// +page.svelte
const defaultColumns = [
  columnHelper.accessor('name', {
    header: header => renderComponent(SortHeader, { label: 'Name', header }),
  }),
  columnHelper.accessor('state', {
    header: header => renderComponent(SortHeader, { label: 'State', header }),
  }),
]

See

https://tanstack.com/table/latest/docs/guide/column-defs


renderSnippet()

function renderSnippet<TProps>(snippet, params): RenderSnippetConfig<TProps>;

Defined in: apps/website/.api-docs-entry/ui/build/utils/index.d.ts:112

A helper function to help create cells from Svelte Snippets through ColumnDef's cell and header properties.

The snippet must only take one parameter.

This is only to be used with Snippets - use renderComponent for Svelte Components.

Type Parameters

Type Parameter
TProps

Parameters

Parameter Type Description
snippet Snippet<[TProps]> -
params TProps -

Returns

RenderSnippetConfig<TProps>

  • A RenderSnippetConfig object that helps svelte-table know how to render the header/cell snippet.

Example

// +page.svelte
const defaultColumns = [
  columnHelper.accessor('name', {
    cell: cell => renderSnippet(nameSnippet, { name: cell.row.name }),
  }),
  columnHelper.accessor('state', {
    cell: cell => renderSnippet(stateSnippet, { state: cell.row.state }),
  }),
]

See

https://tanstack.com/table/latest/docs/guide/column-defs

References

ScrollAlignment

Re-exports ScrollAlignment


ScrollToIndexOptions

Re-exports ScrollToIndexOptions


ScrollToOffsetOptions

Re-exports ScrollToOffsetOptions


VirtualItem

Re-exports VirtualItem


Virtualizer

Re-exports Virtualizer


VirtualizerOptions

Re-exports VirtualizerOptions