@lightningtv/solid 3.1.8 → 3.1.10

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.
@@ -43,7 +43,7 @@ export function getNodeLineHeight(props: {
43
43
  fontSize: number;
44
44
  }): number {
45
45
  return (
46
- props.lineHeight ?? Config.fontSettings.lineHeight ?? 1.2 * props.fontSize
46
+ props.lineHeight || Config.fontSettings.lineHeight || 1.2 * props.fontSize
47
47
  );
48
48
  }
49
49
 
@@ -184,10 +184,11 @@ function interpolate(start: number, end: number, t: number): number {
184
184
 
185
185
  function interpolateColor(start: number, end: number, t: number): number {
186
186
  return (
187
- (interpolate((start >> 24) & 0xff, (end >> 24) & 0xff, t) << 24) |
188
- (interpolate((start >> 16) & 0xff, (end >> 16) & 0xff, t) << 16) |
189
- (interpolate((start >> 8) & 0xff, (end >> 8) & 0xff, t) << 8) |
190
- interpolate(start & 0xff, end & 0xff, t)
187
+ ((interpolate((start >> 24) & 0xff, (end >> 24) & 0xff, t) << 24) |
188
+ (interpolate((start >> 16) & 0xff, (end >> 16) & 0xff, t) << 16) |
189
+ (interpolate((start >> 8) & 0xff, (end >> 8) & 0xff, t) << 8) |
190
+ interpolate(start & 0xff, end & 0xff, t)) >>>
191
+ 0
191
192
  );
192
193
  }
193
194
 
@@ -786,7 +786,8 @@ export class ElementNode extends Object {
786
786
  (Config.fontWeightAlias &&
787
787
  (Config.fontWeightAlias[v as string] as number | string)) ??
788
788
  v;
789
- (this.lng as any).fontFamily = `${this.fontFamily}${weight}`;
789
+ (this.lng as any).fontFamily =
790
+ `${this.fontFamily || Config.fontSettings?.fontFamily}${weight}`;
790
791
  }
791
792
 
792
793
  get fontWeight() {
@@ -799,7 +800,7 @@ export class ElementNode extends Object {
799
800
  }
800
801
 
801
802
  get fontFamily() {
802
- return this._fontFamily || Config.fontSettings?.fontFamily;
803
+ return this._fontFamily;
803
804
  }
804
805
 
805
806
  insertChild(
@@ -23,13 +23,19 @@ export type AddColorString<T> = {
23
23
  [K in keyof T]: K extends `color${string}` ? string | number : T[K];
24
24
  };
25
25
 
26
- export interface BorderStyleObject extends Partial<lngr.BorderProps> {
26
+ export interface BorderStyleObject
27
+ extends AddColorString<Partial<lngr.BorderProps>> {
27
28
  width?: number | [number, number, number, number];
29
+ gap?: number;
30
+ align?: 'inside' | 'outside' | 'center';
28
31
  }
29
32
 
30
- export interface SingleBorderStyleObject extends Partial<lngr.BorderProps> {
33
+ export interface SingleBorderStyleObject
34
+ extends AddColorString<Partial<lngr.BorderProps>> {
31
35
  width?: number;
32
36
  w?: number;
37
+ gap?: number;
38
+ align?: 'inside' | 'outside' | 'center';
33
39
  }
34
40
 
35
41
  export type DollarString = `$${string}`;
@@ -39,10 +39,13 @@ function createVirtual<T>(
39
39
  const scrollType = s.createMemo(() => props.scroll || 'auto');
40
40
 
41
41
  const selected = () => {
42
+ if (itemCount() <= props.displaySize) {
43
+ return utils.clamp(props.selected || 0, 0, Math.max(0, itemCount() - 1));
44
+ }
42
45
  if (props.wrap) {
43
46
  return Math.max(bufferSize(), scrollIndex());
44
47
  }
45
- return props.selected || 0;
48
+ return utils.clamp(props.selected || 0, 0, Math.max(0, itemCount() - 1));
46
49
  };
47
50
 
48
51
  let cachedScaledSize: number | undefined;
@@ -116,6 +119,18 @@ function createVirtual<T>(
116
119
  cursor: 0,
117
120
  };
118
121
 
122
+ if (total <= props.displaySize) {
123
+ return {
124
+ start: 0,
125
+ slice: items() as T[],
126
+ selected: utils.clamp(c, 0, total - 1),
127
+ delta,
128
+ shiftBy: 0,
129
+ atStart: c <= 0,
130
+ cursor: utils.clamp(c, 0, total - 1),
131
+ };
132
+ }
133
+
119
134
  const length = props.displaySize + bufferSize();
120
135
  let start = prev.start;
121
136
  let selected = prev.selected;
@@ -457,9 +472,10 @@ function createVirtual<T>(
457
472
 
458
473
  const updateSelected = ([sel, _items]: [number?, any?]) => {
459
474
  if (!viewRef || sel === undefined || itemCount() === 0) return;
460
- const item = items()[sel];
461
- setCursor(sel);
462
- const newState = computeSlice(cursor(), 0, slice());
475
+ const safeSel = utils.clamp(sel, 0, itemCount() - 1);
476
+ const item = items()[safeSel];
477
+ setCursor(safeSel);
478
+ const newState = computeSlice(safeSel, 0, slice());
463
479
  setSlice(newState);
464
480
 
465
481
  queueMicrotask(() => {
@@ -487,6 +503,13 @@ function createVirtual<T>(
487
503
  s.on([() => props.wrap, items], () => {
488
504
  if (!viewRef || itemCount() === 0 || !props.wrap || doOnce) return;
489
505
  doOnce = true;
506
+ if (itemCount() <= props.displaySize) {
507
+ queueMicrotask(() => {
508
+ originalPosition = viewRef.lng[axis];
509
+ targetPosition = viewRef.lng[axis];
510
+ });
511
+ return;
512
+ }
490
513
  // offset just for wrap so we keep one item before
491
514
  queueMicrotask(() => {
492
515
  const childSize = computeSize(slice().selected);
@@ -503,10 +526,12 @@ function createVirtual<T>(
503
526
  s.createEffect(
504
527
  s.on(items, () => {
505
528
  if (!viewRef) return;
506
- if (cursor() >= itemCount()) {
507
- setCursor(Math.max(0, itemCount() - 1));
529
+ let c = cursor();
530
+ if (c >= itemCount()) {
531
+ c = Math.max(0, itemCount() - 1);
532
+ setCursor(c);
508
533
  }
509
- const newState = computeSlice(cursor(), 0, slice());
534
+ const newState = computeSlice(c, 0, slice());
510
535
  setSlice(newState);
511
536
  viewRef.selected = newState.selected;
512
537
  }),