@marianmeres/stuic 1.37.0 → 1.39.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.
@@ -39,7 +39,7 @@ export interface AlertConfirmPromptOptions extends Record<string, any> {
39
39
  }>;
40
40
  forceAsHtml?: boolean;
41
41
  }
42
- export declare const createAlertConfirmPromptStore: () => {
42
+ export declare const createAlertConfirmPromptStore: (defaults?: Partial<AlertConfirmPromptOptions>) => {
43
43
  subscribe: (cb: import("@marianmeres/store").Subscribe<AlertConfirmPromptOptions[]>) => import("@marianmeres/store").Unsubscribe;
44
44
  get: () => AlertConfirmPromptOptions[];
45
45
  push: (o: Partial<AlertConfirmPromptOptions>) => void;
@@ -1,5 +1,6 @@
1
1
  import { createStore } from '@marianmeres/store';
2
2
  import { createClog } from '@marianmeres/clog';
3
+ import { dset as mergeDeep } from 'dset/merge';
3
4
  const clog = createClog('alert-confirm-prompt');
4
5
  // export class AlertConfirmPromptType {
5
6
  // static readonly ALERT: 'alert';
@@ -14,36 +15,42 @@ export var AlertConfirmPromptType;
14
15
  })(AlertConfirmPromptType || (AlertConfirmPromptType = {}));
15
16
  const isFn = (v) => typeof v === 'function';
16
17
  const ucf = (s) => `${s}`[0].toUpperCase() + `${s}`.slice(1);
17
- export const createAlertConfirmPromptStore = () => {
18
+ export const createAlertConfirmPromptStore = (defaults) => {
18
19
  // fifo
19
20
  const _stack = createStore([]);
20
- // defaults
21
- const labelOk = 'OK';
22
- const labelCancel = 'Cancel';
23
- // optional 3rd button label
24
- const labelCustom = undefined;
25
21
  const push = (o) => {
22
+ defaults ??= {};
23
+ o ??= {};
24
+ defaults = {
25
+ ...{
26
+ labelOk: 'OK',
27
+ labelCancel: 'Cancel',
28
+ iconFn: true,
29
+ title: ucf(o.type),
30
+ },
31
+ ...defaults,
32
+ };
26
33
  if (!isFn(o.onOk))
27
34
  o.onOk = shift;
28
35
  if (!isFn(o.onCancel))
29
36
  o.onCancel = shift;
30
37
  if (!isFn(o.onEscape))
31
38
  o.onEscape = shift;
32
- if (o.labelOk === undefined)
33
- o.labelOk = labelOk;
34
- if (o.labelCancel === undefined)
35
- o.labelCancel = labelCancel;
36
- if (o.title === undefined)
37
- o.title = ucf(o.type);
39
+ if (!isFn(o.onCustom))
40
+ o.onCustom = () => undefined;
41
+ o.labelOk ??= defaults.labelOk;
42
+ o.labelCancel ??= defaults.labelCancel;
43
+ o.title ??= defaults.title;
44
+ o.iconFn ??= defaults.iconFn;
45
+ o.forceAsHtml ??= defaults.forceAsHtml;
38
46
  // variant defaults to info
39
47
  if (!['info', 'success', 'warn', 'error'].includes(o?.variant)) {
40
48
  o.variant = 'info';
41
49
  }
42
- if (o.iconFn === undefined)
43
- o.iconFn = true; // will use default
44
- // 3rd label may stay undefined
45
- if (!isFn(o.onCustom))
46
- o.onCustom = () => undefined;
50
+ if (defaults.class) {
51
+ o.class ??= {};
52
+ o.class = { ...defaults.class, ...o.class };
53
+ }
47
54
  //
48
55
  _stack.update((old) => [...old, o]);
49
56
  };
@@ -98,7 +98,7 @@ $:
98
98
  <header
99
99
  bind:this={header}
100
100
  data-shell="header"
101
- class={twMerge(`flex-none z-10 ${headerClass}`)}
101
+ class={twMerge(`flex-none ${headerClass}`)}
102
102
  >
103
103
  <slot name="header" />
104
104
  </header>
@@ -2,9 +2,9 @@
2
2
  import { createEventDispatcher } from "svelte";
3
3
  import { get } from "svelte/store";
4
4
  import { twMerge } from "tailwind-merge";
5
+ import { DevicePointer } from "../../index.js";
5
6
  import { prefersReducedMotionStore } from "../../utils/prefers-reduced-motion.js";
6
7
  import { windowSize } from "../../utils/window-size.js";
7
- import { DevicePointer } from "../../index.js";
8
8
  const clog = createClog("HoverExpandableWidth");
9
9
  const dispatch = createEventDispatcher();
10
10
  export let enabled = DevicePointer.isFine;
@@ -15,8 +15,7 @@ export let delayIn = 400;
15
15
  export let delayOut = 100;
16
16
  let _class = "";
17
17
  export { _class as class };
18
- $:
19
- _isExpanded = false;
18
+ let _isExpanded = false;
20
19
  let _isShrinking = false;
21
20
  let _isExpanding = false;
22
21
  let el;
@@ -33,6 +32,7 @@ const _planDelayedExec = (_fn, _delay) => {
33
32
  _resetDelayTimer();
34
33
  }, _delay);
35
34
  };
