@marianmeres/stuic 3.149.0 → 3.150.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.
@@ -24,6 +24,8 @@
24
24
  classButtonPrimary?: string;
25
25
  intentButtonCancel?: IntentColorKey;
26
26
  intentButtonCustom?: IntentColorKey;
27
+ /** Intent of the primary (OK) button. Defaults to `"primary"`, except for the
28
+ * `"warn"` variant, which defaults to `"destructive"`. */
27
29
  intentButtonPrimary?: IntentColorKey;
28
30
  classSpinnerBox?: string;
29
31
  defaultIcons?: Partial<
@@ -22,6 +22,8 @@ export interface Props {
22
22
  classButtonPrimary?: string;
23
23
  intentButtonCancel?: IntentColorKey;
24
24
  intentButtonCustom?: IntentColorKey;
25
+ /** Intent of the primary (OK) button. Defaults to `"primary"`, except for the
26
+ * `"warn"` variant, which defaults to `"destructive"`. */
25
27
  intentButtonPrimary?: IntentColorKey;
26
28
  classSpinnerBox?: string;
27
29
  defaultIcons?: Partial<Record<"info" | "success" | "warn" | "error" | "spinner", () => string | undefined>>;
@@ -39,6 +39,8 @@
39
39
  classButtonPrimary?: string;
40
40
  intentButtonCancel?: IntentColorKey;
41
41
  intentButtonCustom?: IntentColorKey;
42
+ /** Intent of the primary (OK) button. Defaults to `"primary"`, except for the
43
+ * `"warn"` variant, which defaults to `"destructive"`. */
42
44
  intentButtonPrimary?: IntentColorKey;
43
45
  classSpinnerBox?: string;
44
46
  defaultIcons?: Partial<
@@ -68,13 +70,19 @@
68
70
  classButtonPrimary,
69
71
  intentButtonCancel,
70
72
  intentButtonCustom,
71
- intentButtonPrimary = "primary",
73
+ intentButtonPrimary,
72
74
  classSpinnerBox,
73
75
  defaultIcons = acpDefaultIcons,
74
76
  }: Props = $props();
75
77
 
76
78
  let current = $derived(acp?.current!);
77
79
 
