@spiffcommerce/core 0.9.1 → 0.9.3

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/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Workflow as _Workflow1, StepAspect as _StepAspect1, Step as _Step1, AnyStepData as _AnyStepData1, FrameOffsets, PatternImageData, IServerModel, Asset as _Asset1, MaterialResource, AssetType as _AssetType1, ColorDefinition as _ColorDefinition1, IllustrationStepData as _IllustrationStepData1, Region, ILayout as _ILayout1, CreateElementCommand as _CreateElementCommand1, IllustrationElement as _IllustrationElement1, LayoutsState as _LayoutsState1, VariantResource as _VariantResource1, CanvasCommand as _CanvasCommand1, LayoutData as _LayoutData1, DigitalContentStepData as _DigitalContentStepData1, FrameStepData as _FrameStepData1, FrameElement as _FrameElement1, MaterialStepData as _MaterialStepData1, ModelStepData as _ModelStepData1, ModuleStepData as _ModuleStepData1, PatchworkStepData as _PatchworkStepData1, PatchworkOffsets as _PatchworkOffsets1, PictureStepData as _PictureStepData1, QuestionStepData as _QuestionStepData1, ShapeStepData as _ShapeStepData1, FontData, GroupCommand as _GroupCommand1, OptionResource as _OptionResource1, TextboxElement as _TextboxElement1, TextStepData as _TextStepData1, StepStorage as _StepStorage1, SerializableStep, CommandState as _CommandState1, CommandContext as _CommandContext1, Point, ScaleAxis, UnitOfMeasurement as _UnitOfMeasurement1, StepType as _StepType1, Animatable, AnyStepData, Asset, AssetType, BringForwardCommand, BulkStepData, CanvasCommand, ColorDefinition, CommandContext, CommandState, CreateElementCommand, DeleteElementCommand, DigitalContentStepData, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameStepData, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, ImageElement, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutsState, MaterialStepData, ModelStepData, ModuleStepData, MoveCommand, OptionResource, PatchworkElement, PatchworkOffsets, PatchworkStepData, PictureStepData, QuestionStepData, ResizeCommand, RotateCommand, SendBackwardsCommand, ShapeStepData, Step, StepAspect, StepAspectType, StepStorage, StepType, TextChangeCommand, TextStepData, TextboxElement, UnitOfMeasurement, VariantResource, Workflow, dataUrlFromExternalUrl, findElement, frameDataCache, generate, generateSVGWithUnknownColors, getAttributesFromArrayBuffer, getFrameData, getSvgString, loadFontFromDataUrl, loadFontFromExternalUrl, patternImageDataCache, CreateLayoutCommand, rehydrateSerializedLayout, ColorProfileProps, WorkflowPanel, determineCorrectFontSizeAndLines, registerJSDOM } from "@spiffcommerce/papyrus";
1
+ import { Workflow as _Workflow1, StepAspect as _StepAspect1, Step as _Step1, AnyStepData as _AnyStepData1, FrameOffsets, PatternImageData, IServerModel, Asset as _Asset1, MaterialResource, AssetType as _AssetType1, ColorDefinition as _ColorDefinition1, IllustrationStepData as _IllustrationStepData1, Region, ILayout as _ILayout1, CreateElementCommand as _CreateElementCommand1, IllustrationElement as _IllustrationElement1, LayoutsState as _LayoutsState1, VariantResource as _VariantResource1, CanvasCommand as _CanvasCommand1, LayoutData as _LayoutData1, DigitalContentStepData as _DigitalContentStepData1, FrameStepData as _FrameStepData1, FrameElement as _FrameElement1, MaterialStepData as _MaterialStepData1, ModelStepData as _ModelStepData1, ModuleStepData as _ModuleStepData1, PatchworkStepData as _PatchworkStepData1, PatchworkOffsets as _PatchworkOffsets1, PictureStepData as _PictureStepData1, QuestionStepData as _QuestionStepData1, ShapeStepData as _ShapeStepData1, FontData, GroupCommand as _GroupCommand1, OptionResource as _OptionResource1, TextboxElement as _TextboxElement1, TextStepData as _TextStepData1, StepStorage as _StepStorage1, SerializableStep, CommandState as _CommandState1, LayoutState, CommandContext as _CommandContext1, Point, ScaleAxis, UnitOfMeasurement as _UnitOfMeasurement1, StepType as _StepType1, Animatable, AnyStepData, Asset, AssetType, BringForwardCommand, BulkStepData, CanvasCommand, ColorDefinition, CommandContext, CommandState, CreateElementCommand, DeleteElementCommand, DigitalContentStepData, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameStepData, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, ImageElement, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutsState, MaterialStepData, ModelStepData, ModuleStepData, MoveCommand, OptionResource, PatchworkElement, PatchworkOffsets, PatchworkStepData, PictureStepData, QuestionStepData, ResizeCommand, RotateCommand, SendBackwardsCommand, ShapeStepData, Step, StepAspect, StepAspectType, StepStorage, StepType, TextChangeCommand, TextStepData, TextboxElement, UnitOfMeasurement, VariantResource, Workflow, dataUrlFromExternalUrl, findElement, frameDataCache, generate, generateSVGWithUnknownColors, getAttributesFromArrayBuffer, getFrameData, getSvgString, loadFontFromDataUrl, loadFontFromExternalUrl, patternImageDataCache, CreateLayoutCommand, rehydrateSerializedLayout, ColorProfileProps, WorkflowPanel, determineCorrectFontSizeAndLines, registerJSDOM } from "@spiffcommerce/papyrus";
2
2
  import { ApolloClient } from "@apollo/client";
