@kws3/ui 2.1.4 → 2.2.0

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,5 +1,12 @@
1
+ # 2.2.0
2
+ - Fix bug where `ScrollableList` component puts extra padding on top of list when fast scroll to top
3
+ - `ScrollableList` - Fix bug to reset internal positioning props when data changes
4
+ - fix Popperjs position strategy to work better on mobile by default, affects `SearchableSelect`, `MultiSelect` and `AutoComplete` components
5
+ - `ActionSheet` - Update styling to make it wokr better visually on desktop
6
+
1
7
  # 2.1.4
2
- - Fix bug where disabled Checkbox components wrongly appeared as if they were checked
8
+ - Fix bug where disabled `Checkbox` components wrongly appeared as if they were checked
9
+ - Allow adding CSS classes to the input field in `NumberInput` component
3
10
 
4
11
  # 2.1.3
5
12
  - `PasswordInput` - add support for field `autocomplete` and `required`
@@ -139,6 +139,7 @@ Default value: `<span>{option.label}</span>`
139
139
  /**
140
140
  * @typedef {import('@kws3/ui/types').ColorOptions} ColorOptions
141
141
  * @typedef {import('@kws3/ui/types').SizeOptions} SizeOptions
142
+ * @typedef {import('@kws3/ui/types').PopperStrategies} PopperStrategies
142
143
  */
143
144
 
144
145
  /**
@@ -213,6 +214,12 @@ Default value: `<span>{option.label}</span>`
213
214
  */
214
215
  export let disabled = false;
215
216
 
217
+ /**
218
+ * Placement strategy used by Popperjs, see popperjs docs
219
+ * @type {PopperStrategies}
220
+ */
221
+ export let popper_strategy = "absolute";
222
+
216
223
  /**
217
224
  * Where to render the dropdown list.
218
225
  * Can be a DOM element or a `string` with the CSS selector of the element.
@@ -330,7 +337,7 @@ Default value: `<span>{option.label}</span>`
330
337
 
331
338
  onMount(() => {
332
339
  POPPER = createPopper(el, dropdown, {
333
- strategy: "fixed",
340
+ strategy: popper_strategy,
334
341
  placement: "bottom-start",
335
342
  // @ts-ignore
336
343
  modifiers: [sameWidthPopperModifier],
@@ -202,6 +202,7 @@ Default value: `<span>{option[search_key] || option}</span>`
202
202
  /**
203
203
  * @typedef {import('@kws3/ui/types').ColorOptions} ColorOptions
204
204
  * @typedef {import('@kws3/ui/types').SizeOptions} SizeOptions
205
+ * @typedef {import('@kws3/ui/types').PopperStrategies} PopperStrategies
205
206
  */
206
207
 
207
208
  /**
@@ -292,6 +293,11 @@ Default value: `<span>{option[search_key] || option}</span>`
292
293
  * Icon used to mark selected items in dropdown list
293
294
  */
294
295
  export let selected_icon = "check";
296
+ /**
297
+ * Placement strategy used by Popperjs, see popperjs docs
298
+ * @type {PopperStrategies}
299
+ */
300
+ export let popper_strategy = "absolute";
295
301
  /**
296
302
  * Shows only the number of items selected, instead of listing all the selected items in the input.
297
303
  */
@@ -524,7 +530,7 @@ Default value: `<span>{option[search_key] || option}</span>`
524
530
 
