@shumoku/core 0.2.0 → 0.2.3

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 (60) hide show
  1. package/dist/icons/build-icons.js +3 -3
  2. package/dist/icons/build-icons.js.map +1 -1
  3. package/dist/icons/generated-icons.js +10 -10
  4. package/dist/icons/generated-icons.js.map +1 -1
  5. package/dist/index.d.ts +3 -4
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +6 -8
  8. package/dist/index.js.map +1 -1
  9. package/dist/layout/hierarchical.d.ts +1 -1
  10. package/dist/layout/hierarchical.d.ts.map +1 -1
  11. package/dist/layout/hierarchical.js +82 -66
  12. package/dist/layout/hierarchical.js.map +1 -1
  13. package/dist/layout/index.d.ts +1 -1
  14. package/dist/layout/index.d.ts.map +1 -1
  15. package/dist/layout/index.js.map +1 -1
  16. package/dist/models/types.d.ts.map +1 -1
  17. package/dist/models/types.js +13 -13
  18. package/dist/models/types.js.map +1 -1
  19. package/dist/renderer/index.d.ts +4 -3
  20. package/dist/renderer/index.d.ts.map +1 -1
  21. package/dist/renderer/index.js +3 -2
  22. package/dist/renderer/index.js.map +1 -1
  23. package/dist/renderer/svg.d.ts +26 -4
  24. package/dist/renderer/svg.d.ts.map +1 -1
  25. package/dist/renderer/svg.js +286 -147
  26. package/dist/renderer/svg.js.map +1 -1
  27. package/dist/renderer/types.d.ts +70 -0
  28. package/dist/renderer/types.d.ts.map +1 -0
  29. package/dist/renderer/types.js +6 -0
  30. package/dist/renderer/types.js.map +1 -0
  31. package/dist/themes/dark.d.ts.map +1 -1
  32. package/dist/themes/dark.js +1 -1
  33. package/dist/themes/dark.js.map +1 -1
  34. package/dist/themes/index.d.ts +3 -3
  35. package/dist/themes/index.d.ts.map +1 -1
  36. package/dist/themes/index.js +4 -4
  37. package/dist/themes/index.js.map +1 -1
  38. package/dist/themes/modern.d.ts.map +1 -1
  39. package/dist/themes/modern.js.map +1 -1
  40. package/dist/themes/types.d.ts.map +1 -1
  41. package/dist/themes/utils.d.ts +1 -1
  42. package/dist/themes/utils.d.ts.map +1 -1
  43. package/dist/themes/utils.js +5 -4
  44. package/dist/themes/utils.js.map +1 -1
  45. package/package.json +88 -92
  46. package/src/constants.ts +35 -35
  47. package/src/icons/build-icons.ts +12 -6
  48. package/src/icons/generated-icons.ts +12 -12
  49. package/src/index.test.ts +66 -0
  50. package/src/index.ts +6 -13
  51. package/src/layout/hierarchical.ts +1251 -1221
  52. package/src/layout/index.ts +1 -1
  53. package/src/models/types.ts +47 -37
  54. package/src/themes/dark.ts +15 -15
  55. package/src/themes/index.ts +7 -7
  56. package/src/themes/modern.ts +22 -22
  57. package/src/themes/types.ts +26 -26
  58. package/src/themes/utils.ts +25 -24
  59. package/src/renderer/index.ts +0 -6
  60. package/src/renderer/svg.ts +0 -1277
@@ -2,14 +2,14 @@
2
2
  * Theme utilities
3
3
  */
4
4
 
5
- import type { Theme, ThemeOptions, DeepPartial } from './types.js'
5
+ import type { DeepPartial, Theme, ThemeOptions } from './types.js'
6
6
 
7
7
  /**
8
8
  * Merge theme with overrides
9
9
  */
10
10
  export function mergeTheme(base: Theme, overrides?: DeepPartial<Theme>): Theme {
11
11
  if (!overrides) return base
12
-
12
+
13
13
  return deepMerge(base, overrides) as Theme
14
14
  }
15
15
 
