@axel669/zephyr 0.2.0-beta.2 → 0.2.0-beta.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axel669/zephyr",
3
- "version": "0.2.0-beta.2",
3
+ "version": "0.2.0-beta.3",
4
4
  "description": "",
5
5
  "main": "src/index.mjs",
6
6
  "type": "module",
@@ -1,13 +1,16 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import Spinner from "../spinner/hexagon-spinner.svelte"
3
5
  export let source = null
6
+ export let message = "Loading"
4
7
  </script>
5
8
 
6
9
  {#if source !== null}
7
10
  {#await source}
8
11
  <slot name="loading">
9
12
  <ws-flex ws-x="fl.cross[center] fl.main[center]">
10
- <span>Loading</span>
13
+ <span>{message}</span>
11
14
  <Spinner size="100px" />
12
15
  </ws-flex>
13
16
  </slot>
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script context="module">
2
4
  const sortIcons = {
3
5
  "asc": "arrow-narrow-up",
@@ -30,7 +32,6 @@
30
32
  p: "0px",
31
33
  sel: "none"
32
34
  }
33
- $: console.log($context.sorting)
34
35
  $: sortIcon =
35
36
  ($context.sorting.base === sort)
36
37
  ? sortIcons[$context.sorting.direction]
@@ -2,16 +2,31 @@
2
2
 
3
3
  <script context="module">
4
4
  // find the first filter in the list that returns false
5
- const applyFilters = (data, filters) => data.filter(
6
- (row) => {
7
- for (const [filter, value] of filters) {
8
- if (filter(row, value) === false) {
9
- return false
5
+ const applyFilters = (data, filters) => {
6
+ if (Array.isArray(data) === false) {
7
+ return null
8
+ }
9
+ return data.filter(
10
+ (row) => {
11
+ for (const [filter, value] of filters) {
12
+ if (filter(row, value) === false) {
13
+ return false
14
+ }
10
15
  }
16
+ return true
11
17
  }
12
- return true
18
+ )
19
+ }
20
+ const sliceData = (data, page, pageSize, sortFunc) => {
21
+ if (data === null) {
22
+ return []
13
23
  }
14
- )
24
+ const sorted = data.sort(sortFunc)
25
+ return Array.from(
26
+ { length: pageSize },
27
+ (_, i) => sorted[page * pageSize + i]
28
+ )
29
+ }
15
30
  const noSort = {
16
31
  direction: null,
17
32
  func: (a, b) => 0,
@@ -38,26 +53,24 @@
38
53
 
39
54
  export let color = false
40
55
  export let fillHeader = true
41
- export let data = []
56
+ export let data
42
57
  export let pageSize = 10
43
58
  export let page = 0
44
59
  export let rowHeight = "40px"
45
60
 
46
- $: rows = Array.from(
47
- { length: pageSize },
48
- (_, i) => filteredData[page * pageSize + i]
49
- )
50
- $: rowCount = filteredData.length
51
- $: pageCount = Math.ceil(rowCount / pageSize)
52
- $: maxPage = Math.max(pageCount - 1, 0)
53
-
54
61
  let sorting = noSort
55
62
  let filters = new Map()
56
63
  let filterFunctions = []
57
64
 
58
- $: filteredData =
59
- applyFilters(data, filterFunctions)
60
- .sort(sorting.func)
65
+ $: filteredData = applyFilters(data, filterFunctions)
66
+ $: rows = sliceData(filteredData, page, pageSize, sorting.func)
67
+ $: rowCount = filteredData?.length ?? 0
68
+ $: pageCount = Math.ceil(rowCount / pageSize)
69
+ $: maxPage = Math.max(pageCount - 1, 0)
70
+
71
+ $: if (filteredData === null) {
72
+ console.warn("DataTable: data is not an array")
73
+ }
61
74
 
62
75
  const prev = () => page = Math.max(0, page - 1)
63
76
  const next = () => page = Math.min(maxPage, page + 1)
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import { createEventDispatcher } from "svelte"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script context="module">
2
4
  const genID = () => `${Date.now()}:${Math.random().toString(16)}`
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import variant from "../variant.mjs"
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script context="module">
2
4
  const parseNumeric = (value) => {
3
5
  if (value === "") {
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import variant from "../variant.mjs"
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import variant from "../variant.mjs"
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import { handler$ } from "../handler$.mjs"
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script context="module">
2
4
  const groupOptions = (options) => options.reduce(
3
5
  ({grouped, target = grouped}, item, pos) => {
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import { handler$ } from "../handler$.mjs"
@@ -20,7 +22,7 @@
20
22
  )
21
23
 
22
24
  $: wind = {
23
- "@solid": solid,
25
+ "$solid": solid,
24
26
  "$color": color,
25
27
  $vert: vertical,
26
28
  ...$$restProps,
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import variant from "../variant.mjs"
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import { fade } from "svelte/transition"
3
5
  import wsx from "../wsx.mjs"
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -9,7 +11,7 @@
9
11
  export let label = null
10
12
 
11
13
  $: wind = {
12
- "@progress": true,
14
+ "$progress": true,
13
15
  "$outline": outline,
14
16
  "$color": color,
15
17
  $row: row,
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import Button from "../control/button.svelte"
3
5
  import Dialog from "../layout/dialog.svelte"
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import Button from "../control/button.svelte"
3
5
  import Dialog from "../layout/dialog.svelte"
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import { fade } from "svelte/transition"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script context="module">
2
4
  const defs = {
3
5
  select: {
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script context="module">
2
4
  let topClose = null
3
5
  </script>
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import Flex from "./flex.svelte"
3
5
  import wsx from "../wsx.mjs"
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script context="module">
2
4
  const ctxStack = Symbol("stack context")
3
5
  const ctxClose = Symbol("close context")
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
package/src/text.svelte CHANGED
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "./wsx.mjs"
3
5