@hkdigital/lib-sveltekit 0.1.55 → 0.1.57

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 (35) hide show
  1. package/dist/classes/svelte/audio/AudioScene.svelte.d.ts +8 -2
  2. package/dist/classes/svelte/audio/AudioScene.svelte.js +24 -11
  3. package/dist/components/area/HkArea.svelte.d.ts +14 -0
  4. package/dist/components/area/HkGridArea.svelte.d.ts +22 -0
  5. package/dist/components/buttons/button/Button.svelte.d.ts +23 -0
  6. package/dist/components/buttons/button-icon-steeze/SteezeIconButton.svelte.d.ts +9 -0
  7. package/dist/components/buttons/button-text/TextButton.svelte.d.ts +7 -0
  8. package/dist/components/debug/debug-panel-design-scaling/DebugPanelDesignScaling.svelte.d.ts +4 -0
  9. package/dist/components/hkdev/blocks/TextBlock.svelte.d.ts +13 -0
  10. package/dist/components/hkdev/buttons/CheckButton.svelte.d.ts +18 -0
  11. package/dist/components/icons/HkIcon.svelte.d.ts +12 -0
  12. package/dist/components/icons/HkTabIcon.svelte.d.ts +21 -0
  13. package/dist/components/icons/SteezeIcon.svelte.d.ts +12 -0
  14. package/dist/components/inputs/text-input/TextInput.svelte.d.ts +28 -0
  15. package/dist/components/layout/grid-layers/GridLayers.svelte.d.ts +23 -0
  16. package/dist/components/panels/panel/Panel.svelte.d.ts +13 -0
  17. package/dist/components/rows/panel-grid-row/PanelGridRow.svelte.d.ts +14 -0
  18. package/dist/components/rows/panel-row-2/PanelRow2.svelte.d.ts +14 -0
  19. package/dist/components/tab-bar/HkTabBar.svelte.d.ts +18 -0
  20. package/dist/components/tab-bar/HkTabBarSelector.svelte.d.ts +19 -0
  21. package/dist/design/tailwind-theme-extend.d.ts +4 -4
  22. package/dist/server/logger.d.ts +1 -0
  23. package/dist/util/design-system/skeleton.d.ts +1 -1
  24. package/dist/util/design-system/skeleton.js +141 -4
  25. package/dist/util/design-system/tailwind.d.ts +14 -9
  26. package/dist/util/design-system/tailwind.js +15 -16
  27. package/dist/widgets/button-group/ButtonGroup.svelte.d.ts +16 -0
  28. package/dist/widgets/compare-left-right/CompareLeftRight.svelte.d.ts +10 -0
  29. package/dist/widgets/game-box/GameBox.svelte.d.ts +41 -0
  30. package/dist/widgets/hk-app-layout/HkAppLayout.svelte.d.ts +11 -0
  31. package/dist/widgets/image-box/ImageBox.svelte.d.ts +20 -0
  32. package/dist/widgets/presenter/ImageSlide.svelte.d.ts +19 -0
  33. package/dist/widgets/presenter/Presenter.svelte.d.ts +10 -0
  34. package/dist/widgets/virtual-viewport/VirtualViewport.svelte.d.ts +22 -0
  35. package/package.json +1 -1
@@ -28,14 +28,20 @@ export default class AudioScene {
28
28
  }): void;
29
29
  /**
30
30
  * Start loading all audio sources
31
+ */
32
+ load(): void;
33
+ /**
34
+ * Set an audio context to use
31
35
  *
32
- * @param {AudioContext} audioContext
36
+ * @param {AudioContext} [audioContext]
33
37
  */
34
- load(audioContext: AudioContext): void;
38
+ setAudioContext(audioContext?: AudioContext): void;
35
39
  /**
36
40
  * Get a source that can be used to play the audio once
37
41
  *
38
42
  * @param {string} label
43
+ *
44
+ * @returns {Promise<AudioBufferSourceNode>}
39
45
  */
40
46
  getSourceNode(label: string): Promise<AudioBufferSourceNode>;
41
47
  #private;