35
+ let box;
36
36
  const _expand = () => {
37
37
  if (!enabled)
38
38
  return;
@@ -40,22 +40,22 @@ const _expand = () => {
40
40
  return;
41
41
  _isExpanded = true;
42
42
  _isExpanding = true;
43
- const box = el.getBoundingClientRect();
44
- const w = get(windowSize);
43
+ box = el.getBoundingClientRect();
44
+ const win = get(windowSize);
45
45
  const pos = {
46
46
  top: box.top,
47
- bottom: w.height - box.bottom,
47
+ bottom: win.height - box.bottom,
48
48
  left: box.left,
49
- right: w.width - box.right
49
+ right: win.width - box.right
50
50
  };
51
51
  el.style.boxShadow = `16px 0 24px -16px rgb(0 0 0 / ${shadowOpacity})`;
52
- el.style.zIndex = `1`;
53
52
  el.style.top = `${pos.top}px`;
54
53
  el.style.right = `${pos.right}px`;
55
54
  el.style.bottom = `${pos.bottom}px`;
56
55
  el.style.left = `${pos.left}px`;
57
56
  el.style.width = "auto";
58
57
  el.style.height = "auto";
58
+ el.style.zIndex = "1";
59
59
  setTimeout(
60
60
  () => _isExpanding = false,
61
61
  duration + 1e3 / 60 * 3
@@ -79,17 +79,18 @@ const _shrink = () => {
79
79
  return;
80
80
  _isExpanded = false;
81
81
  _isShrinking = true;
82
- el.style.position = `static`;
83
- el.style.zIndex = `auto`;
84
- el.style.top = "auto";
85
- el.style.right = "auto";
86
- el.style.bottom = "auto";
87
- el.style.left = "auto";
88
- el.style.width = "100%";
89
- el.style.height = "100%";
90
82
  el.style.boxShadow = "none";
83
+ el.style.width = `${box.width}px`;
91
84
  setTimeout(() => {
92
85
  _isShrinking = false;
86
+ el.style.position = `static`;
87
+ el.style.top = "auto";
88
+ el.style.right = "auto";
89
+ el.style.bottom = "auto";
90
+ el.style.left = "auto";
91
+ el.style.width = "100%";
92
+ el.style.height = "100%";
93
+ el.style.zIndex = "0";
93
94
  el.style.transitionProperty = "none";
94
95
  }, duration);
95
96
  };
@@ -36,7 +36,15 @@ export interface NotiticationsCreateStoreOptions {
36
36
  defaultTtl: number;
37
37
  sortOrder?: NotificationsSortOrder;
38
38
  defaultIcons?: Record<NotificationType, () => string> | boolean;
39
- forceAsHtml: boolean | undefined;
39
+ forceAsHtml?: boolean | undefined;
40
+ class?: Partial<{
41
+ box: string;
42
+ count: string;
43
+ icon: string;
44
+ content: string;
45
+ button: string;
46
+ x: string;
47
+ }>;
40
48
  logger: (...v: any) => void;
41
49
  }
42
50
  export declare const NOTIFICATION_EVENT: {
@@ -61,6 +69,14 @@ export declare const createNotificationsStore: (initial?: NotificationCreatePara
61
69
  sortOrder?: NotificationsSortOrder | undefined;
62
70
  defaultIcons?: boolean | Record<string, () => string> | undefined;
63
71
  forceAsHtml?: boolean | undefined;
72
+ class?: Partial<{
73
+ box: string;
74
+ count: string;
75
+ icon: string;
76
+ content: string;
77
+ button: string;
78
+ x: string;
79
+ }> | undefined;
64
80
  logger?: ((...v: any) => void) | undefined;
65
81
  };
66
82
  EVENT: {
@@ -68,6 +68,10 @@ export const createNotificationsStore = (initial = [], opts = {}) => {
68
68
  notif.created = new Date(notif.created || Date.now());
69
69
  notif.count ??= 1;
70
70
  notif.forceAsHtml ??= opts.forceAsHtml;
71
+ if (opts.class) {
72
+ notif.class ??= {};
73
+ notif.class = { ...opts.class, ...notif.class };
74
+ }
71
75
  //
72
76
  if (notif.ttl === undefined)
73
77
  notif.ttl = opts.defaultTtl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "1.37.0",
3
+ "version": "1.39.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package && node ./scripts/date.js",
@@ -66,7 +66,9 @@
66
66
  "@marianmeres/store": "^1.5.0",
67
67
  "@marianmeres/switch-store": "^1.3.1",
68
68
  "@marianmeres/ticker": "^1.5.0",
69
+ "dset": "^3.1.3",
69
70
  "esm-env": "^1.0.0",
71
+ "klona": "^2.0.6",
70
72
  "tailwind-merge": "^2.1.0"
71
73
  }
72
74
  }