525
531
  onMount(() => {
526
532
  POPPER = createPopper(el, dropdown, {
527
- strategy: "fixed",
533
+ strategy: popper_strategy,
528
534
  placement: "bottom-start",
529
535
  // @ts-ignore
530
536
  modifiers: [sameWidthPopperModifier],
@@ -62,6 +62,7 @@ Default value: `<span>{option[search_key] || option}</span>`
62
62
  {remove_all_tip}
63
63
  async_search_prompt={value ? "Backspace to clear" : async_search_prompt}
64
64
  {no_options_msg}
65
+ {popper_strategy}
65
66
  {dropdown_portal}
66
67
  on:change={change}
67
68
  on:blur={blur}
@@ -87,6 +88,7 @@ Default value: `<span>{option[search_key] || option}</span>`
87
88
  /**
88
89
  * @typedef {import('@kws3/ui/types').ColorOptions} ColorOptions
89
90
  * @typedef {import('@kws3/ui/types').SizeOptions} SizeOptions
91
+ * @typedef {import('@kws3/ui/types').PopperStrategies} PopperStrategies
90
92
  */
91
93
 
92
94
  /**
@@ -169,6 +171,11 @@ Default value: `<span>{option[search_key] || option}</span>`
169
171
  * Tooltip text for the Clear selection button
170
172
  */
171
173
  export let remove_all_tip = "Clear Selection";
174
+ /**
175
+ * Placement strategy used by Popperjs, see popperjs docs
176
+ * @type {PopperStrategies}
177
+ */
178
+ export let popper_strategy = "absolute";
172
179
  /**
173
180
  * Where to render the dropdown list.
174
181
  * Can be a DOM element or a `string` with the CSS selector of the element.
@@ -31,7 +31,9 @@ while more items are loading
31
31
  on:resize={resize}>
32
32
  <div
33
33
  bind:this={contents}
34
- style="padding-top: {top}px; padding-bottom: {bottom}px;">
34
+ style="padding-top: {start === 0
35
+ ? 0
36
+ : top}px; padding-bottom: {bottom}px;">
35
37
  {#each visible as item (item.index)}
36
38
  <div class="row">
37
39
  <!--Default slot for list view items-->
@@ -142,6 +144,7 @@ while more items are loading
142
144
 
143
145
  // whenever `items` changes, invalidate the current heightmap
144
146
  $: items, viewport_height, item_height, mounted, refresh();
147
+ $: items, reset();
145
148
 
146
149
  async function refresh() {
147
150
  if (!mounted) return;
@@ -232,4 +235,19 @@ while more items are loading
232
235
  rows = contents.getElementsByClassName("row");
233
236
  mounted = true;
234
237
  });
238
+
239
+ function reset() {
240
+ if (!mounted) return;
241
+ if (!items.length || items.length < items_count) {
242
+ item_height = null;
243
+ start = 0;
244
+ end = 0;
245
+ items_count = 0;
246
+ top = 0;
247
+ bottom = 0;
248
+ average_height;
249
+ padStart = 0;
250
+ padEnd = 0;
251
+ }
252
+ }
235
253
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kws3/ui",
3
- "version": "2.1.4",
3
+ "version": "2.2.0",
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": "801fdf5363f25ccb04d1a6506bb2c51e0a8506cc"
38
+ "gitHead": "c65de99beeacf8cd4eee98bcc5cf82319fe086bf"
39
39
  }
@@ -17,13 +17,20 @@ $kws-actionsheet-box-radius: $radius !default;
17
17
  box-shadow: $kws-actionsheet-box-shadow;
18
18
  position: fixed;
19
19
  bottom: 0;
20
- left: 0;
21
20
  width: 100%;
22
21
  max-height: 90%;
23
22
  min-height: fit-content;
23
+ max-width: 650px;
24
+ margin: 0 auto;
24
25
  background: $kws-actionsheet-background;
25
26
  transition: all 0.3s;
26
27
  z-index: 50;
27
28
  padding: 1.25em 1.5em;
28
29
  overflow-x: auto;
29
30
  }
31
+ @include mobile {
32
+ .kws-action-sheet {
33
+ left: 0;
34
+ max-width: 100%;
35
+ }
36
+ }
package/types/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import type {
7
7
  FontFamilies,
8
8
  FloatiePositions,
9
9
  TippyPositions,
10
+ PopperStrategies,
10
11
  } from "./type-defs";
11
12
 
12
13
  export type ColorOptions = (typeof Colors)[number];
@@ -17,6 +18,7 @@ export type FontFamilies = (typeof FontFamilies)[number];
17
18
  export type Positions = (typeof Positions)[number];
18
19
  export type TippyPositions = (typeof TippyPositions)[number];
19
20
  export type FloatiePositions = (typeof FloatiePositions)[number];
21
+ export type PopperStrategies = (typeof PopperStrategies)[number];
20
22
 
21
23
  export type FloatieType = {
22
24
  create: (opts: object) => { props: object; destroy: () => void };
@@ -62,3 +62,5 @@ export const TippyPositions = [
62
62
  "auto-start",
63
63
  "auto-end",
64
64
  ] as const;
65
+
66
+ export const PopperStrategies = ["fixed", "absolute"] as const;