sveltacular 0.0.5 → 0.0.6

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.
@@ -3,6 +3,6 @@
3
3
  </section>
4
4
 
5
5
  <style>section {
6
- margin: 0 auto;
7
- padding: 0 1rem;
6
+ padding: 0;
7
+ margin: 1rem 1rem;
8
8
  }</style>
@@ -1,9 +1,9 @@
1
- <script>export let marginY = 1;
2
- export let marginX = 0;
3
- export let gap = 1;
1
+ <script>export let marginBottom = "1rem";
2
+ export let marginTop = "1rem";
3
+ export let gap = "1rem";
4
4
  </script>
5
5
 
6
- <div style={`margin: ${marginY}rem ${marginX}rem; gap: ${gap}rem`}>
6
+ <div style={`margin: ${marginTop} ${marginBottom}; gap: ${gap}`}>
7
7
  <slot />
8
8
  </div>
9
9
 
@@ -1,9 +1,9 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- marginY?: number | undefined;
5
- marginX?: number | undefined;
6
- gap?: number | undefined;
4
+ marginBottom?: string | number | undefined;
5
+ marginTop?: string | number | undefined;
6
+ gap?: string | number | undefined;
7
7
  };
8
8
  events: {
9
9
  [evt: string]: CustomEvent<any>;
@@ -1,10 +1,15 @@
1
- <script>export let gap = 1;
1
+ <script>export let marginBottom = "1rem";
2
+ export let marginTop = "1rem";
3
+ export let gap = "1rem";
2
4
  export let layout = "stretch";
3
5
  export let size = "full";
4
6
  export let wrap = false;
5
7
  </script>
6
8
 
7
- <div style={`gap: ${gap}rem`} class="{layout} {size} {wrap ? 'wrap' : 'nowrap'}">
9
+ <div
10
+ style={`margin: ${marginTop} ${marginBottom}; gap: ${gap}`}
11
+ class="{layout} {size} {wrap ? 'wrap' : 'nowrap'}"
12
+ >
8
13
  <slot />
9
14
  </div>
10
15
 
@@ -14,6 +19,7 @@ export let wrap = false;
14
19
  justify-content: center;
15
20
  align-items: center;
16
21
  flex-wrap: nowrap;
22
+ column-gap: 1rem;
17
23
  }