80
+ // the "warn" variant hints a destructive action, so unless explicitly configured
81
+ // otherwise, render the primary button accordingly
82
+ let _intentButtonPrimary = $derived(
83
+ intentButtonPrimary ?? (current?.variant === "warn" ? "destructive" : "primary")
84
+ );
85
+
78
86
  let iconHtml = $derived.by(() => {
79
87
  let fn = current.iconFn as any;
80
88
  if (current.iconFn === true) {
@@ -235,7 +243,7 @@
235
243
  <li class={twMerge(_classMenuLi, classMenuLi, hasCustom && classMenuLiCustom)}>
236
244
  <CmpButtonOk
237
245
  class={twMerge("ok", _classButton, classButton, classButtonPrimary)}
238
- intent={intentButtonPrimary}
246
+ intent={_intentButtonPrimary}
239
247
  disabled={isPending}
240
248
  onclick={createOnClick("ok", current.onOk)}
241
249
  bind:el={okButtonEl}
@@ -22,6 +22,8 @@ interface Props {
22
22
  classButtonPrimary?: string;
23
23
  intentButtonCancel?: IntentColorKey;
24
24
  intentButtonCustom?: IntentColorKey;
25
+ /** Intent of the primary (OK) button. Defaults to `"primary"`, except for the
26
+ * `"warn"` variant, which defaults to `"destructive"`. */
25
27
  intentButtonPrimary?: IntentColorKey;
26
28
  classSpinnerBox?: string;
27
29
  defaultIcons?: Partial<Record<"info" | "success" | "warn" | "error" | "spinner", () => string | undefined>>;
@@ -4,20 +4,23 @@ A modern, customizable replacement for native browser `alert()`, `confirm()`, an
4
4
 
5
5
  ## Props
6
6
 
7
- | Prop | Type | Default | Description |
8
- | -------------------- | ------------------------------- | ------- | ---------------------------------------- |
9
- | `acp` | `AlertConfirmPromptStack` | - | Stack instance managing the dialog queue |
10
- | `forceAsHtml` | `boolean` | `false` | Render all content as HTML |
11
- | `class` | `string` | - | CSS classes for the modal dialog |
12
- | `classWrap` | `string` | - | CSS for outer wrapper |
13
- | `classIconBox` | `string` | - | CSS for icon container |
14
- | `classTitle` | `string` | - | CSS for title text |
15
- | `classContent` | `string` | - | CSS for content area |
16
- | `classInput` | `string` | - | CSS for prompt input field |
17
- | `classButton` | `string` | - | CSS for all buttons |
18
- | `classButtonPrimary` | `string` | - | CSS for OK button |
19
- | `classButtonCancel` | `string` | - | CSS for Cancel button |
20
- | `defaultIcons` | `Record<variant, () => string>` | - | Custom icon functions per variant |
7
+ | Prop | Type | Default | Description |
8
+ | --------------------- | ------------------------------- | ------- | --------------------------------------------------------------------------------------------- |
9
+ | `acp` | `AlertConfirmPromptStack` | - | Stack instance managing the dialog queue |
10
+ | `forceAsHtml` | `boolean` | `false` | Render all content as HTML |
11
+ | `class` | `string` | - | CSS classes for the modal dialog |
12
+ | `classWrap` | `string` | - | CSS for outer wrapper |
13
+ | `classIconBox` | `string` | - | CSS for icon container |
14
+ | `classTitle` | `string` | - | CSS for title text |
15
+ | `classContent` | `string` | - | CSS for content area |
16
+ | `classInput` | `string` | - | CSS for prompt input field |
17
+ | `classButton` | `string` | - | CSS for all buttons |
18
+ | `classButtonPrimary` | `string` | - | CSS for OK button |
19
+ | `classButtonCancel` | `string` | - | CSS for Cancel button |
20
+ | `intentButtonPrimary` | `IntentColorKey` | - | Intent of the OK button; defaults to `"primary"`, or `"destructive"` for the `"warn"` variant |
21
+ | `intentButtonCancel` | `IntentColorKey` | - | Intent of the Cancel button |
22
+ | `intentButtonCustom` | `IntentColorKey` | - | Intent of the custom button |
23
+ | `defaultIcons` | `Record<variant, () => string>` | - | Custom icon functions per variant |
21
24
 
22
25
  ## AlertConfirmPromptStack API
23
26
 
@@ -39,16 +42,16 @@ A modern, customizable replacement for native browser `alert()`, `confirm()`, an
39
42
 
40
43
  ### Dialog Options
41
44
 
42
- | Option | Type | Description |
43
- | ------------- | ------------------------------------------ | --------------------------- |
44
- | `title` | `THC` | Dialog title |
45
- | `content` | `THC` | Dialog message/content |
46
- | `variant` | `"info" \| "success" \| "warn" \| "error"` | Visual style |
47
- | `value` | `any` | Initial value for prompt |
48
- | `labelOk` | `THC` | Custom OK button label |
49
- | `labelCancel` | `THC` | Custom Cancel button label |
50
- | `labelCustom` | `THC` | Optional third button label |
51
- | `onCustom` | `(value) => void` | Custom button callback |
45
+ | Option | Type | Description |
46
+ | ------------- | ------------------------------------------ | ------------------------------------------------------------------- |
47
+ | `title` | `THC` | Dialog title |
48
+ | `content` | `THC` | Dialog message/content |
49
+ | `variant` | `"info" \| "success" \| "warn" \| "error"` | Visual style (`"warn"` also renders the OK button as `destructive`) |
50
+ | `value` | `any` | Initial value for prompt |
51
+ | `labelOk` | `THC` | Custom OK button label |
52
+ | `labelCancel` | `THC` | Custom Cancel button label |
53
+ | `labelCustom` | `THC` | Optional third button label |
54
+ | `onCustom` | `(value) => void` | Custom button callback |
52
55
 
53
56
  ## Usage
54
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "3.149.0",
3
+ "version": "3.150.0",
4
4
  "packageManager": "pnpm@11.5.0",
5
5
  "scripts": {
6
6
  "dev": "vite dev",