@marianmeres/stuic 2.1.4 → 2.1.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/dist/components/AlertConfirmPrompt/Current.svelte +5 -1
- package/dist/components/AlertConfirmPrompt/Current.svelte.d.ts +1 -0
- package/dist/components/Button/Button.svelte +15 -3
- package/dist/components/Button/Button.svelte.d.ts +3 -1
- package/dist/components/Button/index.css +1 -1
- package/dist/components/Input/FieldOptions.svelte +7 -2
- package/dist/components/Switch/Switch.svelte +1 -1
- package/dist/components/Switch/SwitchButton.svelte +1 -1
- package/dist/utils/hex-to-oklch.d.ts +1 -0
- package/dist/utils/hex-to-oklch.js +53 -0
- package/dist/utils/hex-to-rgb.d.ts +6 -0
- package/dist/utils/hex-to-rgb.js +12 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/package.json +1 -1
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
classMenuLi?: string;
|
|
32
32
|
classButton?: string;
|
|
33
33
|
classSpinnerBox?: string;
|
|
34
|
+
defaultIcons?: Partial<
|
|
35
|
+
Record<"info" | "success" | "warn" | "error" | "spinner", () => string | undefined>
|
|
36
|
+
>;
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
let {
|
|
@@ -49,6 +52,7 @@
|
|
|
49
52
|
classMenuLi,
|
|
50
53
|
classButton,
|
|
51
54
|
classSpinnerBox,
|
|
55
|
+
defaultIcons = acpDefaultIcons,
|
|
52
56
|
}: Props = $props();
|
|
53
57
|
|
|
54
58
|
let current = $derived(acp?.current!);
|
|
@@ -56,7 +60,7 @@
|
|
|
56
60
|
let iconFn = $derived.by(() => {
|
|
57
61
|
let out = current.iconFn;
|
|
58
62
|
if (current.iconFn === true) {
|
|
59
|
-
out =
|
|
63
|
+
out = defaultIcons[current.variant];
|
|
60
64
|
}
|
|
61
65
|
return out;
|
|
62
66
|
});
|
|
@@ -15,6 +15,7 @@ interface Props {
|
|
|
15
15
|
classMenuLi?: string;
|
|
16
16
|
classButton?: string;
|
|
17
17
|
classSpinnerBox?: string;
|
|
18
|
+
defaultIcons?: Partial<Record<"info" | "success" | "warn" | "error" | "spinner", () => string | undefined>>;
|
|
18
19
|
}
|
|
19
20
|
declare const Current: import("svelte").Component<Props, {}, "isPending">;
|
|
20
21
|
type Current = ReturnType<typeof Current>;
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
inline-flex items-center justify-center gap-x-2
|
|
11
11
|
px-3 py-2
|
|
12
12
|
|
|
13
|
-
hover:brightness-
|
|
14
|
-
active:brightness-
|
|
13
|
+
hover:brightness-105
|
|
14
|
+
active:brightness-95
|
|
15
15
|
disabled:hover:brightness-100
|
|
16
16
|
|
|
17
|
-
focus:brightness-
|
|
17
|
+
focus:brightness-105
|
|
18
18
|
focus:border-button-border-focus focus:dark:border-button-border-focus-dark
|
|
19
19
|
|
|
20
20
|
focus:outline-4 focus:outline-black/10 focus:dark:outline-white/20
|
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
active:shadow-none active:translate-[1px]
|
|
43
43
|
disabled:shadow-none disabled:active:shadow-none disabled:active:translate-none
|
|
44
44
|
`,
|
|
45
|
+
inverse: `
|
|
46
|
+
bg-transparent dark:bg-transparent
|
|
47
|
+
hover:bg-button-bg hover:dark:bg-button-bg-dark
|
|
48
|
+
hover:brightness-100
|
|
49
|
+
`,
|
|
45
50
|
};
|
|
46
51
|
</script>
|
|
47
52
|
|
|
@@ -58,7 +63,9 @@
|
|
|
58
63
|
size?: "sm" | "md" | "lg" | string;
|
|
59
64
|
muted?: boolean;
|
|
60
65
|
noshadow?: boolean;
|
|
66
|
+
noborder?: boolean;
|
|
61
67
|
unstyled?: boolean;
|
|
68
|
+
inverse?: boolean; // a.k.a. formerly "outlined"
|
|
62
69
|
class?: string;
|
|
63
70
|
href?: string;
|
|
64
71
|
children?: Snippet<[{ checked?: boolean }]>;
|
|
@@ -74,6 +81,8 @@
|
|
|
74
81
|
class: classProp,
|
|
75
82
|
muted,
|
|
76
83
|
noshadow,
|
|
84
|
+
noborder,
|
|
85
|
+
inverse,
|
|
77
86
|
unstyled,
|
|
78
87
|
href,
|
|
79
88
|
children,
|
|
@@ -108,12 +117,15 @@
|
|
|
108
117
|
size,
|
|
109
118
|
muted && "muted",
|
|
110
119
|
noshadow && "no-shadow",
|
|
120
|
+
noborder && "border-none",
|
|
121
|
+
inverse && "inverse",
|
|
111
122
|
// now, attach the default tw classes (unless not explicitly forbidden)
|
|
112
123
|
!unstyled && _base,
|
|
113
124
|
!unstyled && size && _preset.size[size],
|
|
114
125
|
!unstyled && variant && _preset.variant[variant],
|
|
115
126
|
!unstyled && muted && _preset.muted,
|
|
116
127
|
!unstyled && !noshadow && _preset.shadow,
|
|
128
|
+
!unstyled && inverse && _preset.inverse,
|
|
117
129
|
]
|
|
118
130
|
.filter(Boolean)
|
|
119
131
|
.join(" ")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const BUTTON_STUIC_BASE_CLASSES = "\n\t\tbg-button-bg text-button-text \n\t\tdark:bg-button-bg-dark dark:text-button-text-dark\n\t\tfont-mono text-sm text-center \n\t\tleading-none\n\t\tborder-1\n\t\tborder-button-border dark:border-button-border-dark\n\t\trounded-md\n\t\tinline-flex items-center justify-center gap-x-2\n\t\tpx-3 py-2\n\n\t\thover:brightness-
|
|
1
|
+
export declare const BUTTON_STUIC_BASE_CLASSES = "\n\t\tbg-button-bg text-button-text \n\t\tdark:bg-button-bg-dark dark:text-button-text-dark\n\t\tfont-mono text-sm text-center \n\t\tleading-none\n\t\tborder-1\n\t\tborder-button-border dark:border-button-border-dark\n\t\trounded-md\n\t\tinline-flex items-center justify-center gap-x-2\n\t\tpx-3 py-2\n\n\t\thover:brightness-105\n\t\tactive:brightness-95\n\t\tdisabled:hover:brightness-100\n\n\t\tfocus:brightness-105\n\t\tfocus:border-button-border-focus focus:dark:border-button-border-focus-dark\n\n\t\t focus:outline-4 focus:outline-black/10 focus:dark:outline-white/20\n\t\tfocus-visible:outline-4 focus-visible:outline-black/10 focus-visible:dark:outline-white/20\n\t";
|
|
2
2
|
export declare const BUTTON_STUIC_PRESET_CLASSES: any;
|
|
3
3
|
import type { Snippet } from "svelte";
|
|
4
4
|
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
@@ -8,7 +8,9 @@ interface Props extends HTMLButtonAttributes {
|
|
|
8
8
|
size?: "sm" | "md" | "lg" | string;
|
|
9
9
|
muted?: boolean;
|
|
10
10
|
noshadow?: boolean;
|
|
11
|
+
noborder?: boolean;
|
|
11
12
|
unstyled?: boolean;
|
|
13
|
+
inverse?: boolean;
|
|
12
14
|
class?: string;
|
|
13
15
|
href?: string;
|
|
14
16
|
children?: Snippet<[{
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
--color-button-text-dark: var(--color-button-text-dark, var(--color-white));
|
|
8
8
|
|
|
9
9
|
--color-button-border: var(--color-button-border, var(--color-neutral-400));
|
|
10
|
-
--color-button-border-dark: var(--color-button-border-dark, var(--color-neutral-
|
|
10
|
+
--color-button-border-dark: var(--color-button-border-dark, var(--color-neutral-600));
|
|
11
11
|
|
|
12
12
|
--color-button-border-focus: var(--color-button-border-focus, var(--color-neutral-500));
|
|
13
13
|
--color-button-border-focus-dark: var(--color-button-border-focus-dark, var(--color-neutral-500));
|
|
@@ -369,11 +369,16 @@
|
|
|
369
369
|
|
|
370
370
|
// "inner" submit
|
|
371
371
|
function try_submit(force = false) {
|
|
372
|
-
// clog("try_submit", innerValue);
|
|
372
|
+
// clog("try_submit", innerValue, _selectedColl.dump());
|
|
373
373
|
if (innerValue) {
|
|
374
374
|
let found = have_option_label_like(_optionsColl.items, innerValue);
|
|
375
|
+
// clog("found", found, allowUnknown, _selectedColl.dump());
|
|
375
376
|
if (!found && !allowUnknown) {
|
|
376
|
-
|
|
377
|
+
if (isMultiple && _selectedColl.size) {
|
|
378
|
+
// this is actually ok... (not simplifying the outer if so its easily readable)
|
|
379
|
+
} else {
|
|
380
|
+
return notifications?.error(t("select_from_list"), { ttl: 1000 });
|
|
381
|
+
}
|
|
377
382
|
}
|
|
378
383
|
|
|
379
384
|
if (!found && !_optionsColl.size) {
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
|
|
94
94
|
transition-colors duration-100
|
|
95
95
|
|
|
96
|
-
hover:brightness-
|
|
96
|
+
hover:brightness-105 active:brightness-95
|
|
97
97
|
data-[disabled=true]:!cursor-not-allowed data-[disabled=true]:!opacity-50 data-[disabled=true]:hover:brightness-100
|
|
98
98
|
|
|
99
99
|
bg-neutral-400 dark:bg-neutral-400
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
|
|
69
69
|
transition-colors duration-100
|
|
70
70
|
|
|
71
|
-
hover:brightness-
|
|
71
|
+
hover:brightness-105 active:brightness-95
|
|
72
72
|
disabled:!cursor-not-allowed disabled:!opacity-50 disabled:hover:brightness-100
|
|
73
73
|
|
|
74
74
|
bg-neutral-400 dark:bg-neutral-400
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a hex color string to OKLCH
|
|
4
|
+
* @param {string} hex - The hex color string (with or without leading #)
|
|
5
|
+
* @returns {Object} An object with l (lightness), c (chroma), and h (hue) properties
|
|
6
|
+
*/
|
|
7
|
+
function hexToOklch(hex) {
|
|
8
|
+
// Remove the hash if it exists
|
|
9
|
+
hex = hex.replace(/^#/, "");
|
|
10
|
+
// Handle both 3-digit and 6-digit formats
|
|
11
|
+
if (hex.length === 3) {
|
|
12
|
+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
13
|
+
}
|
|
14
|
+
// Parse the hex values to RGB (0-1)
|
|
15
|
+
const r = parseInt(hex.substring(0, 2), 16) / 255;
|
|
16
|
+
const g = parseInt(hex.substring(2, 4), 16) / 255;
|
|
17
|
+
const b = parseInt(hex.substring(4, 6), 16) / 255;
|
|
18
|
+
// Convert RGB to linear RGB (removing gamma correction)
|
|
19
|
+
const linearR = r <= 0.04045 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4);
|
|
20
|
+
const linearG = g <= 0.04045 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4);
|
|
21
|
+
const linearB = b <= 0.04045 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4);
|
|
22
|
+
// Convert to XYZ
|
|
23
|
+
const x = 0.4124 * linearR + 0.3576 * linearG + 0.1805 * linearB;
|
|
24
|
+
const y = 0.2126 * linearR + 0.7152 * linearG + 0.0722 * linearB;
|
|
25
|
+
const z = 0.0193 * linearR + 0.1192 * linearG + 0.9505 * linearB;
|
|
26
|
+
// Convert XYZ to LMS (cone response)
|
|
27
|
+
const l = 0.819 * x + 0.3619 * y - 0.1289 * z;
|
|
28
|
+
const m = 0.0329 * x + 0.9293 * y + 0.0361 * z;
|
|
29
|
+
const s = 0.0482 * x + 0.2645 * y + 0.6886 * z;
|
|
30
|
+
// Apply non-linearity to LMS
|
|
31
|
+
const lp = Math.cbrt(l);
|
|
32
|
+
const mp = Math.cbrt(m);
|
|
33
|
+
const sp = Math.cbrt(s);
|
|
34
|
+
// Convert to Oklab
|
|
35
|
+
const L = 0.2104 * lp + 0.7936 * mp - 0.004 * sp;
|
|
36
|
+
const a = 1.9779 * lp - 2.4285 * mp + 0.4505 * sp;
|
|
37
|
+
const bb = 0.0259 * lp + 0.7827 * mp - 0.8086 * sp;
|
|
38
|
+
// Convert Oklab to Oklch
|
|
39
|
+
const C = Math.sqrt(a * a + bb * bb);
|
|
40
|
+
let h = (Math.atan2(bb, a) * 180) / Math.PI;
|
|
41
|
+
// Ensure hue is positive
|
|
42
|
+
if (h < 0) {
|
|
43
|
+
h += 360;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
l: parseFloat(L.toFixed(4)),
|
|
47
|
+
c: parseFloat(C.toFixed(4)),
|
|
48
|
+
h: parseFloat(h.toFixed(2)),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// Example usage:
|
|
52
|
+
// const oklch = hexToOklch("#ff5733");
|
|
53
|
+
// console.log(oklch); // Example output: { l: 0.6321, c: 0.1549, h: 27.23 }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Will convert #fff or #ffffff to {r: 255, g: 255, b: 255} */
|
|
2
|
+
export function hexToRgb(hex) {
|
|
3
|
+
hex = hex.replace(/^#/, "");
|
|
4
|
+
// both 3-digit and 6-digit formats
|
|
5
|
+
if (hex.length === 3) {
|
|
6
|
+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
7
|
+
}
|
|
8
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
9
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
10
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
11
|
+
return { r, g, b };
|
|
12
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export * from "./escape-regex.js";
|
|
|
5
5
|
export * from "./event-emitter.js";
|
|
6
6
|
export * from "./event-modifiers.js";
|
|
7
7
|
export * from "./get-id.js";
|
|
8
|
+
export * from "./hex-to-oklch.js";
|
|
9
|
+
export * from "./hex-to-rgb.js";
|
|
8
10
|
export * from "./is-browser.js";
|
|
9
11
|
export * from "./is-mac.js";
|
|
10
12
|
export * from "./is-nullish.js";
|
package/dist/utils/index.js
CHANGED
|
@@ -5,6 +5,8 @@ export * from "./escape-regex.js";
|
|
|
5
5
|
export * from "./event-emitter.js";
|
|
6
6
|
export * from "./event-modifiers.js";
|
|
7
7
|
export * from "./get-id.js";
|
|
8
|
+
export * from "./hex-to-oklch.js";
|
|
9
|
+
export * from "./hex-to-rgb.js";
|
|
8
10
|
export * from "./is-browser.js";
|
|
9
11
|
export * from "./is-mac.js";
|
|
10
12
|
export * from "./is-nullish.js";
|