@marianmeres/stuic 2.3.2 → 2.5.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.
Files changed (99) hide show
  1. package/README.md +0 -1
  2. package/dist/README.md +17 -11
  3. package/dist/actions/autogrow.svelte.js +4 -4
  4. package/dist/actions/autoscroll.d.ts +2 -2
  5. package/dist/actions/autoscroll.js +17 -8
  6. package/dist/actions/file-dropzone.svelte.d.ts +1 -1
  7. package/dist/actions/file-dropzone.svelte.js +1 -1
  8. package/dist/actions/focus-trap.js +33 -24
  9. package/dist/actions/highlight-dragover.svelte.js +6 -5
  10. package/dist/actions/index.d.ts +1 -0
  11. package/dist/actions/index.js +1 -0
  12. package/dist/actions/on-submit-validity-check.svelte.js +2 -2
  13. package/dist/actions/popover/PopoverContent.svelte +15 -0
  14. package/dist/actions/popover/PopoverContent.svelte.d.ts +7 -0
  15. package/dist/actions/popover/index.css +78 -0
  16. package/dist/actions/popover/index.d.ts +1 -0
  17. package/dist/actions/popover/index.js +1 -0
  18. package/dist/actions/popover/popover.svelte.d.ts +112 -0
  19. package/dist/actions/popover/popover.svelte.js +449 -0
  20. package/dist/actions/resizable-width.svelte.d.ts +1 -1
  21. package/dist/actions/resizable-width.svelte.js +7 -5
  22. package/dist/actions/tooltip/index.css +2 -7
  23. package/dist/actions/tooltip/tooltip.svelte.js +5 -4
  24. package/dist/actions/trim.svelte.d.ts +1 -1
  25. package/dist/actions/trim.svelte.js +2 -2
  26. package/dist/actions/validate.svelte.d.ts +4 -4
  27. package/dist/actions/validate.svelte.js +9 -9
  28. package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.d.ts +7 -6
  29. package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.js +1 -2
  30. package/dist/components/AlertConfirmPrompt/index.d.ts +1 -1
  31. package/dist/components/AlertConfirmPrompt/index.js +1 -1
  32. package/dist/components/AnimatedElipsis/index.d.ts +1 -1
  33. package/dist/components/AnimatedElipsis/index.js +1 -1
  34. package/dist/components/Button/index.d.ts +1 -1
  35. package/dist/components/Button/index.js +1 -1
  36. package/dist/components/ButtonGroupRadio/ButtonGroupRadio.svelte +4 -1
  37. package/dist/components/ButtonGroupRadio/index.d.ts +1 -1
  38. package/dist/components/ButtonGroupRadio/index.js +1 -1
  39. package/dist/components/ColorScheme/index.d.ts +2 -2
  40. package/dist/components/ColorScheme/index.js +2 -2
  41. package/dist/components/CommandMenu/CommandMenu.svelte +1 -1
  42. package/dist/components/CommandMenu/index.d.ts +1 -1
  43. package/dist/components/CommandMenu/index.js +1 -1
  44. package/dist/components/DismissibleMessage/index.d.ts +1 -1
  45. package/dist/components/DismissibleMessage/index.js +1 -1
  46. package/dist/components/HoverExpandableWidth/index.d.ts +1 -1
  47. package/dist/components/HoverExpandableWidth/index.js +1 -1
  48. package/dist/components/Input/FieldAssets.svelte +7 -3
  49. package/dist/components/Input/FieldLikeButton.svelte +1 -1
  50. package/dist/components/Input/FieldOptions.svelte +1 -1
  51. package/dist/components/Input/index.d.ts +7 -7
  52. package/dist/components/Input/index.js +7 -7
  53. package/dist/components/KbdShortcut/index.d.ts +1 -1
  54. package/dist/components/KbdShortcut/index.js +1 -1
  55. package/dist/components/ModalDialog/index.d.ts +1 -1
  56. package/dist/components/ModalDialog/index.js +1 -1
  57. package/dist/components/Notifications/index.d.ts +1 -1
  58. package/dist/components/Notifications/index.js +1 -1
  59. package/dist/components/Notifications/notifications-stack.svelte.d.ts +5 -5
  60. package/dist/components/Notifications/notifications-stack.svelte.js +8 -7
  61. package/dist/components/SlidingPanels/index.d.ts +1 -1
  62. package/dist/components/SlidingPanels/index.js +1 -1
  63. package/dist/components/Spinner/index.d.ts +1 -1
  64. package/dist/components/Spinner/index.js +1 -1
  65. package/dist/components/Switch/Switch.svelte +5 -2
  66. package/dist/components/Switch/index.d.ts +1 -1
  67. package/dist/components/Switch/index.js +1 -1
  68. package/dist/components/TypeaheadInput/index.d.ts +1 -1
  69. package/dist/components/TypeaheadInput/index.js +1 -1
  70. package/dist/utils/body-scroll-locker.js +4 -3
  71. package/dist/utils/breakpoint.svelte.js +0 -2
  72. package/dist/utils/colors.js +3 -3
  73. package/dist/utils/debounce.d.ts +1 -1
  74. package/dist/utils/debounce.js +1 -2
  75. package/dist/utils/escape-regex.js +1 -1
  76. package/dist/utils/event-emitter.d.ts +2 -3
  77. package/dist/utils/event-emitter.js +1 -2
  78. package/dist/utils/event-modifiers.d.ts +4 -4
  79. package/dist/utils/event-modifiers.js +4 -6
  80. package/dist/utils/get-file-type-label.js +1 -1
  81. package/dist/utils/is-image.js +2 -2
  82. package/dist/utils/is-nullish.d.ts +1 -1
  83. package/dist/utils/is-plain-object.d.ts +1 -1
  84. package/dist/utils/is-plain-object.js +4 -1
  85. package/dist/utils/maybe-json-parse.d.ts +1 -1
  86. package/dist/utils/maybe-json-parse.js +1 -1
  87. package/dist/utils/maybe-json-stringify.d.ts +1 -1
  88. package/dist/utils/move-array-item.d.ts +1 -1
  89. package/dist/utils/preload-img.js +2 -1
  90. package/dist/utils/sleep.d.ts +1 -1
  91. package/dist/utils/storage-abstraction.d.ts +13 -13
  92. package/dist/utils/storage-abstraction.js +2 -0
  93. package/dist/utils/svg-circle.js +2 -1
  94. package/dist/utils/switch.svelte.d.ts +1 -1
  95. package/dist/utils/switch.svelte.js +1 -1
  96. package/dist/utils/throttle.d.ts +1 -1
  97. package/dist/utils/throttle.js +7 -8
  98. package/dist/utils/to-integer.d.ts +1 -1
  99. package/package.json +6 -2
