@lightningtv/solid 3.0.5 → 3.0.7-0

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.
@@ -1,5 +1,16 @@
1
- import { ElementNode, insertNode, type NodeProps, type NodeStyles } from '@lightningtv/solid';
2
- import { createMemo, getOwner, onMount, runWithOwner, type Accessor } from 'solid-js';
1
+ import {
2
+ ElementNode,
3
+ insertNode,
4
+ type NodeProps,
5
+ type NodeStyles,
6
+ } from '@lightningtv/solid';
7
+ import {
8
+ createMemo,
9
+ getOwner,
10
+ onMount,
11
+ runWithOwner,
12
+ type Accessor,
13
+ } from 'solid-js';
3
14
  import { fadeIn, fadeOut } from './FadeInOut.jsx';
4
15
  import { chainFunctions } from '@lightningtv/solid/primitives';
5
16
 
@@ -12,29 +23,32 @@ export const BorderBoxStyle: NodeStyles = {
12
23
 
13
24
  type BorderProps = NodeProps & { borderSpace?: number };
14
25
  const borderComponent = (props: BorderProps) => {
15
- const space = createMemo(() => props.borderSpace ?? (BorderBoxStyle.borderSpace as number));
26
+ const space = createMemo(
27
+ () => props.borderSpace ?? (BorderBoxStyle.borderSpace as number),
28
+ );
16
29
  return (
17
- <>
18
- <view
19
- skipFocus
20
- onCreate={(el) => {
21
- const parent = el.parent!;
22
- el.width = parent.width + space() * 2;
23
- el.height = parent.height + space() * 2;
24
- fadeIn(el);
25
- }}
26
- onDestroy={fadeOut}
27
- style={BorderBoxStyle}
28
- x={-space()}
29
- y={-space()}
30
- {...props}
31
- />
32
- </>
30
+ <view
31
+ skipFocus
32
+ onCreate={(el) => {
33
+ const parent = el.parent!;
34
+ el.width = parent.width + space() * 2;
35
+ el.height = parent.height + space() * 2;
36
+ fadeIn(el);
37
+ }}
38
+ onDestroy={fadeOut}
39
+ style={BorderBoxStyle}
40
+ x={-space()}
41
+ y={-space()}
42
+ {...props}
43
+ />
33
44
  );
34
45
  };
35
46
 
36
47
  // Solid directives can only be used on native root elements `view` and `text`
37
- export default function borderbox(el: ElementNode, accessor: Accessor<BorderProps | true | undefined>) {
48
+ export function borderBox(
49
+ el: ElementNode,
50
+ accessor: Accessor<BorderProps | true | undefined>,
51
+ ) {
38
52
  let border: ElementNode | null;
39
53
  const owner = getOwner();
40
54
 
@@ -49,6 +49,26 @@ export interface NavigableProps extends NodeProps {
49
49
  offset: number,
50
50
  isInitial: boolean,
51
51
  ) => void;
52
+
53
+ /**
54
+ * Defines transitions for animatable properties when navigating up.
55
+ */
56
+ transitionUp?: NodeStyles['transition'];
57
+
58
+ /**
59
+ * Defines transitions for animatable properties when navigating down.
60
+ */
61
+ transitionDown?: NodeStyles['transition'];
62
+
63
+ /**
64
+ * Defines transitions for animatable properties when navigating left.
65
+ */
66
+ transitionLeft?: NodeStyles['transition'];
67
+
68
+ /**
69
+ * Defines transitions for animatable properties when navigating right.
70
+ */
71
+ transitionRight?: NodeStyles['transition'];
52
72
  }
53
73
 
54
74
  // @ts-expect-error animationSettings is not identical - weird
@@ -2,6 +2,34 @@ import * as s from 'solid-js';
2
2
  import * as lng from '../../index.js';
3
3
  import * as lngp from '../index.js';
4
4
 
5
+ export const defaultTransitionBack = {
6
+ x: {
7
+ duration: 180,
8
+ easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
9
+ },
10
+ };
11
+
12
+ export const defaultTransitionForward = {
13
+ x: {
14
+ duration: 180,
15
+ easing: 'cubic-bezier(0.2, 0, 0, 1)',
16
+ },
17
+ };
18
+
19
+ export const defaultTransitionDown = {
20
+ y: {
21
+ duration: 300,
22
+ easing: 'cubic-bezier(0.2, 1, 0.8, 1)',
23
+ },
24
+ };
25
+
26
+ export const defaultTransitionUp = {
27
+ y: {
28
+ duration: 300,
29
+ easing: 'cubic-bezier(0.3, 0, 0.2, 1)',
30
+ },
31
+ };
32
+
5
33
  function idxInArray(idx: number, arr: readonly any[]): boolean {
6
34
  return idx >= 0 && idx < arr.length;
7
35
  }
@@ -93,6 +121,30 @@ export function handleNavigation(
93
121
  direction: 'up' | 'right' | 'down' | 'left',
94
122
  ): lng.KeyHandler {
95
123
  return function () {
124
+ const el = this as lngp.NavigableElement;
125
+ const transition =
126
+ direction === 'up'
127
+ ? el.transitionUp
128
+ : direction === 'down'
129
+ ? el.transitionDown
130
+ : direction === 'left'
131
+ ? el.transitionLeft
132
+ : direction === 'right'
133
+ ? el.transitionRight
134
+ : undefined;
135
+
136
+ if (transition) {
137
+ const currentTransition =
138
+ typeof el.transition === 'object' && el.transition !== null
139
+ ? el.transition
140
+ : {};
141
+
142
+ el.transition = {
143
+ ...currentTransition,
144
+ ...(transition as object),
145
+ };
146
+ }
147
+
96
148
  return moveSelection(
97
149
  this as lngp.NavigableElement,
98
150
  direction === 'up' || direction === 'left' ? -1 : 1,