18
24
  div *.auto {
19
25
  width: auto;
@@ -1,7 +1,9 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- gap?: number | undefined;
4
+ marginBottom?: string | number | undefined;
5
+ marginTop?: string | number | undefined;
6
+ gap?: string | number | undefined;
5
7
  layout?: "stretch" | "center" | "end" | "start" | undefined;
6
8
  size?: "full" | "auto" | undefined;
7
9
  wrap?: boolean | undefined;
@@ -8,6 +8,9 @@ import TableHeaderRow from "./table-header-row.svelte";
8
8
  import TableHeader from "./table-header.svelte";
9
9
  import TableRow from "./table-row.svelte";
10
10
  import Table from "./table.svelte";
11
+ import Text from "../typography/text.svelte";
12
+ import TableCaption from "./table-caption.svelte";
13
+ export let caption = "";
11
14
  export let data;
12
15
  export let cols;
13
16
  $:
@@ -15,11 +18,14 @@ $:
15
18
  </script>
16
19
 
17
20
  <Table>
21
+ {#if caption}
22
+ <TableCaption>{caption}</TableCaption>
23
+ {/if}
18
24
  <TableHeader>
19
25
  <TableHeaderRow>
20
26
  {#each cols as col}
21
27
  {#if !col.hide}
22
- <TableHeaderCell>{col.label}</TableHeaderCell>
28
+ <TableHeaderCell type={col.type || typeof data[0][col.key]}>{col.label}</TableHeaderCell>
23
29
  {/if}
24
30
  {/each}
25
31
  </TableHeaderRow>
@@ -29,7 +35,13 @@ $:
29
35
  <TableRow>
30
36
  {#each cols as col}
31
37
  {#if !col.hide}
32
- <TableCell>{row[col.key]}</TableCell>
38
+ <TableCell type={col.type || typeof row[col.key]}>
39
+ {#if col.format}
40
+ {col.format(row, col.key)}
41
+ {:else}
42
+ {row[col.key]}
43
+ {/if}
44
+ </TableCell>
33
45
  {/if}
34
46
  {/each}
35
47
  </TableRow>
@@ -37,7 +49,9 @@ $:
37
49
  </TableBody>
38
50
  <TableFooter>
39
51
  <TableFooterRow>
40
- <TableFooterCell colspan={colCount}>Page 1 of 50</TableFooterCell>
52
+ <TableFooterCell colspan={colCount}>
53
+ <Text transform="uppercase">Page 1 of 50</Text>
54
+ </TableFooterCell>
41
55
  </TableFooterRow>
42
56
  </TableFooter>
43
57
  </Table>
@@ -2,6 +2,7 @@ import { SvelteComponent } from "svelte";
2
2
  import type { DataCol, DataRow } from '../types/data.js';
3
3
  declare const __propDef: {
4
4
  props: {
5
+ caption?: string | undefined;
5
6
  data: DataRow[];
6
7
  cols: DataCol[];
7
8
  };
@@ -0,0 +1,14 @@
1
+ <caption>
2
+ <slot />
3
+ </caption>
4
+
5
+ <style>caption {
6
+ padding: 0.5rem 0.75rem;
7
+ font-weight: 600;
8
+ font-size: 1rem;
9
+ line-height: 1.25rem;
10
+ letter-spacing: 0.1em;
11
+ text-transform: uppercase;
12
+ font-family: sans-serif;
13
+ text-shadow: 1px 1px 1px black;
14
+ }</style>
@@ -0,0 +1,27 @@
1
+ /** @typedef {typeof __propDef.props} TableCaptionProps */
2
+ /** @typedef {typeof __propDef.events} TableCaptionEvents */
3
+ /** @typedef {typeof __propDef.slots} TableCaptionSlots */
4
+ export default class TableCaption extends SvelteComponent<{
5
+ [x: string]: never;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {
9
+ default: {};
10
+ }> {
11
+ }
12
+ export type TableCaptionProps = typeof __propDef.props;
13
+ export type TableCaptionEvents = typeof __propDef.events;
14
+ export type TableCaptionSlots = typeof __propDef.slots;
15
+ import { SvelteComponent } from "svelte";
16
+ declare const __propDef: {
17
+ props: {
18
+ [x: string]: never;
19
+ };
20
+ events: {
21
+ [evt: string]: CustomEvent<any>;
22
+ };
23
+ slots: {
24
+ default: {};
25
+ };
26
+ };
27
+ export {};
@@ -1,13 +1,19 @@
1
1
  <script>export let colspan = 1;
2
+ export let type = void 0;
2
3
  </script>
3
4
 
4
- <td {colspan}>
5
+ <td {colspan} class={type}>
5
6
  <slot />
6
7
  </td>
7
8
 
8
- <style>
9
- td {
10
- padding: 0.5rem;
11
- font-size: 1rem;
12
- }
13
- </style>
9
+ <style>td {
10
+ padding: 0.5rem;
11
+ font-size: 1rem;
12
+ }
13
+ td.currency, td.number {
14
+ text-align: right;
15
+ }
16
+ td.boolean {
17
+ text-align: center;
18
+ text-transform: uppercase;
19
+ }</style>
@@ -2,6 +2,7 @@ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  colspan?: number | undefined;
5
+ type?: string | undefined;
5
6
  };
6
7
  events: {
7
8
  [evt: string]: CustomEvent<any>;
@@ -8,5 +8,8 @@
8
8
  <style>
9
9
  td {
10
10
  padding: 0.5rem;
11
+ font-size: 0.8rem;
12
+ font-family: sans-serif;
13
+ text-shadow: 1px 1px 1px black;
11
14
  }
12
15
  </style>
@@ -1,18 +1,25 @@
1
1
  <script>export let colspan = 1;
2
+ export let type = void 0;
2
3
  </script>
3
4
 
4
- <th {colspan}>
5
+ <th {colspan} class={type}>
5
6
  <slot />
6
7
  </th>
7
8
 
8
- <style>
9
- th {
10
- text-align: left;
11
- padding: 0.5rem 0.75rem;
12
- font-weight: 500;
13
- font-size: 0.875rem;
14
- line-height: 1.25rem;
15
- letter-spacing: 0.015em;
16
- text-transform: uppercase;
17
- }
18
- </style>
9
+ <style>th {
10
+ text-align: left;
11
+ padding: 0.5rem 0.75rem;
12
+ font-weight: 500;
13
+ font-size: 0.8rem;
14
+ font-family: sans-serif;
15
+ line-height: 1.25rem;
16
+ letter-spacing: 0.015em;
17
+ text-transform: uppercase;
18
+ text-shadow: 1px 1px 1px black;
19
+ }
20
+ th.currency, th.number {
21
+ text-align: right;
22
+ }
23
+ th.boolean {
24
+ text-align: center;
25
+ }</style>
@@ -2,6 +2,7 @@ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  colspan?: number | undefined;
5
+ type?: string | undefined;
5
6
  };
6
7
  events: {
7
8
  [evt: string]: CustomEvent<any>;
@@ -1,9 +1,9 @@
1
- export type DataRow = {
2
- [key: string]: unknown;
3
- };
1
+ export type DataRow = Record<string, unknown>;
4
2
  export type DataCol = {
5
3
  key: string;
6
4
  label: string;
5
+ type?: string;
6
+ format?: (row: DataRow, key: string) => string;
7
7
  hide?: boolean;
8
8
  };
9
9
  export type Pagination = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltacular",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "scripts": {
5
5
  "watch": "npm run dev -- --open",
6
6
  "dev": "vite dev",