Skip to main content
Glama
deleonio
by deleonio
table-selection.ts1.09 kB
import type { Generic } from 'adopted-style-sheets'; import type { KoliBriTableSelection, Stringified } from '../types'; import { parseJson, setState } from '../utils'; import { isObject } from '../validators'; /* types */ export type TableSelectionPropType = Stringified<KoliBriTableSelection>; /** * Defines how rows can be selected and the current selection. */ export type PropTableSelection = { selection: TableSelectionPropType; }; /* validator */ export const validateTableSelection = (component: Generic.Element.Component, value?: TableSelectionPropType): void => { const parseSerializedValue = () => { try { return parseJson<KoliBriTableSelection>(value); } catch (e) { return undefined; } }; const validateObject = (value?: KoliBriTableSelection) => { return value && isObject(value) && typeof value.label === 'function' && (!value.selectedKeys || Array.isArray(value.selectedKeys)); }; const objectValue = typeof value === 'string' ? parseSerializedValue() : value; if (validateObject(objectValue)) { setState(component, '_selection', value); } };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/deleonio/public-ui-kolibri'

If you have feedback or need assistance with the MCP directory API, please join our Discord server