@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,191 +1,223 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import ComboBox from "./ComboBox.svelte";
|
|
3
|
-
import { clickOutside } from "../actions/ClickOutside.js";
|
|
4
|
-
import Textbox from "./Textbox.svelte";
|
|
5
|
-
import type { NotifyModel } from "../models/NotifyModel.js";
|
|
6
|
-
import type {
|
|
7
|
-
ComboBoxItem,
|
|
8
|
-
FetchFunctionType,
|
|
9
|
-
SearchFunctionType,
|
|
10
|
-
} from "../models/ComboBoxItem.js";
|
|
11
|
-
import { onMount } from "svelte";
|
|
12
|
-
|
|
13
|
-
interface Props {
|
|
14
|
-
label?: string;
|
|
15
|
-
value?: string;
|
|
16
|
-
placeholder?: string;
|
|
17
|
-
showRequired?: boolean;
|
|
18
|
-
classes?: string;
|
|
19
|
-
autofocus?: boolean;
|
|
20
|
-
|
|
21
|
-
preventChangeOnSelection?: boolean;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
let
|
|
58
|
-
let
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import ComboBox from "./ComboBox.svelte";
|
|
3
|
+
import { clickOutside } from "../actions/ClickOutside.js";
|
|
4
|
+
import Textbox from "./Textbox.svelte";
|
|
5
|
+
import type { NotifyModel } from "../models/NotifyModel.js";
|
|
6
|
+
import type {
|
|
7
|
+
ComboBoxItem,
|
|
8
|
+
FetchFunctionType,
|
|
9
|
+
SearchFunctionType,
|
|
10
|
+
} from "../models/ComboBoxItem.js";
|
|
11
|
+
import { onMount } from "svelte";
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
label?: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
showRequired?: boolean;
|
|
18
|
+
classes?: string;
|
|
19
|
+
autofocus?: boolean;
|
|
20
|
+
showNoResultsMessage?: boolean;
|
|
21
|
+
preventChangeOnSelection?: boolean;
|
|
22
|
+
allowCreate?: boolean;
|
|
23
|
+
loadingText?: string;
|
|
24
|
+
groupClass?: string;
|
|
25
|
+
leftIconSvg?: string;
|
|
26
|
+
options?: ComboBoxItem[];
|
|
27
|
+
fetchFunction?: FetchFunctionType;
|
|
28
|
+
searchFunction?: SearchFunctionType;
|
|
29
|
+
onchange?: (e: string) => void;
|
|
30
|
+
enterPressed?: (e: string) => void;
|
|
31
|
+
onSelect?: (e: ComboBoxItem) => void;
|
|
32
|
+
onCreate?: (value: string) => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let {
|
|
36
|
+
label,
|
|
37
|
+
value = $bindable(""),
|
|
38
|
+
placeholder = "Start typing to search...",
|
|
39
|
+
showRequired = false,
|
|
40
|
+
classes = "",
|
|
41
|
+
autofocus = false,
|
|
42
|
+
showNoResultsMessage = false,
|
|
43
|
+
preventChangeOnSelection = false,
|
|
44
|
+
allowCreate = false,
|
|
45
|
+
loadingText = "",
|
|
46
|
+
groupClass = "",
|
|
47
|
+
leftIconSvg,
|
|
48
|
+
options,
|
|
49
|
+
fetchFunction,
|
|
50
|
+
searchFunction,
|
|
51
|
+
onchange = undefined,
|
|
52
|
+
enterPressed = undefined,
|
|
53
|
+
onSelect = undefined,
|
|
54
|
+
onCreate = undefined,
|
|
55
|
+
}: Props = $props();
|
|
56
|
+
|
|
57
|
+
let preloading = $state(false);
|
|
58
|
+
let searching = $state(false);
|
|
59
|
+
let timeout = setTimeout(() => {});
|
|
60
|
+
|
|
61
|
+
let allOptions: ComboBoxItem[] = [];
|
|
62
|
+
let filteredOptions: ComboBoxItem[] = $state([]);
|
|
63
|
+
|
|
64
|
+
let open = $state(false);
|
|
65
|
+
|
|
66
|
+
onMount(() => {
|
|
67
|
+
if (fetchFunction) {
|
|
68
|
+
preloading = true;
|
|
69
|
+
fetchFunction().then((response: NotifyModel<ComboBoxItem[]>) => {
|
|
70
|
+
convertOptions(response.object!);
|
|
71
|
+
preloading = false;
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
if (options) convertOptions(options);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
function convertOptions(options: ComboBoxItem[]) {
|
|
79
|
+
allOptions = options.map((option) => {
|
|
80
|
+
return {
|
|
81
|
+
html: option.label,
|
|
82
|
+
value: option.value,
|
|
83
|
+
selected: option.value == value,
|
|
84
|
+
label: option.label,
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
filteredOptions = [...allOptions];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const CREATE_PREFIX = "__create__";
|
|
91
|
+
|
|
92
|
+
function onSelection(selectedValue: ComboBoxItem) {
|
|
93
|
+
open = false;
|
|
94
|
+
|
|
95
|
+
if (selectedValue.value.startsWith(CREATE_PREFIX)) {
|
|
96
|
+
const newValue = selectedValue.value.slice(CREATE_PREFIX.length);
|
|
97
|
+
const newItem: ComboBoxItem = { label: newValue, value: newValue };
|
|
98
|
+
if (options) {
|
|
99
|
+
options.push(newItem);
|
|
100
|
+
convertOptions(options);
|
|
101
|
+
} else {
|
|
102
|
+
allOptions.push({ ...newItem, selected: true });
|
|
103
|
+
}
|
|
104
|
+
if (!preventChangeOnSelection) value = newValue;
|
|
105
|
+
onSelect?.(newItem);
|
|
106
|
+
onCreate?.(newValue);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (options) {
|
|
111
|
+
options.forEach((option) => {
|
|
112
|
+
option.selected = option.value == selectedValue.value;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!preventChangeOnSelection) value = selectedValue.value;
|
|
117
|
+
|
|
118
|
+
onSelect?.(selectedValue);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function appendCreateOption(opts: ComboBoxItem[], query: string): ComboBoxItem[] {
|
|
122
|
+
if (!allowCreate || !query.trim()) return opts;
|
|
123
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
124
|
+
const exactMatch = opts.some((o) => o.label.toLowerCase() === normalizedQuery);
|
|
125
|
+
if (exactMatch) return opts;
|
|
126
|
+
return [...opts, { label: `Create "${query.trim()}"`, value: CREATE_PREFIX + query.trim() }];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function onFilterChange(value: string) {
|
|
130
|
+
if (searchFunction && value) {
|
|
131
|
+
clearTimeout(timeout);
|
|
132
|
+
searching = true;
|
|
133
|
+
timeout = setTimeout(() => {
|
|
134
|
+
searchFunction(value).then(
|
|
135
|
+
(response: NotifyModel<ComboBoxItem[]>) => {
|
|
136
|
+
convertOptions(response.object!);
|
|
137
|
+
filteredOptions = appendCreateOption(filteredOptions, value);
|
|
138
|
+
searching = false;
|
|
139
|
+
},
|
|
140
|
+
);
|
|
141
|
+
}, 300);
|
|
142
|
+
} else if (allOptions) {
|
|
143
|
+
filteredOptions = allOptions.filter((option) =>
|
|
144
|
+
option.label.toLowerCase().includes(value.toLowerCase()),
|
|
145
|
+
);
|
|
146
|
+
filteredOptions = appendCreateOption(filteredOptions, value);
|
|
147
|
+
open = true;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
onchange?.(value);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let textboxElement: HTMLElement | undefined = $state(undefined);
|
|
154
|
+
|
|
155
|
+
// returns true if an item was selected, false otherwise
|
|
156
|
+
let comboBoxKeyDown: ((e: KeyboardEvent) => boolean) | undefined =
|
|
157
|
+
$state(undefined);
|
|
158
|
+
|
|
159
|
+
function onKeyDown(e: KeyboardEvent) {
|
|
160
|
+
if (!open) {
|
|
161
|
+
if (e.key === "Enter")
|
|
162
|
+
// If combobox is not open return user entered string
|
|
163
|
+
enterPressed?.(value);
|
|
164
|
+
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (e.key === "Escape") {
|
|
169
|
+
e.preventDefault();
|
|
170
|
+
open = false;
|
|
171
|
+
} else if (comboBoxKeyDown) {
|
|
172
|
+
const itemSelected = comboBoxKeyDown(e);
|
|
173
|
+
|
|
174
|
+
if (!itemSelected && e.key === "Enter") enterPressed?.(value);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function onFocus(e: any) {
|
|
179
|
+
open = true;
|
|
180
|
+
const target = e?.target as HTMLInputElement;
|
|
181
|
+
target?.select();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function closePopover(e: MouseEvent) {
|
|
185
|
+
if (textboxElement?.contains(e.target as HTMLElement)) return;
|
|
186
|
+
|
|
187
|
+
open = false;
|
|
188
|
+
}
|
|
189
|
+
</script>
|
|
190
|
+
|
|
191
|
+
<Textbox
|
|
192
|
+
{label}
|
|
193
|
+
class={classes}
|
|
194
|
+
required={showRequired}
|
|
195
|
+
bind:textboxElement
|
|
196
|
+
placeholder={preloading ? "Loading..." : placeholder}
|
|
197
|
+
loading={searching || preloading}
|
|
198
|
+
disabled={preloading}
|
|
199
|
+
noAutocomplete
|
|
200
|
+
{groupClass}
|
|
201
|
+
{leftIconSvg}
|
|
202
|
+
bind:value
|
|
203
|
+
oninput={() => {
|
|
204
|
+
onFilterChange(value);
|
|
205
|
+
}}
|
|
206
|
+
onfocus={onFocus}
|
|
207
|
+
onkeydown={onKeyDown}
|
|
208
|
+
>
|
|
209
|
+
<div class="relative w-full" use:clickOutside={closePopover}>
|
|
210
|
+
<ComboBox
|
|
211
|
+
{value}
|
|
212
|
+
onselection={onSelection}
|
|
213
|
+
options={filteredOptions}
|
|
214
|
+
{open}
|
|
215
|
+
loading={searching}
|
|
216
|
+
{showNoResultsMessage}
|
|
217
|
+
{loadingText}
|
|
218
|
+
/>
|
|
219
|
+
</div>
|
|
220
|
+
</Textbox>
|
|
221
|
+
|
|
222
|
+
<style>
|
|
223
|
+
</style>
|
|
@@ -6,8 +6,9 @@ interface Props {
|
|
|
6
6
|
showRequired?: boolean;
|
|
7
7
|
classes?: string;
|
|
8
8
|
autofocus?: boolean;
|
|
9
|
-
|
|
9
|
+
showNoResultsMessage?: boolean;
|
|
10
10
|
preventChangeOnSelection?: boolean;
|
|
11
|
+
allowCreate?: boolean;
|
|
11
12
|
loadingText?: string;
|
|
12
13
|
groupClass?: string;
|
|
13
14
|
leftIconSvg?: string;
|
|
@@ -17,6 +18,7 @@ interface Props {
|
|
|
17
18
|
onchange?: (e: string) => void;
|
|
18
19
|
enterPressed?: (e: string) => void;
|
|
19
20
|
onSelect?: (e: ComboBoxItem) => void;
|
|
21
|
+
onCreate?: (value: string) => void;
|
|
20
22
|
}
|
|
21
23
|
declare const Autocomplete: import("svelte").Component<Props, {}, "value">;
|
|
22
24
|
type Autocomplete = ReturnType<typeof Autocomplete>;
|