@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.
Files changed (56) hide show
  1. package/dist/Avatar/Avatar.css +1 -1
  2. package/dist/Badge/Badge.css +1 -1
  3. package/dist/Box/Box.css +1 -1
  4. package/dist/Button/Button.css +1 -1
  5. package/dist/Checkbox/Checkbox.css +1 -1
  6. package/dist/Chip/Chip.css +1 -1
  7. package/dist/Clickable/Clickable.css +1 -1
  8. package/dist/ColorField/ColorField.css +1 -1
  9. package/dist/Combobox/Combobox.css +1 -1
  10. package/dist/Dialog/Dialog.css +1 -1
  11. package/dist/Field/Field.css +1 -1
  12. package/dist/Heading/Heading.css +1 -1
  13. package/dist/Icon/Icon.css +1 -1
  14. package/dist/IconButton/IconButton.css +1 -1
  15. package/dist/Inline/Inline.css +1 -1
  16. package/dist/Menu/Menu.css +1 -1
  17. package/dist/MultiSelect/MultiSelect.css +1 -1
  18. package/dist/NavList/NavList.css +2 -2
  19. package/dist/NavList/NavList.css.mjs +2 -2
  20. package/dist/NavList/client.mjs +36 -0
  21. package/dist/NavList/index.mjs +78 -57
  22. package/dist/RadioGroup/RadioGroup.css +1 -1
  23. package/dist/SearchField/SearchField.css +1 -1
  24. package/dist/Select/Select.css +1 -1
  25. package/dist/Sidebar/Sidebar.css +1 -1
  26. package/dist/SidebarLayout/SidebarLayout.css +1 -1
  27. package/dist/Stack/Stack.css +1 -1
  28. package/dist/Switch/Switch.css +1 -1
  29. package/dist/Table/Table.css +1 -1
  30. package/dist/Tabs/Tabs.css +1 -1
  31. package/dist/Tag/Tag.css +1 -1
  32. package/dist/Text/Text.css +1 -1
  33. package/dist/TextField/TextField.css +1 -1
  34. package/dist/Textarea/Textarea.css +1 -1
  35. package/dist/Toast/Toast.css +1 -1
  36. package/dist/Tooltip/Tooltip.css +1 -1
  37. package/dist/Tooltip/base.d.mts +4 -0
  38. package/dist/Tooltip/base.mjs +38 -0
  39. package/dist/Tooltip/client.d.mts +0 -2
  40. package/dist/Tooltip/client.mjs +15 -77
  41. package/dist/Tooltip/index.d.mts +4 -8
  42. package/dist/Tooltip/index.mjs +12 -43
  43. package/dist/VisuallyHidden/VisuallyHidden.css +1 -1
  44. package/dist/base.css +1 -1
  45. package/dist/docs/NavList.md +4 -4
  46. package/dist/docs/Sidebar.md +1 -1
  47. package/dist/docs/manifest.json +1 -1
  48. package/dist/index.d.mts +2 -1
  49. package/dist/popup/tooltip.d.mts +6 -0
  50. package/dist/popup/tooltip.mjs +81 -0
  51. package/dist/styles/atoms.css +1 -1
  52. package/dist/styles/custom-property.mjs +3 -0
  53. package/dist/styles/layers.css +1 -1
  54. package/dist/styles/responsive.css +1 -1
  55. package/dist/theme/define-theme.mjs +43 -42
  56. package/package.json +1 -1
@@ -1,55 +1,56 @@
1
- import { fallbackFaces as e, fallbackFamily as t, fallbackPairs as n, fontFeatures as r, fontStack as i, fontTracking as a, fontTrim as o, isFeatures as s, isTracking as c } from "../brands/font.mjs";
2
- import { forcedColors as l } from "../brands/forced-colors.mjs";
3
- import { presets as u } from "../brands/index.mjs";
4
- import { resolveColor as d } from "../contrast/color.mjs";
5
- import { colorRoles as f, fontRoles as p } from "../tokens/roles.mjs";
6
- import { checkContrast as m, contrastPairs as h } from "../contrast/contrast.mjs";
7
- import { checkMixes as g, contrastMixes as _ } from "../contrast/mixes.mjs";
8
- import { vars as v } from "../tokens/contract.mjs";
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 y = (e) => e.slice(4, -1), b = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), x = (e, t) => `${e} {\n${t.map(([e, t]) => ` ${e}: ${t};\n`).join("")}}`;
11
- function S(d) {
12
- let m = (e) => {
13
- throw Error(`defineTheme("${d.name}"): ${e}`);
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(d.name) || m("the name must be a CSS identifier");
16
- let h = f.filter((e) => typeof d.color[e] != "string");
17
- h.length > 0 && m(`color is missing ${h.map((e) => `color.${e}`).join(", ")}`);
18
- for (let [e, t] of Object.entries(d.color)) C.test(t) && m(`color.${e} must be a single color value`);
19
- for (let [e, t] of Object.entries(d.font)) {
20
- t.tracking !== void 0 && !c(t.tracking) && m(`font.${e}.tracking must be a plain CSS length such as -0.01em or 0.5px, or normal: ${t.tracking}`), t.features !== void 0 && !s(t.features) && m(`font.${e}.features must be quoted four-letter tags such as "cv11", "ss03", or normal: ${t.features}`);
21
- for (let r of [t.metrics, ...n(t).flatMap(({ fallback: e }) => [e, ...Object.values(e.variants ?? {})])].flatMap((e) => [
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
- ])) r !== void 0 && (C.test(r) || /["'\n]/.test(r)) && m(`font.${e} has a font name with quotes or CSS syntax: ${r}`);
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(d, m);
28
- let g = `[data-brand="${d.name}"]`, _ = Object.values(d.font), S = Object.values(u).flatMap((e) => Object.values(e.font)), T;
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 = e([...S, ..._]);
31
+ T = t([...S, ...v]);
31
32
  } catch (e) {
32
- return m(e.message);
33
+ return h(e.message);
33
34
  }
34
- let E = new Set(_.flatMap(n).map(t));
35
- for (let [t, n] of e(S)) E.delete(t), T.get(t).length > n.length && m(`"${t}" is declared with a weight or style base.css lacks`);
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(g, [...f.map((e) => [y(v.color[e]), d.color[e]]), ...p.flatMap((e) => {
39
- let t = o(d.font[e].metrics);
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(v.font[e]), i(d.font[e])],
42
- [y(v.fontTrim[e].cap), t.cap],
43
- [y(v.fontTrim[e].baseline), t.baseline],
44
- [y(v.fontTracking[e]), a(d.font[e])],
45
- [y(v.fontFeatures[e]), r(d.font[e])]
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(g, f.map((e) => [y(v.color[e]), l[e]])).split("\n").map((e) => ` ${e}`).join("\n")}\n}`
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: d,
52
- href: `ui-theme-${d.name}-${w(D)}`,
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(f.map((e) => [b(e), e])), D = new Set(h.filter((e) => !e.over).map((e) => e.bg));
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(f.map((e) => [e, n(e)]));
68
- for (let n of f) {
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} = d(r[n], i));
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 _) for (let i of ["light", "dark"]) d(n(r), i).alpha < 1 && t(`the ${e} is translucent in ${i} mode: the roles it mixes must be opaque`);
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 = m(i), o = [...a, ...g(i).filter((e) => !a.some((t) => t.fg === e.fg && t.mode === e.mode && t.ratio === e.ratio)).map(({ mix: e, ...t }) => ({
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jonmilner/ui",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "bin": {
5
5
  "ui-doctor": "./dist/cli/ui-doctor.mjs"
6
6
  },