@inshapardaz/likhari-react 0.1.6-dev.70 → 0.1.6

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 (62) hide show
  1. package/dist/EditorRoot.d.ts +1 -25
  2. package/dist/EditorRoot.d.ts.map +1 -1
  3. package/dist/EditorRoot.js +5 -24
  4. package/dist/components/LinkDialog.d.ts.map +1 -1
  5. package/dist/components/LinkDialog.js +3 -7
  6. package/dist/components/Toolbar.d.ts +1 -4
  7. package/dist/components/Toolbar.d.ts.map +1 -1
  8. package/dist/components/Toolbar.js +33 -246
  9. package/dist/index.d.ts +0 -4
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +0 -2
  12. package/dist/nodes.d.ts.map +1 -1
  13. package/dist/nodes.js +0 -2
  14. package/dist/theme/EditorThemeProvider.d.ts +1 -17
  15. package/dist/theme/EditorThemeProvider.d.ts.map +1 -1
  16. package/dist/theme/EditorThemeProvider.js +2 -24
  17. package/dist/theme/editor.css +0 -125
  18. package/dist/theme/editorTheme.d.ts.map +1 -1
  19. package/dist/theme/editorTheme.js +0 -1
  20. package/package.json +1 -2
  21. package/dist/PortalTargetContext.d.ts +0 -16
  22. package/dist/PortalTargetContext.d.ts.map +0 -1
  23. package/dist/PortalTargetContext.js +0 -18
  24. package/dist/i18n/index.d.ts +0 -4
  25. package/dist/i18n/index.d.ts.map +0 -1
  26. package/dist/i18n/index.js +0 -2
  27. package/dist/i18n/strings.d.ts +0 -158
  28. package/dist/i18n/strings.d.ts.map +0 -1
  29. package/dist/i18n/strings.js +0 -425
  30. package/dist/i18n/useStrings.d.ts +0 -10
  31. package/dist/i18n/useStrings.d.ts.map +0 -1
  32. package/dist/i18n/useStrings.js +0 -14
  33. package/dist/image/ImageComponent.d.ts +0 -23
  34. package/dist/image/ImageComponent.d.ts.map +0 -1
  35. package/dist/image/ImageComponent.js +0 -171
  36. package/dist/image/ImageCropDialog.d.ts +0 -22
  37. package/dist/image/ImageCropDialog.d.ts.map +0 -1
  38. package/dist/image/ImageCropDialog.js +0 -120
  39. package/dist/image/ImageCropper.d.ts +0 -15
  40. package/dist/image/ImageCropper.d.ts.map +0 -1
  41. package/dist/image/ImageCropper.js +0 -120
  42. package/dist/image/ImageDialog.d.ts +0 -37
  43. package/dist/image/ImageDialog.d.ts.map +0 -1
  44. package/dist/image/ImageDialog.js +0 -176
  45. package/dist/image/ImageNode.d.ts +0 -64
  46. package/dist/image/ImageNode.d.ts.map +0 -1
  47. package/dist/image/ImageNode.js +0 -133
  48. package/dist/image/ImageOptionsContext.d.ts +0 -24
  49. package/dist/image/ImageOptionsContext.d.ts.map +0 -1
  50. package/dist/image/ImageOptionsContext.js +0 -10
  51. package/dist/image/cropMath.d.ts +0 -35
  52. package/dist/image/cropMath.d.ts.map +0 -1
  53. package/dist/image/cropMath.js +0 -92
  54. package/dist/image/imageEdit.d.ts +0 -49
  55. package/dist/image/imageEdit.d.ts.map +0 -1
  56. package/dist/image/imageEdit.js +0 -132
  57. package/dist/image/imageUrl.d.ts +0 -14
  58. package/dist/image/imageUrl.d.ts.map +0 -1
  59. package/dist/image/imageUrl.js +0 -27
  60. package/dist/theme/accentColor.d.ts +0 -43
  61. package/dist/theme/accentColor.d.ts.map +0 -1
  62. package/dist/theme/accentColor.js +0 -84