@@ -1,2 +1,2 @@
1
1
  export * from "./alert-confirm-prompt-stack.svelte.js";
2
- export { default as AlertConfirmPrompt, type Props as AlertConfirmPromptProps } from "./AlertConfirmPrompt.svelte";
2
+ export { default as AlertConfirmPrompt, type Props as AlertConfirmPromptProps, } from "./AlertConfirmPrompt.svelte";
@@ -1,2 +1,2 @@
1
1
  export * from "./alert-confirm-prompt-stack.svelte.js";
2
- export { default as AlertConfirmPrompt } from "./AlertConfirmPrompt.svelte";
2
+ export { default as AlertConfirmPrompt, } from "./AlertConfirmPrompt.svelte";
@@ -1 +1 @@
1
- export { default as AnimatedEllipsis, type Props as AnimatedEllipsisProps } from "./AnimatedEllipsis.svelte";
1
+ export { default as AnimatedEllipsis, type Props as AnimatedEllipsisProps, } from "./AnimatedEllipsis.svelte";
@@ -1 +1 @@
1
- export { default as AnimatedEllipsis } from "./AnimatedEllipsis.svelte";
1
+ export { default as AnimatedEllipsis, } from "./AnimatedEllipsis.svelte";
@@ -1 +1 @@
1
- export { default as Button, type Props as ButtonProps } from './Button.svelte';
1
+ export { default as Button, type Props as ButtonProps } from "./Button.svelte";
@@ -1 +1 @@
1
- export { default as Button } from './Button.svelte';
1
+ export { default as Button } from "./Button.svelte";
@@ -30,7 +30,10 @@
30
30
 
31
31
  <script lang="ts">
32
32
  import { ItemCollection } from "@marianmeres/item-collection";
33
- type ItemCollectionItem = { id: string; option: import("../Input/types.js").FieldRadiosOption };
33
+ type ItemCollectionItem = {
34
+ id: string;
35
+ option: import("../Input/types.js").FieldRadiosOption;
36
+ };
34
37
  import { twMerge } from "../../utils/tw-merge.js";
35
38
  import Button from "../Button/Button.svelte";
36
39
  //
@@ -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";
@@ -291,7 +291,7 @@
291
291
  "options block space-y-1 p-1",
292
292
  "overflow-y-auto overflow-x-hidden mb-1",
293
293
  "border-t border-black/20",
294
- "max-h-[240px]"
294
+ "max-h-60"
295
295
  )}
296
296
  bind:this={optionsBox}
297
297
  tabindex="-1"
