@easemate/web-kit 0.1.5 → 0.2.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.
- package/README.md +360 -168
- package/build/elements/index.cjs +5 -2
- package/build/elements/index.d.cts +2 -1
- package/build/elements/index.d.ts +2 -1
- package/build/elements/index.js +2 -1
- package/build/elements/panel/index.cjs +496 -0
- package/build/elements/panel/index.d.cts +67 -0
- package/build/elements/panel/index.d.ts +67 -0
- package/build/elements/panel/index.js +492 -0
- package/build/elements/state/index.cjs +57 -464
- package/build/elements/state/index.d.cts +34 -25
- package/build/elements/state/index.d.ts +34 -25
- package/build/elements/state/index.js +59 -466
- package/build/internal/component-loaders.cjs +2 -0
- package/build/internal/component-loaders.d.cts +2 -2
- package/build/internal/component-loaders.d.ts +2 -2
- package/build/internal/component-loaders.js +2 -0
- package/build/react/events.cjs +25 -0
- package/build/react/events.d.cts +39 -0
- package/build/react/events.d.ts +39 -0
- package/build/react/events.js +22 -0
- package/build/react/index.cjs +19 -0
- package/build/react/index.d.cts +13 -0
- package/build/react/index.d.ts +13 -0
- package/build/react/index.js +12 -0
- package/build/react/provider.cjs +134 -0
- package/build/react/provider.d.cts +81 -0
- package/build/react/provider.d.ts +81 -0
- package/build/react/provider.js +98 -0
- package/build/react/types.cjs +8 -0
- package/build/react/types.d.cts +55 -0
- package/build/react/types.d.ts +55 -0
- package/build/react/types.js +7 -0
- package/build/react/use-ease-state.cjs +129 -0
- package/build/react/use-ease-state.d.cts +95 -0
- package/build/react/use-ease-state.d.ts +95 -0
- package/build/react/use-ease-state.js +126 -0
- package/build/react/use-web-kit.cjs +150 -0
- package/build/react/use-web-kit.d.cts +80 -0
- package/build/react/use-web-kit.d.ts +80 -0
- package/build/react/use-web-kit.js +114 -0
- package/build/register.cjs +1 -0
- package/build/register.d.cts +1 -0
- package/build/register.d.ts +1 -0
- package/build/register.js +1 -0
- package/package.json +15 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* All root-level web-kit element tags (excludes internal sub-components).
|
|
7
7
|
*/
|
|
8
|
-
export declare const WEB_KIT_ELEMENT_TAGS: readonly ["ease-button", "ease-checkbox", "ease-color-input", "ease-color-picker", "ease-dropdown", "ease-input", "ease-number-input", "ease-origin", "ease-radio-group", "ease-radio-input", "ease-slider", "ease-toggle", "ease-field", "ease-popover", "ease-state", "ease-tooltip", "ease-logo-loader", "ease-monitor", "ease-monitor-fps", "ease-icon-anchor-add", "ease-icon-anchor-remove", "ease-icon-arrow-up", "ease-icon-arrows-vertical", "ease-icon-bezier", "ease-icon-bezier-angle", "ease-icon-bezier-distribute", "ease-icon-bezier-length", "ease-icon-bezier-mirror", "ease-icon-check", "ease-icon-chevron", "ease-icon-circle-arrow-left", "ease-icon-circle-arrow-right", "ease-icon-clear", "ease-icon-code", "ease-icon-dots", "ease-icon-grid", "ease-icon-loading", "ease-icon-mention", "ease-icon-minus", "ease-icon-picker", "ease-icon-plus", "ease-icon-settings", "ease-icon-snap"];
|
|
8
|
+
export declare const WEB_KIT_ELEMENT_TAGS: readonly ["ease-button", "ease-checkbox", "ease-color-input", "ease-color-picker", "ease-dropdown", "ease-input", "ease-number-input", "ease-origin", "ease-radio-group", "ease-radio-input", "ease-slider", "ease-toggle", "ease-field", "ease-panel", "ease-popover", "ease-state", "ease-tooltip", "ease-logo-loader", "ease-monitor", "ease-monitor-fps", "ease-icon-anchor-add", "ease-icon-anchor-remove", "ease-icon-arrow-up", "ease-icon-arrows-vertical", "ease-icon-bezier", "ease-icon-bezier-angle", "ease-icon-bezier-distribute", "ease-icon-bezier-length", "ease-icon-bezier-mirror", "ease-icon-check", "ease-icon-chevron", "ease-icon-circle-arrow-left", "ease-icon-circle-arrow-right", "ease-icon-clear", "ease-icon-code", "ease-icon-dots", "ease-icon-grid", "ease-icon-loading", "ease-icon-mention", "ease-icon-minus", "ease-icon-picker", "ease-icon-plus", "ease-icon-settings", "ease-icon-snap"];
|
|
9
9
|
/**
|
|
10
10
|
* Advanced component tags (curve, code editor, etc.)
|
|
11
11
|
*/
|
|
@@ -13,7 +13,7 @@ export declare const WEB_KIT_COMPONENT_TAGS: readonly ["ease-curve", "ease-code"
|
|
|
13
13
|
/**
|
|
14
14
|
* All public web-kit tags.
|
|
15
15
|
*/
|
|
16
|
-
export declare const WEB_KIT_ALL_TAGS: readonly ["ease-button", "ease-checkbox", "ease-color-input", "ease-color-picker", "ease-dropdown", "ease-input", "ease-number-input", "ease-origin", "ease-radio-group", "ease-radio-input", "ease-slider", "ease-toggle", "ease-field", "ease-popover", "ease-state", "ease-tooltip", "ease-logo-loader", "ease-monitor", "ease-monitor-fps", "ease-icon-anchor-add", "ease-icon-anchor-remove", "ease-icon-arrow-up", "ease-icon-arrows-vertical", "ease-icon-bezier", "ease-icon-bezier-angle", "ease-icon-bezier-distribute", "ease-icon-bezier-length", "ease-icon-bezier-mirror", "ease-icon-check", "ease-icon-chevron", "ease-icon-circle-arrow-left", "ease-icon-circle-arrow-right", "ease-icon-clear", "ease-icon-code", "ease-icon-dots", "ease-icon-grid", "ease-icon-loading", "ease-icon-mention", "ease-icon-minus", "ease-icon-picker", "ease-icon-plus", "ease-icon-settings", "ease-icon-snap", "ease-curve", "ease-code"];
|
|
16
|
+
export declare const WEB_KIT_ALL_TAGS: readonly ["ease-button", "ease-checkbox", "ease-color-input", "ease-color-picker", "ease-dropdown", "ease-input", "ease-number-input", "ease-origin", "ease-radio-group", "ease-radio-input", "ease-slider", "ease-toggle", "ease-field", "ease-panel", "ease-popover", "ease-state", "ease-tooltip", "ease-logo-loader", "ease-monitor", "ease-monitor-fps", "ease-icon-anchor-add", "ease-icon-anchor-remove", "ease-icon-arrow-up", "ease-icon-arrows-vertical", "ease-icon-bezier", "ease-icon-bezier-angle", "ease-icon-bezier-distribute", "ease-icon-bezier-length", "ease-icon-bezier-mirror", "ease-icon-check", "ease-icon-chevron", "ease-icon-circle-arrow-left", "ease-icon-circle-arrow-right", "ease-icon-clear", "ease-icon-code", "ease-icon-dots", "ease-icon-grid", "ease-icon-loading", "ease-icon-mention", "ease-icon-minus", "ease-icon-picker", "ease-icon-plus", "ease-icon-settings", "ease-icon-snap", "ease-curve", "ease-code"];
|
|
17
17
|
/**
|
|
18
18
|
* Union type of all element tag names.
|
|
19
19
|
*/
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* All root-level web-kit element tags (excludes internal sub-components).
|
|
7
7
|
*/
|
|
8
|
-
export declare const WEB_KIT_ELEMENT_TAGS: readonly ["ease-button", "ease-checkbox", "ease-color-input", "ease-color-picker", "ease-dropdown", "ease-input", "ease-number-input", "ease-origin", "ease-radio-group", "ease-radio-input", "ease-slider", "ease-toggle", "ease-field", "ease-popover", "ease-state", "ease-tooltip", "ease-logo-loader", "ease-monitor", "ease-monitor-fps", "ease-icon-anchor-add", "ease-icon-anchor-remove", "ease-icon-arrow-up", "ease-icon-arrows-vertical", "ease-icon-bezier", "ease-icon-bezier-angle", "ease-icon-bezier-distribute", "ease-icon-bezier-length", "ease-icon-bezier-mirror", "ease-icon-check", "ease-icon-chevron", "ease-icon-circle-arrow-left", "ease-icon-circle-arrow-right", "ease-icon-clear", "ease-icon-code", "ease-icon-dots", "ease-icon-grid", "ease-icon-loading", "ease-icon-mention", "ease-icon-minus", "ease-icon-picker", "ease-icon-plus", "ease-icon-settings", "ease-icon-snap"];
|
|
8
|
+
export declare const WEB_KIT_ELEMENT_TAGS: readonly ["ease-button", "ease-checkbox", "ease-color-input", "ease-color-picker", "ease-dropdown", "ease-input", "ease-number-input", "ease-origin", "ease-radio-group", "ease-radio-input", "ease-slider", "ease-toggle", "ease-field", "ease-panel", "ease-popover", "ease-state", "ease-tooltip", "ease-logo-loader", "ease-monitor", "ease-monitor-fps", "ease-icon-anchor-add", "ease-icon-anchor-remove", "ease-icon-arrow-up", "ease-icon-arrows-vertical", "ease-icon-bezier", "ease-icon-bezier-angle", "ease-icon-bezier-distribute", "ease-icon-bezier-length", "ease-icon-bezier-mirror", "ease-icon-check", "ease-icon-chevron", "ease-icon-circle-arrow-left", "ease-icon-circle-arrow-right", "ease-icon-clear", "ease-icon-code", "ease-icon-dots", "ease-icon-grid", "ease-icon-loading", "ease-icon-mention", "ease-icon-minus", "ease-icon-picker", "ease-icon-plus", "ease-icon-settings", "ease-icon-snap"];
|
|
9
9
|
/**
|
|
10
10
|
* Advanced component tags (curve, code editor, etc.)
|
|
11
11
|
*/
|
|
@@ -13,7 +13,7 @@ export declare const WEB_KIT_COMPONENT_TAGS: readonly ["ease-curve", "ease-code"
|
|
|
13
13
|
/**
|
|
14
14
|
* All public web-kit tags.
|
|
15
15
|
*/
|
|
16
|
-
export declare const WEB_KIT_ALL_TAGS: readonly ["ease-button", "ease-checkbox", "ease-color-input", "ease-color-picker", "ease-dropdown", "ease-input", "ease-number-input", "ease-origin", "ease-radio-group", "ease-radio-input", "ease-slider", "ease-toggle", "ease-field", "ease-popover", "ease-state", "ease-tooltip", "ease-logo-loader", "ease-monitor", "ease-monitor-fps", "ease-icon-anchor-add", "ease-icon-anchor-remove", "ease-icon-arrow-up", "ease-icon-arrows-vertical", "ease-icon-bezier", "ease-icon-bezier-angle", "ease-icon-bezier-distribute", "ease-icon-bezier-length", "ease-icon-bezier-mirror", "ease-icon-check", "ease-icon-chevron", "ease-icon-circle-arrow-left", "ease-icon-circle-arrow-right", "ease-icon-clear", "ease-icon-code", "ease-icon-dots", "ease-icon-grid", "ease-icon-loading", "ease-icon-mention", "ease-icon-minus", "ease-icon-picker", "ease-icon-plus", "ease-icon-settings", "ease-icon-snap", "ease-curve", "ease-code"];
|
|
16
|
+
export declare const WEB_KIT_ALL_TAGS: readonly ["ease-button", "ease-checkbox", "ease-color-input", "ease-color-picker", "ease-dropdown", "ease-input", "ease-number-input", "ease-origin", "ease-radio-group", "ease-radio-input", "ease-slider", "ease-toggle", "ease-field", "ease-panel", "ease-popover", "ease-state", "ease-tooltip", "ease-logo-loader", "ease-monitor", "ease-monitor-fps", "ease-icon-anchor-add", "ease-icon-anchor-remove", "ease-icon-arrow-up", "ease-icon-arrows-vertical", "ease-icon-bezier", "ease-icon-bezier-angle", "ease-icon-bezier-distribute", "ease-icon-bezier-length", "ease-icon-bezier-mirror", "ease-icon-check", "ease-icon-chevron", "ease-icon-circle-arrow-left", "ease-icon-circle-arrow-right", "ease-icon-clear", "ease-icon-code", "ease-icon-dots", "ease-icon-grid", "ease-icon-loading", "ease-icon-mention", "ease-icon-minus", "ease-icon-picker", "ease-icon-plus", "ease-icon-settings", "ease-icon-snap", "ease-curve", "ease-code"];
|
|
17
17
|
/**
|
|
18
18
|
* Union type of all element tag names.
|
|
19
19
|
*/
|
|
@@ -21,6 +21,7 @@ export const WEB_KIT_ELEMENT_TAGS = [
|
|
|
21
21
|
'ease-toggle',
|
|
22
22
|
// Layout
|
|
23
23
|
'ease-field',
|
|
24
|
+
'ease-panel',
|
|
24
25
|
'ease-popover',
|
|
25
26
|
'ease-state',
|
|
26
27
|
'ease-tooltip',
|
|
@@ -93,6 +94,7 @@ export const COMPONENT_LOADERS = {
|
|
|
93
94
|
'ease-toggle': () => import("../elements/toggle/index.js"),
|
|
94
95
|
// Layout
|
|
95
96
|
'ease-field': () => import("../elements/field/index.js"),
|
|
97
|
+
'ease-panel': () => import("../elements/panel/index.js"),
|
|
96
98
|
'ease-popover': () => import("../elements/popover/index.js"),
|
|
97
99
|
'ease-state': () => import("../elements/state/index.js"),
|
|
98
100
|
'ease-tooltip': () => import("../elements/tooltip/index.js"),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* React event handling utilities for @easemate/web-kit
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createEventHandler = createEventHandler;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a type-safe event handler for control-change events.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <ease-slider
|
|
13
|
+
* name="opacity"
|
|
14
|
+
* value={0.5}
|
|
15
|
+
* onControlChange={createEventHandler<number>((value, name) => {
|
|
16
|
+
* console.log(`${name} changed to ${value}`);
|
|
17
|
+
* })}
|
|
18
|
+
* />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function createEventHandler(callback) {
|
|
22
|
+
return (e) => {
|
|
23
|
+
callback(e.detail.value, e.detail.name, e.detail.event);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React event handling utilities for @easemate/web-kit
|
|
3
|
+
*/
|
|
4
|
+
import type { TabChangeEventDetail } from '../elements/panel';
|
|
5
|
+
import type { ControlEventDetail } from '../elements/shared';
|
|
6
|
+
import type { StateChangeEventDetail } from '../elements/state';
|
|
7
|
+
/**
|
|
8
|
+
* Control change event type for React
|
|
9
|
+
*/
|
|
10
|
+
export interface ControlChangeEvent<T = unknown> extends CustomEvent<ControlEventDetail<T>> {
|
|
11
|
+
detail: ControlEventDetail<T>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* State change event type for React
|
|
15
|
+
*/
|
|
16
|
+
export interface StateChangeEvent extends CustomEvent<StateChangeEventDetail> {
|
|
17
|
+
detail: StateChangeEventDetail;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tab change event type for React
|
|
21
|
+
*/
|
|
22
|
+
export interface TabChangeEvent extends CustomEvent<TabChangeEventDetail> {
|
|
23
|
+
detail: TabChangeEventDetail;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a type-safe event handler for control-change events.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <ease-slider
|
|
31
|
+
* name="opacity"
|
|
32
|
+
* value={0.5}
|
|
33
|
+
* onControlChange={createEventHandler<number>((value, name) => {
|
|
34
|
+
* console.log(`${name} changed to ${value}`);
|
|
35
|
+
* })}
|
|
36
|
+
* />
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function createEventHandler<T = unknown>(callback: (value: T, name: string | undefined, event: Event) => void): (e: CustomEvent<ControlEventDetail<T>>) => void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React event handling utilities for @easemate/web-kit
|
|
3
|
+
*/
|
|
4
|
+
import type { TabChangeEventDetail } from '../elements/panel';
|
|
5
|
+
import type { ControlEventDetail } from '../elements/shared';
|
|
6
|
+
import type { StateChangeEventDetail } from '../elements/state';
|
|
7
|
+
/**
|
|
8
|
+
* Control change event type for React
|
|
9
|
+
*/
|
|
10
|
+
export interface ControlChangeEvent<T = unknown> extends CustomEvent<ControlEventDetail<T>> {
|
|
11
|
+
detail: ControlEventDetail<T>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* State change event type for React
|
|
15
|
+
*/
|
|
16
|
+
export interface StateChangeEvent extends CustomEvent<StateChangeEventDetail> {
|
|
17
|
+
detail: StateChangeEventDetail;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tab change event type for React
|
|
21
|
+
*/
|
|
22
|
+
export interface TabChangeEvent extends CustomEvent<TabChangeEventDetail> {
|
|
23
|
+
detail: TabChangeEventDetail;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a type-safe event handler for control-change events.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <ease-slider
|
|
31
|
+
* name="opacity"
|
|
32
|
+
* value={0.5}
|
|
33
|
+
* onControlChange={createEventHandler<number>((value, name) => {
|
|
34
|
+
* console.log(`${name} changed to ${value}`);
|
|
35
|
+
* })}
|
|
36
|
+
* />
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function createEventHandler<T = unknown>(callback: (value: T, name: string | undefined, event: Event) => void): (e: CustomEvent<ControlEventDetail<T>>) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React event handling utilities for @easemate/web-kit
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Creates a type-safe event handler for control-change events.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <ease-slider
|
|
10
|
+
* name="opacity"
|
|
11
|
+
* value={0.5}
|
|
12
|
+
* onControlChange={createEventHandler<number>((value, name) => {
|
|
13
|
+
* console.log(`${name} changed to ${value}`);
|
|
14
|
+
* })}
|
|
15
|
+
* />
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function createEventHandler(callback) {
|
|
19
|
+
return (e) => {
|
|
20
|
+
callback(e.detail.value, e.detail.name, e.detail.event);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* React integration for @easemate/web-kit
|
|
4
|
+
*
|
|
5
|
+
* Provides React hooks and utilities for seamless integration with
|
|
6
|
+
* React and Next.js applications.
|
|
7
|
+
*
|
|
8
|
+
* @module @easemate/web-kit/react
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.useWebKit = exports.useEaseState = exports.createWebKitProvider = exports.createEventHandler = void 0;
|
|
12
|
+
var events_1 = require("./events.cjs");
|
|
13
|
+
Object.defineProperty(exports, "createEventHandler", { enumerable: true, get: function () { return events_1.createEventHandler; } });
|
|
14
|
+
var provider_1 = require("./provider.cjs");
|
|
15
|
+
Object.defineProperty(exports, "createWebKitProvider", { enumerable: true, get: function () { return provider_1.createWebKitProvider; } });
|
|
16
|
+
var use_ease_state_1 = require("./use-ease-state.cjs");
|
|
17
|
+
Object.defineProperty(exports, "useEaseState", { enumerable: true, get: function () { return use_ease_state_1.useEaseState; } });
|
|
18
|
+
var use_web_kit_1 = require("./use-web-kit.cjs");
|
|
19
|
+
Object.defineProperty(exports, "useWebKit", { enumerable: true, get: function () { return use_web_kit_1.useWebKit; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React integration for @easemate/web-kit
|
|
3
|
+
*
|
|
4
|
+
* Provides React hooks and utilities for seamless integration with
|
|
5
|
+
* React and Next.js applications.
|
|
6
|
+
*
|
|
7
|
+
* @module @easemate/web-kit/react
|
|
8
|
+
*/
|
|
9
|
+
export type { EaseControlElement, EasePanelRef, EaseStateRef, StateChangeEventDetail, TabChangeEventDetail } from "./types.cjs";
|
|
10
|
+
export { type ControlChangeEvent, createEventHandler, type StateChangeEvent, type TabChangeEvent } from "./events.cjs";
|
|
11
|
+
export { createWebKitProvider, type ReactHooksForProvider, type WebKitContextValue, type WebKitProviderProps } from "./provider.cjs";
|
|
12
|
+
export { type ReactHooksLike, type UseEaseStateOptions, type UseEaseStateReturn, useEaseState } from "./use-ease-state.cjs";
|
|
13
|
+
export { type UseWebKitOptions, type UseWebKitReturn, useWebKit } from "./use-web-kit.cjs";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React integration for @easemate/web-kit
|
|
3
|
+
*
|
|
4
|
+
* Provides React hooks and utilities for seamless integration with
|
|
5
|
+
* React and Next.js applications.
|
|
6
|
+
*
|
|
7
|
+
* @module @easemate/web-kit/react
|
|
8
|
+
*/
|
|
9
|
+
export type { EaseControlElement, EasePanelRef, EaseStateRef, StateChangeEventDetail, TabChangeEventDetail } from "./types.js";
|
|
10
|
+
export { type ControlChangeEvent, createEventHandler, type StateChangeEvent, type TabChangeEvent } from "./events.js";
|
|
11
|
+
export { createWebKitProvider, type ReactHooksForProvider, type WebKitContextValue, type WebKitProviderProps } from "./provider.js";
|
|
12
|
+
export { type ReactHooksLike, type UseEaseStateOptions, type UseEaseStateReturn, useEaseState } from "./use-ease-state.js";
|
|
13
|
+
export { type UseWebKitOptions, type UseWebKitReturn, useWebKit } from "./use-web-kit.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React integration for @easemate/web-kit
|
|
3
|
+
*
|
|
4
|
+
* Provides React hooks and utilities for seamless integration with
|
|
5
|
+
* React and Next.js applications.
|
|
6
|
+
*
|
|
7
|
+
* @module @easemate/web-kit/react
|
|
8
|
+
*/
|
|
9
|
+
export { createEventHandler } from "./events.js";
|
|
10
|
+
export { createWebKitProvider } from "./provider.js";
|
|
11
|
+
export { useEaseState } from "./use-ease-state.js";
|
|
12
|
+
export { useWebKit } from "./use-web-kit.js";
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* React context provider for @easemate/web-kit
|
|
4
|
+
*
|
|
5
|
+
* This module provides a simple way to initialize the web kit in a React context.
|
|
6
|
+
* For simpler use cases, consider using `initWebKit()` directly in a useEffect.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.createWebKitProvider = createWebKitProvider;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a WebKit provider and context hook.
|
|
45
|
+
*
|
|
46
|
+
* This function creates a React context and provider component
|
|
47
|
+
* that initializes the web kit and provides access to its state.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* // providers.tsx
|
|
52
|
+
* 'use client';
|
|
53
|
+
*
|
|
54
|
+
* import * as React from '../react';
|
|
55
|
+
* import { createWebKitProvider } from '@easemate/web-kit/react';
|
|
56
|
+
*
|
|
57
|
+
* const { WebKitProvider, useWebKitContext } = createWebKitProvider(React);
|
|
58
|
+
*
|
|
59
|
+
* export { WebKitProvider, useWebKitContext };
|
|
60
|
+
*
|
|
61
|
+
* // layout.tsx
|
|
62
|
+
* import { WebKitProvider } from './providers';
|
|
63
|
+
*
|
|
64
|
+
* export default function Layout({ children }) {
|
|
65
|
+
* return (
|
|
66
|
+
* <WebKitProvider options={{ theme: 'default', styles: 'main' }}>
|
|
67
|
+
* {children}
|
|
68
|
+
* </WebKitProvider>
|
|
69
|
+
* );
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
function createWebKitProvider(React) {
|
|
74
|
+
const defaultValue = {
|
|
75
|
+
ready: false,
|
|
76
|
+
theme: undefined
|
|
77
|
+
};
|
|
78
|
+
const WebKitContext = React.createContext(defaultValue);
|
|
79
|
+
function WebKitProvider(props) {
|
|
80
|
+
const { options = {}, immediate = true, children } = props;
|
|
81
|
+
const isSSR = typeof window === 'undefined';
|
|
82
|
+
const { useState, useEffect, useMemo, createElement } = React;
|
|
83
|
+
const [ready, setReady] = useState(false);
|
|
84
|
+
const [controller, setController] = useState(null);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
// Skip initialization on SSR
|
|
87
|
+
if (isSSR) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
let isMounted = true;
|
|
91
|
+
const initialize = async () => {
|
|
92
|
+
const { initWebKit } = await Promise.resolve().then(() => __importStar(require('../init')));
|
|
93
|
+
const ctrl = initWebKit(options);
|
|
94
|
+
if (isMounted) {
|
|
95
|
+
setController(ctrl);
|
|
96
|
+
}
|
|
97
|
+
await ctrl.ready;
|
|
98
|
+
if (isMounted) {
|
|
99
|
+
setReady(true);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
initialize();
|
|
103
|
+
return () => {
|
|
104
|
+
isMounted = false;
|
|
105
|
+
controller?.dispose();
|
|
106
|
+
return undefined;
|
|
107
|
+
};
|
|
108
|
+
}, []);
|
|
109
|
+
const value = useMemo(() => {
|
|
110
|
+
return {
|
|
111
|
+
ready,
|
|
112
|
+
theme: controller?.theme
|
|
113
|
+
};
|
|
114
|
+
}, [ready, controller]);
|
|
115
|
+
// On SSR, just render children directly
|
|
116
|
+
if (isSSR) {
|
|
117
|
+
return children;
|
|
118
|
+
}
|
|
119
|
+
// Don't render children until ready if immediate is false
|
|
120
|
+
if (!immediate && !ready) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
return createElement(WebKitContext.Provider, { value }, children);
|
|
124
|
+
}
|
|
125
|
+
function useWebKitContext() {
|
|
126
|
+
const context = React.useContext(WebKitContext);
|
|
127
|
+
// On SSR, context will be the default value anyway
|
|
128
|
+
return context;
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
WebKitProvider,
|
|
132
|
+
useWebKitContext
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React context provider for @easemate/web-kit
|
|
3
|
+
*
|
|
4
|
+
* This module provides a simple way to initialize the web kit in a React context.
|
|
5
|
+
* For simpler use cases, consider using `initWebKit()` directly in a useEffect.
|
|
6
|
+
*/
|
|
7
|
+
import type { InitWebKitOptions, WebKitController } from '../init';
|
|
8
|
+
/**
|
|
9
|
+
* WebKit context value
|
|
10
|
+
*/
|
|
11
|
+
export interface WebKitContextValue {
|
|
12
|
+
/** Whether the web kit is ready */
|
|
13
|
+
ready: boolean;
|
|
14
|
+
/** Theme controller */
|
|
15
|
+
theme?: WebKitController['theme'];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Props for createWebKitProvider
|
|
19
|
+
*/
|
|
20
|
+
export interface WebKitProviderProps {
|
|
21
|
+
/** Initialization options */
|
|
22
|
+
options?: InitWebKitOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Render children even before ready
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
immediate?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* React hooks interface for provider creation
|
|
31
|
+
*/
|
|
32
|
+
export interface ReactHooksForProvider {
|
|
33
|
+
useState: <S>(initial: S) => [S, (value: S) => void];
|
|
34
|
+
useEffect: (effect: () => (() => void) | undefined, deps?: unknown[]) => void;
|
|
35
|
+
useMemo: <T>(factory: () => T, deps: unknown[]) => T;
|
|
36
|
+
createContext: <T>(defaultValue: T) => {
|
|
37
|
+
Provider: unknown;
|
|
38
|
+
Consumer: unknown;
|
|
39
|
+
};
|
|
40
|
+
useContext: <T>(context: {
|
|
41
|
+
Provider: unknown;
|
|
42
|
+
Consumer: unknown;
|
|
43
|
+
}) => T;
|
|
44
|
+
createElement: (type: unknown, props: Record<string, unknown> | null, ...children: unknown[]) => unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a WebKit provider and context hook.
|
|
48
|
+
*
|
|
49
|
+
* This function creates a React context and provider component
|
|
50
|
+
* that initializes the web kit and provides access to its state.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* // providers.tsx
|
|
55
|
+
* 'use client';
|
|
56
|
+
*
|
|
57
|
+
* import * as React from '../react';
|
|
58
|
+
* import { createWebKitProvider } from '@easemate/web-kit/react';
|
|
59
|
+
*
|
|
60
|
+
* const { WebKitProvider, useWebKitContext } = createWebKitProvider(React);
|
|
61
|
+
*
|
|
62
|
+
* export { WebKitProvider, useWebKitContext };
|
|
63
|
+
*
|
|
64
|
+
* // layout.tsx
|
|
65
|
+
* import { WebKitProvider } from './providers';
|
|
66
|
+
*
|
|
67
|
+
* export default function Layout({ children }) {
|
|
68
|
+
* return (
|
|
69
|
+
* <WebKitProvider options={{ theme: 'default', styles: 'main' }}>
|
|
70
|
+
* {children}
|
|
71
|
+
* </WebKitProvider>
|
|
72
|
+
* );
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function createWebKitProvider(React: ReactHooksForProvider): {
|
|
77
|
+
WebKitProvider: (props: WebKitProviderProps & {
|
|
78
|
+
children: unknown;
|
|
79
|
+
}) => unknown;
|
|
80
|
+
useWebKitContext: () => WebKitContextValue;
|
|
81
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React context provider for @easemate/web-kit
|
|
3
|
+
*
|
|
4
|
+
* This module provides a simple way to initialize the web kit in a React context.
|
|
5
|
+
* For simpler use cases, consider using `initWebKit()` directly in a useEffect.
|
|
6
|
+
*/
|
|
7
|
+
import type { InitWebKitOptions, WebKitController } from '../init';
|
|
8
|
+
/**
|
|
9
|
+
* WebKit context value
|
|
10
|
+
*/
|
|
11
|
+
export interface WebKitContextValue {
|
|
12
|
+
/** Whether the web kit is ready */
|
|
13
|
+
ready: boolean;
|
|
14
|
+
/** Theme controller */
|
|
15
|
+
theme?: WebKitController['theme'];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Props for createWebKitProvider
|
|
19
|
+
*/
|
|
20
|
+
export interface WebKitProviderProps {
|
|
21
|
+
/** Initialization options */
|
|
22
|
+
options?: InitWebKitOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Render children even before ready
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
immediate?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* React hooks interface for provider creation
|
|
31
|
+
*/
|
|
32
|
+
export interface ReactHooksForProvider {
|
|
33
|
+
useState: <S>(initial: S) => [S, (value: S) => void];
|
|
34
|
+
useEffect: (effect: () => (() => void) | undefined, deps?: unknown[]) => void;
|
|
35
|
+
useMemo: <T>(factory: () => T, deps: unknown[]) => T;
|
|
36
|
+
createContext: <T>(defaultValue: T) => {
|
|
37
|
+
Provider: unknown;
|
|
38
|
+
Consumer: unknown;
|
|
39
|
+
};
|
|
40
|
+
useContext: <T>(context: {
|
|
41
|
+
Provider: unknown;
|
|
42
|
+
Consumer: unknown;
|
|
43
|
+
}) => T;
|
|
44
|
+
createElement: (type: unknown, props: Record<string, unknown> | null, ...children: unknown[]) => unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a WebKit provider and context hook.
|
|
48
|
+
*
|
|
49
|
+
* This function creates a React context and provider component
|
|
50
|
+
* that initializes the web kit and provides access to its state.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* // providers.tsx
|
|
55
|
+
* 'use client';
|
|
56
|
+
*
|
|
57
|
+
* import * as React from '../react';
|
|
58
|
+
* import { createWebKitProvider } from '@easemate/web-kit/react';
|
|
59
|
+
*
|
|
60
|
+
* const { WebKitProvider, useWebKitContext } = createWebKitProvider(React);
|
|
61
|
+
*
|
|
62
|
+
* export { WebKitProvider, useWebKitContext };
|
|
63
|
+
*
|
|
64
|
+
* // layout.tsx
|
|
65
|
+
* import { WebKitProvider } from './providers';
|
|
66
|
+
*
|
|
67
|
+
* export default function Layout({ children }) {
|
|
68
|
+
* return (
|
|
69
|
+
* <WebKitProvider options={{ theme: 'default', styles: 'main' }}>
|
|
70
|
+
* {children}
|
|
71
|
+
* </WebKitProvider>
|
|
72
|
+
* );
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function createWebKitProvider(React: ReactHooksForProvider): {
|
|
77
|
+
WebKitProvider: (props: WebKitProviderProps & {
|
|
78
|
+
children: unknown;
|
|
79
|
+
}) => unknown;
|
|
80
|
+
useWebKitContext: () => WebKitContextValue;
|
|
81
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React context provider for @easemate/web-kit
|
|
3
|
+
*
|
|
4
|
+
* This module provides a simple way to initialize the web kit in a React context.
|
|
5
|
+
* For simpler use cases, consider using `initWebKit()` directly in a useEffect.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Creates a WebKit provider and context hook.
|
|
9
|
+
*
|
|
10
|
+
* This function creates a React context and provider component
|
|
11
|
+
* that initializes the web kit and provides access to its state.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* // providers.tsx
|
|
16
|
+
* 'use client';
|
|
17
|
+
*
|
|
18
|
+
* import * as React from '../react';
|
|
19
|
+
* import { createWebKitProvider } from '@easemate/web-kit/react';
|
|
20
|
+
*
|
|
21
|
+
* const { WebKitProvider, useWebKitContext } = createWebKitProvider(React);
|
|
22
|
+
*
|
|
23
|
+
* export { WebKitProvider, useWebKitContext };
|
|
24
|
+
*
|
|
25
|
+
* // layout.tsx
|
|
26
|
+
* import { WebKitProvider } from './providers';
|
|
27
|
+
*
|
|
28
|
+
* export default function Layout({ children }) {
|
|
29
|
+
* return (
|
|
30
|
+
* <WebKitProvider options={{ theme: 'default', styles: 'main' }}>
|
|
31
|
+
* {children}
|
|
32
|
+
* </WebKitProvider>
|
|
33
|
+
* );
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function createWebKitProvider(React) {
|
|
38
|
+
const defaultValue = {
|
|
39
|
+
ready: false,
|
|
40
|
+
theme: undefined
|
|
41
|
+
};
|
|
42
|
+
const WebKitContext = React.createContext(defaultValue);
|
|
43
|
+
function WebKitProvider(props) {
|
|
44
|
+
const { options = {}, immediate = true, children } = props;
|
|
45
|
+
const isSSR = typeof window === 'undefined';
|
|
46
|
+
const { useState, useEffect, useMemo, createElement } = React;
|
|
47
|
+
const [ready, setReady] = useState(false);
|
|
48
|
+
const [controller, setController] = useState(null);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
// Skip initialization on SSR
|
|
51
|
+
if (isSSR) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
let isMounted = true;
|
|
55
|
+
const initialize = async () => {
|
|
56
|
+
const { initWebKit } = await import('../init');
|
|
57
|
+
const ctrl = initWebKit(options);
|
|
58
|
+
if (isMounted) {
|
|
59
|
+
setController(ctrl);
|
|
60
|
+
}
|
|
61
|
+
await ctrl.ready;
|
|
62
|
+
if (isMounted) {
|
|
63
|
+
setReady(true);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
initialize();
|
|
67
|
+
return () => {
|
|
68
|
+
isMounted = false;
|
|
69
|
+
controller?.dispose();
|
|
70
|
+
return undefined;
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
const value = useMemo(() => {
|
|
74
|
+
return {
|
|
75
|
+
ready,
|
|
76
|
+
theme: controller?.theme
|
|
77
|
+
};
|
|
78
|
+
}, [ready, controller]);
|
|
79
|
+
// On SSR, just render children directly
|
|
80
|
+
if (isSSR) {
|
|
81
|
+
return children;
|
|
82
|
+
}
|
|
83
|
+
// Don't render children until ready if immediate is false
|
|
84
|
+
if (!immediate && !ready) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return createElement(WebKitContext.Provider, { value }, children);
|
|
88
|
+
}
|
|
89
|
+
function useWebKitContext() {
|
|
90
|
+
const context = React.useContext(WebKitContext);
|
|
91
|
+
// On SSR, context will be the default value anyway
|
|
92
|
+
return context;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
WebKitProvider,
|
|
96
|
+
useWebKitContext
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* React type definitions for @easemate/web-kit
|
|
4
|
+
*
|
|
5
|
+
* These types are provided for consumers using React/Next.js with this library.
|
|
6
|
+
* React is NOT a dependency of this package - these are interface definitions only.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|