@@ -1,84 +0,0 @@
1
- /**
2
- * Derives Mantine's 10-shade color array and the editor's own
3
- * `--editor-accent` / `--editor-accent-soft` pair from a single
4
- * host-supplied accent color (EditorRootProps.accentColor). No color
5
- * library needed — a few lines of hex parsing plus RGB lerp is enough for a
6
- * usable (not professionally calibrated) ramp.
7
- */
8
- /** Parses a `#rgb` or `#rrggbb` hex color. Returns null for anything else —
9
- * callers fall back to the static default tokens rather than throwing on a
10
- * bad host-supplied value. */
11
- export function hexToRgb(hex) {
12
- const cleaned = hex.trim().replace(/^#/, '');
13
- const full = cleaned.length === 3
14
- ? cleaned
15
- .split('')
16
- .map((c) => c + c)
17
- .join('')
18
- : cleaned;
19
- if (!/^[0-9a-fA-F]{6}$/.test(full))
20
- return null;
21
- return {
22
- r: parseInt(full.slice(0, 2), 16),
23
- g: parseInt(full.slice(2, 4), 16),
24
- b: parseInt(full.slice(4, 6), 16),
25
- };
26
- }
27
- function toHex(n) {
28
- return Math.round(Math.min(255, Math.max(0, n)))
29
- .toString(16)
30
- .padStart(2, '0');
31
- }
32
- export function rgbToHex({ r, g, b }) {
33
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
34
- }
35
- /** Linear-interpolates two colors; t=0 -> a, t=1 -> b. */
36
- export function mix(a, b, t) {
37
- return {
38
- r: a.r + (b.r - a.r) * t,
39
- g: a.g + (b.g - a.g) * t,
40
- b: a.b + (b.b - a.b) * t,
41
- };
42
- }
43
- const WHITE = { r: 255, g: 255, b: 255 };
44
- const BLACK = { r: 0, g: 0, b: 0 };
45
- /**
46
- * A 10-shade Mantine color array for `theme.colors.likhariAccent`, mixing
47
- * the base color towards white for the lighter shades (0-4ish) and towards
48
- * black for the darker ones (6-9ish) — shade 6 (Mantine's default "filled"
49
- * shade) is the exact input color, matching what the static
50
- * `likhariAccent` ramp already did for the default tokens.
51
- */
52
- export function generateAccentShades(hex) {
53
- const base = hexToRgb(hex);
54
- if (!base)
55
- return null;
56
- // How far to mix towards white (positive) or black (negative) per shade,
57
- // relative to shade 6 = the exact input color.
58
- const mixAmount = [0.88, 0.72, 0.56, 0.4, 0.22, 0.1, 0, -0.14, -0.28, -0.42];
59
- const shades = mixAmount.map((t) => rgbToHex(mix(base, t >= 0 ? WHITE : BLACK, Math.abs(t))));
60
- return shades;
61
- }
62
- /**
63
- * The editor canvas/toolbar's own `--editor-accent` / `--editor-accent-soft`
64
- * pair for a host-supplied accent color, mirroring the relationship between
65
- * `LIGHT_TOKENS`/`DARK_TOKENS`'s `accent`/`accentSoft` (packages/core/src/theme/tokens.ts):
66
- * light mode keeps the accent as given and derives a light tint for "soft";
67
- * dark mode lightens the accent itself (for contrast against a dark canvas)
68
- * and derives a dark tint for "soft".
69
- */
70
- export function generateAccentCssVars(hex, mode) {
71
- const base = hexToRgb(hex);
72
- if (!base)
73
- return null;
74
- if (mode === 'dark') {
75
- return {
76
- accent: rgbToHex(mix(base, WHITE, 0.45)),
77
- accentSoft: rgbToHex(mix(base, BLACK, 0.75)),
78
- };
79
- }
80
- return {
81
- accent: hex,
82
- accentSoft: rgbToHex(mix(base, WHITE, 0.88)),
83
- };
84
- }