@siiway/ui-core 0.0.0 → 0.1.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.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +14 -1
  3. package/dist/boot.d.ts +17 -0
  4. package/dist/boot.d.ts.map +1 -0
  5. package/dist/boot.js +29 -0
  6. package/dist/boot.js.map +1 -0
  7. package/dist/duration.d.ts +27 -0
  8. package/dist/duration.d.ts.map +1 -0
  9. package/dist/duration.js +87 -0
  10. package/dist/duration.js.map +1 -0
  11. package/dist/i18n/en.d.ts +3 -0
  12. package/dist/i18n/en.d.ts.map +1 -0
  13. package/dist/i18n/en.js +53 -0
  14. package/dist/i18n/en.js.map +1 -0
  15. package/dist/i18n/index.d.ts +11 -0
  16. package/dist/i18n/index.d.ts.map +1 -0
  17. package/dist/i18n/index.js +16 -0
  18. package/dist/i18n/index.js.map +1 -0
  19. package/dist/i18n/types.d.ts +66 -0
  20. package/dist/i18n/types.d.ts.map +1 -0
  21. package/dist/i18n/types.js +2 -0
  22. package/dist/i18n/types.js.map +1 -0
  23. package/dist/i18n/zh.d.ts +3 -0
  24. package/dist/i18n/zh.d.ts.map +1 -0
  25. package/dist/i18n/zh.js +53 -0
  26. package/dist/i18n/zh.js.map +1 -0
  27. package/dist/index.d.ts +12 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +12 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/scheme.d.ts +11 -0
  32. package/dist/scheme.d.ts.map +1 -0
  33. package/dist/scheme.js +13 -0
  34. package/dist/scheme.js.map +1 -0
  35. package/dist/theme/brand.d.ts +17 -0
  36. package/dist/theme/brand.d.ts.map +1 -0
  37. package/dist/theme/brand.js +25 -0
  38. package/dist/theme/brand.js.map +1 -0
  39. package/dist/theme/color.d.ts +26 -0
  40. package/dist/theme/color.d.ts.map +1 -0
  41. package/dist/theme/color.js +148 -0
  42. package/dist/theme/color.js.map +1 -0
  43. package/dist/theme/overrides.d.ts +12 -0
  44. package/dist/theme/overrides.d.ts.map +1 -0
  45. package/dist/theme/overrides.js +12 -0
  46. package/dist/theme/overrides.js.map +1 -0
  47. package/dist/tokens/canvas.d.ts +8 -0
  48. package/dist/tokens/canvas.d.ts.map +1 -0
  49. package/dist/tokens/canvas.js +7 -0
  50. package/dist/tokens/canvas.js.map +1 -0
  51. package/dist/tokens/neutral.d.ts +55 -0
  52. package/dist/tokens/neutral.d.ts.map +1 -0
  53. package/dist/tokens/neutral.js +110 -0
  54. package/dist/tokens/neutral.js.map +1 -0
  55. package/dist/tokens/radii.d.ts +8 -0
  56. package/dist/tokens/radii.d.ts.map +1 -0
  57. package/dist/tokens/radii.js +8 -0
  58. package/dist/tokens/radii.js.map +1 -0
  59. package/dist/tokens/shadows.d.ts +14 -0
  60. package/dist/tokens/shadows.d.ts.map +1 -0
  61. package/dist/tokens/shadows.js +21 -0
  62. package/dist/tokens/shadows.js.map +1 -0
  63. package/package.json +25 -2
  64. package/src/boot.ts +40 -0
  65. package/src/duration.ts +119 -0
  66. package/src/i18n/en.ts +63 -0
  67. package/src/i18n/index.ts +24 -0
  68. package/src/i18n/types.ts +76 -0
  69. package/src/i18n/zh.ts +62 -0
  70. package/src/index.ts +42 -0
  71. package/src/scheme.ts +19 -0
  72. package/src/theme/brand.ts +32 -0
  73. package/src/theme/color.ts +147 -0
  74. package/src/theme/overrides.ts +15 -0
  75. package/src/tokens/canvas.ts +8 -0
  76. package/src/tokens/neutral.ts +116 -0
  77. package/src/tokens/radii.ts +7 -0
  78. package/src/tokens/shadows.ts +27 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SiiWay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,16 @@