3
3
  import { ReactNode, Dispatch, FunctionComponent, RefObject, PointerEvent, KeyboardEvent, MouseEvent } from "react";
4
4
  export const gatherVaryingStepAspects: (workflow: _Workflow1) => _StepAspect1[];
@@ -293,44 +293,27 @@ interface TextError {
293
293
  }
294
294
  declare class TextStepService implements StepService<_TextStepData1> {
295
295
  init(stepData: _Step1<_TextStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
296
- /**
297
- * @deprecated Only returns the first element. see findLayoutElements. A step can have multiple and we should return all of them!
298
- */
299
- findLayoutElement(workflowManager: WorkflowManager, step: _Step1<_TextStepData1>, getAllLayouts: () => any[]): _TextboxElement1;
300
- findLayoutElements(workflowManager: WorkflowManager, step: _Step1<_TextStepData1>, getAllLayouts: () => any[]): _TextboxElement1[];
296
+ findLayoutElements(workflowManager: WorkflowManager, step: _Step1<_TextStepData1>): _TextboxElement1[];
301
297
  /**
302
298
  * Get the colors that can be used for a given text step.
303
299
  * @param stepData The text step to get colors for.
304
300
  * @returns A list of color objects containg fill, stroke and variant if available.
305
301
  */
306
302
  availableColors(stepData: _Step1<_TextStepData1>): ColorOption[];
307
- createTextFillSpotColor(colorOption: IServerModel<_OptionResource1>, variant: _VariantResource1): TextFillSpotColor | undefined;
308
- changeColor(stepData: _Step1<_TextStepData1>, newColor: ColorOption, elements: RegionElement[], workflowManager: WorkflowManager): Promise<void>;
303
+ changeFill(stepData: _Step1<_TextStepData1>, newColor: ColorOption, elements: RegionElement[], workflowManager: WorkflowManager): Promise<void>;
309
304
  /**
310
305
  * Given an element and a string, filters any characters from the string that are
311
306
  * not supported by the font of the given element.
312
307
  * @param layoutElement The element to use for glyph lookup.
313
308
  * @param text The text string to filter.
309
+ * @param fontData An optional fontData object, when provided, we use the font table to determine glyphs that aren't provided and additionally strip these out also.
314
310
  * @returns A new string representing the passed string with unsupported characters removed.
315
311
  */
316
- filterUnsupportedCharacters: (layoutElement: _TextboxElement1 | undefined, text: string) => string;
317
- updateInputText(input: string, customiseAllText: boolean, elements: _TextboxElement1[], step: _Step1<_TextStepData1>, storage: TextStepStorage, workflowManager: WorkflowManager): TextUpdateResult;
318
- /**
319
- * @deprecated
320
- */
321
- changeInputTextWithRegion(step: _Step1<_TextStepData1>,
322
- /**
323
- * @deprecated
324
- */
325
- curFontSize: number,
326
- /**
327
- * @deprecated
328
- */
329
- curFontData: FontData, input: string, storage: TextStepStorage, workflowManager: WorkflowManager, customiseAllText: boolean, setError: (status: boolean) => void, setHelperText: (text: string) => void, setFlashRedError?: (status: boolean) => void): Promise<_GroupCommand1 | undefined>;
330
- selectVariant(step: _Step1<_TextStepData1>, variant: _VariantResource1, storage: TextStepStorage, elements: RegionElement[], workflowManager: WorkflowManager, customiseAllText: boolean, setError: (status: boolean) => void, setHelperText: (text: string) => void): void;
331
- fontDataFromVariant(variant: _VariantResource1): Promise<FontData>;
332
- findOrCreateElements(workflowManager: WorkflowManager, step: _Step1<_TextStepData1>, getAllLayouts: () => any[]): Promise<_TextboxElement1[]>;
312
+ filterUnsupportedCharacters: (text: string, fontData?: FontData) => string;
313
+ updateInputText(input: string, elements: _TextboxElement1[], step: _Step1<_TextStepData1>, workflowManager: WorkflowManager): TextUpdateResult;
314
+ selectVariant(step: _Step1<_TextStepData1>, variant: _VariantResource1, storage: TextStepStorage, elements: RegionElement[], workflowManager: WorkflowManager, setError: (status: boolean) => void, setHelperText: (text: string) => void): void;
333
315
  textAlign: (stepData: _TextStepData1) => string;
316
+ createTextFillSpotColor(colorOption: IServerModel<_OptionResource1>, variant: _VariantResource1): TextFillSpotColor | undefined;
334
317
  }
335
318
  export const textStepService: TextStepService;
336
319
  declare abstract class ModuleProduct {
@@ -430,6 +413,7 @@ export interface WorkflowManager {
430
413
  getCurrentVariationRecord: () => VariationRecord | undefined;
431
414
  getVariationRecords: () => VariationRecord[];
432
415
  getLayouts: () => _ILayout1[];
416
+ getAllLayoutData: () => LayoutState[];
433
417
  getLayoutPreviewService: () => any;
434
418
  getPreviewService: () => any | undefined;
435
419
  getProductName: () => string | undefined;
@@ -437,6 +421,9 @@ export interface WorkflowManager {
437
421
  getRegionElements: (stepName: string) => RegionElement[];
438
422
  getSerializedStep: (stepName: string, serializedSteps: SerializableStep[]) => SerializableStep | undefined;
439
423
  getStepSpecificServices: (stepName: string) => StepSpecificServices | undefined;
424
+ getStepStorage: (stepName: string) => _StepStorage1 | undefined;
425
+ getMetadata: (stepName: string) => StepMetadata | undefined;
426
+ getInformationResults(): InformationResult[];
440
427
  getTransaction: () => Transaction;
441
428
  getWorkflow: () => _Workflow1;
442
429
  getWorkflowSelections: () => WorkflowSelections;
@@ -734,11 +721,12 @@ interface TextMetadata {
734
721
  export interface SelectionStorage {
735
722
  selectedVariants?: _VariantResource1[];
736
723
  }
737
- interface TextStepStorage extends SelectionStorage {
724
+ export interface TextStepStorage extends SelectionStorage {
738
725
  color?: string;
739
726
  defaultCleared?: boolean;
740
727
  inputText?: string;
741
728
  text?: string;
729
+ customiseAllText?: boolean;
742
730
  }
743
731
  type StepSelections = {
744
732
  [key: string]: SelectionStorage;
@@ -1043,6 +1031,31 @@ interface StorageService {
1043
1031
  setMap(key: string, val: Map<any, any>): void;
1044
1032
  }
1045
1033
  export const persistenceService: StorageService;
1034
+ /**
1035
+ * An abstract base class to be extended by step handles to implement type specific behavior.
1036
+ */
1037
+ declare abstract class StepHandleTypeContext<T> {
1038
+ protected readonly manager: WorkflowManager;
1039
+ protected readonly step: _Step1<T>;
1040
+ constructor(manager: WorkflowManager, stepConfiguration: _Step1<T>);
1041
+ }
1042
+ interface TextChangeResult {
1043
+ input: string;
1044
+ helperText?: string;
1045
+ errorText?: string;
1046
+ }
1047
+ declare class StepHandleTextContext extends StepHandleTypeContext<_TextStepData1> {
1048
+ /**
1049
+ * Changes the fill of text related to this step to the new fill value.
1050
+ * @param fill A new fill value to use.
1051
+ */
1052
+ setFill(fill: ColorOption): Promise<void>;
1053
+ /**
1054
+ * Changes the text value of text related to this step to a new value.
1055
+ * @param userInput Input from the user.
1056
+ */
1057
+ setText(userInput: string): TextChangeResult;
1058
+ }
1046
1059
  /**
1047
1060
  * A StepHandle allows for managing the state of a specific step in a workflow. This class
1048
1061
  * abstracts away the complexities of dealing with a step directly and allows for using high level
@@ -1061,6 +1074,14 @@ interface StepHandle {
1061
1074
  * Selects a specific variant for this step.
1062
1075
  */
1063
1076
  selectVariant(variant: _VariantResource1): any;
1077
+ /**
1078
+ * Get a handle to a class that exposes any functionality specific to this step type.
1079
+ */
1080
+ getTypeSpecificContext(): StepHandleTextContext | StepHandleIllustrationContext | StepHandleQuestionContext;
1081
+ }
1082
+ declare class StepHandleIllustrationContext extends StepHandleTypeContext<_IllustrationStepData1> {
1083
+ }
1084
+ declare class StepHandleQuestionContext extends StepHandleTypeContext<_QuestionStepData1> {
1064
1085
  }
1065
1086
  /**
1066
1087
  * A Workflow experience encapsulates the workflow manager and command context. It
@@ -1173,6 +1194,10 @@ export class Client {
1173
1194
  getTransaction(): Transaction;
1174
1195
  }
1175
1196
  export class MockWorkflowManager implements WorkflowManager {
1197
+ getAllLayoutData: () => LayoutState[];
1198
+ getMetadata: (stepName: string) => StepMetadata | undefined;
1199
+ getStepStorage: (stepName: string) => _StepStorage1 | undefined;
1200
+ getInformationResults(): InformationResult[];
1176
1201
  getVariationRecords(): VariationRecord[];
1177
1202
  reset(): Promise<void>;
1178
1203
  updateStateWithServer(_getReducerState: () => _CommandState1): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "Core client API for interacting with the Spiff Commerce backend.",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",
@@ -45,7 +45,6 @@
45
45
  "@types/lodash.clonedeep": "^4.5.7",
46
46
  "@types/lodash.debounce": "^4.0.7",
47
47
  "@types/lodash.isequal": "^4.5.6",
48
- "@types/offscreencanvas": "^2019.7.0",
49
48
  "@types/opentype.js": "^0.7.2",
50
49
  "@types/qrcode": "^1.3.5",
51
50
  "@types/react": "^17.0.9",