@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
|
@@ -1,201 +1,201 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
interface Props {
|
|
3
|
-
label?: string;
|
|
4
|
-
required?: boolean;
|
|
5
|
-
class?: string;
|
|
6
|
-
inputId?: string;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
showError?: boolean;
|
|
9
|
-
errorText?: string;
|
|
10
|
-
checked?: boolean;
|
|
11
|
-
onchange?: (e: boolean) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
let {
|
|
15
|
-
label,
|
|
16
|
-
required = false,
|
|
17
|
-
class: classes = '',
|
|
18
|
-
inputId = undefined,
|
|
19
|
-
disabled = false,
|
|
20
|
-
showError = false,
|
|
21
|
-
errorText = '',
|
|
22
|
-
checked = $bindable(false),
|
|
23
|
-
onchange = undefined
|
|
24
|
-
}: Props = $props();
|
|
25
|
-
|
|
26
|
-
const nonce = Math.random().toString(36).substring(2, 15);
|
|
27
|
-
|
|
28
|
-
const id = $derived(inputId ? inputId : label ? `input-${label}` : `input-${nonce}`);
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<div class="checkbox-container {disabled ? 'disabled' : ''}">
|
|
32
|
-
<label for={id}>
|
|
33
|
-
<input
|
|
34
|
-
class="checkbox {showError && 'error'} {classes}"
|
|
35
|
-
type="checkbox"
|
|
36
|
-
{id}
|
|
37
|
-
{disabled}
|
|
38
|
-
bind:checked
|
|
39
|
-
onchange={() => onchange?.(checked)}
|
|
40
|
-
/>
|
|
41
|
-
<span class="label-text"
|
|
42
|
-
>{label}
|
|
43
|
-
{#if required}
|
|
44
|
-
<span class="required">*</span>
|
|
45
|
-
{/if}</span
|
|
46
|
-
>
|
|
47
|
-
</label>
|
|
48
|
-
{#if showError && errorText}
|
|
49
|
-
<div class="error-text">{errorText}</div>
|
|
50
|
-
{/if}
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
<style>
|
|
54
|
-
.checkbox-container {
|
|
55
|
-
display: flex;
|
|
56
|
-
align-items: center;
|
|
57
|
-
gap: var(--pui-spacing-1_5);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
label {
|
|
61
|
-
display: flex;
|
|
62
|
-
flex-direction: row;
|
|
63
|
-
align-items: center;
|
|
64
|
-
user-select: none;
|
|
65
|
-
cursor: pointer;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.disabled label,
|
|
69
|
-
.disabled input {
|
|
70
|
-
cursor: not-allowed;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
input {
|
|
74
|
-
position: relative !important;
|
|
75
|
-
-webkit-appearance: none;
|
|
76
|
-
-moz-appearance: none;
|
|
77
|
-
appearance: none;
|
|
78
|
-
margin: 8px;
|
|
79
|
-
box-sizing: content-box;
|
|
80
|
-
overflow: hidden;
|
|
81
|
-
cursor: pointer;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
input:before {
|
|
85
|
-
content: '';
|
|
86
|
-
display: block;
|
|
87
|
-
box-sizing: content-box;
|
|
88
|
-
width: 16px;
|
|
89
|
-
height: 16px;
|
|
90
|
-
border: 2px solid var(--pui-border-disabled);
|
|
91
|
-
transition: border-color var(--pui-transition-fast) var(--pui-ease-out);
|
|
92
|
-
}
|
|
93
|
-
:global(.dark) input:before {
|
|
94
|
-
border-color: var(--pui-color-gray-600);
|
|
95
|
-
}
|
|
96
|
-
input:checked:before {
|
|
97
|
-
border-color: var(--pui-color-primary);
|
|
98
|
-
transition: border-color var(--pui-transition-slower) var(--pui-ease-out);
|
|
99
|
-
}
|
|
100
|
-
:global(.dark) input:checked:before {
|
|
101
|
-
border-color: var(--pui-color-primary);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
input:disabled:before {
|
|
105
|
-
border-color: var(--pui-border-disabled);
|
|
106
|
-
background-color: var(--pui-bg-disabled);
|
|
107
|
-
opacity: 0.5;
|
|
108
|
-
}
|
|
109
|
-
:global(.dark) input:disabled:before {
|
|
110
|
-
border-color: var(--pui-color-gray-600);
|
|
111
|
-
background-color: var(--pui-color-gray-600);
|
|
112
|
-
}
|
|
113
|
-
input:after {
|
|
114
|
-
content: '';
|
|
115
|
-
display: block;
|
|
116
|
-
position: absolute;
|
|
117
|
-
box-sizing: content-box;
|
|
118
|
-
top: 50%;
|
|
119
|
-
left: 50%;
|
|
120
|
-
transform-origin: 50% 50%;
|
|
121
|
-
background-color: var(--pui-color-primary);
|
|
122
|
-
width: 16px;
|
|
123
|
-
height: 16px;
|
|
124
|
-
border-radius: 100vh;
|
|
125
|
-
transform: translate(-50%, -50%) scale(0);
|
|
126
|
-
}
|
|
127
|
-
input:disabled:after {
|
|
128
|
-
opacity: 0.5;
|
|
129
|
-
}
|
|
130
|
-
:global(.dark) input:after {
|
|
131
|
-
background-color: var(--pui-color-primary);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
input[type='checkbox']:before {
|
|
135
|
-
border-radius: var(--pui-radius-sm);
|
|
136
|
-
}
|
|
137
|
-
input[type='checkbox']:after {
|
|
138
|
-
width: 7px;
|
|
139
|
-
height: 14px;
|
|
140
|
-
border-radius: 0;
|
|
141
|
-
transform: translate(-50%, -85%) scale(0) rotate(45deg);
|
|
142
|
-
background-color: transparent;
|
|
143
|
-
box-shadow: 4px 4px 0px 0px var(--pui-color-primary);
|
|
144
|
-
}
|
|
145
|
-
:global(.dark) input[type='checkbox']:after {
|
|
146
|
-
box-shadow: 4px 4px 0px 0px var(--pui-color-primary);
|
|
147
|
-
}
|
|
148
|
-
input[type='checkbox']:checked:after {
|
|
149
|
-
-webkit-animation: toggleOnCheckbox var(--pui-transition-fast) var(--pui-ease-out) forwards;
|
|
150
|
-
animation: toggleOnCheckbox var(--pui-transition-fast) var(--pui-ease-out) forwards;
|
|
151
|
-
}
|
|
152
|
-
input[type='checkbox'].filled:before {
|
|
153
|
-
border-radius: var(--pui-radius-sm);
|
|
154
|
-
transition:
|
|
155
|
-
border-color var(--pui-transition-fast) var(--pui-ease-out),
|
|
156
|
-
background-color var(--pui-transition-fast) var(--pui-ease-out);
|
|
157
|
-
}
|
|
158
|
-
input[type='checkbox'].filled:checked:not(:disabled):before {
|
|
159
|
-
background-color: var(--pui-color-primary);
|
|
160
|
-
}
|
|
161
|
-
:global(.dark) input[type='checkbox'].filled:checked:not(:disabled):before {
|
|
162
|
-
background-color: var(--pui-color-primary);
|
|
163
|
-
}
|
|
164
|
-
input[type='checkbox'].filled:not(:disabled):after {
|
|
165
|
-
box-shadow: 4px 4px 0px 0px var(--pui-color-white);
|
|
166
|
-
}
|
|
167
|
-
@-webkit-keyframes toggleOnCheckbox {
|
|
168
|
-
0% {
|
|
169
|
-
opacity: 0;
|
|
170
|
-
transform: translate(-50%, -85%) scale(0) rotate(45deg);
|
|
171
|
-
}
|
|
172
|
-
70% {
|
|
173
|
-
opacity: 1;
|
|
174
|
-
transform: translate(-50%, -85%) scale(0.9) rotate(45deg);
|
|
175
|
-
}
|
|
176
|
-
100% {
|
|
177
|
-
transform: translate(-50%, -85%) scale(0.8) rotate(45deg);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
@keyframes toggleOnCheckbox {
|
|
181
|
-
0% {
|
|
182
|
-
opacity: 0;
|
|
183
|
-
transform: translate(-50%, -85%) scale(0) rotate(45deg);
|
|
184
|
-
}
|
|
185
|
-
70% {
|
|
186
|
-
opacity: 1;
|
|
187
|
-
transform: translate(-50%, -85%) scale(0.9) rotate(45deg);
|
|
188
|
-
}
|
|
189
|
-
100% {
|
|
190
|
-
transform: translate(-50%, -85%) scale(0.8) rotate(45deg);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
input.error:before {
|
|
195
|
-
border-color: var(--pui-text-danger) !important;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
.error-text {
|
|
199
|
-
color: var(--pui-text-danger);
|
|
200
|
-
}
|
|
201
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
label?: string;
|
|
4
|
+
required?: boolean;
|
|
5
|
+
class?: string;
|
|
6
|
+
inputId?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
showError?: boolean;
|
|
9
|
+
errorText?: string;
|
|
10
|
+
checked?: boolean;
|
|
11
|
+
onchange?: (e: boolean) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
label,
|
|
16
|
+
required = false,
|
|
17
|
+
class: classes = '',
|
|
18
|
+
inputId = undefined,
|
|
19
|
+
disabled = false,
|
|
20
|
+
showError = false,
|
|
21
|
+
errorText = '',
|
|
22
|
+
checked = $bindable(false),
|
|
23
|
+
onchange = undefined
|
|
24
|
+
}: Props = $props();
|
|
25
|
+
|
|
26
|
+
const nonce = Math.random().toString(36).substring(2, 15);
|
|
27
|
+
|
|
28
|
+
const id = $derived(inputId ? inputId : label ? `input-${label}` : `input-${nonce}`);
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<div class="checkbox-container {disabled ? 'disabled' : ''}">
|
|
32
|
+
<label for={id}>
|
|
33
|
+
<input
|
|
34
|
+
class="checkbox {showError && 'error'} {classes}"
|
|
35
|
+
type="checkbox"
|
|
36
|
+
{id}
|
|
37
|
+
{disabled}
|
|
38
|
+
bind:checked
|
|
39
|
+
onchange={() => onchange?.(checked)}
|
|
40
|
+
/>
|
|
41
|
+
<span class="label-text"
|
|
42
|
+
>{label}
|
|
43
|
+
{#if required}
|
|
44
|
+
<span class="required">*</span>
|
|
45
|
+
{/if}</span
|
|
46
|
+
>
|
|
47
|
+
</label>
|
|
48
|
+
{#if showError && errorText}
|
|
49
|
+
<div class="error-text">{errorText}</div>
|
|
50
|
+
{/if}
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<style>
|
|
54
|
+
.checkbox-container {
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: var(--pui-spacing-1_5);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
label {
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: row;
|
|
63
|
+
align-items: center;
|
|
64
|
+
user-select: none;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.disabled label,
|
|
69
|
+
.disabled input {
|
|
70
|
+
cursor: not-allowed;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
input {
|
|
74
|
+
position: relative !important;
|
|
75
|
+
-webkit-appearance: none;
|
|
76
|
+
-moz-appearance: none;
|
|
77
|
+
appearance: none;
|
|
78
|
+
margin: 8px;
|
|
79
|
+
box-sizing: content-box;
|
|
80
|
+
overflow: hidden;
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
input:before {
|
|
85
|
+
content: '';
|
|
86
|
+
display: block;
|
|
87
|
+
box-sizing: content-box;
|
|
88
|
+
width: 16px;
|
|
89
|
+
height: 16px;
|
|
90
|
+
border: 2px solid var(--pui-border-disabled);
|
|
91
|
+
transition: border-color var(--pui-transition-fast) var(--pui-ease-out);
|
|
92
|
+
}
|
|
93
|
+
:global(.dark) input:before {
|
|
94
|
+
border-color: var(--pui-color-gray-600);
|
|
95
|
+
}
|
|
96
|
+
input:checked:before {
|
|
97
|
+
border-color: var(--pui-color-primary);
|
|
98
|
+
transition: border-color var(--pui-transition-slower) var(--pui-ease-out);
|
|
99
|
+
}
|
|
100
|
+
:global(.dark) input:checked:before {
|
|
101
|
+
border-color: var(--pui-color-primary);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
input:disabled:before {
|
|
105
|
+
border-color: var(--pui-border-disabled);
|
|
106
|
+
background-color: var(--pui-bg-disabled);
|
|
107
|
+
opacity: 0.5;
|
|
108
|
+
}
|
|
109
|
+
:global(.dark) input:disabled:before {
|
|
110
|
+
border-color: var(--pui-color-gray-600);
|
|
111
|
+
background-color: var(--pui-color-gray-600);
|
|
112
|
+
}
|
|
113
|
+
input:after {
|
|
114
|
+
content: '';
|
|
115
|
+
display: block;
|
|
116
|
+
position: absolute;
|
|
117
|
+
box-sizing: content-box;
|
|
118
|
+
top: 50%;
|
|
119
|
+
left: 50%;
|
|
120
|
+
transform-origin: 50% 50%;
|
|
121
|
+
background-color: var(--pui-color-primary);
|
|
122
|
+
width: 16px;
|
|
123
|
+
height: 16px;
|
|
124
|
+
border-radius: 100vh;
|
|
125
|
+
transform: translate(-50%, -50%) scale(0);
|
|
126
|
+
}
|
|
127
|
+
input:disabled:after {
|
|
128
|
+
opacity: 0.5;
|
|
129
|
+
}
|
|
130
|
+
:global(.dark) input:after {
|
|
131
|
+
background-color: var(--pui-color-primary);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
input[type='checkbox']:before {
|
|
135
|
+
border-radius: var(--pui-radius-sm);
|
|
136
|
+
}
|
|
137
|
+
input[type='checkbox']:after {
|
|
138
|
+
width: 7px;
|
|
139
|
+
height: 14px;
|
|
140
|
+
border-radius: 0;
|
|
141
|
+
transform: translate(-50%, -85%) scale(0) rotate(45deg);
|
|
142
|
+
background-color: transparent;
|
|
143
|
+
box-shadow: 4px 4px 0px 0px var(--pui-color-primary);
|
|
144
|
+
}
|
|
145
|
+
:global(.dark) input[type='checkbox']:after {
|
|
146
|
+
box-shadow: 4px 4px 0px 0px var(--pui-color-primary);
|
|
147
|
+
}
|
|
148
|
+
input[type='checkbox']:checked:after {
|
|
149
|
+
-webkit-animation: toggleOnCheckbox var(--pui-transition-fast) var(--pui-ease-out) forwards;
|
|
150
|
+
animation: toggleOnCheckbox var(--pui-transition-fast) var(--pui-ease-out) forwards;
|
|
151
|
+
}
|
|
152
|
+
input[type='checkbox'].filled:before {
|
|
153
|
+
border-radius: var(--pui-radius-sm);
|
|
154
|
+
transition:
|
|
155
|
+
border-color var(--pui-transition-fast) var(--pui-ease-out),
|
|
156
|
+
background-color var(--pui-transition-fast) var(--pui-ease-out);
|
|
157
|
+
}
|
|
158
|
+
input[type='checkbox'].filled:checked:not(:disabled):before {
|
|
159
|
+
background-color: var(--pui-color-primary);
|
|
160
|
+
}
|
|
161
|
+
:global(.dark) input[type='checkbox'].filled:checked:not(:disabled):before {
|
|
162
|
+
background-color: var(--pui-color-primary);
|
|
163
|
+
}
|
|
164
|
+
input[type='checkbox'].filled:not(:disabled):after {
|
|
165
|
+
box-shadow: 4px 4px 0px 0px var(--pui-color-white);
|
|
166
|
+
}
|
|
167
|
+
@-webkit-keyframes toggleOnCheckbox {
|
|
168
|
+
0% {
|
|
169
|
+
opacity: 0;
|
|
170
|
+
transform: translate(-50%, -85%) scale(0) rotate(45deg);
|
|
171
|
+
}
|
|
172
|
+
70% {
|
|
173
|
+
opacity: 1;
|
|
174
|
+
transform: translate(-50%, -85%) scale(0.9) rotate(45deg);
|
|
175
|
+
}
|
|
176
|
+
100% {
|
|
177
|
+
transform: translate(-50%, -85%) scale(0.8) rotate(45deg);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
@keyframes toggleOnCheckbox {
|
|
181
|
+
0% {
|
|
182
|
+
opacity: 0;
|
|
183
|
+
transform: translate(-50%, -85%) scale(0) rotate(45deg);
|
|
184
|
+
}
|
|
185
|
+
70% {
|
|
186
|
+
opacity: 1;
|
|
187
|
+
transform: translate(-50%, -85%) scale(0.9) rotate(45deg);
|
|
188
|
+
}
|
|
189
|
+
100% {
|
|
190
|
+
transform: translate(-50%, -85%) scale(0.8) rotate(45deg);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
input.error:before {
|
|
195
|
+
border-color: var(--pui-text-danger) !important;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.error-text {
|
|
199
|
+
color: var(--pui-text-danger);
|
|
200
|
+
}
|
|
201
|
+
</style>
|
package/dist/form/Chips.svelte
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { ComboBoxItem } from '../models/ComboBoxItem.js';
|
|
3
|
-
import FormGroup from './FormGroup.svelte';
|
|
4
|
-
import { iconCheck } from '../icon/index.js';
|
|
5
|
-
import Button from '../ui/Button.svelte';
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
label: string;
|
|
9
|
-
options: ComboBoxItem[];
|
|
10
|
-
required?: boolean;
|
|
11
|
-
showError?: boolean;
|
|
12
|
-
errorText?: string;
|
|
13
|
-
class?: string;
|
|
14
|
-
containerClass?: string;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
value?: string;
|
|
17
|
-
values?: string[];
|
|
18
|
-
multiple?: boolean;
|
|
19
|
-
deselectable?: boolean;
|
|
20
|
-
tooltipLocation?: 'top' | 'bottom' | 'left' | 'right';
|
|
21
|
-
onchange?: (e: string | string[] | undefined) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let {
|
|
25
|
-
label,
|
|
26
|
-
options,
|
|
27
|
-
required = false,
|
|
28
|
-
showError = false,
|
|
29
|
-
errorText = '',
|
|
30
|
-
class: classes = '',
|
|
31
|
-
containerClass = '',
|
|
32
|
-
disabled = false,
|
|
33
|
-
tooltipLocation = 'top',
|
|
34
|
-
value = $bindable(),
|
|
35
|
-
values = $bindable([]),
|
|
36
|
-
multiple = false,
|
|
37
|
-
deselectable = true,
|
|
38
|
-
onchange = undefined
|
|
39
|
-
}: Props = $props();
|
|
40
|
-
|
|
41
|
-
const nonce = Math.random().toString(36).substring(2, 15);
|
|
42
|
-
const randomName = $derived(label + nonce);
|
|
43
|
-
|
|
44
|
-
function handleChange(option: ComboBoxItem) {
|
|
45
|
-
if (!multiple) {
|
|
46
|
-
if (option.value === value) {
|
|
47
|
-
if (!deselectable) return;
|
|
48
|
-
value = undefined;
|
|
49
|
-
} else {
|
|
50
|
-
value = option.value;
|
|
51
|
-
}
|
|
52
|
-
onchange?.(value);
|
|
53
|
-
} else {
|
|
54
|
-
if (values.includes(option.value)) {
|
|
55
|
-
if (!deselectable) return;
|
|
56
|
-
values = values.filter((v) => v !== option.value);
|
|
57
|
-
} else {
|
|
58
|
-
values = [...values, option.value];
|
|
59
|
-
}
|
|
60
|
-
onchange?.(values.length > 0 ? values : undefined);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
</script>
|
|
64
|
-
|
|
65
|
-
<div class="radio-container {containerClass}">
|
|
66
|
-
<FormGroup {label} class={classes} {required} {tooltipLocation}>
|
|
67
|
-
<div
|
|
68
|
-
class="
|
|
69
|
-
radio-options
|
|
70
|
-
{required ? 'radio-required' : ''}
|
|
71
|
-
{showError ? 'error' : ''}
|
|
72
|
-
{disabled ? 'disabled' : ''}"
|
|
73
|
-
>
|
|
74
|
-
{#each options as option}
|
|
75
|
-
{@const checked = multiple ? values.includes(option.value) : option.value === value}
|
|
76
|
-
<div class="flex">
|
|
77
|
-
{#if checked}
|
|
78
|
-
<Button class="chip checked" {disabled} onclick={() => handleChange(option)} svg={iconCheck} iconSize={'16px'}
|
|
79
|
-
>{option.label}</Button
|
|
80
|
-
>
|
|
81
|
-
{:else}
|
|
82
|
-
<Button class="chip" {disabled} onclick={() => handleChange(option)}
|
|
83
|
-
>{option.label}</Button
|
|
84
|
-
>
|
|
85
|
-
{/if}
|
|
86
|
-
</div>
|
|
87
|
-
{/each}
|
|
88
|
-
</div>
|
|
89
|
-
{#if showError && errorText}
|
|
90
|
-
<div class="error-text">{errorText}</div>
|
|
91
|
-
{/if}
|
|
92
|
-
</FormGroup>
|
|
93
|
-
</div>
|
|
94
|
-
|
|
95
|
-
<style>
|
|
96
|
-
.radio-options {
|
|
97
|
-
display: flex;
|
|
98
|
-
gap: var(--pui-spacing-2);
|
|
99
|
-
border-radius: var(--pui-radius-lg);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.radio-required {
|
|
103
|
-
padding: var(--pui-spacing-1);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.error {
|
|
107
|
-
border: 1px solid var(--pui-text-danger);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.error-text {
|
|
111
|
-
margin-top: var(--pui-spacing-1);
|
|
112
|
-
color: var(--pui-text-danger);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
:global(.chip) {
|
|
116
|
-
padding: var(--pui-spacing-1) var(--pui-spacing-4) !important;
|
|
117
|
-
border-radius: var(--pui-radius-full) !important;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
:global(.chip.checked) {
|
|
121
|
-
padding-left: var(--pui-spacing-1) !important;
|
|
122
|
-
padding-right: var(--pui-spacing-2) !important;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
:global(.chip .button) {
|
|
126
|
-
gap: var(--pui-spacing-1);
|
|
127
|
-
}
|
|
128
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComboBoxItem } from '../models/ComboBoxItem.js';
|
|
3
|
+
import FormGroup from './FormGroup.svelte';
|
|
4
|
+
import { iconCheck } from '../icon/index.js';
|
|
5
|
+
import Button from '../ui/Button.svelte';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
label: string;
|
|
9
|
+
options: ComboBoxItem[];
|
|
10
|
+
required?: boolean;
|
|
11
|
+
showError?: boolean;
|
|
12
|
+
errorText?: string;
|
|
13
|
+
class?: string;
|
|
14
|
+
containerClass?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
value?: string;
|
|
17
|
+
values?: string[];
|
|
18
|
+
multiple?: boolean;
|
|
19
|
+
deselectable?: boolean;
|
|
20
|
+
tooltipLocation?: 'top' | 'bottom' | 'left' | 'right';
|
|
21
|
+
onchange?: (e: string | string[] | undefined) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let {
|
|
25
|
+
label,
|
|
26
|
+
options,
|
|
27
|
+
required = false,
|
|
28
|
+
showError = false,
|
|
29
|
+
errorText = '',
|
|
30
|
+
class: classes = '',
|
|
31
|
+
containerClass = '',
|
|
32
|
+
disabled = false,
|
|
33
|
+
tooltipLocation = 'top',
|
|
34
|
+
value = $bindable(),
|
|
35
|
+
values = $bindable([]),
|
|
36
|
+
multiple = false,
|
|
37
|
+
deselectable = true,
|
|
38
|
+
onchange = undefined
|
|
39
|
+
}: Props = $props();
|
|
40
|
+
|
|
41
|
+
const nonce = Math.random().toString(36).substring(2, 15);
|
|
42
|
+
const randomName = $derived(label + nonce);
|
|
43
|
+
|
|
44
|
+
function handleChange(option: ComboBoxItem) {
|
|
45
|
+
if (!multiple) {
|
|
46
|
+
if (option.value === value) {
|
|
47
|
+
if (!deselectable) return;
|
|
48
|
+
value = undefined;
|
|
49
|
+
} else {
|
|
50
|
+
value = option.value;
|
|
51
|
+
}
|
|
52
|
+
onchange?.(value);
|
|
53
|
+
} else {
|
|
54
|
+
if (values.includes(option.value)) {
|
|
55
|
+
if (!deselectable) return;
|
|
56
|
+
values = values.filter((v) => v !== option.value);
|
|
57
|
+
} else {
|
|
58
|
+
values = [...values, option.value];
|
|
59
|
+
}
|
|
60
|
+
onchange?.(values.length > 0 ? values : undefined);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<div class="radio-container {containerClass}">
|
|
66
|
+
<FormGroup {label} class={classes} {required} {tooltipLocation}>
|
|
67
|
+
<div
|
|
68
|
+
class="
|
|
69
|
+
radio-options
|
|
70
|
+
{required ? 'radio-required' : ''}
|
|
71
|
+
{showError ? 'error' : ''}
|
|
72
|
+
{disabled ? 'disabled' : ''}"
|
|
73
|
+
>
|
|
74
|
+
{#each options as option}
|
|
75
|
+
{@const checked = multiple ? values.includes(option.value) : option.value === value}
|
|
76
|
+
<div class="flex">
|
|
77
|
+
{#if checked}
|
|
78
|
+
<Button class="chip checked" {disabled} onclick={() => handleChange(option)} svg={iconCheck} iconSize={'16px'}
|
|
79
|
+
>{option.label}</Button
|
|
80
|
+
>
|
|
81
|
+
{:else}
|
|
82
|
+
<Button class="chip" {disabled} onclick={() => handleChange(option)}
|
|
83
|
+
>{option.label}</Button
|
|
84
|
+
>
|
|
85
|
+
{/if}
|
|
86
|
+
</div>
|
|
87
|
+
{/each}
|
|
88
|
+
</div>
|
|
89
|
+
{#if showError && errorText}
|
|
90
|
+
<div class="error-text">{errorText}</div>
|
|
91
|
+
{/if}
|
|
92
|
+
</FormGroup>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<style>
|
|
96
|
+
.radio-options {
|
|
97
|
+
display: flex;
|
|
98
|
+
gap: var(--pui-spacing-2);
|
|
99
|
+
border-radius: var(--pui-radius-lg);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.radio-required {
|
|
103
|
+
padding: var(--pui-spacing-1);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.error {
|
|
107
|
+
border: 1px solid var(--pui-text-danger);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.error-text {
|
|
111
|
+
margin-top: var(--pui-spacing-1);
|
|
112
|
+
color: var(--pui-text-danger);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:global(.chip) {
|
|
116
|
+
padding: var(--pui-spacing-1) var(--pui-spacing-4) !important;
|
|
117
|
+
border-radius: var(--pui-radius-full) !important;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
:global(.chip.checked) {
|
|
121
|
+
padding-left: var(--pui-spacing-1) !important;
|
|
122
|
+
padding-right: var(--pui-spacing-2) !important;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
:global(.chip .button) {
|
|
126
|
+
gap: var(--pui-spacing-1);
|
|
127
|
+
}
|
|
128
|
+
</style>
|