@placeholderco/placeholder-ui 1.0.3 → 1.0.6
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/LICENSE +26 -26
- package/README.md +179 -179
- package/dist/display/Alert.svelte +179 -179
- package/dist/display/Avatar.svelte +166 -166
- package/dist/display/LinkCollection.svelte +161 -161
- package/dist/display/Paper.svelte +118 -118
- package/dist/form/Autocomplete.svelte +223 -191
- package/dist/form/Autocomplete.svelte.d.ts +3 -1
- package/dist/form/AutocompleteMulti.svelte +356 -0
- package/dist/form/AutocompleteMulti.svelte.d.ts +28 -0
- package/dist/form/Checkbox.svelte +201 -201
- package/dist/form/Chips.svelte +128 -128
- package/dist/form/ComboBox.svelte +158 -158
- package/dist/form/ComboBox.svelte.d.ts +1 -1
- package/dist/form/ComboBoxItemBuilder.svelte +460 -460
- package/dist/form/ComboBoxMulti.svelte +197 -197
- package/dist/form/ComboBoxMulti.svelte.d.ts +1 -1
- package/dist/form/CronBuilder.svelte +693 -693
- package/dist/form/DatePicker.svelte +672 -672
- package/dist/form/DateTimePicker.svelte +712 -712
- package/dist/form/FileInput.svelte +235 -235
- package/dist/form/FormGroup.svelte +68 -68
- package/dist/form/Number.svelte +238 -238
- package/dist/form/PasswordInput.svelte +252 -252
- package/dist/form/RadioGroup.svelte +210 -210
- package/dist/form/Rating.svelte +235 -235
- package/dist/form/SegmentedControl.svelte +149 -149
- package/dist/form/Select.svelte +590 -590
- package/dist/form/Select.svelte.d.ts +1 -1
- package/dist/form/SelectMulti.svelte +613 -613
- package/dist/form/SelectMulti.svelte.d.ts +1 -1
- package/dist/form/Slider.svelte +358 -358
- package/dist/form/Switch.svelte +147 -147
- package/dist/form/TextArea.svelte +148 -148
- package/dist/form/Textbox.svelte +228 -228
- package/dist/form/TimePicker.svelte +267 -267
- package/dist/icon/Icon.svelte +52 -52
- package/dist/icon/alert-octagon.svg +5 -5
- package/dist/icon/alert-triangle.svg +5 -5
- package/dist/icon/archive.svg +1 -1
- package/dist/icon/arrow-down.svg +1 -1
- package/dist/icon/arrow-left.svg +1 -1
- package/dist/icon/arrow-right.svg +1 -1
- package/dist/icon/arrow-up.svg +1 -1
- package/dist/icon/at.svg +1 -1
- package/dist/icon/bell.svg +1 -1
- package/dist/icon/bookmark.svg +1 -1
- package/dist/icon/calendar.svg +1 -1
- package/dist/icon/camera.svg +1 -1
- package/dist/icon/chart-bar.svg +1 -1
- package/dist/icon/chart-line.svg +1 -1
- package/dist/icon/chart-pie.svg +1 -1
- package/dist/icon/checkbox.svg +1 -1
- package/dist/icon/checklist.svg +1 -1
- package/dist/icon/circle-check.svg +1 -1
- package/dist/icon/circle-x.svg +1 -1
- package/dist/icon/clock.svg +1 -1
- package/dist/icon/credit-card.svg +1 -1
- package/dist/icon/dots-vertical.svg +1 -1
- package/dist/icon/dots.svg +1 -1
- package/dist/icon/external-link.svg +1 -1
- package/dist/icon/eye-off.svg +1 -1
- package/dist/icon/eye.svg +1 -1
- package/dist/icon/filter.svg +1 -1
- package/dist/icon/fingerprint.svg +1 -1
- package/dist/icon/flag.svg +1 -1
- package/dist/icon/heart.svg +1 -1
- package/dist/icon/home.svg +1 -1
- package/dist/icon/key.svg +1 -1
- package/dist/icon/list-check.svg +1 -1
- package/dist/icon/login.svg +1 -1
- package/dist/icon/logout.svg +1 -1
- package/dist/icon/map-pin.svg +1 -1
- package/dist/icon/maximize.svg +1 -1
- package/dist/icon/microphone.svg +1 -1
- package/dist/icon/minimize.svg +1 -1
- package/dist/icon/note.svg +1 -1
- package/dist/icon/player-pause.svg +1 -1
- package/dist/icon/printer.svg +1 -1
- package/dist/icon/qrcode.svg +1 -1
- package/dist/icon/send.svg +1 -1
- package/dist/icon/settings.svg +1 -1
- package/dist/icon/share.svg +1 -1
- package/dist/icon/shopping-cart.svg +1 -1
- package/dist/icon/sort-ascending.svg +1 -1
- package/dist/icon/sort-descending.svg +1 -1
- package/dist/icon/star.svg +1 -1
- package/dist/icon/tag.svg +1 -1
- package/dist/icon/trending-down.svg +1 -1
- package/dist/icon/trending-up.svg +1 -1
- package/dist/icon/upload.svg +1 -1
- package/dist/icon/volume-off.svg +1 -1
- package/dist/icon/volume.svg +1 -1
- package/dist/icon/world.svg +1 -1
- package/dist/icon/zoom-in.svg +1 -1
- package/dist/icon/zoom-out.svg +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/layout/AppShell.svelte +169 -169
- package/dist/layout/CustomNavbar.svelte +61 -61
- package/dist/layout/Navbar.svelte +206 -206
- package/dist/layout/NavbarItemDisplay.svelte +29 -29
- package/dist/layout/Sidenav.svelte +712 -712
- package/dist/styles/components.css +199 -199
- package/dist/styles/dark.css +146 -146
- package/dist/styles/index.css +116 -116
- package/dist/styles/reset.css +110 -110
- package/dist/styles/semantic.css +86 -86
- package/dist/styles/tokens.css +203 -197
- package/dist/styles/utilities.css +523 -523
- package/dist/ui/Accordion.svelte +289 -289
- package/dist/ui/ActionIcon.svelte +76 -76
- package/dist/ui/Badge.svelte +329 -279
- package/dist/ui/Breadcrumbs.svelte +131 -131
- package/dist/ui/Button.svelte +432 -370
- package/dist/ui/ButtonVariant.d.ts +1 -1
- package/dist/ui/Dialog.svelte +307 -307
- package/dist/ui/Drawer.svelte +524 -524
- package/dist/ui/Dropdown.svelte +97 -97
- package/dist/ui/Dropzone.svelte +122 -122
- package/dist/ui/Link.svelte +32 -32
- package/dist/ui/Loader.svelte +70 -70
- package/dist/ui/LoadingOverlay.svelte +53 -53
- package/dist/ui/Pagination.svelte +135 -135
- package/dist/ui/Popover.svelte +225 -225
- package/dist/ui/Progress.svelte +191 -191
- package/dist/ui/RingProgress.svelte +141 -141
- package/dist/ui/Skeleton.svelte +85 -85
- package/dist/ui/Stepper.svelte +355 -355
- package/dist/ui/Table.svelte +345 -345
- package/dist/ui/Tabs.svelte +146 -146
- package/dist/ui/ThemeSwitcher.svelte +39 -39
- package/dist/ui/Timeline.svelte +225 -225
- package/dist/ui/Toaster.svelte +6 -6
- package/dist/ui/Tooltip.svelte +434 -434
- package/package.json +14 -14
package/dist/form/Rating.svelte
CHANGED
|
@@ -1,235 +1,235 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import Icon from '../icon/Icon.svelte';
|
|
3
|
-
import { iconStar } from '../icon/index.js';
|
|
4
|
-
import FormGroup from './FormGroup.svelte';
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
label?: string;
|
|
8
|
-
value?: number;
|
|
9
|
-
count?: number;
|
|
10
|
-
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
11
|
-
color?: 'primary' | 'secondary' | 'accent' | 'warning';
|
|
12
|
-
emptySymbol?: string;
|
|
13
|
-
fullSymbol?: string;
|
|
14
|
-
readOnly?: boolean;
|
|
15
|
-
fractions?: 1 | 2 | 4;
|
|
16
|
-
highlightSelectedOnly?: boolean;
|
|
17
|
-
required?: boolean;
|
|
18
|
-
showError?: boolean;
|
|
19
|
-
errorText?: string;
|
|
20
|
-
class?: string;
|
|
21
|
-
onchange?: (value: number) => void;
|
|
22
|
-
onhover?: (value: number) => void;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let {
|
|
26
|
-
label = '',
|
|
27
|
-
value = $bindable(0),
|
|
28
|
-
count = 5,
|
|
29
|
-
size = 'md',
|
|
30
|
-
color = 'warning',
|
|
31
|
-
emptySymbol = undefined,
|
|
32
|
-
fullSymbol = undefined,
|
|
33
|
-
readOnly = false,
|
|
34
|
-
fractions = 1,
|
|
35
|
-
highlightSelectedOnly = false,
|
|
36
|
-
required = false,
|
|
37
|
-
showError = false,
|
|
38
|
-
errorText = '',
|
|
39
|
-
class: classes = '',
|
|
40
|
-
onchange,
|
|
41
|
-
onhover
|
|
42
|
-
}: Props = $props();
|
|
43
|
-
|
|
44
|
-
let hoverValue = $state(-1);
|
|
45
|
-
|
|
46
|
-
const displayValue = $derived(hoverValue >= 0 ? hoverValue : value);
|
|
47
|
-
|
|
48
|
-
const sizeMap: Record<string, string> = {
|
|
49
|
-
xs: '16px',
|
|
50
|
-
sm: '20px',
|
|
51
|
-
md: '24px',
|
|
52
|
-
lg: '32px',
|
|
53
|
-
xl: '40px'
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const iconSize = $derived(sizeMap[size] || '24px');
|
|
57
|
-
|
|
58
|
-
function handleClick(index: number, fraction: number = 1) {
|
|
59
|
-
if (readOnly) return;
|
|
60
|
-
const newValue = index + fraction / fractions;
|
|
61
|
-
value = newValue;
|
|
62
|
-
onchange?.(newValue);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function handleMouseEnter(index: number, fraction: number = 1) {
|
|
66
|
-
if (readOnly) return;
|
|
67
|
-
const newHoverValue = index + fraction / fractions;
|
|
68
|
-
hoverValue = newHoverValue;
|
|
69
|
-
onhover?.(newHoverValue);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function handleMouseLeave() {
|
|
73
|
-
hoverValue = -1;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function getSymbolState(index: number): 'empty' | 'full' | 'partial' {
|
|
77
|
-
const currentValue = displayValue;
|
|
78
|
-
if (highlightSelectedOnly) {
|
|
79
|
-
return Math.ceil(currentValue) === index + 1 ? 'full' : 'empty';
|
|
80
|
-
}
|
|
81
|
-
if (currentValue >= index + 1) return 'full';
|
|
82
|
-
if (currentValue > index) return 'partial';
|
|
83
|
-
return 'empty';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function getPartialWidth(index: number): number {
|
|
87
|
-
const currentValue = displayValue;
|
|
88
|
-
if (currentValue <= index) return 0;
|
|
89
|
-
if (currentValue >= index + 1) return 100;
|
|
90
|
-
return (currentValue - index) * 100;
|
|
91
|
-
}
|
|
92
|
-
</script>
|
|
93
|
-
|
|
94
|
-
<FormGroup {label} {required} {showError} {errorText} class={classes}>
|
|
95
|
-
<div
|
|
96
|
-
class="rating size-{size} color-{color}"
|
|
97
|
-
class:read-only={readOnly}
|
|
98
|
-
role="slider"
|
|
99
|
-
tabindex={readOnly ? -1 : 0}
|
|
100
|
-
aria-valuenow={value}
|
|
101
|
-
aria-valuemin={0}
|
|
102
|
-
aria-valuemax={count}
|
|
103
|
-
aria-label={label || 'Rating'}
|
|
104
|
-
onmouseleave={handleMouseLeave}
|
|
105
|
-
>
|
|
106
|
-
{#each Array(count) as _, index (index)}
|
|
107
|
-
{@const state = getSymbolState(index)}
|
|
108
|
-
{@const partialWidth = getPartialWidth(index)}
|
|
109
|
-
<div class="rating-symbol-wrapper">
|
|
110
|
-
{#if fractions > 1}
|
|
111
|
-
<!-- Fractional rating with invisible click zones -->
|
|
112
|
-
{#each Array(fractions) as __, fractionIndex (fractionIndex)}
|
|
113
|
-
<button
|
|
114
|
-
type="button"
|
|
115
|
-
class="rating-fraction-zone"
|
|
116
|
-
style="width: {100 / fractions}%; left: {(fractionIndex / fractions) * 100}%;"
|
|
117
|
-
onclick={() => handleClick(index, fractionIndex + 1)}
|
|
118
|
-
onmouseenter={() => handleMouseEnter(index, fractionIndex + 1)}
|
|
119
|
-
disabled={readOnly}
|
|
120
|
-
aria-label="Rate {index + (fractionIndex + 1) / fractions}"
|
|
121
|
-
></button>
|
|
122
|
-
{/each}
|
|
123
|
-
{:else}
|
|
124
|
-
<button
|
|
125
|
-
type="button"
|
|
126
|
-
class="rating-button"
|
|
127
|
-
onclick={() => handleClick(index)}
|
|
128
|
-
onmouseenter={() => handleMouseEnter(index, 1)}
|
|
129
|
-
disabled={readOnly}
|
|
130
|
-
aria-label="Rate {index + 1}"
|
|
131
|
-
></button>
|
|
132
|
-
{/if}
|
|
133
|
-
<div class="rating-symbol empty">
|
|
134
|
-
<Icon svg={emptySymbol || iconStar} size={iconSize} />
|
|
135
|
-
</div>
|
|
136
|
-
<div class="rating-symbol full" style="width: {partialWidth}%;">
|
|
137
|
-
<Icon svg={fullSymbol || iconStar} size={iconSize} />
|
|
138
|
-
</div>
|
|
139
|
-
</div>
|
|
140
|
-
{/each}
|
|
141
|
-
</div>
|
|
142
|
-
</FormGroup>
|
|
143
|
-
|
|
144
|
-
<style>
|
|
145
|
-
.rating {
|
|
146
|
-
display: inline-flex;
|
|
147
|
-
gap: var(--pui-spacing-1);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.rating.read-only {
|
|
151
|
-
pointer-events: none;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.rating-symbol-wrapper {
|
|
155
|
-
position: relative;
|
|
156
|
-
cursor: pointer;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.read-only .rating-symbol-wrapper {
|
|
160
|
-
cursor: default;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.rating-button,
|
|
164
|
-
.rating-fraction-zone {
|
|
165
|
-
position: absolute;
|
|
166
|
-
top: 0;
|
|
167
|
-
height: 100%;
|
|
168
|
-
background: transparent;
|
|
169
|
-
border: none;
|
|
170
|
-
cursor: pointer;
|
|
171
|
-
z-index: 2;
|
|
172
|
-
padding: 0;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.rating-button {
|
|
176
|
-
left: 0;
|
|
177
|
-
width: 100%;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.rating-button:disabled,
|
|
181
|
-
.rating-fraction-zone:disabled {
|
|
182
|
-
cursor: default;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.rating-symbol {
|
|
186
|
-
display: flex;
|
|
187
|
-
align-items: center;
|
|
188
|
-
justify-content: center;
|
|
189
|
-
transition: transform var(--pui-transition-fast) var(--pui-ease-out);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.rating-symbol-wrapper:hover .rating-symbol {
|
|
193
|
-
transform: scale(1.1);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
.read-only .rating-symbol-wrapper:hover .rating-symbol {
|
|
197
|
-
transform: none;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.rating-symbol.empty {
|
|
201
|
-
color: var(--pui-color-gray-300);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
:global(.dark) .rating-symbol.empty {
|
|
205
|
-
color: var(--pui-color-dark-border);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.rating-symbol.full {
|
|
209
|
-
position: absolute;
|
|
210
|
-
top: 0;
|
|
211
|
-
left: 0;
|
|
212
|
-
overflow: hidden;
|
|
213
|
-
color: var(--rating-color, var(--pui-color-warning));
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.rating-symbol.full :global(svg) {
|
|
217
|
-
fill: currentColor;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/* Colors */
|
|
221
|
-
.color-primary {
|
|
222
|
-
--rating-color: var(--pui-color-primary);
|
|
223
|
-
}
|
|
224
|
-
.color-secondary {
|
|
225
|
-
--rating-color: var(--pui-color-secondary);
|
|
226
|
-
}
|
|
227
|
-
.color-accent {
|
|
228
|
-
--rating-color: var(--pui-color-accent);
|
|
229
|
-
}
|
|
230
|
-
.color-warning {
|
|
231
|
-
--rating-color: var(--pui-color-warning);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/* Sizes via icon prop */
|
|
235
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from '../icon/Icon.svelte';
|
|
3
|
+
import { iconStar } from '../icon/index.js';
|
|
4
|
+
import FormGroup from './FormGroup.svelte';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
label?: string;
|
|
8
|
+
value?: number;
|
|
9
|
+
count?: number;
|
|
10
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
11
|
+
color?: 'primary' | 'secondary' | 'accent' | 'warning';
|
|
12
|
+
emptySymbol?: string;
|
|
13
|
+
fullSymbol?: string;
|
|
14
|
+
readOnly?: boolean;
|
|
15
|
+
fractions?: 1 | 2 | 4;
|
|
16
|
+
highlightSelectedOnly?: boolean;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
showError?: boolean;
|
|
19
|
+
errorText?: string;
|
|
20
|
+
class?: string;
|
|
21
|
+
onchange?: (value: number) => void;
|
|
22
|
+
onhover?: (value: number) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let {
|
|
26
|
+
label = '',
|
|
27
|
+
value = $bindable(0),
|
|
28
|
+
count = 5,
|
|
29
|
+
size = 'md',
|
|
30
|
+
color = 'warning',
|
|
31
|
+
emptySymbol = undefined,
|
|
32
|
+
fullSymbol = undefined,
|
|
33
|
+
readOnly = false,
|
|
34
|
+
fractions = 1,
|
|
35
|
+
highlightSelectedOnly = false,
|
|
36
|
+
required = false,
|
|
37
|
+
showError = false,
|
|
38
|
+
errorText = '',
|
|
39
|
+
class: classes = '',
|
|
40
|
+
onchange,
|
|
41
|
+
onhover
|
|
42
|
+
}: Props = $props();
|
|
43
|
+
|
|
44
|
+
let hoverValue = $state(-1);
|
|
45
|
+
|
|
46
|
+
const displayValue = $derived(hoverValue >= 0 ? hoverValue : value);
|
|
47
|
+
|
|
48
|
+
const sizeMap: Record<string, string> = {
|
|
49
|
+
xs: '16px',
|
|
50
|
+
sm: '20px',
|
|
51
|
+
md: '24px',
|
|
52
|
+
lg: '32px',
|
|
53
|
+
xl: '40px'
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const iconSize = $derived(sizeMap[size] || '24px');
|
|
57
|
+
|
|
58
|
+
function handleClick(index: number, fraction: number = 1) {
|
|
59
|
+
if (readOnly) return;
|
|
60
|
+
const newValue = index + fraction / fractions;
|
|
61
|
+
value = newValue;
|
|
62
|
+
onchange?.(newValue);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function handleMouseEnter(index: number, fraction: number = 1) {
|
|
66
|
+
if (readOnly) return;
|
|
67
|
+
const newHoverValue = index + fraction / fractions;
|
|
68
|
+
hoverValue = newHoverValue;
|
|
69
|
+
onhover?.(newHoverValue);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function handleMouseLeave() {
|
|
73
|
+
hoverValue = -1;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function getSymbolState(index: number): 'empty' | 'full' | 'partial' {
|
|
77
|
+
const currentValue = displayValue;
|
|
78
|
+
if (highlightSelectedOnly) {
|
|
79
|
+
return Math.ceil(currentValue) === index + 1 ? 'full' : 'empty';
|
|
80
|
+
}
|
|
81
|
+
if (currentValue >= index + 1) return 'full';
|
|
82
|
+
if (currentValue > index) return 'partial';
|
|
83
|
+
return 'empty';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getPartialWidth(index: number): number {
|
|
87
|
+
const currentValue = displayValue;
|
|
88
|
+
if (currentValue <= index) return 0;
|
|
89
|
+
if (currentValue >= index + 1) return 100;
|
|
90
|
+
return (currentValue - index) * 100;
|
|
91
|
+
}
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<FormGroup {label} {required} {showError} {errorText} class={classes}>
|
|
95
|
+
<div
|
|
96
|
+
class="rating size-{size} color-{color}"
|
|
97
|
+
class:read-only={readOnly}
|
|
98
|
+
role="slider"
|
|
99
|
+
tabindex={readOnly ? -1 : 0}
|
|
100
|
+
aria-valuenow={value}
|
|
101
|
+
aria-valuemin={0}
|
|
102
|
+
aria-valuemax={count}
|
|
103
|
+
aria-label={label || 'Rating'}
|
|
104
|
+
onmouseleave={handleMouseLeave}
|
|
105
|
+
>
|
|
106
|
+
{#each Array(count) as _, index (index)}
|
|
107
|
+
{@const state = getSymbolState(index)}
|
|
108
|
+
{@const partialWidth = getPartialWidth(index)}
|
|
109
|
+
<div class="rating-symbol-wrapper">
|
|
110
|
+
{#if fractions > 1}
|
|
111
|
+
<!-- Fractional rating with invisible click zones -->
|
|
112
|
+
{#each Array(fractions) as __, fractionIndex (fractionIndex)}
|
|
113
|
+
<button
|
|
114
|
+
type="button"
|
|
115
|
+
class="rating-fraction-zone"
|
|
116
|
+
style="width: {100 / fractions}%; left: {(fractionIndex / fractions) * 100}%;"
|
|
117
|
+
onclick={() => handleClick(index, fractionIndex + 1)}
|
|
118
|
+
onmouseenter={() => handleMouseEnter(index, fractionIndex + 1)}
|
|
119
|
+
disabled={readOnly}
|
|
120
|
+
aria-label="Rate {index + (fractionIndex + 1) / fractions}"
|
|
121
|
+
></button>
|
|
122
|
+
{/each}
|
|
123
|
+
{:else}
|
|
124
|
+
<button
|
|
125
|
+
type="button"
|
|
126
|
+
class="rating-button"
|
|
127
|
+
onclick={() => handleClick(index)}
|
|
128
|
+
onmouseenter={() => handleMouseEnter(index, 1)}
|
|
129
|
+
disabled={readOnly}
|
|
130
|
+
aria-label="Rate {index + 1}"
|
|
131
|
+
></button>
|
|
132
|
+
{/if}
|
|
133
|
+
<div class="rating-symbol empty">
|
|
134
|
+
<Icon svg={emptySymbol || iconStar} size={iconSize} />
|
|
135
|
+
</div>
|
|
136
|
+
<div class="rating-symbol full" style="width: {partialWidth}%;">
|
|
137
|
+
<Icon svg={fullSymbol || iconStar} size={iconSize} />
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
{/each}
|
|
141
|
+
</div>
|
|
142
|
+
</FormGroup>
|
|
143
|
+
|
|
144
|
+
<style>
|
|
145
|
+
.rating {
|
|
146
|
+
display: inline-flex;
|
|
147
|
+
gap: var(--pui-spacing-1);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.rating.read-only {
|
|
151
|
+
pointer-events: none;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.rating-symbol-wrapper {
|
|
155
|
+
position: relative;
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.read-only .rating-symbol-wrapper {
|
|
160
|
+
cursor: default;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.rating-button,
|
|
164
|
+
.rating-fraction-zone {
|
|
165
|
+
position: absolute;
|
|
166
|
+
top: 0;
|
|
167
|
+
height: 100%;
|
|
168
|
+
background: transparent;
|
|
169
|
+
border: none;
|
|
170
|
+
cursor: pointer;
|
|
171
|
+
z-index: 2;
|
|
172
|
+
padding: 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.rating-button {
|
|
176
|
+
left: 0;
|
|
177
|
+
width: 100%;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.rating-button:disabled,
|
|
181
|
+
.rating-fraction-zone:disabled {
|
|
182
|
+
cursor: default;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.rating-symbol {
|
|
186
|
+
display: flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
justify-content: center;
|
|
189
|
+
transition: transform var(--pui-transition-fast) var(--pui-ease-out);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.rating-symbol-wrapper:hover .rating-symbol {
|
|
193
|
+
transform: scale(1.1);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.read-only .rating-symbol-wrapper:hover .rating-symbol {
|
|
197
|
+
transform: none;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.rating-symbol.empty {
|
|
201
|
+
color: var(--pui-color-gray-300);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
:global(.dark) .rating-symbol.empty {
|
|
205
|
+
color: var(--pui-color-dark-border);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.rating-symbol.full {
|
|
209
|
+
position: absolute;
|
|
210
|
+
top: 0;
|
|
211
|
+
left: 0;
|
|
212
|
+
overflow: hidden;
|
|
213
|
+
color: var(--rating-color, var(--pui-color-warning));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.rating-symbol.full :global(svg) {
|
|
217
|
+
fill: currentColor;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/* Colors */
|
|
221
|
+
.color-primary {
|
|
222
|
+
--rating-color: var(--pui-color-primary);
|
|
223
|
+
}
|
|
224
|
+
.color-secondary {
|
|
225
|
+
--rating-color: var(--pui-color-secondary);
|
|
226
|
+
}
|
|
227
|
+
.color-accent {
|
|
228
|
+
--rating-color: var(--pui-color-accent);
|
|
229
|
+
}
|
|
230
|
+
.color-warning {
|
|
231
|
+
--rating-color: var(--pui-color-warning);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* Sizes via icon prop */
|
|
235
|
+
</style>
|