1
1
  # @siiway/ui-core
2
2
 
3
- A placeholder. The first release is 0.1.0: see https://github.com/siiway/ui.
3
+ SiiWay's design tokens, theme maths and UI strings, for any framework. No
4
+ dependencies.
5
+
6
+ - Neutral greys, radii and shadows as Fluent token names (`NEUTRAL`, `RADII`,
7
+ `SHADOWS`, `themeOverrides(scheme)`), and the page canvas (`CANVAS`).
8
+ - The 16-shade brand ramp around an accent, with the accent at shade 80
9
+ (`brandRamp(accent)`).
10
+ - The library's own strings in English and Chinese (`pickStrings(locale)`).
11
+
12
+ For React, use [`@siiway/ui-react`](https://www.npmjs.com/package/@siiway/ui-react),
13
+ which builds on this package. Documentation:
14
+ https://ui.siiway.org
15
+
16
+ MIT licensed.
package/dist/boot.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { type ThemeMode } from "./scheme.js";
2
+ export interface SchemeBootOptions {
3
+ /** The `localStorage` key the choice is kept under; the same as `useThemeMode`'s. */
4
+ storageKey?: string;
5
+ /** When nothing valid is stored. Defaults to `system`. */
6
+ defaultMode?: ThemeMode;
7
+ }
8
+ /**
9
+ * JavaScript for an inline `<script>` at the top of the page's `<head>`. Before
10
+ * anything renders, it reads the stored choice, resolves `system` with the
11
+ * OS setting, and draws `<html>` in that scheme: `data-scheme`,
12
+ * `color-scheme` and the canvas background. Without it, a dark page is white
13
+ * until the app's JavaScript runs. `<UiProvider page>` keeps `<html>` the
14
+ * same way afterwards.
15
+ */
16
+ export declare function schemeBootScript({ storageKey, defaultMode, }?: SchemeBootOptions): string;
17
+ //# sourceMappingURL=boot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAGhE,MAAM,WAAW,iBAAiB;IAChC,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB;AAOD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,UAA8B,EAC9B,WAAsB,GACvB,GAAE,iBAAsB,GAAG,MAAM,CAajC"}
package/dist/boot.js ADDED
@@ -0,0 +1,29 @@
1
+ import { THEME_STORAGE_KEY } from "./scheme.js";
2
+ import { CANVAS } from "./tokens/canvas.js";
3
+ // A value as a JavaScript literal that is safe inside an inline <script>.
4
+ function literal(value) {
5
+ return JSON.stringify(value).replace(/</g, "\\u003c");
6
+ }
7
+ /**
8
+ * JavaScript for an inline `<script>` at the top of the page's `<head>`. Before
9
+ * anything renders, it reads the stored choice, resolves `system` with the
10
+ * OS setting, and draws `<html>` in that scheme: `data-scheme`,
11
+ * `color-scheme` and the canvas background. Without it, a dark page is white
12
+ * until the app's JavaScript runs. `<UiProvider page>` keeps `<html>` the
13
+ * same way afterwards.
14
+ */
15
+ export function schemeBootScript({ storageKey = THEME_STORAGE_KEY, defaultMode = "system", } = {}) {
16
+ return [
17
+ "(function(){",
18
+ "var m;",
19
+ `try{m=localStorage.getItem(${literal(storageKey)})}catch(e){}`,
20
+ `if(m!=="system"&&m!=="light"&&m!=="dark")m=${literal(defaultMode)};`,
21
+ 'var s=m!=="system"?m:matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";',
22
+ "var r=document.documentElement;",
23
+ 'r.setAttribute("data-scheme",s);',
24
+ "r.style.colorScheme=s;",
25
+ `r.style.backgroundColor=s==="dark"?${literal(CANVAS.dark)}:${literal(CANVAS.light)};`,
26
+ "})();",
27
+ ].join("");
28
+ }
29
+ //# sourceMappingURL=boot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boot.js","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAS5C,0EAA0E;AAC1E,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,UAAU,GAAG,iBAAiB,EAC9B,WAAW,GAAG,QAAQ,MACD,EAAE;IACvB,OAAO;QACL,cAAc;QACd,QAAQ;QACR,8BAA8B,OAAO,CAAC,UAAU,CAAC,cAAc;QAC/D,8CAA8C,OAAO,CAAC,WAAW,CAAC,GAAG;QACrE,yFAAyF;QACzF,iCAAiC;QACjC,kCAAkC;QAClC,wBAAwB;QACxB,sCAAsC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG;QACtF,OAAO;KACR,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACb,CAAC"}
@@ -0,0 +1,27 @@
1
+ export type DurationUnit = "minutes" | "days";
2
+ /** The units a duration can be typed in. A month is 30 days, a year 365. */
3
+ export type DurationUnitKey = "s" | "m" | "h" | "d" | "w" | "mo" | "y";
4
+ /** One language's words for each unit, matched ignoring case. */
5
+ export type DurationUnitWords = Record<DurationUnitKey, readonly string[]>;
6
+ /**
7
+ * Parse a duration string. Returns the integer count in the field's
8
+ * `defaultUnit`, or `null` for an empty string ("use the site default"),
9
+ * or a `string` error code for an unparseable input.
10
+ */
11
+ export type ParseResult = {
12
+ kind: "ok";
13
+ value: number;
14
+ } | {
15
+ kind: "blank";
16
+ } | {
17
+ kind: "error";
18
+ reason: "format" | "non_positive" | "unknown_unit";
19
+ };
20
+ /** Reads `input` with the unit words of `units`, one language or several. */
21
+ export declare function parseDuration(input: string, defaultUnit: DurationUnit, units?: DurationUnitWords | readonly DurationUnitWords[]): ParseResult;
22
+ /**
23
+ * Format an integer count with its unit, in English. The duration field
24
+ * shows the app's language instead (`UiStrings.duration`).
25
+ */
26
+ export declare function formatDuration(value: number, defaultUnit: DurationUnit): string;
27
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../src/duration.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;AAE9C,4EAA4E;AAC5E,MAAM,MAAM,eAAe,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC;AAEvE,iEAAiE;AACjE,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,QAAQ,GAAG,cAAc,GAAG,cAAc,CAAA;CAAE,CAAC;AAgB1E,6EAA6E;AAC7E,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,YAAY,EACzB,KAAK,GAAE,iBAAiB,GAAG,SAAS,iBAAiB,EAAqB,GACzE,WAAW,CAiEb;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,GAAG,MAAM,CAE/E"}
@@ -0,0 +1,87 @@
1
+ // Parse durations people type, like "60min", "1 hour", "30 days", into whole
2
+ // minutes or days, depending on the field's storage unit. A bare number is in
3
+ // the field's unit. The unit words come from the library's strings
4
+ // (`UiStrings.durationUnits`), so each language reads its own; English by
5
+ // default.
6
+ import { en } from "./i18n/en.js";
7
+ function unitFor(word, units) {
8
+ const tables = "s" in units ? [units] : units;
9
+ for (const table of tables) {
10
+ for (const key of Object.keys(table)) {
11
+ if (table[key].some((name) => name.toLowerCase() === word))
12
+ return key;
13
+ }
14
+ }
15
+ return null;
16
+ }
17
+ /** Reads `input` with the unit words of `units`, one language or several. */
18
+ export function parseDuration(input, defaultUnit, units = en.durationUnits) {
19
+ const trimmed = input.trim();
20
+ if (!trimmed)
21
+ return { kind: "blank" };
22
+ // Strict: a number, optional whitespace, optional unit word (letters, in
23
+ // any script). Reject anything else (commas, multiple numbers, units
24
+ // without a number, etc.).
25
+ const match = trimmed.match(/^(\d+(?:\.\d+)?)\s*(\p{L}*)$/u);
26
+ if (!match)
27
+ return { kind: "error", reason: "format" };
28
+ const num = parseFloat(match[1]);
29
+ if (!Number.isFinite(num) || num <= 0) {
30
+ return { kind: "error", reason: "non_positive" };
31
+ }
32
+ const unitRaw = (match[2] ?? "").toLowerCase();
33
+ const canonical = unitRaw === "" ? null : unitFor(unitRaw, units);
34
+ if (unitRaw !== "" && !canonical) {
35
+ return { kind: "error", reason: "unknown_unit" };
36
+ }
37
+ // Convert to minutes first, then down to the field's unit.
38
+ let totalMinutes;
39
+ switch (canonical) {
40
+ case "s":
41
+ totalMinutes = num / 60;
42
+ break;
43
+ case "m":
44
+ totalMinutes = num;
45
+ break;
46
+ case "h":
47
+ totalMinutes = num * 60;
48
+ break;
49
+ case "d":
50
+ totalMinutes = num * 60 * 24;
51
+ break;
52
+ case "w":
53
+ totalMinutes = num * 60 * 24 * 7;
54
+ break;
55
+ case "mo":
56
+ totalMinutes = num * 60 * 24 * 30;
57
+ break;
58
+ case "y":
59
+ totalMinutes = num * 60 * 24 * 365;
60
+ break;
61
+ case null:
62
+ // No unit — interpret in the field's default unit.
63
+ totalMinutes = defaultUnit === "minutes" ? num : num * 60 * 24;
64
+ break;
65
+ default: {
66
+ // Exhaustiveness check.
67
+ const _exhaustive = canonical;
68
+ void _exhaustive;
69
+ totalMinutes = num;
70
+ }
71
+ }
72
+ const value = defaultUnit === "minutes" ? Math.round(totalMinutes) : Math.round(totalMinutes / (60 * 24));
73
+ // Round-down for very small inputs (e.g. "30s" in a days-unit field) but
74
+ // never let a positive duration round to 0 — that would mint zero-TTL
75
+ // tokens. Clamp to 1 of the field's unit.
76
+ if (value < 1)
77
+ return { kind: "ok", value: 1 };
78
+ return { kind: "ok", value };
79
+ }
80
+ /**
81
+ * Format an integer count with its unit, in English. The duration field
82
+ * shows the app's language instead (`UiStrings.duration`).
83
+ */
84
+ export function formatDuration(value, defaultUnit) {
85
+ return en.duration(value, defaultUnit);
86
+ }
87
+ //# sourceMappingURL=duration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.js","sourceRoot":"","sources":["../src/duration.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,mEAAmE;AACnE,0EAA0E;AAC1E,WAAW;AAEX,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAoBlC,SAAS,OAAO,CACd,IAAY,EACZ,KAAuD;IAEvD,MAAM,MAAM,GACV,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,KAA0B,CAAC,CAAC,CAAC,CAAE,KAAsC,CAAC;IACxF,KAAK,MAA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GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IAE9F,yEAAyE;IACzE,sEAAsE;IACtE,0CAA0C;IAC1C,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC/C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC/B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,WAAyB;IACrE,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { UiStrings } from "./types.js";
2
+ export declare const en: UiStrings;
3
+ //# sourceMappingURL=en.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,EAAE,EAAE,SA4DhB,CAAC"}
@@ -0,0 +1,53 @@
1
+ export const en = {
2
+ cancel: "Cancel",
3
+ clear: "Clear",
4
+ close: "Close",
5
+ required: "Required",
6
+ copy: "Copy",
7
+ copied: "Copied!",
8
+ copyFailed: "Copy failed",
9
+ saveChanges: "Save changes",
10
+ discardChanges: "Discard changes",
11
+ showPassword: "Show password",
12
+ hidePassword: "Hide password",
13
+ previous: "Previous",
14
+ next: "Next",
15
+ pageOf: (page, total) => `${page} / ${total}`,
16
+ totalItems: (count) => (count === 1 ? `${count} item` : `${count} items`),
17
+ pageNumber: "Page",
18
+ goToPage: "Go to page",
19
+ go: "Go",
20
+ pickColor: "Pick a color",
21
+ hexColor: "Hex color",
22
+ optionalHexColor: "Optional hex color",
23
+ invalidHexColor: "Enter a three- or six-digit hex color.",
24
+ colorArea: "Color saturation and brightness",
25
+ saturation: "Saturation",
26
+ brightness: "Brightness",
27
+ hue: "Hue",
28
+ theme: "Theme",
29
+ themeSystem: "System",
30
+ themeLight: "Light",
31
+ themeDark: "Dark",
32
+ search: "Search",
33
+ commandMove: "to move",
34
+ commandOpen: "to open",
35
+ commandClose: "to close",
36
+ onThisPage: "On this page",
37
+ openNavigation: "Open navigation",
38
+ primaryNavigation: "Primary",
39
+ duration: (value, unit) => unit === "minutes" ? `${value} min` : value === 1 ? "1 day" : `${value} days`,
40
+ durationUnits: {
41
+ s: ["s", "sec", "secs", "second", "seconds"],
42
+ m: ["m", "min", "mins", "minute", "minutes"],
43
+ h: ["h", "hr", "hrs", "hour", "hours"],
44
+ d: ["d", "day", "days"],
45
+ w: ["w", "wk", "wks", "week", "weeks"],
46
+ mo: ["mo", "mon", "month", "months"],
47
+ y: ["y", "yr", "yrs", "year", "years"],
48
+ },
49
+ durationInvalid: "Invalid format: try “60” or “1 hour”",
50
+ durationNotPositive: "Must be a positive duration",
51
+ durationUnknownUnit: "Unknown time unit",
52
+ };
53
+ //# sourceMappingURL=en.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en.js","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,EAAE,GAAc;IAC3B,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IAEpB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,SAAS;IACjB,UAAU,EAAE,aAAa;IAEzB,WAAW,EAAE,cAAc;IAC3B,cAAc,EAAE,iBAAiB;IAEjC,YAAY,EAAE,eAAe;IAC7B,YAAY,EAAE,eAAe;IAE7B,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,MAAM,KAAK,EAAE;IAC7C,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAA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G,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;QACtC,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;QACpC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;KACvC;IACD,eAAe,EAAE,sCAAsC;IACvD,mBAAmB,EAAE,6BAA6B;IAClD,mBAAmB,EAAE,mBAAmB;CACzC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { UiLocale, UiStrings } from "./types.js";
2
+ export type { UiLocale, UiStrings } from "./types.js";
3
+ export declare const UI_STRINGS: Record<UiLocale, UiStrings>;
4
+ /**
5
+ * The library locale for a BCP-47 tag: any `zh` tag (`zh`, `zh-CN`,
6
+ * `zh-Hans-CN`) is `zh`, everything else is `en`.
7
+ */
8
+ export declare function uiLocale(locale: string | null | undefined): UiLocale;
9
+ /** The strings for a BCP-47 tag, with any of them replaced by `overrides`. */
10
+ export declare function pickStrings(locale: string | null | undefined, overrides?: Partial<UiStrings>): UiStrings;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGtD,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEtD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAc,CAAC;AAElE;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,CAEpE;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAC7B,SAAS,CAGX"}
@@ -0,0 +1,16 @@
1
+ import { en } from "./en.js";
2
+ import { zh } from "./zh.js";
3
+ export const UI_STRINGS = { en, zh };
4
+ /**
5
+ * The library locale for a BCP-47 tag: any `zh` tag (`zh`, `zh-CN`,
6
+ * `zh-Hans-CN`) is `zh`, everything else is `en`.
7
+ */
8
+ export function uiLocale(locale) {
9
+ return locale?.trim().toLowerCase().split(/[-_]/)[0] === "zh" ? "zh" : "en";
10
+ }
11
+ /** The strings for a BCP-47 tag, with any of them replaced by `overrides`. */
12
+ export function pickStrings(locale, overrides) {
13
+ const base = UI_STRINGS[uiLocale(locale)];
14
+ return overrides ? { ...base, ...overrides } : base;
15
+ }
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAI7B,MAAM,CAAC,MAAM,UAAU,GAAgC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;AAElE;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAiC;IACxD,OAAO,MAAM,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9E,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,WAAW,CACzB,MAAiC,EACjC,SAA8B;IAE9B,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACtD,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The text the library's own components show: button labels, feedback,
3
+ * `aria-label`s and placeholders. Everything else comes in as props, already
4
+ * translated by the app. Each locale satisfies this type, so a key missing
5
+ * from one fails the typecheck.
6
+ */
7
+ import type { DurationUnit, DurationUnitWords } from "../duration.js";
8
+ export interface UiStrings {
9
+ cancel: string;
10
+ clear: string;
11
+ close: string;
12
+ required: string;
13
+ copy: string;
14
+ copied: string;
15
+ copyFailed: string;
16
+ saveChanges: string;
17
+ discardChanges: string;
18
+ showPassword: string;
19
+ hidePassword: string;
20
+ previous: string;
21
+ next: string;
22
+ /** Pagination position, e.g. "2 / 7". */
23
+ pageOf: (page: number, total: number) => string;
24
+ totalItems: (count: number) => string;
25
+ /** Placeholder of the go-to-page field. */
26
+ pageNumber: string;
27
+ goToPage: string;
28
+ go: string;
29
+ pickColor: string;
30
+ hexColor: string;
31
+ optionalHexColor: string;
32
+ invalidHexColor: string;
33
+ colorArea: string;
34
+ saturation: string;
35
+ brightness: string;
36
+ hue: string;
37
+ /** Label of the theme switch. */
38
+ theme: string;
39
+ themeSystem: string;
40
+ themeLight: string;
41
+ themeDark: string;
42
+ /** The search button's label and the command palette's field name. */
43
+ search: string;
44
+ /** The command palette's key hints, each after its key: "↑ ↓ to move". */
45
+ commandMove: string;
46
+ commandOpen: string;
47
+ commandClose: string;
48
+ /** The outline's heading. */
49
+ onThisPage: string;
50
+ /** The top bar's menu button, which opens the navigation on a narrow screen. */
51
+ openNavigation: string;
52
+ /** Names the top bar's links for screen readers. */
53
+ primaryNavigation: string;
54
+ /** A duration as the duration field shows it, e.g. "30 days". It must read
55
+ * back with `parseDuration`. */
56
+ duration: (value: number, unit: DurationUnit) => string;
57
+ /** This language's words for each unit, which the duration field reads. */
58
+ durationUnits: DurationUnitWords;
59
+ /** The duration field's errors. */
60
+ durationInvalid: string;
61
+ durationNotPositive: string;
62
+ durationUnknownUnit: string;
63
+ }
64
+ /** Locales the library ships strings for. */
65
+ export type UiLocale = "en" | "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CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAElB,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IAErB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,iBAAiB,EAAE,MAAM,CAAC;IAE1B;qCACiC;IACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,KAAK,MAAM,CAAC;IACxD,2EAA2E;IAC3E,aAAa,EAAE,iBAAiB,CAAC;IACjC,mCAAmC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,6CAA6C;AAC7C,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { UiStrings } from "./types.js";
2
+ export declare const zh: UiStrings;
3
+ //# sourceMappingURL=zh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zh.d.ts","sourceRoot":"","sources":["../../src/i18n/zh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,EAAE,EAAE,SA2DhB,CAAC"}
@@ -0,0 +1,53 @@
1
+ export const zh = {
2
+ cancel: "取消",
3
+ clear: "清除",
4
+ close: "关闭",
5
+ required: "必填",
6
+ copy: "复制",
7
+ copied: "已复制!",
8
+ copyFailed: "复制失败",
9
+ saveChanges: "保存更改",
10
+ discardChanges: "放弃更改",
11
+ showPassword: "显示密码",
12
+ hidePassword: "隐藏密码",
13
+ previous: "上一页",
14
+ next: "下一页",
15
+ pageOf: (page, total) => `${page} / ${total}`,
16
+ totalItems: (count) => `共 ${count} 项`,
17
+ pageNumber: "页数",
18
+ goToPage: "跳转到页",
19
+ go: "跳转",
20
+ pickColor: "选择颜色",
21
+ hexColor: "十六进制颜色",
22
+ optionalHexColor: "可选的十六进制颜色",
23
+ invalidHexColor: "请输入三位或六位十六进制色值。",
24
+ colorArea: "颜色饱和度和亮度",
25
+ saturation: "饱和度",
26
+ brightness: "亮度",
27
+ hue: "色相",
28
+ theme: "主题",
29
+ themeSystem: "跟随系统",
30
+ themeLight: "浅色",
31
+ themeDark: "深色",
32
+ search: "搜索",
33
+ commandMove: "移动",
34
+ commandOpen: "打开",
35
+ commandClose: "关闭",
36
+ onThisPage: "目录",
37
+ openNavigation: "打开导航",
38
+ primaryNavigation: "主导航",
39
+ duration: (value, unit) => (unit === "minutes" ? `${value} 分钟` : `${value} 天`),
40
+ durationUnits: {
41
+ s: ["秒", "秒钟"],
42
+ m: ["分", "分钟"],
43
+ h: ["时", "小时", "个小时"],
44
+ d: ["天", "日"],
45
+ w: ["周", "星期", "个星期"],
46
+ mo: ["月", "个月"],
47
+ y: ["年"],
48
+ },
49
+ durationInvalid: "格式无效,试试“60”或“1 小时”",
50
+ durationNotPositive: "时长必须大于零",
51
+ durationUnknownUnit: "无法识别的时间单位",
52
+ };
53
+ //# sourceMappingURL=zh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zh.js","sourceRoot":"","sources":["../../src/i18n/zh.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,EAAE,GAAc;IAC3B,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,IAAI;IAEd,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,MAAM;I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E,GAAG,CAAC;QACb,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC;QACrB,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC;QACf,CAAC,EAAE,CAAC,GAAG,CAAC;KACT;IACD,eAAe,EAAE,oBAAoB;IACrC,mBAAmB,EAAE,SAAS;IAC9B,mBAAmB,EAAE,WAAW;CACjC,CAAC"}
@@ -0,0 +1,12 @@
1
+ export { THEME_STORAGE_KEY, isThemeMode, resolveScheme, type Scheme, type ThemeMode, } from "./scheme.js";
2
+ export { schemeBootScript, type SchemeBootOptions } from "./boot.js";
3
+ export { NEUTRAL, type NeutralTokens } from "./tokens/neutral.js";
4
+ export { RADII } from "./tokens/radii.js";
5
+ export { SHADOWS, type ShadowTokens } from "./tokens/shadows.js";
6
+ export { CANVAS } from "./tokens/canvas.js";
7
+ export { normalizeHexColor, normalizeAccent, hexToHsl, hslToHex, hexToHsv, hsvToHex, type HsvColor, } from "./theme/color.js";
8
+ export { DEFAULT_ACCENT, BRAND_SHADES, brandRamp, type BrandShade, type BrandRamp, } from "./theme/brand.js";
9
+ export { themeOverrides, type ThemeOverrides } from "./theme/overrides.js";
10
+ export { UI_STRINGS, uiLocale, pickStrings, type UiLocale, type UiStrings } from "./i18n/index.js";
11
+ export { parseDuration, formatDuration, type DurationUnit, type DurationUnitKey, type DurationUnitWords, type ParseResult, } from "./duration.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,KAAK,MAAM,EACX,KAAK,SAAS,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,QAAQ,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EACd,YAAY,EACZ,SAAS,EACT,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEnG,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ export { THEME_STORAGE_KEY, isThemeMode, resolveScheme, } from "./scheme.js";
2
+ export { schemeBootScript } from "./boot.js";
3
+ export { NEUTRAL } from "./tokens/neutral.js";
4
+ export { RADII } from "./tokens/radii.js";
5
+ export { SHADOWS } from "./tokens/shadows.js";
6
+ export { CANVAS } from "./tokens/canvas.js";
7
+ export { normalizeHexColor, normalizeAccent, hexToHsl, hslToHex, hexToHsv, hsvToHex, } from "./theme/color.js";
8
+ export { DEFAULT_ACCENT, BRAND_SHADES, brandRamp, } from "./theme/brand.js";
9
+ export { themeOverrides } from "./theme/overrides.js";
10
+ export { UI_STRINGS, uiLocale, pickStrings } from "./i18n/index.js";
11
+ export { parseDuration, formatDuration, } from "./duration.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,aAAa,GAGd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAA0B,MAAM,WAAW,CAAC;AAErE,OAAO,EAAE,OAAO,EAAsB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAqB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,GAET,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EACd,YAAY,EACZ,SAAS,GAGV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAiC,MAAM,iBAAiB,CAAC;AAEnG,OAAO,EACL,aAAa,EACb,cAAc,GAKf,MAAM,eAAe,CAAC"}
@@ -0,0 +1,11 @@
1
+ /** A resolved colour scheme: what the page is drawn in right now. */
2
+ export type Scheme = "light" | "dark";
3
+ /** A person's colour-scheme choice: a fixed scheme, or follow the OS. */
4
+ export type ThemeMode = "system" | Scheme;
5
+ /** Where the choice is kept by default (`localStorage`), by `useThemeMode` and `schemeBootScript`. */
6
+ export declare const THEME_STORAGE_KEY = "siiway-theme";
7
+ /** Whether a value, such as one read back from storage, is a ThemeMode. */
8
+ export declare function isThemeMode(value: unknown): value is ThemeMode;
9
+ /** The scheme a mode draws in: `system` follows the OS. */
10
+ export declare function resolveScheme(mode: ThemeMode, systemDark: boolean): Scheme;
11
+ //# sourceMappingURL=scheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheme.d.ts","sourceRoot":"","sources":["../src/scheme.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAEtC,yEAAyE;AACzE,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE1C,sGAAsG;AACtG,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,2DAA2D;AAC3D,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,CAG1E"}
package/dist/scheme.js ADDED
@@ -0,0 +1,13 @@
1
+ /** Where the choice is kept by default (`localStorage`), by `useThemeMode` and `schemeBootScript`. */
2
+ export const THEME_STORAGE_KEY = "siiway-theme";
3
+ /** Whether a value, such as one read back from storage, is a ThemeMode. */
4
+ export function isThemeMode(value) {
5
+ return value === "system" || value === "light" || value === "dark";
6
+ }
7
+ /** The scheme a mode draws in: `system` follows the OS. */
8
+ export function resolveScheme(mode, systemDark) {
9
+ if (mode !== "system")
10
+ return mode;
11
+ return systemDark ? "dark" : "light";
12
+ }
13
+ //# sourceMappingURL=scheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheme.js","sourceRoot":"","sources":["../src/scheme.ts"],"names":[],"mappings":"AAMA,sGAAsG;AACtG,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEhD,2EAA2E;AAC3E,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,CAAC;AACrE,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,aAAa,CAAC,IAAe,EAAE,UAAmB;IAChE,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;AACvC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /** Fluent's default blue, used when no accent is configured. */
2
+ export declare const DEFAULT_ACCENT = "#0078d4";
3
+ export declare const BRAND_SHADES: readonly [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160];
4
+ export type BrandShade = (typeof BRAND_SHADES)[number];
5
+ /** Sixteen shades of one hue, darkest (10) to lightest (160). Fluent calls this BrandVariants. */
6
+ export type BrandRamp = Record<BrandShade, string>;
7
+ /**
8
+ * Builds the brand ramp around an accent colour.
9
+ *
10
+ * Fluent ramps run dark → light: light themes tint surfaces with the high
11
+ * shades and dark themes lift foregrounds with them. The accent is anchored
12
+ * at shade 80, which the light theme uses for primary buttons, links and
13
+ * focus, so those stay exactly the colour that was configured. Each step is
14
+ * 7 points of lightness, clamped to 5–96.
15
+ */
16
+ export declare function brandRamp(accent?: string | null): BrandRamp;
17
+ //# sourceMappingURL=brand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../src/theme/brand.ts"],"names":[],"mappings":"AAEA,gEAAgE;AAChE,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,eAAO,MAAM,YAAY,kFAEf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,kGAAkG;AAClG,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAEnD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAQ3D"}
@@ -0,0 +1,25 @@
1
+ import { hexToHsl, hslToHex, normalizeAccent } from "./color.js";
2
+ /** Fluent's default blue, used when no accent is configured. */
3
+ export const DEFAULT_ACCENT = "#0078d4";
4
+ export const BRAND_SHADES = [
5
+ 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160,
6
+ ];
7
+ /**
8
+ * Builds the brand ramp around an accent colour.
9
+ *
10
+ * Fluent ramps run dark → light: light themes tint surfaces with the high
11
+ * shades and dark themes lift foregrounds with them. The accent is anchored
12
+ * at shade 80, which the light theme uses for primary buttons, links and
13
+ * focus, so those stay exactly the colour that was configured. Each step is
14
+ * 7 points of lightness, clamped to 5–96.
15
+ */
16
+ export function brandRamp(accent) {
17
+ const [h, s, l] = hexToHsl(normalizeAccent(accent, DEFAULT_ACCENT));
18
+ const ramp = {};
19
+ BRAND_SHADES.forEach((shade, i) => {
20
+ const lightness = Math.max(5, Math.min(96, l + (i - 7) * 7));
21
+ ramp[shade] = hslToHex(h, s, lightness);
22
+ });
23
+ return ramp;
24
+ }
25
+ //# sourceMappingURL=brand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand.js","sourceRoot":"","sources":["../../src/theme/brand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEjE,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AAExC,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;CAC7D,CAAC;AAOX;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,MAAsB;IAC9C,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,EAAe,CAAC;IAC7B,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;QAChC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}