@marianmeres/stuic 2.3.2 → 2.4.0
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/README.md +0 -1
- package/dist/README.md +17 -11
- package/dist/actions/autogrow.svelte.js +4 -4
- package/dist/actions/autoscroll.d.ts +2 -2
- package/dist/actions/autoscroll.js +17 -8
- package/dist/actions/file-dropzone.svelte.d.ts +1 -1
- package/dist/actions/file-dropzone.svelte.js +1 -1
- package/dist/actions/focus-trap.js +33 -24
- package/dist/actions/highlight-dragover.svelte.js +6 -5
- package/dist/actions/on-submit-validity-check.svelte.js +2 -2
- package/dist/actions/resizable-width.svelte.d.ts +1 -1
- package/dist/actions/resizable-width.svelte.js +7 -5
- package/dist/actions/tooltip/index.css +2 -7
- package/dist/actions/tooltip/tooltip.svelte.js +5 -4
- package/dist/actions/trim.svelte.d.ts +1 -1
- package/dist/actions/trim.svelte.js +2 -2
- package/dist/actions/validate.svelte.d.ts +4 -4
- package/dist/actions/validate.svelte.js +9 -9
- package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.d.ts +7 -6
- package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.js +1 -2
- package/dist/components/AlertConfirmPrompt/index.d.ts +1 -1
- package/dist/components/AlertConfirmPrompt/index.js +1 -1
- package/dist/components/AnimatedElipsis/index.d.ts +1 -1
- package/dist/components/AnimatedElipsis/index.js +1 -1
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/ButtonGroupRadio/ButtonGroupRadio.svelte +4 -1
- package/dist/components/ButtonGroupRadio/index.d.ts +1 -1
- package/dist/components/ButtonGroupRadio/index.js +1 -1
- package/dist/components/ColorScheme/index.d.ts +2 -2
- package/dist/components/ColorScheme/index.js +2 -2
- package/dist/components/CommandMenu/index.d.ts +1 -1
- package/dist/components/CommandMenu/index.js +1 -1
- package/dist/components/DismissibleMessage/index.d.ts +1 -1
- package/dist/components/DismissibleMessage/index.js +1 -1
- package/dist/components/HoverExpandableWidth/index.d.ts +1 -1
- package/dist/components/HoverExpandableWidth/index.js +1 -1
- package/dist/components/Input/FieldAssets.svelte +7 -3
- package/dist/components/Input/FieldLikeButton.svelte +1 -1
- package/dist/components/Input/FieldOptions.svelte +1 -1
- package/dist/components/Input/index.d.ts +7 -7
- package/dist/components/Input/index.js +7 -7
- package/dist/components/KbdShortcut/index.d.ts +1 -1
- package/dist/components/KbdShortcut/index.js +1 -1
- package/dist/components/ModalDialog/index.d.ts +1 -1
- package/dist/components/ModalDialog/index.js +1 -1
- package/dist/components/Notifications/index.d.ts +1 -1
- package/dist/components/Notifications/index.js +1 -1
- package/dist/components/Notifications/notifications-stack.svelte.d.ts +5 -5
- package/dist/components/Notifications/notifications-stack.svelte.js +8 -7
- package/dist/components/SlidingPanels/index.d.ts +1 -1
- package/dist/components/SlidingPanels/index.js +1 -1
- package/dist/components/Spinner/index.d.ts +1 -1
- package/dist/components/Spinner/index.js +1 -1
- package/dist/components/Switch/Switch.svelte +5 -2
- package/dist/components/Switch/index.d.ts +1 -1
- package/dist/components/Switch/index.js +1 -1
- package/dist/components/TypeaheadInput/index.d.ts +1 -1
- package/dist/components/TypeaheadInput/index.js +1 -1
- package/dist/utils/body-scroll-locker.js +4 -3
- package/dist/utils/breakpoint.svelte.js +0 -2
- package/dist/utils/colors.js +3 -3
- package/dist/utils/debounce.d.ts +1 -1
- package/dist/utils/debounce.js +1 -2
- package/dist/utils/escape-regex.js +1 -1
- package/dist/utils/event-emitter.d.ts +2 -3
- package/dist/utils/event-emitter.js +1 -2
- package/dist/utils/event-modifiers.d.ts +4 -4
- package/dist/utils/event-modifiers.js +4 -6
- package/dist/utils/get-file-type-label.js +1 -1
- package/dist/utils/is-image.js +2 -2
- package/dist/utils/is-nullish.d.ts +1 -1
- package/dist/utils/is-plain-object.d.ts +1 -1
- package/dist/utils/is-plain-object.js +4 -1
- package/dist/utils/maybe-json-parse.d.ts +1 -1
- package/dist/utils/maybe-json-parse.js +1 -1
- package/dist/utils/maybe-json-stringify.d.ts +1 -1
- package/dist/utils/move-array-item.d.ts +1 -1
- package/dist/utils/preload-img.js +2 -1
- package/dist/utils/sleep.d.ts +1 -1
- package/dist/utils/storage-abstraction.d.ts +13 -13
- package/dist/utils/storage-abstraction.js +2 -0
- package/dist/utils/svg-circle.js +2 -1
- package/dist/utils/switch.svelte.d.ts +1 -1
- package/dist/utils/switch.svelte.js +1 -1
- package/dist/utils/throttle.d.ts +1 -1
- package/dist/utils/throttle.js +7 -8
- package/dist/utils/to-integer.d.ts +1 -1
- package/package.json +6 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as ButtonGroupRadio, type Props as ButtonGroupRadioProps } from "./ButtonGroupRadio.svelte";
|
|
1
|
+
export { default as ButtonGroupRadio, type Props as ButtonGroupRadioProps, } from "./ButtonGroupRadio.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as ButtonGroupRadio } from "./ButtonGroupRadio.svelte";
|
|
1
|
+
export { default as ButtonGroupRadio, } from "./ButtonGroupRadio.svelte";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from "./color-scheme.js";
|
|
2
|
-
export { default as ColorSchemeLocal, type Props as ColorSchemeLocalProps } from "./ColorSchemeLocal.svelte";
|
|
3
|
-
export { default as ColorSchemeSystemAware, type Props as ColorSchemeSystemAwareProps } from "./ColorSchemeSystemAware.svelte";
|
|
2
|
+
export { default as ColorSchemeLocal, type Props as ColorSchemeLocalProps, } from "./ColorSchemeLocal.svelte";
|
|
3
|
+
export { default as ColorSchemeSystemAware, type Props as ColorSchemeSystemAwareProps, } from "./ColorSchemeSystemAware.svelte";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from "./color-scheme.js";
|
|
2
|
-
export { default as ColorSchemeLocal } from "./ColorSchemeLocal.svelte";
|
|
3
|
-
export { default as ColorSchemeSystemAware } from "./ColorSchemeSystemAware.svelte";
|
|
2
|
+
export { default as ColorSchemeLocal, } from "./ColorSchemeLocal.svelte";
|
|
3
|
+
export { default as ColorSchemeSystemAware, } from "./ColorSchemeSystemAware.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as CommandMenu, type Props as CommandMenuProps } from "./CommandMenu.svelte";
|
|
1
|
+
export { default as CommandMenu, type Props as CommandMenuProps, } from "./CommandMenu.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as CommandMenu } from "./CommandMenu.svelte";
|
|
1
|
+
export { default as CommandMenu, } from "./CommandMenu.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as DismissibleMessage, type Props as DismissibleMessageProps } from "./DismissibleMessage.svelte";
|
|
1
|
+
export { default as DismissibleMessage, type Props as DismissibleMessageProps, } from "./DismissibleMessage.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as DismissibleMessage } from "./DismissibleMessage.svelte";
|
|
1
|
+
export { default as DismissibleMessage, } from "./DismissibleMessage.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as HoverExpandableWidth, type Props as HoverExpandableWidthProps } from "./HoverExpandableWidth.svelte";
|
|
1
|
+
export { default as HoverExpandableWidth, type Props as HoverExpandableWidthProps, } from "./HoverExpandableWidth.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as HoverExpandableWidth } from "./HoverExpandableWidth.svelte";
|
|
1
|
+
export { default as HoverExpandableWidth, } from "./HoverExpandableWidth.svelte";
|
|
@@ -454,13 +454,17 @@
|
|
|
454
454
|
|
|
455
455
|
if (accept && [...(files ?? [])].some((f) => !is_accepted_type(accept, f.type))) {
|
|
456
456
|
const msg = t("invalid_type", { accept });
|
|
457
|
-
|
|
457
|
+
if (notifications) notifications.error(msg);
|
|
458
|
+
else alert(msg);
|
|
459
|
+
return;
|
|
458
460
|
}
|
|
459
461
|
|
|
460
462
|
const cardErrMsg = t("cardinality_reached", { max: cardinality });
|
|
461
463
|
if (assets.length > cardinality) {
|
|
462
464
|
// if (assets.length + (files?.length ?? 0) > cardinality) {
|
|
463
|
-
|
|
465
|
+
if (notifications) notifications.error(cardErrMsg);
|
|
466
|
+
else alert(cardErrMsg);
|
|
467
|
+
return;
|
|
464
468
|
}
|
|
465
469
|
|
|
466
470
|
const toBeProcessed: FieldAsset[] = [];
|
|
@@ -547,7 +551,7 @@
|
|
|
547
551
|
|
|
548
552
|
<input type="file" bind:this={inputEl} multiple style="display: none" {accept} />
|
|
549
553
|
<!-- hack to be able to validate the conventional way -->
|
|
550
|
-
<input type="hidden" {name}
|
|
554
|
+
<input type="hidden" {name} {value} use:validateAction={() => wrappedValidate} />
|
|
551
555
|
|
|
552
556
|
<Modal
|
|
553
557
|
bind:this={modal}
|
|
@@ -329,7 +329,7 @@
|
|
|
329
329
|
|
|
330
330
|
$effect(() => {
|
|
331
331
|
if (modal.visibility().visible && touch) {
|
|
332
|
-
_selectedColl.clear().addMany(maybeJsonParse(value));
|
|
332
|
+
_selectedColl.clear().addMany(maybeJsonParse(value) as Item[]);
|
|
333
333
|
// IMPORTANT: focus first selected so it scrolls into view on open
|
|
334
334
|
if (_selectedColl.size) {
|
|
335
335
|
waitForNextRepaint().then(() => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export * from "./types.js";
|
|
2
2
|
export { default as FieldAssets, type Props as FieldAssetsProps, type FieldAsset, type FieldAssetUrlObj, type FieldAssetWithBlobUrl, } from "./FieldAssets.svelte";
|
|
3
|
-
export { default as FieldCheckbox, type Props as FieldCheckboxProps } from "./FieldCheckbox.svelte";
|
|
3
|
+
export { default as FieldCheckbox, type Props as FieldCheckboxProps, } from "./FieldCheckbox.svelte";
|
|
4
4
|
export { default as FieldFile, type Props as FieldFileProps } from "./FieldFile.svelte";
|
|
5
|
-
export { default as FieldInput, type Props as FieldInputProps } from "./FieldInput.svelte";
|
|
6
|
-
export { default as FieldLikeButton, type Props as FieldLikeButtonProps } from "./FieldLikeButton.svelte";
|
|
5
|
+
export { default as FieldInput, type Props as FieldInputProps, } from "./FieldInput.svelte";
|
|
6
|
+
export { default as FieldLikeButton, type Props as FieldLikeButtonProps, } from "./FieldLikeButton.svelte";
|
|
7
7
|
export { default as FieldOptions, type Props as FieldOptionsProps, type Option as FieldOption, } from "./FieldOptions.svelte";
|
|
8
|
-
export { default as FieldRadios, type Props as FieldRadiosProps } from "./FieldRadios.svelte";
|
|
9
|
-
export { default as FieldSelect, type Props as FieldSelectProps } from "./FieldSelect.svelte";
|
|
8
|
+
export { default as FieldRadios, type Props as FieldRadiosProps, } from "./FieldRadios.svelte";
|
|
9
|
+
export { default as FieldSelect, type Props as FieldSelectProps, } from "./FieldSelect.svelte";
|
|
10
10
|
export { default as Fieldset, type Props as FieldsetProps } from "./Fieldset.svelte";
|
|
11
|
-
export { default as FieldSwitch, type Props as FieldSwitchProps } from "./FieldSwitch.svelte";
|
|
12
|
-
export { default as FieldTextarea, type Props as FieldTextareaProps } from "./FieldTextarea.svelte";
|
|
11
|
+
export { default as FieldSwitch, type Props as FieldSwitchProps, } from "./FieldSwitch.svelte";
|
|
12
|
+
export { default as FieldTextarea, type Props as FieldTextareaProps, } from "./FieldTextarea.svelte";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export * from "./types.js";
|
|
2
2
|
export { default as FieldAssets, } from "./FieldAssets.svelte";
|
|
3
|
-
export { default as FieldCheckbox } from "./FieldCheckbox.svelte";
|
|
3
|
+
export { default as FieldCheckbox, } from "./FieldCheckbox.svelte";
|
|
4
4
|
export { default as FieldFile } from "./FieldFile.svelte";
|
|
5
|
-
export { default as FieldInput } from "./FieldInput.svelte";
|
|
6
|
-
export { default as FieldLikeButton } from "./FieldLikeButton.svelte";
|
|
5
|
+
export { default as FieldInput, } from "./FieldInput.svelte";
|
|
6
|
+
export { default as FieldLikeButton, } from "./FieldLikeButton.svelte";
|
|
7
7
|
export { default as FieldOptions, } from "./FieldOptions.svelte";
|
|
8
|
-
export { default as FieldRadios } from "./FieldRadios.svelte";
|
|
9
|
-
export { default as FieldSelect } from "./FieldSelect.svelte";
|
|
8
|
+
export { default as FieldRadios, } from "./FieldRadios.svelte";
|
|
9
|
+
export { default as FieldSelect, } from "./FieldSelect.svelte";
|
|
10
10
|
export { default as Fieldset } from "./Fieldset.svelte";
|
|
11
|
-
export { default as FieldSwitch } from "./FieldSwitch.svelte";
|
|
12
|
-
export { default as FieldTextarea } from "./FieldTextarea.svelte";
|
|
11
|
+
export { default as FieldSwitch, } from "./FieldSwitch.svelte";
|
|
12
|
+
export { default as FieldTextarea, } from "./FieldTextarea.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as KbdShortcut, type Props as KbdShortcutProps } from "./KbdShortcut.svelte";
|
|
1
|
+
export { default as KbdShortcut, type Props as KbdShortcutProps, } from "./KbdShortcut.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as KbdShortcut } from "./KbdShortcut.svelte";
|
|
1
|
+
export { default as KbdShortcut, } from "./KbdShortcut.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as ModalDialog, type Props as ModalDialogProps } from "./ModalDialog.svelte";
|
|
1
|
+
export { default as ModalDialog, type Props as ModalDialogProps, } from "./ModalDialog.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as ModalDialog } from "./ModalDialog.svelte";
|
|
1
|
+
export { default as ModalDialog, } from "./ModalDialog.svelte";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./notifications-stack.svelte.js";
|
|
2
|
-
export { default as Notifications, type Props as NotificationsProps } from "./Notifications.svelte";
|
|
2
|
+
export { default as Notifications, type Props as NotificationsProps, } from "./Notifications.svelte";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./notifications-stack.svelte.js";
|
|
2
|
-
export { default as Notifications } from "./Notifications.svelte";
|
|
2
|
+
export { default as Notifications, } from "./Notifications.svelte";
|
|
@@ -5,7 +5,7 @@ import { type THC } from "../Thc/Thc.svelte";
|
|
|
5
5
|
*/
|
|
6
6
|
export interface ComponentWrap {
|
|
7
7
|
component: Component;
|
|
8
|
-
props?:
|
|
8
|
+
props?: Record<string, unknown>;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Sort order for notifications in the stack.
|
|
@@ -18,17 +18,17 @@ export type NotificationType = "info" | "success" | "warn" | "error" | string;
|
|
|
18
18
|
/**
|
|
19
19
|
* Input options for creating a notification.
|
|
20
20
|
*/
|
|
21
|
-
export interface NotificationInput extends Record<string,
|
|
21
|
+
export interface NotificationInput extends Record<string, unknown> {
|
|
22
22
|
/** Unique id of the notification. If not provided, will be calculated from content.
|
|
23
23
|
Multiple notifications with the same id will be ignored (but the `count` will be increased). */
|
|
24
|
-
id:
|
|
24
|
+
id: string | number;
|
|
25
25
|
/** Optional UI rendering well known hint (has no effect on the functionality, can be
|
|
26
26
|
any string), defaults to "info". */
|
|
27
27
|
type: NotificationType;
|
|
28
28
|
/** The actual notification message (either plain text, html or component)
|
|
29
29
|
notifications without any content will be ignored. */
|
|
30
30
|
content: THC;
|
|
31
|
-
onClick: (self: Notification, all: Notification[], data:
|
|
31
|
+
onClick: (self: Notification, all: Notification[], data: unknown) => void;
|
|
32
32
|
/** Notification specific time-to-live in milliseconds (after which notif will be auto discarded)
|
|
33
33
|
use 0 to disable auto disposal */
|
|
34
34
|
ttl: number;
|
|
@@ -113,7 +113,7 @@ export declare class NotificationsStack {
|
|
|
113
113
|
readonly options: NotificationsStackOptions;
|
|
114
114
|
constructor(initial?: NotificationCreateParam[], opts?: Partial<NotificationsStackOptions>);
|
|
115
115
|
/** Will remove the notification from stack */
|
|
116
|
-
removeById: (id: string) => this;
|
|
116
|
+
removeById: (id: string | number) => this;
|
|
117
117
|
/** Will cleanup the stack. */
|
|
118
118
|
reset: () => this;
|
|
119
119
|
/**
|
|
@@ -9,12 +9,13 @@ const DEFAULT_OPTIONS = {
|
|
|
9
9
|
sortOrder: "asc",
|
|
10
10
|
disposeInterval: 500,
|
|
11
11
|
};
|
|
12
|
-
const isFn = (v) => typeof v === "function";
|
|
12
|
+
// const isFn = (v: unknown) => typeof v === "function";
|
|
13
13
|
const _id = (type, content) => {
|
|
14
|
-
const
|
|
14
|
+
const c = content;
|
|
15
|
+
const str = typeof c === "object" && c?.component
|
|
15
16
|
? "component"
|
|
16
|
-
:
|
|
17
|
-
return ["id", type, strHash(str)].join("-");
|
|
17
|
+
: (typeof c === "object" ? c?.html || c?.text : c) || content;
|
|
18
|
+
return ["id", type, strHash(String(str))].join("-");
|
|
18
19
|
};
|
|
19
20
|
/**
|
|
20
21
|
* A reactive notification queue manager with auto-disposal and deduplication.
|
|
@@ -91,7 +92,7 @@ export class NotificationsStack {
|
|
|
91
92
|
}
|
|
92
93
|
/** Will normalize item to internal shape. */
|
|
93
94
|
#normalize = (n) => {
|
|
94
|
-
|
|
95
|
+
const o = typeof n === "string" ? { id: 0, content: n } : n;
|
|
95
96
|
if (!o.content)
|
|
96
97
|
return null;
|
|
97
98
|
o.type ||= this.options.defaultType;
|
|
@@ -125,8 +126,8 @@ export class NotificationsStack {
|
|
|
125
126
|
else {
|
|
126
127
|
stack.push(notif);
|
|
127
128
|
stack.sort((a, b) => {
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
const _a = a.created.valueOf();
|
|
130
|
+
const _b = b.created.valueOf();
|
|
130
131
|
return sortOrder === "desc" ? _b - _a : _a - _b;
|
|
131
132
|
});
|
|
132
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as SlidingPanels, type Props as SlidingPanelsProps } from "./SlidingPanels.svelte";
|
|
1
|
+
export { default as SlidingPanels, type Props as SlidingPanelsProps, } from "./SlidingPanels.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as SlidingPanels } from "./SlidingPanels.svelte";
|
|
1
|
+
export { default as SlidingPanels, } from "./SlidingPanels.svelte";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default as Spinner, type Props as SpinnerProps } from "./Spinner.svelte";
|
|
2
|
-
export { default as SpinnerCircle, type Props as SpinnerCircleProps } from "./SpinnerCircle.svelte";
|
|
2
|
+
export { default as SpinnerCircle, type Props as SpinnerCircleProps, } from "./SpinnerCircle.svelte";
|
|
3
3
|
export { spinnerCreateBackAndForthCharFrames, default as SpinnerUnicode, type Props as SpinnerUnicodeProps, type SpinnerUnicodeVariant, } from "./SpinnerUnicode.svelte";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default as Spinner } from "./Spinner.svelte";
|
|
2
|
-
export { default as SpinnerCircle } from "./SpinnerCircle.svelte";
|
|
2
|
+
export { default as SpinnerCircle, } from "./SpinnerCircle.svelte";
|
|
3
3
|
export { spinnerCreateBackAndForthCharFrames, default as SpinnerUnicode, } from "./SpinnerUnicode.svelte";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
3
|
import type { FormEventHandler, HTMLLabelAttributes } from "svelte/elements";
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
ValidateOptions,
|
|
6
|
+
ValidationResult,
|
|
7
|
+
} from "../../actions/validate.svelte.js";
|
|
5
8
|
|
|
6
9
|
export interface Props extends Omit<HTMLLabelAttributes, "children" | "onchange"> {
|
|
7
10
|
button?: HTMLButtonElement;
|
|
@@ -136,7 +139,7 @@
|
|
|
136
139
|
|
|
137
140
|
if (typeof onclick === "function") onclick(e);
|
|
138
141
|
}}
|
|
139
|
-
{...
|
|
142
|
+
{...rest as Record<string, unknown>}
|
|
140
143
|
>
|
|
141
144
|
<span
|
|
142
145
|
class={twMerge(
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as Switch, type Props as SwitchProps } from "./Switch.svelte";
|
|
2
|
-
export { default as SwitchButton, type Props as SwitchButtonProps } from "./SwitchButton.svelte";
|
|
2
|
+
export { default as SwitchButton, type Props as SwitchButtonProps, } from "./SwitchButton.svelte";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as Switch } from "./Switch.svelte";
|
|
2
|
-
export { default as SwitchButton } from "./SwitchButton.svelte";
|
|
2
|
+
export { default as SwitchButton, } from "./SwitchButton.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as TypeaheadInput, type Props as TypeaheadInputProps } from "./TypeaheadInput.svelte";
|
|
1
|
+
export { default as TypeaheadInput, type Props as TypeaheadInputProps, } from "./TypeaheadInput.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as TypeaheadInput } from "./TypeaheadInput.svelte";
|
|
1
|
+
export { default as TypeaheadInput, } from "./TypeaheadInput.svelte";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { createClog } from "@marianmeres/clog";
|
|
2
1
|
import { isBrowser } from "./is-browser.js";
|
|
3
|
-
const clog = createClog("BodyScroll").debug;
|
|
2
|
+
// const clog = createClog("BodyScroll").debug;
|
|
4
3
|
const document = globalThis.document ?? {};
|
|
5
4
|
/**
|
|
6
5
|
* A utility class for locking and unlocking body scroll position.
|
|
@@ -87,7 +86,9 @@ export class BodyScroll {
|
|
|
87
86
|
try {
|
|
88
87
|
original = JSON.parse(originalJsonString);
|
|
89
88
|
}
|
|
90
|
-
catch
|
|
89
|
+
catch {
|
|
90
|
+
// ignore parse errors, use defaults
|
|
91
|
+
}
|
|
91
92
|
["position", "top", "width", "overflow"].forEach((k) => {
|
|
92
93
|
if (original[k] !== null) {
|
|
93
94
|
document.body.style[k] = original[k];
|
package/dist/utils/colors.js
CHANGED
|
@@ -65,11 +65,11 @@ export function rgbToOklch(rgb) {
|
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
67
|
export function hexToRgb(hex) {
|
|
68
|
-
|
|
68
|
+
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
69
69
|
hex = hex.replace(shorthandRegex, (m, r, g, b) => {
|
|
70
70
|
return r + r + g + g + b + b;
|
|
71
71
|
});
|
|
72
|
-
|
|
72
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
73
73
|
return result
|
|
74
74
|
? {
|
|
75
75
|
r: parseInt(result[1], 16),
|
|
@@ -95,7 +95,7 @@ export function hexToRgb(hex) {
|
|
|
95
95
|
*/
|
|
96
96
|
export function srgbToLinearRgb({ r, g, b }) {
|
|
97
97
|
const convert = (val) => {
|
|
98
|
-
|
|
98
|
+
const v = val / 255;
|
|
99
99
|
return v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
|
|
100
100
|
};
|
|
101
101
|
return {
|
package/dist/utils/debounce.d.ts
CHANGED
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
* input.addEventListener('input', (e) => debouncedSearch(e.target.value));
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export declare function debounce<T extends (...args:
|
|
13
|
+
export declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, wait: number): (...args: Parameters<T>) => void;
|
package/dist/utils/debounce.js
CHANGED
|
@@ -13,9 +13,8 @@
|
|
|
13
13
|
export function debounce(fn, wait) {
|
|
14
14
|
let timeout = null;
|
|
15
15
|
return function (...args) {
|
|
16
|
-
const context = this;
|
|
17
16
|
if (timeout !== null)
|
|
18
17
|
clearTimeout(timeout);
|
|
19
|
-
timeout = setTimeout(() => fn.apply(
|
|
18
|
+
timeout = setTimeout(() => fn.apply(this, args), wait);
|
|
20
19
|
};
|
|
21
20
|
}
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
* escapeRegex('a+b=c'); // 'a\\+b=c'
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export const escapeRegex = (str) => `${str}`.replace(/[.*+?^${}()|[\]\\]/g,
|
|
14
|
+
export const escapeRegex = (str) => `${str}`.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
|
|
@@ -23,8 +23,7 @@ export declare class EventEmitter extends EventTarget {
|
|
|
23
23
|
* Adds an event listener with automatic abort signal attachment.
|
|
24
24
|
* Overrides the native method to enable `removeAllListeners()` functionality.
|
|
25
25
|
*/
|
|
26
|
-
addEventListener(type: string, listener:
|
|
27
|
-
options?: boolean | AddEventListenerOptions): void;
|
|
26
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
|
|
28
27
|
/**
|
|
29
28
|
* Removes all registered event listeners at once.
|
|
30
29
|
*/
|
|
@@ -34,7 +33,7 @@ export declare class EventEmitter extends EventTarget {
|
|
|
34
33
|
* @param eventName - The name of the event to emit
|
|
35
34
|
* @param detail - Optional data to attach to the event
|
|
36
35
|
*/
|
|
37
|
-
emit(eventName: string, detail?:
|
|
36
|
+
emit(eventName: string, detail?: unknown): void;
|
|
38
37
|
/**
|
|
39
38
|
* Subscribes to an event. Returns an unsubscribe function.
|
|
40
39
|
* @param eventName - The name of the event
|
|
@@ -25,8 +25,7 @@ export class EventEmitter extends EventTarget {
|
|
|
25
25
|
* Adds an event listener with automatic abort signal attachment.
|
|
26
26
|
* Overrides the native method to enable `removeAllListeners()` functionality.
|
|
27
27
|
*/
|
|
28
|
-
addEventListener(type, listener,
|
|
29
|
-
options = {}) {
|
|
28
|
+
addEventListener(type, listener, options = {}) {
|
|
30
29
|
// normalize opts (for the `once` shorthand)
|
|
31
30
|
options = typeof options === "boolean" ? { capture: options } : options;
|
|
32
31
|
// make sure to always add abort signal
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* // Logs only on first click
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export declare function once(fn: (e: Event) =>
|
|
13
|
+
export declare function once(fn: (e: Event) => void): (this: unknown, e: Event) => void;
|
|
14
14
|
/**
|
|
15
15
|
* Wraps an event handler to call `preventDefault()` before executing.
|
|
16
16
|
*
|
|
@@ -22,7 +22,7 @@ export declare function once(fn: (e: Event) => any): (e: Event) => void;
|
|
|
22
22
|
* form.addEventListener('submit', preventDefault((e) => handleSubmit(e)));
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
export declare function preventDefault(fn?: (e: Event) =>
|
|
25
|
+
export declare function preventDefault(fn?: (e: Event) => void): (this: unknown, e: Event) => void;
|
|
26
26
|
/**
|
|
27
27
|
* Wraps an event handler to call `stopPropagation()` before executing.
|
|
28
28
|
*
|
|
@@ -35,7 +35,7 @@ export declare function preventDefault(fn?: (e: Event) => any): (e: Event) => vo
|
|
|
35
35
|
* // Parent click handlers won't be triggered
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
export declare function stopPropagation(fn?: (e: Event) =>
|
|
38
|
+
export declare function stopPropagation(fn?: (e: Event) => void): (this: unknown, e: Event) => void;
|
|
39
39
|
/**
|
|
40
40
|
* Wraps an event handler to call `stopImmediatePropagation()` before executing.
|
|
41
41
|
*
|
|
@@ -50,4 +50,4 @@ export declare function stopPropagation(fn?: (e: Event) => any): (e: Event) => v
|
|
|
50
50
|
* // Other click handlers on this element won't be triggered
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
|
-
export declare function stopImmediatePropagation(fn?: (e: Event) =>
|
|
53
|
+
export declare function stopImmediatePropagation(fn?: (e: Event) => void): (this: unknown, e: Event) => void;
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
13
|
export function once(fn) {
|
|
14
|
+
let called = false;
|
|
14
15
|
return function (e) {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
if (!called) {
|
|
17
|
+
called = true;
|
|
17
18
|
fn.call(this, e);
|
|
18
|
-
|
|
19
|
+
}
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
@@ -32,7 +33,6 @@ export function once(fn) {
|
|
|
32
33
|
export function preventDefault(fn) {
|
|
33
34
|
return function (e) {
|
|
34
35
|
e.preventDefault();
|
|
35
|
-
// @ts-ignore
|
|
36
36
|
fn?.call(this, e);
|
|
37
37
|
};
|
|
38
38
|
}
|
|
@@ -51,7 +51,6 @@ export function preventDefault(fn) {
|
|
|
51
51
|
export function stopPropagation(fn) {
|
|
52
52
|
return function (e) {
|
|
53
53
|
e.stopPropagation();
|
|
54
|
-
// @ts-ignore
|
|
55
54
|
fn?.call(this, e);
|
|
56
55
|
};
|
|
57
56
|
}
|
|
@@ -72,7 +71,6 @@ export function stopPropagation(fn) {
|
|
|
72
71
|
export function stopImmediatePropagation(fn) {
|
|
73
72
|
return function (e) {
|
|
74
73
|
e.stopImmediatePropagation();
|
|
75
|
-
// @ts-ignore
|
|
76
74
|
fn?.call(this, e);
|
|
77
75
|
};
|
|
78
76
|
}
|
package/dist/utils/is-image.js
CHANGED
|
@@ -18,10 +18,10 @@ export function isImage(mimeOrPath) {
|
|
|
18
18
|
// common browser supported image file extensions
|
|
19
19
|
const exts = ["jpg", "jpeg", "png", "gif", "webp", "svg", "bmp", "ico", "avif"];
|
|
20
20
|
// looks like a path?
|
|
21
|
-
const rgx = new RegExp(
|
|
21
|
+
const rgx = new RegExp(`\\.(${exts.join("|")})$`, "i");
|
|
22
22
|
if (rgx.test(mimeOrPath)) {
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
// looks like an image mime type?
|
|
26
|
-
return /^image\/[
|
|
26
|
+
return /^image\/[^/]+/i.test(`${mimeOrPath}`);
|
|
27
27
|
}
|
|
@@ -16,5 +16,8 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
export function isPlainObject(v) {
|
|
19
|
-
|
|
19
|
+
if (v === null || typeof v !== "object")
|
|
20
|
+
return false;
|
|
21
|
+
const ctor = v.constructor;
|
|
22
|
+
return ctor === undefined || ctor === Object;
|
|
20
23
|
}
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
* maybeJsonStringify(null); // null (unchanged)
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export declare function maybeJsonStringify(val:
|
|
19
|
+
export declare function maybeJsonStringify(val: unknown, prettyIndent?: number | string): string | null | number | boolean | undefined;
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
* moveArrayItem(['a', 'b', 'c'], 1, 1); // ['a', 'b', 'c'] (clone)
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export declare function moveArrayItem(array:
|
|
19
|
+
export declare function moveArrayItem<T>(array: T[], fromIndex: number, toIndex: number): T[];
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export function preloadImg(url, debug = false) {
|
|
15
|
-
|
|
15
|
+
if (debug)
|
|
16
|
+
console.debug(`preloading: ${url}`);
|
|
16
17
|
return new Promise((resolve, reject) => {
|
|
17
18
|
const img = new Image();
|
|
18
19
|
img.onload = () => resolve(img);
|
package/dist/utils/sleep.d.ts
CHANGED