@react-hive/honey-layout 2.3.1 → 2.4.1
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.
- package/dist/contexts/HoneyLayoutContext.d.ts +74 -0
- package/dist/contexts/index.d.ts +1 -0
- package/dist/helpers.d.ts +1 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/use-honey-document-key-up-handler.d.ts +19 -0
- package/dist/hooks/use-honey-layout.d.ts +9 -0
- package/dist/hooks/use-honey-overlay.d.ts +25 -0
- package/dist/hooks/use-register-honey-overlay.d.ts +2 -0
- package/dist/index.js +1135 -1051
- package/dist/providers/HoneyLayoutProvider.d.ts +1 -59
- package/dist/providers/hooks/index.d.ts +1 -0
- package/dist/providers/hooks/use-honey-overlays.d.ts +11 -0
- package/dist/types/dom.types.d.ts +5 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types.d.ts +73 -4
- package/package.json +3 -3
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { DefaultTheme, Interpolation } from 'styled-components';
|
|
2
|
+
import { HoneyColorKey, HoneyCSSColor, HoneyDimensionName, HoneyFontName, HoneyOverlayConfig, HoneySpacings, Nullable, HoneyScreenState, HoneyCSSDimensionUnit, HoneyCSSDimensionValue, HoneyCSSMultiValue, HoneyOverlayId, HoneyOverlay } from '../types';
|
|
3
|
+
import { ResolveSpacingResult } from '../helpers';
|
|
4
|
+
/**
|
|
5
|
+
* Function to unregister a previously registered overlay.
|
|
6
|
+
*/
|
|
7
|
+
export type HoneyUnregisterOverlay = (targetOverlayId: HoneyOverlayId) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Function to register a new overlay and manage its lifecycle.
|
|
10
|
+
*
|
|
11
|
+
* @param {HoneyOverlayConfig} overlayConfig - Configuration object for the overlay.
|
|
12
|
+
*/
|
|
13
|
+
export type HoneyRegisterOverlay = (overlayConfig: HoneyOverlayConfig) => HoneyOverlay;
|
|
14
|
+
export type HoneyLayoutContextValue = {
|
|
15
|
+
/**
|
|
16
|
+
* Represents the theme object.
|
|
17
|
+
*/
|
|
18
|
+
theme: DefaultTheme;
|
|
19
|
+
/**
|
|
20
|
+
* Represents the current state of the screen.
|
|
21
|
+
*/
|
|
22
|
+
screenState: HoneyScreenState;
|
|
23
|
+
/**
|
|
24
|
+
* Overlays.
|
|
25
|
+
*/
|
|
26
|
+
overlays: HoneyOverlay[];
|
|
27
|
+
/**
|
|
28
|
+
* Function to register a new overlay.
|
|
29
|
+
*/
|
|
30
|
+
registerOverlay: HoneyRegisterOverlay;
|
|
31
|
+
/**
|
|
32
|
+
* Function to unregister an overlay.
|
|
33
|
+
*/
|
|
34
|
+
unregisterOverlay: HoneyUnregisterOverlay;
|
|
35
|
+
/**
|
|
36
|
+
* Function to resolve spacing values based on a given theme.
|
|
37
|
+
*
|
|
38
|
+
* @template MultiValue - A type representing the spacing value(s), which could be a single value or an array of values.
|
|
39
|
+
* @template Unit - The CSS unit used for the resolved spacing value, e.g., 'px', 'em'.
|
|
40
|
+
*
|
|
41
|
+
* @param {MultiValue} value - The spacing value(s) to be applied, which could be a single number or an array of numbers.
|
|
42
|
+
* @param {Unit} unit - Optional. The CSS unit to use for the calculated value. Defaults to 'px'.
|
|
43
|
+
* @param {keyof HoneySpacings} type - Optional. The type of spacing to use from the theme (e.g., 'base', 'small', 'large').
|
|
44
|
+
*
|
|
45
|
+
* @returns {ResolveSpacingResult<MultiValue, Unit>} - The resolved spacing value, formatted as a string with the appropriate unit.
|
|
46
|
+
*/
|
|
47
|
+
resolveSpacing: <MultiValue extends HoneyCSSMultiValue<number>, Unit extends Nullable<HoneyCSSDimensionUnit> = 'px'>(value: MultiValue, unit?: Unit, type?: keyof HoneySpacings) => ResolveSpacingResult<MultiValue, Unit>;
|
|
48
|
+
/**
|
|
49
|
+
* Function to resolve color values based on the theme.
|
|
50
|
+
*
|
|
51
|
+
* @param {HoneyColorKey} colorKey - The key representing the color in the theme.
|
|
52
|
+
* @param {number} [alpha] - Optional alpha value to apply to the color for transparency.
|
|
53
|
+
*
|
|
54
|
+
* @returns {HoneyCSSColor} - The resolved CSS color, optionally with alpha transparency.
|
|
55
|
+
*/
|
|
56
|
+
resolveColor: (colorKey: HoneyColorKey, alpha?: number) => HoneyCSSColor;
|
|
57
|
+
/**
|
|
58
|
+
* Function to resolve font styles based on the theme.
|
|
59
|
+
*
|
|
60
|
+
* @param {HoneyFontName} fontName - The name of the font to resolve from the theme.
|
|
61
|
+
*
|
|
62
|
+
* @returns {Interpolation<object>} - The CSS style rules for the specified font.
|
|
63
|
+
*/
|
|
64
|
+
resolveFont: (fontName: HoneyFontName) => Interpolation<object>;
|
|
65
|
+
/**
|
|
66
|
+
* Function to resolve dimension values based on the theme.
|
|
67
|
+
*
|
|
68
|
+
* @param {HoneyDimensionName} dimensionName - The name of the dimension to resolve from the theme.
|
|
69
|
+
*
|
|
70
|
+
* @returns {HoneyCSSDimensionValue} - The resolved CSS dimension value (e.g., width, height).
|
|
71
|
+
*/
|
|
72
|
+
resolveDimension: (dimensionName: HoneyDimensionName) => HoneyCSSDimensionValue;
|
|
73
|
+
};
|
|
74
|
+
export declare const HoneyLayoutContext: import('react').Context<HoneyLayoutContextValue | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HoneyLayoutContext';
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'react';
|
|
2
2
|
import { ExecutionContext, StyleFunction, css } from 'styled-components';
|
|
3
3
|
import { Nullable, HoneyBreakpointName, HoneyCSSArrayValue, HoneyCSSDimensionShortHandValue, HoneyCSSDimensionUnit, HoneyCSSMultiValue, HoneyCSSMediaRule, HoneySpacings, HoneyColorKey, HoneyFontName, HoneyCSSColor, HoneyDimensionName, HoneyPrefixedCSSProperties, HoneyBreakpoints, HoneyScreenState, HoneyCSSDimensionValue } from './types';
|
|
4
|
+
export declare const generateUniqueId: () => string;
|
|
4
5
|
/**
|
|
5
6
|
* Conditional type to determine the return type of the `resolveSpacing` function.
|
|
6
7
|
*
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -2,3 +2,7 @@ export * from './use-honey-media-query';
|
|
|
2
2
|
export * from './use-honey-drag';
|
|
3
3
|
export * from './use-honey-infinite-scroll';
|
|
4
4
|
export * from './use-honey-synthetic-scrollable-container';
|
|
5
|
+
export * from './use-honey-document-key-up-handler';
|
|
6
|
+
export * from './use-honey-layout';
|
|
7
|
+
export * from './use-register-honey-overlay';
|
|
8
|
+
export * from './use-honey-overlay';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HoneyKeyboardEventCode } from '../types';
|
|
2
|
+
export type HoneyDocumentKeyUpHandler = (keyCode: HoneyKeyboardEventCode, e: KeyboardEvent) => void;
|
|
3
|
+
type UseHoneyDocumentKeyUpHandlerOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Determines if the event listener is active.
|
|
6
|
+
*
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
isEnabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A hook that listens for specific key up events at the document level and triggers a callback function.
|
|
13
|
+
*
|
|
14
|
+
* @param {HoneyDocumentKeyUpHandler} keyUpHandler - The callback function to be triggered when one of the specified keys is released.
|
|
15
|
+
* @param {HoneyKeyboardEventCode[]} listenKeys - An array of key codes to listen for. Only these specified keys will trigger the callback.
|
|
16
|
+
* @param {Object} options - Optional configuration.
|
|
17
|
+
*/
|
|
18
|
+
export declare const useHoneyDocumentKeyUpHandler: (keyUpHandler: HoneyDocumentKeyUpHandler, listenKeys: HoneyKeyboardEventCode[], { isEnabled }?: UseHoneyDocumentKeyUpHandlerOptions) => void;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HoneyLayoutContextValue } from '../contexts';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook to access the Honey layout context.
|
|
4
|
+
*
|
|
5
|
+
* @throws Will throw an error if the hook is used outside of a `HoneyLayoutProvider` component.
|
|
6
|
+
*
|
|
7
|
+
* @returns {HoneyLayoutContextValue} - The context value providing theming utilities and screen state.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useHoneyLayout: () => HoneyLayoutContextValue;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HoneyOverlayId, HoneyOverlayEventListenerHandler } from '../types';
|
|
2
|
+
type UseHoneyOverlayOptions = {
|
|
3
|
+
onKeyUp?: HoneyOverlayEventListenerHandler;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Hook to interact with a specific overlay managed by the `HoneyLayoutProvider`.
|
|
7
|
+
*
|
|
8
|
+
* @param targetOverlayId - The unique identifier of the overlay to interact with.
|
|
9
|
+
* @param options - Configuration options for the overlay, such as keyboard event handling.
|
|
10
|
+
*
|
|
11
|
+
* @returns The overlay object associated with the provided `targetOverlayId`, or `undefined` if not found.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const overlay = useHoneyOverlay('my-overlay-id', {
|
|
16
|
+
* onKeyUp: (keyCode, e) => {
|
|
17
|
+
* if (keyCode === 'Escape') {
|
|
18
|
+
* console.log('Escape key pressed');
|
|
19
|
+
* }
|
|
20
|
+
* },
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const useHoneyOverlay: (targetOverlayId: HoneyOverlayId, { onKeyUp }?: UseHoneyOverlayOptions) => import('../types').HoneyOverlay | undefined;
|
|
25
|
+
export {};
|