@kws3/ui 2.2.5 → 2.3.1

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/CHANGELOG.mdx CHANGED
@@ -1,4 +1,12 @@
1
- # 2.2.3
1
+ # 2.3.1
2
+ - `DatePicker` - add support for configurable border radius
3
+ - `DatePicker` - add support for configurable box shadow
4
+ - `DatePicker` - bug fix on date range selection colors
5
+
6
+ # 2.3.0
7
+ - New component `InfiniteList` Added
8
+
9
+ # 2.2.5
2
10
  - `ScrollableList` - bugfixes, and add support for removing items without affecting scroll position
3
11
 
4
12
  # 2.2.4
@@ -0,0 +1,136 @@
1
+ <!--
2
+ @component
3
+
4
+
5
+ @param {array} [items=[]] - Array of items, Default: `[]`
6
+ @param {object} [iteration_key=null] - Iteration key - by default it uses the index of the array inside the keyed each block, Default: `null`
7
+ @param {string} [height="100%"] - Height of the wrapper, CSS String, Default: `"100%"`
8
+ @param {number} [end_offset=400] - `end` event will be fired when the scroll position reaches this many pixels from the end of the list., Default: `400`
9
+ @param {string} [style=""] - Inline CSS for scroller container, Default: `""`
10
+ @param {string} [class=""] - CSS classes for scroller container, Default: `""`
11
+
12
+ ### Events
13
+ - `end` - Fired when the scroll position reaches `end_offset` pixels from the end of the list.
14
+
15
+ ### Slots
16
+ - `<slot name="default" {item} {index} />` - Default slot for list view items
17
+ - `<slot name="loader" />` - Optional slot to display a loading graphic at the bottom of the list
18
+ while more items are loading
19
+
20
+ -->
21
+ {#if hasResizeObserver}
22
+ <div
23
+ bind:this={viewport}
24
+ class="kws-scrollable-list kws-infinite-list with-resize-observer {klass}"
25
+ on:scroll={handle_scroll}
26
+ style="height:{height};{style}"
27
+ use:resizeObserver
28
+ on:resize={resize}>
29
+ <div bind:this={contents}>
30
+ {#each visible as item (item.index)}
31
+ <div class="row">
32
+ <!--Default slot for list view items-->
33
+ <slot item={item.data} index={item.index} />
34
+ </div>
35
+ {/each}
36
+ <!--Optional slot to display a loading graphic at the bottom of the list
37
+ while more items are loading-->
38
+ <slot name="loader" />
39
+ </div>
40
+ </div>
41
+ {:else}
42
+ <div
43
+ bind:this={viewport}
44
+ class="kws-scrollable-list kws-infinite-list {klass}"
45
+ on:scroll={handle_scroll}
46
+ style="height:{height};{style}"
47
+ bind:offsetHeight={viewport_height}>
48
+ <div bind:this={contents}>
49
+ {#each visible as item (item.index)}
50
+ <div class="row">
51
+ <!--Default slot for list view items-->
52
+ <slot item={item.data} index={item.index} />
53
+ </div>
54
+ {/each}
55
+ <!--Optional slot to display a loading graphic at the bottom of the list
56
+ while more items are loading-->
57
+ <slot name="loader" />
58
+ </div>
59
+ </div>
60
+ {/if}
61
+
62
+ <style>
63
+ .kws-infinite-list {
64
+ overflow: auto;
65
+ -webkit-overflow-scrolling: touch;
66
+ position: relative;
67
+ height: 100%;
68
+ }
69
+ </style>
70
+
71
+ <script>
72
+ import { hasResizeObserver, resizeObserver } from "@kws3/ui/resizeObserver";
73
+ import { createEventDispatcher } from "svelte";
74
+
75
+ const fire = createEventDispatcher();
76
+ /**
77
+ * Array of items
78
+ */
79
+ export let items = [],
80
+ /**
81
+ * Iteration key - by default it uses the index of the array inside the keyed each block
82
+ */
83
+ iteration_key = null,
84
+ /**
85
+ * Height of the wrapper, CSS String
86
+ */
87
+ height = "100%",
88
+ /**
89
+ * `end` event will be fired when the scroll position reaches this many pixels from the end of the list.
90
+ */
91
+ end_offset = 400,
92
+ /**
93
+ * Inline CSS for scroller container
94
+ */
95
+ style = "";
96
+
97
+ /**
98
+ * CSS classes for scroller container
99
+ */
100
+ let klass = "";
101
+ export { klass as class };
102
+
103
+ // local state
104
+ let viewport,
105
+ contents,
106
+ viewport_height = 0,
107
+ visible,
108
+ fired = false;
109
+
110
+ $: visible = items.slice().map((data, i) => ({
111
+ index: iteration_key ? data[iteration_key] : i,
112
+ data,
113
+ }));
114
+
115
+ function handle_scroll() {
116
+ const { scrollTop, scrollHeight } = viewport;
117
+ let offset = scrollHeight - viewport_height - scrollTop;
118
+ // fire on:end event if we scrolled past the end_offset
119
+ if (offset <= end_offset) {
120
+ if (!fired) {
121
+ /**
122
+ * Fired when the scroll position reaches `end_offset` pixels from the end of the list.
123
+ */
124
+ fire("end");
125
+ }
126
+ fired = true;
127
+ } else {
128
+ fired = false;
129
+ }
130
+ }
131
+
132
+ const resize = () => {
133
+ viewport_height = viewport.offsetHeight;
134
+ handle_scroll();
135
+ };
136
+ </script>
package/index.d.ts CHANGED
@@ -16,6 +16,7 @@ export { default as TimelineHeader } from "./helpers/Timeline/TimelineHeader.sve
16
16
  export { default as Nl2br } from "./helpers/Nl2br.svelte";
17
17
  export { default as ClipboardCopier } from "./helpers/ClipboardCopier.svelte";
18
18
  export { default as ScrollableList } from "./helpers/ScrollableList.svelte";
19
+ export { default as InfiniteList } from "./helpers/InfiniteList.svelte";
19
20
  export { default as FloatingUIOutput } from "./helpers/FloatingUI/FloatingUIOutput.svelte";
20
21
  export { default as Floatie } from "./helpers/FloatingUI/Floatie.svelte";
21
22
  export { default as ConfirmButton } from "./buttons/ConfirmButton.svelte";
package/index.js CHANGED
@@ -18,6 +18,7 @@ export { default as TimelineHeader } from "./helpers/Timeline/TimelineHeader.sve
18
18
  export { default as Nl2br } from "./helpers/Nl2br.svelte";
19
19
  export { default as ClipboardCopier } from "./helpers/ClipboardCopier.svelte";
20
20
  export { default as ScrollableList } from "./helpers/ScrollableList.svelte";
21
+ export { default as InfiniteList } from "./helpers/InfiniteList.svelte";
21
22
  export {
22
23
  alert,
23
24
  confirm,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kws3/ui",
3
- "version": "2.2.5",
3
+ "version": "2.3.1",
4
4
  "description": "UI components for use with Svelte v3 applications.",
5
5
  "main": "index.js",
6
6
  "svelte": "index.js",
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "typescript": "^5.0.4"
37
37
  },
38
- "gitHead": "7a85c9f2d6e4021ac05477ccda398d54064a4c13"
38
+ "gitHead": "c617cd16beda41c5cb580bb8b6d0e562ec07da50"
39
39
  }
@@ -1,6 +1,9 @@
1
1
  $kws-theme-colors: $colors !default;
2
2
  $kws-datepicker-background: $scheme-main-ter !default;
3
3
  $kws-datepicker-text: $text !default;
4
+ $kws-datepicker-shadow: 0 2px 5px rgba(0, 0, 0, 0.3),
5
+ 0 0 0 0.0625rem rgba(0, 0, 0, 0.1) !default;
6
+ $kws-datepicker-radius: 0px !default;
4
7
 
5
8
  .flatpickr-calendar {
6
9
  $inRangeBg: lighten($kws-datepicker-text, 55);
@@ -8,10 +11,21 @@ $kws-datepicker-text: $text !default;
8
11
  $inRangeBg: darken($kws-datepicker-text, 55);
9
12
  }
10
13
 
11
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3), 0 0 0 0.0625rem rgba(0, 0, 0, 0.1);
14
+ box-shadow: $kws-datepicker-shadow;
12
15
  background: $kws-datepicker-background;
13
16
  color: $kws-datepicker-text;
14
17
 
18
+ border-radius: $kws-datepicker-radius;
19
+ .flatpickr-months {
20
+ border-radius: $kws-datepicker-radius $kws-datepicker-radius 0 0;
21
+ .flatpickr-month {
22
+ border-radius: $kws-datepicker-radius $kws-datepicker-radius 0 0;
23
+ }
24
+ }
25
+ .flatpickr-innerContainer {
26
+ border-radius: 0 0 $kws-datepicker-radius $kws-datepicker-radius;
27
+ }
28
+
15
29
  @each $name, $pair in $kws-theme-colors {
16
30
  $color: nth($pair, 1);
17
31
  $color-invert: nth($pair, 2);
@@ -94,6 +108,24 @@ $kws-datepicker-text: $text !default;
94
108
  color: $color-dark;
95
109
  }
96
110
  }
111
+
112
+ .flatpickr-day.inRange,
113
+ .flatpickr-day.prevMonthDay.inRange,
114
+ .flatpickr-day.nextMonthDay.inRange,
115
+ .flatpickr-day.today.inRange,
116
+ .flatpickr-day.prevMonthDay.today.inRange,
117
+ .flatpickr-day.nextMonthDay.today.inRange {
118
+ color: $color-dark;
119
+ background: $color-light;
120
+ border-color: $color-light;
121
+ box-shadow: -5px 0 0 $color-light, 5px 0 0 $color-light;
122
+ }
123
+ .flatpickr-day.selected.startRange + .endRange:not(:nth-child(7n + 1)),
124
+ .flatpickr-day.startRange.startRange + .endRange:not(:nth-child(7n + 1)),
125
+ .flatpickr-day.endRange.startRange + .endRange:not(:nth-child(7n + 1)) {
126
+ box-shadow: -10px 0 0 $color;
127
+ }
128
+
97
129
  .flatpickr-innerContainer {
98
130
  border-bottom: 1px solid $color;
99
131
  }