@@ -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
- return notifications ? notifications.error(msg) : alert(msg);
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
- return notifications ? notifications.error(cardErrMsg) : alert(cardErrMsg);
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} value={value} use:validateAction={() => wrappedValidate} />
554
+ <input type="hidden" {name} {value} use:validateAction={() => wrappedValidate} />
551
555
 
552
556
  <Modal
553
557
  bind:this={modal}
@@ -195,7 +195,7 @@
195
195
 
196
196
  // also, by default, JSON validation is built in
197
197
  try {
198
- JSON.parse(val);
198
+ JSON.parse(val as string);
199
199
  return "";
200
200
  } catch (e) {
201
201
  return "typeMismatch";
@@ -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?: any;
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, any> {
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: any;
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: any) => void;
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 str = content?.component
14
+ const c = content;
15
+ const str = typeof c === "object" && c?.component
15
16
  ? "component"
16
- : content?.html || content?.text || content;
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
- let o = typeof n === "string" ? { id: 0, content: n } : n;
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
- let _a = a.created.valueOf();
129
- let _b = b.created.valueOf();
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 { ValidateOptions, ValidationResult } from "../../actions/validate.svelte.js";
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
- {...(rest as Record<string, unknown>)}
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 (e) { }
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];
@@ -1,6 +1,4 @@
1
- import { createClog } from "@marianmeres/clog";
2
1
  import { innerWidth } from "svelte/reactivity/window";
3
- const clog = createClog("breakpoint").debug;
4
2
  // https://tailwindcss.com/docs/responsive-design
5
3
  const _breakpoints = [
6
4
  ["sm", 640],
@@ -65,11 +65,11 @@ export function rgbToOklch(rgb) {
65
65
  * ```
66
66
  */
67
67
  export function hexToRgb(hex) {
68
- let shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
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
- let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
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
- let v = val / 255;
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 {
@@ -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: any[]) => any>(fn: T, wait: number): (...args: Parameters<T>) => void;
13
+ export declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, wait: number): (...args: Parameters<T>) => void;
@@ -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(context, args), wait);
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, '\\$&'); // $& means the whole matched string
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: any, // fuck it (we would need 3 signatures)
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?: any): void;
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, // fuck it (we would need 3 signatures)
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) => any): (e: Event) => void;
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) => any): (e: Event) => void;
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) => any): (e: Event) => void;
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) => any): (e: Event) => void;
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
- // @ts-ignore
16
- if (fn)
16
+ if (!called) {
17
+ called = true;
17
18
  fn.call(this, e);
18
- fn = null;
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
  }
@@ -84,7 +84,7 @@ export const EXTS = {
84
84
  text: EXT_TEXT,
85
85
  };
86
86
  const MAP = Object.entries(EXTS).reduce((m, [label, exts]) => {
87
- // @ts-ignore
87
+ // @ts-expect-error - label is a valid key
88
88
  exts.forEach((ext) => (m[ext] = label));
89
89
  return m;
90
90
  }, {});
@@ -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(`\.(${exts.join("|")})$`, "i");
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\/[^\/]+/i.test(`${mimeOrPath}`);
26
+ return /^image\/[^/]+/i.test(`${mimeOrPath}`);
27
27
  }
@@ -13,4 +13,4 @@
13
13
  * isNullish(false); // false
14
14
  * ```
15
15
  */
16
- export declare function isNullish(v: any): boolean;
16
+ export declare function isNullish(v: unknown): v is null | undefined;
@@ -15,4 +15,4 @@
15
15
  * isPlainObject(new Date()); // false
16
16
  * ```
17
17
  */
18
- export declare function isPlainObject(v: any): boolean;
18
+ export declare function isPlainObject(v: unknown): boolean;
@@ -16,5 +16,8 @@
16
16
  * ```
17
17
  */
18
18
  export function isPlainObject(v) {
19
- return (v !== null && typeof v === "object" && [undefined, Object].includes(v.constructor));
19
+ if (v === null || typeof v !== "object")
20
+ return false;
21
+ const ctor = v.constructor;
22
+ return ctor === undefined || ctor === Object;
20
23
  }
@@ -15,4 +15,4 @@
15
15
  * maybeJsonParse('bad', true); // throws SyntaxError
16
16
  * ```
17
17
  */
18
- export declare function maybeJsonParse(val: any, strict?: boolean): any;
18
+ export declare function maybeJsonParse(val: unknown, strict?: boolean): unknown;
@@ -18,7 +18,7 @@
18
18
  export function maybeJsonParse(val, strict = false) {
19
19
  if (typeof val === "string") {
20
20
  try {
21
- val = JSON.parse(val);
21
+ return JSON.parse(val);
22
22
  }
23
23
  catch (e) {
24
24
  if (strict)