@sigx/lynx-zero 0.4.9

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 (100) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/dist/components/SwiperIndicator.d.ts +43 -0
  4. package/dist/components/SwiperIndicator.d.ts.map +1 -0
  5. package/dist/components/SwiperIndicator.js +272 -0
  6. package/dist/components/SwiperIndicator.js.map +1 -0
  7. package/dist/contract.d.ts +95 -0
  8. package/dist/contract.d.ts.map +1 -0
  9. package/dist/contract.js +30 -0
  10. package/dist/contract.js.map +1 -0
  11. package/dist/index.d.ts +30 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +41 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/layout/Center.d.ts +7 -0
  16. package/dist/layout/Center.d.ts.map +1 -0
  17. package/dist/layout/Center.js +25 -0
  18. package/dist/layout/Center.js.map +1 -0
  19. package/dist/layout/Col.d.ts +8 -0
  20. package/dist/layout/Col.d.ts.map +1 -0
  21. package/dist/layout/Col.js +34 -0
  22. package/dist/layout/Col.js.map +1 -0
  23. package/dist/layout/Row.d.ts +8 -0
  24. package/dist/layout/Row.d.ts.map +1 -0
  25. package/dist/layout/Row.js +34 -0
  26. package/dist/layout/Row.js.map +1 -0
  27. package/dist/layout/ScrollView.d.ts +6 -0
  28. package/dist/layout/ScrollView.d.ts.map +1 -0
  29. package/dist/layout/ScrollView.js +19 -0
  30. package/dist/layout/ScrollView.js.map +1 -0
  31. package/dist/layout/Spacer.d.ts +4 -0
  32. package/dist/layout/Spacer.d.ts.map +1 -0
  33. package/dist/layout/Spacer.js +12 -0
  34. package/dist/layout/Spacer.js.map +1 -0
  35. package/dist/preset/index.d.ts +31 -0
  36. package/dist/preset/index.d.ts.map +1 -0
  37. package/dist/preset/index.js +72 -0
  38. package/dist/preset/index.js.map +1 -0
  39. package/dist/shared/press.d.ts +3 -0
  40. package/dist/shared/press.d.ts.map +1 -0
  41. package/dist/shared/press.js +7 -0
  42. package/dist/shared/press.js.map +1 -0
  43. package/dist/shared/styles.d.ts +27 -0
  44. package/dist/shared/styles.d.ts.map +1 -0
  45. package/dist/shared/styles.js +62 -0
  46. package/dist/shared/styles.js.map +1 -0
  47. package/dist/shared/tabs-selection.d.ts +25 -0
  48. package/dist/shared/tabs-selection.d.ts.map +1 -0
  49. package/dist/shared/tabs-selection.js +45 -0
  50. package/dist/shared/tabs-selection.js.map +1 -0
  51. package/dist/styles/tokens.css +98 -0
  52. package/dist/theme/StatusBarSync.d.ts +42 -0
  53. package/dist/theme/StatusBarSync.d.ts.map +1 -0
  54. package/dist/theme/StatusBarSync.js +89 -0
  55. package/dist/theme/StatusBarSync.js.map +1 -0
  56. package/dist/theme/ThemeProvider.d.ts +144 -0
  57. package/dist/theme/ThemeProvider.d.ts.map +1 -0
  58. package/dist/theme/ThemeProvider.js +328 -0
  59. package/dist/theme/ThemeProvider.js.map +1 -0
  60. package/dist/theme/color-mix.d.ts +21 -0
  61. package/dist/theme/color-mix.d.ts.map +1 -0
  62. package/dist/theme/color-mix.js +65 -0
  63. package/dist/theme/color-mix.js.map +1 -0
  64. package/dist/theme/registry.d.ts +182 -0
  65. package/dist/theme/registry.d.ts.map +1 -0
  66. package/dist/theme/registry.js +182 -0
  67. package/dist/theme/registry.js.map +1 -0
  68. package/dist/theme/theme-state.d.ts +43 -0
  69. package/dist/theme/theme-state.d.ts.map +1 -0
  70. package/dist/theme/theme-state.js +94 -0
  71. package/dist/theme/theme-state.js.map +1 -0
  72. package/dist/theme/use-screen-theme.d.ts +4 -0
  73. package/dist/theme/use-screen-theme.d.ts.map +1 -0
  74. package/dist/theme/use-screen-theme.js +43 -0
  75. package/dist/theme/use-screen-theme.js.map +1 -0
  76. package/dist/theme/use-theme-colors.d.ts +48 -0
  77. package/dist/theme/use-theme-colors.d.ts.map +1 -0
  78. package/dist/theme/use-theme-colors.js +69 -0
  79. package/dist/theme/use-theme-colors.js.map +1 -0
  80. package/package.json +80 -0
  81. package/src/components/SwiperIndicator.tsx +519 -0
  82. package/src/contract.ts +136 -0
  83. package/src/index.ts +101 -0
  84. package/src/layout/Center.tsx +41 -0
  85. package/src/layout/Col.tsx +53 -0
  86. package/src/layout/Row.tsx +53 -0
  87. package/src/layout/ScrollView.tsx +38 -0
  88. package/src/layout/Spacer.tsx +18 -0
  89. package/src/preset/index.ts +77 -0
  90. package/src/shared/press.ts +6 -0
  91. package/src/shared/styles.ts +82 -0
  92. package/src/shared/tabs-selection.ts +57 -0
  93. package/src/styles/tokens.css +98 -0
  94. package/src/theme/StatusBarSync.tsx +104 -0
  95. package/src/theme/ThemeProvider.tsx +492 -0
  96. package/src/theme/color-mix.ts +68 -0
  97. package/src/theme/registry.ts +290 -0
  98. package/src/theme/theme-state.ts +112 -0
  99. package/src/theme/use-screen-theme.ts +42 -0
  100. package/src/theme/use-theme-colors.ts +99 -0
