@skeletonlabs/skeleton 1.9.0-dev.3c9cbf35 → 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
|
|
20
|
+
function filterByAllowDeny() {
|
|
21
|
+
let _options = [...options];
|
|
21
22
|
if (allowlist.length) {
|
|
22
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
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>
|