@timeax/digital-service-engine 0.3.4 → 0.3.6
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/core/index.cjs +680 -159
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +48 -6
- package/dist/core/index.d.ts +48 -6
- package/dist/core/index.js +671 -158
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.cjs +2123 -999
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +115 -58
- package/dist/react/index.d.ts +115 -58
- package/dist/react/index.js +2123 -999
- package/dist/react/index.js.map +1 -1
- package/dist/schema/index.d.cts +19 -2
- package/dist/schema/index.d.ts +19 -2
- package/dist/workspace/index.cjs +1291 -372
- package/dist/workspace/index.cjs.map +1 -1
- package/dist/workspace/index.d.cts +176 -5
- package/dist/workspace/index.d.ts +176 -5
- package/dist/workspace/index.js +1291 -372
- package/dist/workspace/index.js.map +1 -1
- package/package.json +1 -1
- package/schema/editor-snapshot.schema.json +38 -0
- package/schema/service-props.schema.json +38 -0
package/dist/react/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
type EventMap = Record<string, unknown>;
|
|
5
5
|
declare class EventBus<E extends EventMap> {
|
|
@@ -187,7 +187,7 @@ type NodeRef$1 = {
|
|
|
187
187
|
};
|
|
188
188
|
type NodeMap = Map<string, NodeRef$1>;
|
|
189
189
|
|
|
190
|
-
type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "option_include_exclude_conflict" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern" | "multiple_order_kinds_selected";
|
|
190
|
+
type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "bad_option_effect_key" | "bad_option_effect_target" | "bad_option_effect_option" | "option_include_exclude_conflict" | "visibility_dependency_cycle" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern" | "multiple_order_kinds_selected";
|
|
191
191
|
type ValidationError = {
|
|
192
192
|
code: ValidationCode;
|
|
193
193
|
message: string;
|
|
@@ -463,6 +463,22 @@ type FieldOption = {
|
|
|
463
463
|
service_id?: ServiceIdRef;
|
|
464
464
|
pricing_role?: PricingRole;
|
|
465
465
|
meta?: Record<string, unknown> & UtilityMark & WithQuantityDefault;
|
|
466
|
+
children?: FieldOption[];
|
|
467
|
+
};
|
|
468
|
+
type OptionEffectForButton = {
|
|
469
|
+
/**
|
|
470
|
+
* If true, selecting this button/option may force the target field visible.
|
|
471
|
+
* If false/missing, the option filter only applies when the target field is already visible.
|
|
472
|
+
*/
|
|
473
|
+
forceVisible?: boolean;
|
|
474
|
+
/**
|
|
475
|
+
* If present, only these option ids remain visible.
|
|
476
|
+
*/
|
|
477
|
+
include?: string[];
|
|
478
|
+
/**
|
|
479
|
+
* Removed after include is applied.
|
|
480
|
+
*/
|
|
481
|
+
exclude?: string[];
|
|
466
482
|
};
|
|
467
483
|
type Field = BaseFieldUI & {
|
|
468
484
|
id: string;
|
|
@@ -516,6 +532,7 @@ type ServiceProps = {
|
|
|
516
532
|
fields: Field[];
|
|
517
533
|
includes_for_buttons?: Record<string, string[]>;
|
|
518
534
|
excludes_for_buttons?: Record<string, string[]>;
|
|
535
|
+
option_effects_for_buttons?: Record<string, Record<string, OptionEffectForButton>>;
|
|
519
536
|
schema_version?: string;
|
|
520
537
|
fallbacks?: ServiceFallback;
|
|
521
538
|
name?: string;
|
|
@@ -611,6 +628,12 @@ type CommentThread = {
|
|
|
611
628
|
_sync?: "pending" | "synced" | "error";
|
|
612
629
|
};
|
|
613
630
|
|
|
631
|
+
type ResolvedVisibility = {
|
|
632
|
+
fieldIds: string[];
|
|
633
|
+
optionsByFieldId: Record<string, string[]>;
|
|
634
|
+
forcedFieldIds: string[];
|
|
635
|
+
};
|
|
636
|
+
|
|
614
637
|
/** Options you can set on the builder (used for validation/visibility) */
|
|
615
638
|
type BuilderOptions = Omit<ValidatorOptions, "serviceMap"> & {
|
|
616
639
|
serviceMap?: DgpServiceMap;
|
|
@@ -636,6 +659,8 @@ interface Builder {
|
|
|
636
659
|
* NOTE: keys are “button ids”: either option.id or field.id for option-less buttons.
|
|
637
660
|
*/
|
|
638
661
|
visibleFields(tagId: string, selectedOptionKeys?: string[]): string[];
|
|
662
|
+
/** Compute field ids plus option visibility under a tag. */
|
|
663
|
+
resolveVisibility(tagId: string, selectedOptionKeys?: string[]): ResolvedVisibility;
|
|
639
664
|
/** Update builder options (validator context etc.) */
|
|
640
665
|
setOptions(patch: Partial<BuilderOptions>): void;
|
|
641
666
|
/** Access the current props (already normalised) */
|
|
@@ -716,6 +741,8 @@ type VisibleGroup = {
|
|
|
716
741
|
tag?: Tag;
|
|
717
742
|
fields: Field[];
|
|
718
743
|
fieldIds: string[];
|
|
744
|
+
optionsByFieldId?: Record<string, string[]>;
|
|
745
|
+
forcedFieldIds?: string[];
|
|
719
746
|
parentTags?: Tag[];
|
|
720
747
|
childrenTags?: Tag[];
|
|
721
748
|
/** In order of selection: tag base (unless overridden) then selected options */
|
|
@@ -765,11 +792,10 @@ declare class Selection {
|
|
|
765
792
|
* What counts as a "button selection" (trigger key):
|
|
766
793
|
* - field key where the field has button === true (e.g. "f:dripfeed")
|
|
767
794
|
* - option key (e.g. "o:fast")
|
|
768
|
-
* - composite key "fieldId::optionId" (e.g. "f:speed::o:fast")
|
|
769
795
|
*
|
|
770
796
|
* Grouping:
|
|
771
797
|
* - button-field trigger groups under its own fieldId
|
|
772
|
-
* - option
|
|
798
|
+
* - option trigger groups under the option's owning fieldId (from nodeMap)
|
|
773
799
|
*
|
|
774
800
|
* Deterministic:
|
|
775
801
|
* - preserves selection insertion order
|
|
@@ -780,7 +806,6 @@ declare class Selection {
|
|
|
780
806
|
* Returns only selection keys that are valid "trigger buttons":
|
|
781
807
|
* - field keys where field.button === true
|
|
782
808
|
* - option keys
|
|
783
|
-
* - composite keys "fieldId::optionId" (validated by optionId)
|
|
784
809
|
* Excludes tags and non-button fields.
|
|
785
810
|
*/
|
|
786
811
|
selectedButtons(): string[];
|
|
@@ -790,6 +815,7 @@ declare class Selection {
|
|
|
790
815
|
private computeGroupForTag;
|
|
791
816
|
private addServiceByRole;
|
|
792
817
|
private findOptionById;
|
|
818
|
+
private isSelectedOptionVisible;
|
|
793
819
|
}
|
|
794
820
|
|
|
795
821
|
type CatalogId = string;
|
|
@@ -1511,6 +1537,69 @@ type QuantityRule = {
|
|
|
1511
1537
|
fallback?: number;
|
|
1512
1538
|
};
|
|
1513
1539
|
|
|
1540
|
+
/** Matches your InputWrapper’s expectations */
|
|
1541
|
+
type InputKind = string;
|
|
1542
|
+
type InputVariant = "default" | (string & {});
|
|
1543
|
+
type AdapterCtx = {
|
|
1544
|
+
field: Field;
|
|
1545
|
+
props: ServiceProps;
|
|
1546
|
+
};
|
|
1547
|
+
type Adapter = {
|
|
1548
|
+
valueProp?: string;
|
|
1549
|
+
changeProp?: string;
|
|
1550
|
+
errorProp?: string;
|
|
1551
|
+
/** normalize what the host emitted into what we store in form-palette */
|
|
1552
|
+
getValue?: (next: unknown, current: unknown, ctx: AdapterCtx) => unknown;
|
|
1553
|
+
/** REQUIRED if field.options exists */
|
|
1554
|
+
getSelectedOptions?: (next: unknown, current: unknown, ctx: AdapterCtx) => string[];
|
|
1555
|
+
/** For option-less action buttons (button: true with no options) */
|
|
1556
|
+
isActive?: (stored: unknown, ctx: AdapterCtx) => boolean;
|
|
1557
|
+
getInputPropsFromField?: (props: AdapterCtx) => any;
|
|
1558
|
+
toValue?: (value: any) => any;
|
|
1559
|
+
};
|
|
1560
|
+
type InputChildOptionCapability = {
|
|
1561
|
+
supported?: boolean;
|
|
1562
|
+
autoCreate?: boolean;
|
|
1563
|
+
defaultLabel?: string;
|
|
1564
|
+
defaultValue?: string | number;
|
|
1565
|
+
};
|
|
1566
|
+
type InputOptionCapability = {
|
|
1567
|
+
supported?: boolean;
|
|
1568
|
+
autoCreate?: boolean;
|
|
1569
|
+
defaultLabel?: string;
|
|
1570
|
+
defaultValue?: string | number;
|
|
1571
|
+
children?: InputChildOptionCapability;
|
|
1572
|
+
};
|
|
1573
|
+
type InputMultiCapability = {
|
|
1574
|
+
supported?: boolean;
|
|
1575
|
+
autoEnable?: boolean;
|
|
1576
|
+
};
|
|
1577
|
+
type InputDescriptor = {
|
|
1578
|
+
Component: React.ComponentType<Record<string, unknown>>;
|
|
1579
|
+
adapter?: Adapter;
|
|
1580
|
+
defaultProps?: Record<string, unknown>;
|
|
1581
|
+
ui?: Record<string, Ui>;
|
|
1582
|
+
options?: InputOptionCapability;
|
|
1583
|
+
multi?: InputMultiCapability;
|
|
1584
|
+
};
|
|
1585
|
+
type VariantMap = Map<InputVariant, InputDescriptor>;
|
|
1586
|
+
type RegistryStore = Map<InputKind, VariantMap>;
|
|
1587
|
+
type Registry = {
|
|
1588
|
+
get(kind: InputKind, variant?: InputVariant): InputDescriptor | undefined;
|
|
1589
|
+
register(kind: InputKind, descriptor: InputDescriptor, variant?: InputVariant): void;
|
|
1590
|
+
unregister(kind: InputKind, variant?: InputVariant): void;
|
|
1591
|
+
registerMany(entries: Array<{
|
|
1592
|
+
kind: InputKind;
|
|
1593
|
+
descriptor: InputDescriptor;
|
|
1594
|
+
variant?: InputVariant;
|
|
1595
|
+
}>): void;
|
|
1596
|
+
/** low-level escape hatch */
|
|
1597
|
+
_store: RegistryStore;
|
|
1598
|
+
};
|
|
1599
|
+
declare function createInputRegistry(): Registry;
|
|
1600
|
+
/** Helper used by InputWrapper */
|
|
1601
|
+
declare function resolveInputDescriptor(registry: Registry, kind: InputKind, variant?: InputVariant): InputDescriptor | undefined;
|
|
1602
|
+
|
|
1514
1603
|
declare class Editor {
|
|
1515
1604
|
private readonly builder;
|
|
1516
1605
|
private readonly api;
|
|
@@ -1582,7 +1671,14 @@ declare class Editor {
|
|
|
1582
1671
|
id?: string;
|
|
1583
1672
|
label: string;
|
|
1584
1673
|
type: Field["type"];
|
|
1585
|
-
}):
|
|
1674
|
+
}): string;
|
|
1675
|
+
addFieldFromDescriptor(registry: Registry, partial: Omit<Field, "id" | "label" | "type"> & {
|
|
1676
|
+
id?: string;
|
|
1677
|
+
label: string;
|
|
1678
|
+
type: Field["type"];
|
|
1679
|
+
}, opts?: {
|
|
1680
|
+
variant?: InputVariant;
|
|
1681
|
+
}): string;
|
|
1586
1682
|
updateField(id: string, patch: Partial<Field>): void;
|
|
1587
1683
|
removeField(id: string): void;
|
|
1588
1684
|
remove(id: string): void;
|
|
@@ -1601,6 +1697,7 @@ declare class Editor {
|
|
|
1601
1697
|
setPricingRoleMany(ids: readonly string[], role: "base" | "utility"): void;
|
|
1602
1698
|
clearFieldDefaultsMany(ids: readonly string[]): void;
|
|
1603
1699
|
clearFieldValidationMany(ids: readonly string[]): void;
|
|
1700
|
+
setFieldMulti(fieldId: string, enabled: boolean): void;
|
|
1604
1701
|
autoCreateOptionsMany(ids: readonly string[], makeOption?: (fieldId: string) => {
|
|
1605
1702
|
id?: string;
|
|
1606
1703
|
label: string;
|
|
@@ -1615,6 +1712,14 @@ declare class Editor {
|
|
|
1615
1712
|
clearFieldQuantityRule(id: string): void;
|
|
1616
1713
|
include(receiverId: string, idOrIds: string | string[]): void;
|
|
1617
1714
|
exclude(receiverId: string, idOrIds: string | string[]): void;
|
|
1715
|
+
setOptionEffect(triggerId: string, targetFieldId: string, effect: OptionEffectForButton | undefined | null): void;
|
|
1716
|
+
patchOptionEffect(triggerId: string, targetFieldId: string, patch: OptionEffectForButton): void;
|
|
1717
|
+
clearOptionEffect(triggerId: string, targetFieldId: string): void;
|
|
1718
|
+
clearOptionEffectsForTrigger(triggerId: string): void;
|
|
1719
|
+
clearOptionEffectsForTarget(targetFieldId: string): void;
|
|
1720
|
+
addOptionEffectOptions(triggerId: string, targetFieldId: string, kind: "include" | "exclude", optionIds: readonly string[]): void;
|
|
1721
|
+
removeOptionEffectOptions(triggerId: string, targetFieldId: string, kind: "include" | "exclude", optionIds: readonly string[]): void;
|
|
1722
|
+
setOptionEffectForceVisible(triggerId: string, targetFieldId: string, forceVisible: boolean | undefined): void;
|
|
1618
1723
|
connect(kind: WireKind, fromId: string, toId: string): void;
|
|
1619
1724
|
disconnect(kind: WireKind, fromId: string, toId: string): void;
|
|
1620
1725
|
setConstraint(tagId: string, flag: string, value: boolean | undefined): void;
|
|
@@ -1825,57 +1930,6 @@ type FormProviderProps = {
|
|
|
1825
1930
|
};
|
|
1826
1931
|
declare function FormProvider({ children, schema, initial }: FormProviderProps): react_jsx_runtime.JSX.Element;
|
|
1827
1932
|
|
|
1828
|
-
/** Matches your InputWrapper’s expectations */
|
|
1829
|
-
type InputKind = string;
|
|
1830
|
-
type InputVariant = "default" | (string & {});
|
|
1831
|
-
type AdapterCtx = {
|
|
1832
|
-
field: Field;
|
|
1833
|
-
props: ServiceProps;
|
|
1834
|
-
};
|
|
1835
|
-
type Adapter = {
|
|
1836
|
-
valueProp?: string;
|
|
1837
|
-
changeProp?: string;
|
|
1838
|
-
errorProp?: string;
|
|
1839
|
-
/** normalize what the host emitted into what we store in form-palette */
|
|
1840
|
-
getValue?: (next: unknown, current: unknown, ctx: AdapterCtx) => unknown;
|
|
1841
|
-
/** REQUIRED if field.options exists */
|
|
1842
|
-
getSelectedOptions?: (next: unknown, current: unknown, ctx: AdapterCtx) => string[];
|
|
1843
|
-
/** For option-less action buttons (button: true with no options) */
|
|
1844
|
-
isActive?: (stored: unknown, ctx: AdapterCtx) => boolean;
|
|
1845
|
-
getInputPropsFromField?: (props: AdapterCtx) => any;
|
|
1846
|
-
toValue?: (value: any) => any;
|
|
1847
|
-
};
|
|
1848
|
-
type InputOptionCapability = {
|
|
1849
|
-
supported?: boolean;
|
|
1850
|
-
autoCreate?: boolean;
|
|
1851
|
-
defaultLabel?: string;
|
|
1852
|
-
defaultValue?: string | number;
|
|
1853
|
-
};
|
|
1854
|
-
type InputDescriptor = {
|
|
1855
|
-
Component: React.ComponentType<Record<string, unknown>>;
|
|
1856
|
-
adapter?: Adapter;
|
|
1857
|
-
defaultProps?: Record<string, unknown>;
|
|
1858
|
-
ui?: Record<string, Ui>;
|
|
1859
|
-
options?: InputOptionCapability;
|
|
1860
|
-
};
|
|
1861
|
-
type VariantMap = Map<InputVariant, InputDescriptor>;
|
|
1862
|
-
type RegistryStore = Map<InputKind, VariantMap>;
|
|
1863
|
-
type Registry = {
|
|
1864
|
-
get(kind: InputKind, variant?: InputVariant): InputDescriptor | undefined;
|
|
1865
|
-
register(kind: InputKind, descriptor: InputDescriptor, variant?: InputVariant): void;
|
|
1866
|
-
unregister(kind: InputKind, variant?: InputVariant): void;
|
|
1867
|
-
registerMany(entries: Array<{
|
|
1868
|
-
kind: InputKind;
|
|
1869
|
-
descriptor: InputDescriptor;
|
|
1870
|
-
variant?: InputVariant;
|
|
1871
|
-
}>): void;
|
|
1872
|
-
/** low-level escape hatch */
|
|
1873
|
-
_store: RegistryStore;
|
|
1874
|
-
};
|
|
1875
|
-
declare function createInputRegistry(): Registry;
|
|
1876
|
-
/** Helper used by InputWrapper */
|
|
1877
|
-
declare function resolveInputDescriptor(registry: Registry, kind: InputKind, variant?: InputVariant): InputDescriptor | undefined;
|
|
1878
|
-
|
|
1879
1933
|
type InputsCtxValue = {
|
|
1880
1934
|
registry: Registry;
|
|
1881
1935
|
register: (kind: InputKind, descriptor: InputDescriptor, variant?: InputVariant) => void;
|
|
@@ -2026,6 +2080,8 @@ type UseOrderFlowReturn = {
|
|
|
2026
2080
|
raw: ServiceProps;
|
|
2027
2081
|
/** visibility is Selection-only */
|
|
2028
2082
|
visibleGroup: VisibleGroup | null;
|
|
2083
|
+
visibleOptionsByFieldId: Record<string, string[]>;
|
|
2084
|
+
forcedFieldIds: string[];
|
|
2029
2085
|
/**
|
|
2030
2086
|
* Values are from form-palette (values()) and are already "visible-only"
|
|
2031
2087
|
* because your UI mounts only visible fields.
|
|
@@ -2045,6 +2101,7 @@ type UseOrderFlowReturn = {
|
|
|
2045
2101
|
max: number;
|
|
2046
2102
|
selectTag: (tagId: string) => void;
|
|
2047
2103
|
toggleOption: (fieldId: string, optionId?: string) => void;
|
|
2104
|
+
setFieldOptions: (fieldId: string, optionIds: string[]) => void;
|
|
2048
2105
|
/** programmatic value set (rare; wrapper/field hook should handle most) */
|
|
2049
2106
|
setValue: (fieldId: string, value: Scalar | Scalar[]) => void;
|
|
2050
2107
|
clearField: (fieldId: string) => void;
|
|
@@ -2283,4 +2340,4 @@ type Props = {
|
|
|
2283
2340
|
};
|
|
2284
2341
|
declare function FallbackAddRegistrationDialog({ open, onClose, onSelect, }: Props): react_jsx_runtime.JSX.Element | null;
|
|
2285
2342
|
|
|
2286
|
-
export { type Adapter, type AdapterCtx, CanvasAPI, type EditorSettings, EventBus, type EventMap, FallbackAddCandidatesDialog, FallbackAddRegistrationDialog, FallbackDetailsPanel, FallbackEditor, type FallbackEditorData, FallbackEditorHeader, FallbackEditorProvider, type FallbackEditorProviderProps, FallbackRegistrationsPanel, FallbackServiceSidebar, FallbackSettingsPanel, type FormApi, FormProvider, type FormProviderProps, type FormSnapshot, type InputDescriptor, type InputKind, type InputOptionCapability, type InputVariant, type InputWrapperProps, OrderFlowProvider, Provider, type RegistrationItem, type RegistrationScope, type Registry, type ServiceSummary, type ValidationMessage, type ValidationTone, VirtualServiceList, Wrapper, createInputRegistry, registerEntries, resolveInputDescriptor, useActiveFallbackRegistrations, useEligibleServiceList, useFallbackEditor, useFallbackEditorContext, useFormApi, useInputs, useInputsMaybe, useOptionalFormApi, useOrderFlow, useOrderFlowContext, usePrimaryServiceList };
|
|
2343
|
+
export { type Adapter, type AdapterCtx, CanvasAPI, type EditorSettings, EventBus, type EventMap, FallbackAddCandidatesDialog, FallbackAddRegistrationDialog, FallbackDetailsPanel, FallbackEditor, type FallbackEditorData, FallbackEditorHeader, FallbackEditorProvider, type FallbackEditorProviderProps, FallbackRegistrationsPanel, FallbackServiceSidebar, FallbackSettingsPanel, type FormApi, FormProvider, type FormProviderProps, type FormSnapshot, type InputChildOptionCapability, type InputDescriptor, type InputKind, type InputMultiCapability, type InputOptionCapability, type InputVariant, type InputWrapperProps, OrderFlowProvider, Provider, type RegistrationItem, type RegistrationScope, type Registry, type ServiceSummary, type ValidationMessage, type ValidationTone, VirtualServiceList, Wrapper, createInputRegistry, registerEntries, resolveInputDescriptor, useActiveFallbackRegistrations, useEligibleServiceList, useFallbackEditor, useFallbackEditorContext, useFormApi, useInputs, useInputsMaybe, useOptionalFormApi, useOrderFlow, useOrderFlowContext, usePrimaryServiceList };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
type EventMap = Record<string, unknown>;
|
|
5
5
|
declare class EventBus<E extends EventMap> {
|
|
@@ -187,7 +187,7 @@ type NodeRef$1 = {
|
|
|
187
187
|
};
|
|
188
188
|
type NodeMap = Map<string, NodeRef$1>;
|
|
189
189
|
|
|
190
|
-
type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "option_include_exclude_conflict" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern" | "multiple_order_kinds_selected";
|
|
190
|
+
type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "bad_option_effect_key" | "bad_option_effect_target" | "bad_option_effect_option" | "option_include_exclude_conflict" | "visibility_dependency_cycle" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern" | "multiple_order_kinds_selected";
|
|
191
191
|
type ValidationError = {
|
|
192
192
|
code: ValidationCode;
|
|
193
193
|
message: string;
|
|
@@ -463,6 +463,22 @@ type FieldOption = {
|
|
|
463
463
|
service_id?: ServiceIdRef;
|
|
464
464
|
pricing_role?: PricingRole;
|
|
465
465
|
meta?: Record<string, unknown> & UtilityMark & WithQuantityDefault;
|
|
466
|
+
children?: FieldOption[];
|
|
467
|
+
};
|
|
468
|
+
type OptionEffectForButton = {
|
|
469
|
+
/**
|
|
470
|
+
* If true, selecting this button/option may force the target field visible.
|
|
471
|
+
* If false/missing, the option filter only applies when the target field is already visible.
|
|
472
|
+
*/
|
|
473
|
+
forceVisible?: boolean;
|
|
474
|
+
/**
|
|
475
|
+
* If present, only these option ids remain visible.
|
|
476
|
+
*/
|
|
477
|
+
include?: string[];
|
|
478
|
+
/**
|
|
479
|
+
* Removed after include is applied.
|
|
480
|
+
*/
|
|
481
|
+
exclude?: string[];
|
|
466
482
|
};
|
|
467
483
|
type Field = BaseFieldUI & {
|
|
468
484
|
id: string;
|
|
@@ -516,6 +532,7 @@ type ServiceProps = {
|
|
|
516
532
|
fields: Field[];
|
|
517
533
|
includes_for_buttons?: Record<string, string[]>;
|
|
518
534
|
excludes_for_buttons?: Record<string, string[]>;
|
|
535
|
+
option_effects_for_buttons?: Record<string, Record<string, OptionEffectForButton>>;
|
|
519
536
|
schema_version?: string;
|
|
520
537
|
fallbacks?: ServiceFallback;
|
|
521
538
|
name?: string;
|
|
@@ -611,6 +628,12 @@ type CommentThread = {
|
|
|
611
628
|
_sync?: "pending" | "synced" | "error";
|
|
612
629
|
};
|
|
613
630
|
|
|
631
|
+
type ResolvedVisibility = {
|
|
632
|
+
fieldIds: string[];
|
|
633
|
+
optionsByFieldId: Record<string, string[]>;
|
|
634
|
+
forcedFieldIds: string[];
|
|
635
|
+
};
|
|
636
|
+
|
|
614
637
|
/** Options you can set on the builder (used for validation/visibility) */
|
|
615
638
|
type BuilderOptions = Omit<ValidatorOptions, "serviceMap"> & {
|
|
616
639
|
serviceMap?: DgpServiceMap;
|
|
@@ -636,6 +659,8 @@ interface Builder {
|
|
|
636
659
|
* NOTE: keys are “button ids”: either option.id or field.id for option-less buttons.
|
|
637
660
|
*/
|
|
638
661
|
visibleFields(tagId: string, selectedOptionKeys?: string[]): string[];
|
|
662
|
+
/** Compute field ids plus option visibility under a tag. */
|
|
663
|
+
resolveVisibility(tagId: string, selectedOptionKeys?: string[]): ResolvedVisibility;
|
|
639
664
|
/** Update builder options (validator context etc.) */
|
|
640
665
|
setOptions(patch: Partial<BuilderOptions>): void;
|
|
641
666
|
/** Access the current props (already normalised) */
|
|
@@ -716,6 +741,8 @@ type VisibleGroup = {
|
|
|
716
741
|
tag?: Tag;
|
|
717
742
|
fields: Field[];
|
|
718
743
|
fieldIds: string[];
|
|
744
|
+
optionsByFieldId?: Record<string, string[]>;
|
|
745
|
+
forcedFieldIds?: string[];
|
|
719
746
|
parentTags?: Tag[];
|
|
720
747
|
childrenTags?: Tag[];
|
|
721
748
|
/** In order of selection: tag base (unless overridden) then selected options */
|
|
@@ -765,11 +792,10 @@ declare class Selection {
|
|
|
765
792
|
* What counts as a "button selection" (trigger key):
|
|
766
793
|
* - field key where the field has button === true (e.g. "f:dripfeed")
|
|
767
794
|
* - option key (e.g. "o:fast")
|
|
768
|
-
* - composite key "fieldId::optionId" (e.g. "f:speed::o:fast")
|
|
769
795
|
*
|
|
770
796
|
* Grouping:
|
|
771
797
|
* - button-field trigger groups under its own fieldId
|
|
772
|
-
* - option
|
|
798
|
+
* - option trigger groups under the option's owning fieldId (from nodeMap)
|
|
773
799
|
*
|
|
774
800
|
* Deterministic:
|
|
775
801
|
* - preserves selection insertion order
|
|
@@ -780,7 +806,6 @@ declare class Selection {
|
|
|
780
806
|
* Returns only selection keys that are valid "trigger buttons":
|
|
781
807
|
* - field keys where field.button === true
|
|
782
808
|
* - option keys
|
|
783
|
-
* - composite keys "fieldId::optionId" (validated by optionId)
|
|
784
809
|
* Excludes tags and non-button fields.
|
|
785
810
|
*/
|
|
786
811
|
selectedButtons(): string[];
|
|
@@ -790,6 +815,7 @@ declare class Selection {
|
|
|
790
815
|
private computeGroupForTag;
|
|
791
816
|
private addServiceByRole;
|
|
792
817
|
private findOptionById;
|
|
818
|
+
private isSelectedOptionVisible;
|
|
793
819
|
}
|
|
794
820
|
|
|
795
821
|
type CatalogId = string;
|
|
@@ -1511,6 +1537,69 @@ type QuantityRule = {
|
|
|
1511
1537
|
fallback?: number;
|
|
1512
1538
|
};
|
|
1513
1539
|
|
|
1540
|
+
/** Matches your InputWrapper’s expectations */
|
|
1541
|
+
type InputKind = string;
|
|
1542
|
+
type InputVariant = "default" | (string & {});
|
|
1543
|
+
type AdapterCtx = {
|
|
1544
|
+
field: Field;
|
|
1545
|
+
props: ServiceProps;
|
|
1546
|
+
};
|
|
1547
|
+
type Adapter = {
|
|
1548
|
+
valueProp?: string;
|
|
1549
|
+
changeProp?: string;
|
|
1550
|
+
errorProp?: string;
|
|
1551
|
+
/** normalize what the host emitted into what we store in form-palette */
|
|
1552
|
+
getValue?: (next: unknown, current: unknown, ctx: AdapterCtx) => unknown;
|
|
1553
|
+
/** REQUIRED if field.options exists */
|
|
1554
|
+
getSelectedOptions?: (next: unknown, current: unknown, ctx: AdapterCtx) => string[];
|
|
1555
|
+
/** For option-less action buttons (button: true with no options) */
|
|
1556
|
+
isActive?: (stored: unknown, ctx: AdapterCtx) => boolean;
|
|
1557
|
+
getInputPropsFromField?: (props: AdapterCtx) => any;
|
|
1558
|
+
toValue?: (value: any) => any;
|
|
1559
|
+
};
|
|
1560
|
+
type InputChildOptionCapability = {
|
|
1561
|
+
supported?: boolean;
|
|
1562
|
+
autoCreate?: boolean;
|
|
1563
|
+
defaultLabel?: string;
|
|
1564
|
+
defaultValue?: string | number;
|
|
1565
|
+
};
|
|
1566
|
+
type InputOptionCapability = {
|
|
1567
|
+
supported?: boolean;
|
|
1568
|
+
autoCreate?: boolean;
|
|
1569
|
+
defaultLabel?: string;
|
|
1570
|
+
defaultValue?: string | number;
|
|
1571
|
+
children?: InputChildOptionCapability;
|
|
1572
|
+
};
|
|
1573
|
+
type InputMultiCapability = {
|
|
1574
|
+
supported?: boolean;
|
|
1575
|
+
autoEnable?: boolean;
|
|
1576
|
+
};
|
|
1577
|
+
type InputDescriptor = {
|
|
1578
|
+
Component: React.ComponentType<Record<string, unknown>>;
|
|
1579
|
+
adapter?: Adapter;
|
|
1580
|
+
defaultProps?: Record<string, unknown>;
|
|
1581
|
+
ui?: Record<string, Ui>;
|
|
1582
|
+
options?: InputOptionCapability;
|
|
1583
|
+
multi?: InputMultiCapability;
|
|
1584
|
+
};
|
|
1585
|
+
type VariantMap = Map<InputVariant, InputDescriptor>;
|
|
1586
|
+
type RegistryStore = Map<InputKind, VariantMap>;
|
|
1587
|
+
type Registry = {
|
|
1588
|
+
get(kind: InputKind, variant?: InputVariant): InputDescriptor | undefined;
|
|
1589
|
+
register(kind: InputKind, descriptor: InputDescriptor, variant?: InputVariant): void;
|
|
1590
|
+
unregister(kind: InputKind, variant?: InputVariant): void;
|
|
1591
|
+
registerMany(entries: Array<{
|
|
1592
|
+
kind: InputKind;
|
|
1593
|
+
descriptor: InputDescriptor;
|
|
1594
|
+
variant?: InputVariant;
|
|
1595
|
+
}>): void;
|
|
1596
|
+
/** low-level escape hatch */
|
|
1597
|
+
_store: RegistryStore;
|
|
1598
|
+
};
|
|
1599
|
+
declare function createInputRegistry(): Registry;
|
|
1600
|
+
/** Helper used by InputWrapper */
|
|
1601
|
+
declare function resolveInputDescriptor(registry: Registry, kind: InputKind, variant?: InputVariant): InputDescriptor | undefined;
|
|
1602
|
+
|
|
1514
1603
|
declare class Editor {
|
|
1515
1604
|
private readonly builder;
|
|
1516
1605
|
private readonly api;
|
|
@@ -1582,7 +1671,14 @@ declare class Editor {
|
|
|
1582
1671
|
id?: string;
|
|
1583
1672
|
label: string;
|
|
1584
1673
|
type: Field["type"];
|
|
1585
|
-
}):
|
|
1674
|
+
}): string;
|
|
1675
|
+
addFieldFromDescriptor(registry: Registry, partial: Omit<Field, "id" | "label" | "type"> & {
|
|
1676
|
+
id?: string;
|
|
1677
|
+
label: string;
|
|
1678
|
+
type: Field["type"];
|
|
1679
|
+
}, opts?: {
|
|
1680
|
+
variant?: InputVariant;
|
|
1681
|
+
}): string;
|
|
1586
1682
|
updateField(id: string, patch: Partial<Field>): void;
|
|
1587
1683
|
removeField(id: string): void;
|
|
1588
1684
|
remove(id: string): void;
|
|
@@ -1601,6 +1697,7 @@ declare class Editor {
|
|
|
1601
1697
|
setPricingRoleMany(ids: readonly string[], role: "base" | "utility"): void;
|
|
1602
1698
|
clearFieldDefaultsMany(ids: readonly string[]): void;
|
|
1603
1699
|
clearFieldValidationMany(ids: readonly string[]): void;
|
|
1700
|
+
setFieldMulti(fieldId: string, enabled: boolean): void;
|
|
1604
1701
|
autoCreateOptionsMany(ids: readonly string[], makeOption?: (fieldId: string) => {
|
|
1605
1702
|
id?: string;
|
|
1606
1703
|
label: string;
|
|
@@ -1615,6 +1712,14 @@ declare class Editor {
|
|
|
1615
1712
|
clearFieldQuantityRule(id: string): void;
|
|
1616
1713
|
include(receiverId: string, idOrIds: string | string[]): void;
|
|
1617
1714
|
exclude(receiverId: string, idOrIds: string | string[]): void;
|
|
1715
|
+
setOptionEffect(triggerId: string, targetFieldId: string, effect: OptionEffectForButton | undefined | null): void;
|
|
1716
|
+
patchOptionEffect(triggerId: string, targetFieldId: string, patch: OptionEffectForButton): void;
|
|
1717
|
+
clearOptionEffect(triggerId: string, targetFieldId: string): void;
|
|
1718
|
+
clearOptionEffectsForTrigger(triggerId: string): void;
|
|
1719
|
+
clearOptionEffectsForTarget(targetFieldId: string): void;
|
|
1720
|
+
addOptionEffectOptions(triggerId: string, targetFieldId: string, kind: "include" | "exclude", optionIds: readonly string[]): void;
|
|
1721
|
+
removeOptionEffectOptions(triggerId: string, targetFieldId: string, kind: "include" | "exclude", optionIds: readonly string[]): void;
|
|
1722
|
+
setOptionEffectForceVisible(triggerId: string, targetFieldId: string, forceVisible: boolean | undefined): void;
|
|
1618
1723
|
connect(kind: WireKind, fromId: string, toId: string): void;
|
|
1619
1724
|
disconnect(kind: WireKind, fromId: string, toId: string): void;
|
|
1620
1725
|
setConstraint(tagId: string, flag: string, value: boolean | undefined): void;
|
|
@@ -1825,57 +1930,6 @@ type FormProviderProps = {
|
|
|
1825
1930
|
};
|
|
1826
1931
|
declare function FormProvider({ children, schema, initial }: FormProviderProps): react_jsx_runtime.JSX.Element;
|
|
1827
1932
|
|
|
1828
|
-
/** Matches your InputWrapper’s expectations */
|
|
1829
|
-
type InputKind = string;
|
|
1830
|
-
type InputVariant = "default" | (string & {});
|
|
1831
|
-
type AdapterCtx = {
|
|
1832
|
-
field: Field;
|
|
1833
|
-
props: ServiceProps;
|
|
1834
|
-
};
|
|
1835
|
-
type Adapter = {
|
|
1836
|
-
valueProp?: string;
|
|
1837
|
-
changeProp?: string;
|
|
1838
|
-
errorProp?: string;
|
|
1839
|
-
/** normalize what the host emitted into what we store in form-palette */
|
|
1840
|
-
getValue?: (next: unknown, current: unknown, ctx: AdapterCtx) => unknown;
|
|
1841
|
-
/** REQUIRED if field.options exists */
|
|
1842
|
-
getSelectedOptions?: (next: unknown, current: unknown, ctx: AdapterCtx) => string[];
|
|
1843
|
-
/** For option-less action buttons (button: true with no options) */
|
|
1844
|
-
isActive?: (stored: unknown, ctx: AdapterCtx) => boolean;
|
|
1845
|
-
getInputPropsFromField?: (props: AdapterCtx) => any;
|
|
1846
|
-
toValue?: (value: any) => any;
|
|
1847
|
-
};
|
|
1848
|
-
type InputOptionCapability = {
|
|
1849
|
-
supported?: boolean;
|
|
1850
|
-
autoCreate?: boolean;
|
|
1851
|
-
defaultLabel?: string;
|
|
1852
|
-
defaultValue?: string | number;
|
|
1853
|
-
};
|
|
1854
|
-
type InputDescriptor = {
|
|
1855
|
-
Component: React.ComponentType<Record<string, unknown>>;
|
|
1856
|
-
adapter?: Adapter;
|
|
1857
|
-
defaultProps?: Record<string, unknown>;
|
|
1858
|
-
ui?: Record<string, Ui>;
|
|
1859
|
-
options?: InputOptionCapability;
|
|
1860
|
-
};
|
|
1861
|
-
type VariantMap = Map<InputVariant, InputDescriptor>;
|
|
1862
|
-
type RegistryStore = Map<InputKind, VariantMap>;
|
|
1863
|
-
type Registry = {
|
|
1864
|
-
get(kind: InputKind, variant?: InputVariant): InputDescriptor | undefined;
|
|
1865
|
-
register(kind: InputKind, descriptor: InputDescriptor, variant?: InputVariant): void;
|
|
1866
|
-
unregister(kind: InputKind, variant?: InputVariant): void;
|
|
1867
|
-
registerMany(entries: Array<{
|
|
1868
|
-
kind: InputKind;
|
|
1869
|
-
descriptor: InputDescriptor;
|
|
1870
|
-
variant?: InputVariant;
|
|
1871
|
-
}>): void;
|
|
1872
|
-
/** low-level escape hatch */
|
|
1873
|
-
_store: RegistryStore;
|
|
1874
|
-
};
|
|
1875
|
-
declare function createInputRegistry(): Registry;
|
|
1876
|
-
/** Helper used by InputWrapper */
|
|
1877
|
-
declare function resolveInputDescriptor(registry: Registry, kind: InputKind, variant?: InputVariant): InputDescriptor | undefined;
|
|
1878
|
-
|
|
1879
1933
|
type InputsCtxValue = {
|
|
1880
1934
|
registry: Registry;
|
|
1881
1935
|
register: (kind: InputKind, descriptor: InputDescriptor, variant?: InputVariant) => void;
|
|
@@ -2026,6 +2080,8 @@ type UseOrderFlowReturn = {
|
|
|
2026
2080
|
raw: ServiceProps;
|
|
2027
2081
|
/** visibility is Selection-only */
|
|
2028
2082
|
visibleGroup: VisibleGroup | null;
|
|
2083
|
+
visibleOptionsByFieldId: Record<string, string[]>;
|
|
2084
|
+
forcedFieldIds: string[];
|
|
2029
2085
|
/**
|
|
2030
2086
|
* Values are from form-palette (values()) and are already "visible-only"
|
|
2031
2087
|
* because your UI mounts only visible fields.
|
|
@@ -2045,6 +2101,7 @@ type UseOrderFlowReturn = {
|
|
|
2045
2101
|
max: number;
|
|
2046
2102
|
selectTag: (tagId: string) => void;
|
|
2047
2103
|
toggleOption: (fieldId: string, optionId?: string) => void;
|
|
2104
|
+
setFieldOptions: (fieldId: string, optionIds: string[]) => void;
|
|
2048
2105
|
/** programmatic value set (rare; wrapper/field hook should handle most) */
|
|
2049
2106
|
setValue: (fieldId: string, value: Scalar | Scalar[]) => void;
|
|
2050
2107
|
clearField: (fieldId: string) => void;
|
|
@@ -2283,4 +2340,4 @@ type Props = {
|
|
|
2283
2340
|
};
|
|
2284
2341
|
declare function FallbackAddRegistrationDialog({ open, onClose, onSelect, }: Props): react_jsx_runtime.JSX.Element | null;
|
|
2285
2342
|
|
|
2286
|
-
export { type Adapter, type AdapterCtx, CanvasAPI, type EditorSettings, EventBus, type EventMap, FallbackAddCandidatesDialog, FallbackAddRegistrationDialog, FallbackDetailsPanel, FallbackEditor, type FallbackEditorData, FallbackEditorHeader, FallbackEditorProvider, type FallbackEditorProviderProps, FallbackRegistrationsPanel, FallbackServiceSidebar, FallbackSettingsPanel, type FormApi, FormProvider, type FormProviderProps, type FormSnapshot, type InputDescriptor, type InputKind, type InputOptionCapability, type InputVariant, type InputWrapperProps, OrderFlowProvider, Provider, type RegistrationItem, type RegistrationScope, type Registry, type ServiceSummary, type ValidationMessage, type ValidationTone, VirtualServiceList, Wrapper, createInputRegistry, registerEntries, resolveInputDescriptor, useActiveFallbackRegistrations, useEligibleServiceList, useFallbackEditor, useFallbackEditorContext, useFormApi, useInputs, useInputsMaybe, useOptionalFormApi, useOrderFlow, useOrderFlowContext, usePrimaryServiceList };
|
|
2343
|
+
export { type Adapter, type AdapterCtx, CanvasAPI, type EditorSettings, EventBus, type EventMap, FallbackAddCandidatesDialog, FallbackAddRegistrationDialog, FallbackDetailsPanel, FallbackEditor, type FallbackEditorData, FallbackEditorHeader, FallbackEditorProvider, type FallbackEditorProviderProps, FallbackRegistrationsPanel, FallbackServiceSidebar, FallbackSettingsPanel, type FormApi, FormProvider, type FormProviderProps, type FormSnapshot, type InputChildOptionCapability, type InputDescriptor, type InputKind, type InputMultiCapability, type InputOptionCapability, type InputVariant, type InputWrapperProps, OrderFlowProvider, Provider, type RegistrationItem, type RegistrationScope, type Registry, type ServiceSummary, type ValidationMessage, type ValidationTone, VirtualServiceList, Wrapper, createInputRegistry, registerEntries, resolveInputDescriptor, useActiveFallbackRegistrations, useEligibleServiceList, useFallbackEditor, useFallbackEditorContext, useFormApi, useInputs, useInputsMaybe, useOptionalFormApi, useOrderFlow, useOrderFlowContext, usePrimaryServiceList };
|