@susilkumar006/widgets-test 1.0.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 +445 -0
- package/dist/api/FacePeApiClient.d.cts +74 -0
- package/dist/api/FacePeApiClient.d.ts +74 -0
- package/dist/api/FacePeApiContext.d.cts +8 -0
- package/dist/api/FacePeApiContext.d.ts +8 -0
- package/dist/api/decoders.d.cts +48 -0
- package/dist/api/decoders.d.ts +48 -0
- package/dist/api/index.d.cts +8 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/json.d.cts +5 -0
- package/dist/api/json.d.ts +5 -0
- package/dist/api/useFacePeResource.d.cts +21 -0
- package/dist/api/useFacePeResource.d.ts +21 -0
- package/dist/components/Avatar/FacePeAvatar.d.cts +23 -0
- package/dist/components/Avatar/FacePeAvatar.d.ts +23 -0
- package/dist/components/Avatar/engines.d.cts +30 -0
- package/dist/components/Avatar/engines.d.ts +30 -0
- package/dist/components/Avatar/index.d.cts +1 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Form/FacePeForm.d.cts +19 -0
- package/dist/components/Form/FacePeForm.d.ts +19 -0
- package/dist/components/Form/index.d.cts +1 -0
- package/dist/components/Form/index.d.ts +1 -0
- package/dist/components/Picker/FacePePicker.d.cts +22 -0
- package/dist/components/Picker/FacePePicker.d.ts +22 -0
- package/dist/components/Picker/index.d.cts +1 -0
- package/dist/components/Picker/index.d.ts +1 -0
- package/dist/components/Placement/FacePeOverlay.d.cts +13 -0
- package/dist/components/Placement/FacePeOverlay.d.ts +13 -0
- package/dist/components/Placement/FacePePage.d.cts +10 -0
- package/dist/components/Placement/FacePePage.d.ts +10 -0
- package/dist/components/Placement/index.d.cts +2 -0
- package/dist/components/Placement/index.d.ts +2 -0
- package/dist/components/Timeline/FacePeTimeline.d.cts +23 -0
- package/dist/components/Timeline/FacePeTimeline.d.ts +23 -0
- package/dist/components/Timeline/index.d.cts +1 -0
- package/dist/components/Timeline/index.d.ts +1 -0
- package/dist/components/shared/FacePeErrorBoundary.d.cts +28 -0
- package/dist/components/shared/FacePeErrorBoundary.d.ts +28 -0
- package/dist/components/shared/surface.d.cts +6 -0
- package/dist/components/shared/surface.d.ts +6 -0
- package/dist/context/FacePeContext.d.cts +22 -0
- package/dist/context/FacePeContext.d.ts +22 -0
- package/dist/context/avatar.d.cts +6 -0
- package/dist/context/avatar.d.ts +6 -0
- package/dist/context/index.d.cts +5 -0
- package/dist/context/index.d.ts +5 -0
- package/dist/context/navigation.d.cts +10 -0
- package/dist/context/navigation.d.ts +10 -0
- package/dist/events/FacePeEventEmitter.d.cts +59 -0
- package/dist/events/FacePeEventEmitter.d.ts +59 -0
- package/dist/events/createCorrelationId.d.cts +9 -0
- package/dist/events/createCorrelationId.d.ts +9 -0
- package/dist/events/index.d.cts +8 -0
- package/dist/events/index.d.ts +8 -0
- package/dist/events/telemetry.d.cts +11 -0
- package/dist/events/telemetry.d.ts +11 -0
- package/dist/events/useFacePeEmitter.d.cts +15 -0
- package/dist/events/useFacePeEmitter.d.ts +15 -0
- package/dist/index.cjs +1925 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +1903 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/FacePeCustomerPayload.schema.json +31 -0
- package/dist/schemas/FacePeError.schema.json +63 -0
- package/dist/schemas/FacePeEventMeta.schema.json +53 -0
- package/dist/schemas/FacePeFormValues.schema.json +27 -0
- package/dist/schemas/FacePeNavigationRequest.schema.json +33 -0
- package/dist/schemas/FacePePickerOption.schema.json +34 -0
- package/dist/schemas/FacePePickerOptionsPayload.schema.json +49 -0
- package/dist/schemas/FacePeTelemetryEvent.schema.json +66 -0
- package/dist/schemas/FacePeTimelineItem.schema.json +91 -0
- package/dist/schemas/FacePeTimelinePayload.schema.json +109 -0
- package/dist/styles.css +887 -0
- package/dist/types/api.d.cts +60 -0
- package/dist/types/api.d.ts +60 -0
- package/dist/types/avatar.d.cts +102 -0
- package/dist/types/avatar.d.ts +102 -0
- package/dist/types/common.d.cts +42 -0
- package/dist/types/common.d.ts +42 -0
- package/dist/types/components.d.cts +53 -0
- package/dist/types/components.d.ts +53 -0
- package/dist/types/config.d.cts +27 -0
- package/dist/types/config.d.ts +27 -0
- package/dist/types/events.d.cts +85 -0
- package/dist/types/events.d.ts +85 -0
- package/dist/types/form.d.cts +83 -0
- package/dist/types/form.d.ts +83 -0
- package/dist/types/index.d.cts +18 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/picker.d.cts +82 -0
- package/dist/types/picker.d.ts +82 -0
- package/dist/types/placement.d.cts +69 -0
- package/dist/types/placement.d.ts +69 -0
- package/dist/types/provider.d.cts +75 -0
- package/dist/types/provider.d.ts +75 -0
- package/dist/types/results.d.cts +28 -0
- package/dist/types/results.d.ts +28 -0
- package/dist/types/telemetry.d.cts +38 -0
- package/dist/types/telemetry.d.ts +38 -0
- package/dist/types/timeline.d.cts +103 -0
- package/dist/types/timeline.d.ts +103 -0
- package/dist/version.d.cts +2 -0
- package/dist/version.d.ts +2 -0
- package/package.json +71 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Events: how a component reports outcomes to the host.
|
|
3
|
+
*
|
|
4
|
+
* Every event is an envelope of `type`, `payload` and `meta`. Components declare
|
|
5
|
+
* their events as a map of event name → payload type; the typed `on…`
|
|
6
|
+
* handler props are derived from that map, so handler names and event types
|
|
7
|
+
* cannot drift apart.
|
|
8
|
+
*/
|
|
9
|
+
import type { CorrelationId, EntityId, FacePeError } from './common.js';
|
|
10
|
+
/** Metadata stamped on every event. Never carries credentials. */
|
|
11
|
+
export interface FacePeEventMeta {
|
|
12
|
+
/**
|
|
13
|
+
* Version of the envelope's shape (`type`, `payload`, `meta`). Changes only
|
|
14
|
+
* if that shape changes incompatibly, independently of `sdkVersion`.
|
|
15
|
+
*/
|
|
16
|
+
readonly schemaVersion: 1;
|
|
17
|
+
/** Ties the event to the request and gateway log entries that caused it. */
|
|
18
|
+
readonly correlationId: CorrelationId;
|
|
19
|
+
/** When the event was emitted, as an ISO 8601 timestamp. */
|
|
20
|
+
readonly timestamp: string;
|
|
21
|
+
/** Version of the SDK that emitted the event. */
|
|
22
|
+
readonly sdkVersion: string;
|
|
23
|
+
/** Name of the emitting component, e.g. "FacePeForm". */
|
|
24
|
+
readonly source: string;
|
|
25
|
+
/** The entity the emitting component works on, when it was given an `entityId`. */
|
|
26
|
+
readonly entityId?: EntityId;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A request to navigate, raised by a component and carried out by the host's
|
|
30
|
+
* router (the SDK never changes the URL itself).
|
|
31
|
+
*/
|
|
32
|
+
export type FacePeNavigationRequest = {
|
|
33
|
+
/** Destination, as the host's routing understands it (a route name, path or deep link). */
|
|
34
|
+
readonly to: string;
|
|
35
|
+
/** Route parameters. @default none */
|
|
36
|
+
readonly params?: Readonly<Record<string, string>>;
|
|
37
|
+
/** Replace the current history entry instead of pushing one. @default false */
|
|
38
|
+
readonly replace?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The envelope every FacePe event is delivered in.
|
|
42
|
+
*
|
|
43
|
+
* @typeParam TType - the event name, e.g. "submit".
|
|
44
|
+
* @typeParam TPayload - the event's data.
|
|
45
|
+
*/
|
|
46
|
+
export interface FacePeEvent<TType extends string = string, TPayload = unknown> {
|
|
47
|
+
readonly type: TType;
|
|
48
|
+
readonly payload: TPayload;
|
|
49
|
+
readonly meta: FacePeEventMeta;
|
|
50
|
+
}
|
|
51
|
+
/** Map of event name → payload type that a component emits. */
|
|
52
|
+
export type FacePeEventMap = Readonly<Record<string, unknown>>;
|
|
53
|
+
/**
|
|
54
|
+
* The standard events defined by the architecture, by category:
|
|
55
|
+
* - lifecycle: `ready`, `error`
|
|
56
|
+
* - intent: `select`, `submit`, `cancel`
|
|
57
|
+
* - navigation: `navigate`
|
|
58
|
+
*
|
|
59
|
+
* `error` and `navigate` have fixed payloads; the others are `unknown` here,
|
|
60
|
+
* and a component narrows the ones it emits by intersecting this map with its
|
|
61
|
+
* own, e.g. `FacePeStandardEvents & { submit: MyFormValues }`.
|
|
62
|
+
*/
|
|
63
|
+
export type FacePeStandardEvents = {
|
|
64
|
+
readonly ready: unknown;
|
|
65
|
+
readonly select: unknown;
|
|
66
|
+
readonly submit: unknown;
|
|
67
|
+
readonly cancel: unknown;
|
|
68
|
+
readonly navigate: FacePeNavigationRequest;
|
|
69
|
+
readonly error: FacePeError;
|
|
70
|
+
};
|
|
71
|
+
/** The name of a standard event. */
|
|
72
|
+
export type FacePeEventType = keyof FacePeStandardEvents;
|
|
73
|
+
/** A callback receiving one event envelope. */
|
|
74
|
+
export type FacePeEventHandler<TEvent extends FacePeEvent> = (event: TEvent) => void;
|
|
75
|
+
/**
|
|
76
|
+
* The optional `on…` handler props derived from an event map:
|
|
77
|
+
* `{ submit: X }` becomes `{ onSubmit?: (event: FacePeEvent<'submit', X>) => void }`.
|
|
78
|
+
*/
|
|
79
|
+
export type FacePeEventHandlers<TEvents extends FacePeEventMap = FacePeStandardEvents> = {
|
|
80
|
+
readonly [K in keyof TEvents & string as `on${Capitalize<K>}`]?: FacePeEventHandler<FacePeEvent<K, TEvents[K]>>;
|
|
81
|
+
};
|
|
82
|
+
/** Union of every event envelope a component with this event map can emit. */
|
|
83
|
+
export type FacePeEventOf<TEvents extends FacePeEventMap = FacePeStandardEvents> = {
|
|
84
|
+
[K in keyof TEvents & string]: FacePeEvent<K, TEvents[K]>;
|
|
85
|
+
}[keyof TEvents & string];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts of `<FacePeForm>`.
|
|
3
|
+
*/
|
|
4
|
+
import type { FacePeComponentProps, FacePeHandleMethod } from './components.cjs';
|
|
5
|
+
import type { FacePeStandardEvents } from './events.cjs';
|
|
6
|
+
import type { FacePeFallbackContext } from './placement.cjs';
|
|
7
|
+
import type { AsyncResult } from './results.cjs';
|
|
8
|
+
/** The values the form collects. Deliberately small until the backend contract exists. */
|
|
9
|
+
export type FacePeFormValues = {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly email: string;
|
|
12
|
+
readonly notes: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Events `<FacePeForm>` emits: its payload for each standard event it uses.
|
|
16
|
+
* `ready` and `cancel` carry no data (`null`).
|
|
17
|
+
*/
|
|
18
|
+
export type FacePeFormEvents = {
|
|
19
|
+
readonly ready: null;
|
|
20
|
+
readonly submit: FacePeFormValues;
|
|
21
|
+
readonly cancel: null;
|
|
22
|
+
readonly error: FacePeStandardEvents['error'];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* What the `actions` slot's render function receives: the form's own submit
|
|
26
|
+
* and cancel, so a host-rendered action bar behaves like the built-in one.
|
|
27
|
+
*/
|
|
28
|
+
export type FacePeFormActionsContext = {
|
|
29
|
+
/** Validates and submits (the same path as the built-in Submit button). */
|
|
30
|
+
readonly submit: () => void;
|
|
31
|
+
/** Emits `cancel` (the same as the built-in Cancel button). */
|
|
32
|
+
readonly cancel: () => void;
|
|
33
|
+
/** A submission is in progress. */
|
|
34
|
+
readonly submitting: boolean;
|
|
35
|
+
/** The form is in `view` mode. */
|
|
36
|
+
readonly readOnly: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Host-rendered regions of the form: `header` above the fields, `actions`
|
|
40
|
+
* replacing the built-in Cancel/Submit bar, `footer` below it, and `fallback`
|
|
41
|
+
* in place of the form if it fails to render. @default none
|
|
42
|
+
*/
|
|
43
|
+
export type FacePeFormSlots = {
|
|
44
|
+
readonly header: void;
|
|
45
|
+
readonly actions: FacePeFormActionsContext;
|
|
46
|
+
readonly footer: void;
|
|
47
|
+
readonly fallback: FacePeFallbackContext;
|
|
48
|
+
};
|
|
49
|
+
/** Field layout: one field per row, or name and email side by side when the container is wide enough. */
|
|
50
|
+
export type FacePeFormVariant = 'stacked' | 'inline';
|
|
51
|
+
/**
|
|
52
|
+
* Work to run with validated values before `submit` is emitted, e.g. saving
|
|
53
|
+
* them. The form shows its submitting state until it resolves. It resolves to
|
|
54
|
+
* a `Result`; a rejection is treated as a failure too.
|
|
55
|
+
*/
|
|
56
|
+
export type FacePeFormSubmitAction = (values: FacePeFormValues) => AsyncResult<void>;
|
|
57
|
+
/** Props of `<FacePeForm>`. Configuration props override the provider's for this form. */
|
|
58
|
+
export type FacePeFormProps = FacePeComponentProps<FacePeFormEvents, FacePeFormSlots> & {
|
|
59
|
+
/**
|
|
60
|
+
* Values the form starts with, and returns to on `reset()`. Leave out to
|
|
61
|
+
* pass the entity by reference instead: with an `entityId` (an order id)
|
|
62
|
+
* the form loads that order's customer details through the gateway.
|
|
63
|
+
* @default loaded by `entityId`; all empty without one
|
|
64
|
+
*/
|
|
65
|
+
readonly initialValues?: Partial<FacePeFormValues>;
|
|
66
|
+
/**
|
|
67
|
+
* @default with an `entityId` and no `initialValues`: the values are saved
|
|
68
|
+
* to that order through the gateway before `submit` is emitted; otherwise
|
|
69
|
+
* `submit` is emitted as soon as the values are valid
|
|
70
|
+
*/
|
|
71
|
+
readonly submitAction?: FacePeFormSubmitAction;
|
|
72
|
+
/** Layout variant (customization rung L2). @default 'stacked' */
|
|
73
|
+
readonly variant?: FacePeFormVariant;
|
|
74
|
+
};
|
|
75
|
+
/** Imperative handle of `<FacePeForm>`, reached through a React `ref`. */
|
|
76
|
+
export interface FacePeFormHandle {
|
|
77
|
+
/** Validates and shows any errors, without submitting. */
|
|
78
|
+
readonly validate: FacePeHandleMethod<[], FacePeFormValues>;
|
|
79
|
+
/** Restores `initialValues` (or the last loaded or saved values) and clears errors. */
|
|
80
|
+
readonly reset: FacePeHandleMethod;
|
|
81
|
+
/** Moves keyboard focus to the first field. */
|
|
82
|
+
readonly focus: FacePeHandleMethod;
|
|
83
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts of `<FacePeForm>`.
|
|
3
|
+
*/
|
|
4
|
+
import type { FacePeComponentProps, FacePeHandleMethod } from './components.js';
|
|
5
|
+
import type { FacePeStandardEvents } from './events.js';
|
|
6
|
+
import type { FacePeFallbackContext } from './placement.js';
|
|
7
|
+
import type { AsyncResult } from './results.js';
|
|
8
|
+
/** The values the form collects. Deliberately small until the backend contract exists. */
|
|
9
|
+
export type FacePeFormValues = {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly email: string;
|
|
12
|
+
readonly notes: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Events `<FacePeForm>` emits: its payload for each standard event it uses.
|
|
16
|
+
* `ready` and `cancel` carry no data (`null`).
|
|
17
|
+
*/
|
|
18
|
+
export type FacePeFormEvents = {
|
|
19
|
+
readonly ready: null;
|
|
20
|
+
readonly submit: FacePeFormValues;
|
|
21
|
+
readonly cancel: null;
|
|
22
|
+
readonly error: FacePeStandardEvents['error'];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* What the `actions` slot's render function receives: the form's own submit
|
|
26
|
+
* and cancel, so a host-rendered action bar behaves like the built-in one.
|
|
27
|
+
*/
|
|
28
|
+
export type FacePeFormActionsContext = {
|
|
29
|
+
/** Validates and submits (the same path as the built-in Submit button). */
|
|
30
|
+
readonly submit: () => void;
|
|
31
|
+
/** Emits `cancel` (the same as the built-in Cancel button). */
|
|
32
|
+
readonly cancel: () => void;
|
|
33
|
+
/** A submission is in progress. */
|
|
34
|
+
readonly submitting: boolean;
|
|
35
|
+
/** The form is in `view` mode. */
|
|
36
|
+
readonly readOnly: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Host-rendered regions of the form: `header` above the fields, `actions`
|
|
40
|
+
* replacing the built-in Cancel/Submit bar, `footer` below it, and `fallback`
|
|
41
|
+
* in place of the form if it fails to render. @default none
|
|
42
|
+
*/
|
|
43
|
+
export type FacePeFormSlots = {
|
|
44
|
+
readonly header: void;
|
|
45
|
+
readonly actions: FacePeFormActionsContext;
|
|
46
|
+
readonly footer: void;
|
|
47
|
+
readonly fallback: FacePeFallbackContext;
|
|
48
|
+
};
|
|
49
|
+
/** Field layout: one field per row, or name and email side by side when the container is wide enough. */
|
|
50
|
+
export type FacePeFormVariant = 'stacked' | 'inline';
|
|
51
|
+
/**
|
|
52
|
+
* Work to run with validated values before `submit` is emitted, e.g. saving
|
|
53
|
+
* them. The form shows its submitting state until it resolves. It resolves to
|
|
54
|
+
* a `Result`; a rejection is treated as a failure too.
|
|
55
|
+
*/
|
|
56
|
+
export type FacePeFormSubmitAction = (values: FacePeFormValues) => AsyncResult<void>;
|
|
57
|
+
/** Props of `<FacePeForm>`. Configuration props override the provider's for this form. */
|
|
58
|
+
export type FacePeFormProps = FacePeComponentProps<FacePeFormEvents, FacePeFormSlots> & {
|
|
59
|
+
/**
|
|
60
|
+
* Values the form starts with, and returns to on `reset()`. Leave out to
|
|
61
|
+
* pass the entity by reference instead: with an `entityId` (an order id)
|
|
62
|
+
* the form loads that order's customer details through the gateway.
|
|
63
|
+
* @default loaded by `entityId`; all empty without one
|
|
64
|
+
*/
|
|
65
|
+
readonly initialValues?: Partial<FacePeFormValues>;
|
|
66
|
+
/**
|
|
67
|
+
* @default with an `entityId` and no `initialValues`: the values are saved
|
|
68
|
+
* to that order through the gateway before `submit` is emitted; otherwise
|
|
69
|
+
* `submit` is emitted as soon as the values are valid
|
|
70
|
+
*/
|
|
71
|
+
readonly submitAction?: FacePeFormSubmitAction;
|
|
72
|
+
/** Layout variant (customization rung L2). @default 'stacked' */
|
|
73
|
+
readonly variant?: FacePeFormVariant;
|
|
74
|
+
};
|
|
75
|
+
/** Imperative handle of `<FacePeForm>`, reached through a React `ref`. */
|
|
76
|
+
export interface FacePeFormHandle {
|
|
77
|
+
/** Validates and shows any errors, without submitting. */
|
|
78
|
+
readonly validate: FacePeHandleMethod<[], FacePeFormValues>;
|
|
79
|
+
/** Restores `initialValues` (or the last loaded or saved values) and clears errors. */
|
|
80
|
+
readonly reset: FacePeHandleMethod;
|
|
81
|
+
/** Moves keyboard focus to the first field. */
|
|
82
|
+
readonly focus: FacePeHandleMethod;
|
|
83
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public TypeScript contracts of @facepe/widgets.
|
|
3
|
+
*
|
|
4
|
+
* Only types listed here are public; src/index.ts re-exports this list.
|
|
5
|
+
*/
|
|
6
|
+
export type { CorrelationId, EntityId, FacePeDataObject, FacePeDensity, FacePeError, FacePeFeatureFlags, FacePeLocale, FacePeMode, JsonArray, JsonObject, JsonPrimitive, JsonValue, } from './common.cjs';
|
|
7
|
+
export type { FacePeConfig } from './config.cjs';
|
|
8
|
+
export type { FacePeEvent, FacePeEventHandler, FacePeEventHandlers, FacePeEventMap, FacePeEventMeta, FacePeEventOf, FacePeNavigationRequest, FacePeEventType, FacePeStandardEvents, } from './events.cjs';
|
|
9
|
+
export type { AsyncResult, Failure, Result, Success } from './results.cjs';
|
|
10
|
+
export type { FacePeAvatarControlsContext, FacePeAvatarEvents, FacePeAvatarHandle, FacePeAvatarInfo, FacePeAvatarProps, FacePeAvatarSession, FacePeAvatarSessionEnd, FacePeAvatarSlots, FacePeAvatarStatus, FacePeTranscriptLine, } from './avatar.cjs';
|
|
11
|
+
export type { FacePeTelemetry, FacePeTelemetryAttributes, FacePeTelemetryEvent } from './telemetry.cjs';
|
|
12
|
+
export type { FacePeContextValue, FacePeProviderProps } from './provider.cjs';
|
|
13
|
+
export type { FacePeColorScheme, FacePeFallbackContext, FacePeOverlayProps, FacePeOverlayVariant, FacePePageProps, FacePeThemeTokens, } from './placement.cjs';
|
|
14
|
+
export type { FacePeCustomerPayload, FacePeHttpMethod, FacePePickerOptionsPayload, FacePeTimelinePayload, FacePeProviderEvents, FacePeSessionExpiredPayload, FacePeTokenProvider, FacePeTokenRequest, } from './api.cjs';
|
|
15
|
+
export type { FacePeFormActionsContext, FacePeFormEvents, FacePeFormHandle, FacePeFormProps, FacePeFormSlots, FacePeFormSubmitAction, FacePeFormValues, FacePeFormVariant, } from './form.cjs';
|
|
16
|
+
export type { FacePePickerEvents, FacePePickerHandle, FacePePickerOption, FacePePickerOptionSlotContext, FacePePickerProps, FacePePickerSelection, FacePePickerSlots, FacePePickerVariant, } from './picker.cjs';
|
|
17
|
+
export type { FacePeTimelineEvents, FacePeTimelineHandle, FacePeTimelineItem, FacePeTimelineItemSlotContext, FacePeTimelineItemStatus, FacePeTimelineMetadata, FacePeTimelineProps, FacePeTimelineSelection, FacePeTimelineSlots, } from './timeline.cjs';
|
|
18
|
+
export type { FacePeComponentProps, FacePeEmphasis, FacePeHandle, FacePeHandleMethod, FacePeSlot, FacePeSlotMap, FacePeSize, FacePeSlots, } from './components.cjs';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public TypeScript contracts of @facepe/widgets.
|
|
3
|
+
*
|
|
4
|
+
* Only types listed here are public; src/index.ts re-exports this list.
|
|
5
|
+
*/
|
|
6
|
+
export type { CorrelationId, EntityId, FacePeDataObject, FacePeDensity, FacePeError, FacePeFeatureFlags, FacePeLocale, FacePeMode, JsonArray, JsonObject, JsonPrimitive, JsonValue, } from './common.js';
|
|
7
|
+
export type { FacePeConfig } from './config.js';
|
|
8
|
+
export type { FacePeEvent, FacePeEventHandler, FacePeEventHandlers, FacePeEventMap, FacePeEventMeta, FacePeEventOf, FacePeNavigationRequest, FacePeEventType, FacePeStandardEvents, } from './events.js';
|
|
9
|
+
export type { AsyncResult, Failure, Result, Success } from './results.js';
|
|
10
|
+
export type { FacePeAvatarControlsContext, FacePeAvatarEvents, FacePeAvatarHandle, FacePeAvatarInfo, FacePeAvatarProps, FacePeAvatarSession, FacePeAvatarSessionEnd, FacePeAvatarSlots, FacePeAvatarStatus, FacePeTranscriptLine, } from './avatar.js';
|
|
11
|
+
export type { FacePeTelemetry, FacePeTelemetryAttributes, FacePeTelemetryEvent } from './telemetry.js';
|
|
12
|
+
export type { FacePeContextValue, FacePeProviderProps } from './provider.js';
|
|
13
|
+
export type { FacePeColorScheme, FacePeFallbackContext, FacePeOverlayProps, FacePeOverlayVariant, FacePePageProps, FacePeThemeTokens, } from './placement.js';
|
|
14
|
+
export type { FacePeCustomerPayload, FacePeHttpMethod, FacePePickerOptionsPayload, FacePeTimelinePayload, FacePeProviderEvents, FacePeSessionExpiredPayload, FacePeTokenProvider, FacePeTokenRequest, } from './api.js';
|
|
15
|
+
export type { FacePeFormActionsContext, FacePeFormEvents, FacePeFormHandle, FacePeFormProps, FacePeFormSlots, FacePeFormSubmitAction, FacePeFormValues, FacePeFormVariant, } from './form.js';
|
|
16
|
+
export type { FacePePickerEvents, FacePePickerHandle, FacePePickerOption, FacePePickerOptionSlotContext, FacePePickerProps, FacePePickerSelection, FacePePickerSlots, FacePePickerVariant, } from './picker.js';
|
|
17
|
+
export type { FacePeTimelineEvents, FacePeTimelineHandle, FacePeTimelineItem, FacePeTimelineItemSlotContext, FacePeTimelineItemStatus, FacePeTimelineMetadata, FacePeTimelineProps, FacePeTimelineSelection, FacePeTimelineSlots, } from './timeline.js';
|
|
18
|
+
export type { FacePeComponentProps, FacePeEmphasis, FacePeHandle, FacePeHandleMethod, FacePeSlot, FacePeSlotMap, FacePeSize, FacePeSlots, } from './components.js';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts of `<FacePePicker>`.
|
|
3
|
+
*/
|
|
4
|
+
import type { FacePeComponentProps, FacePeHandleMethod } from './components.cjs';
|
|
5
|
+
import type { FacePeStandardEvents } from './events.cjs';
|
|
6
|
+
import type { FacePeFallbackContext } from './placement.cjs';
|
|
7
|
+
/** One choice in the picker. */
|
|
8
|
+
export type FacePePickerOption = {
|
|
9
|
+
/** Unique within the picker; what `select` reports. */
|
|
10
|
+
readonly value: string;
|
|
11
|
+
/** Text shown to the user. */
|
|
12
|
+
readonly label: string;
|
|
13
|
+
/** Secondary text, shown when the `picker.descriptions` feature flag is on. */
|
|
14
|
+
readonly description?: string;
|
|
15
|
+
/** Shown but not selectable. @default false */
|
|
16
|
+
readonly disabled?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** Payload of the `select` event and of a successful `select()` call. */
|
|
19
|
+
export type FacePePickerSelection = {
|
|
20
|
+
readonly value: string;
|
|
21
|
+
readonly label: string;
|
|
22
|
+
/** The value selected before this one, or `null` if there was none. */
|
|
23
|
+
readonly previousValue: string | null;
|
|
24
|
+
};
|
|
25
|
+
/** Events `<FacePePicker>` emits. `ready` carries no data (`null`). */
|
|
26
|
+
export type FacePePickerEvents = {
|
|
27
|
+
readonly ready: null;
|
|
28
|
+
readonly select: FacePePickerSelection;
|
|
29
|
+
readonly error: FacePeStandardEvents['error'];
|
|
30
|
+
};
|
|
31
|
+
/** What the `option` row renderer receives for each option. */
|
|
32
|
+
export type FacePePickerOptionSlotContext = {
|
|
33
|
+
readonly option: FacePePickerOption;
|
|
34
|
+
readonly selected: boolean;
|
|
35
|
+
readonly disabled: boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Host-rendered regions: `header` above the options, `option` rendering each
|
|
39
|
+
* option's content (the radio and its selection behaviour stay), `emptyState`
|
|
40
|
+
* in place of an empty list, and `fallback` in place of the picker if it
|
|
41
|
+
* fails to render. @default none
|
|
42
|
+
*/
|
|
43
|
+
export type FacePePickerSlots = {
|
|
44
|
+
readonly header: void;
|
|
45
|
+
readonly option: FacePePickerOptionSlotContext;
|
|
46
|
+
readonly emptyState: void;
|
|
47
|
+
readonly fallback: FacePeFallbackContext;
|
|
48
|
+
};
|
|
49
|
+
/** Option layout: one per row, or a grid filling the container's width. */
|
|
50
|
+
export type FacePePickerVariant = 'list' | 'grid';
|
|
51
|
+
/**
|
|
52
|
+
* Props of `<FacePePicker>`. Configuration props override the provider's;
|
|
53
|
+
* `featureFlags` are merged per flag, the picker's own winning.
|
|
54
|
+
*
|
|
55
|
+
* Feature flags read: `picker.descriptions` (show option descriptions).
|
|
56
|
+
*/
|
|
57
|
+
export type FacePePickerProps = FacePeComponentProps<FacePePickerEvents, FacePePickerSlots> & {
|
|
58
|
+
/** The group's accessible label, shown as its legend. @default 'Choose an option' */
|
|
59
|
+
readonly label?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The choices. Leave out to pass the entity by reference instead: with an
|
|
62
|
+
* `entityId` (a location id) the picker fetches that location's menu
|
|
63
|
+
* categories through the gateway (architecture §7.5).
|
|
64
|
+
* @default fetched by `entityId`; none without one
|
|
65
|
+
*/
|
|
66
|
+
readonly options?: readonly FacePePickerOption[];
|
|
67
|
+
/**
|
|
68
|
+
* Value selected once the options are known (on first render, or when
|
|
69
|
+
* fetched options arrive). Ignored, with an `error` event, if it names no
|
|
70
|
+
* option or a disabled one. @default none
|
|
71
|
+
*/
|
|
72
|
+
readonly defaultValue?: string;
|
|
73
|
+
/** Layout variant (customization rung L2). @default 'list' */
|
|
74
|
+
readonly variant?: FacePePickerVariant;
|
|
75
|
+
};
|
|
76
|
+
/** Imperative handle of `<FacePePicker>`, reached through a React `ref`. */
|
|
77
|
+
export interface FacePePickerHandle {
|
|
78
|
+
/** Moves keyboard focus into the picker. */
|
|
79
|
+
readonly focus: FacePeHandleMethod;
|
|
80
|
+
/** Returns to the initial selection (`defaultValue`, or none). Emits nothing. */
|
|
81
|
+
readonly reset: FacePeHandleMethod;
|
|
82
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts of `<FacePePicker>`.
|
|
3
|
+
*/
|
|
4
|
+
import type { FacePeComponentProps, FacePeHandleMethod } from './components.js';
|
|
5
|
+
import type { FacePeStandardEvents } from './events.js';
|
|
6
|
+
import type { FacePeFallbackContext } from './placement.js';
|
|
7
|
+
/** One choice in the picker. */
|
|
8
|
+
export type FacePePickerOption = {
|
|
9
|
+
/** Unique within the picker; what `select` reports. */
|
|
10
|
+
readonly value: string;
|
|
11
|
+
/** Text shown to the user. */
|
|
12
|
+
readonly label: string;
|
|
13
|
+
/** Secondary text, shown when the `picker.descriptions` feature flag is on. */
|
|
14
|
+
readonly description?: string;
|
|
15
|
+
/** Shown but not selectable. @default false */
|
|
16
|
+
readonly disabled?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** Payload of the `select` event and of a successful `select()` call. */
|
|
19
|
+
export type FacePePickerSelection = {
|
|
20
|
+
readonly value: string;
|
|
21
|
+
readonly label: string;
|
|
22
|
+
/** The value selected before this one, or `null` if there was none. */
|
|
23
|
+
readonly previousValue: string | null;
|
|
24
|
+
};
|
|
25
|
+
/** Events `<FacePePicker>` emits. `ready` carries no data (`null`). */
|
|
26
|
+
export type FacePePickerEvents = {
|
|
27
|
+
readonly ready: null;
|
|
28
|
+
readonly select: FacePePickerSelection;
|
|
29
|
+
readonly error: FacePeStandardEvents['error'];
|
|
30
|
+
};
|
|
31
|
+
/** What the `option` row renderer receives for each option. */
|
|
32
|
+
export type FacePePickerOptionSlotContext = {
|
|
33
|
+
readonly option: FacePePickerOption;
|
|
34
|
+
readonly selected: boolean;
|
|
35
|
+
readonly disabled: boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Host-rendered regions: `header` above the options, `option` rendering each
|
|
39
|
+
* option's content (the radio and its selection behaviour stay), `emptyState`
|
|
40
|
+
* in place of an empty list, and `fallback` in place of the picker if it
|
|
41
|
+
* fails to render. @default none
|
|
42
|
+
*/
|
|
43
|
+
export type FacePePickerSlots = {
|
|
44
|
+
readonly header: void;
|
|
45
|
+
readonly option: FacePePickerOptionSlotContext;
|
|
46
|
+
readonly emptyState: void;
|
|
47
|
+
readonly fallback: FacePeFallbackContext;
|
|
48
|
+
};
|
|
49
|
+
/** Option layout: one per row, or a grid filling the container's width. */
|
|
50
|
+
export type FacePePickerVariant = 'list' | 'grid';
|
|
51
|
+
/**
|
|
52
|
+
* Props of `<FacePePicker>`. Configuration props override the provider's;
|
|
53
|
+
* `featureFlags` are merged per flag, the picker's own winning.
|
|
54
|
+
*
|
|
55
|
+
* Feature flags read: `picker.descriptions` (show option descriptions).
|
|
56
|
+
*/
|
|
57
|
+
export type FacePePickerProps = FacePeComponentProps<FacePePickerEvents, FacePePickerSlots> & {
|
|
58
|
+
/** The group's accessible label, shown as its legend. @default 'Choose an option' */
|
|
59
|
+
readonly label?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The choices. Leave out to pass the entity by reference instead: with an
|
|
62
|
+
* `entityId` (a location id) the picker fetches that location's menu
|
|
63
|
+
* categories through the gateway (architecture §7.5).
|
|
64
|
+
* @default fetched by `entityId`; none without one
|
|
65
|
+
*/
|
|
66
|
+
readonly options?: readonly FacePePickerOption[];
|
|
67
|
+
/**
|
|
68
|
+
* Value selected once the options are known (on first render, or when
|
|
69
|
+
* fetched options arrive). Ignored, with an `error` event, if it names no
|
|
70
|
+
* option or a disabled one. @default none
|
|
71
|
+
*/
|
|
72
|
+
readonly defaultValue?: string;
|
|
73
|
+
/** Layout variant (customization rung L2). @default 'list' */
|
|
74
|
+
readonly variant?: FacePePickerVariant;
|
|
75
|
+
};
|
|
76
|
+
/** Imperative handle of `<FacePePicker>`, reached through a React `ref`. */
|
|
77
|
+
export interface FacePePickerHandle {
|
|
78
|
+
/** Moves keyboard focus into the picker. */
|
|
79
|
+
readonly focus: FacePeHandleMethod;
|
|
80
|
+
/** Returns to the initial selection (`defaultValue`, or none). Emits nothing. */
|
|
81
|
+
readonly reset: FacePeHandleMethod;
|
|
82
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts for how embedded experiences are placed and styled by the host:
|
|
3
|
+
* display modes, error fallback, and the design-token rung of the
|
|
4
|
+
* customization ladder.
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
import type { FacePeError } from './common.cjs';
|
|
8
|
+
/** What a component's `fallback` slot receives after the component failed to render. */
|
|
9
|
+
export type FacePeFallbackContext = {
|
|
10
|
+
/** Typed and safe to show or log: no stack trace, no credentials. */
|
|
11
|
+
readonly error: FacePeError;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Design tokens (customization rung L1), supplied by the host through the
|
|
15
|
+
* provider. Each is applied as the matching documented CSS custom property.
|
|
16
|
+
* The package hard-codes no colours or fonts: a token left out inherits from
|
|
17
|
+
* the host page (text colour, font, size) or stays neutral (transparent
|
|
18
|
+
* surface, borders tinted from the text colour). Values are plain CSS strings.
|
|
19
|
+
*/
|
|
20
|
+
export type FacePeThemeTokens = {
|
|
21
|
+
/** `--fp-color-surface` (frame and field background) @default transparent: the host's background */
|
|
22
|
+
readonly colorSurface?: string;
|
|
23
|
+
/** `--fp-color-surface-muted` (read-only fields, hover) @default a light tint of the text colour */
|
|
24
|
+
readonly colorSurfaceMuted?: string;
|
|
25
|
+
/** `--fp-color-text` @default inherited from the host */
|
|
26
|
+
readonly colorText?: string;
|
|
27
|
+
/** `--fp-color-muted` (secondary text) @default the text colour, partly transparent */
|
|
28
|
+
readonly colorMuted?: string;
|
|
29
|
+
/** `--fp-color-border` @default the text colour, mostly transparent */
|
|
30
|
+
readonly colorBorder?: string;
|
|
31
|
+
/** `--fp-color-accent` (primary action, focus, selection, links) @default the text colour */
|
|
32
|
+
readonly colorAccent?: string;
|
|
33
|
+
/** `--fp-color-on-accent` (text on the accent, e.g. the primary button) @default inherited text colour */
|
|
34
|
+
readonly colorOnAccent?: string;
|
|
35
|
+
/** `--fp-color-danger` (errors, failed status) @default the text colour */
|
|
36
|
+
readonly colorDanger?: string;
|
|
37
|
+
/** `--fp-color-success` (completed status) @default the text colour */
|
|
38
|
+
readonly colorSuccess?: string;
|
|
39
|
+
/** `--fp-font-family` @default inherited from the host */
|
|
40
|
+
readonly fontFamily?: string;
|
|
41
|
+
/** `--fp-font-size` (base of the type scale) @default inherited from the host */
|
|
42
|
+
readonly fontSize?: string;
|
|
43
|
+
/** `--fp-spacing` (unit of the spacing rhythm; gaps and padding are multiples) @default '0.25rem' */
|
|
44
|
+
readonly spacing?: string;
|
|
45
|
+
/** `--fp-radius` (field and button corners; frames use 1.5×) @default '0.375rem' */
|
|
46
|
+
readonly radius?: string;
|
|
47
|
+
/** `--fp-shadow` (elevation of `emphasis="strong"`) @default a soft shadow tinted from the text colour */
|
|
48
|
+
readonly shadow?: string;
|
|
49
|
+
};
|
|
50
|
+
/** Light or dark token scheme, chosen by the host (architecture §7.1). */
|
|
51
|
+
export type FacePeColorScheme = 'light' | 'dark';
|
|
52
|
+
/** Props of `<FacePePage>`: a component shown as a full view filling its container. */
|
|
53
|
+
export type FacePePageProps = {
|
|
54
|
+
readonly children?: ReactNode;
|
|
55
|
+
};
|
|
56
|
+
/** How `<FacePeOverlay>` presents: a centred modal or a side drawer. */
|
|
57
|
+
export type FacePeOverlayVariant = 'modal' | 'drawer';
|
|
58
|
+
/** Props of `<FacePeOverlay>`: a component shown over the page. */
|
|
59
|
+
export type FacePeOverlayProps = {
|
|
60
|
+
/** Whether it is shown. The host owns this state. */
|
|
61
|
+
readonly open: boolean;
|
|
62
|
+
/** The dialog's accessible name. */
|
|
63
|
+
readonly label: string;
|
|
64
|
+
/** @default 'modal' */
|
|
65
|
+
readonly variant?: FacePeOverlayVariant;
|
|
66
|
+
/** Asked to close (Escape). The host decides by setting `open`. @default none */
|
|
67
|
+
readonly onClose?: () => void;
|
|
68
|
+
readonly children?: ReactNode;
|
|
69
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts for how embedded experiences are placed and styled by the host:
|
|
3
|
+
* display modes, error fallback, and the design-token rung of the
|
|
4
|
+
* customization ladder.
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
import type { FacePeError } from './common.js';
|
|
8
|
+
/** What a component's `fallback` slot receives after the component failed to render. */
|
|
9
|
+
export type FacePeFallbackContext = {
|
|
10
|
+
/** Typed and safe to show or log: no stack trace, no credentials. */
|
|
11
|
+
readonly error: FacePeError;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Design tokens (customization rung L1), supplied by the host through the
|
|
15
|
+
* provider. Each is applied as the matching documented CSS custom property.
|
|
16
|
+
* The package hard-codes no colours or fonts: a token left out inherits from
|
|
17
|
+
* the host page (text colour, font, size) or stays neutral (transparent
|
|
18
|
+
* surface, borders tinted from the text colour). Values are plain CSS strings.
|
|
19
|
+
*/
|
|
20
|
+
export type FacePeThemeTokens = {
|
|
21
|
+
/** `--fp-color-surface` (frame and field background) @default transparent: the host's background */
|
|
22
|
+
readonly colorSurface?: string;
|
|
23
|
+
/** `--fp-color-surface-muted` (read-only fields, hover) @default a light tint of the text colour */
|
|
24
|
+
readonly colorSurfaceMuted?: string;
|
|
25
|
+
/** `--fp-color-text` @default inherited from the host */
|
|
26
|
+
readonly colorText?: string;
|
|
27
|
+
/** `--fp-color-muted` (secondary text) @default the text colour, partly transparent */
|
|
28
|
+
readonly colorMuted?: string;
|
|
29
|
+
/** `--fp-color-border` @default the text colour, mostly transparent */
|
|
30
|
+
readonly colorBorder?: string;
|
|
31
|
+
/** `--fp-color-accent` (primary action, focus, selection, links) @default the text colour */
|
|
32
|
+
readonly colorAccent?: string;
|
|
33
|
+
/** `--fp-color-on-accent` (text on the accent, e.g. the primary button) @default inherited text colour */
|
|
34
|
+
readonly colorOnAccent?: string;
|
|
35
|
+
/** `--fp-color-danger` (errors, failed status) @default the text colour */
|
|
36
|
+
readonly colorDanger?: string;
|
|
37
|
+
/** `--fp-color-success` (completed status) @default the text colour */
|
|
38
|
+
readonly colorSuccess?: string;
|
|
39
|
+
/** `--fp-font-family` @default inherited from the host */
|
|
40
|
+
readonly fontFamily?: string;
|
|
41
|
+
/** `--fp-font-size` (base of the type scale) @default inherited from the host */
|
|
42
|
+
readonly fontSize?: string;
|
|
43
|
+
/** `--fp-spacing` (unit of the spacing rhythm; gaps and padding are multiples) @default '0.25rem' */
|
|
44
|
+
readonly spacing?: string;
|
|
45
|
+
/** `--fp-radius` (field and button corners; frames use 1.5×) @default '0.375rem' */
|
|
46
|
+
readonly radius?: string;
|
|
47
|
+
/** `--fp-shadow` (elevation of `emphasis="strong"`) @default a soft shadow tinted from the text colour */
|
|
48
|
+
readonly shadow?: string;
|
|
49
|
+
};
|
|
50
|
+
/** Light or dark token scheme, chosen by the host (architecture §7.1). */
|
|
51
|
+
export type FacePeColorScheme = 'light' | 'dark';
|
|
52
|
+
/** Props of `<FacePePage>`: a component shown as a full view filling its container. */
|
|
53
|
+
export type FacePePageProps = {
|
|
54
|
+
readonly children?: ReactNode;
|
|
55
|
+
};
|
|
56
|
+
/** How `<FacePeOverlay>` presents: a centred modal or a side drawer. */
|
|
57
|
+
export type FacePeOverlayVariant = 'modal' | 'drawer';
|
|
58
|
+
/** Props of `<FacePeOverlay>`: a component shown over the page. */
|
|
59
|
+
export type FacePeOverlayProps = {
|
|
60
|
+
/** Whether it is shown. The host owns this state. */
|
|
61
|
+
readonly open: boolean;
|
|
62
|
+
/** The dialog's accessible name. */
|
|
63
|
+
readonly label: string;
|
|
64
|
+
/** @default 'modal' */
|
|
65
|
+
readonly variant?: FacePeOverlayVariant;
|
|
66
|
+
/** Asked to close (Escape). The host decides by setting `open`. @default none */
|
|
67
|
+
readonly onClose?: () => void;
|
|
68
|
+
readonly children?: ReactNode;
|
|
69
|
+
};
|