@jonmilner/ui 0.15.0 → 0.15.1
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/Avatar/Avatar.css +1 -1
- package/dist/Badge/Badge.css +1 -1
- package/dist/Box/Box.css +1 -1
- package/dist/Button/Button.css +1 -1
- package/dist/Checkbox/Checkbox.css +1 -1
- package/dist/Chip/Chip.css +1 -1
- package/dist/Clickable/Clickable.css +1 -1
- package/dist/ColorField/ColorField.css +1 -1
- package/dist/Combobox/Combobox.css +1 -1
- package/dist/Dialog/Dialog.css +1 -1
- package/dist/Field/Field.css +1 -1
- package/dist/Heading/Heading.css +1 -1
- package/dist/Icon/Icon.css +1 -1
- package/dist/IconButton/IconButton.css +1 -1
- package/dist/Inline/Inline.css +1 -1
- package/dist/Menu/Menu.css +1 -1
- package/dist/MultiSelect/MultiSelect.css +1 -1
- package/dist/NavList/NavList.css +2 -2
- package/dist/NavList/NavList.css.mjs +2 -2
- package/dist/NavList/client.mjs +36 -0
- package/dist/NavList/index.mjs +78 -57
- package/dist/RadioGroup/RadioGroup.css +1 -1
- package/dist/SearchField/SearchField.css +1 -1
- package/dist/Select/Select.css +1 -1
- package/dist/Sidebar/Sidebar.css +1 -1
- package/dist/SidebarLayout/SidebarLayout.css +1 -1
- package/dist/Stack/Stack.css +1 -1
- package/dist/Switch/Switch.css +1 -1
- package/dist/Table/Table.css +1 -1
- package/dist/Tabs/Tabs.css +1 -1
- package/dist/Tag/Tag.css +1 -1
- package/dist/Text/Text.css +1 -1
- package/dist/TextField/TextField.css +1 -1
- package/dist/Textarea/Textarea.css +1 -1
- package/dist/Toast/Toast.css +1 -1
- package/dist/Tooltip/Tooltip.css +1 -1
- package/dist/Tooltip/base.d.mts +4 -0
- package/dist/Tooltip/base.mjs +38 -0
- package/dist/Tooltip/client.d.mts +0 -2
- package/dist/Tooltip/client.mjs +15 -77
- package/dist/Tooltip/index.d.mts +4 -8
- package/dist/Tooltip/index.mjs +12 -43
- package/dist/VisuallyHidden/VisuallyHidden.css +1 -1
- package/dist/base.css +1 -1
- package/dist/docs/NavList.md +4 -4
- package/dist/docs/Sidebar.md +1 -1
- package/dist/docs/manifest.json +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/popup/tooltip.d.mts +6 -0
- package/dist/popup/tooltip.mjs +81 -0
- package/dist/styles/atoms.css +1 -1
- package/dist/styles/custom-property.mjs +3 -0
- package/dist/styles/layers.css +1 -1
- package/dist/styles/responsive.css +1 -1
- package/dist/theme/define-theme.mjs +43 -42
- package/package.json +1 -1
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { customProperty as e } from "../styles/custom-property.mjs";
|
|
2
|
+
import { fallbackFaces as t, fallbackFamily as n, fallbackPairs as r, fontFeatures as i, fontStack as a, fontTracking as o, fontTrim as s, isFeatures as c, isTracking as l } from "../brands/font.mjs";
|
|
3
|
+
import { forcedColors as u } from "../brands/forced-colors.mjs";
|
|
4
|
+
import { presets as d } from "../brands/index.mjs";
|
|
5
|
+
import { resolveColor as f } from "../contrast/color.mjs";
|
|
6
|
+
import { colorRoles as p, fontRoles as m } from "../tokens/roles.mjs";
|
|
7
|
+
import { checkContrast as h, contrastPairs as g } from "../contrast/contrast.mjs";
|
|
8
|
+
import { checkMixes as _, contrastMixes as v } from "../contrast/mixes.mjs";
|
|
9
|
+
import { vars as y } from "../tokens/contract.mjs";
|
|
9
10
|
// src/theme/define-theme.ts
|
|
10
|
-
var
|
|
11
|
-
function S(
|
|
12
|
-
let
|
|
13
|
-
throw Error(`defineTheme("${
|
|
11
|
+
var b = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), x = (e, t) => `${e} {\n${t.map(([e, t]) => ` ${e}: ${t};\n`).join("")}}`;
|
|
12
|
+
function S(f) {
|
|
13
|
+
let h = (e) => {
|
|
14
|
+
throw Error(`defineTheme("${f.name}"): ${e}`);
|
|
14
15
|
};
|
|
15
|
-
/^[a-z][\w-]*$/i.test(
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
for (let [e, t] of Object.entries(
|
|
19
|
-
for (let [e, t] of Object.entries(
|
|
20
|
-
t.tracking !== void 0 && !
|
|
21
|
-
for (let
|
|
16
|
+
/^[a-z][\w-]*$/i.test(f.name) || h("the name must be a CSS identifier");
|
|
17
|
+
let g = p.filter((e) => typeof f.color[e] != "string");
|
|
18
|
+
g.length > 0 && h(`color is missing ${g.map((e) => `color.${e}`).join(", ")}`);
|
|
19
|
+
for (let [e, t] of Object.entries(f.color)) C.test(t) && h(`color.${e} must be a single color value`);
|
|
20
|
+
for (let [e, t] of Object.entries(f.font)) {
|
|
21
|
+
t.tracking !== void 0 && !l(t.tracking) && h(`font.${e}.tracking must be a plain CSS length such as -0.01em or 0.5px, or normal: ${t.tracking}`), t.features !== void 0 && !c(t.features) && h(`font.${e}.features must be quoted four-letter tags such as "cv11", "ss03", or normal: ${t.features}`);
|
|
22
|
+
for (let n of [t.metrics, ...r(t).flatMap(({ fallback: e }) => [e, ...Object.values(e.variants ?? {})])].flatMap((e) => [
|
|
22
23
|
e.familyName,
|
|
23
24
|
e.fullName,
|
|
24
25
|
e.postscriptName
|
|
25
|
-
]))
|
|
26
|
+
])) n !== void 0 && (C.test(n) || /["'\n]/.test(n)) && h(`font.${e} has a font name with quotes or CSS syntax: ${n}`);
|
|
26
27
|
}
|
|
27
|
-
process.env.NODE_ENV !== "production" && O(
|
|
28
|
-
let
|
|
28
|
+
process.env.NODE_ENV !== "production" && O(f, h);
|
|
29
|
+
let _ = `[data-brand="${f.name}"]`, v = Object.values(f.font), S = Object.values(d).flatMap((e) => Object.values(e.font)), T;
|
|
29
30
|
try {
|
|
30
|
-
T =
|
|
31
|
+
T = t([...S, ...v]);
|
|
31
32
|
} catch (e) {
|
|
32
|
-
return
|
|
33
|
+
return h(e.message);
|
|
33
34
|
}
|
|
34
|
-
let E = new Set(
|
|
35
|
-
for (let [
|
|
35
|
+
let E = new Set(v.flatMap(r).map(n));
|
|
36
|
+
for (let [e, n] of t(S)) E.delete(e), T.get(e).length > n.length && h(`"${e}" is declared with a weight or style base.css lacks`);
|
|
36
37
|
let D = [
|
|
37
38
|
...[...T].filter(([e]) => E.has(e)).flatMap(([e, t]) => t.map((t) => x("@font-face", [["font-family", `"${e}"`], ...Object.entries(t).map(([e, t]) => [b(e), t])]))),
|
|
38
|
-
x(
|
|
39
|
-
let
|
|
39
|
+
x(_, [...p.map((t) => [e(y.color[t]), f.color[t]]), ...m.flatMap((t) => {
|
|
40
|
+
let n = s(f.font[t].metrics);
|
|
40
41
|
return [
|
|
41
|
-
[y
|
|
42
|
-
[y
|
|
43
|
-
[y
|
|
44
|
-
[y
|
|
45
|
-
[y
|
|
42
|
+
[e(y.font[t]), a(f.font[t])],
|
|
43
|
+
[e(y.fontTrim[t].cap), n.cap],
|
|
44
|
+
[e(y.fontTrim[t].baseline), n.baseline],
|
|
45
|
+
[e(y.fontTracking[t]), o(f.font[t])],
|
|
46
|
+
[e(y.fontFeatures[t]), i(f.font[t])]
|
|
46
47
|
];
|
|
47
48
|
})]),
|
|
48
|
-
`@media (forced-colors: active) {\n${x(
|
|
49
|
+
`@media (forced-colors: active) {\n${x(_, p.map((t) => [e(y.color[t]), u[t]])).split("\n").map((e) => ` ${e}`).join("\n")}\n}`
|
|
49
50
|
].join("\n");
|
|
50
51
|
return {
|
|
51
|
-
brand:
|
|
52
|
-
href: `ui-theme-${
|
|
52
|
+
brand: f,
|
|
53
|
+
href: `ui-theme-${f.name}-${w(D)}`,
|
|
53
54
|
css: D
|
|
54
55
|
};
|
|
55
56
|
}
|
|
@@ -59,29 +60,29 @@ function w(e) {
|
|
|
59
60
|
for (let n = 0; n < e.length; n++) t = Math.imul(t ^ e.charCodeAt(n), 16777619);
|
|
60
61
|
return (t >>> 0).toString(36);
|
|
61
62
|
}
|
|
62
|
-
var T = /var\(\s*--color-([a-z-]+)\s*\)/g, E = new Map(
|
|
63
|
+
var T = /var\(\s*--color-([a-z-]+)\s*\)/g, E = new Map(p.map((e) => [b(e), e])), D = new Set(g.filter((e) => !e.over).map((e) => e.bg));
|
|
63
64
|
function O(e, t) {
|
|
64
65
|
let n = (r, i = []) => (i.includes(r) && t(`color.${r} references itself through var()`), e.color[r].replace(T, (e, t) => {
|
|
65
66
|
let a = E.get(t);
|
|
66
67
|
return a ? n(a, [...i, r]) : e;
|
|
67
|
-
})), r = Object.fromEntries(
|
|
68
|
-
for (let n of
|
|
68
|
+
})), r = Object.fromEntries(p.map((e) => [e, n(e)]));
|
|
69
|
+
for (let n of p) {
|
|
69
70
|
r[n].includes("var(") && t(`color.${n} is ${e.color[n]}: the contrast check needs literal colors, so use var() only to reference another color role`);
|
|
70
71
|
for (let i of ["light", "dark"]) {
|
|
71
72
|
let a;
|
|
72
73
|
try {
|
|
73
|
-
({alpha: a} =
|
|
74
|
+
({alpha: a} = f(r[n], i));
|
|
74
75
|
} catch (r) {
|
|
75
76
|
return t(`color.${n} is ${e.color[n]}, which the contrast check cannot resolve (${r.message}). Use hex, rgb(), oklab(), oklch(), color-mix() or light-dark(); named colors other than white, black and transparent are not supported`);
|
|
76
77
|
}
|
|
77
78
|
a < 1 && D.has(n) && t(`color.${n} is translucent in ${i} mode, but it is a background in a contrast pair and must be opaque`);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
for (let { name: e, fill: n } of
|
|
81
|
+
for (let { name: e, fill: n } of v) for (let i of ["light", "dark"]) f(n(r), i).alpha < 1 && t(`the ${e} is translucent in ${i} mode: the roles it mixes must be opaque`);
|
|
81
82
|
let i = {
|
|
82
83
|
...e,
|
|
83
84
|
color: r
|
|
84
|
-
}, a =
|
|
85
|
+
}, a = h(i), o = [...a, ..._(i).filter((e) => !a.some((t) => t.fg === e.fg && t.mode === e.mode && t.ratio === e.ratio)).map(({ mix: e, ...t }) => ({
|
|
85
86
|
...t,
|
|
86
87
|
bg: `the ${e}`
|
|
87
88
|
}))].toSorted((e, t) => e.mode === t.mode ? 0 : e.mode === "light" ? -1 : 1);
|