@@ -0,0 +1,48 @@
1
+ /**
2
+ * `useThemeColors()` — resolve the *active, scoped* theme palette to concrete
3
+ * color values for consumers that can't read CSS custom properties.
4
+ *
5
+ * Native widgets are the audience: platform text inputs, `<sigx-richtext>`,
6
+ * SVG fills — anything where `var(--color-*)` never resolves because the
7
+ * value is consumed outside Lynx's CSS pipeline. Components pass these
8
+ * resolved literals via inline `style` or native props instead.
9
+ *
10
+ * Scoped + reactive: resolves through `useTheme()` (the nearest
11
+ * `<ThemeProvider>`'s controller, falling back to the global one), and the
12
+ * getters read `theme.name` — call them inside render and a theme switch
13
+ * recolors the consumer.
14
+ *
15
+ * ```tsx
16
+ * const colors = useThemeColors();
17
+ * return () => (
18
+ * <input style={{
19
+ * color: colors.colorOf('base-content'),
20
+ * '-x-placeholder-color': colors.colorOf('base-content', 0.45),
21
+ * }} />
22
+ * );
23
+ * ```
24
+ */
25
+ import type { ColorToken } from '../contract.js';
26
+ export interface ThemeColors {
27
+ /**
28
+ * The active palette's value for `token`, normalized to hex — optionally
29
+ * with `alpha` (0–1) appended as a hex byte (`#RRGGBBAA`). Returns `''`
30
+ * when no theme is registered yet (pre-DS-import edge case).
31
+ */
32
+ colorOf(token: ColorToken, alpha?: number): string;
33
+ }
34
+ export declare function useThemeColors(): ThemeColors;
35
+ /**
36
+ * Normalize an engine-safe palette color to full-form hex
37
+ * (`#RRGGBB`/`#RRGGBBAA`) — the registry allows `rgb()`/`rgba()` entries and
38
+ * shorthand hex, but native color parsers may accept only the full forms.
39
+ * Unknown notations pass through unchanged.
40
+ */
41
+ export declare function toHexColor(color: string): string;
42
+ /**
43
+ * Append an alpha channel (0–1) to a hex color
44
+ * (`#RGB`/`#RRGGBB`/`#RRGGBBAA` → `#RRGGBBAA`). Non-hex input passes
45
+ * through unchanged; non-finite alpha is treated as opaque.
46
+ */
47
+ export declare function withAlpha(hex: string, alpha: number): string;
48
+ //# sourceMappingURL=use-theme-colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-theme-colors.d.ts","sourceRoot":"","sources":["../../src/theme/use-theme-colors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACpD;AAED,wBAAgB,cAAc,IAAI,WAAW,CAY5C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoBhD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAc5D"}
@@ -0,0 +1,69 @@
1
+ import { colorsOf, fallbackPalette } from './registry.js';
2
+ import { useTheme } from './ThemeProvider.js';
3
+ export function useThemeColors() {
4
+ const theme = useTheme();
5
+ return {
6
+ colorOf(token, alpha) {
7
+ // Reading `theme.name` here is what makes call sites reactive.
8
+ const palette = colorsOf(theme.name) ?? fallbackPalette();
9
+ const raw = palette?.[token];
10
+ if (!raw)
11
+ return '';
12
+ const hex = toHexColor(raw);
13
+ return alpha === undefined ? hex : withAlpha(hex, alpha);
14
+ },
15
+ };
16
+ }
17
+ /**
18
+ * Normalize an engine-safe palette color to full-form hex
19
+ * (`#RRGGBB`/`#RRGGBBAA`) — the registry allows `rgb()`/`rgba()` entries and
20
+ * shorthand hex, but native color parsers may accept only the full forms.
21
+ * Unknown notations pass through unchanged.
22
+ */
23
+ export function toHexColor(color) {
24
+ const c = color.trim();
25
+ if (c.startsWith('#')) {
26
+ const h = c.slice(1);
27
+ // Expand #RGB / #RGBA to the full form; leave other lengths as-is.
28
+ if (h.length === 3 || h.length === 4) {
29
+ return `#${h.split('').map((ch) => ch + ch).join('')}`;
30
+ }
31
+ return c;
32
+ }
33
+ const m = /^rgba?\(\s*(\d+)\s*[, ]\s*(\d+)\s*[, ]\s*(\d+)\s*(?:[,/]\s*([\d.]+%?)\s*)?\)$/i.exec(c);
34
+ if (!m)
35
+ return c;
36
+ const byte = (v) => Math.max(0, Math.min(255, Math.round(v))).toString(16).padStart(2, '0');
37
+ let hex = `#${byte(Number(m[1]))}${byte(Number(m[2]))}${byte(Number(m[3]))}`;
38
+ if (m[4] !== undefined) {
39
+ const a = m[4].endsWith('%') ? Number(m[4].slice(0, -1)) / 100 : Number(m[4]);
40
+ hex += byte(Math.max(0, Math.min(1, a)) * 255);
41
+ }
42
+ return hex;
43
+ }
44
+ /**
45
+ * Append an alpha channel (0–1) to a hex color
46
+ * (`#RGB`/`#RRGGBB`/`#RRGGBBAA` → `#RRGGBBAA`). Non-hex input passes
47
+ * through unchanged; non-finite alpha is treated as opaque.
48
+ */
49
+ export function withAlpha(hex, alpha) {
50
+ const input = hex.trim();
51
+ if (!input.startsWith('#'))
52
+ return input;
53
+ if (!Number.isFinite(alpha))
54
+ return input;
55
+ let h = input.slice(1);
56
+ if (h.length === 3)
57
+ h = h.split('').map((c) => c + c).join('');
58
+ if (h.length === 8)
59
+ h = h.slice(0, 6);
60
+ // Anything that isn't #RRGGBB by now (#RGBA, bad lengths) is not a shape
61
+ // we can safely re-alpha — return it unchanged rather than corrupt it.
62
+ if (h.length !== 6)
63
+ return input;
64
+ const byte = Math.round(Math.max(0, Math.min(1, alpha)) * 255)
65
+ .toString(16)
66
+ .padStart(2, '0');
67
+ return `#${h}${byte}`;
68
+ }
69
+ //# sourceMappingURL=use-theme-colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-theme-colors.js","sourceRoot":"","sources":["../../src/theme/use-theme-colors.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAW9C,MAAM,UAAU,cAAc;IAC5B,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,OAAO;QACL,OAAO,CAAC,KAAK,EAAE,KAAK;YAClB,+DAA+D;YAC/D,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,eAAe,EAAE,CAAC;YAC1D,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG;gBAAE,OAAO,EAAE,CAAC;YACpB,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YAC5B,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACvB,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CA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CAAC;SACZ,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACpB,OAAO,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;AACxB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@sigx/lynx-zero",
3
+ "version": "0.4.9",
4
+ "description": "Design-system-neutral UI foundation for sigx-lynx — the shared props/token contract and style utilities that design-system packages (daisyui, heroui, …) build on",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./screen-theme": {
14
+ "types": "./dist/theme/use-screen-theme.d.ts",
15
+ "import": "./dist/theme/use-screen-theme.js"
16
+ },
17
+ "./preset": {
18
+ "types": "./dist/preset/index.d.ts",
19
+ "import": "./dist/preset/index.js",
20
+ "default": "./dist/preset/index.js"
21
+ },
22
+ "./styles/tokens.css": "./dist/styles/tokens.css"
23
+ },
24
+ "files": [
25
+ "src",
26
+ "dist"
27
+ ],
28
+ "keywords": [
29
+ "sigx",
30
+ "lynx",
31
+ "ui",
32
+ "design-system",
33
+ "headless",
34
+ "tokens"
35
+ ],
36
+ "author": "Andreas Ekdahl",
37
+ "license": "MIT",
38
+ "dependencies": {
39
+ "@sigx/lynx": "^0.4.9",
40
+ "@sigx/lynx-motion": "^0.4.9",
41
+ "@sigx/lynx-appearance": "^0.4.9",
42
+ "@sigx/lynx-gestures": "^0.4.9"
43
+ },
44
+ "peerDependencies": {
45
+ "tailwindcss": "^3.0.0 || ^4.0.0",
46
+ "@sigx/lynx-navigation": "^0.4.9"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "@sigx/lynx-navigation": {
50
+ "optional": true
51
+ },
52
+ "tailwindcss": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "devDependencies": {
57
+ "@typescript/native-preview": "7.0.0-dev.20260521.1",
58
+ "tailwindcss": "^4.0.0",
59
+ "typescript": "^6.0.3",
60
+ "@sigx/lynx-navigation": "^0.4.9",
61
+ "@sigx/lynx-testing": "^0.4.9"
62
+ },
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "git+https://github.com/signalxjs/lynx.git",
66
+ "directory": "packages/lynx-zero"
67
+ },
68
+ "homepage": "https://github.com/signalxjs/lynx/tree/main/packages/lynx-zero",
69
+ "bugs": {
70
+ "url": "https://github.com/signalxjs/lynx/issues"
71
+ },
72
+ "publishConfig": {
73
+ "access": "public"
74
+ },
75
+ "scripts": {
76
+ "build": "node ../../scripts/clean.mjs dist && tsgo && node ../../scripts/copy-assets.mjs src/styles dist/styles",
77
+ "dev": "tsgo --watch",
78
+ "clean": "node ../../scripts/clean.mjs dist .turbo"
79
+ }
80
+ }