sveltacular 0.0.28 → 0.0.30

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.
@@ -2,6 +2,14 @@
2
2
  import FlexRow from '../layout/flex-row.svelte';
3
3
  </script>
4
4
 
5
- <FlexRow layout="stretch">
6
- <slot />
7
- </FlexRow>
5
+ <div>
6
+ <FlexRow layout="stretch">
7
+ <slot />
8
+ </FlexRow>
9
+ </div>
10
+
11
+ <style>
12
+ div {
13
+ margin-top: 1.5rem;
14
+ }
15
+ </style>
@@ -1,12 +1,18 @@
1
1
  <script>import Headline from "../typography/headline.svelte";
2
- export let title;
3
2
  export let level = 4;
3
+ export let underline = true;
4
4
  </script>
5
5
 
6
- <div>
7
- <Headline {level}>{title}</Headline>
6
+ <div class:underline>
7
+ <Headline {level}>
8
+ <slot />
9
+ </Headline>
8
10
  </div>
9
11
 
10
12
  <style>div {
11
13
  margin-bottom: 1rem;
14
+ }
15
+ div.underline {
16
+ padding-bottom: 0.5rem;
17
+ border-bottom: solid 1px var(--divider-color, rgba(127, 127, 127, 0.5));
12
18
  }</style>
@@ -2,13 +2,15 @@ import { SvelteComponent } from "svelte";
2
2
  import type { SectionLevel } from '../types/generic.js';
3
3
  declare const __propDef: {
4
4
  props: {
5
- title: string;
6
5
  level?: SectionLevel | undefined;
6
+ underline?: boolean | undefined;
7
7
  };
8
8
  events: {
9
9
  [evt: string]: CustomEvent<any>;
10
10
  };
11
- slots: {};
11
+ slots: {
12
+ default: {};
13
+ };
12
14
  };
13
15
  export type FormHeaderProps = typeof __propDef.props;
14
16
  export type FormHeaderEvents = typeof __propDef.events;
@@ -1,4 +1,4 @@
1
- <script>export let id;
1
+ <script>export let id = void 0;
2
2
  export let required = false;
3
3
  </script>
4
4
 
@@ -1,7 +1,7 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- id: string;
4
+ id?: string | undefined;
5
5
  required?: boolean | undefined;
6
6
  };