@@ -26,7 +26,7 @@ export function createTheme(options: ThemeOptions): Theme {
26
26
  */
27
27
  export function applyThemeToCSS(theme: Theme, root: HTMLElement = document.documentElement): void {
28
28
  const prefix = '--shumoku'
29
-
29
+
30
30
  // Colors
31
31
  root.style.setProperty(`${prefix}-bg`, theme.colors.background)
32
32
  root.style.setProperty(`${prefix}-surface`, theme.colors.surface)
@@ -38,34 +38,34 @@ export function applyThemeToCSS(theme: Theme, root: HTMLElement = document.docum
38
38
  root.style.setProperty(`${prefix}-warning`, theme.colors.warning)
39
39
  root.style.setProperty(`${prefix}-error`, theme.colors.error)
40
40
  root.style.setProperty(`${prefix}-info`, theme.colors.info)
41
-
41
+
42
42
  // Dimensions
43
43
  root.style.setProperty(`${prefix}-radius-sm`, `${theme.dimensions.radius.small}px`)
44
44
  root.style.setProperty(`${prefix}-radius-md`, `${theme.dimensions.radius.medium}px`)
45
45
  root.style.setProperty(`${prefix}-radius-lg`, `${theme.dimensions.radius.large}px`)
46
-
46
+
47
47
  // Spacing
48
48
  root.style.setProperty(`${prefix}-space-xs`, `${theme.dimensions.spacing.xs}px`)
49
49
  root.style.setProperty(`${prefix}-space-sm`, `${theme.dimensions.spacing.sm}px`)
50
50
  root.style.setProperty(`${prefix}-space-md`, `${theme.dimensions.spacing.md}px`)
51
51
  root.style.setProperty(`${prefix}-space-lg`, `${theme.dimensions.spacing.lg}px`)
52
52
  root.style.setProperty(`${prefix}-space-xl`, `${theme.dimensions.spacing.xl}px`)
53
-
53
+
54
54
  // Typography
55
55
  root.style.setProperty(`${prefix}-font-sans`, theme.typography.fontFamily.sans)
56
56
  root.style.setProperty(`${prefix}-font-mono`, theme.typography.fontFamily.mono)
57
-
57
+
58
58
  // Shadows
59
59
  const shadowToCSS = (shadow: Theme['shadows'][keyof Theme['shadows']]) => {
60
60
  const alpha = shadow.alpha || 1
61
61
  const color = hexToRgba(shadow.color, alpha)
62
62
  return `${shadow.offsetX}px ${shadow.offsetY}px ${shadow.blur}px ${color}`
63
63
  }
64
-
64
+
65
65
  root.style.setProperty(`${prefix}-shadow-sm`, shadowToCSS(theme.shadows.small))
66
66
  root.style.setProperty(`${prefix}-shadow-md`, shadowToCSS(theme.shadows.medium))
67
67
  root.style.setProperty(`${prefix}-shadow-lg`, shadowToCSS(theme.shadows.large))
68
-
68
+
69
69
  // Set theme variant
70
70
  root.setAttribute('data-theme', theme.variant)
71
71
  }
@@ -76,11 +76,11 @@ export function applyThemeToCSS(theme: Theme, root: HTMLElement = document.docum
76
76
  export function getThemeFromCSS(root: HTMLElement = document.documentElement): Partial<Theme> {
77
77
  const prefix = '--shumoku'
78
78
  const style = getComputedStyle(root)
79
-
79
+
80
80
  const getVar = (name: string) => style.getPropertyValue(`${prefix}-${name}`).trim()
81
-
81
+
82
82
  return {
83
- variant: root.getAttribute('data-theme') as 'light' | 'dark' || 'light',
83
+ variant: (root.getAttribute('data-theme') as 'light' | 'dark') || 'light',
84
84
  colors: {
85
85
  background: getVar('bg'),
86
86
  surface: getVar('surface'),
@@ -99,29 +99,30 @@ export function getThemeFromCSS(root: HTMLElement = document.documentElement): P
99
99
  /**
100
100
  * Convert hex color to rgba
101
101
  */
102
- function hexToRgba(hex: string, alpha: number = 1): string {
102
+ function hexToRgba(hex: string, alpha = 1): string {
103
103
  if (hex === 'transparent') return 'transparent'
104
-
104
+
105
105
  const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
106
106
  if (!result) return hex
107
-
108
- const r = parseInt(result[1], 16)
109
- const g = parseInt(result[2], 16)
110
- const b = parseInt(result[3], 16)
111
-
107
+
108
+ const r = Number.parseInt(result[1], 16)
109
+ const g = Number.parseInt(result[2], 16)
110
+ const b = Number.parseInt(result[3], 16)
111
+
112
112
  return `rgba(${r}, ${g}, ${b}, ${alpha})`
113
113
  }
114
114
 
115
115
  /**
116
116
  * Deep merge utility
117
117
  */
118
+ // biome-ignore lint/suspicious/noExplicitAny: generic deep merge requires any types
118
119
  function deepMerge(target: any, source: any): any {
119
120
  if (!source) return target
120
-
121
+
121
122
  const result = { ...target }
122
-
123
+
123
124
  for (const key in source) {
124
- if (source.hasOwnProperty(key)) {
125
+ if (Object.hasOwn(source, key)) {
125
126
  if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
126
127
  result[key] = deepMerge(target[key] || {}, source[key])
127
128
  } else {
@@ -129,7 +130,7 @@ function deepMerge(target: any, source: any): any {
129
130
  }
130
131
  }
131
132
  }
132
-
133
+
133
134
  return result
134
135
  }
135
136
 
@@ -140,4 +141,4 @@ function getDefaultTheme(): Theme {
140
141
  // Lazy import to avoid circular dependency
141
142
  const { modernTheme } = require('./modern')
142
143
  return modernTheme
143
- }
144
+ }
@@ -1,6 +0,0 @@
1
- /**
2
- * Shumoku Renderers
3
- */
4
-
5
- export { SVGRenderer, svgRenderer } from './svg.js'
6
- export type { SVGRendererOptions } from './svg.js'