@@ -81,9 +81,6 @@ export default class AudioScene {
81
81
 
82
82
  /**
83
83
  * Construct AudioScene
84
- *
85
- * @param {object} _
86
- * @param {AudioContext} _.audioContext
87
84
  */
88
85
  constructor() {
89
86
  const state = this.#state;
@@ -172,12 +169,8 @@ export default class AudioScene {
172
169
 
173
170
  /**
174
171
  * Start loading all audio sources
175
- *
176
- * @param {AudioContext} audioContext
177
172
  */
178
- load(audioContext) {
179
- this.#audioContext = audioContext;
180
- // console.log(123);
173
+ load() {
181
174
  this.#state.send(LOAD);
182
175
 
183
176
  // FIXME: in unit test when moved to startloading it hangs!
@@ -187,6 +180,15 @@ export default class AudioScene {
187
180
  }
188
181
  }
189
182
 
183
+ /**
184
+ * Set an audio context to use
185
+ *
186
+ * @param {AudioContext} [audioContext]
187
+ */
188
+ setAudioContext( audioContext ) {
189
+ this.#audioContext = audioContext;
190
+ }
191
+
190
192
  async #startLoading() {
191
193
  console.log('#startLoading');
192
194
 
@@ -200,6 +202,8 @@ export default class AudioScene {
200
202
  * Get a source that can be used to play the audio once
201
203
  *
202
204
  * @param {string} label
205
+ *
206
+ * @returns {Promise<AudioBufferSourceNode>}
203
207
  */
204
208
  async getSourceNode(label) {
205
209
  // @note Gain setup
@@ -212,12 +216,11 @@ export default class AudioScene {
212
216
  }
213
217
 
214
218
  const sourceNode = await audioLoader.getAudioBufferSourceNode(
215
- // @ts-ignore
216
- this.#audioContext
219
+ this.#getAudioContext()
217
220
  );
218
221
 
219
222
  // @ts-ignore
220
- sourceNode.connect(this.#audioContext.destination);
223
+ sourceNode.connect(this.#getAudioContext().destination);
221
224
 
222
225
  // Clean up
223
226
  sourceNode.onended = () => {
@@ -228,6 +231,16 @@ export default class AudioScene {
228
231
  return sourceNode;
229
232
  }
230
233
 
234
+ #getAudioContext()
235
+ {
236
+ if( !this.#audioContext )
237
+ {
238
+ this.#audioContext = new AudioContext();
239
+ }
240
+
241
+ return this.#audioContext;
242
+ }
243
+
231
244
  /**
232
245
  * Get memory source
233
246
  *
@@ -1,4 +1,18 @@
1
1
  export default HkArea;
2
+ type HkArea = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ base?: string;
6
+ bg?: string;
7
+ padding?: string;
8
+ margin?: string;
9
+ classes?: string;
10
+ style?: string;
11
+ children: Snippet<[]>;
12
+ } & {
13
+ [attr: string]: any;
14
+ }>): void;
15
+ };
2
16
  declare const HkArea: import("svelte").Component<{
3
17
  base?: string;
4
18
  bg?: string;
@@ -1,4 +1,26 @@
1
1
  export default HkGridArea;
2
+ type HkGridArea = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ base?: string;
6
+ bg?: string;
7
+ padding?: string;
8
+ margin?: string;
9
+ classes?: string;
10
+ style?: string;
11
+ boxBase?: string;
12
+ boxBg?: string;
13
+ boxPadding?: string;
14
+ boxMargin?: string;
15
+ boxClasses?: string;
16
+ boxAttrs?: {
17
+ [attr: string]: any;
18
+ };
19
+ children: Snippet<[]>;
20
+ } & {
21
+ [attr: string]: any;
22
+ }>): void;
23
+ };
2
24
  declare const HkGridArea: import("svelte").Component<{
3
25
  base?: string;
4
26
  bg?: string;
@@ -1,4 +1,27 @@
1
1
  export default Button;
2
+ type Button = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ [key: string]: any;
6
+ base?: string;
7
+ bg?: string;
8
+ classes?: string;
9
+ type?: string;
10
+ role?: "custom" | "primary" | "secondary" | "tertiary";
11
+ size?: "sm" | "md" | "lg";
12
+ variant?: string;
13
+ mode?: "light" | "dark";
14
+ buttonType?: "reset" | "submit" | "button";
15
+ active?: boolean;
16
+ selected?: boolean;
17
+ loading?: boolean;
18
+ error?: boolean;
19
+ disabled?: boolean;
20
+ snippetLoading?: Snippet<[]>;
21
+ snippetError?: Snippet<[]>;
22
+ children: Snippet<[]>;
23
+ }>): void;
24
+ };
2
25
  declare const Button: import("svelte").Component<{
3
26
  [key: string]: any;
4
27
  base?: string;
@@ -1,4 +1,13 @@
1
1
  export default SteezeIconButton;
2
+ type SteezeIconButton = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ [key: string]: any;
6
+ src: IconSource;
7
+ iconSize?: string;
8
+ theme?: string;
9
+ }>): void;
10
+ };
2
11
  declare const SteezeIconButton: import("svelte").Component<{
3
12
  [key: string]: any;
4
13
  src: import("../../icons/typedef.js").IconSource;
@@ -1,4 +1,11 @@
1
1
  export default TextButton;
2
+ type TextButton = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ [key: string]: any;
6
+ children: Snippet<[]>;
7
+ }>): void;
8
+ };
2
9
  declare const TextButton: import("svelte").Component<{
3
10
  [key: string]: any;
4
11
  children: import("svelte").Snippet;
@@ -1,2 +1,6 @@
1
1
  export default DebugPanelDesignScaling;
2
+ type DebugPanelDesignScaling = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Record<string, never>>): void;
5
+ };
2
6
  declare const DebugPanelDesignScaling: import("svelte").Component<Record<string, never>, {}, "">;
@@ -1,4 +1,17 @@
1
1
  export default TextBlock;
2
+ type TextBlock = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ base?: string;
6
+ bg?: string;
7
+ classes?: string;
8
+ title?: Snippet<[]>;
9
+ content?: Snippet<[]>;
10
+ footer?: Snippet<[]>;
11
+ } & {
12
+ [attr: string]: any;
13
+ }>): void;
14
+ };
2
15
  declare const TextBlock: import("svelte").Component<{
3
16
  base?: string;
4
17
  bg?: string;
@@ -1,4 +1,22 @@
1
1
  export default CheckButton;
2
+ type CheckButton = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ checked?: boolean;
6
+ activeChild?: boolean;
7
+ inactiveChild?: boolean;
8
+ iconActiveBase?: string;
9
+ classes?: string;
10
+ disabled?: boolean;
11
+ title: string;
12
+ iconInactiveBase?: string;
13
+ inactiveClasses?: string;
14
+ activeClasses: string;
15
+ onclick?: () => void;
16
+ onchange?: () => void;
17
+ topic?: string;
18
+ }>): void;
19
+ };
2
20
  declare const CheckButton: import("svelte").Component<{
3
21
  checked?: boolean;
4
22
  activeChild?: boolean;
@@ -1,4 +1,16 @@
1
1
  export default HkIcon;
2
+ type HkIcon = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ src: IconSource;
6
+ size?: string;
7
+ theme?: string;
8
+ base?: string;
9
+ classes?: string;
10
+ } & {
11
+ [attr: string]: any;
12
+ }>): void;
13
+ };
2
14
  declare const HkIcon: import("svelte").Component<{
3
15
  src: import("./typedef.js").IconSource;
4
16
  size?: string;
@@ -1,4 +1,25 @@
1
1
  export default HkTabIcon;
2
+ type HkTabIcon = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ src: IconSource;
6
+ iconTheme?: string;
7
+ label?: string;
8
+ route?: string;
9
+ active?: boolean;
10
+ base?: string;
11
+ bg?: string;
12
+ padding?: string;
13
+ margin?: string;
14
+ classes?: string;
15
+ iconClasses?: string;
16
+ iconHeight?: string;
17
+ labelClasses?: string;
18
+ rect?: DOMRect;
19
+ } & {
20
+ [attr: string]: any;
21
+ }>): void;
22
+ };
2
23
  declare const HkTabIcon: import("svelte").Component<{
3
24
  src: import("./typedef.js").IconSource;
4
25
  iconTheme?: string;
@@ -1,4 +1,16 @@
1
1
  export default SteezeIcon;
2
+ type SteezeIcon = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ src: IconSource;
6
+ size?: string;
7
+ theme?: string;
8
+ base?: string;
9
+ classes?: string;
10
+ } & {
11
+ [attr: string]: any;
12
+ }>): void;
13
+ };
2
14
  declare const SteezeIcon: import("svelte").Component<{
3
15
  src: import("./typedef.js").IconSource;
4
16
  size?: string;
@@ -1,4 +1,32 @@
1
1
  export default TextInput;
2
+ type TextInput = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ base?: string;
6
+ borderShape?: string;
7
+ classes?: string;
8
+ inputBase?: string;
9
+ inputClasses?: string;
10
+ legendBase?: string;
11
+ legendClasses?: string;
12
+ iconClasses?: string;
13
+ value?: string;
14
+ type?: "number" | "url" | "text" | "email";
15
+ pattern?: string;
16
+ required?: boolean;
17
+ title?: string;
18
+ placeholder?: string;
19
+ isValid?: boolean;
20
+ isPristine?: boolean;
21
+ hasFocus?: boolean;
22
+ validate?: (value: string) => string;
23
+ iconRequired?: Snippet<[]>;
24
+ iconValid?: Snippet<[]>;
25
+ iconInvalid?: Snippet<[]>;
26
+ } & {
27
+ [attr: string]: any;
28
+ }>): void;
29
+ };
2
30
  declare const TextInput: import("svelte").Component<{
3
31
  base?: string;
4
32
  borderShape?: string;
@@ -1,4 +1,27 @@
1
1
  export default GridLayers;
2
+ type GridLayers = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ [attr: string]: any;
6
+ base?: string;
7
+ bg?: string;
8
+ padding?: string;
9
+ margin?: string;
10
+ height?: string;
11
+ classes?: string;
12
+ style?: string;
13
+ cellBase?: string;
14
+ cellBg?: string;
15
+ cellPadding?: string;
16
+ cellMargin?: string;
17
+ cellClasses?: string;
18
+ cellStyle?: string;
19
+ children: Snippet<[]>;
20
+ cellAttrs?: {
21
+ [attr: string]: any;
22
+ };
23
+ }>): void;
24
+ };
2
25
  declare const GridLayers: import("svelte").Component<{
3
26
  [attr: string]: any;
4
27
  base?: string;
@@ -1,4 +1,17 @@
1
1
  export default Panel;
2
+ type Panel = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ base?: string;
6
+ bg?: string;
7
+ classes?: string;
8
+ width?: "sm" | "md" | "lg";
9
+ variant?: string;
10
+ children?: Snippet<[]>;
11
+ } & {
12
+ [attr: string]: any;
13
+ }>): void;
14
+ };
2
15
  declare const Panel: import("svelte").Component<{
3
16
  base?: string;
4
17
  bg?: string;
@@ -1,4 +1,18 @@
1
1
  export default PanelGridRow;
2
+ type PanelGridRow = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ base?: string;
6
+ bg?: string;
7
+ justify?: "start" | "center" | "end" | "between" | "around" | "evenly" | "stretch" | "normal";
8
+ justifyItems?: "start" | "center" | "end" | "stretch";
9
+ gap?: string;
10
+ classes?: string;
11
+ children?: Snippet<[]>;
12
+ } & {
13
+ [attr: string]: any;
14
+ }>): void;
15
+ };
2
16
  declare const PanelGridRow: import("svelte").Component<{
3
17
  base?: string;
4
18
  bg?: string;
@@ -1,4 +1,18 @@
1
1
  export default PanelRow2;
2
+ type PanelRow2 = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ base?: string;
6
+ bg?: string;
7
+ justify?: "start" | "center" | "end" | "between" | "around" | "evenly" | "stretch" | "normal";
8
+ justifyItems?: "start" | "center" | "end" | "stretch";
9
+ gap?: string;
10
+ classes?: string;
11
+ children?: Snippet<[]>;
12
+ } & {
13
+ [attr: string]: any;
14
+ }>): void;
15
+ };
2
16
  declare const PanelRow2: import("svelte").Component<{
3
17
  base?: string;
4
18
  bg?: string;
@@ -1,4 +1,22 @@
1
1
  export default HkTabBar;
2
+ type HkTabBar = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ cols?: number;
6
+ base?: string;
7
+ bg?: string;
8
+ padding?: string;
9
+ margin?: string;
10
+ classes?: string;
11
+ style?: string;
12
+ instanceKey?: string | Symbol;
13
+ children: Snippet<[]>;
14
+ onmount?: Function;
15
+ domElem?: HTMLElement;
16
+ } & {
17
+ [attr: string]: any;
18
+ }>): void;
19
+ };
2
20
  declare const HkTabBar: import("svelte").Component<{
3
21
  cols?: number;
4
22
  base?: string;
@@ -1,4 +1,23 @@
1
1
  export default HkTabBarSelector;
2
+ type HkTabBarSelector = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ base?: string;
6
+ bg?: string;
7
+ classes?: string;
8
+ boxBase?: string;
9
+ boxBg?: string;
10
+ boxPadding?: string;
11
+ boxMargin?: string;
12
+ boxClasses?: string;
13
+ boxAttrs?: {
14
+ [attr: string]: any;
15
+ };
16
+ instanceKey?: string | Symbol;
17
+ } & {
18
+ [attr: string]: any;
19
+ }>): void;
20
+ };
2
21
  declare const HkTabBarSelector: import("svelte").Component<{
3
22
  base?: string;
4
23
  bg?: string;
@@ -10,14 +10,14 @@ export const borderRadius: {
10
10
  [x: string]: string;
11
11
  };
12
12
  export const borderWidth: {
13
- [x: string]: string;
13
+ [key: string]: string;
14
14
  };
15
15
  export const strokeWidth: {
16
- [x: string]: string;
16
+ [key: string]: string;
17
17
  };
18
18
  export const outlineWidth: {
19
- [x: string]: string;
19
+ [key: string]: string;
20
20
  };
21
21
  export const outlineOffset: {
22
- [x: string]: string;
22
+ [key: string]: string;
23
23
  };
@@ -22,3 +22,4 @@ export type LoggerExtension = {
22
22
  */
23
23
  /** @type {pino.Logger & LoggerExtension} */
24
24
  export const logger: pino.Logger & LoggerExtension;
25
+ import pino from 'pino';
@@ -36,6 +36,6 @@
36
36
  * @param {Object} api - Tailwind plugin API
37
37
  * @param {Function} api.addUtilities - Function to add utilities
38
38
  */
39
- export function customUtilitiesPlugin({ addUtilities }: {
39
+ export function customUtilitiesPlugin({ addUtilities, theme }: {
40
40
  addUtilities: Function;
41
41
  }): void;
@@ -36,8 +36,8 @@
36
36
  * @param {Object} api - Tailwind plugin API
37
37
  * @param {Function} api.addUtilities - Function to add utilities
38
38
  */
39
- export function customUtilitiesPlugin({ addUtilities }) {
40
- const utilities = {
39
+ export function customUtilitiesPlugin({ addUtilities, theme }) {
40
+ const fontFamilyUtilities = {
41
41
  '.font-heading': {
42
42
  'font-family': 'var(--heading-font-family)'
43
43
  },
@@ -46,7 +46,10 @@ export function customUtilitiesPlugin({ addUtilities }) {
46
46
  },
47
47
  '.font-ui': {
48
48
  'font-family': 'var(--ui-font-family, var(--base-font-family))'
49
- },
49
+ }
50
+ };
51
+
52
+ const textColorUtilities = {
50
53
  '.text-base-color': {
51
54
  color: 'rgb( var(--base-font-color) )'
52
55
  },
@@ -67,5 +70,139 @@ export function customUtilitiesPlugin({ addUtilities }) {
67
70
  }
68
71
  };
69
72
 
70
- addUtilities(utilities);
73
+ const typographyUtilities = generateTypographyUtilities(theme);
74
+
75
+ addUtilities({
76
+ ...typographyUtilities,
77
+ ...fontFamilyUtilities,
78
+ ...textColorUtilities
79
+ });
80
+ }
81
+
82
+ /**
83
+ * Generates typography utility classes based on fontSize entries in the
84
+ * Tailwind theme
85
+ *
86
+ * This function creates typography utility classes for entries in the
87
+ * theme's fontSize configuration that start with 'heading-', 'base-', or
88
+ * 'ui-' prefixes. Each class includes font size, line height, font weight,
89
+ * font family, and color properties.
90
+ *
91
+ * @param {Function} theme - Tailwind's theme function to access configuration
92
+ * @returns {Object} An object containing the generated typography utility classes
93
+ *
94
+ * @example
95
+ * // In your Tailwind plugin:
96
+ * const typographyUtils = generateTypographyUtilities(theme);
97
+ * addUtilities(typographyUtils);
98
+ *
99
+ * @example
100
+ * // Example output format:
101
+ * // {
102
+ * // '.type-heading-h1': {
103
+ * // fontSize: 'calc(32px * var(--scale-text-heading))',
104
+ * // lineHeight: '1.25',
105
+ * // fontWeight: '700',
106
+ * // fontFamily: 'var(--heading-font-family)',
107
+ * // fontStyle: 'var(--heading-font-style)',
108
+ * // letterSpacing: 'var(--heading-letter-spacing)',
109
+ * // color: 'rgb(var(--heading-font-color))'
110
+ * // }
111
+ * // }
112
+ */
113
+ function generateTypographyUtilities(theme) {
114
+ // Get font sizes from theme
115
+ const fontSizes = theme('fontSize');
116
+
117
+ // Create typography utilities
118
+ const typographyUtilities = {};
119
+
120
+ // Process all fontSize entries and create type- classes for them
121
+ Object.entries(fontSizes).forEach(([key, value]) => {
122
+ // Skip entries that don't match our prefixes
123
+ if (
124
+ !key.startsWith('heading-') &&
125
+ !key.startsWith('base-') &&
126
+ !key.startsWith('ui-')
127
+ ) {
128
+ return;
129
+ }
130
+
131
+ const [size, options] = Array.isArray(value) ? value : [value, {}];
132
+
133
+ // Determine properties based on the prefix
134
+ let properties = {};
135
+
136
+ let propertiesDark;
137
+
138
+ if (key.startsWith('heading-')) {
139
+ properties = {
140
+ lineHeight: options.lineHeight || 'normal',
141
+ fontFamily: 'var(--heading-font-family)',
142
+ fontStyle: 'var(--heading-font-style)',
143
+ fontWeight: 'var(--heading-font-weight)',
144
+ letterSpacing: 'var(--heading-letter-spacing)',
145
+ color: 'rgb(var(--heading-font-color))'
146
+ };
147
+
148
+ propertiesDark = {
149
+ ...properties,
150
+ color: 'rgb(var(--heading-font-color-dark))'
151
+ };
152
+ } else if (key.startsWith('base-')) {
153
+ properties = {
154
+ lineHeight: options.lineHeight || 'normal',
155
+ fontFamily: 'var(--base-font-family)',
156
+ fontWeight: 'var(--base-font-weight)',
157
+ letterSpacing: 'var(--base-letter-spacing)',
158
+ color: 'rgb(var(--base-font-color))'
159
+ };
160
+
161
+ propertiesDark = {
162
+ ...properties,
163
+ color: 'rgb(var(--base-font-color-dark))'
164
+ };
165
+ } else if (key.startsWith('ui-')) {
166
+ properties = {
167
+ lineHeight: options.lineHeight || 'normal',
168
+ fontFamily: 'var(--ui-font-family, var(--base-font-family))',
169
+ fontWeight: 'var(--ui-font-weight)',
170
+ letterSpacing: 'var(--ui-letter-spacing, var(--base-letter-spacing))',
171
+ color: 'rgb(var(--ui-font-color, var(--base-font-color)))'
172
+ };
173
+
174
+ propertiesDark = {
175
+ ...properties,
176
+ color: 'rgb(var(--ui-font-color-dark, var(--base-font-color-dark)))'
177
+ };
178
+ }
179
+
180
+ // Create the utility class using the original key
181
+ typographyUtilities[`.type-${key}`] = {
182
+ fontSize: size,
183
+ ...properties,
184
+ // Include any other properties defined in the fontSize options
185
+ ...Object.fromEntries(
186
+ Object.entries(options).filter(
187
+ ([k]) => !['lineHeight'].includes(k)
188
+ )
189
+ )
190
+ };
191
+
192
+ // Create the utility class using the original key for dark
193
+ typographyUtilities[`.type-${key}-dark`] = {
194
+ fontSize: size,
195
+ ...propertiesDark,
196
+ // Include any other properties defined in the fontSize options
197
+ ...Object.fromEntries(
198
+ Object.entries(options).filter(
199
+ ([k]) => !['lineHeight'].includes(k)
200
+ )
201
+ )
202
+ };
203
+ });
204
+
205
+ // console.debug(typographyUtilities);
206
+
207
+ return typographyUtilities;
71
208
  }
@@ -54,12 +54,18 @@ export function generateTextBasedSpacing(values: number[]): {
54
54
  export function generateViewportBasedSpacing(values: number[]): {
55
55
  [x: string]: string;
56
56
  };
57
+ /**
58
+ * @typedef {{
59
+ * size?: number,
60
+ * lineHeight?: number|string
61
+ * }} TextStyleSizes
62
+ */
57
63
  /**
58
64
  * Generates semantic text style definitions for a specific text category
59
65
  * (base, UI, or heading). Each style includes a scaled font size and
60
66
  * line height.
61
67
  *
62
- * @param {{[key: string]: {size: number, lineHeight?: number}}} sizes
68
+ * @param {{[key: string]: TextStyleSizes}} configs
63
69
  * Set of text sizes to generate styles for
64
70
  *
65
71
  * @param {'base' | 'ui' | 'heading'} category
@@ -73,7 +79,7 @@ export function generateViewportBasedSpacing(values: number[]): {
73
79
  * @example
74
80
  * const TEXT_BASE_SIZES = {
75
81
  * sm: { size: 16, lineHeight: 1.5 },
76
- * base: { size: 20, lineHeight: 1.5 },
82
+ * md: { size: 20, lineHeight: 1.5 },
77
83
  * lg: { size: 24, lineHeight: 1.4 }
78
84
  * };
79
85
  *
@@ -82,18 +88,13 @@ export function generateViewportBasedSpacing(values: number[]): {
82
88
  * // {
83
89
  * // 'base-sm':
84
90
  * // ['calc(16px * var(--scale-text-base))', { lineHeight: 1.5 }],
85
- * // 'base-base':
91
+ * // 'base-md':
86
92
  * // ['calc(20px * var(--scale-text-base))', { lineHeight: 1.5 }],
87
93
  * // 'base-lg':
88
94
  * // ['calc(24px * var(--scale-text-base))', { lineHeight: 1.4 }]
89
95
  * // }
90
96
  */
91
- export function generateTextStyles(sizes: {
92
- [key: string]: {
93
- size: number;
94
- lineHeight?: number;
95
- };
96
- }, category: "base" | "ui" | "heading"): {
97
+ export function generateTextStyles(sizes: any, category: "base" | "ui" | "heading"): {
97
98
  [key: string]: [string, {
98
99
  lineHeight: number;
99
100
  }];
@@ -174,3 +175,7 @@ export function generateWidthStyles(sizes: {
174
175
  }, prefix?: string, scaleVar?: string): {
175
176
  [key: string]: string;
176
177
  };
178
+ export type TextStyleSizes = {
179
+ size?: number;
180
+ lineHeight?: number | string;
181
+ };
@@ -93,12 +93,19 @@ export function generateViewportBasedSpacing(values) {
93
93
  }, {});
94
94
  }
95
95
 
96
+ /**
97
+ * @typedef {{
98
+ * size?: number,
99
+ * lineHeight?: number|string
100
+ * }} TextStyleSizes
101
+ */
102
+
96
103
  /**
97
104
  * Generates semantic text style definitions for a specific text category
98
105
  * (base, UI, or heading). Each style includes a scaled font size and
99
106
  * line height.
100
107
  *
101
- * @param {{[key: string]: {size: number, lineHeight?: number}}} sizes
108
+ * @param {{[key: string]: TextStyleSizes}} configs
102
109
  * Set of text sizes to generate styles for
103
110
  *
104
111
  * @param {'base' | 'ui' | 'heading'} category
@@ -112,7 +119,7 @@ export function generateViewportBasedSpacing(values) {
112
119
  * @example
113
120
  * const TEXT_BASE_SIZES = {
114
121
  * sm: { size: 16, lineHeight: 1.5 },
115
- * base: { size: 20, lineHeight: 1.5 },
122
+ * md: { size: 20, lineHeight: 1.5 },
116
123
  * lg: { size: 24, lineHeight: 1.4 }
117
124
  * };
118
125
  *
@@ -121,7 +128,7 @@ export function generateViewportBasedSpacing(values) {
121
128
  * // {
122
129
  * // 'base-sm':
123
130
  * // ['calc(16px * var(--scale-text-base))', { lineHeight: 1.5 }],
124
- * // 'base-base':
131
+ * // 'base-md':
125
132
  * // ['calc(20px * var(--scale-text-base))', { lineHeight: 1.5 }],
126
133
  * // 'base-lg':
127
134
  * // ['calc(24px * var(--scale-text-base))', { lineHeight: 1.4 }]
@@ -129,7 +136,7 @@ export function generateViewportBasedSpacing(values) {
129
136
  */
130
137
  export function generateTextStyles(sizes, category) {
131
138
  if (!sizes || typeof sizes !== 'object') {
132
- throw new Error('sizes must be an object');
139
+ throw new Error('configs must be an object');
133
140
  }
134
141
 
135
142
  if (!['base', 'ui', 'heading'].includes(category)) {
@@ -150,20 +157,12 @@ export function generateTextStyles(sizes, category) {
150
157
  );
151
158
  }
152
159
 
153
- if (
154
- config.lineHeight !== undefined &&
155
- typeof config.lineHeight !== 'number'
156
- ) {
157
- throw new Error(
158
- `Invalid lineHeight for "${category}-${variant}": must be a number`
159
- );
160
- }
161
-
162
- const { size, lineHeight = 1.5 } = config;
160
+ const extraProps = { ...config };
161
+ delete extraProps.size;
163
162
 
164
163
  result[`${category}-${variant}`] = [
165
- `calc(${size}px * var(--scale-text-${category}))`,
166
- { lineHeight }
164
+ `calc(${config.size}px * var(--scale-text-${category}))`,
165
+ extraProps
167
166
  ];
168
167
 
169
168
  return result;
@@ -1,4 +1,20 @@
1
1
  export default ButtonGroup;
2
+ type ButtonGroup = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ [attr: string]: any;
6
+ base?: string;
7
+ bg?: string;
8
+ classes?: string;
9
+ buttons: ButtonDef[];
10
+ selected?: ButtonDef;
11
+ select?: (label: string) => void;
12
+ buttonSnippet: Snippet<[{
13
+ text: string;
14
+ props: any;
15
+ }]>;
16
+ }>): void;
17
+ };
2
18
  declare const ButtonGroup: import("svelte").Component<{
3
19
  [attr: string]: any;
4
20
  base?: string;
@@ -1,4 +1,14 @@
1
1
  export default CompareLeftRight;
2
+ type CompareLeftRight = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ leftContent?: Snippet<[]>;
6
+ rightContent?: Snippet<[]>;
7
+ classes?: string;
8
+ dividerColor?: string;
9
+ handleColor?: string;
10
+ } & Record<string, any>>): void;
11
+ };
2
12
  declare const CompareLeftRight: import("svelte").Component<{
3
13
  leftContent?: import("svelte").Snippet;
4
14
  rightContent?: import("svelte").Snippet;
@@ -1,4 +1,45 @@
1
1
  export default GameBox;
2
+ type GameBox = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ [attr: string]: any;
6
+ base?: string;
7
+ bg?: string;
8
+ classes?: string;
9
+ style?: string;
10
+ aspectOnLandscape?: number;
11
+ aspectOnPortrait?: number;
12
+ enableScaling?: boolean;
13
+ designLandscape?: {
14
+ width: number;
15
+ height: number;
16
+ };
17
+ designPortrait?: {
18
+ width: number;
19
+ height: number;
20
+ };
21
+ clamping?: {
22
+ ui: {
23
+ min: number;
24
+ max: number;
25
+ };
26
+ textBase: {
27
+ min: number;
28
+ max: number;
29
+ };
30
+ textHeading: {
31
+ min: number;
32
+ max: number;
33
+ };
34
+ textUi: {
35
+ min: number;
36
+ max: number;
37
+ };
38
+ };
39
+ snippetLandscape?: Snippet<[]>;
40
+ snippetPortrait?: Snippet<[]>;
41
+ }>): void;
42
+ };
2
43
  declare const GameBox: import("svelte").Component<{
3
44
  [attr: string]: any;
4
45
  base?: string;
@@ -1,4 +1,8 @@
1
1
  export default HkAppLayout;
2
+ type HkAppLayout = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<AppLayoutProps>): void;
5
+ };
2
6
  declare const HkAppLayout: import("svelte").Component<{
3
7
  bgPageSnippet?: import("svelte").Snippet | undefined;
4
8
  bgSnippet?: import("svelte").Snippet | undefined;
@@ -6,3 +10,10 @@ declare const HkAppLayout: import("svelte").Component<{
6
10
  bottomSnippet?: import("svelte").Snippet | undefined;
7
11
  children: import("svelte").Snippet;
8
12
  }, {}, "">;
13
+ type AppLayoutProps = {
14
+ bgPageSnippet?: import("svelte").Snippet | undefined;
15
+ bgSnippet?: import("svelte").Snippet | undefined;
16
+ topSnippet?: import("svelte").Snippet | undefined;
17
+ bottomSnippet?: import("svelte").Snippet | undefined;
18
+ children: import("svelte").Snippet;
19
+ };
@@ -1,4 +1,24 @@
1
1
  export default ImageBox;
2
+ type ImageBox = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ [attr: string]: any;
6
+ base?: string;
7
+ bg?: string;
8
+ classes?: string;
9
+ width?: string;
10
+ height?: string;
11
+ aspect?: string;
12
+ overflow?: string;
13
+ fit?: "fill" | "cover" | "contain";
14
+ position?: string;
15
+ imageMeta?: ImageMeta | ImageMeta[];
16
+ imageLoader?: ImageLoader;
17
+ alt?: string;
18
+ id?: string | Symbol;
19
+ onProgress?: (progress: LoadingProgress, id: string | Symbol) => void;
20
+ }>): void;
21
+ };
2
22
  declare const ImageBox: import("svelte").Component<{
3
23
  [attr: string]: any;
4
24
  base?: string;
@@ -1,4 +1,23 @@
1
1
  export default ImageSlide;
2
+ type ImageSlide = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ [attr: string]: any;
6
+ imageMeta?: any;
7
+ slideDuration?: number;
8
+ nextSlideLabel?: string;
9
+ presenter?: {
10
+ gotoSlide: (name: string) => void;
11
+ getCurrentSlideName: () => string;
12
+ };
13
+ getLoadingController?: () => {
14
+ loaded: () => void;
15
+ cancel: () => void;
16
+ };
17
+ fit?: "fill" | "cover" | "contain";
18
+ position?: string;
19
+ }>): void;
20
+ };
2
21
  declare const ImageSlide: import("svelte").Component<{
3
22
  [attr: string]: any;
4
23
  imageMeta?: any | any[];
@@ -1,4 +1,14 @@
1
1
  export default Presenter;
2
+ type Presenter = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ classes?: string;
6
+ slides?: Slide[];
7
+ presenterRef?: PresenterRef;
8
+ layoutSnippet: Snippet<[Slide, Layer]>;
9
+ loadingSnippet?: Snippet<[]>;
10
+ }>): void;
11
+ };
2
12
  declare const Presenter: import("svelte").Component<{
3
13
  classes?: string;
4
14
  slides?: import("./typedef.js").Slide[];
@@ -1,4 +1,26 @@
1
1
  export default VirtualViewport;
2
+ type VirtualViewport = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ [attr: string]: any;
6
+ base?: string;
7
+ bg?: string;
8
+ classes?: string;
9
+ width?: string;
10
+ height?: string;
11
+ overflow?: string;
12
+ designWidth?: number;
13
+ designHeight?: number;
14
+ scaleViewport?: number;
15
+ scaleW?: number;
16
+ scaleH?: number;
17
+ scaleUI?: number;
18
+ scaleTextBase?: number;
19
+ scaleTextHeading?: number;
20
+ scaleTextUI?: number;
21
+ children?: Snippet<[]>;
22
+ }>): void;
23
+ };
2
24
  declare const VirtualViewport: import("svelte").Component<{
3
25
  [attr: string]: any;
4
26
  base?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"