@truelab/truelogic 4.3.0-9 → 4.3.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,9 +1,17 @@
1
+ import { PointerEventHandler } from 'react';
1
2
  type TProps = {
2
3
  onClick: (event: React.MouseEvent) => void;
3
4
  cashPrice: number;
4
5
  disabled: boolean;
5
6
  /** Bonus mode is selected: the spin becomes the confirm control and shows the price chip */
6
7
  isActive?: boolean;
8
+ /**
9
+ * The control is held — a pointer on it or Space down; the panel owns the hold (useHold), as it
10
+ * does for the spin this control stands in for. Not `:active`: Blink sets that for a touch too
11
+ * late for a quick tap to show it, and a hotkey never sets it at all (GTT-2754)
12
+ */
13
+ isPressed?: boolean;
14
+ onPointerDown?: PointerEventHandler<HTMLButtonElement>;
7
15
  };
8
- export declare const BonusConfirmButtonBase: ({ onClick, cashPrice, disabled, isActive }: TProps) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const BonusConfirmButtonBase: ({ onClick, onPointerDown, cashPrice, disabled, isActive, isPressed, }: TProps) => import("react/jsx-runtime").JSX.Element;
9
17
  export {};
@@ -1,10 +1,12 @@
1
1
  declare const meta: {
2
2
  title: string;
3
- component: ({ onClick, cashPrice, disabled, isActive }: {
3
+ component: ({ onClick, onPointerDown, cashPrice, disabled, isActive, isPressed, }: {
4
4
  onClick: (event: React.MouseEvent) => void;
5
5
  cashPrice: number;
6
6
  disabled: boolean;
7
7
  isActive?: boolean;
8
+ isPressed?: boolean;
9
+ onPointerDown?: import("react").PointerEventHandler<HTMLButtonElement>;
8
10
  }) => import("react/jsx-runtime").JSX.Element;
9
11
  decorators: import("@storybook/react-webpack5").Decorator[];
10
12
  parameters: {};
@@ -20,8 +22,12 @@ export declare const Variants: import("storybook/internal/csf").StoryAnnotations
20
22
  cashPrice: number;
21
23
  disabled: boolean;
22
24
  isActive?: boolean;
25
+ isPressed?: boolean;
26
+ onPointerDown?: import("react").PointerEventHandler<HTMLButtonElement>;
23
27
  }, {
24
28
  isActive?: boolean;
29
+ isPressed?: boolean;
30
+ onPointerDown?: import("react").PointerEventHandler<HTMLButtonElement>;
25
31
  onClick?: (event: React.MouseEvent) => void;
26
32
  cashPrice?: number;
27
33
  disabled?: boolean;
@@ -5,6 +5,12 @@ type TPanelPlayProps = {
5
5
  ref: RefObject<HTMLButtonElement>;
6
6
  /** Rendered as `data-state` so e2e tests can tell play from stop/skip without guessing by `disabled` */
7
7
  state?: TPanelPlayState;
8
+ /**
9
+ * The spin is held — a pointer on the button or a hotkey down; the panel owns the hold (useHold).
10
+ * Not `:active`: Blink sets that for a touch too late for a quick tap to show, and On_tap must
11
+ * stay until the player lets go even once the round it started has disabled the button (GTT-2754)
12
+ */
13
+ isPressed?: boolean;
8
14
  } & ButtonHTMLAttributes<HTMLButtonElement>;
9
- export declare const PanelPlay: ({ onClick, className, disabled, state, ref, ...props }: TPanelPlayProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const PanelPlay: ({ onPointerDown, className, disabled, state, isPressed, ref, ...props }: TPanelPlayProps) => import("react/jsx-runtime").JSX.Element;
10
16
  export {};
@@ -4,7 +4,8 @@ export { useElementInViewPort } from './useElementInViewPort';
4
4
  export { useElementsBottomCssVar } from './useElementsBottomCssVar';
5
5
  export { useEnv } from './useEnv';
6
6
  export { useGameTime } from './useGameTime';
7
- export { useHoldDown } from './useHoldDown';
7
+ export type { THoldSource } from './useHold';
8
+ export { useHold } from './useHold';
8
9
  export { useOffline } from './useOffline';
9
10
  export { useOrientationChange } from './useOrientationChange';
10
11
  export { usePageVisibility } from './usePageVisibility';
@@ -0,0 +1,31 @@
1
+ import { PointerEvent as ReactPointerEvent } from 'react';
2
+ export type THoldSource = 'pointer' | 'key';
3
+ type THoldOptions = {
4
+ /** The control is held while one of these keys is down (`KeyboardEvent.code`) */
5
+ keys?: readonly string[];
6
+ /** How long the control must stay held for `onHold` to fire; a control with no hold action omits it */
7
+ holdDelay?: number;
8
+ onPress?: (source: THoldSource) => void;
9
+ onHold?: (source: THoldSource) => void;
10
+ /**
11
+ * `isCancelled` — the hold ended without the player letting go: a pointercancel, a window blur,
12
+ * another press taking over, the hook getting disabled or unmounted. An action that lands on the
13
+ * release (like a click does) must skip those
14
+ */
15
+ onRelease?: (source: THoldSource, isCancelled: boolean) => void;
16
+ /** Turning it off releases a hold in progress: a lock (a modal) must not leave the action stuck on */
17
+ isEnabled?: boolean;
18
+ };
19
+ /**
20
+ * One held state for a control pressed with a pointer (attach `onPointerDown` to it) or with
21
+ * hotkeys. The press fires `onPress`, a hold of `holdDelay` fires `onHold`, the release — pointerup
22
+ * or pointercancel anywhere in the document, keyup, window blur — fires `onRelease`. The latest
23
+ * press owns the hold: a second finger or key takes over instead of piling up. `isHeld` paints the
24
+ * control; it comes from the events themselves, not from `:active`, which Blink sets for a touch
25
+ * too late for a quick tap to show.
26
+ */
27
+ export declare const useHold: ({ keys, holdDelay, onPress, onHold, onRelease, isEnabled }: THoldOptions) => {
28
+ isHeld: boolean;
29
+ onPointerDown: (event: ReactPointerEvent<HTMLElement>) => void;
30
+ };
31
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -8,6 +8,13 @@ type TMenuInnerPageContext = {
8
8
  page: TMenuInnerPage | null;
9
9
  openPage: (page: TMenuInnerPage) => void;
10
10
  closePage: () => void;
11
+ /**
12
+ * A box over the header row for the toasts of a page, drawn there through a portal. Anything
13
+ * positioned inside the tab content, `fixed` included, travels with it: the tab scroll moves
14
+ * the content with a transform.
15
+ */
16
+ headerOverlay: HTMLElement | null;
17
+ setHeaderOverlay: (element: HTMLElement | null) => void;
11
18
  };
12
19
  type TProps = {
13
20
  children: ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truelab/truelogic",
3
- "version": "4.3.0-9",
3
+ "version": "4.3.0",
4
4
  "description": "",
5
5
  "main": "./dist/truelogic.min.js",
6
6
  "types": "./dist/types/src/index.d.ts",
@@ -58,7 +58,11 @@
58
58
  "test:e2e:ui": "playwright test --project=sandbox --ui",
59
59
  "test:e2e:ui:game": "playwright test --project=game --ui",
60
60
  "test:e2e:report": "playwright show-report",
61
- "test:e2e:typecheck": "tsc -p tests/e2e/tsconfig.json"
61
+ "test:e2e:typecheck": "tsc -p tests/e2e/tsconfig.json",
62
+ "email:install": "npm install --prefix ./email-letters",
63
+ "email:dev": "npm run dev --prefix ./email-letters",
64
+ "email:export": "npm run export --prefix ./email-letters",
65
+ "email:send-test": "npm run send-test --prefix ./email-letters --"
62
66
  },
63
67
  "browserslist": [
64
68
  "defaults and supports es6-module"
@@ -1 +0,0 @@
1
- export declare const useHoldDown: (button: "Space" | "Enter", onKeyDown: () => void, onKeyUp: () => void, keyDownDelay?: number, isEnabled?: boolean) => void;