import { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type $RestProps = SvelteHTMLElements["p"];

type $Props = {
  /**
   * Specify `"end"` or `"front"`. `"front"` only works when `lines` is `1`.
   * @default "end"
   */
  clamp?: "end" | "front";

  /**
   * Number of visible lines before truncating. Values above `1` use multiline mode (end clamp only).
   * @default 1
   */
  lines?: number;

  children?: (this: void) => void;

  [key: `data-${string}`]: unknown;
};

export type TruncateProps = Omit<$RestProps, keyof $Props> & $Props;

export default class Truncate extends SvelteComponentTyped<
  TruncateProps,
  Record<string, any>,
  { default: Record<string, never> }
> {}
