@siiway/ui-core 0.0.0 → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +14 -1
- package/dist/boot.d.ts +24 -0
- package/dist/boot.d.ts.map +1 -0
- package/dist/boot.js +38 -0
- package/dist/boot.js.map +1 -0
- package/dist/duration.d.ts +27 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/duration.js +87 -0
- package/dist/duration.js.map +1 -0
- package/dist/i18n/en.d.ts +3 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +56 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/index.d.ts +11 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +16 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/types.d.ts +72 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +2 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/i18n/zh.d.ts +3 -0
- package/dist/i18n/zh.d.ts.map +1 -0
- package/dist/i18n/zh.js +56 -0
- package/dist/i18n/zh.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/scheme.d.ts +36 -0
- package/dist/scheme.d.ts.map +1 -0
- package/dist/scheme.js +49 -0
- package/dist/scheme.js.map +1 -0
- package/dist/theme/brand.d.ts +17 -0
- package/dist/theme/brand.d.ts.map +1 -0
- package/dist/theme/brand.js +25 -0
- package/dist/theme/brand.js.map +1 -0
- package/dist/theme/color.d.ts +26 -0
- package/dist/theme/color.d.ts.map +1 -0
- package/dist/theme/color.js +148 -0
- package/dist/theme/color.js.map +1 -0
- package/dist/theme/overrides.d.ts +12 -0
- package/dist/theme/overrides.d.ts.map +1 -0
- package/dist/theme/overrides.js +12 -0
- package/dist/theme/overrides.js.map +1 -0
- package/dist/tokens/canvas.d.ts +8 -0
- package/dist/tokens/canvas.d.ts.map +1 -0
- package/dist/tokens/canvas.js +7 -0
- package/dist/tokens/canvas.js.map +1 -0
- package/dist/tokens/neutral.d.ts +55 -0
- package/dist/tokens/neutral.d.ts.map +1 -0
- package/dist/tokens/neutral.js +110 -0
- package/dist/tokens/neutral.js.map +1 -0
- package/dist/tokens/radii.d.ts +8 -0
- package/dist/tokens/radii.d.ts.map +1 -0
- package/dist/tokens/radii.js +8 -0
- package/dist/tokens/radii.js.map +1 -0
- package/dist/tokens/shadows.d.ts +14 -0
- package/dist/tokens/shadows.d.ts.map +1 -0
- package/dist/tokens/shadows.js +21 -0
- package/dist/tokens/shadows.js.map +1 -0
- package/package.json +25 -2
- package/src/boot.ts +55 -0
- package/src/duration.ts +119 -0
- package/src/i18n/en.ts +66 -0
- package/src/i18n/index.ts +24 -0
- package/src/i18n/types.ts +82 -0
- package/src/i18n/zh.ts +65 -0
- package/src/index.ts +46 -0
- package/src/scheme.ts +71 -0
- package/src/theme/brand.ts +32 -0
- package/src/theme/color.ts +147 -0
- package/src/theme/overrides.ts +15 -0
- package/src/tokens/canvas.ts +8 -0
- package/src/tokens/neutral.ts +116 -0
- package/src/tokens/radii.ts +7 -0
- 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
|
-
|
|
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,24 @@
|
|
|
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
|
+
* A cookie to write the scheme to, for the server to render in
|
|
9
|
+
* (`schemeFromRequest`), such as `SCHEME_COOKIE`. Give `useThemeMode` the same.
|
|
10
|
+
*/
|
|
11
|
+
cookie?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* JavaScript for an inline `<script>` in the page's `<head>`, after
|
|
15
|
+
* `<meta name="theme-color">` if there is one. Before anything renders, it
|
|
16
|
+
* reads the stored choice, resolves `system` with the OS setting, and draws
|
|
17
|
+
* `<html>` in that scheme: `data-scheme`, `color-scheme`, the canvas
|
|
18
|
+
* background and `--siiway-canvas`. Each `theme-color` takes the canvas.
|
|
19
|
+
* Without it, a dark page is white until the app's JavaScript runs.
|
|
20
|
+
* `<UiProvider page>` keeps `<html>` the same way afterwards. With `cookie`,
|
|
21
|
+
* it also writes the scheme there, for the server to render the next request in.
|
|
22
|
+
*/
|
|
23
|
+
export declare function schemeBootScript({ storageKey, defaultMode, cookie, }?: SchemeBootOptions): string;
|
|
24
|
+
//# sourceMappingURL=boot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAG1F,MAAM,WAAW,iBAAiB;IAChC,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAOD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,UAA8B,EAC9B,WAAsB,EACtB,MAAM,GACP,GAAE,iBAAsB,GAAG,MAAM,CAoBjC"}
|
package/dist/boot.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SCHEME_COOKIE_ATTRIBUTES, 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>` in the page's `<head>`, after
|
|
9
|
+
* `<meta name="theme-color">` if there is one. Before anything renders, it
|
|
10
|
+
* reads the stored choice, resolves `system` with the OS setting, and draws
|
|
11
|
+
* `<html>` in that scheme: `data-scheme`, `color-scheme`, the canvas
|
|
12
|
+
* background and `--siiway-canvas`. Each `theme-color` takes the canvas.
|
|
13
|
+
* Without it, a dark page is white until the app's JavaScript runs.
|
|
14
|
+
* `<UiProvider page>` keeps `<html>` the same way afterwards. With `cookie`,
|
|
15
|
+
* it also writes the scheme there, for the server to render the next request in.
|
|
16
|
+
*/
|
|
17
|
+
export function schemeBootScript({ storageKey = THEME_STORAGE_KEY, defaultMode = "system", cookie, } = {}) {
|
|
18
|
+
return [
|
|
19
|
+
"(function(){",
|
|
20
|
+
"var m;",
|
|
21
|
+
`try{m=localStorage.getItem(${literal(storageKey)})}catch(e){}`,
|
|
22
|
+
`if(m!=="system"&&m!=="light"&&m!=="dark")m=${literal(defaultMode)};`,
|
|
23
|
+
'var s=m!=="system"?m:matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";',
|
|
24
|
+
"var r=document.documentElement;",
|
|
25
|
+
`var c=s==="dark"?${literal(CANVAS.dark)}:${literal(CANVAS.light)};`,
|
|
26
|
+
'r.setAttribute("data-scheme",s);',
|
|
27
|
+
"r.style.colorScheme=s;",
|
|
28
|
+
"r.style.backgroundColor=c;",
|
|
29
|
+
'r.style.setProperty("--siiway-canvas",c);',
|
|
30
|
+
`for(var t=document.querySelectorAll(${literal('meta[name="theme-color"]')}),i=0;i<t.length;i++)t[i].setAttribute("content",c);`,
|
|
31
|
+
// As schemeCookie() writes it.
|
|
32
|
+
cookie
|
|
33
|
+
? `try{document.cookie=${literal(`${cookie}=`)}+s+${literal(SCHEME_COOKIE_ATTRIBUTES)}+(self.isSecureContext?";secure":"")}catch(e){}`
|
|
34
|
+
: "",
|
|
35
|
+
"})();",
|
|
36
|
+
].join("");
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=boot.js.map
|
package/dist/boot.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot.js","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAkB,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAc5C,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;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,UAAU,GAAG,iBAAiB,EAC9B,WAAW,GAAG,QAAQ,EACtB,MAAM,MACe,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,oBAAoB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG;QACpE,kCAAkC;QAClC,wBAAwB;QACxB,4BAA4B;QAC5B,2CAA2C;QAC3C,uCAAuC,OAAO,CAAC,0BAA0B,CAAC,sDAAsD;QAChI,+BAA+B;QAC/B,MAAM;YACJ,CAAC,CAAC,uBAAuB,OAAO,CAAC,GAAG,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,wBAAwB,CAAC,iDAAiD;YACtI,CAAC,CAAC,EAAE;QACN,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"}
|
package/dist/duration.js
ADDED
|
@@ -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,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,MAAM,GAAG,IAAI,MAAM,CAA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AsE;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 @@
|
|
|
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,SA+DhB,CAAC"}
|
package/dist/i18n/en.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
loading: "Loading",
|
|
38
|
+
openNavigation: "Open navigation",
|
|
39
|
+
primaryNavigation: "Primary",
|
|
40
|
+
navigation: "Navigation",
|
|
41
|
+
closeNavigation: "Close navigation",
|
|
42
|
+
duration: (value, unit) => unit === "minutes" ? `${value} min` : value === 1 ? "1 day" : `${value} days`,
|
|
43
|
+
durationUnits: {
|
|
44
|
+
s: ["s", "sec", "secs", "second", "seconds"],
|
|
45
|
+
m: ["m", "min", "mins", "minute", "minutes"],
|
|
46
|
+
h: ["h", "hr", "hrs", "hour", "hours"],
|
|
47
|
+
d: ["d", "day", "days"],
|
|
48
|
+
w: ["w", "wk", "wks", "week", "weeks"],
|
|
49
|
+
mo: ["mo", "mon", "month", "months"],
|
|
50
|
+
y: ["y", "yr", "yrs", "year", "years"],
|
|
51
|
+
},
|
|
52
|
+
durationInvalid: "Invalid format: try “60” or “1 hour”",
|
|
53
|
+
durationNotPositive: "Must be a positive duration",
|
|
54
|
+
durationUnknownUnit: "Unknown time unit",
|
|
55
|
+
};
|
|
56
|
+
//# 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,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C,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,OAAO;IAC/E,aAAa,EAAE;QACb,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC;QAC5C,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC;QAC5C,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;QACtC,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC;QACvB,CAAC,EAAE,CAAC,GAAG,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,72 @@
|
|
|
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
|
+
/** Names a spinner that has no text of its own, such as a page still loading. */
|
|
51
|
+
loading: string;
|
|
52
|
+
/** The top bar's menu button, which opens the navigation on a narrow screen. */
|
|
53
|
+
openNavigation: string;
|
|
54
|
+
/** Names the top bar's links for screen readers. */
|
|
55
|
+
primaryNavigation: string;
|
|
56
|
+
/** Names the app shell's sidebar while it is a drawer. */
|
|
57
|
+
navigation: string;
|
|
58
|
+
/** The button in the drawer that closes it. */
|
|
59
|
+
closeNavigation: string;
|
|
60
|
+
/** A duration as the duration field shows it, e.g. "30 days". It must read
|
|
61
|
+
* back with `parseDuration`. */
|
|
62
|
+
duration: (value: number, unit: DurationUnit) => string;
|
|
63
|
+
/** This language's words for each unit, which the duration field reads. */
|
|
64
|
+
durationUnits: DurationUnitWords;
|
|
65
|
+
/** The duration field's errors. */
|
|
66
|
+
durationInvalid: string;
|
|
67
|
+
durationNotPositive: string;
|
|
68
|
+
durationUnknownUnit: string;
|
|
69
|
+
}
|
|
70
|
+
/** Locales the library ships strings for. */
|
|
71
|
+
export type UiLocale = "en" | "zh";
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IAEvB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IAErB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAChD,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACtC,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IAEX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IAEZ,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,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,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,eAAe,EAAE,MAAM,CAAC;IAExB;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 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":""}
|
|
@@ -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,SA8DhB,CAAC"}
|
package/dist/i18n/zh.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
loading: "加载中",
|
|
38
|
+
openNavigation: "打开导航",
|
|
39
|
+
primaryNavigation: "主导航",
|
|
40
|
+
navigation: "导航",
|
|
41
|
+
closeNavigation: "关闭导航",
|
|
42
|
+
duration: (value, unit) => (unit === "minutes" ? `${value} 分钟` : `${value} 天`),
|
|
43
|
+
durationUnits: {
|
|
44
|
+
s: ["秒", "秒钟"],
|
|
45
|
+
m: ["分", "分钟"],
|
|
46
|
+
h: ["时", "小时", "个小时"],
|
|
47
|
+
d: ["天", "日"],
|
|
48
|
+
w: ["周", "星期", "个星期"],
|
|
49
|
+
mo: ["月", "个月"],
|
|
50
|
+
y: ["年"],
|
|
51
|
+
},
|
|
52
|
+
durationInvalid: "格式无效,试试“60”或“1 小时”",
|
|
53
|
+
durationNotPositive: "时长必须大于零",
|
|
54
|
+
durationUnknownUnit: "无法识别的时间单位",
|
|
55
|
+
};
|
|
56
|
+
//# 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;IACd,UAAU,EAAE,MAAM;IAElB,WAAW,EAAE,MAAM;IACnB,cAAc,EAAE,MAAM;IAEtB,YAAY,EAAE,MAAM;IACpB,YAAY,EAAE,MAAM;IAEpB,QAAQ,EAAE,KAAK;IACf,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,MAAM,KAAK,EAAE;IAC7C,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI;IACrC,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,MAAM;IAChB,EAAE,EAAE,IAAI;IAER,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,QAAQ;IAClB,gBAAgB,EAAE,WAAW;IAC7B,eAAe,EAAE,iBAAiB;IAClC,SAAS,EAAE,UAAU;IACrB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,IAAI;IAChB,GAAG,EAAE,IAAI;IAET,KAAK,EAAE,IAAI;IACX,WAAW,EAAE,MAAM;IACnB,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,IAAI;IAEf,MAAM,EAAE,IAAI;IACZ,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAElB,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,KAAK;IACd,cAAc,EAAE,MAAM;IACtB,iBAAiB,EAAE,KAAK;IACxB,UAAU,EAAE,IAAI;IAChB,eAAe,EAAE,MAAM;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC;IAC9E,aAAa,EAAE;QACb,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC;QACd,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC;QACd,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC;QACrB,CAAC,EAAE,CAAC,GAAG,EAAE,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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { SCHEME_COOKIE, THEME_STORAGE_KEY, isThemeMode, resolveScheme, schemeCookie, schemeFromRequest, type Scheme, type SchemeRequestOptions, 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,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,KAAK,MAAM,EACX,KAAK,oBAAoB,EACzB,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 { SCHEME_COOKIE, THEME_STORAGE_KEY, isThemeMode, resolveScheme, schemeCookie, schemeFromRequest, } 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,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,YAAY,EACZ,iBAAiB,GAIlB,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"}
|
package/dist/scheme.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
/** A name for the cookie that carries the scheme to the server, as `schemeFromRequest` reads it by default. */
|
|
12
|
+
export declare const SCHEME_COOKIE = "siiway-scheme";
|
|
13
|
+
export declare const SCHEME_COOKIE_ATTRIBUTES = ";path=/;max-age=31536000;samesite=lax";
|
|
14
|
+
/**
|
|
15
|
+
* The scheme cookie, as `document.cookie` takes it, the way `schemeBootScript`
|
|
16
|
+
* and `useThemeMode` write it. `secure` (in a secure context) lets the name
|
|
17
|
+
* start with `__Host-`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function schemeCookie(name: string, scheme: Scheme, secure: boolean): string;
|
|
20
|
+
/** How the app keeps the scheme: `schemeBootScript`'s options fit. */
|
|
21
|
+
export interface SchemeRequestOptions {
|
|
22
|
+
/** The cookie's name, as given to `schemeBootScript` and `useThemeMode`. Defaults to `SCHEME_COOKIE`. */
|
|
23
|
+
cookie?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The app's `defaultMode`. For `light` or `dark`, the hint is left out: a
|
|
26
|
+
* first visit draws that, whatever the OS. Defaults to `system`.
|
|
27
|
+
*/
|
|
28
|
+
defaultMode?: ThemeMode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The scheme to render a request in: the scheme cookie from the `Cookie`
|
|
32
|
+
* header, else (for `defaultMode` `system`) the browser's
|
|
33
|
+
* `Sec-CH-Prefers-Color-Scheme` hint, else null, for `defaultMode`'s scheme.
|
|
34
|
+
*/
|
|
35
|
+
export declare function schemeFromRequest(cookieHeader?: string | null, prefersColorSchemeHint?: string | null, { cookie, defaultMode }?: SchemeRequestOptions): Scheme | null;
|
|
36
|
+
//# 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;AAED,+GAA+G;AAC/G,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAG7C,eAAO,MAAM,wBAAwB,0CAA0C,CAAC;AAEhF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAElF;AAED,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,yGAAyG;IACzG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,EAC5B,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,EACtC,EAAE,MAAsB,EAAE,WAAsB,EAAE,GAAE,oBAAyB,GAC5E,MAAM,GAAG,IAAI,CAef"}
|