7
7
  events: {
@@ -0,0 +1,17 @@
1
+ <script>import FormHeader from "./form-header.svelte";
2
+ export let title = void 0;
3
+ export let level = 4;
4
+ </script>
5
+
6
+ <section>
7
+ {#if title}
8
+ <FormHeader {level}>{title}</FormHeader>
9
+ {/if}
10
+ <slot />
11
+ </section>
12
+
13
+ <style>
14
+ section {
15
+ margin-bottom: 1rem;
16
+ }
17
+ </style>
@@ -0,0 +1,20 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { SectionLevel } from '../types/generic.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ title?: string | undefined;
6
+ level?: SectionLevel | undefined;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {
12
+ default: {};
13
+ };
14
+ };
15
+ export type FormSectionProps = typeof __propDef.props;
16
+ export type FormSectionEvents = typeof __propDef.events;
17
+ export type FormSectionSlots = typeof __propDef.slots;
18
+ export default class FormSection extends SvelteComponent<FormSectionProps, FormSectionEvents, FormSectionSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,25 @@
1
+ <script>import FormField from "../form-field.svelte";
2
+ import FormLabel from "../form-label.svelte";
3
+ export let size = "md";
4
+ export let value;
5
+ </script>
6
+
7
+ <FormField {size}>
8
+ {#if $$slots.default}
9
+ <FormLabel><slot /></FormLabel>
10
+ {/if}
11
+ <div class="input">
12
+ {value}
13
+ </div>
14
+ </FormField>
15
+
16
+ <style>
17
+ .input {
18
+ background-color: transparent;
19
+ line-height: 2rem;
20
+ font-size: 1rem;
21
+ width: 100%;
22
+ padding-left: 1rem;
23
+ border-bottom: solid 1px var(--form-input-border, black);
24
+ }
25
+ </style>
@@ -0,0 +1,20 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { FormFieldSizeOptions } from '../../index.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ size?: FormFieldSizeOptions | undefined;
6
+ value: string;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {
12
+ default: {};
13
+ };
14
+ };
15
+ export type InfoBoxProps = typeof __propDef.props;
16
+ export type InfoBoxEvents = typeof __propDef.events;
17
+ export type InfoBoxSlots = typeof __propDef.slots;
18
+ export default class InfoBox extends SvelteComponent<InfoBoxProps, InfoBoxEvents, InfoBoxSlots> {
19
+ }
20
+ export {};
@@ -20,6 +20,8 @@ let text = getText();
20
20
  let open = false;
21
21
  let highlightIndex = -1;
22
22
  let filteredItems = [];
23
+ $:
24
+ isSeachable = searchable || !!search;
23
25
  const onSelect = (e) => {
24
26
  value = e.detail.value;
25
27
  dispatch("change", value);
@@ -67,7 +69,7 @@ const onInputKeyPress = (e) => {
67
69
  }
68
70
  };
69
71
  const triggerSearch = debounce(async () => {
70
- if (search && searchable) {
72
+ if (search && isSeachable) {
71
73
  items = await search(text);
72
74
  }
73
75
  updateText();
@@ -75,7 +77,7 @@ const triggerSearch = debounce(async () => {
75
77
  }, 300);
76
78
  const applyFilter = () => {
77
79
  const searchText = text.trim().toLowerCase();
78
- filteredItems = searchText && searchable ? items.map((item, index) => ({ ...item, index })).filter((item) => item.name.toLowerCase().includes(searchText)) : items.map((item, index) => ({ ...item, index }));
80
+ filteredItems = searchText && isSeachable ? items.map((item, index) => ({ ...item, index })).filter((item) => item.name.toLowerCase().includes(searchText)) : items.map((item, index) => ({ ...item, index }));
79
81
  };
80
82
  const clear = () => {
81
83
  text = "";
@@ -104,7 +106,7 @@ triggerSearch();
104
106
  bind:value={text}
105
107
  {required}
106
108
  {disabled}
107
- readonly={!searchable}
109
+ readonly={!isSeachable}
108
110
  on:focus={() => (open = true)}
109
111
  on:keyup={onInputKeyPress}
110
112
  data-value={value}
@@ -113,7 +115,7 @@ triggerSearch();
113
115
  <button type="button" class="icon" on:click={clickArrow} on:keydown={clickArrow}>
114
116
  <AngleUpIcon />
115
117
  </button>
116
- {#if text}
118
+ {#if text && isSeachable}
117
119
  <button type="button" class="clear" on:click={clear} on:keydown={clear}> X </button>
118
120
  {/if}
119
121
  <div class="dropdown">
@@ -177,5 +179,5 @@ div .dropdown {
177
179
  top: 100%;
178
180
  left: 0;
179
181
  width: 100%;
180
- z-index: 1;
182
+ z-index: 3;
181
183
  }</style>
@@ -1,7 +1,9 @@
1
1
  <script>import { uniqueId } from "../../helpers/unique-id.js";
2
2
  import FormField from "../form-field.svelte";
3
3
  import FormLabel from "../form-label.svelte";
4
+ import { createEventDispatcher } from "svelte";
4
5
  const id = uniqueId();
6
+ const dipatch = createEventDispatcher();
5
7
  export let value = "";
6
8
  export let placeholder = "";
7
9
  export let helperText = "";
@@ -36,6 +38,7 @@ const onInput = (e) => {
36
38
  } else if (textCase === "upper") {
37
39
  value = value.toUpperCase();
38
40
  }
41
+ dipatch("input", value);
39
42
  };
40
43
  </script>
41
44
 
@@ -21,6 +21,9 @@ declare const __propDef: {
21
21
  textCase?: 'lower' | 'upper' | undefined;
22
22
  };
23
23
  events: {
24
+ change: CustomEvent<string>;
25
+ input: CustomEvent<string>;
26
+ } & {
24
27
  [evt: string]: CustomEvent<any>;
25
28
  };
26
29
  slots: {
@@ -0,0 +1,26 @@
1
+ <script>import TextBox from "../text-box/text-box.svelte";
2
+ export let protocol = "https";
3
+ export let value = "";
4
+ export let size = "lg";
5
+ export let placeholder = "example.com";
6
+ const onInput = () => {
7
+ const urlParts = value.split("://");
8
+ if (["http", "https"].includes(urlParts[0])) {
9
+ protocol = urlParts[0];
10
+ value = urlParts[1];
11
+ }
12
+ };
13
+ </script>
14
+
15
+ <TextBox
16
+ bind:value
17
+ type="text"
18
+ {placeholder}
19
+ prefix={protocol + '://'}
20
+ {size}
21
+ on:input={onInput}
22
+ on:change={onInput}
23
+ allowSpaces={false}
24
+ >
25
+ <slot />
26
+ </TextBox>
@@ -0,0 +1,23 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { FormFieldSizeOptions } from '../../index.js';
3
+ import type { HttpProtocol } from '../../types/generic.js';
4
+ declare const __propDef: {
5
+ props: {
6
+ protocol?: HttpProtocol | undefined;
7
+ value?: string | undefined;
8
+ size?: FormFieldSizeOptions | undefined;
9
+ placeholder?: string | undefined;
10
+ };
11
+ events: {
12
+ [evt: string]: CustomEvent<any>;
13
+ };
14
+ slots: {
15
+ default: {};
16
+ };
17
+ };
18
+ export type UrlBoxProps = typeof __propDef.props;
19
+ export type UrlBoxEvents = typeof __propDef.events;
20
+ export type UrlBoxSlots = typeof __propDef.slots;
21
+ export default class UrlBox extends SvelteComponent<UrlBoxProps, UrlBoxEvents, UrlBoxSlots> {
22
+ }
23
+ export {};
@@ -1,4 +1,4 @@
1
- <script>export let title;
1
+ <script>export let title = void 0;
2
2
  export let border = true;
3
3
  </script>
4
4
 
@@ -1,7 +1,7 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- title: string;
4
+ title?: string | undefined;
5
5
  border?: boolean | undefined;
6
6
  };
7
7
  events: {
package/dist/index.d.ts CHANGED
@@ -16,6 +16,9 @@ export { default as FormLabel } from './forms/form-label.svelte';
16
16
  export { default as Form } from './forms/form.svelte';
17
17
  export { default as FormHeader } from './forms/form-header.svelte';
18
18
  export { default as FormFooter } from './forms/form-footer.svelte';
19
+ export { default as FormSection } from './forms/form-section.svelte';
20
+ export { default as InfoBox } from './forms/info-box/info-box.svelte';
21
+ export { default as UrlBox } from './forms/url-box/url-box.svelte';
19
22
  export { default as Card } from './generic/card/card.svelte';
20
23
  export { default as Divider } from './generic/divider/divider.svelte';
21
24
  export { default as Link } from './generic/link/link.svelte';
package/dist/index.js CHANGED
@@ -17,6 +17,9 @@ export { default as FormLabel } from './forms/form-label.svelte';
17
17
  export { default as Form } from './forms/form.svelte';
18
18
  export { default as FormHeader } from './forms/form-header.svelte';
19
19
  export { default as FormFooter } from './forms/form-footer.svelte';
20
+ export { default as FormSection } from './forms/form-section.svelte';
21
+ export { default as InfoBox } from './forms/info-box/info-box.svelte';
22
+ export { default as UrlBox } from './forms/url-box/url-box.svelte';
20
23
  // Generic
21
24
  export { default as Card } from './generic/card/card.svelte';
22
25
  export { default as Divider } from './generic/divider/divider.svelte';
@@ -6,12 +6,17 @@ import Divider from "../generic/divider/divider.svelte";
6
6
  import Overlay from "../generic/overlay.svelte";
7
7
  import Button from "../forms/button/button.svelte";
8
8
  import DialogCloseButton from "./dialog-close-button.svelte";
9
+ import { createEventDispatcher } from "svelte";
10
+ const dispatch = createEventDispatcher();
9
11
  export let open = false;
10
12
  export let title = void 0;
11
13
  export let size = "md";
12
14
  export let buttonText = "OK";
13
15
  export let showCloseButton = true;
14
- const close = () => open = false;
16
+ const close = () => {
17
+ dispatch("close");
18
+ open = false;
19
+ };
15
20
  </script>
16
21
 
17
22
  {#if open}
@@ -9,6 +9,8 @@ declare const __propDef: {
9
9
  showCloseButton?: boolean | undefined;
10
10
  };
11
11
  events: {
12
+ close: CustomEvent<void>;
13
+ } & {
12
14
  [evt: string]: CustomEvent<any>;
13
15
  };
14
16
  slots: {
@@ -15,12 +15,12 @@ export let noText = "No";
15
15
  export let showCloseButton = true;
16
16
  const dispatch = createEventDispatcher();
17
17
  const no = () => {
18
- open = false;
19
18
  dispatch("no");
19
+ open = false;
20
20
  };
21
21
  const yes = () => {
22
- open = false;
23
22
  dispatch("yes");
23
+ open = false;
24
24
  };
25
25
  </script>
26
26
 
@@ -2,10 +2,15 @@
2
2
  import Dialog from "./dialog-window.svelte";
3
3
  import Overlay from "../generic/overlay.svelte";
4
4
  import DialogCloseButton from "./dialog-close-button.svelte";
5
+ import { createEventDispatcher } from "svelte";
6
+ const dispatch = createEventDispatcher();
5
7
  export let open = false;
6
8
  export let size = "md";
7
9
  export let showCloseButton = true;
8
- const close = () => open = false;
10
+ const close = () => {
11
+ dispatch("close");
12
+ open = false;
13
+ };
9
14
  </script>
10
15
 
11
16
  {#if open}
@@ -7,6 +7,8 @@ declare const __propDef: {
7
7
  showCloseButton?: boolean | undefined;
8
8
  };
9
9
  events: {
10
+ close: CustomEvent<void>;
11
+ } & {
10
12
  [evt: string]: CustomEvent<any>;
11
13
  };
12
14
  slots: {
@@ -0,0 +1,36 @@
1
+ <script>export let value = 0;
2
+ </script>
3
+
4
+ <div class="progress-bar" style="--progress-value: {value}%">
5
+ <div class="progress">
6
+ <div class="progress-value">{value}%</div>
7
+ </div>
8
+ </div>
9
+
10
+ <style>.progress-bar {
11
+ height: 2rem;
12
+ background-color: var(--base-color-fg, #ccc);
13
+ border-radius: 1rem;
14
+ margin-bottom: 1rem;
15
+ }
16
+ .progress-bar .progress {
17
+ height: 100%;
18
+ background-color: var(--primary-color, #00a);
19
+ color: white;
20
+ border-radius: 1rem;
21
+ transition: width 0.5s ease-in-out;
22
+ width: var(--progress-value, 0%);
23
+ min-width: 3rem;
24
+ display: flex;
25
+ align-items: center;
26
+ justify-content: flex-end;
27
+ }
28
+ .progress-bar .progress-value {
29
+ color: var(--base-color-bg, #fff);
30
+ font-size: 1rem;
31
+ font-family: var(--base-font-family, sans-serif);
32
+ font-weight: 500;
33
+ line-height: 1.5rem;
34
+ padding: 0 0.5rem;
35
+ text-shadow: 0 0 0.5rem rgba(0, 0, 0, 0.5);
36
+ }</style>
@@ -0,0 +1,16 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ value?: number | undefined;
5
+ };
6
+ events: {
7
+ [evt: string]: CustomEvent<any>;
8
+ };
9
+ slots: {};
10
+ };
11
+ export type ProgressProps = typeof __propDef.props;
12
+ export type ProgressEvents = typeof __propDef.events;
13
+ export type ProgressSlots = typeof __propDef.slots;
14
+ export default class Progress extends SvelteComponent<ProgressProps, ProgressEvents, ProgressSlots> {
15
+ }
16
+ export {};
@@ -8,10 +8,11 @@ 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 Loading from "../placeholders/loading.svelte";
11
12
  import Text from "../typography/text.svelte";
12
13
  import TableCaption from "./table-caption.svelte";
13
14
  export let caption = "";
14
- export let rows;
15
+ export let rows = void 0;
15
16
  export let cols;
16
17
  export let pagination = void 0;
17
18
  export let editRow = void 0;
@@ -19,7 +20,7 @@ export let deleteRow = void 0;
19
20
  const getColType = (col) => {
20
21
  if (col.type)
21
22
  return col.type;
22
- if (rows.length === 0)
23
+ if (!rows?.length)
23
24
  return "string";
24
25
  return typeof rows[0][col.key];
25
26
  };
@@ -44,7 +45,7 @@ $:
44
45
  $:
45
46
  colCount = Math.max(1, cols.filter((col) => !col.hide).length) + (hasActionRow ? 1 : 0);
46
47
  $:
47
- totalPages = pagination ? Math.ceil((pagination.total || rows.length) / pagination.perPage) : 1;
48
+ totalPages = pagination && rows ? Math.ceil((pagination.total || rows.length) / pagination.perPage) : 1;
48
49
  </script>
49
50
 
50
51
  <Table>
@@ -64,11 +65,15 @@ $:
64
65
  </TableHeaderRow>
65
66
  </TableHeader>
66
67
  <TableBody>
67
- {#if rows.length == 0}
68
+ {#if !rows?.length}
68
69
  <TableRow>
69
70
  <TableCell colspan={colCount}>
70
71
  <div class="empty">
71
- <Text>No data</Text>
72
+ {#if rows === undefined}
73
+ <Loading />
74
+ {:else}
75
+ <Text>No data</Text>
76
+ {/if}
72
77
  </div>
73
78
  </TableCell>
74
79
  </TableRow>
@@ -3,7 +3,7 @@ import type { DataCol, DataRow, Pagination } from '../types/data.js';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  caption?: string | undefined;
6
- rows: DataRow[];
6
+ rows?: DataRow[] | undefined;
7
7
  cols: DataCol[];
8
8
  pagination?: Pagination | undefined;
9
9
  editRow?: ((row: DataRow) => unknown) | undefined;
@@ -1 +1,3 @@
1
1
  export type SectionLevel = 1 | 2 | 3 | 4 | 5 | 6;
2
+ export type HttpProtocol = 'http' | 'https';
3
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltacular",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "scripts": {
5
5
  "watch": "npm run dev -- --open",
6
6
  "dev": "vite dev",