@skeletonlabs/skeleton 1.9.0-dev.1226d909 → 1.9.0-dev.59b70bc4

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.
@@ -17,20 +17,18 @@ export let duration = 200;
17
17
  const deprecated = [whitelist, blacklist, duration];
18
18
  $:
19
19
  listedOptions = options;
20
- function filterByAllowed() {
20
+ function filterByAllowDeny() {
21
+ let _options = [...options];
21
22
  if (allowlist.length) {
22
- listedOptions = [...options].filter((option) => allowlist.includes(option.value));
23
- } else {
24
- listedOptions = [...options];
23
+ _options = _options.filter((option) => allowlist.includes(option.value));
25
24
  }
26
- }
27
- function filterByDenied() {
28
25
  if (denylist.length) {
29
- const denySet = new Set(denylist);
30
- listedOptions = [...options].filter((option) => !denySet.has(option.value));
31
- } else {
32
- listedOptions = [...options];
26
+ _options = _options.filter((option) => !denylist.includes(option.value));
27
+ }
28
+ if (!allowlist.length && !denylist.length) {
29
+ _options = options;
33
30
  }
31
+ listedOptions = _options;
34
32
  }
35
33
  function filterOptions() {
36
34
  let _options = [...listedOptions];
@@ -46,11 +44,8 @@ function onSelection(option) {
46
44
  dispatch("selection", option);
47
45
  }
48
46
  $:
49
- if (allowlist)
50
- filterByAllowed();
51
- $:
52
- if (denylist)
53
- filterByDenied();
47
+ if (allowlist.length || denylist.length)
48
+ filterByAllowDeny();
54
49
  $:
55
50
  optionsFiltered = input ? filterOptions() : listedOptions;
56
51
  $:
@@ -13,11 +13,13 @@ function iconClick(index) {
13
13
  index: index + 1
14
14
  });
15
15
  }
16
+ function isFull(value2, index) {
17
+ return Math.floor(value2) >= index + 1;
18
+ }
19
+ function isHalf(value2, index) {
20
+ return value2 === index + 0.5;
21
+ }
16
22
  const cBase = "w-full flex";
17
- $:
18
- elemInteractive = interactive ? "button" : "span";
19
- $:
20
- attrInteractive = interactive ? { type: "button" } : {};
21
23
  $:
22
24
  classesBase = `${cBase} ${text} ${fill} ${justify} ${spacing} ${$$props.class ?? ""}`;
23
25
  </script>
@@ -25,18 +27,26 @@ $:
25
27
  <div class="ratings {classesBase}" data-testid="rating-bar">
26
28
  <!-- eslint-disable-next-line @typescript-eslint/no-unused-vars -->
27
29
  {#each Array(max) as _, i}
28
- {#if Math.floor(value) >= i + 1}
29
- <svelte:element this={elemInteractive} {...attrInteractive} class="rating-icon {regionIcon}" on:click={() => iconClick(i)}>
30
- <slot name="full" />
31
- </svelte:element>
32
- {:else if value === i + 0.5}
33
- <svelte:element this={elemInteractive} {...attrInteractive} class="rating-icon {regionIcon}" on:click={() => iconClick(i)}>
34
- <slot name="half" />
35
- </svelte:element>
30
+ {#if interactive}
31
+ <button class="rating-icon {regionIcon}" type="button" on:click={() => iconClick(i)}>
32
+ {#if isFull(value, i)}
33
+ <slot name="full" />
34
+ {:else if isHalf(value, i)}
35
+ <slot name="half" />
36
+ {:else}
37
+ <slot name="empty" />
38
+ {/if}
39
+ </button>
36
40
  {:else}
37
- <svelte:element this={elemInteractive} {...attrInteractive} class="rating-icon {regionIcon}" on:click={() => iconClick(i)}>
38
- <slot name="empty" />
39
- </svelte:element>
41
+ <span class="rating-icon {regionIcon}">
42
+ {#if isFull(value, i)}
43
+ <slot name="full" />
44
+ {:else if isHalf(value, i)}
45
+ <slot name="half" />
46
+ {:else}
47
+ <slot name="empty" />
48
+ {/if}
49
+ </span>
40
50
  {/if}
41
51
  {/each}
42
52
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skeletonlabs/skeleton",
3
- "version": "1.9.0-dev.1226d909",
3
+ "version": "1.9.0-dev.59b70bc4",
4
4
  "description": "A SvelteKit component library.",
5
5
  "author": "endigo9740 <chris@skeletonlabs.dev>",
6
6
  "repository": {